Skip to content

Commit 47d7427

Browse files
author
Brinden Carlson
committed
Merge branch 'release/v10_04_01_01'
2 parents b7420d1 + aff2e7c commit 47d7427

21 files changed

Lines changed: 220 additions & 86 deletions

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
1717

18-
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 10.04.01)
18+
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 10.04.01.01)
1919
find_package(cetmodules REQUIRED)
2020
project(sbndcode LANGUAGES CXX)
2121

2222
# for CI:
23-
# project(sbndcode VERSION 10.04.01)
23+
# project(sbndcode VERSION 10.04.01.01)
2424

2525
message(STATUS "\n")
2626
message(STATUS "================================= ${PROJECT_NAME} =================================")

sbndcode/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,4 @@ add_subdirectory(Decoders)
4444
add_subdirectory(ChannelMaps)
4545

4646
# for CVN
47-
# Disable for now
48-
#add_subdirectory(SBNDCVN)
47+
add_subdirectory(SBNDCVN)

sbndcode/CRT/CRTAna/CRTAnalysis_module.cc

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include "sbndcode/Geometry/GeometryWrappers/CRTGeoAlg.h"
3838
#include "sbndcode/Geometry/GeometryWrappers/TPCGeoAlg.h"
39+
#include "sbndcode/ChannelMaps/CRT/CRTChannelMapService.h"
3940
#include "sbndcode/CRT/CRTBackTracker/CRTBackTrackerAlg.h"
4041
#include "sbndcode/CRT/CRTUtils/CRTCommonUtils.h"
4142
#include "sbndcode/Decoders/PTB/sbndptb.h"
@@ -97,6 +98,8 @@ class sbnd::crt::CRTAnalysis : public art::EDAnalyzer {
9798
fCRTSpacePointMatchingModuleLabel, fCRTTrackMatchingModuleLabel, fPFPModuleLabel, fPTBModuleLabel,
9899
fTDCModuleLabel, fTimingReferenceModuleLabel;
99100
bool fDebug, fDataMode, fNoTPC, fHasPTB, fHasTDC;
101+
//! Adding some of the reco parameters to save corrections
102+
double fPEAttenuation, fTimeWalkNorm, fTimeWalkScale, fPropDelay;
100103

101104
TTree* fTree;
102105

@@ -181,6 +184,11 @@ class sbnd::crt::CRTAnalysis : public art::EDAnalyzer {
181184
std::vector<uint8_t> _cl_composition;
182185
std::vector<std::vector<uint32_t>> _cl_channel_set;
183186
std::vector<std::vector<uint16_t>> _cl_adc_set;
187+
std::vector<std::vector<uint32_t>> _cl_sh_ts0_set; //! To store t0 from x-y coincidences
188+
std::vector<std::vector<uint32_t>> _cl_sh_ts1_set; //! To store t1 from x-y coincidences
189+
std::vector<std::vector<uint16_t>> _cl_sh_feb_mac5_set; //! MAC5 addresses of StripHit FEBs
190+
std::vector<std::vector<double>> _cl_sh_time_walk_set; //! Time walk correction
191+
std::vector<std::vector<double>> _cl_sh_prop_delay_set; //! Light propagation correction
184192
std::vector<int> _cl_truth_trackid;
185193
std::vector<double> _cl_truth_completeness;
186194
std::vector<double> _cl_truth_purity;
@@ -340,6 +348,11 @@ sbnd::crt::CRTAnalysis::CRTAnalysis(fhicl::ParameterSet const& p)
340348
fNoTPC = p.get<bool>("NoTPC", false);
341349
fHasPTB = p.get<bool>("HasPTB", false);
342350
fHasTDC = p.get<bool>("HasTDC", false);
351+
//! Adding some of the reco parameters to save corrections
352+
fPEAttenuation = p.get<double>("PEAttenuation", 1.0);
353+
fTimeWalkNorm = p.get<double>("TimeWalkNorm", 0.0);
354+
fTimeWalkScale = p.get<double>("TimeWalkScale", 0.0);
355+
fPropDelay = p.get<double>("PropDelay", 0.0);
343356

344357
if(!fDataMode)
345358
fCRTBackTrackerAlg = CRTBackTrackerAlg(p.get<fhicl::ParameterSet>("CRTBackTrackerAlg", fhicl::ParameterSet()));
@@ -427,6 +440,11 @@ sbnd::crt::CRTAnalysis::CRTAnalysis(fhicl::ParameterSet const& p)
427440
fTree->Branch("cl_composition", "std::vector<uint8_t>", &_cl_composition);
428441
fTree->Branch("cl_channel_set", "std::vector<std::vector<uint32_t>>", &_cl_channel_set);
429442
fTree->Branch("cl_adc_set", "std::vector<std::vector<uint16_t>>", &_cl_adc_set);
443+
fTree->Branch("cl_sh_ts0_set", "std::vector<std::vector<uint32_t>>", &_cl_sh_ts0_set);
444+
fTree->Branch("cl_sh_ts1_set", "std::vector<std::vector<uint32_t>>", &_cl_sh_ts1_set);
445+
fTree->Branch("cl_sh_feb_mac5_set", "std::vector<std::vector<uint16_t>>", &_cl_sh_feb_mac5_set);
446+
fTree->Branch("cl_sh_time_walk_set", "std::vector<std::vector<double>>", &_cl_sh_time_walk_set);
447+
fTree->Branch("cl_sh_prop_delay_set", "std::vector<std::vector<double>>", &_cl_sh_prop_delay_set);
430448
if(!fDataMode)
431449
{
432450
fTree->Branch("cl_truth_trackid", "std::vector<int>", &_cl_truth_trackid);
@@ -1093,6 +1111,11 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
10931111
_cl_composition.resize(nClusters);
10941112
_cl_channel_set.resize(nClusters);
10951113
_cl_adc_set.resize(nClusters);
1114+
_cl_sh_ts0_set.resize(nClusters);
1115+
_cl_sh_ts1_set.resize(nClusters);
1116+
_cl_sh_feb_mac5_set.resize(nClusters);
1117+
_cl_sh_time_walk_set.resize(nClusters);
1118+
_cl_sh_prop_delay_set.resize(nClusters);
10961119
_cl_truth_trackid.resize(nClusters);
10971120
_cl_truth_completeness.resize(nClusters);
10981121
_cl_truth_purity.resize(nClusters);
@@ -1123,6 +1146,8 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
11231146
_cl_sp_ets1.resize(nClusters);
11241147
_cl_sp_complete.resize(nClusters);
11251148

1149+
art::ServiceHandle<SBND::CRTChannelMapService> ChannelMapService;
1150+
11261151
for(unsigned i = 0; i < nClusters; ++i)
11271152
{
11281153
const auto cluster = CRTClusterVec[i];
@@ -1134,16 +1159,52 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
11341159
_cl_tagger[i] = cluster->Tagger();
11351160
_cl_composition[i] = cluster->Composition();
11361161

1162+
const auto spacepoints = clustersToSpacePoints.at(cluster.key());
1163+
11371164
const auto striphits = clustersToStripHits.at(cluster.key());
11381165
_cl_channel_set[i].resize(_cl_nhits[i]);
11391166
_cl_adc_set[i].resize(2 * _cl_nhits[i]);
1167+
_cl_sh_ts0_set[i].resize(_cl_nhits[i] );
1168+
_cl_sh_ts1_set[i].resize(_cl_nhits[i] );
1169+
_cl_sh_feb_mac5_set[i].resize(_cl_nhits[i]);
1170+
_cl_sh_time_walk_set[i].resize(_cl_nhits[i]);
1171+
_cl_sh_prop_delay_set[i].resize(_cl_nhits[i]);
11401172

11411173
for(unsigned ii = 0; ii < _cl_nhits[i]; ++ii)
11421174
{
11431175
const auto striphit = striphits[ii];
11441176
_cl_channel_set[i][ii] = striphit->Channel();
11451177
_cl_adc_set[i][2*ii] = striphit->ADC1();
11461178
_cl_adc_set[i][2*ii+1] = striphit->ADC2();
1179+
_cl_sh_ts0_set[i][ii] = striphit->Ts0();
1180+
_cl_sh_ts1_set[i][ii] = striphit->Ts1();
1181+
SBND::CRTChannelMapService::ModuleInfo_t module_info = ChannelMapService->GetModuleInfoFromOfflineID( striphit->Channel() / 32 );
1182+
_cl_sh_feb_mac5_set[i][ii] = ( module_info.valid ) ? module_info.feb_mac5 : 0;
1183+
1184+
/*
1185+
* The below segment reimplements the CorrectTime() method
1186+
* from CRTReco/CRTClusterCharacterisationAlg.cc .
1187+
* Because the Ts0(), Ts1() getters invoked in _cl_sp_ts*, _cl_sh_ts*_set are raw T0/1
1188+
* counters, the time walk and propagation delay are saved as explicit branches here.
1189+
*/
1190+
if(spacepoints.size() == 1) { // need unique position of spacepoint
1191+
double pe0 = fCRTGeoAlg.GetSiPM( striphit->Channel() ).gain * striphit->ADC1();
1192+
double pe1 = fCRTGeoAlg.GetSiPM( striphit->Channel() + 1 ).gain * striphit->ADC2();
1193+
double pe = pe0 + pe1;
1194+
1195+
double dist = fCRTGeoAlg.DistanceDownStrip( spacepoints[0]->Pos(), striphit->Channel() );
1196+
1197+
double corr = std::pow( dist - fPEAttenuation, 2.0 ) / std::pow( fPEAttenuation, 2.0 );
1198+
double tw_pe = pe * corr;
1199+
1200+
_cl_sh_time_walk_set[i][ii] = fTimeWalkNorm * std::exp( -fTimeWalkScale * tw_pe );
1201+
_cl_sh_prop_delay_set[i][ii] = fPropDelay * dist;
1202+
1203+
} else { // fill with nonsense
1204+
_cl_sh_time_walk_set[i][ii] = -999999.;
1205+
_cl_sh_prop_delay_set[i][ii] = -999999.;
1206+
}
1207+
11471208
}
11481209

11491210
if(!fDataMode)
@@ -1167,7 +1228,6 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
11671228
_cl_truth_core_z[i] = truthMatch.deposit.coreZ;
11681229
}
11691230

1170-
const auto spacepoints = clustersToSpacePoints.at(cluster.key());
11711231
if(spacepoints.size() == 1)
11721232
{
11731233
const auto spacepoint = spacepoints[0];

sbndcode/CRT/CRTAna/run_crtana.fcl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "crtgeoalg_sbnd.fcl"
22
#include "crtbacktrackeralg_sbnd.fcl"
3+
#include "crtrecoproducers_sbnd.fcl"
34
#include "simulationservices_sbnd.fcl"
45

56
process_name: CRTAnalyzer
@@ -27,6 +28,10 @@ physics:
2728
module_type: "CRTAnalysis"
2829
CRTGeoAlg: @local::crtgeoalg_sbnd
2930
CRTBackTrackerAlg: @local::crtbacktrackeralg_sbnd
31+
PEAttenuation: @local::sbnd_crtsim.DetSimParams.NpeScaleShift
32+
PropDelay: @local::sbnd_crtsim.DetSimParams.PropDelay
33+
TimeWalkNorm: @local::sbnd_crtsim.DetSimParams.TDelayNorm
34+
TimeWalkScale: @local::sbnd_crtsim.DetSimParams.TDelayScale
3035
}
3136
}
3237

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)