Skip to content

Commit ac11709

Browse files
authored
Merge branch 'develop' into feature/gputnam-crt-hit-truth-dev
2 parents 33f3455 + a415453 commit ac11709

12 files changed

Lines changed: 296 additions & 65 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
1717

1818
find_package(cetmodules 3.20.00 REQUIRED)
19-
project(sbncode VERSION 10.10.02 LANGUAGES CXX)
19+
project(sbncode VERSION 10.10.03.02 LANGUAGES CXX)
2020

2121
message(STATUS "\n\n ========================== ${PROJECT_NAME} ==========================")
2222

sbncode/BeamSpillInfoRetriever/job/run_sbndbnbinfo_sbn.fcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ physics: {
3434
stream1: [ out1 ]
3535
}
3636

37-
physics.producers.sbndbnbinfo.module_type: "SBNDBNBRetriever"
37+
physics.producers.bnbinfo.module_type: "SBNDBNBRetriever"
3838

3939
outputs: {
4040
out1: {
@@ -45,4 +45,4 @@ outputs: {
4545
}
4646
}
4747

48-
physics.producers.sbndbnbinfo.fileNames: @local::outputs.out1.fileName
48+
physics.producers.bnbinfo.fileNames: @local::outputs.out1.fileName

sbncode/CAFMaker/CAFMakerParams.h

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace caf
1616
template<class T> using Atom = fhicl::Atom<T>;
1717
template<class T> using Sequence = fhicl::Sequence<T>;
1818
template<class T> using Table = fhicl::Table<T>;
19+
template<class T> using OptionalTable = fhicl::OptionalTable<T>;
1920
using Comment = fhicl::Comment;
2021
using Name = fhicl::Name;
2122
using string = std::string;
@@ -368,6 +369,12 @@ namespace caf
368369
"" //Empty by default, configured in icaruscode cafmaker_defs
369370
};
370371

372+
Atom<string> CorrectedOpFlashLabel {
373+
Name("CorrectedOpFlashLabel"),
374+
Comment("Label of CorrectedOpFlash containing tpc-corrected flash time."),
375+
""
376+
};
377+
371378
Atom<art::InputTag> NuGraphSliceHitLabel {
372379
Name("NuGraphSliceHitLabel"),
373380
Comment("Label of NuGraph slice hit map."),
@@ -476,6 +483,92 @@ namespace caf
476483
25.
477484
};
478485

