Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:19

0001 
0002 // Copyright 2020, Jefferson Science Associates, LLC.
0003 // Subject to the terms in the LICENSE file found in the top-level directory.
0004 
0005 
0006 #ifndef JANA2_JHITCALIBRATOR_H
0007 #define JANA2_JHITCALIBRATOR_H
0008 
0009 #include <JANA/JEventProcessor.h>
0010 #include <JANA/JEvent.h>
0011 #include <JANA/JBenchUtils.h>
0012 #include "AHit.h"
0013 
0014 /// AHitBHitFuser
0015 class AHitBHitFuser : public JEventProcessor {
0016 
0017 public:
0018     AHitAnomalyDetector(JApplication* app = nullptr, size_t delay_ms=1000)
0019         : JEventProcessor(app)
0020         , m_delay_ms(delay_ms) {
0021             SetCallbackStyle(CallbackStyle::ExpertMode);
0022         };
0023 
0024     void Init() override {
0025 
0026     }
0027     void Process(const JEvent& event) override {
0028 
0029         auto a_hits = event.Get<AHit>();
0030         auto b_hits = event.Get<BHit>();
0031         std::stringstream ss;
0032         ss << "AHit/BHit fusion: Event #" << event.GetEventNumber() << " : {";
0033         for (auto & hit : a_hits) {
0034             ss << "(" << hit->E << "," << hit->t << "), ";
0035         }
0036         ss << "}, ";
0037         for (auto & hit : b_hits) {
0038             ss << "(" << hit->E << "," << hit->t << "), ";
0039         }
0040         ss << "}" << std::endl;
0041         std::cout << ss.str();
0042 
0043         m_bench_utils.set_seed(event.GetEventNumber(), NAME_OF_THIS);
0044         m_bench_utils.consume_cpu_ms(m_delay_ms);
0045 
0046 
0047         auto raw_hits = event.Get<AHit>("raw_hits");
0048 
0049 
0050         std::cout << "Processing event #" << event.GetEventNumber() << std::endl;
0051         Serializer<AHit> serializer;
0052         for (auto & hit : raw_hits) {
0053             AHit* calibrated_hit = new DetectorAHit(*hit);
0054             calibrated_hit->V += 7;
0055             std::cout << serializer.serialize(*calibrated_hit) << std::endl;
0056         }
0057         m_bench_utils.consume_cpu_ms(m_delay_ms);
0058     }
0059     void Finish() override {
0060         std::cout << "Done!" << std::endl;
0061     }
0062 private:
0063     size_t m_delay_ms;
0064     JBenchUtils m_bench_utils = JBenchUtils();
0065 
0066 };
0067 
0068 
0069 #endif