Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:12:04

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 
0014 class AHitAnomalyDetector : public JEventProcessor {
0015 
0016 public:
0017     AHitAnomalyDetector(JApplication* app = nullptr, size_t delay_ms=1000)
0018         : JEventProcessor(app)
0019         , 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         std::stringstream ss;
0030         ss << "Anomaly detection: Event #" << event.GetEventNumber() << " : {";
0031         for (auto & hit : a_hits) {
0032             ss << "(" << hit->E << "," << hit->x << "), ";
0033         }
0034         ss << "}" << std::endl;
0035         std::cout << ss.str();
0036         m_bench_utils.set_seed(event.GetEventNumber(), NAME_OF_THIS);
0037         m_bench_utils.consume_cpu_ms(m_delay_ms);
0038     }
0039     void Finish() override {
0040         std::cout << "Anomaly detection: Done!" << std::endl;
0041     }
0042 private:
0043     size_t m_delay_ms;
0044     JBenchUtils m_bench_utils = JBenchUtils();
0045 
0046 };
0047 
0048 
0049 #endif