Skip to content

Commit 990f123

Browse files
committed
Fix: Change back to Run 1 Baseline and other minor changes to opDetDigitizerSBND_module.cc
1 parent a25a48b commit 990f123

7 files changed

Lines changed: 29 additions & 82 deletions

sbndcode/Decoders/PMT/run_pmtdecoder.fcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services: {
1111
MonWidth: 12
1212
TotalCAENBoards: 8
1313
PMTPerBoard: 15
14-
Baseline: 14257 #Run 1: 14250, Run 2: 14257
14+
Baseline: 14250 #Run 1: 14250, Run 2: 14257
1515
MC: false
1616
}
1717
}

sbndcode/OpDetSim/TriggerEmulationService.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace calib {
1717
: fMonWidth(pset.get<int>("MonWidth", 12)),
1818
fTotalCAENBoards(pset.get<int>("TotalCAENBoards", 8)),
1919
PMTPerBoard(pset.get<int>("PMTPerBoard", 15)),
20-
Baseline(pset.get<int>("Baseline", 14257)),
20+
Baseline(pset.get<int>("Baseline")),
2121
fMC(pset.get<bool>("MC", true))
2222
{}
2323

@@ -69,10 +69,10 @@ namespace calib {
6969
if (PMT_Channels.empty()) std::cout<<"Warning: Please provide PMT channels list to check if channels are PMT channels."<<std::endl;
7070
else {
7171
if (!(std::find(PMT_Channels.begin(), PMT_Channels.end(), ch1) != PMT_Channels.end())) {
72-
std::cout<<"Paired channel "<<ch1<<" is not PMT channel. Check Pairs list. Skipping..."<<std::endl;
72+
throw cet::exception("TriggerEmulationService") << "Paired channel " << ch1 << " is not PMT channel. Check Pairs list. Skipping..." << std::endl;
7373
continue;
7474
} if (!(std::find(PMT_Channels.begin(), PMT_Channels.end(), ch2) != PMT_Channels.end())) {
75-
std::cout<<"Paired channel "<<ch2<<" is not PMT channel. Check Pairs list. Skipping..."<<std::endl;
75+
throw cet::exception("TriggerEmulationService") << "Paired channel " << ch2 << " is not PMT channel. Check Pairs list. Skipping..." << std::endl;
7676
continue;
7777
}
7878
}
@@ -104,7 +104,7 @@ namespace calib {
104104
if (PMT_Channels.empty()) std::cout<<"Warning: Please provide PMT channels list to check if channels are PMT channels."<<std::endl;
105105
else {
106106
if (!(std::find(PMT_Channels.begin(), PMT_Channels.end(), ch) != PMT_Channels.end())) {
107-
std::cout<<"Unpaired channel "<<ch<<" is not PMT channel. Check list. Skipping..."<<std::endl;
107+
throw cet::exception("TriggerEmulationService") << "Unpaired channel " << ch << " is not PMT channel. Check list. Skipping..." << std::endl;
108108
continue;
109109
}
110110
}

sbndcode/OpDetSim/digi_pmt_sbnd.fcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ sbnd_digipmt_alg:
2424

2525
# Digitizer simulation
2626
PMTADCDynamicRange: 14745 #in ADC values
27-
PMTBaseline: 14745 #in ADC
27+
PMTBaseline: 14250 #in ADC
2828
PMTBaselineRMS: 2.6 #in ADC
2929

3030
#Sample noise from data

sbndcode/OpDetSim/opDetDigitizerSBND_module.cc

Lines changed: 21 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,6 @@ namespace opdet {
137137
Comment("Threshold for pair count threshold for event/flash triggers (to determine interesting trigger)")
138138
};
139139

140-
fhicl::Atom<bool> SaveNewPlots{
141-
Name("SaveNewPlots"),
142-
Comment("Save plots of triggered waveforms and MonPulse with new trigger logic.")
143-
};
144-
145-
fhicl::Atom<bool> SaveOldPlots{
146-
Name("SaveOldPlots"),
147-
Comment("Save plots of triggered waveforms with old trigger logic.")
148-
};
149-
150140
fhicl::TableFragment<opdet::DigiPMTSBNDAlgMaker::Config> pmtAlgoConfig;
151141
fhicl::TableFragment<opdet::DigiArapucaSBNDAlgMaker::Config> araAlgoConfig;
152142
fhicl::TableFragment<opdet::opDetSBNDTriggerAlg::Config> trigAlgoConfig;
@@ -169,7 +159,7 @@ namespace opdet {
169159
// Required functions.
170160
void produce(art::Event & e) override;
171161
std::vector<raw::OpDetWaveform> sliceWaveforms(std::vector<raw::OpDetWaveform> fWaveforms,
172-
std::vector<int> PMT_Channels,
162+
std::vector<int> fPMT_Channels,
173163
std::vector<int> *MonPulse,
174164
int PairMultiplicityThreshold,
175165
double tickPeriod,
@@ -185,6 +175,8 @@ namespace opdet {
185175
unsigned int nChannels = map.size();
186176
std::vector<raw::OpDetWaveform> fWaveforms; // holder for un-triggered waveforms
187177

178+
std::vector<int> fPMT_Channels;
179+
188180
private:
189181
bool fApplyTriggers;
190182
art::InputTag fInputModuleName;
@@ -218,8 +210,6 @@ namespace opdet {
218210
float PercentTicksBeforeCross;
219211
int MonThreshold;
220212
int PairMultiplicityThreshold;
221-
bool SaveNewPlots;
222-
bool SaveOldPlots;
223213
};
224214

225215
opDetDigitizerSBND::opDetDigitizerSBND(Parameters const& config)
@@ -233,8 +223,6 @@ namespace opdet {
233223
, PercentTicksBeforeCross(config().PercentTicksBeforeCross())
234224
, MonThreshold(config().MonThreshold())
235225
, PairMultiplicityThreshold(config().PairMultiplicityThreshold())
236-
, SaveNewPlots(config().SaveNewPlots())
237-
, SaveOldPlots(config().SaveOldPlots())
238226
{
239227
opDetDigitizerWorker::Config wConfig( config().pmtAlgoConfig(), config().araAlgoConfig());
240228

@@ -309,6 +297,12 @@ namespace opdet {
309297
&fFinished);
310298
}
311299

300+
// get PMT channels
301+
for (const auto& wvf : fWaveforms) {
302+
auto ch = wvf.ChannelNumber();
303+
if (map.isPDType(ch, "pmt_uncoated") || map.isPDType(ch, "pmt_coated")) fPMT_Channels.push_back(ch);
304+
}
305+
312306
// Call appropriate produces<>() functions here.
313307
produces< std::vector< raw::OpDetWaveform > >();
314308
produces<bool>("triggerEmulation");
@@ -376,63 +370,27 @@ namespace opdet {
376370

377371
std::vector<int> numPairsOverThreshold;
378372

379-
// get PMT channels
380-
std::vector<int> PMT_Channels;
381-
for (const auto& wvf : fWaveforms) {
382-
auto ch = wvf.ChannelNumber();
383-
if (map.isPDType(ch, "pmt_uncoated") || map.isPDType(ch, "pmt_coated")) PMT_Channels.push_back(ch);
384-
}
385-
386-
if (PMT_Channels.empty()) std::cout<<"Error: PMT has *NO* PMT channels in fWaveforms"<<std::endl;
387-
int WaveIndex = PMT_Channels[0];
373+
if (fPMT_Channels.empty()) throw cet::exception("opDetDigitizerSBND") << "PMT has *NO* PMT channels in fWaveforms" << std::endl;
374+
int WaveIndex = fPMT_Channels[0];
388375
int WaveformSize = fWaveforms[WaveIndex].size();
389376

390377
std::vector<int>* MonPulse = new std::vector<int>(WaveformSize, 0);
391378

392379
int pairThisFlash = 0;
393380
// Send 3ms waveforms to ConstructMonPulse
394-
fTriggerService->ConstructMonPulse(fWaveforms, MonThreshold, MonPulse, 0, &pairThisFlash, PMT_Channels);
381+
fTriggerService->ConstructMonPulse(fWaveforms, MonThreshold, MonPulse, 0, &pairThisFlash, fPMT_Channels);
395382
numPairsOverThreshold.push_back(pairThisFlash);
396383

397384
double tickPeriod = sampling_rate(clockData);
398385

399-
std::vector<raw::OpDetWaveform> SlicedWaveforms = sliceWaveforms(fWaveforms, PMT_Channels, MonPulse, PairMultiplicityThreshold, tickPeriod, ticksPerSlice, PercentTicksBeforeCross);
386+
std::vector<raw::OpDetWaveform> SlicedWaveforms = sliceWaveforms(fWaveforms, fPMT_Channels, MonPulse, PairMultiplicityThreshold, tickPeriod, ticksPerSlice, PercentTicksBeforeCross);
400387
std::vector<std::vector<int>> SlicedMonPulse = sliceMonPulse(MonPulse, PairMultiplicityThreshold, ticksPerSlice, PercentTicksBeforeCross);
401388

402389
int numSlices = SlicedMonPulse.size();
403390
SlicedWaveformsAll.push_back(std::move(SlicedWaveforms));
404391
MonPulsesFlat.insert(MonPulsesFlat.end(), (*MonPulse).begin(), (*MonPulse).end());
405392
pulseSizes.push_back(MonPulse->size());
406393

407-
if (SaveNewPlots) {
408-
// Save histograms
409-
// Sliced waveforms
410-
for (size_t j; j < SlicedWaveformsAll.size(); ++j) {
411-
std::stringstream plotname2;
412-
plotname2 << "Sliced_waveforms_" << e.id().event() << "_Mon_" << MonThreshold << "_slice" << j;
413-
PlotWaveforms(SlicedWaveformsAll[j], plotname2.str());
414-
}
415-
// Long MonPulse
416-
std::stringstream histname;
417-
histname << "Long_event_" << e.id().event() << "_Mon_" << MonThreshold;
418-
TH1D* MonHist = tfs->make<TH1D>(histname.str().c_str(), histname.str().c_str(),
419-
MonPulse->size(), 0.0, MonPulse->size() - 1);
420-
for (size_t i = 0; i < MonPulse->size(); i++) {
421-
MonHist->SetBinContent(i + 1, (*MonPulse)[i]);
422-
}
423-
// Sliced MonPulse
424-
for (size_t idx = 0; idx < SlicedMonPulse.size(); ++idx) {
425-
auto const& vec = SlicedMonPulse[idx];
426-
std::stringstream histname;
427-
histname << "Sliced_event_" << e.id().event() << "_Mon_" << MonThreshold << "_slice" << idx;
428-
429-
TH1D* MonHist = tfs->make<TH1D>(histname.str().c_str(), histname.str().c_str(),
430-
vec.size(), 0.0, vec.size() - 1);
431-
for (size_t i = 0; i < vec.size(); i++) {
432-
MonHist->SetBinContent(i + 1, vec[i]);
433-
}
434-
}
435-
}
436394
delete MonPulse;
437395
//}
438396

@@ -455,29 +413,20 @@ namespace opdet {
455413
opdet::StartopDetDigitizerWorkers(fNThreads, fSemStart);
456414
opdet::WaitopDetDigitizerWorkers(fNThreads, fSemFinish);
457415

458-
// plot fTriggeredWaveforms
459-
if (SaveOldPlots) {
460-
for (size_t j; j < fTriggeredWaveforms.size(); ++j) {
461-
std::stringstream plotnameTW;
462-
plotnameTW << "Triggered_waveforms_" << e.id().event() << "_Mon_" << MonThreshold;
463-
PlotWaveforms(fTriggeredWaveforms[j], plotnameTW.str());
464-
}
465-
}
466-
467416
// put triggered waveforms in the event (old trigger logic)
468417
for (std::vector<raw::OpDetWaveform> &waveforms : fTriggeredWaveforms) {
469418
// move these waveforms into the pulseVecPtr
470419
pulseVecPtr->reserve(pulseVecPtr->size() + waveforms.size());
471420
std::move(waveforms.begin(), waveforms.end(), std::back_inserter(*pulseVecPtr));
472421
}
473-
// clean up the vector
474-
for (unsigned i = 0; i < fTriggeredWaveforms.size(); i++) {
475-
fTriggeredWaveforms[i] = std::vector<raw::OpDetWaveform>();
476-
}
477422
// put the waveforms in the event
478423
e.put(std::move(pulseVecPtr));
479424
// clear out the triggers
480425
fTriggerAlg.ClearTriggerLocations();
426+
// clean up the vector
427+
for (unsigned i = 0; i < fTriggeredWaveforms.size(); i++) {
428+
fTriggeredWaveforms[i] = std::vector<raw::OpDetWaveform>();
429+
}
481430

482431

483432
// put boolean trigger result in the event
@@ -512,12 +461,12 @@ namespace opdet {
512461
SlicedWaveformsPtr->reserve(SlicedWaveformsPtr->size() + waveforms.size());
513462
std::move(waveforms.begin(), waveforms.end(), std::back_inserter(*SlicedWaveformsPtr));
514463
}
464+
// put the waveforms in the event
465+
e.put(std::move(SlicedWaveformsPtr), "slicedWaveforms");
515466
// clean up the vector
516467
for (unsigned i = 0; i < SlicedWaveformsAll.size(); i++) {
517468
SlicedWaveformsAll[i] = std::vector<raw::OpDetWaveform>();
518469
}
519-
// put the waveforms in the event
520-
e.put(std::move(SlicedWaveformsPtr), "slicedWaveforms");
521470

522471
// put MonPulses in the event
523472
auto flatPtr = std::make_unique<std::vector<int>>(std::move(MonPulsesFlat));
@@ -625,7 +574,7 @@ namespace opdet {
625574
// sliceWaveforms function
626575
std::vector<raw::OpDetWaveform> opDetDigitizerSBND::sliceWaveforms(
627576
std::vector<raw::OpDetWaveform> fWaveforms,
628-
std::vector<int> PMT_Channels,
577+
std::vector<int> fPMT_Channels,
629578
std::vector<int>* MonPulse,
630579
int PairMultiplicityThreshold,
631580
double tickPeriod,
@@ -641,7 +590,7 @@ namespace opdet {
641590

642591
std::vector<raw::OpDetWaveform> SlicedWaveforms;
643592
// loop through channels
644-
for (int chan : PMT_Channels) {
593+
for (int chan : fPMT_Channels) {
645594
const raw::OpDetWaveform& wf = fWaveforms[chan];
646595

647596
for (auto [start, end] : intervals) {

sbndcode/OpDetSim/opdetdigitizer_sbnd.fcl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ sbnd_opdetdigitizer:
1616
PercentTicksBeforeCross: 0.2
1717
MonThreshold: 15
1818
PairMultiplicityThreshold: 4
19-
SaveNewPlots: true
20-
SaveOldPlots: false
2119

2220
@table::sbnd_digipmt_alg
2321
@table::sbnd_digiarapuca_alg

sbndcode/OpDetSim/run_BeamRatesCalib.fcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ services:
1717
MonWidth: 12
1818
TotalCAENBoards: 8
1919
PMTPerBoard: 15
20-
Baseline: 14257 #Run 1: 14250, Run 2: 14257
20+
Baseline: 14250 #Run 1: 14250, Run 2: 14257
2121
MC: false
2222
}
2323
}

sbndcode/OpDetSim/triggeremulationservice_sbnd.fcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sbnd_triggeremulation_service: {
66
MonWidth: 12
77
TotalCAENBoards: 8
88
PMTPerBoard: 15
9-
Baseline: 14257 #Run 1: 14250, Run 2: 14257
9+
Baseline: 14250 #Run 1: 14250, Run 2: 14257
1010
MC: true
1111
}
1212

0 commit comments

Comments
 (0)