@@ -199,7 +199,8 @@ class CAFMaker : public art::EDProducer {
199199
200200 std::string fSourceFile ;
201201 std::uint32_t fSourceFileHash ;
202-
202+
203+ bool fOverrideRealData ;
203204 bool fFirstInSubRun ;
204205 unsigned int fIndexInFile = SRHeader::NoSourceIndex;
205206 bool fFirstBlindInSubRun ;
@@ -401,6 +402,7 @@ class CAFMaker : public art::EDProducer {
401402 // Note: we will define isRealData on a per event basis in produce function [using event.isRealData()], at least for now.
402403
403404 fCafFilename = fParams .CAFFilename ();
405+ fOverrideRealData = fParams .OverrideRealData ();
404406 fFlatCafFilename = fParams .FlatCAFFilename ();
405407
406408 // Normally CAFMaker is run wit no output ART stream, so these go
@@ -847,9 +849,18 @@ void CAFMaker::beginSubRun(art::SubRun& sr) {
847849 std::cout << std::endl;
848850 abort ();
849851 }
850-
852+ if ( fOverrideRealData ) {
853+ // Expects a generator POT summary then...
854+ if (auto pot_handle = sr.getHandle <sumdata::POTSummary>(fParams .GenLabel ())){
855+ fSubRunPOT = pot_handle->totgoodpot ;
856+ fTotalPOT += fSubRunPOT ;
857+ }else {
858+ std::cout << " Did not find MC POT info under " << fParams .GenLabel () << std::endl;
859+ if (fParams .StrictMode ()) abort ();
860+ }
861+ }else {
851862 if (bnb_spill){
852- FillExposure (*bnb_spill, fBNBInfo , fSubRunPOT );
863+ FillExposure (*bnb_spill, fBNBInfo , fSubRunPOT );
853864 fTotalPOT += fSubRunPOT ;
854865
855866 // Find the spill for each event and fill the event map:
@@ -908,10 +919,9 @@ void CAFMaker::beginSubRun(art::SubRun& sr) {
908919 << std::endl;
909920 if (fParams .StrictMode ()) abort ();
910921 }
911-
912922 // Otherwise, if one label is blank, maybe no POT was the expected result
913923 }
914-
924+ }
915925 std::cout << " POT: " << fSubRunPOT << std::endl;
916926
917927 fFirstInSubRun = true ;
@@ -1263,8 +1273,8 @@ void CAFMaker::produce(art::Event& evt) noexcept {
12631273
12641274 bool const firstInFile = (fIndexInFile ++ == 0 );
12651275
1266- // is this event real data?
1267- bool isRealData = evt.isRealData ();
1276+ // is this event real data? -- BH: if fOverrideRealData, treat it as MC. Otherwise, get the info from the art event.
1277+ bool isRealData = ! fOverrideRealData && evt.isRealData ();
12681278
12691279 std::unique_ptr<std::vector<caf::StandardRecord>> srcol (
12701280 new std::vector<caf::StandardRecord>);
@@ -1459,7 +1469,7 @@ void CAFMaker::produce(art::Event& evt) noexcept {
14591469
14601470 int iparticle=0 ;
14611471 genie::GHepParticle * p = 0 ;
1462- while ( genie_rec->Particle (iparticle) != 0 ) {
1472+ while ( ( genie_rec->Particle (iparticle) != 0 ) && (iparticle < 250 ) ) {
14631473 p = genie_rec->Particle (iparticle);
14641474 fGenieEvtRec_brStdHepPdg [iparticle] = p->Pdg ();
14651475 fGenieEvtRec_brStdHepStatus [iparticle] = (int ) p->Status ();
@@ -1654,26 +1664,50 @@ void CAFMaker::produce(art::Event& evt) noexcept {
16541664
16551665 // Get all of the OpFlashes
16561666 std::vector<caf::SROpFlash> srflashes;
1667+ if (fDet == kICARUS )
1668+ {
1669+ for (const std::string& pandora_tag_suffix : pandora_tag_suffixes) {
1670+ art::Handle<std::vector<recob::OpFlash>> flashes_handle;
1671+ GetByLabelStrict (evt, fParams .OpFlashLabel () + pandora_tag_suffix, flashes_handle);
1672+ // fill into event
1673+ if (flashes_handle.isValid ()) {
1674+ const std::vector<recob::OpFlash> &opflashes = *flashes_handle;
1675+ int cryostat = ( pandora_tag_suffix.find (" W" ) != std::string::npos ) ? 1 : 0 ;
16571676
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 ;
1677+ // get associated OpHits for each OpFlash
1678+ art::FindMany<recob::OpHit> findManyHits (flashes_handle, evt, fParams .OpFlashLabel () + pandora_tag_suffix);
16651679
1666- // get associated OpHits for each OpFlash
1667- art::FindMany< recob::OpHit> findManyHits (flashes_handle, evt, fParams . OpFlashLabel () + pandora_tag_suffix);
1680+ int iflash= 0 ;
1681+ for ( const recob::OpFlash& flash : opflashes) {
16681682
1669- int iflash=0 ;
1670- for (const recob::OpFlash& flash : opflashes) {
1683+ std::vector<recob::OpHit const *> const & ophits = findManyHits.at (iflash);
16711684
1672- std::vector<recob::OpHit const *> const & ophits = findManyHits.at (iflash);
1685+ srflashes.emplace_back ();
1686+ FillICARUSOpFlash (flash, ophits, cryostat, srflashes.back ());
1687+ iflash++;
1688+ }
1689+ }
1690+ }
1691+ }
1692+ else if (fDet == kSBND )
1693+ {
1694+ std::vector<std::string> tpc_suffixes_sbnd = {" tpc0" , " tpc1" };
16731695
1674- srflashes.emplace_back ();
1675- FillOpFlash (flash, ophits, cryostat, srflashes.back ());
1676- iflash++;
1696+ for (size_t tpc=0 ; tpc<tpc_suffixes_sbnd.size (); tpc++) {
1697+ art::Handle<std::vector<recob::OpFlash>> flashes_handle;
1698+ GetByLabelStrict (evt, fParams .OpFlashLabel () + tpc_suffixes_sbnd[tpc], flashes_handle);
1699+ // fill into event
1700+ if (flashes_handle.isValid ()) {
1701+ const std::vector<recob::OpFlash> &opflashes = *flashes_handle;
1702+ // get associated OpHits for each OpFlash
1703+ art::FindMany<recob::OpHit> findManyHits (flashes_handle, evt, fParams .OpFlashLabel () + tpc_suffixes_sbnd[tpc]);
1704+ int iflash=0 ;
1705+ for (const recob::OpFlash& flash : opflashes) {
1706+ std::vector<recob::OpHit const *> const & ophits = findManyHits.at (iflash);
1707+ srflashes.emplace_back ();
1708+ FillSBNDOpFlash (flash, ophits, tpc, srflashes.back ());
1709+ iflash++;
1710+ }
16771711 }
16781712 }
16791713 }
0 commit comments