5858#include " sbndaq-artdaq-core/Obj/SBND/pmtSoftwareTrigger.hh"
5959#include " sbndaq-artdaq-core/Obj/SBND/CRTmetric.hh"
6060
61+ #include " sbnobj/SBND/Timing/DAQTimestamp.hh"
62+
6163// Truth includes
6264// #include "larsim/MCCheater/BackTrackerService.h"
6365// #include "larsim/MCCheater/ParticleInventoryService.h"
@@ -127,6 +129,9 @@ class Hitdumper : public art::EDAnalyzer {
127129
128130 // Called at the beginning of every subrun
129131 virtual void beginSubRun (art::SubRun const & sr) override ;
132+
133+ void AnalyseTDCs (std::vector<art::Ptr<sbnd::timing::DAQTimestamp>> &TDCVec);
134+
130135private:
131136
132137 // / Resets the variables that are saved to the TTree
@@ -162,6 +167,11 @@ class Hitdumper : public art::EDAnalyzer {
162167 // / Resize the data structure for MCShowers
163168 void ResizeMCShower (int nShowers);
164169
170+ std::string fTDCModuleLabel ;
171+
172+ bool fHasTDC ;
173+
174+
165175 opdet::sbndPDMapAlg _pd_map;
166176
167177 TTree* fTree ;
@@ -438,6 +448,12 @@ class Hitdumper : public art::EDAnalyzer {
438448
439449 const int MAX_INT = std::numeric_limits<int >::max();
440450 const long int TIME_CORRECTION = (long int ) std::numeric_limits<int >::max() * 2 ;
451+
452+ std::vector<uint32_t > _tdc_channel;
453+ std::vector<uint64_t > _tdc_timestamp;
454+ std::vector<uint64_t > _tdc_offset;
455+ std::vector<std::string> _tdc_name;
456+
441457};
442458
443459
@@ -460,6 +476,9 @@ Hitdumper::Hitdumper(fhicl::ParameterSet const& pset)
460476void Hitdumper::reconfigure (fhicl::ParameterSet const & p)
461477{
462478
479+ fTDCModuleLabel = p.get <std::string>(" TDCModuleLabel" , " tdcdecoder" );
480+ fHasTDC = p.get <bool >(" HasTDC" , false );
481+
463482 _max_hits = p.get <int >(" MaxHits" , 50000 );
464483 _max_ophits = p.get <int >(" MaxOpHits" , 50000 );
465484 _max_samples = p.get <int >(" MaxSamples" , 5001 );
@@ -523,6 +542,24 @@ void Hitdumper::analyze(const art::Event& evt)
523542 _t0 = 0 .;
524543 // t0 = detprop->TriggerOffset(); // units of TPC ticks
525544
545+
546+ if (fHasTDC )
547+ {
548+ // Get TDCs
549+ art::Handle<std::vector<sbnd::timing::DAQTimestamp>> TDCHandle;
550+ evt.getByLabel (fTDCModuleLabel , TDCHandle);
551+ if (!TDCHandle.isValid ()){
552+ std::cout << " TDC product " << fTDCModuleLabel << " not found..." << std::endl;
553+ throw std::exception ();
554+ }
555+ std::vector<art::Ptr<sbnd::timing::DAQTimestamp>> TDCVec;
556+ art::fill_ptr_vector (TDCVec, TDCHandle);
557+
558+ // Fill TDC variables
559+ AnalyseTDCs (TDCVec);
560+ }
561+
562+
526563 //
527564 // Hits
528565 //
@@ -1190,6 +1227,15 @@ void Hitdumper::analyze(const art::Event& evt)
11901227 fTree ->Branch (" evttime" ,&_evttime," evttime/D" );
11911228 fTree ->Branch (" t0" ,&_t0," t0/I" );
11921229
1230+ if (fHasTDC )
1231+ {
1232+ fTree ->Branch (" tdc_channel" , " std::vector<uint32_t>" , &_tdc_channel);
1233+ fTree ->Branch (" tdc_timestamp" , " std::vector<uint64_t>" , &_tdc_timestamp);
1234+ fTree ->Branch (" tdc_offset" , " std::vector<uint64_t>" , &_tdc_offset);
1235+ fTree ->Branch (" tdc_name" , " std::vector<std::string>" , &_tdc_name);
1236+ }
1237+
1238+
11931239 fTree ->Branch (" nhits" , &_nhits, " nhits/I" );
11941240 fTree ->Branch (" hit_cryostat" , &_hit_cryostat);
11951241 fTree ->Branch (" hit_tpc" , &_hit_tpc);
@@ -1410,6 +1456,29 @@ void Hitdumper::analyze(const art::Event& evt)
14101456}
14111457
14121458
1459+ void Hitdumper::AnalyseTDCs (std::vector<art::Ptr<sbnd::timing::DAQTimestamp>> &TDCVec)
1460+ {
1461+ const unsigned nTDCs = TDCVec.size ();
1462+
1463+ _tdc_channel.resize (nTDCs);
1464+ _tdc_timestamp.resize (nTDCs);
1465+ _tdc_offset.resize (nTDCs);
1466+ _tdc_name.resize (nTDCs);
1467+
1468+ unsigned tdc_i = 0 ;
1469+
1470+ for (auto const & tdc : TDCVec)
1471+ {
1472+ _tdc_channel[tdc_i] = tdc->Channel ();
1473+ _tdc_timestamp[tdc_i] = tdc->Timestamp ();
1474+ _tdc_offset[tdc_i] = tdc->Offset ();
1475+ _tdc_name[tdc_i] = tdc->Name ();
1476+
1477+ ++tdc_i;
1478+ }
1479+ }
1480+
1481+
14131482void Hitdumper::ResetWireHitsVars (int n) {
14141483 _hit_cryostat.assign (n, DEFAULT_VALUE );
14151484 _hit_tpc.assign (n, DEFAULT_VALUE );
0 commit comments