From 64f2fad3eab75d4f9cbb4b43234fcc6b9274ba0e Mon Sep 17 00:00:00 2001 From: Chengdong Fu <fucd@ihep.ac.cn> Date: Mon, 27 Jun 2022 23:18:23 +0800 Subject: [PATCH] remove info & add CPU time --- .../src/SiliconTrackingAlg.cpp | 30 +++++++++++++++++-- .../SiliconTracking/src/SiliconTrackingAlg.h | 9 ++++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.cpp b/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.cpp index 7fbb98e9..f9b6a546 100644 --- a/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.cpp +++ b/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.cpp @@ -34,6 +34,7 @@ #include "TrackSystemSvc/HelixFit.h" #include "TrackSystemSvc/IMarlinTrack.h" +#include <TStopwatch.h> //#include "TrackSystemSvc/MarlinTrkDiagnostics.h" //#ifdef MARLINTRK_DIAGNOSTICS_ON //#include "TrackSystemSvc/DiagnosticsController.h" @@ -104,7 +105,23 @@ StatusCode SiliconTrackingAlg::initialize() { _nRun = -1 ; _nEvt = 0 ; //printParameters() ; - + if(m_dumpTime){ + NTuplePtr nt1(ntupleSvc(), "MyTuples/Time"+name()); + if ( !nt1 ) { + m_tuple = ntupleSvc()->book("MyTuples/Time"+name(),CLID_ColumnWiseTuple,"Tracking time"); + if ( 0 != m_tuple ) { + m_tuple->addItem ("timeTotal", m_timeTotal ).ignore(); + m_tuple->addItem ("timeKalman", m_timeKalman ).ignore(); + } + else { + fatal() << "Cannot book MyTuples/Time"+name() <<endmsg; + return StatusCode::FAILURE; + } + } + else{ + m_tuple = nt1; + } + } // set up the geometery needed by KalTest //FIXME: for now do KalTest only - make this a steering parameter to use other fitters auto _trackSystemSvc = service<ITrackSystemSvc>("TrackSystemSvc"); @@ -157,6 +174,7 @@ StatusCode SiliconTrackingAlg::initialize() { } StatusCode SiliconTrackingAlg::execute(){ + auto stopwatch = TStopwatch(); Navigation::Instance()->Initialize(); //_current_event = evt; //_allHits.reserve(1000); @@ -355,6 +373,10 @@ StatusCode SiliconTrackingAlg::execute(){ CleanUp(); debug() << "Event is done " << endmsg; _nEvt++; + if(m_dumpTime&&m_tuple){ + m_timeTotal = stopwatch.RealTime()*1000; + m_tuple->write(); + } return StatusCode::SUCCESS; } @@ -907,7 +929,7 @@ StatusCode SiliconTrackingAlg::finalize(){ //delete _trksystem ; _trksystem = 0; //delete _histos ; _histos = 0; info() << "Processed " << _nEvt << " events " << endmsg; - info() << lcio::ILDCellID0::encoder_string << " " << UTIL::ILDCellID0::encoder_string << endmsg; + return GaudiAlgorithm::finalize(); } @@ -2545,6 +2567,7 @@ void SiliconTrackingAlg::FinalRefit(edm4hep::TrackCollection* trk_col) { float pyTot = 0.; float pzTot = 0.; debug() << "Total " << nTracks << " candidate tracks will be dealed" << endmsg; + auto stopwatch = TStopwatch(); for (int iTrk=0;iTrk<nTracks;++iTrk) { TrackExtended * trackAR = _trackImplVec[iTrk]; @@ -2886,7 +2909,8 @@ void SiliconTrackingAlg::FinalRefit(edm4hep::TrackCollection* trk_col) { } } } - + if(m_dumpTime&&m_tuple) m_timeKalman = stopwatch.RealTime()*1000; + debug() << " -> run " << _nRun << " event " << _nEvt << endmsg; debug() << "Number of Si tracks = " << nSiSegments << endmsg; debug() << "Total 4-momentum of Si Tracks : E = " << std::setprecision(7) << eTot diff --git a/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.h b/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.h index 7f584b26..e8e915b5 100644 --- a/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.h +++ b/Reconstruction/SiliconTracking/src/SiliconTrackingAlg.h @@ -27,6 +27,7 @@ #include <UTIL/BitField64.h> #include <UTIL/ILDConf.h> +#include "GaudiKernel/NTuple.h" //using namespace edm4hep ; namespace gear{ @@ -252,7 +253,7 @@ class SiliconTrackingAlg : public GaudiAlgorithm { Gaudi::Property<bool> _ElossOn{this, "EnergyLossOn", true}; Gaudi::Property<bool> _SmoothOn{this, "SmoothOn", true}; Gaudi::Property<float> _helix_max_r{this, "HelixMaxR", 2000.}; - + Gaudi::Property<bool> m_dumpTime{this, "DumpTime", true}; //std::vector<int> _colours; /** helper function to get collection using try catch block */ @@ -300,7 +301,11 @@ class SiliconTrackingAlg : public GaudiAlgorithm { std::vector<TrackerHitExtendedVec> _sectors; std::vector<TrackerHitExtendedVec> _sectorsFTD; - + + NTuple::Tuple* m_tuple; + NTuple::Item<float> m_timeTotal; + NTuple::Item<float> m_timeKalman; + /** * A helper class to allow good code readability by accessing tracks with N hits. * As the smalest valid track contains three hits, but the first index in a vector is 0, -- GitLab