486+
struct PFOCharLabels_t {
487+
Atom<string> EndFractionName {
488+
Name("EndFractionName"),
489+
Comment("Provide the tool name for the EndFraction BDT variable."),
490+
"LArThreeDChargeFeatureTool_EndFraction"
491+
};
492+
493+
Atom<string> FractionalSpreadName {
494+
Name("FractionalSpreadName"),
495+
Comment("Provide the tool name for the FractionalSpread BDT variable."),
496+
"LArThreeDChargeFeatureTool_FractionalSpread"
497+
};
498+
499+
Atom<string> DiffStraightLineMeanName {
500+
Name("DiffStraightLineMeanName"),
501+
Comment("Provide the tool name for the DiffStraightLineMean BDT variable."),
502+
"LArThreeDLinearFitFeatureTool_DiffStraightLineMean"
503+
};
504+
505+
Atom<string> LengthName {
506+
Name("LengthName"),
507+
Comment("Provide the tool name for the Length BDT variable."),
508+
"LArThreeDLinearFitFeatureTool_Length"
509+
};
510+
511+
Atom<string> MaxFitGapLengthName {
512+
Name("MaxFitGapLengthName"),
513+
Comment("Provide the tool name for the MaxFitGapLength BDT variable."),
514+
"LArThreeDLinearFitFeatureTool_MaxFitGapLength"
515+
};
516+
517+
Atom<string> SlidingLinearFitRMSName {
518+
Name("SlidingLinearFitRMSName"),
519+
Comment("Provide the tool name for the SlidingLinearFitRMS BDT variable."),
520+
"LArThreeDLinearFitFeatureTool_SlidingLinearFitRMS"
521+
};
522+
523+
Atom<string> AngleDiffName {
524+
Name("AngleDiffName"),
525+
Comment("Provide the tool name for the AngleDiff BDT variable."),
526+
"LArThreeDOpeningAngleFeatureTool_AngleDiff"
527+
};
528+
529+
Atom<string> SecondaryPCARatioName {
530+
Name("SecondaryPCARatioName"),
531+
Comment("Provide the tool name for the SecondaryPCARatio BDT variable."),
532+
"LArThreeDPCAFeatureTool_SecondaryPCARatio"
533+
};
534+
535+
Atom<string> TertiaryPCARatioName {
536+
Name("TertiaryPCARatioName"),
537+
Comment("Provide the tool name for the TertiaryPCARatio BDT variable."),
538+
"LArThreeDPCAFeatureTool_TertiaryPCARatio"
539+
};
540+
541+
Atom<string> VertexDistanceName {
542+
Name("VertexDistanceName"),
543+
Comment("Provide the tool name for the VertexDistance BDT variable."),
544+
"LArThreeDVertexDistanceFeatureTool_VertexDistance"
545+
};
546+
547+
Atom<string> HaloTotalRatioName {
548+
Name("HaloTotalRatioName"),
549+
Comment("Provide the tool name for the HaloTotalRatio BDT variable."),
550+
"LArConeChargeFeatureTool_HaloTotalRatio"
551+
};
552+
553+
Atom<string> ConcentrationName {
554+
Name("ConcentrationName"),
555+
Comment("Provide the tool name for the Concentration BDT variable."),
556+
"LArConeChargeFeatureTool_Concentration"
557+
558+
};
559+
560+
Atom<string> ConicalnessName {
561+
Name("ConicalnessName"),
562+
Comment("Provide the tool name for the Conicalness BDT variable."),
563+
"LArConeChargeFeatureTool_Conicalness"
564+
};
565+
};
566+
567+
OptionalTable<PFOCharLabels_t> PFOCharLabels {
568+
Name("PFOCharLabels"),
569+
Comment("Provide tool names for the Pandora track/shower discrimination BDT variables.")
570+
};
571+
479572
Atom<bool> ReferencePMTFromTriggerToBeam {
480573
Name("ReferencePMTFromTriggerToBeam"),
481574
Comment("Whether to switch the reference time of PMT reco from 'trigger' to 'beam spill' time."),

sbncode/CAFMaker/CAFMaker_module.cc

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,11 @@
118118
#include "sbnobj/Common/Trigger/ExtraTriggerInfo.h"
119119
#include "sbnobj/Common/Reco/CRUMBSResult.h"
120120
#include "sbnobj/Common/Reco/OpT0FinderResult.h"
121+
#include "sbnobj/Common/Reco/CorrectedOpFlashTiming.h"
121122
#include "sbnobj/SBND/Timing/TimingInfo.hh"
122123
#include "sbnobj/SBND/Timing/FrameShiftInfo.hh"
123124

125+
124126
// GENIE
125127
#include "Framework/EventGen/EventRecord.h"
126128
#include "Framework/Ntuple/NtpMCEventRecord.h"
@@ -1668,6 +1670,8 @@ void CAFMaker::produce(art::Event& evt) noexcept {
16681670
// }
16691671

16701672
// try to find the result of the Flash trigger if it was run
1673+
mf::LogInfo("CAFMaker") << " New Trigger Time = " << srtrigger.global_trigger_det_time << " us\n"
1674+
<< " New Beam Gate Time = " << srtrigger.beam_gate_det_time << " us";
16711675
bool pass_flash_trig = false;
16721676
art::Handle<bool> flashtrig_handle;
16731677
GetByLabelStrict(evt, fParams.FlashTrigLabel(), flashtrig_handle);
@@ -1959,6 +1963,15 @@ void CAFMaker::produce(art::Event& evt) noexcept {
19591963
const sbn::TPCPMTBarycenterMatch *barycenterMatch
19601964
= foTPCPMTBarycenterMatch.isValid()? foTPCPMTBarycenterMatch.at(0).get(): nullptr;
19611965

1966+
1967+
art::FindManyP<sbn::CorrectedOpFlashTiming> fmCorrectedOpFlash =
1968+
FindManyPStrict<sbn::CorrectedOpFlashTiming>(sliceList, evt,
1969+
fParams.CorrectedOpFlashLabel() + slice_tag_suff);
1970+
std::vector<art::Ptr<sbn::CorrectedOpFlashTiming>> slcCorrectedOpFlash;
1971+
if (fmCorrectedOpFlash.isValid())
1972+
slcCorrectedOpFlash = fmCorrectedOpFlash.at(0);
1973+
1974+
19621975
art::FindOneP<lcvn::Result> foCVNResult =
19631976
FindOnePStrict<lcvn::Result>(sliceList, evt,
19641977
fParams.CVNLabel() + slice_tag_suff);
@@ -2214,6 +2227,7 @@ void CAFMaker::produce(art::Event& evt) noexcept {
22142227
FillSliceOpT0Finder(slcOpT0, recslc);
22152228
FillSliceBarycenter(slcHits, slcSpacePoints, recslc);
22162229
FillTPCPMTBarycenterMatch(barycenterMatch, recslc);
2230+
FillCorrectedOpFlashTiming(slcCorrectedOpFlash, recslc);
22172231
FillCVNScores(cvnResult, recslc);
22182232

22192233
// select slice
@@ -2313,7 +2327,24 @@ void CAFMaker::produce(art::Event& evt) noexcept {
23132327
}
23142328

23152329
const larpandoraobj::PFParticleMetadata *pfpMeta = (fmPFPMeta.at(iPart).empty()) ? NULL : fmPFPMeta.at(iPart).at(0).get();
2316-
FillPFPVars(thisParticle, primary, pfpMeta, thisPFPT0, pfp);
2330+
caf::CAFMakerParams::PFOCharLabels_t const& pfoCharParams
2331+
= fParams.PFOCharLabels().value_or(caf::CAFMakerParams::PFOCharLabels_t{});
2332+
const caf::PFOCharLabelsStruct pfoCharLabels {
2333+
pfoCharParams.EndFractionName(),
2334+
pfoCharParams.FractionalSpreadName(),
2335+
pfoCharParams.DiffStraightLineMeanName(),
2336+
pfoCharParams.LengthName(),
2337+
pfoCharParams.MaxFitGapLengthName(),
2338+
pfoCharParams.SlidingLinearFitRMSName(),
2339+
pfoCharParams.AngleDiffName(),
2340+
pfoCharParams.SecondaryPCARatioName(),
2341+
pfoCharParams.TertiaryPCARatioName(),
2342+
pfoCharParams.VertexDistanceName(),
2343+
pfoCharParams.HaloTotalRatioName(),
2344+
pfoCharParams.ConcentrationName(),
2345+
pfoCharParams.ConicalnessName()
2346+
};
2347+
FillPFPVars(thisParticle, primary, pfpMeta, thisPFPT0, pfp, pfoCharLabels);
23172348

23182349
if (fmCNNScores.isValid()) {
23192350
const sbn::PFPCNNScore *cnnScores = fmCNNScores.at(iPart).at(0).get();
@@ -2586,6 +2617,7 @@ void CAFMaker::produce(art::Event& evt) noexcept {
25862617
rec.hdr.ismc = !isRealData;
25872618
rec.hdr.det = fDet;
25882619
rec.hdr.fno = fFileNumber;
2620+
25892621
if(fFirstInSubRun)
25902622
{
25912623
rec.hdr.nbnbinfo = fBNBInfo.size();
@@ -2626,13 +2658,13 @@ void CAFMaker::produce(art::Event& evt) noexcept {
26262658
else {
26272659
std::cout << "Did not find this event in the spill info map." << std::endl;
26282660
}
2629-
2661+
26302662
if(fRecTree){
26312663
// Save the standard-record
26322664
StandardRecord* prec = &rec;
2665+
26332666
fRecTree->SetBranchAddress("rec", &prec);
26342667
fRecTree->Fill();
2635-
26362668
if(fFlatTree){
26372669
fFlatRecord->Clear();
26382670
fFlatRecord->Fill(rec);

sbncode/CAFMaker/FillReco.cxx

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,24 @@ namespace caf
342342
}
343343
}
344344

345+
346+
void FillCorrectedOpFlashTiming(const std::vector<art::Ptr<sbn::CorrectedOpFlashTiming>> &slcCorrectedOpFlash,
347+
caf::SRSlice& slice)
348+
{
349+
slice.correctedOpFlash.setDefault();
350+
if ( slcCorrectedOpFlash.empty()==false ) {
351+
const sbn::CorrectedOpFlashTiming &_correctedOpFlash = *slcCorrectedOpFlash[0];
352+
//TODO: use the score of the match to fill the information accordingly
353+
slice.correctedOpFlash.OpFlashT0 = _correctedOpFlash.OpFlashT0;
354+
slice.correctedOpFlash.UpstreamTime_lightonly = _correctedOpFlash.UpstreamTime_lightonly;
355+
slice.correctedOpFlash.UpstreamTime_tpczcorr = _correctedOpFlash.UpstreamTime_tpczcorr;
356+
slice.correctedOpFlash.UpstreamTime_propcorr_tpczcorr = _correctedOpFlash.UpstreamTime_propcorr_tpczcorr;
357+
slice.correctedOpFlash.FMScore = _correctedOpFlash.FMScore;
358+
slice.correctedOpFlash.SliceNuScore = _correctedOpFlash.SliceNuScore;
359+
}
360+
}
361+
362+
345363
std::vector<float> double_to_float_vector(const std::vector<double>& v)
346364
{
347365
std::vector<float> ret;
@@ -1053,6 +1071,7 @@ namespace caf
10531071
const larpandoraobj::PFParticleMetadata *pfpMeta,
10541072
const art::Ptr<anab::T0> t0,
10551073
caf::SRPFP& srpfp,
1074+
const PFOCharLabelsStruct& pfoCharLabels,
10561075
bool allowEmpty)
10571076
{
10581077
srpfp.id = particle.Self();
@@ -1076,19 +1095,19 @@ namespace caf
10761095
// Pfo Characterisation features
10771096
srpfp.pfochar.setDefault();
10781097

1079-
CopyPropertyIfSet(propertiesMap, "LArThreeDChargeFeatureTool_EndFraction", srpfp.pfochar.chgendfrac);
1080-
CopyPropertyIfSet(propertiesMap, "LArThreeDChargeFeatureTool_FractionalSpread", srpfp.pfochar.chgfracspread);
1081-
CopyPropertyIfSet(propertiesMap, "LArThreeDLinearFitFeatureTool_DiffStraightLineMean", srpfp.pfochar.linfitdiff);
1082-
CopyPropertyIfSet(propertiesMap, "LArThreeDLinearFitFeatureTool_Length", srpfp.pfochar.linfitlen);
1083-
CopyPropertyIfSet(propertiesMap, "LArThreeDLinearFitFeatureTool_MaxFitGapLength", srpfp.pfochar.linfitgaplen);
1084-
CopyPropertyIfSet(propertiesMap, "LArThreeDLinearFitFeatureTool_SlidingLinearFitRMS", srpfp.pfochar.linfitrms);
1085-
CopyPropertyIfSet(propertiesMap, "LArThreeDOpeningAngleFeatureTool_AngleDiff", srpfp.pfochar.openanglediff);
1086-
CopyPropertyIfSet(propertiesMap, "LArThreeDPCAFeatureTool_SecondaryPCARatio", srpfp.pfochar.pca2ratio);
1087-
CopyPropertyIfSet(propertiesMap, "LArThreeDPCAFeatureTool_TertiaryPCARatio", srpfp.pfochar.pca3ratio);
1088-
CopyPropertyIfSet(propertiesMap, "LArThreeDVertexDistanceFeatureTool_VertexDistance", srpfp.pfochar.vtxdist);
1089-
CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_HaloTotalRatio", srpfp.pfochar.halototratio);
1090-
CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_Concentration", srpfp.pfochar.concentration);
1091-
CopyPropertyIfSet(propertiesMap, "LArConeChargeFeatureTool_Conicalness", srpfp.pfochar.conicalness);
1098+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.EndFractionName, srpfp.pfochar.chgendfrac);
1099+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.FractionalSpreadName, srpfp.pfochar.chgfracspread);
1100+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.DiffStraightLineMeanName, srpfp.pfochar.linfitdiff);
1101+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.LengthName, srpfp.pfochar.linfitlen);
1102+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.MaxFitGapLengthName, srpfp.pfochar.linfitgaplen);
1103+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.SlidingLinearFitRMSName, srpfp.pfochar.linfitrms);
1104+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.AngleDiffName, srpfp.pfochar.openanglediff);
1105+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.SecondaryPCARatioName, srpfp.pfochar.pca2ratio);
1106+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.TertiaryPCARatioName, srpfp.pfochar.pca3ratio);
1107+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.VertexDistanceName, srpfp.pfochar.vtxdist);
1108+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.HaloTotalRatioName, srpfp.pfochar.halototratio);
1109+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.ConcentrationName, srpfp.pfochar.concentration);
1110+
CopyPropertyIfSet(propertiesMap, pfoCharLabels.ConicalnessName, srpfp.pfochar.conicalness);
10921111
}
10931112
if (t0) {
10941113
srpfp.t0 = t0->Time() / 1e3; /* ns -> us */
@@ -1211,6 +1230,8 @@ namespace caf
12111230
slice.barycenterFM.deltaZ_Trigger = matchInfo->deltaZ_Trigger;
12121231
slice.barycenterFM.deltaY_Trigger = matchInfo->deltaY_Trigger;
12131232
slice.barycenterFM.radius_Trigger = matchInfo->radius_Trigger;
1233+
slice.barycenterFM.score = matchInfo->score;
1234+
slice.barycenterFM.chi2 = matchInfo->chi2;
12141235
}
12151236
}
12161237

