Skip to content

Add PMT Beam Signal timing to ICARUS CAFs #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions sbncode/CAFMaker/CAFMakerParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,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
15 changes: 13 additions & 2 deletions sbncode/CAFMaker/CAFMaker_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1669,14 +1669,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 @@ -1686,7 +1690,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
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
5 changes: 5 additions & 0 deletions sbncode/CAFMaker/FillReco.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,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 +193,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
2 changes: 2 additions & 0 deletions sbncode/CAFMaker/FillReco.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#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"

Expand Down Expand Up @@ -256,6 +257,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 Down