Skip to content

Commit b0dd48b

Browse files
committed
correct timing in Caf
1 parent f868720 commit b0dd48b

File tree

3 files changed

+68
-4
lines changed

3 files changed

+68
-4
lines changed

sbncode/CAFMaker/CAFMakerParams.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,13 @@ namespace caf
341341
Atom<string> SBNDFrameShiftInfoLabel {
342342
Name("SBNDFrameShiftInfoLabel"),
343343
Comment("Label of sbnd frame shift."),
344-
"reco1" // sbnd
344+
"framshift" // sbnd
345345
};
346346

347347
Atom<string> SBNDTimingInfoLabel {
348348
Name("SBNDTimingInfoLabel"),
349349
Comment("Label of sbnd timing shift."),
350-
"reco1" // sbnd
350+
"frameshift" // sbnd
351351
};
352352

353353
Atom<string> CRTPMTLabel {

sbncode/CAFMaker/CAFMaker_module.cc

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ class CAFMaker : public art::EDProducer {
316316
void FixPMTReferenceTimes(StandardRecord &rec, double PMT_reference_time);
317317
void FixCRTReferenceTimes(StandardRecord &rec, double CRTT0_reference_time, double CRTT1_reference_time);
318318

319+
void SBNDShiftCRTReference(StandardRecord &rec, double SBNDFrame);
320+
void SBNDShiftPMTReference(StandardRecord &rec, double SBNDFrame);
321+
319322
/// Equivalent of FindManyP except a return that is !isValid() prints a
320323
/// messsage and aborts if StrictMode is true.
321324
template <class T, class U>
@@ -499,6 +502,41 @@ void CAFMaker::BlindEnergyParameters(StandardRecord* brec) {
499502
}
500503
}
501504

505+
void CAFMaker::SBNDShiftCRTReference(StandardRecord &rec, double SBNDFrame){
506+
507+
//CRT Space Point
508+
for (SRCRTSpacePoint &sp: rec.crt_spacepoints){
509+
sp.time += SBNDFrame; //ns
510+
}
511+
512+
//CRT Track
513+
for (SRSBNDCRTTrack &trk: rec.sbnd_crt_tracks){
514+
trk.time += SBNDFrame; //ns
515+
}
516+
517+
//CRT Space Point and Track Match
518+
for (SRPFP &pfp: rec.reco.pfp) {
519+
pfp.trk.crtspacepoint.spacepoint.time += SBNDFrame;
520+
pfp.trk.crtsbndtrack.track.time += SBNDFrame;
521+
}
522+
}
523+
524+
void CAFMaker::SBNDShiftPMTReference(StandardRecord &rec, double SBNDFrame){
525+
526+
double SBNDFrame_us = SBNDFrame / 1000.0; //convert ns to us
527+
528+
//Op Flash
529+
for (SROpFlash &opf: rec.opflashes) {
530+
opf.time += SBNDFrame_us;
531+
opf.firsttime += SBNDFrame_us;
532+
}
533+
534+
//OpT0 match to slice
535+
for (SRSlice &s: rec.slc) {
536+
s.opt0.time += SBNDFrame_us;
537+
}
538+
}
539+
502540
void CAFMaker::FixPMTReferenceTimes(StandardRecord &rec, double PMT_reference_time) {
503541
// Fix the flashes
504542
for (SROpFlash &f: rec.opflashes) {
@@ -2382,14 +2420,19 @@ void CAFMaker::produce(art::Event& evt) noexcept {
23822420
rec.nsbnd_crt_tracks = srsbndcrttracks.size();
23832421
rec.opflashes = srflashes;
23842422
rec.nopflashes = srflashes.size();
2423+
rec.sbnd_frames = srsbndframeshiftinfo;
2424+
rec.nsbnd_frames = srsbndframeshiftinfo.size();
2425+
rec.sbnd_timings = srsbndtiminginfo;
2426+
rec.nsbnd_timings = srsbndtiminginfo.size();
2427+
23852428
if (fParams.FillTrueParticles()) {
23862429
rec.true_particles = true_particles;
23872430
}
23882431
rec.ntrue_particles = true_particles.size();
23892432
rec.crtpmt_matches = srcrtpmtmatches;
23902433
rec.ncrtpmt_matches = srcrtpmtmatches.size();
23912434

2392-
// Fix the Reference time
2435+
// ICARUS: Fix the Reference time
23932436
//
23942437
// We want MC and Data to have the same reference time.
23952438
// In MC/LArSoft the "reference time" is canonically defined
@@ -2421,6 +2464,26 @@ void CAFMaker::produce(art::Event& evt) noexcept {
24212464
FixPMTReferenceTimes(rec, PMT_reference_time);
24222465

24232466
// TODO: TPC?
2467+
2468+
// SBND: Fix the Reference time (See docdb# ????? and FrameShift module on sbndcode repo)
2469+
2470+
if (isRealData & (fDet == kSBND))
2471+
{
2472+
mf::LogInfo("CAFMaker") << "Setting Reference Timing for timing object in SBND" ;
2473+
2474+
//Should only be 1 set of frame per event, if not, something is really wrong and nothing should be corrected
2475+
if (rec.nsbnd_frames == 1)
2476+
{
2477+
SRSBNDFrameShiftInfo frame = rec.sbnd_frames.at(0);
2478+
2479+
//shift reference frame for CRT objects: crt trk, crt sp, crt sp match, crt trk match
2480+
SBNDShiftCRTReference(rec, frame.frameApplyAtCaf);
2481+
2482+
//shift reference frame for PMT objects: opflash, opt0
2483+
SBNDShiftPMTReference(rec, frame.frameApplyAtCaf);
2484+
}
2485+
2486+
}
24242487

24252488
// Get metadata information for header
24262489
unsigned int run = evt.run();

sbncode/CAFMaker/FillReco.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,13 @@ namespace caf
145145
caf::SRSBNDFrameShiftInfo &srsbndframe,
146146
bool allowEmpty)
147147
{
148+
srsbndframe.timingType = frame.timingType;
148149
srsbndframe.frameTdcCrtt1 = frame.frameTdcCrtt1;
149150
srsbndframe.frameTdcBes = frame.frameTdcBes;
150151
srsbndframe.frameTdcRwm = frame.frameTdcRwm;
151152
srsbndframe.frameHltCrtt1 = frame.frameHltCrtt1;
152153
srsbndframe.frameHltBeamGate = frame.frameHltBeamGate;
153-
srsbndframe.frameDataToMC = frame.frameDataToMC;
154+
srsbndframe.frameApplyAtCaf = frame.frameApplyAtCaf;
154155
}
155156

156157
void FillSBNDTimingInfo(const raw::TimingInfo &timing,

0 commit comments

Comments
 (0)