Skip to content

Commit 4346c58

Browse files
authored
Merge branch 'develop' into feature/sungbino_likepid_into_cafmaker
2 parents c48e4bf + baaf88e commit 4346c58

6 files changed

Lines changed: 113 additions & 41 deletions

File tree

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.11.01.01 LANGUAGES CXX)
19+
project(sbncode VERSION 10.12.02 LANGUAGES CXX)
2020

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

sbncode/CAFMaker/CAFMakerParams.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,12 @@ namespace caf
351351
"crttracks" // sbnd
352352
};
353353

354+
Atom<string> SBNDCRTVetoLabel {
355+
Name("SBNDCRTVetoLabel"),
356+
Comment("Label of sbnd CRT Veto."),
357+
"crtveto" // sbnd
358+
};
359+
354360
Atom<string> SBNDFrameShiftInfoLabel {
355361
Name("SBNDFrameShiftInfoLabel"),
356362
Comment("Label of sbnd frame shift."),

sbncode/CAFMaker/CAFMaker_module.cc

Lines changed: 73 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@
118118
#include "sbnobj/Common/Trigger/ExtraTriggerInfo.h"
119119
#include "sbnobj/Common/Reco/CRUMBSResult.h"
120120
#include "sbnobj/Common/Reco/OpT0FinderResult.h"
121+
#include "sbnobj/SBND/CRT/CRTVeto.hh"
121122
#include "sbnobj/Common/Reco/CorrectedOpFlashTiming.h"
122123
#include "sbnobj/SBND/Timing/TimingInfo.hh"
123124
#include "sbnobj/SBND/Timing/FrameShiftInfo.hh"
124125

125-
126126
// GENIE
127127
#include "Framework/EventGen/EventRecord.h"
128128
#include "Framework/Ntuple/NtpMCEventRecord.h"
@@ -207,6 +207,8 @@ class CAFMaker : public art::EDProducer {
207207

208208
std::string fSourceFile;
209209
std::uint32_t fSourceFileHash;
210+
211+
bool fNewInputFile;
210212

211213
bool fOverrideRealData;
212214
bool fFirstInSubRun;
@@ -224,6 +226,7 @@ class CAFMaker : public art::EDProducer {
224226
double fTotalEvents;
225227
double fBlindEvents;
226228
double fPrescaleEvents;
229+
double fTotalGenEvents;
227230
std::vector<caf::SRBNBInfo> fBNBInfo; ///< Store detailed BNB info to save into the first StandardRecord of the output file
228231
std::vector<caf::SRNuMIInfo> fNuMIInfo; ///< Store detailed NuMI info to save into the first StandardRecord of the output file
229232
std::map<unsigned int,sbn::BNBSpillInfo> fBNBInfoEventMap; ///< Store detailed BNB info to save for the particular spills of events
@@ -264,6 +267,8 @@ class CAFMaker : public art::EDProducer {
264267
double fGenieEvtRec_brEvtXSec = 0.0; ////< Cross section for selected event (1e-38 cm2)
265268
double fGenieEvtRec_brEvtDXSec = 0.0; ////< Cross section for selected event kinematics (1e-38 cm2 / {K^n})
266269
unsigned int fGenieEvtRec_brEvtKPS = 0; ////< Kinematic phase space variables. See $GENIE/src/Framework/Conventions/KinePhaseSpace.h -> KinePhaseSpace_t
270+
int fGenieEvtRec_brSctType = 0; ///< See [`genie::EScatteringType`](https://hep.ph.liv.ac.uk/~costasa/genie_doxygen/master/html/namespacegenie.html#ab97d2b4d1f37af8d967dadd15be88d0b)
271+
int fGenieEvtRec_brIntType = 0; ///< See [`genie::EInteractionType`](https://hep.ph.liv.ac.uk/~costasa/genie_doxygen/master/html/namespacegenie.html#a554f81bb9954c9e46bbabadfcd403111)
267272
double fGenieEvtRec_brEvtWght = 0.0; ////< Weight for that event
268273
double fGenieEvtRec_brEvtProb = 0.0; ////< Probability for that event (given cross section, path lengths, etc)
269274
double fGenieEvtRec_brEvtVtx[4] = {0.0}; ////< Event vertex position in detector coord syst (SI)
@@ -783,6 +788,7 @@ void CAFMaker::respondToOpenInputFile(const art::FileBlock& fb) {
783788
// so should be less than or equal to 32-bit
784789
fSourceFileHash = static_cast<std::uint32_t>(fSourceFileHashFull);
785790

791+
fNewInputFile = true;
786792
}
787793

788794
//......................................................................
@@ -858,6 +864,18 @@ void CAFMaker::beginRun(art::Run& run) {
858864
fDet = override;
859865
}
860866

867+
if (std::exchange(fNewInputFile, false)){
868+
for (const art::ProcessConfiguration &process: run.processHistory()) {
869+
std::optional<fhicl::ParameterSet> gen_config = run.getProcessParameterSet(process.processName());
870+
if (gen_config && gen_config->has_key("source") && gen_config->has_key("source.maxEvents") && gen_config->has_key("source.module_type") ) {
871+
int max_events = gen_config->get<int>("source.maxEvents");
872+
std::string module_type = gen_config->get<std::string>("source.module_type");
873+
if (module_type == "EmptyEvent") {
874+
fTotalGenEvents += max_events;
875+
}
876+
}
877+
}
878+
}
861879

862880
if(fParams.SystWeightLabels().empty()) return; // no need for globalTree
863881

@@ -1182,6 +1200,8 @@ void CAFMaker::InitializeOutfiles()
11821200
fFlatGenieTree->Branch("GenieEvtRec.EvtXSec", &fGenieEvtRec_brEvtXSec, "GenieEvtRec.EvtXSec/D" );
11831201
fFlatGenieTree->Branch("GenieEvtRec.EvtDXSec", &fGenieEvtRec_brEvtDXSec, "GenieEvtRec.EvtDXSec/D" );
11841202
fFlatGenieTree->Branch("GenieEvtRec.EvtKPS", &fGenieEvtRec_brEvtKPS, "GenieEvtRec.EvtKPS/i" );
1203+
fFlatGenieTree->Branch("GenieEvtRec.SctType", &fGenieEvtRec_brSctType, "GenieEvtRec.SctType/I" );
1204+
fFlatGenieTree->Branch("GenieEvtRec.IntType", &fGenieEvtRec_brIntType, "GenieEvtRec.IntType/I" );
11851205
fFlatGenieTree->Branch("GenieEvtRec.EvtWght", &fGenieEvtRec_brEvtWght, "GenieEvtRec.EvtWght/D" );
11861206
fFlatGenieTree->Branch("GenieEvtRec.EvtProb", &fGenieEvtRec_brEvtProb, "GenieEvtRec.EvtProb/D" );
11871207
fFlatGenieTree->Branch("GenieEvtRec.EvtVtx", fGenieEvtRec_brEvtVtx, "GenieEvtRec.EvtVtx[4]/D" );
@@ -1212,6 +1232,7 @@ void CAFMaker::InitializeOutfiles()
12121232
fTotalEvents = 0;
12131233
fBlindEvents = 0;
12141234
fPrescaleEvents = 0;
1235+
fTotalGenEvents = 0;
12151236
fIndexInFile = SRHeader::NoSourceIndex;
12161237
fFirstInSubRun = false;
12171238
fFirstBlindInSubRun = false;
@@ -1547,6 +1568,8 @@ void CAFMaker::produce(art::Event& evt) noexcept {
15471568
fGenieEvtRec_brEvtXSec = genie_rec->XSec() * (1e+38/genie::units::cm2);
15481569
fGenieEvtRec_brEvtDXSec = genie_rec->DiffXSec() * (1e+38/genie::units::cm2);
15491570
fGenieEvtRec_brEvtKPS = genie_rec->DiffXSecVars();
1571+
fGenieEvtRec_brSctType = genie_rec->Summary()->ProcInfo().ScatteringTypeId();
1572+
fGenieEvtRec_brIntType = genie_rec->Summary()->ProcInfo().InteractionTypeId();
15501573
fGenieEvtRec_brEvtWght = genie_rec->Weight();
15511574
fGenieEvtRec_brEvtProb = genie_rec->Probability();
15521575
fGenieEvtRec_brEvtVtx[0] = genie_rec->Vertex()->X();
@@ -1713,6 +1736,7 @@ void CAFMaker::produce(art::Event& evt) noexcept {
17131736
std::vector<caf::SRCRTTrack> srcrttracks;
17141737
std::vector<caf::SRCRTSpacePoint> srcrtspacepoints;
17151738
std::vector<caf::SRSBNDCRTTrack> srsbndcrttracks;
1739+
caf::SRSBNDCRTVeto srsbndcrtveto;
17161740
caf::SRSBNDFrameShiftInfo srsbndframeshiftinfo;
17171741
caf::SRSBNDTimingInfo srsbndtiminginfo;
17181742

@@ -1783,6 +1807,24 @@ void CAFMaker::produce(art::Event& evt) noexcept {
17831807
FillSBNDCRTTrack(sbndcrttracks[i], srsbndcrttracks.back());
17841808
}
17851809
}
1810+
1811+
// Fill CRT Veto
1812+
art::Handle<std::vector<sbnd::crt::CRTVeto>> sbndcrtveto_handle;
1813+
GetByLabelStrict(evt, fParams.SBNDCRTVetoLabel(), sbndcrtveto_handle);
1814+
// fill into event
1815+
if (sbndcrtveto_handle.isValid()) {
1816+
const std::vector<sbnd::crt::CRTVeto> &sbndcrtveto_vec = *sbndcrtveto_handle;
1817+
// Only one valid veto per event
1818+
if (sbndcrtveto_vec.size() == 1) {
1819+
// And associated SpacePoint objects
1820+
art::FindManyP<sbnd::crt::CRTSpacePoint> spAssoc(sbndcrtveto_handle, evt, fParams.SBNDCRTVetoLabel());
1821+
if (spAssoc.isValid()) {
1822+
// There is one vector of SpacePoints per Veto --> can be empty if no veto condition was satisfied
1823+
const std::vector<art::Ptr<sbnd::crt::CRTSpacePoint>>& veto_sp_v(spAssoc.at(0));
1824+
FillSBNDCRTVeto(sbndcrtveto_vec[0], veto_sp_v, srsbndcrtveto);
1825+
}
1826+
}
1827+
}
17861828

17871829
art::Handle<sbnd::timing::FrameShiftInfo> sbndframeshiftinfo_handle;
17881830
GetByLabelStrict(evt, fParams.SBNDFrameShiftInfoLabel(), sbndframeshiftinfo_handle);
@@ -2548,6 +2590,7 @@ void CAFMaker::produce(art::Event& evt) noexcept {
25482590
rec.ncrt_spacepoints = srcrtspacepoints.size();
25492591
rec.sbnd_crt_tracks = srsbndcrttracks;
25502592
rec.nsbnd_crt_tracks = srsbndcrttracks.size();
2593+
rec.sbnd_crt_veto = srsbndcrtveto;
25512594
rec.opflashes = srflashes;
25522595
rec.nopflashes = srflashes.size();
25532596
rec.sbnd_frames = srsbndframeshiftinfo;
@@ -2777,11 +2820,11 @@ void CAFMaker::endSubRun(art::SubRun& sr) {
27772820
//......................................................................
27782821
void CAFMaker::AddHistogramsToFile(TFile* outfile,bool isBlindPOT = false, bool isPrescalePOT = false) const
27792822
{
2780-
27812823
outfile->cd();
27822824

27832825
TH1* hPOT = new TH1D("TotalPOT", "TotalPOT;; POT", 1, 0, 1);
27842826
TH1* hEvents = new TH1D("TotalEvents", "TotalEvents;; Events", 1, 0, 1);
2827+
TH1* hGen = new TH1D("TotalGenEvents", "TotalGenEvents;; Events", 1, 0, 1);
27852828

27862829
if (isBlindPOT) {
27872830
hPOT->Fill(0.5,fTotalPOT*(1-(1/fParams.PrescaleFactor()))*GetBlindPOTScale());
@@ -2793,13 +2836,15 @@ void CAFMaker::endSubRun(art::SubRun& sr) {
27932836
hPOT->Fill(0.5,fTotalPOT);
27942837
}
27952838
hEvents->Fill(0.5,fTotalEvents);
2839+
hGen->Fill(0.5,fTotalGenEvents);
27962840

27972841
hPOT->Write();
27982842
hEvents->Write();
2843+
hGen->Write();
27992844

28002845
if (fParams.CreateBlindedCAF()) {
28012846
TH1*hBlindEvents = new TH1D("BlindEvents", "BlindEvents;; Events", 1, 0, 1);
2802-
TH1* hPrescaleEvents = new TH1D("PrescaleEvents", "PrescaleEvents;; Events", 1, 0, 1);
2847+
TH1*hPrescaleEvents = new TH1D("PrescaleEvents", "PrescaleEvents;; Events", 1, 0, 1);
28032848
hBlindEvents->Fill(0.5, fBlindEvents);
28042849
hPrescaleEvents->Fill(0.5, fPrescaleEvents);
28052850
hBlindEvents->Write();
@@ -2809,29 +2854,26 @@ void CAFMaker::endSubRun(art::SubRun& sr) {
28092854

28102855
//......................................................................
28112856
void CAFMaker::endJob() {
2812-
if (fTotalEvents == 0) {
28132857

2814-
std::cerr << "No events processed in this file. Aborting rather than "
2815-
"produce an empty CAF."
2858+
// Only produce empty recTree/GenieTree since it relies on non-zero art events.
2859+
// Still want to keep POT histograms.
2860+
if (fTotalEvents == 0) {
2861+
std::cerr << "No events processed in this file. Producing empty recTree/GenieTree."
28162862
<< std::endl;
2817-
// n.b. changed abort() to return so that eny exceptions thrown during startup
2818-
// still get printed to the user by art
2819-
return;
28202863
}
28212864

2822-
2823-
28242865
if(fFile){
2825-
28262866
AddHistogramsToFile(fFile);
2827-
fRecTree->SetDirectory(fFile);
2828-
if(fGenieTree){
2829-
fGenieTree->BuildIndex("SourceFileHash", "GENIEEntry");
2830-
fGenieTree->SetDirectory(fFile);
2831-
}
2832-
if (fParams.CreateBlindedCAF()) {
2833-
fRecTreeb->SetDirectory(fFileb);
2834-
fRecTreep->SetDirectory(fFilep);
2867+
if (fTotalEvents > 0) {
2868+
if(fGenieTree){
2869+
fGenieTree->BuildIndex("SourceFileHash", "GENIEEntry");
2870+
fGenieTree->SetDirectory(fFile);
2871+
}
2872+
fRecTree->SetDirectory(fFile);
2873+
if (fParams.CreateBlindedCAF()) {
2874+
fRecTreeb->SetDirectory(fFileb);
2875+
fRecTreep->SetDirectory(fFilep);
2876+
}
28352877
}
28362878
fFile->cd();
28372879
fFile->Write();
@@ -2847,17 +2889,19 @@ void CAFMaker::endJob() {
28472889
}
28482890

28492891
if(fFlatFile){
2850-
28512892
AddHistogramsToFile(fFlatFile);
2852-
fFlatTree->SetDirectory(fFlatFile);
2853-
if(fFlatGenieTree){
2854-
fFlatGenieTree->BuildIndex("SourceFileHash", "GENIEEntry");
2855-
fFlatGenieTree->SetDirectory(fFlatFile);
2856-
}
2857-
if (fParams.CreateBlindedCAF() && fFlatFileb) {
2858-
fFlatTreeb->SetDirectory(fFlatFileb);
2859-
fFlatTreep->SetDirectory(fFlatFilep);
2893+
if (fTotalEvents > 0) {
2894+
if(fFlatGenieTree){
2895+
fFlatGenieTree->BuildIndex("SourceFileHash", "GENIEEntry");
2896+
fFlatGenieTree->SetDirectory(fFlatFile);
2897+
}
2898+
fFlatTree->SetDirectory(fFlatFile);
2899+
if (fParams.CreateBlindedCAF() && fFlatFileb) {
2900+
fFlatTreeb->SetDirectory(fFlatFileb);
2901+
fFlatTreep->SetDirectory(fFlatFilep);
2902+
}
28602903
}
2904+
28612905
fFlatFile->cd();
28622906
fFlatFile->Write();
28632907
if (fParams.CreateBlindedCAF()) {

sbncode/CAFMaker/FillReco.cxx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,25 @@ namespace caf
188188
srsbndcrttrack.tof = track.ToF();
189189
}
190190

191+
void FillSBNDCRTVeto(const sbnd::crt::CRTVeto &veto,
192+
const std::vector<art::Ptr<sbnd::crt::CRTSpacePoint>> &points,
193+
caf::SRSBNDCRTVeto &srsbndcrtveto,
194+
bool allowEmpty)
195+
{
196+
srsbndcrtveto.V0 = veto.V0();
197+
srsbndcrtveto.V1 = veto.V1();
198+
srsbndcrtveto.V2 = veto.V2();
199+
srsbndcrtveto.V3 = veto.V3();
200+
srsbndcrtveto.V4 = veto.V4();
201+
202+
// add the CRTSpacePoint associations to the SR Veto
203+
for(auto const& sp : points) {
204+
srsbndcrtveto.sp_position.emplace_back(sp->X(), sp->Y(), sp->Z());
205+
srsbndcrtveto.sp_time.push_back(sp->Ts0()); // ns for SBND CRT SpacePoints
206+
srsbndcrtveto.sp_pe.push_back(sp->PE());
207+
}
208+
}
209+
191210
void FillSBNDFrameShiftInfo(const sbnd::timing::FrameShiftInfo &frame,
192211
caf::SRSBNDFrameShiftInfo &srsbndframe,
193212
bool allowEmpty)
@@ -349,13 +368,10 @@ namespace caf
349368
slice.correctedOpFlash.setDefault();
350369
if ( slcCorrectedOpFlash.empty()==false ) {
351370
const sbn::CorrectedOpFlashTiming &_correctedOpFlash = *slcCorrectedOpFlash[0];
352-
//TODO: use the score of the match to fill the information accordingly
353371
slice.correctedOpFlash.OpFlashT0 = _correctedOpFlash.OpFlashT0;
354-
slice.correctedOpFlash.UpstreamTime_lightonly = _correctedOpFlash.UpstreamTime_lightonly;
355-
slice.correctedOpFlash.UpstreamTime_tpczcorr = _correctedOpFlash.UpstreamTime_tpczcorr;
356-
slice.correctedOpFlash.UpstreamTime_propcorr_tpczcorr = _correctedOpFlash.UpstreamTime_propcorr_tpczcorr;
357-
slice.correctedOpFlash.FMScore = _correctedOpFlash.FMScore;
358-
slice.correctedOpFlash.SliceNuScore = _correctedOpFlash.SliceNuScore;
372+
slice.correctedOpFlash.NuToFLight = _correctedOpFlash.NuToFLight;
373+
slice.correctedOpFlash.NuToFCharge = _correctedOpFlash.NuToFCharge;
374+
slice.correctedOpFlash.OpFlashT0Corrected = _correctedOpFlash.OpFlashT0Corrected;
359375
}
360376
}
361377

sbncode/CAFMaker/FillReco.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "sbnobj/Common/CRT/CRTTrack.hh"
4343
#include "sbnobj/SBND/CRT/CRTSpacePoint.hh"
4444
#include "sbnobj/SBND/CRT/CRTTrack.hh"
45+
#include "sbnobj/SBND/CRT/CRTVeto.hh"
4546
#include "sbnobj/Common/CRT/CRTPMTMatching.hh"
4647
#include "sbnobj/Common/CRT/CRTHitT0TaggingInfo.hh"
4748
#include "sbnobj/Common/PMT/Data/PMTBeamSignal.hh"
@@ -281,6 +282,11 @@ namespace caf
281282
void FillSBNDCRTTrack(const sbnd::crt::CRTTrack &track,
282283
caf::SRSBNDCRTTrack &srsbndcrttrack,
283284
bool allowEmpty = false);
285+
286+
void FillSBNDCRTVeto(const sbnd::crt::CRTVeto &veto,
287+
const std::vector<art::Ptr<sbnd::crt::CRTSpacePoint>> &points,
288+
caf::SRSBNDCRTVeto &srsbndcrtveto,
289+
bool allowEmpty = false);
284290

285291
void FillICARUSOpFlash(const recob::OpFlash &flash,
286292
std::vector<recob::OpHit const*> const& hits,

ups/product_deps

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ libdir fq_dir lib
252252
#
253253
####################################
254254
product version qual flags <table_format=2>
255-
genie_xsec v3_04_00 -
255+
genie_xsec v3_06_00 -
256256
larcv2 v2_2_6 -
257-
larsoft v10_11_01 -
258-
sbnalg v10_11_01_01 -
257+
larsoft v10_12_02 -
258+
sbnalg v10_12_02 -
259259
sbndaq_artdaq_core v1_10_06 -
260260
sbndata v01_08 -
261261
systematicstools v01_04_04 -
262-
nusystematics v1_05_07 -
263-
geant4reweight v01_20_11 -
262+
nusystematics v1_05_09 -
263+
geant4reweight v01_20_13 -
264264
cetmodules v3_24_01 - only_for_build
265265
end_product_list
266266
####################################

0 commit comments

Comments
 (0)