sbncode/CAFMaker/FillReco.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "sbnobj/Common/Reco/CRUMBSResult.h"
3838
#include "sbnobj/Common/Reco/OpT0FinderResult.h"
3939
#include "sbnobj/Common/Reco/TPCPMTBarycenterMatch.h"
40+
#include "sbnobj/Common/Reco/CorrectedOpFlashTiming.h"
4041
#include "sbnobj/Common/CRT/CRTHit.hh"
4142
#include "sbnobj/Common/CRT/CRTTrack.hh"
4243
#include "sbnobj/SBND/CRT/CRTSpacePoint.hh"
@@ -141,12 +142,29 @@ namespace caf
141142
caf::SRHit& srhit,
142143
bool allowEmpty = false);
143144

145+
struct PFOCharLabelsStruct {
146+
std::string EndFractionName;
147+
std::string FractionalSpreadName;
148+
std::string DiffStraightLineMeanName;
149+
std::string LengthName;
150+
std::string MaxFitGapLengthName;
151+
std::string SlidingLinearFitRMSName;
152+
std::string AngleDiffName;
153+
std::string SecondaryPCARatioName;
154+
std::string TertiaryPCARatioName;
155+
std::string VertexDistanceName;
156+
std::string HaloTotalRatioName;
157+
std::string ConcentrationName;
158+
std::string ConicalnessName;
159+
};
160+
144161
void FillPFPVars(const recob::PFParticle &particle,
145162
const recob::PFParticle *primary,
146163
const larpandoraobj::PFParticleMetadata *pfpMeta,
147164
const art::Ptr<anab::T0> t0,
148165
caf::SRPFP& srpfp,
149-
bool allowEmpty= false);
166+
const PFOCharLabelsStruct& pfoCharLabels,
167+
bool allowEmpty = false);
150168

