Skip to content

Commit 7cbf66a

Browse files
committed
Merge branch 'release/v10_05_00'
2 parents bb811ff + c4ed956 commit 7cbf66a

22 files changed

Lines changed: 3059 additions & 34 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
1717

1818
find_package(cetmodules 3.20.00 REQUIRED)
19-
project(sbncode VERSION 10.04.08 LANGUAGES CXX)
19+
project(sbncode VERSION 10.05.00 LANGUAGES CXX)
2020

2121
message(STATUS "\n\n ========================== ${PROJECT_NAME} ==========================")
2222

sbncode/CAFMaker/CAFMakerParams.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ namespace caf
4444
Atom<bool> SaveGENIEEventRecord { Name("SaveGENIEEventRecord"),
4545
Comment("Whether to produce GENIE event record to the output file"), false
4646
};
47+
48+
Atom<bool> OverrideRealData { Name("OverrideRealData"),
49+
Comment("when true, some algorithms (e.g. PoT count) treat events as MC rather than real data -- e.g. set it if the event is an overlay"), false
50+
};
4751

4852
Atom<float> PrescaleFactor { Name("PrescaleFactor"),
4953
Comment("Factor by which to prescale unblind events"), 10

sbncode/CAFMaker/CAFMaker_module.cc

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

sbncode/CAFMaker/FillReco.cxx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ namespace caf
179179
}
180180

181181

182-
void FillOpFlash(const recob::OpFlash &flash,
182+
void FillICARUSOpFlash(const recob::OpFlash &flash,
183183
std::vector<recob::OpHit const*> const& hits,
184184
int cryo,
185185
caf::SROpFlash &srflash,
@@ -227,6 +227,41 @@ namespace caf
227227
}
228228
}
229229

230+
void FillSBNDOpFlash(const recob::OpFlash &flash,
231+
std::vector<recob::OpHit const*> const& hits,
232+
int tpc,
233+
caf::SROpFlash &srflash,
234+
bool allowEmpty) {
235+
236+
srflash.setDefault();
237+
238+
srflash.time = flash.Time();
239+
srflash.timewidth = flash.TimeWidth();
240+
241+
double firstTime = std::numeric_limits<double>::max();
242+
for(const auto& hit: hits){
243+
double const hitTime = hit->HasStartTime()? hit->StartTime(): hit->PeakTime();
244+
if (firstTime > hitTime)
245+
firstTime = hitTime;
246+
}
247+
srflash.firsttime = firstTime;
248+
srflash.tpc = tpc;
249+
250+
srflash.totalpe = flash.TotalPE();
251+
srflash.fasttototal = flash.FastToTotal();
252+
srflash.onbeamtime = flash.OnBeamTime();
253+
254+
srflash.center.SetXYZ( -9999.f, flash.YCenter(), flash.ZCenter() );
255+
srflash.width.SetXYZ( -9999.f, flash.YWidth(), flash.ZWidth() );
256+
257+
// Checks if ( recob::OpFlash.XCenter() != std::numeric_limits<double>::max() )
258+
// See LArSoft OpFlash.h at https://nusoft.fnal.gov/larsoft/doxsvn/html/OpFlash_8h_source.html
259+
if ( flash.hasXCenter() ) {
260+
srflash.center.SetX( flash.XCenter() );
261+
srflash.width.SetX( flash.XWidth() );
262+
}
263+
}
264+
230265
std::vector<float> double_to_float_vector(const std::vector<double>& v)
231266
{
232267
std::vector<float> ret;

sbncode/CAFMaker/FillReco.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,18 @@ namespace caf
217217
caf::SRSBNDCRTTrack &srsbndcrttrack,
218218
bool allowEmpty = false);
219219

