Skip to content

Commit 4309dfe

Browse files
authored
Merge branch 'develop' into feature/sungbino_likepid_into_cafmaker
2 parents 4346c58 + 833248e commit 4309dfe

18 files changed

Lines changed: 162 additions & 1376 deletions

sbncode/BeamSpillInfoRetriever/POTTools.cpp

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -68,42 +68,42 @@ namespace sbn::pot{
6868
// initializing all of our device carriers
6969
// device definitions can be found in BNBSpillInfo.h
7070

71-
double TOR860 = 0; // units e12 protons
72-
double TOR875 = 0; // units e12 protons
73-
double LM875A = 0; // units R/s
74-
double LM875B = 0; // units R/s
75-
double LM875C = 0; // units R/s
76-
double HP873 = 0; // units mm
77-
double VP873 = 0; // units mm; not in the first IFBeam query bunch
78-
double HP875 = 0; // units mm
79-
double VP875 = 0; // units mm
80-
double HPTG1 = 0; // units mm
81-
double VPTG1 = 0; // units mm
82-
double HPTG2 = 0; // units mm
83-
double VPTG2 = 0; // units mm
84-
double BTJT2 = 0; // units Deg C
85-
double THCURR = 0; // units kiloAmps
86-
double M875HS = 0; // units mm
87-
double M875VS = 0; // units mm
88-
double M875HM = 0; // units mm
89-
double M875VM = 0; // units mm
90-
double M876HS = 0; // units mm
91-
double M876VS = 0; // units mm
92-
double M876HM = 0; // units mm
93-
double M876VM = 0; // units mm
71+
double TOR860 = -999; // units e12 protons
72+
double TOR875 = -999; // units e12 protons
73+
double LM875A = -999; // units R/s
74+
double LM875B = -999; // units R/s
75+
double LM875C = -999; // units R/s
76+
double HP873 = -999; // units mm
77+
double VP873 = -999; // units mm; not in the first IFBeam query bunch
78+
double HP875 = -999; // units mm
79+
double VP875 = -999; // units mm
80+
double HPTG1 = -999; // units mm
81+
double VPTG1 = -999; // units mm
82+
double HPTG2 = -999; // units mm
83+
double VPTG2 = -999; // units mm
84+
double BTJT2 = -999; // units Deg C
85+
double THCURR = -999; // units kiloAmps
86+
double M875HS = -999; // units mm
87+
double M875VS = -999; // units mm
88+
double M875HM = -999; // units mm
89+
double M875VM = -999; // units mm
90+
double M876HS = -999; // units mm
91+
double M876VS = -999; // units mm
92+
double M876HM = -999; // units mm
93+
double M876VM = -999; // units mm
9494

9595

96-
double HP875Offset =0;//units mm; make a another separate IFBeam query bunch for offsets
97-
double VP875Offset =0;//units mm
98-
double VP873Offset =0;//units mm
99-
double HPTG1Offset =0;//units mm
100-
double HPTG2Offset =0;//units mm
101-
double VPTG1Offset =0;//units mm
102-
double VPTG2Offset =0;//units mm
96+
double HP875Offset =-999;//units mm; make a another separate IFBeam query bunch for offsets
97+
double VP875Offset =-999;//units mm
98+
double VP873Offset =-999;//units mm
99+
double HPTG1Offset =-999;//units mm
100+
double HPTG2Offset =-999;//units mm
101+
double VPTG1Offset =-999;//units mm
102+
double VPTG2Offset =-999;//units mm
103103

104-
double TOR860_time = 0; // units s
104+
double TOR860_time = -999; // units s
105105

106-
double FOM =0;
106+
double FOM =-999;
107107

108108
// Here we request all the devices
109109
// since sometimes devices fail to report we'll
@@ -116,7 +116,7 @@ namespace sbn::pot{
116116
try{bfp->GetNamedData(time, "E:LM875B",&LM875B);}catch (WebAPIException &we) {mf::LogDebug("BNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
117117
try{bfp->GetNamedData(time, "E:LM875C",&LM875C);}catch (WebAPIException &we) {mf::LogDebug("BNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
118118
try{bfp->GetNamedData(time, "E:HP873",&HP873);}catch (WebAPIException &we) {mf::LogDebug("BNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
119-
try{bfp->GetNamedData(time, "E:VP873",&VP873);}catch (WebAPIException &we) {mf::LogDebug("BNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
119+
try{vp873->GetNamedData(time, "E:VP873",&VP873);}catch (WebAPIException &we) {mf::LogDebug("BNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
120120
try{bfp->GetNamedData(time, "E:HP875",&HP875);}catch (WebAPIException &we) {mf::LogDebug("BNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
121121
try{bfp->GetNamedData(time, "E:VP875",&VP875);}catch (WebAPIException &we) {mf::LogDebug("BNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
122122
try{bfp->GetNamedData(time, "E:HPTG1",&HPTG1);}catch (WebAPIException &we) {mf::LogDebug("BNBRetriever")<< "At time : " << time << " " << "got exception: " << we.what() << "\n";}
@@ -231,21 +231,21 @@ namespace sbn::pot{
231231

232232
bool BrokenClock(double time, std::unique_ptr<ifbeam_ns::BeamFolder> const& bfp)
233233
{
234-
double TOR860 = 0; // units e12 protons
235-
double TOR875 = 0; // units e12 protons
236-
double LM875A = 0; // units R/s
237-
double LM875B = 0; // units R/s
238-
double LM875C = 0; // units R/s
239-
double HP875 = 0; // units mm
240-
double VP875 = 0; // units mm
241-
double HPTG1 = 0; // units mm
242-
double VPTG1 = 0; // units mm
243-
double HPTG2 = 0; // units mm
244-
double VPTG2 = 0; // units mm
245-
double BTJT2 = 0; // units Deg C
246-
double THCURR = 0; // units kiloAmps
234+
double TOR860 = -999; // units e12 protons
235+
double TOR875 = -999; // units e12 protons
236+
double LM875A = -999; // units R/s
237+
double LM875B = -999; // units R/s
238+
double LM875C = -999; // units R/s
239+
double HP875 = -999; // units mm
240+
double VP875 = -999; // units mm
241+
double HPTG1 = -999; // units mm
242+
double VPTG1 = -999; // units mm
243+
double HPTG2 = -999; // units mm
244+
double VPTG2 = -999; // units mm
245+
double BTJT2 = -999; // units Deg C
246+
double THCURR = -999; // units kiloAmps
247247

248-
double TOR860_time = 0; // units s
248+
double TOR860_time = -999; // units s
249249

250250
// Here we request all the devices
251251
// since sometimes devices fail to report we'll

sbncode/BeamSpillInfoRetriever/SBNDBNBRetriever/SBNDBNBRetriever_module.cc

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

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

7676
}
7777

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/CAFMaker/CAFMakerParams.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,12 @@ namespace caf
369369
"" // sbnd
370370
};
371371

372+
Atom<string> SBNDSoftwareTriggerLabel{
373+
Name("SBNDSoftwareTriggerLabel"),
374+
Comment("Label for software trigger producer"),
375+
"" // sbnd
376+
};
377+
372378
Atom<string> CRTPMTLabel {
373379
Name("CRTPMTLabel"),
374380
Comment("Label for the CRTPMT Matched variables from the crtpmt data product"),

sbncode/CAFMaker/CAFMaker_module.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,8 @@ void CAFMaker::produce(art::Event& evt) noexcept {
17031703
caf::SRTrigger srtrigger;
17041704
if (isValidTrigger) {
17051705
FillTrigger(*extratrig_handle, trig_handle->at(0), srtrigger, triggerShift);
1706+
if (fDet == kICARUS)
1707+
FillTriggerICARUS(*extratrig_handle, srtrigger);
17061708
}
17071709
// Fill trigger emulation information
17081710
if (isValidEmulationTrigger) {
@@ -1739,6 +1741,7 @@ void CAFMaker::produce(art::Event& evt) noexcept {
17391741
caf::SRSBNDCRTVeto srsbndcrtveto;
17401742
caf::SRSBNDFrameShiftInfo srsbndframeshiftinfo;
17411743
caf::SRSBNDTimingInfo srsbndtiminginfo;
1744+
caf::SRSoftwareTrigger srsbndsofttrig;
17421745

17431746
// Mapping of (feb, channel) to truth information (AuxDetSimChannel) -- filled for ICARUS
17441747
std::map<std::pair<int, int>, sim::AuxDetSimChannel> crtsimchanmap;
@@ -1841,6 +1844,15 @@ void CAFMaker::produce(art::Event& evt) noexcept {
18411844
sbnd::timing::TimingInfo const& sbndtiminginfo(*sbndtiminginfo_handle);
18421845
FillSBNDTimingInfo(sbndtiminginfo, srsbndtiminginfo);
18431846
}
1847+
1848+
art::Handle<std::vector<sbnd::trigger::pmtSoftwareTrigger>> sbndsofttrig_handle;
1849+
GetByLabelStrict(evt, fParams.SBNDSoftwareTriggerLabel(), sbndsofttrig_handle);
1850+
if (sbndsofttrig_handle.isValid()){
1851+
const std::vector<sbnd::trigger::pmtSoftwareTrigger> &sbndsofttrig = *sbndsofttrig_handle;
1852+
if (sbndsofttrig.size()==1){
1853+
FillSoftwareTriggerSBND(sbndsofttrig.at(0), srsbndsofttrig);
1854+
}
1855+
}
18441856
}
18451857

18461858
// Get all of the CRTPMT Matches
@@ -2530,7 +2542,7 @@ void CAFMaker::produce(art::Event& evt) noexcept {
25302542
assert(thisShower.size() == 1);
25312543

25322544
SRShower& shw = pfp.shw;
2533-
FillShowerVars(*thisShower[0], vertex, fmShowerHit.at(iPart), wireReadout, producer, shw);
2545+
FillShowerVars(*thisShower[0], vertex, fmShowerHit.at(iPart), wireReadout, producer, shw, fDet);
25342546

25352547
// We may have many residuals per shower depending on how many showers ar in the slice
25362548
if (fmShowerRazzle.isValid() && fmShowerRazzle.at(iPart).size()==1) {
@@ -2595,6 +2607,7 @@ void CAFMaker::produce(art::Event& evt) noexcept {
25952607
rec.nopflashes = srflashes.size();
25962608
rec.sbnd_frames = srsbndframeshiftinfo;
25972609
rec.sbnd_timings = srsbndtiminginfo;
2610+
rec.soft_trig = srsbndsofttrig;
25982611

25992612
if (fParams.FillTrueParticles()) {
26002613
rec.true_particles = true_particles;

sbncode/CAFMaker/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ art_make_library( LIBRARY_NAME sbncode_CAFMaker
4343
art::Framework_Services_System_TriggerNamesService_service
4444
sbncode_Metadata_MetadataSBN_service
4545
larsim::Utils
46-
larevt::SpaceCharge
46+
larevt::SpaceCharge
4747
systematicstools::interface
4848
systematicstools::interpreters
4949
systematicstools::utility
5050
${GENIE_LIB_LIST}
5151
nugen::EventGeneratorBase_GENIE
52+
sbndaq_artdaq_core::sbndaq-artdaq-core_Obj_SBND
5253
)
5354

5455
cet_build_plugin ( CAFMaker art::module

sbncode/CAFMaker/FillExposure.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace caf
2626
single_store.FOM = info.FOM;
2727
single_store.VP873 = info.VP873;
2828
single_store.VP875Offset = info.VP875Offset;
29+
single_store.VP873Offset = info.VP873Offset;
2930
single_store.HP875Offset = info.HP875Offset;
3031
single_store.VPTG1Offset = info.VPTG1Offset;
3132
single_store.HPTG1Offset = info.HPTG1Offset;

sbncode/CAFMaker/FillReco.cxx

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ namespace caf
391391
const geo::WireReadoutGeom& wireReadout,
392392
unsigned producer,
393393
caf::SRShower &srshower,
394+
Det_t det,
394395
bool allowEmpty)
395396
{
396397

@@ -411,11 +412,56 @@ namespace caf
411412
// It's sth like this but not quite. And will need to pass a simb::MCtruth object vtx position anyway.
412413
// srshower.conversion_gap = (shower.ShowerStart() - vertex.Position()).Mag();
413414

414-
if(shower.best_plane() != -999){
415-
srshower.bestplane = shower.best_plane();
416-
srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx;
417-
srshower.bestplane_energy = srshower.plane[shower.best_plane()].energy;
418-
}
415+
for(int p = 0; p < 3; ++p) srshower.plane[p].nHits = 0;
416+
for (auto const& hit:hits) ++srshower.plane[hit->WireID().Plane].nHits;
417+
418+
if(det == kSBND)
419+
{
420+
int bestplane_for_energy = -999;
421+
int mosthits = -1;
422+
for(int p = 0; p < 3; ++p)
423+
{
424+
if((int)srshower.plane[p].nHits > mosthits)
425+
{
426+
mosthits = srshower.plane[p].nHits;
427+
bestplane_for_energy = p;
428+
}
429+
}
430+
431+
if(bestplane_for_energy != -999)
432+
{
433+
srshower.bestplane_for_energy = bestplane_for_energy;
434+
srshower.bestplane_energy = srshower.plane[bestplane_for_energy].energy;
435+
}
436+
437+
if(shower.best_plane() != -999 && srshower.plane[shower.best_plane()].dEdx != -999)
438+
{
439+
srshower.bestplane_for_dedx = shower.best_plane();
440+
srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx;
441+
}
442+
else
443+
{
444+
for(int p = 2; p >= 0; --p)
445+
{
446+
if(srshower.plane[p].dEdx != -999)
447+
{
448+
srshower.bestplane_for_dedx = p;
449+
srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx;
450+
break;
451+
}
452+
}
453+
}
454+
}
455+
else
456+
{
457+
if(shower.best_plane() != -999)
458+
{
459+
srshower.bestplane_for_energy = shower.best_plane();
460+
srshower.bestplane_for_dedx = shower.best_plane();
461+
srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx;
462+
srshower.bestplane_energy = srshower.plane[shower.best_plane()].energy;
463+
}
464+
}
419465

420466
if(shower.has_open_angle())
421467
srshower.open_angle = shower.OpenAngle();
@@ -438,9 +484,6 @@ namespace caf
438484
srshower.end = shower.ShowerStart()+ (shower.Length() * shower.Direction());
439485
}
440486

441-
for(int p = 0; p < 3; ++p) srshower.plane[p].nHits = 0;
442-
for (auto const& hit:hits) ++srshower.plane[hit->WireID().Plane].nHits;
443-
444487
for (geo::PlaneGeo const& plane: wireReadout.Iterate<geo::PlaneGeo>()) {
445488

446489
const double angleToVert(wireReadout.WireAngleToVertical(plane.View(), plane.ID()) - 0.5*M_PI);

sbncode/CAFMaker/FillReco.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ namespace caf
7070
const geo::WireReadoutGeom& wireReadout,
7171
unsigned producer,
7272
caf::SRShower& srshower,
73+
Det_t det,
7374
bool allowEmpty = false);
7475

7576
void FillShowerRazzle(const art::Ptr<sbn::MVAPID> razzle,

sbncode/CAFMaker/FillTrigger.cxx

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,16 @@
44
namespace caf
55
{
66
void FillTrigger(const sbn::ExtraTriggerInfo& addltrig_info,
7-
const raw::Trigger& trig,
8-
caf::SRTrigger& triggerInfo,
9-
const double time_offset = 0.0)
7+
const raw::Trigger& trig,
8+
caf::SRTrigger& triggerInfo,
9+
const double time_offset = 0.0)
1010
{
1111
triggerInfo.global_trigger_time = addltrig_info.triggerTimestamp;
1212
triggerInfo.beam_gate_time_abs = addltrig_info.beamGateTimestamp;
1313
triggerInfo.beam_gate_det_time = trig.BeamGateTime() + time_offset;
1414
triggerInfo.global_trigger_det_time = trig.TriggerTime() + time_offset;
15-
std::cout << "Gen triggerInfo.global_trigger_det_time: " << triggerInfo.global_trigger_det_time << std::endl;
16-
std::cout << "Gen triggerInfo.beam_gate_det_time: " << triggerInfo.beam_gate_det_time << std::endl;
1715
double diff_ts = triggerInfo.global_trigger_det_time - triggerInfo.beam_gate_det_time;
18-
std::cout << "diff_ts: " << diff_ts << std::endl;
1916
triggerInfo.trigger_within_gate = diff_ts;
20-
2117
triggerInfo.prev_global_trigger_time = addltrig_info.previousTriggerTimestamp;
2218
triggerInfo.source_type = sbn::bits::value(addltrig_info.sourceType);
2319
triggerInfo.trigger_type = sbn::bits::value(addltrig_info.triggerType);
@@ -29,23 +25,34 @@ namespace caf
2925

3026
}
3127

32-
void FillTriggerMC(double absolute_time, caf::SRTrigger& triggerInfo) {
28+
void FillTriggerMC(double absolute_time, caf::SRTrigger& triggerInfo)
29+
{
3330
triggerInfo.global_trigger_time = absolute_time;
3431
triggerInfo.beam_gate_time_abs = absolute_time;
32+
triggerInfo.trigger_within_gate = 0.; // Set this to 0 since the "MC" trigger is (for now) always at the spill time
33+
}
3534

36-
// Set this to 0 since the "MC" trigger is (for now) always at the spill time
37-
triggerInfo.trigger_within_gate = 0.;
35+
void FillTriggerICARUS(const sbn::ExtraTriggerInfo& addltrig_info,
36+
caf::SRTrigger& triggerInfo)
37+
{
38+
// Choose the cryostat that triggered first (if both are available)
39+
int const cryo = addltrig_info.cryostats[sbn::ExtraTriggerInfo::EastCryostat].beamToTrigger < addltrig_info.cryostats[sbn::ExtraTriggerInfo::WestCryostat].beamToTrigger
40+
? sbn::ExtraTriggerInfo::EastCryostat
41+
: sbn::ExtraTriggerInfo::WestCryostat;
3842

43+
sbn::ExtraTriggerInfo::CryostatInfo const& cryoInfo = addltrig_info.cryostats[cryo];
44+
if (cryoInfo.hasTrigger()) {
45+
triggerInfo.trigger_cryo_source = cryo;
46+
triggerInfo.trigger_logic_bits = cryoInfo.triggerLogicBits;
47+
triggerInfo.gate_to_trigger_time = static_cast<float>(cryoInfo.beamToTrigger) / 1000.0f; // [us]
48+
}
3949
}
4050

4151
void FillTriggerSBND(caf::SRSBNDTimingInfo& timingInfo, caf::SRTrigger& triggerInfo){
4252

4353
triggerInfo.global_trigger_time = timingInfo.hltEtrig;
4454
triggerInfo.beam_gate_time_abs = timingInfo.hltBeamGate;
45-
std::cout << "triggerInfo.global_trigger_det_time: " << triggerInfo.global_trigger_det_time << std::endl;
46-
std::cout << "triggerInfo.beam_gate_det_time: " << triggerInfo.beam_gate_det_time << std::endl;
4755
double diff_ts = triggerInfo.global_trigger_det_time - triggerInfo.beam_gate_det_time;
48-
std::cout << "diff_ts: " << diff_ts << std::endl;
4956
triggerInfo.trigger_within_gate = diff_ts;
5057
}
5158

@@ -59,7 +66,11 @@ namespace caf
5966
triggerInfo.monpulse_sizes = *monpulseSizes;
6067
triggerInfo.num_pairs_over_threshold = *numPairs;
6168
triggerInfo.passed_trigger = *passedTrig;
62-
6369
}
6470

71+
void FillSoftwareTriggerSBND(const sbnd::trigger::pmtSoftwareTrigger& softInfo, caf::SRSoftwareTrigger& caf_softInfo){
72+
caf_softInfo.npmts = softInfo.nAboveThreshold;
73+
caf_softInfo.flash_peakpe = softInfo.peakPE;
74+
caf_softInfo.flash_peaktime = softInfo.peaktime + softInfo.trig_ts*1e-3;
75+
}
6576
}

0 commit comments

Comments
 (0)