151169
void FillCNNScores(const recob::PFParticle &particle,
152170
const sbn::PFPCNNScore *cnnscore,
@@ -280,6 +298,9 @@ namespace caf
280298
void FillTPCPMTBarycenterMatch(const sbn::TPCPMTBarycenterMatch *matchInfo,
281299
caf::SRSlice& slice);
282300

301+
void FillCorrectedOpFlashTiming(const std::vector<art::Ptr<sbn::CorrectedOpFlashTiming>> &slcCorrectedOpFlash,
302+
caf::SRSlice& slice);
303+
283304
void FillCVNScores(const lcvn::Result *cvnResult,
284305
caf::SRSlice& slice);
285306

sbncode/CAFMaker/FillTrigger.cxx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
#include<iostream>
22
#include "sbncode/CAFMaker/FillTrigger.h"
33

44
namespace caf
@@ -12,7 +12,10 @@ namespace caf
1212
triggerInfo.beam_gate_time_abs = addltrig_info.beamGateTimestamp;
1313
triggerInfo.beam_gate_det_time = trig.BeamGateTime() + time_offset;
1414
triggerInfo.global_trigger_det_time = trig.TriggerTime() + time_offset;
15+
std::cout << "Gen triggerInfo.global_trigger_det_time: " << triggerInfo.global_trigger_det_time << std::endl;
16+
std::cout << "Gen triggerInfo.beam_gate_det_time: " << triggerInfo.beam_gate_det_time << std::endl;
1517
double diff_ts = triggerInfo.global_trigger_det_time - triggerInfo.beam_gate_det_time;
18+
std::cout << "diff_ts: " << diff_ts << std::endl;
1619
triggerInfo.trigger_within_gate = diff_ts;
1720

1821
triggerInfo.prev_global_trigger_time = addltrig_info.previousTriggerTimestamp;
@@ -39,8 +42,10 @@ namespace caf
3942

4043
triggerInfo.global_trigger_time = timingInfo.hltEtrig;
4144
triggerInfo.beam_gate_time_abs = timingInfo.hltBeamGate;
42-
45+
std::cout << "triggerInfo.global_trigger_det_time: " << triggerInfo.global_trigger_det_time << std::endl;
46+
std::cout << "triggerInfo.beam_gate_det_time: " << triggerInfo.beam_gate_det_time << std::endl;
4347
double diff_ts = triggerInfo.global_trigger_det_time - triggerInfo.beam_gate_det_time;
48+
std::cout << "diff_ts: " << diff_ts << std::endl;
4449
triggerInfo.trigger_within_gate = diff_ts;
4550
}
4651

0 commit comments

Comments
 (0)