Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
566dade
Update explicit references to 'EventWeightParameterSet::kMultisim'
kjplows Apr 10, 2025
a044228
read PMTBeamSignal into the CAFMaker to be passed to FillICARUSOpFlash
aheggest Jun 3, 2025
505cdc8
within FillICARUSOpFlash, reconstruct the flash time w.r.t. RWM time …
aheggest Jun 3, 2025
9aa0be9
remove cout statement
aheggest Jun 3, 2025
a492b43
remove startmap from SelectFirstOpHitByTime as it is not needed
aheggest Jun 5, 2025
0f63559
use GetByLabelIfExists for PMTBeamSignalLabel
aheggest Jun 5, 2025
f37272b
Update dependencies
kjplows Jul 30, 2025
f3dba86
Merge branch 'release/v10_06_00_04'
kjplows Jul 30, 2025
45b7e0c
Merge tag 'v10_06_00_04' into develop
kjplows Jul 30, 2025
aad2ae1
Merge branch 'develop' into feature/aheggest_RWMinCAF
kjplows Aug 9, 2025
8e4ab73
Merge pull request #541 from SBNSoftware/feature/aheggest_RWMinCAF
kjplows Aug 11, 2025
3146829
Merge branch 'develop' into bugfix/kplows_synchronise_ReweightType
kjplows Aug 11, 2025
5166730
Merge pull request #530 from SBNSoftware/bugfix/kplows_synchronise_Re…
kjplows Aug 11, 2025
f04aa0a
Updated dependencies
kjplows Aug 11, 2025
a18e296
Merge branch 'release/v10_09_00'
kjplows Aug 11, 2025
508e45f
Merge tag 'v10_09_00' into develop
kjplows Aug 11, 2025
f868720
first commit
VCLanNguyen Aug 13, 2025
b0dd48b
correct timing in Caf
VCLanNguyen Aug 26, 2025
4f49aba
add fixes
VCLanNguyen Aug 26, 2025
ce91916
undo frame shift for crt matched
VCLanNguyen Aug 28, 2025
844313c
Merge branch 'develop' into lnguyen/frame_shift_pr
VCLanNguyen Aug 28, 2025
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)

find_package(cetmodules 3.20.00 REQUIRED)
project(sbncode VERSION 10.06.00.03 LANGUAGES CXX)
project(sbncode VERSION 10.09.00 LANGUAGES CXX)

message(STATUS "\n\n ========================== ${PROJECT_NAME} ==========================")

Expand Down
18 changes: 18 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 Expand Up @@ -374,6 +386,12 @@ namespace caf
"OpFlash"
};

Atom<string> PMTBeamSignalLabel {
Name("PMTBeamSignalLabel"),
Comment("Label for special PMT beam timing signals used to build the beam bunch structure"),
"beamTiming:RWM"
};

Atom<long long> CRTSimT0Offset {
Name("CRTSimT0Offset"),
Comment("start of beam gate/simulation time in the simulated CRT clock"),
Expand Down
89 changes: 86 additions & 3 deletions sbncode/CAFMaker/CAFMaker_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,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 +502,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){

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;
}

//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 +1640,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 +1690,22 @@ void CAFMaker::produce(art::Event& evt) noexcept {
FillSBNDCRTTrack(sbndcrttracks[i], srsbndcrttracks.back());
}
}

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

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