220-
void FillOpFlash(const recob::OpFlash &flash,
220+
void FillICARUSOpFlash(const recob::OpFlash &flash,
221221
std::vector<recob::OpHit const*> const& hits,
222222
int cryo,
223223
caf::SROpFlash &srflash,
224224
bool allowEmpty = false);
225+
226+
void FillSBNDOpFlash(const recob::OpFlash &flash,
227+
std::vector<recob::OpHit const*> const& hits,
228+
int tpc,
229+
caf::SROpFlash &srflash,
230+
bool allowEmpty = false);
231+
225232
void FillCRTPMTMatch(const sbn::crt::CRTPMTMatching &match,
226233
caf::SRCRTPMTMatch &srmatch,
227234
bool allowEmpty = false);

sbncode/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ add_subdirectory(GeometryTools)
2020
add_subdirectory(CosmicID)
2121
add_subdirectory(DetSim)
2222
add_subdirectory(Cluster3D)
23+
add_subdirectory(HitFinder)
2324

2425
# Supera
2526
#

sbncode/Calibration/TrackCaloSkimmer_module.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void sbn::TrackCaloSkimmer::analyze(art::Event const& e)
234234

235235
// Hits (ICARUS style)
236236
art::FindManyP<anab::T0> fmT0CRTHit(tracks, e, fCRTHitT0producer);
237-
art::FindManyP<sbn::crt::CRTHitT0TaggingInfo> fmCRTHitT0TaggingInfo(PFParticleList, e, fCRTHitT0producer);
237+
art::FindManyP<sbn::crt::CRTHitT0TaggingInfo> fmCRTHitT0TaggingInfo(tracks, e, fCRTHitT0producer);
238238

239239
// Track - associated data
240240
art::FindManyP<recob::Track> fmTracks(PFParticleList, e, fTRKproducer);

sbncode/DetSim/AdjustSimForTrigger_module.cc

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "lardataobj/Simulation/AuxDetSimChannel.h"
2323
#include "lardataobj/Simulation/BeamGateInfo.h"
2424
#include "lardataobj/Simulation/SimEnergyDeposit.h"
25+
#include "lardataobj/Simulation/SimEnergyDepositLite.h"
2526
#include "lardataobj/Simulation/SimPhotons.h"
2627

2728
#include <lardata/DetectorInfoServices/DetectorClocksService.h>
@@ -49,11 +50,13 @@ class AdjustSimForTrigger : public art::EDProducer {
4950
art::InputTag fInitAuxDetSimChannelLabel;
5051
art::InputTag fInitBeamGateInfoLabel;
5152
art::InputTag fInitSimEnergyDepositLabel;
53+
art::InputTag fInitSimEnergyDepositLiteLabel;
5254
art::InputTag fInitSimPhotonsLabel;
5355
art::InputTag fInitWaveformLabel;
5456
bool fShiftAuxDetIDEs;
5557
bool fShiftBeamGateInfo;
5658
bool fShiftSimEnergyDeposits;
59+
bool fShiftSimEnergyDepositLites;
5760
bool fShiftSimPhotons;
5861
bool fShiftWaveforms;
5962
double fAdditionalOffset;
@@ -66,29 +69,33 @@ AdjustSimForTrigger::AdjustSimForTrigger(fhicl::ParameterSet const& p)
6669
, fInitAuxDetSimChannelLabel(p.get<art::InputTag>("InitAuxDetSimChannelLabel", "undefined"))
6770
, fInitBeamGateInfoLabel{p.get<art::InputTag>("InitBeamGateInfoLabel", "undefined")}
6871
, fInitSimEnergyDepositLabel{p.get<art::InputTag>("InitSimEnergyDepositLabel", "undefined")}
72+
, fInitSimEnergyDepositLiteLabel{p.get<art::InputTag>("InitSimEnergyDepositLiteLabel", "undefined")}
6973
, fInitSimPhotonsLabel{p.get<art::InputTag>("InitSimPhotonsLabel", "undefined")}
7074
, fInitWaveformLabel(p.get<art::InputTag>("InitWaveformLabel", "undefined"))
7175
, fShiftAuxDetIDEs{p.get<bool>("ShiftAuxDetIDEs", false)}
7276
, fShiftBeamGateInfo{p.get<bool>("ShiftBeamGateInfo", false)}
7377
, fShiftSimEnergyDeposits{p.get<bool>("ShiftSimEnergyDeposits", false)}
78+
, fShiftSimEnergyDepositLites{p.get<bool>("ShiftSimEnergyDepositLites", false)}
7479
, fShiftSimPhotons{p.get<bool>("ShiftSimPhotons", false)}
7580
, fShiftWaveforms{p.get<bool>("ShiftWaveforms", false)}
7681
, fAdditionalOffset{p.get<double>("AdditionalOffset", 0.)}
7782
{
7883
if (!(fShiftSimEnergyDeposits || fShiftSimPhotons || fShiftWaveforms || fShiftAuxDetIDEs ||
79-
fShiftBeamGateInfo)) {
84+
fShiftBeamGateInfo || fShiftSimEnergyDepositLites)) {
8085
throw art::Exception(art::errors::EventProcessorFailure)
8186
<< kModuleName << ": NO SHIFTS ENABLED!\n";
8287
}
8388
mf::LogInfo(kModuleName) << std::boolalpha << "SHIFTING AUXDETIDES? " << fShiftAuxDetIDEs << '\n'
8489
<< "SHIFTING BEAMGATEINFO? " << fShiftBeamGateInfo << '\n'
8590
<< "SHIFTING SIMENERGYDEPOSITS? " << fShiftSimEnergyDeposits << '\n'
91+
<< "SHIFTING SIMENERGYDEPOSITLITES? " << fShiftSimEnergyDepositLites << '\n'
8692
<< "SHIFTING SIMPHOTONS? " << fShiftSimPhotons << '\n'
8793
<< "SHIFTING OPDETWAVEFORMS? " << fShiftWaveforms;
8894

8995
if (fShiftAuxDetIDEs) { produces<std::vector<sim::AuxDetSimChannel>>(); }
9096
if (fShiftBeamGateInfo) { produces<std::vector<sim::BeamGateInfo>>(); }
9197
if (fShiftSimEnergyDeposits) { produces<std::vector<sim::SimEnergyDeposit>>(); }
98+
if (fShiftSimEnergyDepositLites) { produces<std::vector<sim::SimEnergyDepositLite>>(); }
9299
if (fShiftSimPhotons) { produces<std::vector<sim::SimPhotons>>(); }
93100
if (fShiftWaveforms) { produces<std::vector<raw::OpDetWaveform>>(); }
94101
}
@@ -205,6 +212,24 @@ void AdjustSimForTrigger::produce(art::Event& e)
205212
}
206213
e.put(std::move(pSimEDeps));
207214
}
215+
// and SimEnergyDepositLite's
216+
if (fShiftSimEnergyDepositLites) {
217+
auto const& simEDepLites =
218+
e.getProduct<std::vector<sim::SimEnergyDepositLite>>(fInitSimEnergyDepositLiteLabel);
219+
220+
auto pSimEDepLites = std::make_unique<std::vector<sim::SimEnergyDepositLite>>();
221+
222+
for (auto const& inSimEDepLite : simEDepLites) {
223+
double energy = inSimEDepLite.Energy();
224+
geo::Point_t middlePos = inSimEDepLite.Position();
225+
double middleTime = inSimEDepLite.Time() + timeShiftForTrigger_ns;
226+
int ID = inSimEDepLite.TrackID();
227+
228+
pSimEDepLites->emplace_back(energy, middlePos, middleTime, ID);
229+
}
230+
231+
e.put(std::move(pSimEDepLites));
232+
}
208233

