Skip to content

Commit 31c8c3c

Browse files
authored
Merge branch 'develop' into feature/acastill_sbnd_opflash_caf
2 parents ce024e1 + ec69666 commit 31c8c3c

16 files changed

Lines changed: 2961 additions & 11 deletions

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: 18 additions & 8 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();

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)

sbncode/DetSim/fcl/icarus_simedepfilter.fcl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ BEGIN_PROLOG
33
simedepfilter_ind1gap: {
44
module_type: "FilterSimEnergyDeposits"
55
InitSimEnergyDepositLabel: "ionization"
6+
InitSimEnergyDepositLiteLabel: "sedlite"
67
P1_X: -400 #cm, create a box that spans the full x,y range. Not super-precise.
78
P1_Y: -200 #cm, create a box that spans the full x,y range. Not super-precise.
89
P1_Z: -2 #cm, one edge of the filtered gap based on the 37 mm total size of the wire gap
@@ -16,4 +17,4 @@ simedepfilter_ind1gap: {
1617
}
1718

1819

19-
END_PROLOG
20+
END_PROLOG

sbncode/HitFinder/CMakeLists.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
add_subdirectory(HitFinderUtilities)
2+
3+
art_make_library(
4+
LIBRARIES
5+
lardataobj::RawData
6+
lardataobj::RecoBase
7+
lardata::Utilities
8+
fhiclcpp::fhiclcpp
9+
cetlib::cetlib
10+
)
11+
set( MODULE_LIBRARIES
12+
larcorealg::Geometry
13+
larcorealg::Geometry
14+
larcore::Geometry_Geometry_service
15+
lardata::Utilities
16+
larevt::Filters
17+
lardataobj::RawData
18+
larevt::CalibrationDBI_IOVData
19+
larevt::CalibrationDBI_Providers
20+
lardataobj::RecoBase
21+
lardata::ArtDataHelper
22+
larreco::RecoAlg
23+
sbnobj::ICARUS_TPC
24+
sbnobj::Common_Utilities
25+
sbncode::HitFinder_HitFinderUtilities
26+
art::Framework_Core
27+
art::Framework_Principal
28+
art::Framework_Services_Registry
29+
art_root_io::tfile_support ROOT::Core
30+
art_root_io::TFileService_service
31+
art::Persistency_Common
32+
art::Persistency_Provenance
33+
art::Utilities
34+
canvas::canvas
35+
messagefacility::MF_MessageLogger
36+
messagefacility::headers
37+
fhiclcpp::fhiclcpp
38+
cetlib::cetlib
39+
ROOT::Geom
40+
ROOT::XMLIO
41+
ROOT::Gdml
42+
ROOT::FFTW
43+
44+
)
45+
cet_build_plugin(GaussHitFinderSBN art::module
46+
LIBRARIES ${MODULE_LIBRARIES}
47+
larreco::HitFinder
48+
larreco::CandidateHitFinderTool
49+
larreco::PeakFitterTool
50+
)
51+
cet_build_plugin(ChannelROIToWire art::module LIBRARIES ${MODULE_LIBRARIES})
52+
cet_build_plugin(WireToChannelROI art::module LIBRARIES ${MODULE_LIBRARIES})
53+
54+
55+
install_headers()
56+
install_fhicl()
57+
install_source()
58+

0 commit comments

Comments
 (0)