// Get all of the CRTPMT Matches
Expand All @@ -1668,14 +1724,18 @@ void CAFMaker::produce(art::Event& evt) noexcept {
std::vector<caf::SROpFlash> srflashes;
if(fDet == kICARUS)
{
//Get all of the special PMT Beam Signals (to use as an opFlash reference time below)
art::Handle<std::vector<sbn::timing::PMTBeamSignal>> PMTBeamSignal_handle;
GetByLabelIfExists(evt, fParams.PMTBeamSignalLabel(), PMTBeamSignal_handle);

for (const std::string& pandora_tag_suffix : pandora_tag_suffixes) {
art::Handle<std::vector<recob::OpFlash>> flashes_handle;
GetByLabelStrict(evt, fParams.OpFlashLabel() + pandora_tag_suffix, flashes_handle);
// fill into event
if (flashes_handle.isValid()) {
const std::vector<recob::OpFlash> &opflashes = *flashes_handle;
int cryostat = ( pandora_tag_suffix.find("W") != std::string::npos ) ? 1 : 0;

// get associated OpHits for each OpFlash
art::FindMany<recob::OpHit> findManyHits(flashes_handle, evt, fParams.OpFlashLabel() + pandora_tag_suffix);

Expand All @@ -1685,7 +1745,14 @@ void CAFMaker::produce(art::Event& evt) noexcept {
std::vector<recob::OpHit const*> const& ophits = findManyHits.at(iflash);

srflashes.emplace_back();
FillICARUSOpFlash(flash, ophits, cryostat, srflashes.back());
if(PMTBeamSignal_handle.isValid() && isRealData){
const std::vector<sbn::timing::PMTBeamSignal> &pmtbeamsignals = *PMTBeamSignal_handle;
FillICARUSOpFlash(flash, ophits, cryostat, pmtbeamsignals, srflashes.back());
}
else{
const std::vector<sbn::timing::PMTBeamSignal> pmtbeamsignals;
FillICARUSOpFlash(flash, ophits, cryostat, pmtbeamsignals, srflashes.back());
}
iflash++;
}
}
Expand Down Expand Up @@ -2356,14 +2423,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;

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
//
// We want MC and Data to have the same reference time.
// In MC/LArSoft the "reference time" is canonically defined
Expand Down Expand Up @@ -2395,6 +2465,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))
{
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 @@ -35,6 +35,7 @@ art_make_library( LIBRARY_NAME sbncode_CAFMaker
sbnobj::Common_CRT
sbnobj::Common_Reco
sbnobj::Common_Analysis
sbnobj::Common_PMT_Data
sbnobj::SBND_CRT
lardataalg::DetectorInfo
art::Framework_Services_System_TriggerNamesService_service
Expand Down
32 changes: 32 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 raw::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 raw::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 Expand Up @@ -183,6 +210,7 @@ namespace caf
void FillICARUSOpFlash(const recob::OpFlash &flash,
std::vector<recob::OpHit const*> const& hits,
int cryo,
std::vector<sbn::timing::PMTBeamSignal> RWMTimes,
caf::SROpFlash &srflash,
bool allowEmpty) {

Expand All @@ -192,11 +220,15 @@ namespace caf
srflash.timewidth = flash.TimeWidth();

double firstTime = std::numeric_limits<double>::max();
std::map<int, double> risemap;
for(const auto& hit: hits){
double const hitTime = hit->HasStartTime()? hit->StartTime(): hit->PeakTime();
if (firstTime > hitTime)
firstTime = hitTime;
if (!RWMTimes.empty())
sbn::timing::SelectFirstOpHitByTime(hit,risemap);
}
srflash.rwmtime = getFlashBunchTime(risemap, RWMTimes);
srflash.firsttime = firstTime;

srflash.cryo = cryo; // 0 in SBND, 0/1 for E/W in ICARUS
Expand Down
11 changes: 11 additions & 0 deletions sbncode/CAFMaker/FillReco.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
#include "sbnobj/SBND/CRT/CRTTrack.hh"
#include "sbnobj/Common/CRT/CRTPMTMatching.hh"
#include "sbnobj/Common/CRT/CRTHitT0TaggingInfo.hh"
#include "sbnobj/Common/PMT/Data/PMTBeamSignal.hh"
#include "nusimdata/SimulationBase/MCParticle.h"
#include "nusimdata/SimulationBase/MCTruth.h"
#include "sbndcode/Timing/SBNDRawTimingObj.h"

#include "sbnanaobj/StandardRecord/SRSlice.h"
#include "sbnanaobj/StandardRecord/StandardRecord.h"
Expand Down Expand Up @@ -256,6 +258,7 @@ namespace caf
void FillICARUSOpFlash(const recob::OpFlash &flash,
std::vector<recob::OpHit const*> const& hits,
int cryo,
std::vector<sbn::timing::PMTBeamSignal> RWMTimes,
caf::SROpFlash &srflash,
bool allowEmpty = false);

Expand All @@ -279,6 +282,14 @@ namespace caf
caf::SRPFP& srpfp,
bool allowEmpty = false);

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

void FillSBNDTimingInfo(const raw::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
6 changes: 3 additions & 3 deletions sbncode/SBNEventWeight/Calculators/BNBFlux/FluxCalcPrep.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ namespace sbn {

//Let's make a weights based on the calculator you have requested

if(fParameterSet.fRWType == EventWeightParameterSet::kMultisim){
if(fParameterSet.fRWType == EventWeightParameterSet::kMultiSim){

for (size_t i=0;i<weights.size();i++) {
double randomN = (fParameterSet.fParameterMap.begin())->second[i];
Expand Down Expand Up @@ -293,7 +293,7 @@ namespace sbn {
return weights;//done, all 1
}// Hadronic parent check

if(fParameterSet.fRWType == EventWeightParameterSet::kMultisim){
if(fParameterSet.fRWType == EventWeightParameterSet::kMultiSim){

for (unsigned int i = 0; int(weights.size()) < NUni; i++) {//if all weights are 1, no need to calculate weights;
std::pair<bool, double> test_weight;
Expand Down Expand Up @@ -338,7 +338,7 @@ namespace sbn {
};

}//Iterate through the number of universes
}//Yes, Multisim
}//Yes, MultiSim
}

if(count_weights){
Expand Down
6 changes: 3 additions & 3 deletions ups/product_deps
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ libdir fq_dir lib
#
####################################
product version qual flags <table_format=2>
genie_xsec v3_04_00 -
genie_xsec v3_06_00 -
larcv2 v2_2_6 -
larsoft v10_06_00_01 -
sbnalg v10_06_00_03 -
larsoft v10_09_00 -
sbnalg v10_09_00 -
sbndaq_artdaq_core v1_10_06 -
sbndata v01_07 -
systematicstools v01_04_04 -
Expand Down