Skip to content

Commit 98cc1c2

Browse files
Fix conflicts
2 parents 534c3c1 + 364bd0b commit 98cc1c2

236 files changed

Lines changed: 10145 additions & 1677 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 3 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 09.93.01.01)
18+
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 10.04.03)
1919
find_package(cetmodules REQUIRED)
2020
project(sbndcode LANGUAGES CXX)
2121

2222
# for CI:
23-
# project(sbndcode VERSION 09.93.01.01)
23+
# project(sbndcode VERSION 10.04.03)
2424

2525
message(STATUS "\n")
2626
message(STATUS "================================= ${PROJECT_NAME} =================================")
@@ -80,6 +80,7 @@ find_package( larcore REQUIRED )
8080
find_package( larcorealg REQUIRED )
8181
find_package( larcoreobj REQUIRED )
8282
find_package( larreco REQUIRED )
83+
find_package( larrecodnn REQUIRED )
8384
find_package( larana REQUIRED )
8485
find_package( PostgreSQL REQUIRED )
8586
find_package( hep_concurrency REQUIRED )

sbndcode/AnalysisTree/AnalysisTree_module.cc

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3677,17 +3677,15 @@ bool sbnd::AnalysisTree::TrackIdToMCTruth( Int_t const trkID, art::Ptr<simb::MCT
36773677
double sbnd::AnalysisTree::bdist(const recob::Track::Point_t& pos)
36783678
{
36793679
// Get geometry.
3680-
art::ServiceHandle<geo::Geometry> geom;
3681-
3680+
geo::TPCGeo const& tpc = art::ServiceHandle<geo::Geometry>()->TPC({0, 0});
36823681
double d1 = pos.X(); // Distance to right side (wires).
3683-
double d2 = 2.*geom->DetHalfWidth() - pos.X(); // Distance to left side (cathode).
3684-
double d3 = pos.Y() + geom->DetHalfHeight(); // Distance to bottom.
3685-
double d4 = geom->DetHalfHeight() - pos.Y(); // Distance to top.
3682+
double d2 = 2.*tpc.HalfWidth() - pos.X(); // Distance to left side (cathode).
3683+
double d3 = pos.Y() + tpc.HalfHeight(); // Distance to bottom.
3684+
double d4 = tpc.HalfHeight() - pos.Y(); // Distance to top.
36863685
double d5 = pos.Z(); // Distance to front.
3687-
double d6 = geom->DetLength() - pos.Z(); // Distance to back.
3686+
double d6 = tpc.Length() - pos.Z(); // Distance to back.
36883687

3689-
double result = std::min(std::min(std::min(std::min(std::min(d1, d2), d3), d4), d5), d6);
3690-
return result;
3688+
return std::min({d1, d2, d3, d4, d5, d6});
36913689
}
36923690

36933691

@@ -3701,16 +3699,14 @@ double sbnd::AnalysisTree::length(const recob::Track& track)
37013699
// Length of MC particle, trajectory by trajectory.
37023700
double sbnd::AnalysisTree::length(const simb::MCParticle& part, TVector3& start, TVector3& end)
37033701
{
3704-
// Get geometry.
3705-
art::ServiceHandle<geo::Geometry> geom;
3706-
37073702
// Get active volume boundary.
3708-
double xmin = -2.0 * geom->DetHalfWidth() - 1e-8;
3709-
double xmax = 2.0 * geom->DetHalfWidth() + 1e-8;
3710-
double ymin = -geom->DetHalfHeight() -1e-8;
3711-
double ymax = geom->DetHalfHeight() + 1e-8;
3703+
geo::TPCGeo const& tpc = art::ServiceHandle<geo::Geometry>()->TPC({0, 0});
3704+
double xmin = -2.0 * tpc.HalfWidth() - 1e-8;
3705+
double xmax = 2.0 * tpc.HalfWidth() + 1e-8;
3706+
double ymin = -tpc.HalfHeight() -1e-8;
3707+
double ymax = tpc.HalfHeight() + 1e-8;
37123708
double zmin = 0. -1e-8;
3713-
double zmax = geom->DetLength() + 1e-8;
3709+
double zmax = tpc.Length() + 1e-8;
37143710

37153711
// Get number traj points
37163712
int n = part.NumberTrajectoryPoints();

sbndcode/AnalysisTree/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ set( MODULE_LIBRARIES larcorealg::Geometry
1313
lardata::RecoObjects
1414
larpandora::LArPandoraInterface
1515
sbndcode_CRTUtils
16-
sbndcode_CRT
1716
sbnobj::Common_CRT
1817
nusimdata::SimulationBase
1918
art::Framework_Core

sbndcode/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ add_subdirectory(WireCell)
4343
add_subdirectory(Decoders)
4444
add_subdirectory(ChannelMaps)
4545

46+
# for CVN
47+
add_subdirectory(SBNDCVN)
48+
49+
# for Calibration database
4650
add_subdirectory(DatabaseInterface)

sbndcode/CRT/CMakeLists.txt

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,37 @@ add_subdirectory(CRTSimulation)
66
add_subdirectory(CRTTPCMatching)
77
add_subdirectory(CRTUtils)
88

9-
art_make(
10-
EXCLUDE
11-
CRTChannelMapAlg.cxx
12-
CRTGeometryHelper_service.cc
13-
LIBRARY_NAME
14-
sbndcode_CRTData
15-
LIB_LIBRARIES
16-
larcorealg::Geometry
17-
larcore::Geometry_Geometry_service
18-
lardataobj::RecoBase
19-
art::Framework_Core
20-
art::Framework_IO_Sources
21-
art::Framework_Principal
22-
canvas::canvas
23-
art::Framework_Services_Registry
24-
messagefacility::MF_MessageLogger
25-
26-
fhiclcpp::fhiclcpp
27-
ROOT::Core
28-
ROOT::Geom
29-
cetlib::cetlib
30-
)
31-
329
art_make_library(
33-
SOURCE CRTChannelMapAlg.cxx
34-
LIBRARIES
35-
larcorealg::Geometry
36-
sbndcode_CRTData
37-
cetlib_except::cetlib_except
38-
messagefacility::MF_MessageLogger
39-
fhiclcpp::fhiclcpp
40-
ROOT::Core
41-
ROOT::Geom
42-
cetlib::cetlib
10+
SOURCE
11+
CRTGeoObjectSorter.cxx
12+
LIBRARY_NAME
13+
sbndcode_CRTData
14+
LIBRARIES
15+
larcorealg::Geometry
16+
larcore::Geometry_Geometry_service
17+
lardataobj::RecoBase
18+
art::Framework_Core
19+
art::Framework_IO_Sources
20+
art::Framework_Principal
21+
canvas::canvas
22+
art::Framework_Services_Registry
23+
messagefacility::MF_MessageLogger
24+
fhiclcpp::fhiclcpp
25+
ROOT::Core
26+
ROOT::Geom
27+
cetlib::cetlib
4328
)
44-
simple_plugin(
45-
CRTGeometryHelper service
46-
sbndcode_CRT
47-
art::Framework_Core
48-
art::Framework_IO_Sources
49-
art::Framework_Principal
50-
canvas::canvas
51-
art::Framework_Services_Registry
52-
messagefacility::MF_MessageLogger
29+
30+
cet_build_plugin( CRTAuxDetInitializer art::tool
31+
LIBRARIES REG
32+
larcorealg::Geometry
33+
sbndcode_CRTData
34+
cetlib_except::cetlib_except
35+
messagefacility::MF_MessageLogger
36+
fhiclcpp::fhiclcpp
37+
cetlib::cetlib
5338
)
39+
40+
install_headers()
41+
install_fhicl()
42+
install_source()

sbndcode/CRT/CRTAna/CRTAnalysis_module.cc

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@
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"
43+
#include "sbndcode/Timing/SBNDRawTimingObj.h"
4244

4345
namespace sbnd::crt {
4446
class CRTAnalysis;
@@ -94,8 +96,10 @@ class sbnd::crt::CRTAnalysis : public art::EDAnalyzer {
9496
std::string fMCParticleModuleLabel, fSimDepositModuleLabel, fFEBDataModuleLabel, fCRTStripHitModuleLabel,
9597
fCRTClusterModuleLabel, fCRTSpacePointModuleLabel, fCRTTrackModuleLabel, fTPCTrackModuleLabel,
9698
fCRTSpacePointMatchingModuleLabel, fCRTTrackMatchingModuleLabel, fPFPModuleLabel, fPTBModuleLabel,
97-
fTDCModuleLabel;
99+
fTDCModuleLabel, fTimingReferenceModuleLabel;
98100
bool fDebug, fDataMode, fNoTPC, fHasPTB, fHasTDC;
101+
//! Adding some of the reco parameters to save corrections
102+
double fPEAttenuation, fTimeWalkNorm, fTimeWalkScale, fPropDelay;
99103

100104
TTree* fTree;
101105

@@ -104,6 +108,8 @@ class sbnd::crt::CRTAnalysis : public art::EDAnalyzer {
104108
int _run;
105109
int _subrun;
106110
int _event;
111+
int _crt_timing_reference_type;
112+
int _crt_timing_reference_channel;
107113

108114
//mc truth
109115
std::vector<int16_t> _mc_trackid;
@@ -178,6 +184,11 @@ class sbnd::crt::CRTAnalysis : public art::EDAnalyzer {
178184
std::vector<uint8_t> _cl_composition;
179185
std::vector<std::vector<uint32_t>> _cl_channel_set;
180186
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
181192
std::vector<int> _cl_truth_trackid;
182193
std::vector<double> _cl_truth_completeness;
183194
std::vector<double> _cl_truth_purity;
@@ -331,11 +342,17 @@ sbnd::crt::CRTAnalysis::CRTAnalysis(fhicl::ParameterSet const& p)
331342
fPFPModuleLabel = p.get<std::string>("PFPModuleLabel", "pandora");
332343
fPTBModuleLabel = p.get<std::string>("PTBModuleLabel", "ptbdecoder");
333344
fTDCModuleLabel = p.get<std::string>("TDCModuleLabel", "tdcdecoder");
345+
fTimingReferenceModuleLabel = p.get<std::string>("TimingReferenceModuleLabel", "crtstrips");
334346
fDebug = p.get<bool>("Debug", false);
335347
fDataMode = p.get<bool>("DataMode", false);
336348
fNoTPC = p.get<bool>("NoTPC", false);
337349
fHasPTB = p.get<bool>("HasPTB", false);
338350
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);
339356

340357
if(!fDataMode)
341358
fCRTBackTrackerAlg = CRTBackTrackerAlg(p.get<fhicl::ParameterSet>("CRTBackTrackerAlg", fhicl::ParameterSet()));
@@ -346,6 +363,8 @@ sbnd::crt::CRTAnalysis::CRTAnalysis(fhicl::ParameterSet const& p)
346363
fTree->Branch("run", &_run);
347364
fTree->Branch("subrun", &_subrun);
348365
fTree->Branch("event", &_event);
366+
fTree->Branch("crt_timing_reference_type", &_crt_timing_reference_type);
367+
fTree->Branch("crt_timing_reference_channel", &_crt_timing_reference_channel);
349368

350369
if(!fDataMode)
351370
{
@@ -421,6 +440,11 @@ sbnd::crt::CRTAnalysis::CRTAnalysis(fhicl::ParameterSet const& p)
421440
fTree->Branch("cl_composition", "std::vector<uint8_t>", &_cl_composition);
422441
fTree->Branch("cl_channel_set", "std::vector<std::vector<uint32_t>>", &_cl_channel_set);
423442
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);
424448
if(!fDataMode)
425449
{
426450
fTree->Branch("cl_truth_trackid", "std::vector<int>", &_cl_truth_trackid);
@@ -621,6 +645,17 @@ void sbnd::crt::CRTAnalysis::analyze(art::Event const& e)
621645

622646
if(fDebug) std::cout << "This is event " << _run << "-" << _subrun << "-" << _event << std::endl;
623647

648+
_crt_timing_reference_type = -1;
649+
_crt_timing_reference_channel = -1;
650+
651+
art::Handle<raw::TimingReferenceInfo> TimingReferenceHandle;
652+
e.getByLabel(fTimingReferenceModuleLabel, TimingReferenceHandle);
653+
if(TimingReferenceHandle.isValid())
654+
{
655+
_crt_timing_reference_type = TimingReferenceHandle->timingType;
656+
_crt_timing_reference_channel = TimingReferenceHandle->timingChannel;
657+
}
658+
624659
if(fHasPTB)
625660
{
626661
// Get PTBs
@@ -1076,6 +1111,11 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
10761111
_cl_composition.resize(nClusters);
10771112
_cl_channel_set.resize(nClusters);
10781113
_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);
10791119
_cl_truth_trackid.resize(nClusters);
10801120
_cl_truth_completeness.resize(nClusters);
10811121
_cl_truth_purity.resize(nClusters);
@@ -1106,6 +1146,8 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
11061146
_cl_sp_ets1.resize(nClusters);
11071147
_cl_sp_complete.resize(nClusters);
11081148

1149+
art::ServiceHandle<SBND::CRTChannelMapService> ChannelMapService;
1150+
11091151
for(unsigned i = 0; i < nClusters; ++i)
11101152
{
11111153
const auto cluster = CRTClusterVec[i];
@@ -1117,16 +1159,52 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
11171159
_cl_tagger[i] = cluster->Tagger();
11181160
_cl_composition[i] = cluster->Composition();
11191161

1162+
const auto spacepoints = clustersToSpacePoints.at(cluster.key());
1163+
11201164
const auto striphits = clustersToStripHits.at(cluster.key());
11211165
_cl_channel_set[i].resize(_cl_nhits[i]);
11221166
_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]);
11231172

11241173
for(unsigned ii = 0; ii < _cl_nhits[i]; ++ii)
11251174
{
11261175
const auto striphit = striphits[ii];
11271176
_cl_channel_set[i][ii] = striphit->Channel();
11281177
_cl_adc_set[i][2*ii] = striphit->ADC1();
11291178
_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+
11301208
}
11311209

11321210
if(!fDataMode)
@@ -1150,7 +1228,6 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
11501228
_cl_truth_core_z[i] = truthMatch.deposit.coreZ;
11511229
}
11521230

1153-
const auto spacepoints = clustersToSpacePoints.at(cluster.key());
11541231
if(spacepoints.size() == 1)
11551232
{
11561233
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

0 commit comments

Comments
 (0)