// $Id$ // // File: JEventProcessor_TrackTiming.cc // Created: Mon Aug 25 01:59:59 PM EDT 2025 // Creator: staylor (on Linux ifarm2401.jlab.org 5.14.0-570.33.2.el9_6.x86_64 x86_64) // /// For more information on the syntax changes between JANA1 and JANA2, visit: https://jeffersonlab.github.io/JANA2/#/jana1to2/jana1-to-jana2 #include "JEventProcessor_TrackTiming.h" #include #include using namespace std::chrono; #include #include #include #include // Routine used to create our JEventProcessor #include extern "C"{ void InitPlugin(JApplication *app){ InitJANAPlugin(app); app->Add(new JEventProcessor_TrackTiming()); } } // "C" //------------------ // JEventProcessor_TrackTiming (Constructor) //------------------ JEventProcessor_TrackTiming::JEventProcessor_TrackTiming() { // Parameters and Services should be accessed from Init() instead of here! } //------------------ // ~JEventProcessor_TrackTiming (Destructor) //------------------ JEventProcessor_TrackTiming::~JEventProcessor_TrackTiming() { SetTypeName(NAME_OF_THIS); // Provide JANA with this class's name } //------------------ // Init //------------------ void JEventProcessor_TrackTiming::Init() { // This is called once at program startup. //auto app = GetApplication(); // lockService should be initialized here like this // lockService = app->GetService(); } //------------------ // BeginRun //------------------ void JEventProcessor_TrackTiming::BeginRun(const std::shared_ptr &event) { // This is called whenever the run number changes } //------------------ // Process //------------------ void JEventProcessor_TrackTiming::Process(const std::shared_ptr &event) { vectorpseudos; event->Get(pseudos); // Time stamp before pattern recognition high_resolution_clock::time_point t0 = high_resolution_clock::now(); vectorcandidates; event->Get(candidates); // Time stamp after pattern recognition high_resolution_clock::time_point t1 = high_resolution_clock::now(); duration time_span = duration_cast>(t1 - t0); cumulative_time+=double(time_span.count()); vectorwbtracks; event->Get(wbtracks); high_resolution_clock::time_point t2 = high_resolution_clock::now(); time_span = duration_cast>(t2 - t1); wb_cumulative_time+=double(time_span.count()); vectortbtracks; event->Get(tbtracks); high_resolution_clock::time_point t3 = high_resolution_clock::now(); time_span = duration_cast>(t3 - t2); tb_cumulative_time+=double(time_span.count()); cumulative_events+=1.0; } //------------------ // EndRun //------------------ void JEventProcessor_TrackTiming::EndRun() { // This is called whenever the run number changes, before it is // changed to give you a chance to clean up before processing // events from the next run number. } //------------------ // Finish //------------------ void JEventProcessor_TrackTiming::Finish() { cout << "Average track finding time = " << 1000.*cumulative_time/cumulative_events << " ms" << endl; cout << "Average wire-based track fitting time = " << 1000.*wb_cumulative_time/cumulative_events << " ms" << endl; cout << "Average time-based track fitting time = " << 1000.*tb_cumulative_time/cumulative_events << " ms" << endl; // Called before program exit after event processing is finished. }