Skip to content

Commit b0de6f4

Browse files
authored
Merge branch 'release/SBN2025A' into feature/twester_wiremod_production
2 parents d3fd5db + 09ee016 commit b0de6f4

5 files changed

Lines changed: 86 additions & 85 deletions

File tree

sbncode/BeamSpillInfoRetriever/SBNDBNBRetriever/SBNDBNBRetriever_module.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ sbn::SBNDBNBRetriever::SBNDBNBRetriever(fhicl::ParameterSet const & params)
7272
vp873->set_epsilon(0.02);
7373

7474
offsets = ifbeam_handle->getBeamFolder(params.get<std::string>("OffsetBundle"), params.get<std::string>("URL"), timeWindow);
75-
offsets->set_epsilon(600);
75+
offsets->set_epsilon(1000);
7676

7777
}
7878

sbncode/BeamSpillInfoRetriever/SBNDPOTTools.cpp

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -73,33 +73,33 @@ namespace sbn{
7373
// initializing all of our device carriers
7474
// device definitions can be found in BNBSpillInfo.h
7575

76-
double TOR860 = 0; // units e12 protons
77-
double TOR875 = 0; // units e12 protons
78-
double LM875A = 0; // units R/s
79-
double LM875B = 0; // units R/s
80-
double LM875C = 0; // units R/s
81-
double HP875 = 0; // units mm
82-
double VP875 = 0; // units mm
83-
double HPTG1 = 0; // units mm
84-
double VPTG1 = 0; // units mm
85-
double HPTG2 = 0; // units mm
86-
double VPTG2 = 0; // units mm
87-
double BTJT2 = 0; // units Deg C
88-
double THCURR = 0; // units kiloAmps
76+
double TOR860 = -999; // units e12 protons
77+
double TOR875 = -999; // units e12 protons
78+
double LM875A = -999; // units R/s
79+
double LM875B = -999; // units R/s
80+
double LM875C = -999; // units R/s
81+
double HP875 = -999; // units mm
82+
double VP875 = -999; // units mm
83+
double HPTG1 = -999; // units mm
84+
double VPTG1 = -999; // units mm
85+
double HPTG2 = -999; // units mm
86+
double VPTG2 = -999; // units mm
87+
double BTJT2 = -999; // units Deg C
88+
double THCURR = -999; // units kiloAmps
8989

9090

91-
double VP873 = 0; //units mm; not in the first IFBeam query bunch
92-
double HP875Offset =0;//units mm; make a another separate IFBeam query bunch for offsets
93-
double VP875Offset =0;//units mm
94-
double VP873Offset =0;//units mm
95-
double HPTG1Offset =0;//units mm
96-
double HPTG2Offset =0;//units mm
97-
double VPTG1Offset =0;//units mm
98-
double VPTG2Offset =0;//units mm
91+
double VP873 = -999; //units mm; not in the first IFBeam query bunch
92+
double HP875Offset = -999;//units mm; make a another separate IFBeam query bunch for offsets
93+
double VP875Offset = -999;//units mm
94+
double VP873Offset = -999;//units mm
95+
double HPTG1Offset = -999;//units mm
96+
double HPTG2Offset = -999;//units mm
97+
double VPTG1Offset = -999;//units mm
98+
double VPTG2Offset = -999;//units mm
9999

100-
double TOR860_time = 0; // units s
100+
double TOR860_time = -999; // units s
101101

102-
double FOM =0;
102+
double FOM = -999;
103103

104104
// Here we request all the devices
105105
// since sometimes devices fail to report we'll
@@ -122,7 +122,7 @@ namespace sbn{
122122

123123

124124

125-
try{bfp->GetNamedData(time, "E:VP873",&VP873);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
125+
try{vp873->GetNamedData(time, "E:VP873",&VP873);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
126126

127127
try{offsets->GetNamedData(time, "E_VP873S",&VP873Offset);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
128128
try{offsets->GetNamedData(time, "E_HP875S",&HP875Offset);}catch (WebAPIException &we) {mf::LogDebug("SBNDBNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
@@ -217,21 +217,21 @@ namespace sbn{
217217
// if time is just a single outlier.
218218
bool BrokenClock(double time, std::unique_ptr<ifbeam_ns::BeamFolder> const& bfp)
219219
{
220-
double TOR860 = 0; // units e12 protons
221-
double TOR875 = 0; // units e12 protons
222-
double LM875A = 0; // units R/s
223-
double LM875B = 0; // units R/s
224-
double LM875C = 0; // units R/s
225-
double HP875 = 0; // units mm
226-
double VP875 = 0; // units mm
227-
double HPTG1 = 0; // units mm
228-
double VPTG1 = 0; // units mm
229-
double HPTG2 = 0; // units mm
230-
double VPTG2 = 0; // units mm
231-
double BTJT2 = 0; // units Deg C
232-
double THCURR = 0; // units kiloAmps
220+
double TOR860 = -999; // units e12 protons
221+
double TOR875 = -999; // units e12 protons
222+
double LM875A = -999; // units R/s
223+
double LM875B = -999; // units R/s
224+
double LM875C = -999; // units R/s
225+
double HP875 = -999; // units mm
226+
double VP875 = -999; // units mm
227+
double HPTG1 = -999; // units mm
228+
double VPTG1 = -999; // units mm
229+
double HPTG2 = -999; // units mm
230+
double VPTG2 = -999; // units mm
231+
double BTJT2 = -999; // units Deg C
232+
double THCURR = -999; // units kiloAmps
233233

234-
double TOR860_time = 0; // units s
234+
double TOR860_time = -999; // units s
235235

236236
// Here we request all the devices
237237
// since sometimes devices fail to report we'll

sbncode/BeamSpillInfoRetriever/job/sbndbnbdefaults.fcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ sbndbnbspillinfo: {
1212
OffsetBundle: "BNB_BPM_settings"
1313

1414
TimeWindow: "700" #seconds
15-
MWR_TimeWindow: "3601" #seconds
15+
MWR_TimeWindow: "700" #seconds
1616
DeviceUsedForTiming: "E:TOR860"
1717
}
1818

sbncode/BeamSpillInfoRetriever/job/sbndbnbspillinfo.fcl

Lines changed: 0 additions & 17 deletions
This file was deleted.

sbncode/CAFMaker/CAFMaker_module.cc

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ class CAFMaker : public art::EDProducer {
206206

207207
std::string fSourceFile;
208208
std::uint32_t fSourceFileHash;
209+
210+
bool fNewInputFile;
209211

210212
bool fOverrideRealData;
211213
bool fFirstInSubRun;
@@ -223,6 +225,7 @@ class CAFMaker : public art::EDProducer {
223225
double fTotalEvents;
224226
double fBlindEvents;
225227
double fPrescaleEvents;
228+
double fTotalGenEvents;
226229
std::vector<caf::SRBNBInfo> fBNBInfo; ///< Store detailed BNB info to save into the first StandardRecord of the output file
227230
std::vector<caf::SRNuMIInfo> fNuMIInfo; ///< Store detailed NuMI info to save into the first StandardRecord of the output file
228231
std::map<unsigned int,sbn::BNBSpillInfo> fBNBInfoEventMap; ///< Store detailed BNB info to save for the particular spills of events
@@ -782,6 +785,7 @@ void CAFMaker::respondToOpenInputFile(const art::FileBlock& fb) {
782785
// so should be less than or equal to 32-bit
783786
fSourceFileHash = static_cast<std::uint32_t>(fSourceFileHashFull);
784787

788+
fNewInputFile = true;
785789
}
786790

787791
//......................................................................
@@ -857,6 +861,18 @@ void CAFMaker::beginRun(art::Run& run) {
857861
fDet = override;
858862
}
859863

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

861877
if(fParams.SystWeightLabels().empty()) return; // no need for globalTree
862878

@@ -1211,6 +1227,7 @@ void CAFMaker::InitializeOutfiles()
12111227
fTotalEvents = 0;
12121228
fBlindEvents = 0;
12131229
fPrescaleEvents = 0;
1230+
fTotalGenEvents = 0;
12141231
fIndexInFile = SRHeader::NoSourceIndex;
12151232
fFirstInSubRun = false;
12161233
fFirstBlindInSubRun = false;
@@ -2704,11 +2721,11 @@ void CAFMaker::endSubRun(art::SubRun& sr) {
27042721
//......................................................................
27052722
void CAFMaker::AddHistogramsToFile(TFile* outfile,bool isBlindPOT = false, bool isPrescalePOT = false) const
27062723
{
2707-
27082724
outfile->cd();
27092725

27102726
TH1* hPOT = new TH1D("TotalPOT", "TotalPOT;; POT", 1, 0, 1);
27112727
TH1* hEvents = new TH1D("TotalEvents", "TotalEvents;; Events", 1, 0, 1);
2728+
TH1* hGen = new TH1D("TotalGenEvents", "TotalGenEvents;; Events", 1, 0, 1);
27122729

27132730
if (isBlindPOT) {
27142731
hPOT->Fill(0.5,fTotalPOT*(1-(1/fParams.PrescaleFactor()))*GetBlindPOTScale());
@@ -2720,13 +2737,15 @@ void CAFMaker::endSubRun(art::SubRun& sr) {
27202737
hPOT->Fill(0.5,fTotalPOT);
27212738
}
27222739
hEvents->Fill(0.5,fTotalEvents);
2740+
hGen->Fill(0.5,fTotalGenEvents);
27232741

27242742
hPOT->Write();
27252743
hEvents->Write();
2744+
hGen->Write();
27262745

27272746
if (fParams.CreateBlindedCAF()) {
27282747
TH1*hBlindEvents = new TH1D("BlindEvents", "BlindEvents;; Events", 1, 0, 1);
2729-
TH1* hPrescaleEvents = new TH1D("PrescaleEvents", "PrescaleEvents;; Events", 1, 0, 1);
2748+
TH1*hPrescaleEvents = new TH1D("PrescaleEvents", "PrescaleEvents;; Events", 1, 0, 1);
27302749
hBlindEvents->Fill(0.5, fBlindEvents);
27312750
hPrescaleEvents->Fill(0.5, fPrescaleEvents);
27322751
hBlindEvents->Write();
@@ -2736,29 +2755,26 @@ void CAFMaker::endSubRun(art::SubRun& sr) {
27362755

27372756
//......................................................................
27382757
void CAFMaker::endJob() {
2739-
if (fTotalEvents == 0) {
27402758

2741-
std::cerr << "No events processed in this file. Aborting rather than "
2742-
"produce an empty CAF."
2759+
// Only produce empty recTree/GenieTree since it relies on non-zero art events.
2760+
// Still want to keep POT histograms.
2761+
if (fTotalEvents == 0) {
2762+
std::cerr << "No events processed in this file. Producing empty recTree/GenieTree."
27432763
<< std::endl;
2744-
// n.b. changed abort() to return so that eny exceptions thrown during startup
2745-
// still get printed to the user by art
2746-
return;
27472764
}
27482765

2749-
2750-
27512766
if(fFile){
2752-
27532767
AddHistogramsToFile(fFile);
2754-
fRecTree->SetDirectory(fFile);
2755-
if(fGenieTree){
2756-
fGenieTree->BuildIndex("SourceFileHash", "GENIEEntry");
2757-
fGenieTree->SetDirectory(fFile);
2758-
}
2759-
if (fParams.CreateBlindedCAF()) {
2760-
fRecTreeb->SetDirectory(fFileb);
2761-
fRecTreep->SetDirectory(fFilep);
2768+
if (fTotalEvents > 0) {
2769+
if(fGenieTree){
2770+
fGenieTree->BuildIndex("SourceFileHash", "GENIEEntry");
2771+
fGenieTree->SetDirectory(fFile);
2772+
}
2773+
fRecTree->SetDirectory(fFile);
2774+
if (fParams.CreateBlindedCAF()) {
2775+
fRecTreeb->SetDirectory(fFileb);
2776+
fRecTreep->SetDirectory(fFilep);
2777+
}
27622778
}
27632779
fFile->cd();
27642780
fFile->Write();
@@ -2774,17 +2790,19 @@ void CAFMaker::endJob() {
27742790
}
27752791

27762792
if(fFlatFile){
2777-
27782793
AddHistogramsToFile(fFlatFile);
2779-
fFlatTree->SetDirectory(fFlatFile);
2780-
if(fFlatGenieTree){
2781-
fFlatGenieTree->BuildIndex("SourceFileHash", "GENIEEntry");
2782-
fFlatGenieTree->SetDirectory(fFlatFile);
2783-
}
2784-
if (fParams.CreateBlindedCAF() && fFlatFileb) {
2785-
fFlatTreeb->SetDirectory(fFlatFileb);
2786-
fFlatTreep->SetDirectory(fFlatFilep);
2794+
if (fTotalEvents > 0) {
2795+
if(fFlatGenieTree){
2796+
fFlatGenieTree->BuildIndex("SourceFileHash", "GENIEEntry");
2797+
fFlatGenieTree->SetDirectory(fFlatFile);
2798+
}
2799+
fFlatTree->SetDirectory(fFlatFile);
2800+
if (fParams.CreateBlindedCAF() && fFlatFileb) {
2801+
fFlatTreeb->SetDirectory(fFlatFileb);
2802+
fFlatTreep->SetDirectory(fFlatFilep);
2803+
}
27872804
}
2805+
27882806
fFlatFile->cd();
27892807
fFlatFile->Write();
27902808
if (fParams.CreateBlindedCAF()) {

0 commit comments

Comments
 (0)