Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 08:57:57

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/Utils/JBenchUtils.h>
0012 #include "AHit.h"
0013 #include "BHit.h"
0014 
0015 /// AHitBHitFuser
0016 class AHitBHitFuser : public JEventProcessor {
0017 
0018 public:
0019     AHitBHitFuser(size_t delay_ms=1000) : m_delay_ms(delay_ms) {
0020             SetCallbackStyle(CallbackStyle::ExpertMode);
0021         };
0022 
0023     void Init() override {
0024 
0025     }
0026     void Process(const JEvent& event) override {
0027 
0028         auto a_hits = event.Get<AHit>();
0029         auto b_hits = event.Get<BHit>();
0030         std::stringstream ss;
0031         ss << "AHit/BHit fusion: Event #" << event.GetEventNumber() << " : {";
0032         for (auto & hit : a_hits) {
0033             ss << "(" << hit->E << "," << hit->t << "), ";
0034         }
0035         ss << "}, ";
0036         for (auto & hit : b_hits) {
0037             ss << "(" << hit->E << "," << hit->t << "), ";
0038         }
0039         ss << "}" << std::endl;
0040         std::cout << ss.str();
0041 
0042         m_bench_utils.set_seed(event.GetEventNumber(), NAME_OF_THIS);
0043         m_bench_utils.consume_cpu_ms(m_delay_ms);
0044 
0045 
0046         auto raw_hits = event.Get<AHit>("raw_hits");
0047 
0048 
0049         std::cout << "Processing event #" << event.GetEventNumber() << std::endl;
0050         //Serializer<AHit> serializer;
0051         for (auto & hit : raw_hits) {
0052             AHit* calibrated_hit = new AHit(*hit);
0053             calibrated_hit->E += 7;
0054             //std::cout << serializer.serialize(*calibrated_hit) << std::endl;
0055         }
0056         m_bench_utils.consume_cpu_ms(m_delay_ms);
0057     }
0058     void Finish() override {
0059         std::cout << "Done!" << std::endl;
0060     }
0061 private:
0062     size_t m_delay_ms;
0063     JBenchUtils m_bench_utils = JBenchUtils();
0064 
0065 };
0066 
0067 
0068 #endif