209234
// Repeat for sim::SimPhotons
210235
if (fShiftSimPhotons) {

sbncode/DetSim/FilterSimEnergyDeposits_module.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "larcorealg/Geometry/BoxBoundedGeo.h"
1919

2020
#include "lardataobj/Simulation/SimEnergyDeposit.h"
21+
#include "lardataobj/Simulation/SimEnergyDepositLite.h"
2122

2223
#include <memory>
2324

@@ -43,6 +44,7 @@ class FilterSimEnergyDeposits : public art::EDProducer {
4344
// Declare member data here.
4445

4546
art::InputTag fInitSimEnergyDepositLabel;
47+
art::InputTag fInitSimEnergyDepositLiteLabel;
4648
geo::BoxBoundedGeo fBox;
4749
static constexpr auto kModuleName = "FilterSimEnergyDeposit";
4850
double ShiftX(double z) const;
@@ -56,6 +58,7 @@ class FilterSimEnergyDeposits : public art::EDProducer {
5658
FilterSimEnergyDeposits::FilterSimEnergyDeposits(fhicl::ParameterSet const& p)
5759
: EDProducer{p}
5860
, fInitSimEnergyDepositLabel{p.get<art::InputTag>("InitSimEnergyDepositLabel", "undefined")}
61+
, fInitSimEnergyDepositLiteLabel{p.get<art::InputTag>("InitSimEnergyDepositLiteLabel", "undefined")}
5962
, fBox{p.get<double>("P1_X"), p.get<double>("P2_X"),
6063
p.get<double>("P1_Y"), p.get<double>("P2_Y"),
6164
p.get<double>("P1_Z"), p.get<double>("P2_Z")}
@@ -66,6 +69,9 @@ FilterSimEnergyDeposits::FilterSimEnergyDeposits(fhicl::ParameterSet const& p)
6669
// Call appropriate produces<>() functions here.
6770
// Call appropriate consumes<>() for any products to be retrieved by this module.
6871
produces<std::vector<sim::SimEnergyDeposit>>();
72+
73+
74+
if (fInitSimEnergyDepositLiteLabel != "undefined") { produces<std::vector<sim::SimEnergyDepositLite>>(); }
6975
}
7076

7177

@@ -126,6 +132,27 @@ void FilterSimEnergyDeposits::produce(art::Event& e)
126132
origID));
127133
}
128134
e.put(std::move(pSimEDeps));
135+
136+
// also futz with the SimEnergyDepositLite's if configured to
137+
if (fInitSimEnergyDepositLiteLabel == "undefined") return;
138+
139+
auto const& simEDepLites =
140+
e.getProduct<std::vector<sim::SimEnergyDepositLite>>(fInitSimEnergyDepositLiteLabel);
141+
auto pSimEDepLites = std::make_unique<std::vector<sim::SimEnergyDepositLite>>();
142+
pSimEDepLites->reserve(simEDepLites.size());
143+
144+
for (auto const& inSimEDepLite : simEDepLites) {
145+
geo::Point_t middlePos = inSimEDepLite.Position();
146+
if(fBox.ContainsPosition(middlePos))
147+
continue;
148+
double energy = inSimEDepLite.Energy();
149+
double middleTime = inSimEDepLite.Time();
150+
int ID = inSimEDepLite.TrackID();
151+
152+
pSimEDepLites->emplace_back(energy, middlePos, middleTime, ID);
153+
}
154+
155+
e.put(std::move(pSimEDepLites));
129156
}
130157

131158
DEFINE_ART_MODULE(FilterSimEnergyDeposits)

0 commit comments

Comments
 (0)