Skip to content

Commit f5b77fd

Browse files
Merge pull request #618 from SBNSoftware/feature/rohanr_crtdqm_v2
Feature/rohanr crtdqm v2
2 parents 42d3a50 + 35f596b commit f5b77fd

3 files changed

Lines changed: 73 additions & 0 deletions

File tree

sbndcode/Commissioning/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ set(
2020
sbndcode_CRTUtils
2121
sbnobj::Common_CRT
2222
sbnobj::SBND_CRT
23+
sbnobj::SBND_Timing
2324
sbndaq_artdaq_core::sbndaq-artdaq-core_Obj_SBND
2425
nusimdata::SimulationBase
2526
art::Framework_Core

sbndcode/Commissioning/HitDumper_module.cc

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
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+
130135
private:
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)
460476
void 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+
14131482
void Hitdumper::ResetWireHitsVars(int n) {
14141483
_hit_cryostat.assign(n, DEFAULT_VALUE);
14151484
_hit_tpc.assign(n, DEFAULT_VALUE);

sbndcode/Commissioning/fcls/hitdumpermodule.fcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ hitdumper:
2727
MCParticleModuleLabel: "largeant"
2828
MCTrackModuleLabel: "mcreco"
2929
MCShowerModuleLabel: "mcreco"
30+
TDCModuleLabel: "tdcdecoder"
3031

3132
KeepCRTStripHits: true
3233
KeepCRTSpacePoints: true
@@ -41,6 +42,7 @@ hitdumper:
4142
readMCParticle: false
4243
savePOTinfo: true
4344
checkTransparency: false
45+
HasTDC: false
4446

4547
window: 100
4648

@@ -55,5 +57,6 @@ hitdumper:
5557
hitdumper_data: @local::hitdumper
5658
hitdumper_data.OpHitsModuleLabel: ["ophitpmt"] #only have PMT data as of 05/30/2024
5759
hitdumper_data.readTruth: false
60+
hitdumper_data.HasTDC: true
5861

5962
END_PROLOG

0 commit comments

Comments
 (0)