Skip to content
Merged
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
54 changes: 39 additions & 15 deletions sbncode/CAFMaker/CAFMaker_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1664,26 +1664,50 @@ void CAFMaker::produce(art::Event& evt) noexcept {

// Get all of the OpFlashes
std::vector<caf::SROpFlash> srflashes;
if(fDet == kICARUS)
{
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;

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

// get associated OpHits for each OpFlash
art::FindMany<recob::OpHit> findManyHits(flashes_handle, evt, fParams.OpFlashLabel() + pandora_tag_suffix);
int iflash=0;
for (const recob::OpFlash& flash : opflashes) {

int iflash=0;
for (const recob::OpFlash& flash : opflashes) {
std::vector<recob::OpHit const*> const& ophits = findManyHits.at(iflash);

std::vector<recob::OpHit const*> const& ophits = findManyHits.at(iflash);
srflashes.emplace_back();
FillICARUSOpFlash(flash, ophits, cryostat, srflashes.back());
iflash++;
}
}
}
}
else if(fDet == kSBND)
{
std::vector<std::string> tpc_suffixes_sbnd = {"tpc0", "tpc1"};

srflashes.emplace_back();
FillOpFlash(flash, ophits, cryostat, srflashes.back());
iflash++;
for (size_t tpc=0; tpc<tpc_suffixes_sbnd.size(); tpc++) {
art::Handle<std::vector<recob::OpFlash>> flashes_handle;
GetByLabelStrict(evt, fParams.OpFlashLabel() + tpc_suffixes_sbnd[tpc], flashes_handle);
// fill into event
if (flashes_handle.isValid()) {
const std::vector<recob::OpFlash> &opflashes = *flashes_handle;
// get associated OpHits for each OpFlash
art::FindMany<recob::OpHit> findManyHits(flashes_handle, evt, fParams.OpFlashLabel() + tpc_suffixes_sbnd[tpc]);
int iflash=0;
for (const recob::OpFlash& flash : opflashes) {
std::vector<recob::OpHit const*> const& ophits = findManyHits.at(iflash);
srflashes.emplace_back();
FillSBNDOpFlash(flash, ophits, tpc, srflashes.back());
iflash++;
}
}
}
}
Expand Down
37 changes: 36 additions & 1 deletion sbncode/CAFMaker/FillReco.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ namespace caf
}


void FillOpFlash(const recob::OpFlash &flash,
void FillICARUSOpFlash(const recob::OpFlash &flash,
std::vector<recob::OpHit const*> const& hits,
int cryo,
caf::SROpFlash &srflash,
Expand Down Expand Up @@ -227,6 +227,41 @@ namespace caf
}
}

void FillSBNDOpFlash(const recob::OpFlash &flash,
std::vector<recob::OpHit const*> const& hits,
int tpc,
caf::SROpFlash &srflash,
bool allowEmpty) {

srflash.setDefault();

srflash.time = flash.Time();
srflash.timewidth = flash.TimeWidth();

double firstTime = std::numeric_limits<double>::max();
for(const auto& hit: hits){
double const hitTime = hit->HasStartTime()? hit->StartTime(): hit->PeakTime();
if (firstTime > hitTime)
firstTime = hitTime;
}
srflash.firsttime = firstTime;
srflash.tpc = tpc;

srflash.totalpe = flash.TotalPE();
srflash.fasttototal = flash.FastToTotal();
srflash.onbeamtime = flash.OnBeamTime();

srflash.center.SetXYZ( -9999.f, flash.YCenter(), flash.ZCenter() );
srflash.width.SetXYZ( -9999.f, flash.YWidth(), flash.ZWidth() );

// Checks if ( recob::OpFlash.XCenter() != std::numeric_limits<double>::max() )
// See LArSoft OpFlash.h at https://nusoft.fnal.gov/larsoft/doxsvn/html/OpFlash_8h_source.html
if ( flash.hasXCenter() ) {
srflash.center.SetX( flash.XCenter() );
srflash.width.SetX( flash.XWidth() );
}
}

std::vector<float> double_to_float_vector(const std::vector<double>& v)
{
std::vector<float> ret;
Expand Down
9 changes: 8 additions & 1 deletion sbncode/CAFMaker/FillReco.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,18 @@ namespace caf
caf::SRSBNDCRTTrack &srsbndcrttrack,
bool allowEmpty = false);

void FillOpFlash(const recob::OpFlash &flash,
void FillICARUSOpFlash(const recob::OpFlash &flash,
std::vector<recob::OpHit const*> const& hits,
int cryo,
caf::SROpFlash &srflash,
bool allowEmpty = false);

void FillSBNDOpFlash(const recob::OpFlash &flash,
std::vector<recob::OpHit const*> const& hits,
int tpc,
caf::SROpFlash &srflash,
bool allowEmpty = false);

void FillCRTPMTMatch(const sbn::crt::CRTPMTMatching &match,
caf::SRCRTPMTMatch &srmatch,
bool allowEmpty = false);
Expand Down