Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions sbncode/CAFMaker/CAFMakerParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,18 @@ namespace caf
"crttracks" // sbnd
};

Atom<string> SBNDFrameShiftInfoLabel {
Name("SBNDFrameShiftInfoLabel"),
Comment("Label of sbnd frame shift."),
"frameshift" // sbnd
};

Atom<string> SBNDTimingInfoLabel {
Name("SBNDTimingInfoLabel"),
Comment("Label of sbnd timing shift."),
"frameshift" // sbnd
};

Atom<string> CRTPMTLabel {
Name("CRTPMTLabel"),
Comment("Label for the CRTPMT Matched variables from the crtpmt data product"),
Expand Down
76 changes: 75 additions & 1 deletion sbncode/CAFMaker/CAFMaker_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
#include "sbnobj/Common/Trigger/ExtraTriggerInfo.h"
#include "sbnobj/Common/Reco/CRUMBSResult.h"
#include "sbnobj/Common/Reco/OpT0FinderResult.h"
#include "sbnobj/SBND/Timing/TimingInfo.hh"
#include "sbnobj/SBND/Timing/FrameShiftInfo.hh"

// GENIE
#include "Framework/EventGen/EventRecord.h"
Expand Down Expand Up @@ -316,6 +318,9 @@ class CAFMaker : public art::EDProducer {
void FixPMTReferenceTimes(StandardRecord &rec, double PMT_reference_time);
void FixCRTReferenceTimes(StandardRecord &rec, double CRTT0_reference_time, double CRTT1_reference_time);

void SBNDShiftCRTReference(StandardRecord &rec, double SBNDFrame);
void SBNDShiftPMTReference(StandardRecord &rec, double SBNDFrame);

/// Equivalent of FindManyP except a return that is !isValid() prints a
/// messsage and aborts if StrictMode is true.
template <class T, class U>
Expand Down Expand Up @@ -499,6 +504,41 @@ void CAFMaker::BlindEnergyParameters(StandardRecord* brec) {
}
}

void CAFMaker::SBNDShiftCRTReference(StandardRecord &rec, double SBNDFrame){

//CRT Space Point
for (SRCRTSpacePoint &sp: rec.crt_spacepoints){
sp.time += SBNDFrame; //ns
}

//CRT Track
for (SRSBNDCRTTrack &trk: rec.sbnd_crt_tracks){
trk.time += SBNDFrame; //ns
}

//TODO: CRT Space Point and Track Match
//for (SRPFP &pfp: rec.reco.pfp) {
// pfp.trk.crtspacepoint.spacepoint.time += SBNDFrame;
// pfp.trk.crtsbndtrack.track.time += SBNDFrame;
//}
}

void CAFMaker::SBNDShiftPMTReference(StandardRecord &rec, double SBNDFrame){
Comment thread
VCLanNguyen marked this conversation as resolved.
Outdated

double SBNDFrame_us = SBNDFrame / 1000.0; //convert ns to us

//Op Flash
for (SROpFlash &opf: rec.opflashes) {
opf.time += SBNDFrame_us;
opf.firsttime += SBNDFrame_us;
}
Comment thread
VCLanNguyen marked this conversation as resolved.

//OpT0 match to slice
for (SRSlice &s: rec.slc) {
s.opt0.time += SBNDFrame_us;
}
}

void CAFMaker::FixPMTReferenceTimes(StandardRecord &rec, double PMT_reference_time) {
// Fix the flashes
for (SROpFlash &f: rec.opflashes) {
Expand Down Expand Up @@ -1602,6 +1642,8 @@ void CAFMaker::produce(art::Event& evt) noexcept {
std::vector<caf::SRCRTTrack> srcrttracks;
std::vector<caf::SRCRTSpacePoint> srcrtspacepoints;
std::vector<caf::SRSBNDCRTTrack> srsbndcrttracks;
caf::SRSBNDFrameShiftInfo srsbndframeshiftinfo;
caf::SRSBNDTimingInfo srsbndtiminginfo;

if(fDet == kICARUS)
{
Expand Down Expand Up @@ -1650,6 +1692,22 @@ void CAFMaker::produce(art::Event& evt) noexcept {
FillSBNDCRTTrack(sbndcrttracks[i], srsbndcrttracks.back());
}
}

art::Handle<sbnd::timing::FrameShiftInfo> sbndframeshiftinfo_handle;
GetByLabelStrict(evt, fParams.SBNDFrameShiftInfoLabel(), sbndframeshiftinfo_handle);
// fill into event
if (sbndframeshiftinfo_handle.isValid()) {
sbnd::timing::FrameShiftInfo const& sbndframeshiftinfo(*sbndframeshiftinfo_handle);
FillSBNDFrameShiftInfo(sbndframeshiftinfo, srsbndframeshiftinfo);
}

art::Handle<sbnd::timing::TimingInfo> sbndtiminginfo_handle;
GetByLabelStrict(evt, fParams.SBNDTimingInfoLabel(), sbndtiminginfo_handle);
// fill into event
if (sbndtiminginfo_handle.isValid()) {
sbnd::timing::TimingInfo const& sbndtiminginfo(*sbndtiminginfo_handle);
FillSBNDTimingInfo(sbndtiminginfo, srsbndtiminginfo);
}
}

// Get all of the CRTPMT Matches
Expand Down Expand Up @@ -2367,14 +2425,17 @@ void CAFMaker::produce(art::Event& evt) noexcept {
rec.nsbnd_crt_tracks = srsbndcrttracks.size();
rec.opflashes = srflashes;
rec.nopflashes = srflashes.size();
rec.sbnd_frames = srsbndframeshiftinfo;
rec.sbnd_timings = srsbndtiminginfo;
Comment thread
VCLanNguyen marked this conversation as resolved.
Outdated

if (fParams.FillTrueParticles()) {
rec.true_particles = true_particles;
}
rec.ntrue_particles = true_particles.size();
rec.crtpmt_matches = srcrtpmtmatches;
rec.ncrtpmt_matches = srcrtpmtmatches.size();

// Fix the Reference time
// ICARUS: Fix the Reference time
Comment thread
VCLanNguyen marked this conversation as resolved.
Outdated
//
// We want MC and Data to have the same reference time.
// In MC/LArSoft the "reference time" is canonically defined
Expand Down Expand Up @@ -2406,6 +2467,19 @@ void CAFMaker::produce(art::Event& evt) noexcept {
FixPMTReferenceTimes(rec, PMT_reference_time);

// TODO: TPC?

// SBND: Fix the Reference time in data depending on the stream (See FrameShift module on sbndcode repo)
if (isRealData & (fDet == kSBND))
Comment thread
VCLanNguyen marked this conversation as resolved.
Outdated
{
mf::LogInfo("CAFMaker") << "Setting Reference Timing for timing object in SBND \n"
<< " Shift Apply At Caf Level = " << rec.sbnd_frames.frameApplyAtCaf << " ns\n";

//shift reference frame for CRT objects: crt trk, crt sp, crt sp match, crt trk match
SBNDShiftCRTReference(rec, rec.sbnd_frames.frameApplyAtCaf);

//shift reference frame for PMT objects: opflash, opt0
SBNDShiftPMTReference(rec, rec.sbnd_frames.frameApplyAtCaf);
}

// Get metadata information for header
unsigned int run = evt.run();
Expand Down
1 change: 1 addition & 0 deletions sbncode/CAFMaker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ art_make_library( LIBRARY_NAME sbncode_CAFMaker
sbnobj::Common_Analysis
sbnobj::Common_PMT_Data
sbnobj::SBND_CRT
sbnobj::SBND_Timing
lardataalg::DetectorInfo
art::Framework_Services_System_TriggerNamesService_service
sbncode_Metadata_MetadataSBN_service
Expand Down
27 changes: 27 additions & 0 deletions sbncode/CAFMaker/FillReco.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,33 @@ namespace caf
srsbndcrttrack.tof = track.ToF();
}

void FillSBNDFrameShiftInfo(const sbnd::timing::FrameShiftInfo &frame,
caf::SRSBNDFrameShiftInfo &srsbndframe,
bool allowEmpty)
{
srsbndframe.timingType = frame.TimingType();
srsbndframe.frameTdcCrtt1 = frame.FrameTdcCrtt1();
srsbndframe.frameTdcBes = frame.FrameTdcBes();
srsbndframe.frameTdcRwm = frame.FrameTdcRwm();
srsbndframe.frameHltCrtt1 = frame.FrameHltCrtt1();
srsbndframe.frameHltBeamGate = frame.FrameHltBeamGate();
srsbndframe.frameApplyAtCaf = frame.FrameApplyAtCaf();
}

void FillSBNDTimingInfo(const sbnd::timing::TimingInfo &timing,
caf::SRSBNDTimingInfo &srsbndtiming,
bool allowEmpty)
{
srsbndtiming.rawDAQHeaderTimestamp = timing.RawDAQHeaderTimestamp();
srsbndtiming.tdcCrtt1 = timing.TdcCrtt1();
srsbndtiming.tdcBes = timing.TdcBes();
srsbndtiming.tdcRwm = timing.TdcRwm();
srsbndtiming.tdcEtrig = timing.TdcEtrig();
srsbndtiming.hltCrtt1 = timing.HltCrtt1();
srsbndtiming.hltEtrig = timing.HltEtrig();
srsbndtiming.hltBeamGate = timing.HltBeamGate();
}

void FillCRTPMTMatch(const sbn::crt::CRTPMTMatching &match,
caf::SRCRTPMTMatch &srmatch,
bool allowEmpty){
Expand Down
11 changes: 11 additions & 0 deletions sbncode/CAFMaker/FillReco.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#include "sbnobj/Common/CRT/CRTPMTMatching.hh"
#include "sbnobj/Common/CRT/CRTHitT0TaggingInfo.hh"
#include "sbnobj/Common/PMT/Data/PMTBeamSignal.hh"
#include "sbnobj/SBND/Timing/TimingInfo.hh"
#include "sbnobj/SBND/Timing/FrameShiftInfo.hh"

#include "nusimdata/SimulationBase/MCParticle.h"
#include "nusimdata/SimulationBase/MCTruth.h"

Expand Down Expand Up @@ -281,6 +284,14 @@ namespace caf
caf::SRPFP& srpfp,
bool allowEmpty = false);

void FillSBNDFrameShiftInfo(const sbnd::timing::FrameShiftInfo &frame,
caf::SRSBNDFrameShiftInfo &srsbndframe,
bool allowEmpty = false);

void FillSBNDTimingInfo(const sbnd::timing::TimingInfo &timing,
caf::SRSBNDTimingInfo &srsbndtiming,
bool allowEmpty = false);

template<class T, class U>
void CopyPropertyIfSet( const std::map<std::string, T>& props, const std::string& search, U& value );
}
Expand Down