Skip to content

Commit 5f31751

Browse files
authored
Merge pull request #534 from SBNSoftware/feature/acastill_sbnd_opflash_caf
Save OpFlash information in CAF files in SBND.
2 parents ec69666 + 31c8c3c commit 5f31751

3 files changed

Lines changed: 83 additions & 17 deletions

File tree

sbncode/CAFMaker/CAFMaker_module.cc

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,26 +1664,50 @@ void CAFMaker::produce(art::Event& evt) noexcept {
16641664

16651665
// Get all of the OpFlashes
16661666
std::vector<caf::SROpFlash> srflashes;
1667+
if(fDet == kICARUS)
1668+
{
1669+
for (const std::string& pandora_tag_suffix : pandora_tag_suffixes) {
1670+
art::Handle<std::vector<recob::OpFlash>> flashes_handle;
1671+
GetByLabelStrict(evt, fParams.OpFlashLabel() + pandora_tag_suffix, flashes_handle);
1672+
// fill into event
1673+
if (flashes_handle.isValid()) {
1674+
const std::vector<recob::OpFlash> &opflashes = *flashes_handle;
1675+
int cryostat = ( pandora_tag_suffix.find("W") != std::string::npos ) ? 1 : 0;
16671676

1668-
for (const std::string& pandora_tag_suffix : pandora_tag_suffixes) {
1669-
art::Handle<std::vector<recob::OpFlash>> flashes_handle;
1670-
GetByLabelStrict(evt, fParams.OpFlashLabel() + pandora_tag_suffix, flashes_handle);
1671-
// fill into event
1672-
if (flashes_handle.isValid()) {
1673-
const std::vector<recob::OpFlash> &opflashes = *flashes_handle;
1674-
int cryostat = ( pandora_tag_suffix.find("W") != std::string::npos ) ? 1 : 0;
1677+
// get associated OpHits for each OpFlash
1678+
art::FindMany<recob::OpHit> findManyHits(flashes_handle, evt, fParams.OpFlashLabel() + pandora_tag_suffix);
16751679

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

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

1682-
std::vector<recob::OpHit const*> const& ophits = findManyHits.at(iflash);
1685+
srflashes.emplace_back();
1686+
FillICARUSOpFlash(flash, ophits, cryostat, srflashes.back());
1687+
iflash++;
1688+
}
1689+
}
1690+
}
1691+
}
1692+
else if(fDet == kSBND)
1693+
{
1694+
std::vector<std::string> tpc_suffixes_sbnd = {"tpc0", "tpc1"};
16831695

1684-
srflashes.emplace_back();
1685-
FillOpFlash(flash, ophits, cryostat, srflashes.back());
1686-
iflash++;
1696+
for (size_t tpc=0; tpc<tpc_suffixes_sbnd.size(); tpc++) {
1697+
art::Handle<std::vector<recob::OpFlash>> flashes_handle;
1698+
GetByLabelStrict(evt, fParams.OpFlashLabel() + tpc_suffixes_sbnd[tpc], flashes_handle);
1699+
// fill into event
1700+
if (flashes_handle.isValid()) {
1701+
const std::vector<recob::OpFlash> &opflashes = *flashes_handle;
1702+
// get associated OpHits for each OpFlash
1703+
art::FindMany<recob::OpHit> findManyHits(flashes_handle, evt, fParams.OpFlashLabel() + tpc_suffixes_sbnd[tpc]);
1704+
int iflash=0;
1705+
for (const recob::OpFlash& flash : opflashes) {
1706+
std::vector<recob::OpHit const*> const& ophits = findManyHits.at(iflash);
1707+
srflashes.emplace_back();
1708+
FillSBNDOpFlash(flash, ophits, tpc, srflashes.back());
1709+
iflash++;
1710+
}
16871711
}
16881712
}
16891713
}

sbncode/CAFMaker/FillReco.cxx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ namespace caf
179179
}
180180

181181

182-
void FillOpFlash(const recob::OpFlash &flash,
182+
void FillICARUSOpFlash(const recob::OpFlash &flash,
183183
std::vector<recob::OpHit const*> const& hits,
184184
int cryo,
185185
caf::SROpFlash &srflash,
@@ -227,6 +227,41 @@ namespace caf
227227
}
228228
}
229229

230+
void FillSBNDOpFlash(const recob::OpFlash &flash,
231+
std::vector<recob::OpHit const*> const& hits,
232+
int tpc,
233+
caf::SROpFlash &srflash,
234+
bool allowEmpty) {
235+
236+
srflash.setDefault();
237+
238+
srflash.time = flash.Time();
239+
srflash.timewidth = flash.TimeWidth();
240+
241+
double firstTime = std::numeric_limits<double>::max();
242+
for(const auto& hit: hits){
243+
double const hitTime = hit->HasStartTime()? hit->StartTime(): hit->PeakTime();
244+
if (firstTime > hitTime)
245+
firstTime = hitTime;
246+
}
247+
srflash.firsttime = firstTime;
248+
srflash.tpc = tpc;
249+
250+
srflash.totalpe = flash.TotalPE();
251+
srflash.fasttototal = flash.FastToTotal();
252+
srflash.onbeamtime = flash.OnBeamTime();
253+
254+
srflash.center.SetXYZ( -9999.f, flash.YCenter(), flash.ZCenter() );
255+
srflash.width.SetXYZ( -9999.f, flash.YWidth(), flash.ZWidth() );
256+
257+
// Checks if ( recob::OpFlash.XCenter() != std::numeric_limits<double>::max() )
258+
// See LArSoft OpFlash.h at https://nusoft.fnal.gov/larsoft/doxsvn/html/OpFlash_8h_source.html
259+
if ( flash.hasXCenter() ) {
260+
srflash.center.SetX( flash.XCenter() );
261+
srflash.width.SetX( flash.XWidth() );
262+
}
263+
}
264+
230265
std::vector<float> double_to_float_vector(const std::vector<double>& v)
231266
{
232267
std::vector<float> ret;

sbncode/CAFMaker/FillReco.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,18 @@ namespace caf
217217
caf::SRSBNDCRTTrack &srsbndcrttrack,
218218
bool allowEmpty = false);
219219

220-
void FillOpFlash(const recob::OpFlash &flash,
220+
void FillICARUSOpFlash(const recob::OpFlash &flash,
221221
std::vector<recob::OpHit const*> const& hits,
222222
int cryo,
223223
caf::SROpFlash &srflash,
224224
bool allowEmpty = false);
225+
226+
void FillSBNDOpFlash(const recob::OpFlash &flash,
227+
std::vector<recob::OpHit const*> const& hits,
228+
int tpc,
229+
caf::SROpFlash &srflash,
230+
bool allowEmpty = false);
231+
225232
void FillCRTPMTMatch(const sbn::crt::CRTPMTMatching &match,
226233
caf::SRCRTPMTMatch &srmatch,
227234
bool allowEmpty = false);

0 commit comments

Comments
 (0)