40 #include "nusimdata/SimulationBase/MCTruth.h"
41 #include "nusimdata/SimulationBase/MCNeutrino.h"
42 #include "nusimdata/SimulationBase/MCParticle.h"
45 #include "art_root_io/TFileService.h"
46 #include "art/Framework/Services/Registry/ServiceHandle.h"
47 #include "art/Framework/Core/ConsumesCollector.h"
48 #include "art/Framework/Principal/Event.h"
49 #include "art/Framework/Principal/Handle.h"
50 #include "canvas/Persistency/Common/Assns.h"
51 #include "canvas/Utilities/InputTag.h"
52 #include "messagefacility/MessageLogger/MessageLogger.h"
53 #include "cetlib_except/exception.h"
56 #include "TEfficiency.h"
77 template <
typename Coll>
78 Coll sortCollection(Coll cont) {
79 std::sort(cont.begin(), cont.end());
92 std::size_t thrIndex = thresholdIndex(threshold);
93 if (thrIndex == NoIndex) thrIndex = registerThreshold(threshold);
95 std::size_t patIndex = patternIndex(patternName);
96 if (patIndex == NoIndex) patIndex = registerPattern(patternName);
98 if (thrIndex >= nThresholds())
99 fCounters.resize(thrIndex + 1U, std::vector<Counter_t>{ nPatterns() });
101 if (patIndex >= nPatterns()) {
102 for (
auto& thrCounters: fCounters) thrCounters.resize(patIndex + 1U);
105 assert(hasThreshold(thrIndex));
106 assert(hasPattern(patIndex));
107 return { thrIndex, patIndex };
119 {
return fCounters.empty()? 0U: fCounters.front().size(); }
126 assert(!hasThreshold(threshold));
128 std::size_t
const newIndex = nThresholds();
129 fThresholdIndex[threshold] = newIndex;
131 assert(hasThreshold(threshold));
140 assert(!hasPattern(name));
142 std::size_t
const newIndex = nPatterns();
143 fPatternIndex[
name] = newIndex;
145 assert(hasPattern(name));
152 (
Threshold_t const& threshold, std::string
const& patternName)
const
156 { thresholdIndex(threshold), patternIndex(patternName) };
157 if (index.first == NoIndex)
158 throw std::out_of_range{ threshold };
159 if (index.second == NoIndex)
160 throw std::out_of_range{ patternName };
167 (std::size_t threshold, std::string
const& patternName)
const
170 IndexPair_t const index { threshold, patternIndex(patternName) };
171 if (index.first == NoIndex)
173 if (index.second == NoIndex)
174 throw std::out_of_range{ patternName };
185 { thresholdIndex(threshold), pattern };
186 if (index.first == NoIndex)
187 throw std::out_of_range{ threshold };
188 if (index.second == NoIndex)
196 (std::size_t threshold, std::size_t pattern)
const
200 if (index.first == NoIndex)
202 if (index.second == NoIndex)
212 if (!hasThreshold(indices.first))
215 auto const& thrCounters = fCounters[indices.first];
216 if (indices.second >= thrCounters.size())
219 return thrCounters[indices.second];
228 { thresholdIndex(threshold), patternIndex(patternName) };
229 if (index.first == NoIndex)
230 throw std::out_of_range{ threshold };
231 if (index.second == NoIndex)
232 throw std::out_of_range{ patternName };
239 (std::size_t threshold, std::string
const& patternName) ->
Counter_t&
241 IndexPair_t const index { threshold, patternIndex(patternName) };
242 if (index.first == NoIndex)
244 if (index.second == NoIndex)
245 throw std::out_of_range{ patternName };
255 { thresholdIndex(threshold), pattern };
256 if (index.first == NoIndex)
257 throw std::out_of_range{ threshold };
258 if (index.second == NoIndex)
266 (std::size_t threshold, std::size_t pattern) ->
Counter_t&
269 if (index.first == NoIndex)
271 if (index.second == NoIndex)
281 if (!hasThreshold(indices.first))
284 auto& thrCounters = fCounters[indices.first];
285 if (indices.second >= thrCounters.size())
288 return thrCounters[indices.second];
295 {
return fThresholdIndex.find(threshold) != fThresholdIndex.end(); }
300 (std::size_t thresholdIndex)
const
301 {
return thresholdIndex < nThresholds(); }
306 (std::string
const& patternName)
const
307 {
return fPatternIndex.find(patternName) != fPatternIndex.end(); }
312 (std::size_t patternIndex)
const
313 {
return patternIndex < nPatterns(); }
320 auto const iIndex = fThresholdIndex.find(threshold);
321 return (iIndex == fThresholdIndex.end())? NoIndex: iIndex->second;
327 (std::string
const& patternName)
const
329 auto const iIndex = fPatternIndex.find(patternName);
330 return (iIndex == fPatternIndex.end())? NoIndex: iIndex->second;
339 for (
auto const& [ threshold, thrIndex ]: fThresholdIndex)
340 if (thrIndex == index)
return threshold;
347 (std::size_t index)
const -> std::string
const&
350 for (
auto const& [ name, patIndex ]: fPatternIndex)
351 if (patIndex == index)
return name;
358 (std::ostream& out)
const
360 out <<
"Triggers for " << nThresholds() <<
" thresholds and " << nPatterns()
364 assert(hasThreshold(iThr));
365 out <<
"\n threshold " << threshold(iThr) <<
" [#" << iThr <<
"]:";
366 unsigned int nonEmptyPatterns = 0U;
368 assert(hasPattern(iPat));
370 if (
counts.empty())
continue;
371 out <<
"\n " << patternName(iPat) <<
" [#" << iPat <<
"]: "
375 if (nonEmptyPatterns == 0) out <<
" no events";
383 std::ostream& icarus::trigger::details::operator<<
385 { counters.dump(out);
return out; }
403 fInPlots =
static_cast<Bool_t
>(inPlots);
434 "All nu_mu",
"nu_mu",
446 {
return info.hasGenerated() &&
info.isWeakChargedCurrent(); }
452 {
return info.hasGenerated() &&
info.isWeakChargedCurrent() &&
info.isNu_mu(); }
458 {
return info.hasGenerated() &&
info.isWeakChargedCurrent() &&
info.isNu_e(); }
464 {
return info.hasGenerated() &&
info.isWeakNeutralCurrent(); }
470 {
return info.hasGenerated() &&
info.isWeakNeutralCurrent() &&
info.isNu_mu(); }
476 {
return info.hasGenerated() &&
info.isWeakNeutralCurrent() &&
info.isNu_e(); }
480 "NoActivity",
"no energy deposited in active volume during beam gate",
483 using namespace util::quantities::energy_literals;
484 return info.hasDepEnergy()
485 && (
info.DepositedEnergyInSpillInActiveVolume() == 0.0_GeV);
494 (
Config const& config, art::ConsumesCollector& consumer)
507 ,
fGeom (*lar::providerFrom<geo::Geometry>())
508 , fOutputDir (*art::ServiceHandle<art::TFileService>())
510 , fEventInfoExtractorMaker(
520 , fChannelCryostat(makeChannelCryostatMap(
fGeom))
528 if (fLogEventDetails.empty()) fLogEventDetails = fLogCategory;
532 for (std::string
const& threshold: config.
Thresholds())
533 fADCthresholds[threshold] = art::InputTag{ discrModuleLabel, threshold };
538 std::string treeName;
541 fIDTree = std::make_unique<details::EventIDTree>
542 (*(fOutputDir.make<TTree>(treeName.c_str(),
"Event information")));
543 fEventTree = std::make_unique<details::EventInfoTree>
544 (fIDTree->tree(), useGen(), useEDep());
545 fPlotTree = std::make_unique<details::PlotInfoTree>(fIDTree->tree());
556 consumer.consumes<std::vector<OpticalTriggerGateData_t>>(inputDataTag);
557 consumer.consumes<art::Assns<OpticalTriggerGateData_t, raw::OpDetWaveform>>
562 mf::LogInfo log(fLogCategory);
563 log <<
"\nConfigured " << fADCthresholds.size() <<
" thresholds (ADC):";
564 for (
auto const& [ thresholdTag, dataTag ]: fADCthresholds)
565 log <<
"\n * " << thresholdTag <<
" (from '" << dataTag.encode() <<
"')";
571 mf::LogVerbatim(fLogCategory)
572 <<
"Generation information will not be produced.";
575 mf::LogVerbatim(fLogCategory)
576 <<
"Energy deposition information will not be produced.";
584 (art::Event
const& event)
604 auto const [
detTimings, beamGate, preSpillWindow ] = makeGatePack(&event);
606 if (
auto oldGate = fBeamGateChangeCheck(beamGate); oldGate) {
607 mf::LogDebug(fLogCategory)
608 <<
"Beam gate has changed from " << oldGate->asOptTickRange()
609 <<
" to " << beamGate.asOptTickRange() <<
" (optical tick)!";
612 EventInfo_t const eventInfo = fEventInfoExtractorMaker
613 (beamGate.asSimulationRange(), preSpillWindow.asSimulationRange())(event);
616 bool const bPlot = shouldPlotEvent(eventInfo);
617 if (bPlot) ++nPlottedEvents;
619 if (fIDTree) fIDTree->assignID(event.id());
620 if (fPlotTree) fPlotTree->assign(bPlot);
621 if (fEventTree) fEventTree->assignEvent(eventInfo);
623 std::vector<std::string> selectedPlotCategories
624 = selectPlotCategories(eventInfo, fPlotCategories);
626 mf::LogTrace log(fLogCategory);
628 <<
"Event " <<
event.id() <<
" falls in " << selectedPlotCategories.size()
631 for (std::string
const& name: selectedPlotCategories)
632 log <<
" \"" << name <<
"\"";
635 if (!fLogEventDetails.empty()) {
636 mf::LogTrace(fLogEventDetails)
637 <<
"Event " <<
event.id() <<
": " << eventInfo;
644 = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
645 for (
auto&& [ iThr, thrPair, thrPlots ]
649 auto const& [ thresholdTag, dataTag ] = thrPair;
656 = splitByCryostat(readTriggerGates(event, dataTag));
664 for (std::string
const& name: selectedPlotCategories)
665 selectedPlots.emplace_back(*(thrPlots.findSandbox(name)));
685 if (fIDTree) fIDTree->tree().Fill();
693 mf::LogInfo log(fLogCategory);
694 log << nPlottedEvents <<
"/" << nEvents <<
" events plotted.";
696 log <<
"\n" << fPassCounters;
705 using namespace std::string_literals;
710 fBeamGateChangeCheck(beamGate);
712 if (fOnlyPlotCategories.empty()) fPlotCategories = std::move(categories);
714 auto const plotThisCategory = [
this](std::string
const&
name)
716 return std::binary_search
717 (fOnlyPlotCategories.begin(), fOnlyPlotCategories.end(),
name);
720 fPlotCategories.clear();
721 for (
auto&& plotCategory: categories) {
722 if (!plotThisCategory(plotCategory.name()))
continue;
723 fPlotCategories.push_back(std::move(plotCategory));
729 mf::LogTrace(fLogCategory)
731 <<
"\n - electronics time: " << beamGate.asGate()
732 <<
"\n - simulation time: " << beamGate.asSimulationRange()
733 <<
"\n - optical ticks: " << beamGate.asOptTickRange()
736 mf::LogInfo log(fLogCategory);
737 log <<
"\nConfigured " << fADCthresholds.size() <<
" thresholds (ADC):";
738 for (
auto const& [ thresholdTag, dataTag ]: fADCthresholds)
739 log <<
"\n * " << thresholdTag <<
" (from '" << dataTag.encode() <<
"')";
740 log <<
"\nBeam gate for plots is " << beamGate.asSimulationRange();
742 log <<
"\nConfigured " << fPlotCategories.size() <<
" plot categories"
743 << (fPlotCategories.empty()?
'.':
':');
744 for (
auto const& plotCategory: fPlotCategories) {
745 log <<
"\n ['" << plotCategory.name() <<
"'] "
746 << plotCategory.description();
752 for (std::string
const& thresholdTag: util::get_elements<0U>(fADCthresholds))
756 { fOutputDir,
"Thr"s + thresholdTag,
"(thr: "s + thresholdTag +
")"s };
762 category.description()
765 initializePlotSet(plots, settings);
767 fThresholdPlots.push_back(std::move(thrPlots));
770 mf::LogTrace log(fLogCategory);
771 log <<
"Created " << fThresholdPlots.size() <<
" plot boxes:\n";
772 for (
auto const& box: fThresholdPlots) {
787 initializeEventPlots(plots);
789 initializePMTplots(plots);
795 using SS_t = std::pair<std::string, std::string>;
796 std::array<SS_t, 2U>
const classes {
797 SS_t{
"triggering",
"triggering events" },
798 SS_t{
"nontriggering",
"non-triggering events" }
800 for (
auto const& settingsDesc: settings) {
804 = plots.
addSubSandbox(settingsDesc.tag, settingsDesc.description);
806 initializeEfficiencyPerTriggerPlots(reqBox);
808 for (
auto const& [ name, desc ]: classes) {
812 initializeEventPlots(box);
814 initializePMTplots(box);
829 auto const [
detTimings, beamGate, preSpillWindow ] = makeGatePack();
832 {
detTimings.toOpticalTicks(fTriggerTimeResolution) };
834 auto const PreSpillDuration = preSpillWindow.asSimulationRange().duration();
840 plots.
make<TEfficiency>(
841 "EffVsEnergyInSpill",
842 "Efficiency of triggering vs. energy deposited in spill"
843 ";energy deposited in spill [ GeV ]"
844 ";trigger efficiency [ / 50 MeV ]",
848 plots.
make<TEfficiency>(
849 "EffVsEnergyInSpillActive",
850 "Efficiency of triggering vs. energy deposited in active volume"
851 ";energy deposited in active volume in spill [ GeV ]"
852 ";trigger efficiency [ / 50 MeV ]",
856 plots.
make<TEfficiency>(
857 "EffVsEnergyInPreSpill",
859 "Efficiency of triggering vs. energy deposited in pre-spill ("
861 ";energy deposited in pre-spill [ GeV ]"
862 ";trigger efficiency [ / 100 MeV ]"
867 plots.
make<TEfficiency>(
868 "EffVsEnergyInPreSpillActive",
870 "Efficiency of triggering vs. energy deposited in active volume"
871 " (pre-spill: " +
to_string(PreSpillDuration) +
")"
872 ";energy deposited in active volume in pre-spill [ GeV ]"
873 ";trigger efficiency [ / 100 MeV ]"
880 plots.
make<TEfficiency>(
881 "EffVsNeutrinoEnergy",
882 "Efficiency of triggering vs. neutrino energy"
883 ";neutrino true energy [ GeV ]"
884 ";trigger efficiency [ / 50 MeV ]",
888 plots.
make<TEfficiency>(
890 "Efficiency of triggering vs. outgoing lepton energy"
891 ";final state lepton true energy [ GeV ]"
892 ";trigger efficiency [ / 50 MeV ]",
897 auto const& beamGateOpt = beamGate.asOptTickRange();
901 ";optical time tick [ /" +
util::to_string(triggerResolutionTicks) +
" ]",
902 beamGateOpt.duration() / triggerResolutionTicks,
903 beamGateOpt.start().value(), beamGateOpt.end().value()
912 preSpillWindow.asElectronicsTimeRange().start(),
913 beamGate.asElectronicsTimeRange().start()
915 - beamGate.asElectronicsTimeRange().start()
919 preSpillWindow.asElectronicsTimeRange().end()
920 - beamGate.asElectronicsTimeRange().start(),
922 ) + beamPlotPadding).value(),
923 fTriggerTimeResolution.value()
930 "Times at which trigger logic was satisfied"
931 ";trigger time (relative to beam gate opening) [ us ]"
932 ";opened trigger gates",
933 beamGateBinning.
nBins(), beamGateBinning.
lower(), beamGateBinning.
upper()
938 "Time of the trigger"
939 ";trigger time (relative to beam gate opening) [ us ]"
940 ";opened trigger gates",
941 beamGateBinning.
nBins(), beamGateBinning.
lower(), beamGateBinning.
upper()
956 auto const [
detTimings, beamGate, preSpillWindow ] = makeGatePack();
958 auto const BeamGateDuration = beamGate.asSimulationRange().duration();
959 auto const PreSpillDuration = preSpillWindow.asSimulationRange().duration();
967 "True Neutrino Energy"
968 ";neutrino energy [GeV]"
977 "Energy deposited during the beam gate opening"
978 ";energy deposited in spill [ GeV ]"
979 ";events [ / 50 MeV ]",
985 "Energy deposited during the pre-spill window ("
987 ";energy deposited in pre-spill [ GeV ]"
988 ";events [ / 100 MeV ]"
993 "EnergyInSpillActive",
994 "Energy deposited during the beam gate opening in active volume"
995 ";energy deposited in active volume in spill [ GeV ]"
996 ";events [ / 50 MeV ]",
1000 "EnergyInPreSpillActive",
1002 "Energy deposited in active volume during the pre-spill window ("
1004 ";energy deposited in active volume in pre-spill [ GeV ]"
1005 ";events [ / 100 MeV ]"
1010 "EnergyInPreSpillVsSpillActive",
1012 "Energy deposited in active volume"
1013 ";energy in spill window (" +
to_string(BeamGateDuration) +
") [ GeV ]"
1014 ";energy in pre-spill window (" +
to_string(PreSpillDuration)
1017 120, 0.0, 6.0, 120, 0.0, 12.0
1031 "Energy of outgoing lepton"
1032 ";deposited energy [ GeV ]"
1033 ";events [ / 50 MeV ]",
1037 "InteractionVertexYZ",
1038 "Vertex of triggered interaction"
1039 ";beam direction (z) [ / 20 cm ]"
1040 ";vertical direction (y) [ / 5 cm ]",
1041 120, -1200., +1200.,
1046 "InteractionTypeNeutrinoEnergy",
1047 "Interaction Type vs Neutrino Energy"
1064 unsigned int const nOpChannels =
fGeom.NOpChannels();
1071 "PMT channels contributing to the trigger"
1072 ";channel with opened trigger gate"
1075 0.0,
static_cast<double>(nOpChannels)
1085 if (fPlotOnlyActiveVolume
1100 using namespace std::string_literals;
1108 getTrig.Hist(
"EnergyInPreSpill"s)
1110 getTrig.Hist(
"EnergyInPreSpillActive"s)
1112 getTrig.Hist2D(
"EnergyInPreSpillVsSpillActive"s).Fill(
1120 getTrig.Hist(
"NeutrinoEnergy"s).Fill(
double(eventInfo.
NeutrinoEnergy()));
1122 getTrig.Hist(
"LeptonEnergy"s).Fill(
double(eventInfo.
LeptonEnergy()));
1125 TH2& vertexHist = getTrig.Hist2D(
"InteractionVertexYZ"s);
1126 for (
auto const& point: eventInfo.
Vertices())
1127 vertexHist.Fill(point.Z(), point.Y());
1138 using namespace std::string_literals;
1142 auto& activePMThist = getTrig.Hist(
"ActivePMT"s);
1144 activePMThist.Fill(channel);
1156 using namespace std::string_literals;
1163 bool const fired = triggerInfo.
fired();
1167 getTrigEff.Eff(
"EffVsEnergyInSpill"s).Fill
1169 getTrigEff.Eff(
"EffVsEnergyInPreSpill"s).Fill
1171 getTrigEff.Eff(
"EffVsEnergyInSpillActive"s).Fill
1173 getTrigEff.Eff(
"EffVsEnergyInPreSpillActive"s).Fill
1178 getTrigEff.Eff(
"EffVsNeutrinoEnergy"s).Fill
1180 getTrigEff.Eff(
"EffVsLeptonEnergy"s).Fill
1189 getTrigEff.Hist(
"TriggerTick"s).Fill(triggerInfo.
atTick().value());
1195 getTrigEff.Hist(
"TriggerTime"s).Fill
1196 ((openingTime(triggerInfo.
main()) - beamGateTime).value());
1198 std::vector<OpeningInfo_t>
const& allTriggerOpenings = triggerInfo.
all();
1200 for (OpeningInfo_t
const& opening : allTriggerOpenings) {
1201 getTrigEff.Hist(
"OpeningTimes"s).Fill
1202 ((openingTime(opening) - beamGateTime).
value());
1218 fillEfficiencyPlots(eventInfo, triggerInfo, plots);
1238 for (
auto& thrPlots: fThresholdPlots) deleteEmptyPlots(thrPlots);
1245 (std::string
const& patternName) -> std::size_t
1248 std::size_t patternIndex = fPassCounters.NoIndex;
1249 std::size_t iThr [[maybe_unused]] = 0U;
1250 for (std::string
const& thresholdTag: util::get_elements<0U>(fADCthresholds))
1253 auto const indices = fPassCounters.create(thresholdTag, patternName);
1254 if (patternIndex == fPassCounters.NoIndex) patternIndex = indices.second;
1255 else assert(indices.second == patternIndex);
1259 return patternIndex;
1265 (std::size_t threshold, std::size_t pattern,
bool fired)
1266 { fPassCounters(threshold, pattern).add(fired); }
1272 { registerTriggerResult(threshold, pattern, triggerInfo.
fired()); }
1283 (
detTimings, fBeamGateDuration, fBeamGateStart),
1285 (
detTimings, fPreSpillStart, fPreSpillStart + fPreSpillWindow)
1292 std::vector<std::string>
1296 std::vector<std::string> selected;
1298 for (
auto const& category: categories)
1299 if (category(info)) selected.push_back(category);
1308 (art::Event
const& event, art::InputTag
const& dataTag)
const
1316 =
event.getProduct<std::vector<OpticalTriggerGateData_t>>(dataTag);
1317 auto const& gateToWaveforms =
event.getProduct
1318 <art::Assns<OpticalTriggerGateData_t, sbn::OpDetWaveformMeta>>(dataTag);
1323 catch (cet::exception
const&
e) {
1324 throw cet::exception(
"TriggerEfficiencyPlots",
"", e)
1325 <<
"Error encountered while reading data products from '"
1326 << dataTag.encode() <<
"'\n";
1339 for (
auto& gate: gates) {
1340 gatesPerCryostat[fChannelCryostat.at(gate.channels().front()).Cryostat]
1341 .push_back(std::move(gate));
1344 return gatesPerCryostat;
1358 std::vector<ChannelID_t> channelList;
1359 for (
auto const& gates: cryoGates) {
1362 if (gate.alwaysClosed())
continue;
1363 for (
auto const channel: gate.channels()) {
1364 channelList.push_back(channel);
1370 std::sort(channelList.begin(), channelList.end());
1371 auto const firstDuplicate
1372 = std::unique(channelList.begin(), channelList.end());
1373 channelList.erase(firstDuplicate, channelList.end());
1384 if (!baseDir)
return true;
1387 unsigned int nEntries = 0U, nDirectories = 0U, nDeleted = 0U;
1388 for (TObject* obj: *(baseDir->GetList())) {
1391 if (dynamic_cast<TDirectory*>(obj)) {
1399 if (
auto hist = dynamic_cast<TH1 const*>(obj)) {
1400 if (hist->GetEntries() > 0)
continue;
1403 else if (
auto graph = dynamic_cast<TGraph const*>(obj)) {
1404 if (graph->GetN() > 0)
continue;
1407 else if (
auto* eff = dynamic_cast<TEfficiency const*>(obj)) {
1408 auto const* hist = eff->GetTotalHistogram();
1409 if (hist && hist->GetEntries() > 0)
continue;
1412 else if (
auto* tree = dynamic_cast<TTree const*>(obj)) {
1413 if (tree->GetEntries() > 0)
continue;
1420 mf::LogTrace(fLogCategory)
1421 <<
"Deleting empty " << obj->IsA()->GetName() <<
"['" << obj->GetName()
1422 <<
"'] from " << plots.
name();
1433 = (nDeleted == nEntries) && (nDirectories <= plots.
nSubSandboxes());
1436 std::vector<std::string> toBeDeleted;
1438 if (!deleteEmptyPlots(subbox))
continue;
1439 toBeDeleted.push_back(subbox.name());
1440 mf::LogTrace(fLogCategory)
1441 <<
"Scheduling empty " << plots.
name() <<
"/" << toBeDeleted.back() <<
" for deletion";
1443 if (toBeDeleted.size() != plots.
nSubSandboxes()) empty =
false;
1444 for (std::string
const& subName: toBeDeleted) {
1446 mf::LogTrace(fLogCategory)
1447 <<
"Deleted box " << plots.
name() <<
"/" << subName;
1461 std::vector<geo::CryostatID> channelCryostatMap(nOpChannels);
1465 channelCryostatMap.at(opChannel)
1469 return channelCryostatMap;
1477 fhicl::Sequence<art::InputTag>
const& EnergyDepositTags,
1478 fhicl::OptionalAtom<art::InputTag>
const& EnergyDepositSummaryTag
1490 return { EnergyDepositTags() };
fhicl::Sequence< art::InputTag > EnergyDepositTags
TriggerEfficiencyPlotsBase(Config const &config, art::ConsumesCollector &consumer)
Constructor; requires a configuration and module's consumesCollector().
bool fired() const
Returns whether the trigger fired.
bool isInActiveVolume() const
Returns whether there is an interaction within the active volume.
Obj * make(std::string const &name, std::string const &title, Args &&...args)
Creates a new ROOT object with the specified name and title.
std::pair< std::size_t, std::size_t > IndexPair_t
Definition of util::zip().
std::vector< OpeningInfo_t > const & all() const
std::size_t nThresholds() const
Returns the number of thresholds currently registered.
Utilities related to art service access.
Utilities for the conversion of trigger gate data formats.
fhicl::Atom< nanoseconds > TriggerTimeResolution
std::optional< typename Optional::value_type > getOptionalValue(Optional const ¶meter)
Returns the value of an optional parameter as std::optional.
Tracks pass rate by discrimination threshold and trigger pattern name.
static PlotCategories_t const DefaultPlotCategories
List of event categories.
Definition of util::enumerate().
Simple utility for human-friendly binning.
virtual void initializeEventPlots(PlotSandbox &plots) const
Initializes a single, trigger-independent plot set into plots.
A collection of useful beam gates. Make one with makeGatePack().
virtual void fillEventPlots(EventInfo_t const &eventInfo, PlotSandbox const &plots) const
Fills the plots (initializeEventPlots()) with info from eventInfo.
std::vector< std::string > selectPlotCategories(EventInfo_t const &info, PlotCategories_t const &categories) const
Returns the names of the plot categories event qualifies for.
std::vector< std::vector< Counter_t > > fCounters
All counters; indices: [threshold][pattern].
void printSummary() const
Prints end-of-job summaries.
GeV NeutrinoEnergy() const
Returns the neutrino energy [GeV].
decltype(auto) subSandboxes() const
Returns an object proper to iterate through all contained sand boxes.
auto gatesIn(TrackingGateColl &trackingGates)
void dump(std::ostream &out) const
Dump all the counters on the specified stream.
fhicl::OptionalAtom< std::string > EventDetailsLogCategory
fhicl::Atom< bool > PlotOnlyActiveVolume
decltype(auto) const_values(Coll &&coll)
Range-for loop helper iterating across the constant values of the specified collection.
virtual void fillAllEfficiencyPlots(EventInfo_t const &eventInfo, PMTInfo_t const &PMTinfo, TriggerInfo_t const &triggerInfo, PlotSandbox const &plots) const
OpeningInfo_t const & main() const
Returns the full data (undefined if !fired()).
static std::vector< geo::CryostatID > makeChannelCryostatMap(geo::GeometryCore const &geom)
Fills and returns a map of cryostat ID for each optical detector channel.
Counter_t const & counter(Threshold_t const &threshold, std::string const &patternName) const
std::string const & name() const
Returns the sandbox name.
IndexPair_t create(Threshold_t const &threshold, std::string const &patternName)
Creates and returns a new counter.
double lower() const
Returns the value of the lower end of the first bin.
void deleteEmptyPlots()
Deletes plots with no entries, and directories which became empty.
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
GeV LeptonEnergy() const
Returns the lepton energy [GeV].
pure virtual base interface for detector clocks
std::size_t thresholdIndex(Threshold_t const &threshold) const
Returns the index of the specified threshold (max() if not registered).
bool hasDepEnergy() const
Returns whether generator information is available.
bool deleteSubSandbox(std::string const &name)
Deletes the subbox with the specified name and its directory.
bool hasVertex() const
Returns whether this type of event has a known vertex.
TriggerGatesPerCryostat_t splitByCryostat(TriggerGates_t &&gates) const
Moves the data in gates in a collection of gates by cryostat.
fhicl::OptionalAtom< std::string > EventTreeName
Helper data structure to store transient trigger result.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
bool hasPattern(std::string const &patternName) const
Returns whether the specified pattern is registered.
BinningSpecs alignBinningTo(BinningSpecs const &binning, double boundary, bool extendCoverage=true)
Returns a binning shifted to align with the specified boundary.
TriggerGates_t readTriggerGates(art::Event const &event, art::InputTag const &dataTag) const
fhicl::Atom< art::InputTag > DetectorParticleTag
timescale_traits< OpticalTimeCategory >::tick_interval_t optical_time_ticks
fhicl::Atom< std::string > TriggerGatesTag
fhicl::Atom< microseconds > BeamGateStart
Access the description of detector geometry.
Information about the event.
std::size_t registerPattern(std::string const &name)
Registers a new pattern in the index and returns its index (unchecked).
fhicl::Sequence< art::InputTag > GeneratorTags
GeV DepositedEnergyInPreSpill() const
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Data structure holding binning information.
virtual void initializePMTplots(PlotSandbox &plots) const
virtual bool shouldPlotEvent(EventInfo_t const &eventInfo) const
Definitions of geometry vector data types.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
virtual void initializePlotSet(PlotSandbox &plots, std::vector< SettingsInfo_t > const &settings) const
Initializes full set of plots for (ADC threshold + category) into plots.
Simple functions to streamline the creation of DetectorClocksData.
void assign(bool inPlots)
Fills the information of the specified event.
fhicl::Sequence< std::string > OnlyPlotCategories
counts_as<> counts
Number of ADC counts, represented by signed short int.
DirObj * getDirectory() const
Fetches the base directory of the sandbox.
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
icarus::trigger::ReadoutTriggerGate< TriggerGateTick_t, TriggerGateTicks_t, raw::Channel_t > OpticalTriggerGateData_t
Type of trigger gate data serialized into art data products.
std::size_t nSubSandboxes() const
Returns the number of contained sand boxes.
A bunch of diverse utilities and futilities related to ROOT.
std::vector< PlotDef > plots
GatePack_t makeGatePack(art::Event const *event=nullptr) const
Creates a GatePack_t from the specified event.
Helper data structure to store PMT activity information in the event.
static std::vector< ChannelID_t > extractActiveChannels(TriggerGatesPerCryostat_t const &cryoGates)
Returns all channels contributing to the trigger gates.
Simple class holding a tree.
PlotInfoTree(TTree &tree)
Creates the required branches and assigns addresses to them.
Description of geometry of one entire detector.
GeV DepositedEnergyInSpill() const
Returns the total energy deposited in the detector during beam [GeV].
An interval (duration, length, distance) between two quantity points.
std::vector< ChannelID_t > const & activeChannels() const
Returns the list of channels with activity above threshold.
std::size_t patternIndex(std::string const &patternName) const
Returns the index of the specified pattern (max() if not registered).
Base class for _art_modules plotting trigger efficiencies.
virtual void fillPMTplots(PMTInfo_t const &PMTinfo, PlotSandbox const &plots) const
Fill the plots (initializePMTplots()) with info from PMTinfo.
GeV DepositedEnergyInSpillInActiveVolume() const
Returns the energy deposited in the active volume during the beam [GeV].
double upper() const
Returns the value of the upper end of the last bin.
std::size_t registerThreshold(Threshold_t const &threshold)
Registers a new threshold in the index and returns its index (unchecked).
fhicl::Atom< std::string > LogCategory
bool hasGenerated() const
Returns whether generator information is available.
GeV DepositedEnergyInPreSpillInActiveVolume() const
fhicl::Sequence< std::string > Thresholds
void process(art::Event const &event)
Fills the plots. Also extracts the information to fill them with.
optical_tick atTick() const
Returns the time of the trigger (undefined if !fired()).
fhicl::OptionalAtom< art::InputTag > EnergyDepositSummaryTag
std::size_t createCountersForPattern(std::string const &patternName)
Creates counters for all the thresholds of the specified trigger.
bool isNeutrino() const
Returns whether the event is generated as a neutrino interaction.
BeamGateStruct makeBeamGateStruct(detinfo::DetectorTimings const &detTimings, util::quantities::intervals::microseconds duration, util::quantities::intervals::microseconds delay=util::quantities::intervals::microseconds{0.0})
Creates a BeamGateStruct object of specified duration and start.
std::string to_string(WindowPattern const &pattern)
then echo File list $list not found else cat $list while read file do echo $file sed s
contains information for a single step in the detector simulation
Data types for detinfo::DetectorTimings.
Functions pulling in STL customization if available.
Class to create an object representing a beam gate.
SandboxType & addSubSandbox(std::string const &name, std::string const &desc, Args &&...args)
Creates a new sandbox contained in this one.
static auto & demandSandbox(SandboxType &sandbox, std::string const &name)
Helper function for demandSandbox() implementations.
std::vector< icarus::trigger::TrackedOpticalTriggerGate< OpDetInfo > > FillTriggerGates(std::vector< icarus::trigger::OpticalTriggerGateData_t > const &gates, art::Assns< icarus::trigger::OpticalTriggerGateData_t, OpDetInfo > const &gateToWaveformInfo)
Creates a gate object out of trigger gate data products.
fhicl::Atom< microseconds > PreSpillWindowGap
Selected information about the event.
Threshold_t const & threshold(std::size_t index) const
void registerTriggerResult(std::size_t threshold, std::size_t pattern, bool fired)
Registers the outcome of the specified trigger.
std::size_t nPatterns() const
Returns the number of patterns currently registered.
Simple helper functions to deal with FHiCL.
geo::OpDetID const & ID() const
Returns the geometry ID of this optical detector.
fhicl::Atom< microseconds > PreSpillWindow
std::vector< std::reference_wrapper< PlotSandbox const >> PlotSandboxRefs_t
List of references to plot sandboxes.
Definition of util::values() and util::const_values().
unsigned long nBins() const
Returns the number of bins.
virtual void initializePlots(PlotCategories_t categories, std::vector< SettingsInfo_t > const &settings)
Initializes all the plot sets, one per PMT threshold.
bool hasThreshold(Threshold_t const &threshold) const
Returns whether the specified threshold is registered.
std::vector< TriggerGates_t > TriggerGatesPerCryostat_t
Type of lists of gates, one list per cryostat (outer index: cryostat no).
fhicl::Atom< microseconds > BeamGateDuration
bool empty(FixedBins< T, C > const &) noexcept
OpDetGeo const & OpDetGeoFromOpChannel(unsigned int OpChannel) const
Returns the geo::OpDetGeo object for the given channel number.
std::vector< PlotCategory > PlotCategories_t
Class counting pass/fail events.
bool IsValidOpChannel(int opChannel) const
Is this a valid OpChannel number?
timescale_traits< ElectronicsTimeCategory >::time_point_t electronics_time
A point in time on the electronics time scale.
A helper to manage ROOT objects in a art::TFileDirectory.
static icarus::trigger::details::EventInfoExtractor::EDepTags_t makeEdepTag(fhicl::Sequence< art::InputTag > const &EnergyDepositTags, fhicl::OptionalAtom< art::InputTag > const &EnergyDepositSummaryTag)
Creates a EDepTags_t out of the module configuration.
art framework interface to geometry description
std::vector< InputTriggerGate_t > TriggerGates_t
A list of trigger gates from input.
std::vector< geo::Point_t > const & Vertices() const
Returns the list of a known interaction vertex.
std::string const & patternName(std::size_t index) const
detinfo::DetectorTimings makeDetTimings(art::Event const *event)
Returns a detinfo::DetectorTimings from DetectorClocksService.
Encapsulate the construction of a single detector plane.
virtual void initializeEfficiencyPerTriggerPlots(PlotSandbox &plots) const
Initializes set of plots per complete trigger definition into plots.
A helper to manage ROOT objects with consistent naming.
virtual void fillEfficiencyPlots(EventInfo_t const &eventInfo, TriggerInfo_t const &triggerInfo, PlotSandbox const &plots) const
int InteractionType() const
Returns the interaction type.