|
20 | 20 | #include "sbncode/CAFMaker/FillExposure.h" |
21 | 21 | #include "sbncode/CAFMaker/FillTrigger.h" |
22 | 22 | #include "sbncode/CAFMaker/Utils.h" |
| 23 | +#include "sbncode/CAFMaker/FillBlip.h" |
23 | 24 |
|
24 | 25 | // C/C++ includes |
25 | 26 | #include <fenv.h> |
|
97 | 98 | #include "lardataobj/RecoBase/MCSFitResult.h" |
98 | 99 | #include "lardataobj/RecoBase/Cluster.h" |
99 | 100 | #include "lardataobj/AnalysisBase/MVAOutput.h" |
| 101 | +#include "lardataobj/Simulation/SimEnergyDeposit.h" |
100 | 102 |
|
101 | 103 | #include "nusimdata/SimulationBase/MCFlux.h" |
102 | 104 | #include "nusimdata/SimulationBase/MCTruth.h" |
|
115 | 117 | #include "sbnobj/Common/POTAccounting/BNBSpillInfo.h" |
116 | 118 | #include "sbnobj/Common/POTAccounting/EXTCountInfo.h" |
117 | 119 | #include "sbnobj/Common/POTAccounting/NuMISpillInfo.h" |
| 120 | +#include "sbncode/BeamSpillInfoRetriever/POTTools.h" |
| 121 | +#include "artdaq-core/Data/ContainerFragment.hh" |
118 | 122 | #include "sbnobj/Common/Trigger/ExtraTriggerInfo.h" |
119 | 123 | #include "sbnobj/Common/Reco/CRUMBSResult.h" |
120 | 124 | #include "sbnobj/Common/Reco/OpT0FinderResult.h" |
121 | 125 | #include "sbnobj/SBND/CRT/CRTVeto.hh" |
122 | 126 | #include "sbnobj/Common/Reco/CorrectedOpFlashTiming.h" |
| 127 | +#include "sbnobj/Common/Reco/LightCalo.h" |
123 | 128 | #include "sbnobj/SBND/Timing/TimingInfo.hh" |
124 | 129 | #include "sbnobj/SBND/Timing/FrameShiftInfo.hh" |
125 | 130 |
|
@@ -352,6 +357,10 @@ class CAFMaker : public art::EDProducer { |
352 | 357 | art::FindOneP<T> FindOnePStrict(const U& from, const art::Event& evt, |
353 | 358 | const art::InputTag& label) const; |
354 | 359 |
|
| 360 | + template <class T, class U> |
| 361 | + art::FindOneP<T> FindOnePStrictSingle(const U& from, const art::Event& evt, |
| 362 | + const art::InputTag& label) const; |
| 363 | + |
355 | 364 | template <class T, class D, class U> |
356 | 365 | art::FindOneP<T, D> FindOnePDStrict(const U& from, |
357 | 366 | const art::Event& evt, |
@@ -1299,6 +1308,14 @@ art::FindOneP<T> CAFMaker::FindOnePStrict(const U& from, |
1299 | 1308 | return ret; |
1300 | 1309 | } |
1301 | 1310 |
|
| 1311 | +//...................................................................... |
| 1312 | +template <class T, class U> |
| 1313 | +art::FindOneP<T> CAFMaker::FindOnePStrictSingle(const U& from, |
| 1314 | + const art::Event& evt, |
| 1315 | + const art::InputTag& tag) const { |
| 1316 | + return FindOnePStrict<T>(std::vector{ from }, evt, tag); |
| 1317 | +} |
| 1318 | + |
1302 | 1319 | //...................................................................... |
1303 | 1320 | template <class T, class D, class U> |
1304 | 1321 | art::FindOneP<T, D> CAFMaker::FindOnePDStrict(const U& from, |
@@ -1378,6 +1395,7 @@ bool CAFMaker::GetPsetParameter(const fhicl::ParameterSet& pset, |
1378 | 1395 |
|
1379 | 1396 | //...................................................................... |
1380 | 1397 | void CAFMaker::produce(art::Event& evt) noexcept { |
| 1398 | + mf::LogInfo("CAFMaker") << "CAFMaker::produce called for event: " << evt.id(); |
1381 | 1399 |
|
1382 | 1400 | bool const firstInFile = (fIndexInFile++ == 0); |
1383 | 1401 |
|
@@ -1637,6 +1655,36 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
1637 | 1655 | } // end for fm |
1638 | 1656 | } // end for i (mctruths) |
1639 | 1657 |
|
| 1658 | + // get sim energy deposits if they're there |
| 1659 | + ::art::Handle<std::vector<sim::SimEnergyDeposit>> sed_handle; |
| 1660 | + GetByLabelStrict(evt, fParams.SimEnergyDepositLabel().encode(), sed_handle); |
| 1661 | + |
| 1662 | + if (!isRealData && sed_handle.isValid()){ |
| 1663 | + art::ServiceHandle<cheat::ParticleInventoryService> pi_serv; |
| 1664 | + |
| 1665 | + srtruthbranch.dep.reserve(mctruths.size()); |
| 1666 | + for (size_t n=0; n<mctruths.size();n++){ |
| 1667 | + SRTrueDeposit init; |
| 1668 | + init.electrons = 0; |
| 1669 | + init.photons = 0; |
| 1670 | + init.energy = 0; |
| 1671 | + srtruthbranch.dep.push_back(init); |
| 1672 | + } |
| 1673 | + |
| 1674 | + for (sim::SimEnergyDeposit const& sed: *sed_handle){ |
| 1675 | + const auto trackID = sed.TrackID(); |
| 1676 | + |
| 1677 | + art::Ptr<simb::MCTruth> mctruth = pi_serv->TrackIdToMCTruth_P(trackID); |
| 1678 | + auto it = std::find(mctruths.begin(), mctruths.end(), mctruth); |
| 1679 | + if (it == mctruths.end()) continue; |
| 1680 | + |
| 1681 | + auto idx = std::distance(mctruths.begin(), it); |
| 1682 | + srtruthbranch.dep.at(idx).energy += sed.Energy()*1e-3; // GeV |
| 1683 | + srtruthbranch.dep.at(idx).photons += sed.NumPhotons(); |
| 1684 | + srtruthbranch.dep.at(idx).electrons += sed.NumElectrons(); |
| 1685 | + } |
| 1686 | + } |
| 1687 | + |
1640 | 1688 | // get the number of events generated in the gen stage |
1641 | 1689 | unsigned n_gen_evt = 0; |
1642 | 1690 | for (const art::ProcessConfiguration &process: evt.processHistory()) { |
@@ -1711,6 +1759,24 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
1711 | 1759 | FillTriggerEmulation(monpulses_handle, monpulse_sizes_handle, pairs_handle, trigemu_handle, srtrigger); |
1712 | 1760 | } |
1713 | 1761 |
|
| 1762 | + |
| 1763 | + // Fill PTB (Penn Trigger Board) information for SBND real data |
| 1764 | + if (isRealData && fDet == kSBND) { |
| 1765 | + art::InputTag PTB_itag("daq", "ContainerPTB"); |
| 1766 | + art::Handle<artdaq::Fragments> ptb_frags_handle; |
| 1767 | + evt.getByLabel(PTB_itag, ptb_frags_handle); |
| 1768 | + if (ptb_frags_handle.isValid()) { |
| 1769 | + mf::LogDebug("CAFMaker") << "Found ContainerPTB, extracting PTB triggers..."; |
| 1770 | + std::vector<sbn::pot::PTBInfo_t> ptb_triggers = sbn::pot::extractAllPTBInfo(*ptb_frags_handle); |
| 1771 | + mf::LogDebug("CAFMaker") << "Extracted " << ptb_triggers.size() << " PTB triggers"; |
| 1772 | + FillPTBTriggersSBND(ptb_triggers, srtrigger); |
| 1773 | + mf::LogDebug("CAFMaker") << "PTB HLT triggers: " << srtrigger.ptb_hlt_timestamp.size() |
| 1774 | + << ", LLT triggers: " << srtrigger.ptb_llt_timestamp.size(); |
| 1775 | + } else { |
| 1776 | + mf::LogDebug("CAFMaker") << "ContainerPTB not found for event " << evt.id(); |
| 1777 | + } |
| 1778 | + } |
| 1779 | + |
1714 | 1780 | // If not real data, fill in enough of the SRTrigger to make (e.g.) the CRT |
1715 | 1781 | // time referencing work. TODO: add more stuff to a "MC"-Trigger? |
1716 | 1782 | // No longer needed with incorporation of trigger emulation in the MC. |
@@ -1791,12 +1857,15 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
1791 | 1857 | { |
1792 | 1858 | art::Handle<std::vector<sbnd::crt::CRTSpacePoint>> crtspacepoints_handle; |
1793 | 1859 | GetByLabelStrict(evt, fParams.CRTSpacePointLabel(), crtspacepoints_handle); |
| 1860 | + art::FindOneP<sbnd::crt::CRTCluster> foCRTCluster = |
| 1861 | + FindOnePStrict<sbnd::crt::CRTCluster>(crtspacepoints_handle, evt, fParams.CRTSpacePointLabel()); |
1794 | 1862 |
|
1795 | 1863 | if (crtspacepoints_handle.isValid()) { |
1796 | 1864 | const std::vector<sbnd::crt::CRTSpacePoint> &crtspacepoints = *crtspacepoints_handle; |
1797 | 1865 | for (unsigned i = 0; i < crtspacepoints.size(); i++) { |
1798 | 1866 | srcrtspacepoints.emplace_back(); |
1799 | | - FillCRTSpacePoint(crtspacepoints[i], srcrtspacepoints.back()); |
| 1867 | + const art::Ptr<sbnd::crt::CRTCluster> crtcluster = foCRTCluster.at(i); |
| 1868 | + FillCRTSpacePoint(crtspacepoints[i], *crtcluster, srcrtspacepoints.back()); |
1800 | 1869 | } |
1801 | 1870 | } |
1802 | 1871 |
|
@@ -1928,6 +1997,13 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
1928 | 1997 | } |
1929 | 1998 | } |
1930 | 1999 |
|
| 2000 | + //Fill blips. art::handle for blips and then call fill blips for each one. Make a vector to hold all of them. I handle for loop in Fill blip |
| 2001 | + art::Handle<std::vector<blip::Blip>> blipHandle; |
| 2002 | + std::vector<caf::SRBlip> srblips; |
| 2003 | + if(evt.getByLabel( fParams.fBlipTag(), blipHandle)) //fill SR blips |
| 2004 | + { |
| 2005 | + FillBlip( *blipHandle, srblips); |
| 2006 | + } |
1931 | 2007 | // collect the TPC slices |
1932 | 2008 | std::vector<art::Ptr<recob::Slice>> slices; |
1933 | 2009 | std::vector<std::string> slice_tag_suffixes; |
@@ -2049,6 +2125,10 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
2049 | 2125 | if (fmCorrectedOpFlash.isValid()) |
2050 | 2126 | slcCorrectedOpFlash = fmCorrectedOpFlash.at(0); |
2051 | 2127 |
|
| 2128 | + art::FindOneP<sbn::LightCalo> foLightCalo = |
| 2129 | + FindOnePStrict<sbn::LightCalo>(sliceList,evt, |
| 2130 | + fParams.LightCaloLabel() + slice_tag_suff); |
| 2131 | + const sbn::LightCalo *slcLightCalo = foLightCalo.isValid()? foLightCalo.at(0).get() : nullptr; |
2052 | 2132 |
|
2053 | 2133 | art::FindOneP<lcvn::Result> foCVNResult = |
2054 | 2134 | FindOnePStrict<lcvn::Result>(sliceList, evt, |
@@ -2239,6 +2319,9 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
2239 | 2319 | FindOnePDStrict<sbnd::crt::CRTSpacePoint, anab::T0>(slcTracks, evt, |
2240 | 2320 | fParams.CRTSpacePointMatchLabel() + slice_tag_suff); |
2241 | 2321 |
|
| 2322 | + art::Handle<std::vector<sbnd::crt::CRTSpacePoint>> crtspacepoints_handle; |
| 2323 | + GetByLabelStrict(evt, fParams.CRTSpacePointLabel(), crtspacepoints_handle); |
| 2324 | + |
2242 | 2325 | art::FindOneP<sbnd::crt::CRTTrack, anab::T0> foSBNDCRTTrackMatch = |
2243 | 2326 | FindOnePDStrict<sbnd::crt::CRTTrack, anab::T0>(slcTracks, evt, |
2244 | 2327 | fParams.SBNDCRTTrackMatchLabel() + slice_tag_suff); |
@@ -2308,6 +2391,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
2308 | 2391 | FillSliceCRUMBS(slcCRUMBS, recslc); |
2309 | 2392 | FillSliceOpT0Finder(slcOpT0, recslc); |
2310 | 2393 | FillSliceBarycenter(slcHits, slcSpacePoints, recslc); |
| 2394 | + FillSliceLightCalo(slcLightCalo, recslc); |
2311 | 2395 | FillTPCPMTBarycenterMatch(barycenterMatch, recslc); |
2312 | 2396 | FillCorrectedOpFlashTiming(slcCorrectedOpFlash, recslc); |
2313 | 2397 | FillCVNScores(cvnResult, recslc); |
@@ -2515,8 +2599,12 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
2515 | 2599 | { |
2516 | 2600 | const art::Ptr<sbnd::crt::CRTSpacePoint> crtspacepoint = foCRTSpacePointMatch.at(iPart); |
2517 | 2601 |
|
| 2602 | + art::FindOneP<sbnd::crt::CRTCluster> foCRTCluster = |
| 2603 | + FindOnePStrictSingle<sbnd::crt::CRTCluster>(crtspacepoint, evt, fParams.CRTSpacePointLabel()); |
| 2604 | + const art::Ptr<sbnd::crt::CRTCluster>& crtcluster = foCRTCluster.at(0); |
| 2605 | + |
2518 | 2606 | if(crtspacepoint.isNonnull()) |
2519 | | - FillTrackCRTSpacePoint(foCRTSpacePointMatch.data(iPart).ref(), crtspacepoint, trk); |
| 2607 | + FillTrackCRTSpacePoint(foCRTSpacePointMatch.data(iPart).ref(), *crtspacepoint, *crtcluster, trk); |
2520 | 2608 | } |
2521 | 2609 | if(foSBNDCRTTrackMatch.isValid() && fDet == kSBND) |
2522 | 2610 | { |
@@ -2605,6 +2693,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
2605 | 2693 | rec.sbnd_crt_veto = srsbndcrtveto; |
2606 | 2694 | rec.opflashes = srflashes; |
2607 | 2695 | rec.nopflashes = srflashes.size(); |
| 2696 | + rec.blips = srblips; |
2608 | 2697 | rec.sbnd_frames = srsbndframeshiftinfo; |
2609 | 2698 | rec.sbnd_timings = srsbndtiminginfo; |
2610 | 2699 | rec.soft_trig = srsbndsofttrig; |
|
0 commit comments