45 #include "nusimdata/SimulationBase/MCTruth.h"
46 #include "nusimdata/SimulationBase/MCNeutrino.h"
47 #include "nusimdata/SimulationBase/MCParticle.h"
50 #include "art_root_io/TFileService.h"
51 #include "art_root_io/TFileDirectory.h"
52 #include "art/Framework/Services/Registry/ServiceHandle.h"
53 #include "art/Framework/Core/EDAnalyzer.h"
54 #include "art/Framework/Core/ModuleMacros.h"
55 #include "art/Framework/Principal/Event.h"
56 #include "art/Framework/Principal/Handle.h"
57 #include "canvas/Persistency/Common/Assns.h"
58 #include "canvas/Utilities/InputTag.h"
59 #include "canvas/Utilities/Exception.h"
60 #include "messagefacility/MessageLogger/MessageLogger.h"
61 #include "fhiclcpp/types/Sequence.h"
62 #include "fhiclcpp/types/Atom.h"
63 #include "fhiclcpp/types/OptionalAtom.h"
64 #include "cetlib_except/exception.h"
66 #include "fhiclcpp/types/DelegatedParameter.h"
67 #include "fhiclcpp/ParameterSet.h"
71 #include "TEfficiency.h"
92 using namespace util::quantities::time_literals;
108 {
return fInteractions[itWCC]; }
112 {
return fInteractions[itWNC]; }
118 nWeakChargedCurrentInteractions() + nWeakNeutralCurrentInteractions();
123 {
return nWeakChargedCurrentInteractions() > 0U; }
127 {
return nWeakNeutralCurrentInteractions() > 0U; }
131 {
return isWeakChargedCurrent() || isWeakNeutralCurrent(); }
151 {
return fEnergyDepSpillActive; }
178 { fInteractions[itWCC] +=
n; }
182 { fInteractions[itWNC] +=
n; }
203 { fEnergyDepSpillActive =
e; }
226 void dump(std::ostream& out)
const
228 out <<
"Event contains:";
230 if (nWeakChargedCurrentInteractions())
231 out <<
" " << nWeakChargedCurrentInteractions() <<
" CC";
232 if (nWeakNeutralCurrentInteractions())
233 out <<
" " << nWeakNeutralCurrentInteractions() <<
" NC";
234 if (isNu_mu()) out <<
" nu_mu";
235 if (isNu_e()) out <<
" nu_e";
236 out <<
"\nThe first neutrino has E=" << NeutrinoEnergy()
237 <<
" and becomes a lepton with E=" << LeptonEnergy()
243 out <<
" no neutrino interaction";
245 out <<
"\nTotal deposited energy: " << DepositedEnergy()
246 <<
", of which in spill " << DepositedEnergyInSpill()
247 <<
", in active volume " << DepositedEnergyInActiveVolume()
248 <<
", in active volume and in spill "
249 << DepositedEnergyInSpillInActiveVolume();
250 if (fVertices.empty()) {
251 out <<
"\nNo interaction vertex found.";
254 auto iVertex = fVertices.begin();
255 auto const vend = fVertices.end();
257 <<
"\n" << fVertices.size() <<
" interaction vertices: " << *iVertex;
258 while (++iVertex != vend) out <<
"; " << *iVertex;
261 out <<
"\nThe event is" << (isInActiveVolume()?
"":
" NOT")
262 <<
" marked as in the active volume of the detector.";
271 static constexpr std::size_t itWCC { 0U };
272 static constexpr std::size_t itWNC { 1U };
273 static constexpr std::size_t NInteractionTypes { 2U };
279 GeV fEnergyDepTotal { 0.0 };
280 GeV fEnergyDepSpill { 0.0 };
281 GeV fEnergyDepActive { 0.0 };
283 GeV fEnergyDepSpillActive { 0.0 };
285 int fNeutrinoPDG { 0 };
286 int fInteractionType { 0 };
288 GeV fNeutrinoEnergy { 0.0 };
289 GeV fLeptonEnergy { 0.0 };
292 bool nu_mu {
false };
296 bool fInActiveVolume {
false };
303 { info.
dump(out);
return out; }
317 std::string
name, std::string descr = {},
320 : fName(std::move(name)), fDescr(std::move(descr)), fTest(std::move(
test))
324 std::string
const&
name()
const {
return fName; }
332 operator std::string()
const {
return name(); }
368 "All nu_mu",
"nu_mu",
417 TTree&
tree() {
return *fTree; }
418 TTree
const&
tree()
const {
return *fTree; }
421 TTree* fTree =
nullptr;
445 void assignID(art::EventID
const&
id);
446 void assignEvent(art::Event
const& event) { assignID(event.id()); }
484 void assign(
bool inPlots);
564 template <
typename Thresholds,
typename Requirements>
566 (TTree& tree,
Thresholds const& thresholds, Requirements
const& minReqs);
569 void assignResponse(std::size_t iThr, std::size_t iReq,
bool resp);
573 std::unique_ptr<bool[]> RespTxxRxx;
582 namespace icarus::trigger {
class TriggerEfficiencyPlots; }
1230 fhicl::Sequence<art::InputTag> GeneratorTags {
1231 Name(
"GeneratorTags"),
1232 Comment(
"labels of the event generators"),
1233 std::vector<art::InputTag>{
"generator" }
1236 fhicl::Atom<art::InputTag> DetectorParticleTag {
1237 Name(
"DetectorParticleTag"),
1238 Comment(
"label of simulated particles through the detector"),
1242 fhicl::Sequence<art::InputTag> EnergyDepositTags {
1243 Name(
"EnergyDeposits"),
1244 Comment(
"label of energy deposition data product(s) in the detector"),
1245 std::vector<art::InputTag>{
"largeant:TPCActive" }
1248 fhicl::Atom<std::string> TriggerGatesTag {
1249 Name(
"TriggerGatesTag"),
1250 Comment(
"label of the input trigger gate data product (no instance name)")
1255 Comment(
"thresholds to consider [ADC counts]")
1258 fhicl::Atom<microseconds> BeamGateDuration {
1259 Name(
"BeamGateDuration"),
1260 Comment(
"length of time interval when optical triggers are accepted")
1263 fhicl::Sequence<unsigned int> MinimumPrimitives {
1264 Name(
"MinimumPrimitives"),
1265 Comment(
"minimum required number of trigger primitives for a trigger")
1268 fhicl::Atom<nanoseconds> TriggerTimeResolution {
1269 Name(
"TriggerTimeResolution"),
1270 Comment(
"resolution of trigger in time"),
1274 fhicl::Atom<bool> PlotOnlyActiveVolume {
1275 Name(
"PlotOnlyActiveVolume"),
1277 (
"only events within TPC active volume are plot (if that makes sense)"),
1281 fhicl::OptionalAtom<std::string> EventTreeName {
1282 Name(
"EventTreeName"),
1283 Comment(
"name of a ROOT tree where to store event-by-event information")
1286 fhicl::OptionalAtom<std::string> EventDetailsLogCategory {
1287 Name(
"EventDetailsLogCategory"),
1288 Comment(
"name of the category used for event information output")
1291 fhicl::Atom<std::string> LogCategory {
1292 Name(
"LogCategory"),
1293 Comment(
"name of the category used for the output"),
1294 "SlidingWindowTrigger"
1318 virtual void analyze(art::Event
const& event)
override;
1321 virtual void endJob()
override;
1340 = std::vector<std::reference_wrapper<PlotSandbox const>>;
1401 std::atomic<unsigned int> nEvents { 0U };
1402 std::atomic<unsigned int> nPlottedEvents { 0U };
1422 bool shouldPlotEvent(
EventInfo_t const& eventInfo)
const;
1426 std::vector<std::string> selectPlotCategories
1469 std::vector<TriggerGateData_t> combineTriggerPrimitives(
1470 art::Event
const& event,
1472 art::InputTag
const& dataTag
1480 std::vector<TriggerGateData_t>
const& primitiveCounts
1485 (art::Event
const& event, art::InputTag
const& dataTag)
const;
1487 static std::string thrAndCatName
1488 (std::string
const& boxName, std::string
const& category)
1489 {
return boxName +
"_" + category; }
1490 static std::string thrAndCatName
1492 {
return thrAndCatName(box.
name(), category); }
1495 template <
typename TrigGateColl>
1496 static auto computeMaxGate(TrigGateColl
const& gates);
1509 : art::EDAnalyzer(config)
1511 , fGeneratorTags (config().GeneratorTags())
1512 , fDetectorParticleTag (config().DetectorParticleTag())
1513 , fEnergyDepositTags (config().EnergyDepositTags())
1514 , fBeamGateDuration (config().BeamGateDuration())
1515 , fMinimumPrimitives (config().MinimumPrimitives())
1516 , fTriggerTimeResolution(config().TriggerTimeResolution())
1517 , fPlotOnlyActiveVolume (config().PlotOnlyActiveVolume())
1520 ,
fGeom (*lar::providerFrom<geo::Geometry>())
1521 , fOutputDir (*art::ServiceHandle<art::TFileService>())
1527 if (config().EventDetailsLogCategory(fLogEventDetails)) {
1530 if (fLogEventDetails.empty()) fLogEventDetails =
fLogCategory;
1533 std::string
const discrModuleLabel = config().TriggerGatesTag();
1539 if (config().EventTreeName.hasValue()) {
1540 std::string treeName;
1541 config().EventTreeName(treeName);
1543 fIDTree = std::make_unique<EventIDTree>
1544 (*(fOutputDir.make<TTree>(treeName.c_str(),
"Event information")));
1545 fEventTree = std::make_unique<EventInfoTree>(fIDTree->tree());
1546 fPlotTree = std::make_unique<PlotInfoTree>(fIDTree->tree());
1547 fResponseTree = std::make_unique<ResponseTree>(
1549 util::get_elements<0U>(fADCthresholds), fMinimumPrimitives
1560 for (art::InputTag
const& inputTag: fGeneratorTags)
1561 consumes<std::vector<simb::MCTruth>>(inputTag);
1562 for (art::InputTag
const& inputTag: fEnergyDepositTags)
1563 consumes<std::vector<sim::SimEnergyDeposit>>(inputTag);
1575 auto const clockData
1576 = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
1581 log <<
"\nConfigured " << fADCthresholds.size() <<
" thresholds:";
1582 for (
auto const& [ threshold, dataTag ]: fADCthresholds)
1583 log <<
"\n * " << threshold <<
" ADC (from '" << dataTag.encode() <<
"')";
1613 auto const clockData
1614 = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
1616 EventInfo_t const eventInfo = extractEventInfo(event, clockData);
1618 bool const bPlot = shouldPlotEvent(eventInfo);
1619 if (bPlot) ++nPlottedEvents;
1621 if (fIDTree) fIDTree->assignEvent(event);
1622 if (fPlotTree) fPlotTree->assign(bPlot);
1623 if (fEventTree) fEventTree->assignEvent(eventInfo);
1625 std::vector<std::string> selectedPlotCategories
1630 <<
"Event " <<
event.id() <<
" falls in " << selectedPlotCategories.size()
1633 for (std::string
const& name: selectedPlotCategories)
1634 log <<
" \"" << name <<
"\"";
1637 if (!fLogEventDetails.empty()) {
1638 mf::LogTrace(fLogEventDetails)
1639 <<
"Event " <<
event.id() <<
": " << eventInfo;
1648 for (
auto&& [ iThr, thrPair, thrPlots ]
1652 auto const& [ threshold, dataTag ] = thrPair;
1661 std::vector<TriggerGateData_t> primitiveCounts;
1662 std::vector<TriggerGateData_t> combinedTriggerPrimitives
1663 = combineTriggerPrimitives(event, threshold, dataTag);
1667 = combinedPrimitive.
Mul(beam_gate);
1669 primitiveCounts.push_back(primitiveCount);
1678 for (std::string
const& name: selectedPlotCategories)
1679 selectedPlots.emplace_back(*(thrPlots.findSandbox(name)));
1683 plotResponses(iThr, threshold,
detTimings, selectedPlots, eventInfo, primitiveCounts);
1691 if (fIDTree) fIDTree->tree().Fill();
1700 << nPlottedEvents <<
"/" << nEvents <<
" events plotted."
1710 using namespace std::string_literals;
1713 : util::get_elements<0U>(fADCthresholds))
1716 auto const thr = threshold.value();
1724 category.description()
1727 initializePlotSet(clockData, plots);
1729 fThresholdPlots.push_back(std::move(thrPlots));
1733 log <<
"Created " << fThresholdPlots.size() <<
" plot boxes:\n";
1734 for (
auto const& box: fThresholdPlots) {
1747 auto [ minimumPrimBinning, minimumPrimBinningLabels ]
1749 assert(minimumPrimBinning.size() == minimumPrimBinningLabels.size() + 1U);
1753 log <<
"TriggerEfficiencyPlots (plots '"
1754 << plots.
name() <<
"') variable binning including the "
1755 << fMinimumPrimitives.size() <<
" points {";
1756 for (
auto value: fMinimumPrimitives) log <<
" " <<
value;
1757 log <<
" } => " << minimumPrimBinningLabels.size() <<
" bins: ";
1758 for (
auto const& [ value, label ]
1759 : util::zip<1U>(minimumPrimBinning, minimumPrimBinningLabels))
1761 log <<
" " << value <<
" (\"" << label <<
"\") =>";
1763 log <<
" " << minimumPrimBinning.back();
1771 {
detTimings.toOpticalTicks(fTriggerTimeResolution) };
1774 auto* TrigTime = plots.
make<TH2F>(
1777 ";minimum requested number of trigger primitives"
1778 ";optical time tick [ /" +
util::to_string(triggerResolutionTicks) +
" ]",
1779 minimumPrimBinning.size() - 1U, minimumPrimBinning.data(),
1781 (beam_gate_opt.second - beam_gate_opt.first) / triggerResolutionTicks,
1782 beam_gate_opt.first.value(), beam_gate_opt.second.value()
1787 auto* Eff = plots.
make<TEfficiency>(
1789 "Efficiency of triggering"
1790 ";minimum requested number of trigger primitives"
1791 ";trigger efficiency",
1792 minimumPrimBinning.size() - 1U, minimumPrimBinning.data()
1801 const_cast<TH1*>(Eff->GetTotalHistogram())->GetXaxis(),
1802 minimumPrimBinningLabels
1810 "Number of trigger primitives (\"channels firing at once\")"
1811 ";maximum trigger primitives at the same time"
1819 initializeEventPlots(plots);
1826 using SS_t = std::pair<std::string, std::string>;
1827 std::array<SS_t, 2U>
const classes {
1828 SS_t{
"triggering",
"triggering events" },
1829 SS_t{
"nontriggering",
"non-triggering events" }
1831 for (
auto minCount: fMinimumPrimitives) {
1837 (
"Req" + minCountStr, minCountStr +
" channels required");
1839 initializeEfficiencyPerTriggerPlots(clockData, reqBox);
1841 for (
auto const& [ name, desc ]: classes) {
1845 initializeEventPlots(box);
1854 "NeutrinoEnergy_NoTrig",
1855 "True Neutrino Energy of Non-Triggered Event"
1856 ";neutrino energy [GeV]"
1861 "EnergyInSpill_NoTrig",
1862 "Energy eposited during the beam gate opening of Non-Triggered Event"
1863 ";deposited energy [ GeV ]"
1864 ";events [ / 50 MeV ]",
1868 "InteractionType_NoTrig",
1869 "Interaction type of Non-Triggered Event"
1871 ";events [ / 50 MeV ]",
1875 "LeptonEnergy_NoTrig",
1876 "Energy of outgoing lepton of Non-Triggered Event"
1877 ";lepton generated energy [ GeV ]"
1878 ";events [ / 50 MeV ]",
1891 {
detTimings.toOpticalTicks(fTriggerTimeResolution) };
1898 plots.
make<TEfficiency>(
1899 "EffVsEnergyInSpill",
1900 "Efficiency of triggering vs. energy deposited in spill"
1901 ";energy deposited in spill [ GeV ]"
1902 ";trigger efficiency [ / 50 GeV ]",
1906 plots.
make<TEfficiency>(
1907 "EffVsEnergyInSpillActive",
1908 "Efficiency of triggering vs. energy deposited in active volume"
1909 ";energy deposited in active volume in spill [ GeV ]"
1910 ";trigger efficiency [ / 50 GeV ]",
1914 plots.
make<TEfficiency>(
1915 "EffVsNeutrinoEnergy",
1916 "Efficiency of triggering vs. neutrino energy"
1917 ";neutrino true energy [ GeV ]"
1918 ";trigger efficiency [ / 50 GeV ]",
1922 plots.
make<TEfficiency>(
1923 "EffVsLeptonEnergy",
1924 "Efficiency of triggering vs. outgoing lepton energy"
1925 ";final state lepton true energy [ GeV ]"
1926 ";trigger efficiency [ / 50 GeV ]",
1933 ";optical time tick [ /" +
util::to_string(triggerResolutionTicks) +
" ]",
1934 (beam_gate_opt.second - beam_gate_opt.first) / triggerResolutionTicks,
1935 beam_gate_opt.first.value(), beam_gate_opt.second.value()
1947 auto [ minimumPrimBinning, minimumPrimBinningLabels ]
1949 assert(minimumPrimBinning.size() == minimumPrimBinningLabels.size() + 1U);
1953 log <<
"TriggerEfficiencyPlots (plots '"
1954 << plots.
name() <<
"') variable binning including the "
1955 << fMinimumPrimitives.size() <<
" points {";
1956 for (
auto value: fMinimumPrimitives) log <<
" " <<
value;
1957 log <<
" } => " << minimumPrimBinningLabels.size() <<
" bins: ";
1958 for (
auto const& [ value, label ]
1959 : util::zip<1U>(minimumPrimBinning, minimumPrimBinningLabels))
1961 log <<
" " << value <<
" (\"" << label <<
"\") =>";
1963 log <<
" " << minimumPrimBinning.back();
1971 "True Neutrino Energy"
1972 ";neutrino energy [GeV]"
1978 "Energy deposited during the beam gate opening"
1979 ";energy deposited in spill [ GeV ]"
1980 ";events [ / 50 MeV ]",
1984 "EnergyInSpillActive",
1985 "Energy deposited during the beam gate opening in active volume"
1986 ";energy deposited in active volume in spill [ GeV ]"
1987 ";events [ / 50 MeV ]",
1999 "Energy of outgoing lepton"
2000 ";deposited energy [ GeV ]"
2001 ";events [ / 50 MeV ]",
2005 "InteractionVertexYZ",
2006 "Vertex of triggered interaction"
2009 120, -1200., +1200.,
2020 if (fPlotOnlyActiveVolume
2031 std::vector<std::string>
2035 std::vector<std::string> selected;
2037 for (
auto const& category: categories)
2038 if (category(info)) selected.push_back(category);
2055 for (art::InputTag
const& inputTag: fGeneratorTags) {
2057 auto const& truthRecords
2058 = *(
event.getValidHandle<std::vector<simb::MCTruth>>(inputTag));
2060 for (simb::MCTruth
const& truth: truthRecords) {
2062 if (truth.NeutrinoSet()) {
2068 simb::MCParticle
const&
nu = truth.GetNeutrino().Nu();
2076 switch (nu.PdgCode()) {
2087 switch (truth.GetNeutrino().CCNC()) {
2092 <<
"Event " <<
event.id() <<
" has unexpected NC/CC flag ("
2093 << truth.GetNeutrino().CCNC() <<
")";
2115 GeV totalEnergy { 0.0 }, inSpillEnergy { 0.0 };
2116 GeV activeEnergy { 0.0 }, inSpillActiveEnergy { 0.0 };
2121 auto const beam_gate_sim = std::make_pair(
detTimings.toSimulationTime(beam_gate_opt.first),
2122 detTimings.toSimulationTime(beam_gate_opt.second));
2123 for (art::InputTag
const& edepTag: fEnergyDepositTags) {
2125 auto const& energyDeposits
2126 = *(
event.getValidHandle<std::vector<sim::SimEnergyDeposit>>(edepTag));
2128 <<
"Event " <<
event.id() <<
" has " << energyDeposits.size()
2129 <<
" energy deposits recorded in '" << edepTag.encode() <<
"'";
2133 MeV const e { edep.Energy() };
2137 = (t >= beam_gate_sim.first) && (t <= beam_gate_sim.second);
2140 if (inSpill) inSpillEnergy +=
e;
2142 if (pointInActiveTPC(edep.MidPoint())) {
2144 if (inSpill) inSpillActiveEnergy +=
e;
2166 return fGeom.PositionToTPCptr(point);
2182 art::Event
const& event,
2184 art::InputTag
const& dataTag
2185 )
const -> std::vector<TriggerGateData_t>{
2191 std::vector<std::vector<TrackedTriggerGate_t>>
const& cryoGates
2194 std::vector<TriggerGateData_t> cryoCombinedGate;
2196 for (
auto const& gates: (cryoGates)) {
2198 <<
"Simulating trigger response with ADC threshold " << threshold
2199 <<
" from '" << dataTag.encode() <<
"' (" << gates.size() <<
" primitives)";
2201 if (gates.empty()) {
2203 <<
" No trigger primitive found for threshold " << threshold
2204 <<
" ('" << dataTag.encode() <<
"')";
2210 cryoCombinedGate.push_back(std::move(combinedGate).gate()) ;
2213 return cryoCombinedGate;
2219 template <
typename TrigGateColl>
2221 (TrigGateColl
const& gates)
2225 if (
empty(gates))
return decltype(*
begin(gates)){};
2227 auto iGate =
cbegin(gates);
2228 auto const gend =
cend(gates);
2229 auto maxGate = *iGate;
2230 while (++iGate != gend) maxGate.Max(*iGate);
2243 std::vector<TriggerGateData_t>
const& primitiveCounts
2262 using namespace std::string_literals;
2267 using PrimitiveCount_t = std::pair<ClockTick_t, OpeningCount_t>;
2270 assert(!primitiveCounts.empty());
2271 auto const primitiveCount = computeMaxGate(primitiveCounts);
2273 auto const maxPrimitiveTime { primitiveCount.findMaxOpen() };
2274 PrimitiveCount_t
const maxPrimitives
2275 { maxPrimitiveTime, primitiveCount.openingCount(maxPrimitiveTime) };
2278 <<
"Max primitive count in " << threshold <<
": "
2279 << maxPrimitives.second <<
" at tick " << maxPrimitives.first <<
" ("
2292 PrimitiveCount_t lastMinCount { TriggerGateData_t::MinTick, 0 };
2303 TH1& Hist(std::string
const& name)
const {
return plots.
demand<TH1>(
name); }
2304 TH2& Hist2D(std::string
const& name)
const {
return plots.
demand<TH2>(
name); }
2305 TEfficiency& Eff(std::string
const& name)
const
2313 if (fired && (lastMinCount.second < minCount)) {
2315 ClockTick_t
const time = primitiveCount.findOpen(minCount);
2316 if (time == TriggerGateData_t::MaxTick) {
2318 <<
"Never got at " << minCount <<
" primitives or above.";
2322 lastMinCount = { time, primitiveCount.openingCount(time) };
2324 <<
"Reached " << minCount <<
" primitives or above ("
2325 << lastMinCount.second <<
") at " << lastMinCount.first <<
".";
2332 if (fResponseTree) fResponseTree->assignResponse(iThr, iReq, fired);
2334 std::string
const minCountStr {
"Req" +
std::to_string(minCount) };
2339 HistGetter
const get { plotSet };
2342 get.Eff(
"Eff"s).Fill(fired, minCount);
2346 get.Hist2D(
"TriggerTick"s).Fill(minCount, lastMinCount.first);
2347 if (minCount == 1) {
2348 for (
auto point : eventInfo.
fVertices) {
2349 get.Hist2D(
"InteractionVertexYZ"s).Fill(point.Z(), point.Y());
2358 HistGetter
const getTrigEff { plotSet.demandSandbox(minCountStr) };
2361 getTrigEff.Eff(
"EffVsEnergyInSpill").Fill
2363 getTrigEff.Eff(
"EffVsEnergyInSpillActive").Fill
2365 getTrigEff.Eff(
"EffVsNeutrinoEnergy").Fill
2367 getTrigEff.Eff(
"EffVsLeptonEnergy").Fill
2370 getTrigEff.Hist(
"TriggerTick"s).Fill(lastMinCount.first);
2378 HistGetter
const getTrig
2379 { getTrigEff.box().demandSandbox(fired?
"triggering":
"nontriggering") };
2384 getTrig.Hist(
"NeutrinoEnergy"s).Fill(
double(eventInfo.
NeutrinoEnergy()));
2386 getTrig.Hist(
"LeptonEnergy"s).Fill(
double(eventInfo.
LeptonEnergy()));
2388 TH2& vertexHist = getTrig.Hist2D(
"InteractionVertexYZ"s);
2389 for (
auto const& point: eventInfo.
fVertices)
2390 vertexHist.Fill(point.Z(), point.Y());
2396 if (!fired && minCount == 1 ) {
2398 get.Hist(
"NeutrinoEnergy_NoTrig"s).Fill(
double(eventInfo.
NeutrinoEnergy()));
2400 get.Hist(
"LeptonEnergy_NoTrig"s).Fill(
double(eventInfo.
LeptonEnergy()));
2415 HistGetter
const get(plotSet);
2418 get.Hist(
"NPrimitives"s).Fill(maxPrimitives.second);
2427 get.Hist(
"LeptonEnergy"s).Fill(
double(eventInfo.
LeptonEnergy()));
2429 TH2& vertexHist =
get.Hist2D(
"InteractionVertexYZ"s);
2430 for (
auto const& point: eventInfo.
fVertices)
2431 vertexHist.Fill(point.Z(), point.Y());
2440 (art::Event
const& event, art::InputTag
const& dataTag)
const
2441 -> std::vector<std::vector<TrackedTriggerGate_t>>
2444 std::vector<TrackedTriggerGate_t> allGates
2447 std::vector<geo::CryostatID> fChannelCryostat;
2449 fChannelCryostat.reserve(
fGeom.NOpChannels());
2451 if (!
fGeom.IsValidOpChannel(opChannel))
continue;
2452 fChannelCryostat[opChannel] =
fGeom.OpDetGeoFromOpChannel(opChannel).ID();
2455 std::vector<std::vector<TrackedTriggerGate_t>> gatesPerCryostat
2456 {
fGeom.Ncryostats() };
2457 for (
auto& gate: allGates) {
2458 assert(gate.gate().hasChannels());
2459 gatesPerCryostat[fChannelCryostat[gate.channels().front()].Cryostat]
2460 .push_back(std::move(gate));
2462 return gatesPerCryostat;
2502 fInPlots =
static_cast<Bool_t
>(inPlots);
2512 this->
tree().Branch(
"CC", &
fCC);
2513 this->
tree().Branch(
"NC", &
fNC);
2548 template <
typename Thresholds,
typename Requirements>
2550 (TTree& tree,
Thresholds const& thresholds, Requirements
const& minReqs)
2553 , RespTxxRxx{ std::make_unique<bool[]>(
indices.size()) }
2561 std::string
const branchName
2565 (branchName.c_str(), &(RespTxxRxx[
indices(iThr, iReq)]));
2576 (std::size_t iThr, std::size_t iReq,
bool resp)
2578 RespTxxRxx[
indices(iThr, iReq)] = resp;
BEGIN_PROLOG BeamGateDuration pmtthr physics producers trigtilewindowORS Thresholds
process_name opflashCryo1 flashfilter analyze
GeV DepositedEnergyInSpill() const
Returns the total energy deposited in the detector during beam [GeV].
Obj * make(std::string const &name, std::string const &title, Args &&...args)
Creates a new ROOT object with the specified name and title.
Base_t GateData_t
Type for gate data access.
void initializeEventPlots(PlotSandbox &plots) const
Initializes a single, trigger-independent plot set into plots.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Produces plots about trigger simulation and trigger efficiency.
Definition of util::zip().
GeV DepositedEnergyInSpillInActiveVolume() const
Returns the energy deposited in the active volume during the beam [GeV].
Utilities related to art service access.
EventIDTree(TTree &tree)
Creates the required branches and assigns addresses to them.
std::string const & description() const
Returns the description of the category.
std::string fLogEventDetails
Steam where to print event info.
Utilities for the conversion of trigger gate data formats.
void SetInteractionType(int type)
nanoseconds fTriggerTimeResolution
Trigger resolution in time.
std::string TruthInteractionTypeName(int type)
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
void AddWeakNeutralCurrentInteractions(unsigned int n=1U)
Marks this event as including n more weak neutral current interactions.
void assignEvent(EventInfo_t const &info)
Fills the information of the specified event.
std::pair< std::vector< double >, std::vector< std::string > > makeVariableBinningAndLabels(Coll const ¢ralPoints)
Returns a variable size binning for the points.
std::vector< unsigned int > fMinimumPrimitives
Minimum number of trigger primitives for a trigger to happen.
void SetNu_mu(bool numu)
Marks the neutrino flavor.
An object representing a time gate, with a start and and end.
Definition of util::get_elements() and util::get_const_elements().
Definition of util::enumerate().
A wrapper to trigger gate objects tracking the input of operations.
microseconds_as<> microseconds
Type of time interval stored in microseconds, in double precision.
std::vector< std::vector< TrackedTriggerGate_t > > ReadTriggerGates(art::Event const &event, art::InputTag const &dataTag) const
Reads a set of input gates from the event.
GeV DepositedEnergyInActiveVolume() const
Returns the energy deposited in the active volume during the event [GeV].
void dump(std::ostream &out) const
Prints the content of the object into a stream.
std::vector< std::string > selectPlotCategories(EventInfo_t const &info, PlotCategories_t const &categories) const
Returns the names of the plot categories event qualifies for.
Class managing the serialization of event information in a simple ROOT tree.
Class managing the serialization of trigger responses in a simple ROOT tree.
ResponseTree(TTree &tree, Thresholds const &thresholds, Requirements const &minReqs)
Constructor: accommodates that many thresholds and requirements.
Geometry information for a single TPC.
void assignResponse(std::size_t iThr, std::size_t iReq, bool resp)
Assigns the response for the specified trigger.
int NeutrinoPDG() const
Returns the neutrino PDG code.
bool isInActiveVolume() const
Returns whether there is an interaction within the active volume.
bool isWeakNeutralCurrent() const
Returns whether the event is generated as a neutrino NC interaction.
geo::BoxBoundedGeo const & ActiveBoundingBox() const
Returns the box of the active volume of this TPC.
decltype(auto) const_values(Coll &&coll)
Range-for loop helper iterating across the constant values of the specified collection.
geo::GeometryCore const & fGeom
std::size_t size(FixedBins< T, C > const &) noexcept
void applyAxisLabels(TAxis *pAxis, std::vector< std::string > const &labels, int first=1)
Sets all the labels starting with the bin first (1 by default).
void declareConsumes(ConsumesCollector &collector) const
Declares to the collector the data products that are going to be read.
TensorIndices class to flatten multi-dimension indices into linear.
std::string const & name() const
Returns the sandbox name.
art::TFileDirectory fOutputDir
ROOT directory where all the plots are written.
art::InputTag fDetectorParticleTag
static auto computeMaxGate(TrigGateColl const &gates)
Returns a gate that is Max() of all the specified gates.
pure virtual base interface for detector clocks
EventInfoTree(TTree &tree)
Creates the required branches and assigns addresses to them.
unsigned int nWeakCurrentInteractions() const
Returns the number of weak current interactions in the event.
Assembles and returns trigger gates from serialized data.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
std::unique_ptr< ResponseTree > fResponseTree
Handler of ROOT tree output.
timescale_traits< OpticalTimeCategory >::tick_interval_t optical_time_ticks
Interface to detinfo::DetectorClocks.
PlotCategories_t const PlotCategories
List of event categories.
Access the description of detector geometry.
Information about the event.
void SetNeutrinoPDG(int NU)
Marks this event's neutrino type.
Charged-current interactions.
void initializeEfficiencyPerTriggerPlots(detinfo::DetectorClocksData const &clockData, PlotSandbox &plots) const
Initializes set of plots per complete trigger definition into plots.
triggergatedata_t & Mul(triggergatedata_t const &other)
Combines with a gate, keeping the product of openings of the two.
std::vector< art::InputTag > fGeneratorTags
Generator data product tags.
void SetNeutrinoEnergy(GeV eNu)
EventInfo_t extractEventInfo(art::Event const &event, detinfo::DetectorClocksData const &clockData) const
Extracts from event the relevant information on the physics event.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
std::pair< detinfo::timescales::optical_tick, detinfo::timescales::optical_tick > const fBeamGateOpt
Beam gate start and stop tick in optical detector scale.
void initializePlots(detinfo::DetectorClocksData const &clockData, PlotCategories_t const &categories)
Initializes all the plot sets, one per threshold.
microseconds fBeamGateDuration
Duration of the gate during with global optical triggers are accepted.
std::vector< PlotSandbox > fThresholdPlots
All plots, one set per ADC threshold.
Converts a tensor element specification into a linear index.
electronics_time toElectronicsTime(FromTime time) const
Converts a time point into electronics time scale.
geo::TPCGeo const * pointInActiveTPC(geo::Point_t const &point) const
TimeRange< simulation_time > const & asSimulationRange() const
Returns the gate as start/stop pair in simulation time scale.
std::vector< PlotCategory > PlotCategories_t
PlotCategory(std::string name, std::string descr={}, QualifyFunc_t &&test=[](EventInfo_t const &){return true;})
Constructor from category name and test function.
Definitions of geometry vector data types.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
timescale_traits< SimulationTimeCategory >::time_point_t simulation_time
A point in time on the simulation time scale.
A value measured in the specified unit.
megaelectronvolt_as<> megaelectronvolt
Type of energy stored in megaelectronvolt, in double precision.
int InteractionType() const
Simple type definitions for trigger algorithms.
bool shouldPlotEvent(EventInfo_t const &eventInfo) const
EventInfo_t()
Constructor. As if nobody noticed.
std::array< unsigned int, NInteractionTypes > fInteractions
A trigger gate data object for optical detector electronics.
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.
void initializePlotSet(detinfo::DetectorClocksData const &clockData, PlotSandbox &plots) const
Initializes full set of plots for (ADC threshold + category) into plots.
A bunch of diverse utilities and futilities related to ROOT.
void SetInActiveVolume(bool active=true)
Set whether the event has relevant activity in the active volume.
bool isNeutrino() const
Returns whether the event is generated as a neutrino interaction.
TTree const & tree() const
bool isWeakChargedCurrent() const
Returns whether the event is generated as a neutrino CC interaction.
std::unique_ptr< PlotInfoTree > fPlotTree
Handler of ROOT tree output.
bool hasVertex() const
Returns whether this type of event has a known vertex.
std::vector< PlotDef > plots
unsigned int nWeakNeutralCurrentInteractions() const
Returns the number of weak neutral current interactions in the event.
Class managing the serialization of plot information in a simple ROOT tree.
void plotResponses(std::size_t iThr, icarus::trigger::ADCCounts_t const threshold, detinfo::DetectorTimings const &detTimings, PlotSandboxRefs_t const &plots, EventInfo_t const &info, std::vector< TriggerGateData_t > const &primitiveCounts) const
Adds all the responses (one per threshold) to the plots.
Utilities for the conversion of trigger gate data formats.
BEGIN_PROLOG vertical distance to the surface Name
std::string const fLogCategory
Message facility stream category for output.
void assignID(art::EventID const &id)
Fills the information of the specified event.
Description of geometry of one entire detector.
An interval (duration, length, distance) between two quantity points.
gigaelectronvolt_as<> gigaelectronvolt
Type of energy stored in gigaelectronvolt, in double precision.
std::unique_ptr< EventInfoTree > fEventTree
Handler of ROOT tree output.
std::string const & name() const
Returns the name of the category.
std::map< icarus::trigger::ADCCounts_t, art::InputTag > fADCthresholds
ADC thresholds to read, and the input tag connected to their data.
void AddWeakChargedCurrentInteractions(unsigned int n=1U)
Marks this event as including n more weak charged current interactions.
auto sumGates(GateColl const &gates)
Sums all the gates in a collection.
art::EDAnalyzer::Table< Config > Parameters
unsigned int OpeningCount_t
Type of count of number of open channels.
nanoseconds_as<> nanoseconds
Type of time interval stored in nanoseconds, in double precision.
geo::TPCGeo const * pointInTPC(geo::Point_t const &point) const
Returns the TPC point is within, nullptr if none.
Utilities to read interval and point quantity FHiCL configuration.
std::vector< art::InputTag > fEnergyDepositTags
Energy deposition data product tags.
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
unsigned int nWeakChargedCurrentInteractions() const
Returns the number of weak charged current interactions in the event.
Dimensioned variables representing energy.
void AddVertex(geo::Point_t const &vertex)
Adds a point to the list of interaction vertices in the event.
bool fPlotOnlyActiveVolume
Plot only events in active volume.
Contains all timing reference information for the detector.
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
Utility functions to print MC truth information.
std::ostream & operator<<(std::ostream &, Binner< T > const &)
void assignEvent(art::Event const &event)
Dimensioned variables representing space or time quantities.
bool test(EventInfo_t const &info) const
Returns whether the event belong to this category.
contains information for a single step in the detector simulation
virtual void endJob() override
Prints end-of-job summaries.
std::pair< detinfo::timescales::simulation_time, detinfo::timescales::simulation_time > const fBeamGateSim
Beam gate start and stop time in simulation scale.
A class exposing an upgraded interface of detinfo::DetectorClocksData.
Data types for detinfo::DetectorTimings.
Energy deposition in the active material.
Functions pulling in STL customization if available.
TriggerEfficiencyPlots(Parameters const &config)
Class to create an object representing a beam gate.
virtual void analyze(art::Event const &event) override
Fills the plots. Also extracts the information to fill them with.
SandboxType & addSubSandbox(std::string const &name, std::string const &desc, Args &&...args)
Creates a new sandbox contained in this one.
Neutral-current interactions.
void SetDepositedEnergyInActiveVolumeInSpill(GeV e)
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
void SetDepositedEnergy(GeV e)
Sets the total deposited energy of the event [GeV].
void SetDepositedEnergyInActiveVolume(GeV e)
Sets the total deposited energy of the event in active volume [GeV].
Logical multi-level gate.
std::function< bool(EventInfo_t const &)> QualifyFunc_t
Type of test function.
Simple utility to generate gates around beam time.
std::vector< TriggerGateData_t > combineTriggerPrimitives(art::Event const &event, icarus::trigger::ADCCounts_t const threshold, art::InputTag const &dataTag) const
Computes the trigger response from primitives with the given threshold.
Class managing the serialization of event ID in a simple ROOT tree.
Obj & demand(std::string const &name) const
Fetches an object with the specified name to be modified.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
GeV DepositedEnergy() const
Returns the total energy deposited in the detector during the event [GeV].
void assign(bool inPlots)
Fills the information of the specified event.
Definition of util::values() and util::const_values().
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree sequence::inline_paths sequence::inline_paths sequence::inline_paths showermakers test
std::vector< std::reference_wrapper< PlotSandbox const >> PlotSandboxRefs_t
List of references to plot sandboxes.
bool isNu_mu() const
Returns which neutrino flavor is present in an event.
PlotInfoTree(TTree &tree)
Creates the required branches and assigns addresses to them.
Tick ClockTick_t
Type of a point in time, measured in ticks.
void SetDepositedEnergyInSpill(GeV e)
Sets the energy of the event deposited during beam gate [GeV].
std::unique_ptr< EventIDTree > fIDTree
Handler of ROOT tree output.
std::vector< icarus::trigger::TrackedOpticalTriggerGate< OpDetInfo > > ReadTriggerGates(Event const &event, art::InputTag const &dataTag)
Assembles and returns trigger gates from serialized data.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
std::vector< geo::Point_t > fVertices
Position of all vertices.
detinfo::timescales::optical_tick optical_tick
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const
Returns whether this volume contains the specified point.
A helper to manage ROOT objects in a art::TFileDirectory.
art framework interface to geometry description
void SetLeptonEnergy(GeV eL)
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
GeV NeutrinoEnergy() const
A helper to manage ROOT objects with consistent naming.