|
101 | 101 | #include "nusimdata/SimulationBase/MCNeutrino.h" |
102 | 102 | #include "nusimdata/SimulationBase/GTruth.h" |
103 | 103 |
|
| 104 | +#include "sbnobj/Common/CRT/CRTHitT0TaggingInfo.hh" |
104 | 105 | #include "sbnobj/Common/EventGen/MeVPrtl/MeVPrtlTruth.h" |
105 | 106 | #include "sbnobj/Common/Reco/RangeP.h" |
106 | 107 | #include "sbnobj/Common/SBNEventWeight/EventWeightMap.h" |
@@ -199,7 +200,8 @@ class CAFMaker : public art::EDProducer { |
199 | 200 |
|
200 | 201 | std::string fSourceFile; |
201 | 202 | std::uint32_t fSourceFileHash; |
202 | | - |
| 203 | + |
| 204 | + bool fOverrideRealData; |
203 | 205 | bool fFirstInSubRun; |
204 | 206 | unsigned int fIndexInFile = SRHeader::NoSourceIndex; |
205 | 207 | bool fFirstBlindInSubRun; |
@@ -401,6 +403,7 @@ class CAFMaker : public art::EDProducer { |
401 | 403 | // Note: we will define isRealData on a per event basis in produce function [using event.isRealData()], at least for now. |
402 | 404 |
|
403 | 405 | fCafFilename = fParams.CAFFilename(); |
| 406 | + fOverrideRealData = fParams.OverrideRealData(); |
404 | 407 | fFlatCafFilename = fParams.FlatCAFFilename(); |
405 | 408 |
|
406 | 409 | // Normally CAFMaker is run wit no output ART stream, so these go |
@@ -847,9 +850,18 @@ void CAFMaker::beginSubRun(art::SubRun& sr) { |
847 | 850 | std::cout << std::endl; |
848 | 851 | abort(); |
849 | 852 | } |
850 | | - |
| 853 | + if ( fOverrideRealData ) { |
| 854 | + // Expects a generator POT summary then... |
| 855 | + if(auto pot_handle = sr.getHandle<sumdata::POTSummary>(fParams.GenLabel())){ |
| 856 | + fSubRunPOT = pot_handle->totgoodpot; |
| 857 | + fTotalPOT += fSubRunPOT; |
| 858 | + }else{ |
| 859 | + std::cout << "Did not find MC POT info under " << fParams.GenLabel() << std::endl; |
| 860 | + if(fParams.StrictMode()) abort(); |
| 861 | + } |
| 862 | + }else{ |
851 | 863 | if(bnb_spill){ |
852 | | - FillExposure(*bnb_spill, fBNBInfo, fSubRunPOT); |
| 864 | + FillExposure(*bnb_spill, fBNBInfo, fSubRunPOT); |
853 | 865 | fTotalPOT += fSubRunPOT; |
854 | 866 |
|
855 | 867 | // Find the spill for each event and fill the event map: |
@@ -908,10 +920,9 @@ void CAFMaker::beginSubRun(art::SubRun& sr) { |
908 | 920 | << std::endl; |
909 | 921 | if(fParams.StrictMode()) abort(); |
910 | 922 | } |
911 | | - |
912 | 923 | // Otherwise, if one label is blank, maybe no POT was the expected result |
913 | 924 | } |
914 | | - |
| 925 | + } |
915 | 926 | std::cout << "POT: " << fSubRunPOT << std::endl; |
916 | 927 |
|
917 | 928 | fFirstInSubRun = true; |
@@ -1263,8 +1274,8 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
1263 | 1274 |
|
1264 | 1275 | bool const firstInFile = (fIndexInFile++ == 0); |
1265 | 1276 |
|
1266 | | - // is this event real data? |
1267 | | - bool isRealData = evt.isRealData(); |
| 1277 | + // is this event real data? -- BH: if fOverrideRealData, treat it as MC. Otherwise, get the info from the art event. |
| 1278 | + bool isRealData = !fOverrideRealData && evt.isRealData(); |
1268 | 1279 |
|
1269 | 1280 | std::unique_ptr<std::vector<caf::StandardRecord>> srcol( |
1270 | 1281 | new std::vector<caf::StandardRecord>); |
@@ -1459,7 +1470,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
1459 | 1470 |
|
1460 | 1471 | int iparticle=0; |
1461 | 1472 | genie::GHepParticle * p = 0; |
1462 | | - while( genie_rec->Particle(iparticle) != 0 ) { |
| 1473 | + while( (genie_rec->Particle(iparticle) != 0) && (iparticle < 250) ) { |
1463 | 1474 | p = genie_rec->Particle(iparticle); |
1464 | 1475 | fGenieEvtRec_brStdHepPdg[iparticle] = p->Pdg(); |
1465 | 1476 | fGenieEvtRec_brStdHepStatus[iparticle] = (int) p->Status(); |
@@ -1654,26 +1665,50 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
1654 | 1665 |
|
1655 | 1666 | // Get all of the OpFlashes |
1656 | 1667 | std::vector<caf::SROpFlash> srflashes; |
| 1668 | + if(fDet == kICARUS) |
| 1669 | + { |
| 1670 | + for (const std::string& pandora_tag_suffix : pandora_tag_suffixes) { |
| 1671 | + art::Handle<std::vector<recob::OpFlash>> flashes_handle; |
| 1672 | + GetByLabelStrict(evt, fParams.OpFlashLabel() + pandora_tag_suffix, flashes_handle); |
| 1673 | + // fill into event |
| 1674 | + if (flashes_handle.isValid()) { |
| 1675 | + const std::vector<recob::OpFlash> &opflashes = *flashes_handle; |
| 1676 | + int cryostat = ( pandora_tag_suffix.find("W") != std::string::npos ) ? 1 : 0; |
1657 | 1677 |
|
1658 | | - for (const std::string& pandora_tag_suffix : pandora_tag_suffixes) { |
1659 | | - art::Handle<std::vector<recob::OpFlash>> flashes_handle; |
1660 | | - GetByLabelStrict(evt, fParams.OpFlashLabel() + pandora_tag_suffix, flashes_handle); |
1661 | | - // fill into event |
1662 | | - if (flashes_handle.isValid()) { |
1663 | | - const std::vector<recob::OpFlash> &opflashes = *flashes_handle; |
1664 | | - int cryostat = ( pandora_tag_suffix.find("W") != std::string::npos ) ? 1 : 0; |
| 1678 | + // get associated OpHits for each OpFlash |
| 1679 | + art::FindMany<recob::OpHit> findManyHits(flashes_handle, evt, fParams.OpFlashLabel() + pandora_tag_suffix); |
1665 | 1680 |
|
1666 | | - // get associated OpHits for each OpFlash |
1667 | | - art::FindMany<recob::OpHit> findManyHits(flashes_handle, evt, fParams.OpFlashLabel() + pandora_tag_suffix); |
| 1681 | + int iflash=0; |
| 1682 | + for (const recob::OpFlash& flash : opflashes) { |
1668 | 1683 |
|
1669 | | - int iflash=0; |
1670 | | - for (const recob::OpFlash& flash : opflashes) { |
| 1684 | + std::vector<recob::OpHit const*> const& ophits = findManyHits.at(iflash); |
1671 | 1685 |
|
1672 | | - std::vector<recob::OpHit const*> const& ophits = findManyHits.at(iflash); |
| 1686 | + srflashes.emplace_back(); |
| 1687 | + FillICARUSOpFlash(flash, ophits, cryostat, srflashes.back()); |
| 1688 | + iflash++; |
| 1689 | + } |
| 1690 | + } |
| 1691 | + } |
| 1692 | + } |
| 1693 | + else if(fDet == kSBND) |
| 1694 | + { |
| 1695 | + std::vector<std::string> tpc_suffixes_sbnd = {"tpc0", "tpc1"}; |
1673 | 1696 |
|
1674 | | - srflashes.emplace_back(); |
1675 | | - FillOpFlash(flash, ophits, cryostat, srflashes.back()); |
1676 | | - iflash++; |
| 1697 | + for (size_t tpc=0; tpc<tpc_suffixes_sbnd.size(); tpc++) { |
| 1698 | + art::Handle<std::vector<recob::OpFlash>> flashes_handle; |
| 1699 | + GetByLabelStrict(evt, fParams.OpFlashLabel() + tpc_suffixes_sbnd[tpc], flashes_handle); |
| 1700 | + // fill into event |
| 1701 | + if (flashes_handle.isValid()) { |
| 1702 | + const std::vector<recob::OpFlash> &opflashes = *flashes_handle; |
| 1703 | + // get associated OpHits for each OpFlash |
| 1704 | + art::FindMany<recob::OpHit> findManyHits(flashes_handle, evt, fParams.OpFlashLabel() + tpc_suffixes_sbnd[tpc]); |
| 1705 | + int iflash=0; |
| 1706 | + for (const recob::OpFlash& flash : opflashes) { |
| 1707 | + std::vector<recob::OpHit const*> const& ophits = findManyHits.at(iflash); |
| 1708 | + srflashes.emplace_back(); |
| 1709 | + FillSBNDOpFlash(flash, ophits, tpc, srflashes.back()); |
| 1710 | + iflash++; |
| 1711 | + } |
1677 | 1712 | } |
1678 | 1713 | } |
1679 | 1714 | } |
@@ -1916,9 +1951,14 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
1916 | 1951 |
|
1917 | 1952 | // NOTE: The sbn::crt::CRTHit is associated to the T0. It's a bit awkward to |
1918 | 1953 | // access that here, so we do it per-track (see code where fmCRTHitMatch is accessed below) |
| 1954 | + |
1919 | 1955 | art::FindManyP<anab::T0> fmCRTHitMatch = |
1920 | 1956 | FindManyPStrict<anab::T0>(slcTracks, evt, |
1921 | | - fParams.CRTHitMatchLabel() + slice_tag_suff); |
| 1957 | + fParams.CRTHitMatchLabel()); |
| 1958 | + |
| 1959 | + art::FindManyP<sbn::crt::CRTHitT0TaggingInfo> fmCRTHitMatchInfo = |
| 1960 | + FindManyPStrict<sbn::crt::CRTHitT0TaggingInfo>(slcTracks, evt, |
| 1961 | + fParams.CRTHitMatchInfoLabel()); |
1922 | 1962 |
|
1923 | 1963 | // TODO: also save the sbn::crt::CRTTrack in the matching so that CAFMaker has access to it |
1924 | 1964 | art::FindManyP<anab::T0> fmCRTTrackMatch = |
@@ -2157,14 +2197,19 @@ void CAFMaker::produce(art::Event& evt) noexcept { |
2157 | 2197 | fParams.TrackHitFillRRStartCut(), fParams.TrackHitFillRREndCut(), |
2158 | 2198 | dprop, trk); |
2159 | 2199 | } |
| 2200 | + |
2160 | 2201 | if (fmCRTHitMatch.isValid() && fDet == kICARUS) { |
2161 | 2202 | art::FindManyP<sbn::crt::CRTHit> CRTT02Hit = FindManyPStrict<sbn::crt::CRTHit> |
2162 | | - (fmCRTHitMatch.at(iPart), evt, fParams.CRTHitMatchLabel() + slice_tag_suff); |
| 2203 | + (fmCRTHitMatch.at(iPart), evt, fParams.CRTHitMatchLabel()); |
2163 | 2204 |
|
2164 | 2205 | std::vector<art::Ptr<sbn::crt::CRTHit>> crthitmatch; |
2165 | | - if (CRTT02Hit.isValid() && CRTT02Hit.size() == 1) crthitmatch = CRTT02Hit.at(0); |
2166 | | - |
2167 | | - FillTrackCRTHit(fmCRTHitMatch.at(iPart), crthitmatch, fParams.CRTUseTS0(), CRT_T0_reference_time, CRT_T1_reference_time, trk); |
| 2206 | + std::vector<art::Ptr<sbn::crt::CRTHitT0TaggingInfo>> crthittagginginfo; |
| 2207 | + if(CRTT02Hit.isValid() && CRTT02Hit.size() == 1){ |
| 2208 | + crthitmatch = CRTT02Hit.at(0); |
| 2209 | + crthittagginginfo = fmCRTHitMatchInfo.at(iPart); |
| 2210 | + } |
| 2211 | + |
| 2212 | + FillTrackCRTHit(fmCRTHitMatch.at(iPart), crthitmatch, crthittagginginfo, fParams.CRTUseTS0(), CRT_T0_reference_time, CRT_T1_reference_time, trk); |
2168 | 2213 | } |
2169 | 2214 | // NOTE: SEE TODO AT fmCRTTrackMatch |
2170 | 2215 | if (fmCRTTrackMatch.isValid() && fDet == kICARUS) { |
|
0 commit comments