Skip to content

Move PMTBeamSignal data product from icaruscode to sbnobj #832

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 10 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
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/**
* @file icaruscode/IcarusObj/PMTBeamSignal.h
* @file icaruscode/IcarusObj/Legacy/PMTBeamSignal.h
* @brief Holds the event-by-event RWM or EW times
* @author Matteo Vicenzi (mvicenzi@bnl.gov)
* @date March 14 2024
* @author Matteo Vicenzi (mvicenzi@bnl.gov), moved to legacy by A. Heggestuen
* @date March 14 2024, moved June 3, 2025
* @note PLEASE NOTE : This is an old/LEGACY header for the previous namespace.
@see sbnobj/Common/PMT/Data/PMTBeamSignal.hh for new/current data product.
*/

#ifndef ICARUSCODE_ICARUSOBJ_PMTBEAMSIGNAL_H
#define ICARUSCODE_ICARUSOBJ_PMTBEAMSIGNAL_H
#ifndef ICARUSCODE_ICARUSOBJ_LEGACY_PMTBEAMSIGNAL_H
#define ICARUSCODE_ICARUSOBJ_LEGACY_PMTBEAMSIGNAL_H

// C/C++ standard libraries
#include <limits>
Expand Down Expand Up @@ -66,4 +68,4 @@ namespace icarus::timing

} // namespace icarus::timing

#endif // ICARUSCODE_ICARUSOBJ_PMTBEAMSIGNAL_H
#endif // ICARUSCODE_ICARUSOBJ_LEGACY_PMTBEAMSIGNAL_H
2 changes: 1 addition & 1 deletion icaruscode/IcarusObj/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "icaruscode/IcarusObj/CRTTPCMatchingInfo.h"
#include "icaruscode/IcarusObj/OpDetWaveformMeta.h"
#include "icaruscode/IcarusObj/PMTWaveformTimeCorrection.h"
#include "icaruscode/IcarusObj/PMTBeamSignal.h"
#include "icaruscode/IcarusObj/Legacy/PMTBeamSignal.h"
#include "icaruscode/IcarusObj/Hit.h"
//#include "icaruscode/IcarusObj/CRTPMTMatching.h"

Expand Down
24 changes: 12 additions & 12 deletions icaruscode/PMT/OpReco/ICARUSBeamStructureAna_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "sbnobj/Common/Trigger/ExtraTriggerInfo.h"
#include "icaruscode/CRT/CRTUtils/CRTPMTMatchingUtils.h"
#include "sbnobj/Common/CRT/CRTPMTMatching.hh"
#include "icaruscode/IcarusObj/PMTBeamSignal.h"
#include "sbnobj/Common/PMT/Data/PMTBeamSignal.hh"

// ROOT libraries
#include "TTree.h"
Expand Down Expand Up @@ -156,7 +156,7 @@ class opana::ICARUSBeamStructureAna : public art::EDAnalyzer
std::vector<int> m_crtregion;

// RWM times
std::vector<icarus::timing::PMTBeamSignal> fRWMTimes;
std::vector<sbn::timing::PMTBeamSignal> fRWMTimes;
};

// --------------------------------------------------------------------------
Expand Down Expand Up @@ -289,9 +289,9 @@ void opana::ICARUSBeamStructureAna::analyze(art::Event const &e)
// ----
// RWM times

fRWMTimes = e.getProduct<std::vector<icarus::timing::PMTBeamSignal>>(fRWMLabel);
fRWMTimes = e.getProduct<std::vector<sbn::timing::PMTBeamSignal>>(fRWMLabel);
if (fRWMTimes.empty())
mf::LogTrace("ICARUSBeamStructureAna") << "Data product std::vector<icarus::timing::PMTBeamSignal> for '" << fRWMLabel.label()
mf::LogTrace("ICARUSBeamStructureAna") << "Data product std::vector<sbn::timing::PMTBeamSignal> for '" << fRWMLabel.label()
<< "' is empty in " << m_gate_name << " event!";

// ----
Expand Down Expand Up @@ -420,11 +420,11 @@ void opana::ICARUSBeamStructureAna::analyze(art::Event const &e)
m_hit_rise_time_rwm.push_back(getRWMRelativeTime(ch, risemap[ch]));
m_hit_pe.push_back(pemap[ch]);
}

// get the flash interaction time w.r.t. RWM
// this is currently the mean between the first ophits on opposite walls
m_flash_time_rwm = getFlashBunchTime(m_channel_id, m_hit_rise_time_rwm);

fOpFlashTrees[iFlashLabel]->Fill();

clear();
Expand Down Expand Up @@ -461,7 +461,7 @@ double opana::ICARUSBeamStructureAna::getRWMRelativeTime(int channel, double t)
{

if (fRWMTimes.empty())
return icarus::timing::NoTime;
return sbn::timing::NoTime;

auto rwm = fRWMTimes.at(channel);
if (!rwm.isValid())
Expand All @@ -470,7 +470,7 @@ double opana::ICARUSBeamStructureAna::getRWMRelativeTime(int channel, double t)
<< "(Crate " << rwm.crate << ", Board " << rwm.digitizerLabel
<< ", SpecialChannel " << rwm.specialChannel << ")"
<< " in event " << m_event << " gate " << m_gate_name;
return icarus::timing::NoTime;
return sbn::timing::NoTime;
}

double rwm_trigger = rwm.startTime; // rwm time w.r.t. trigger time [us]
Expand All @@ -486,9 +486,9 @@ double opana::ICARUSBeamStructureAna::getFlashBunchTime(std::vector<int> channel
double tfirst_right = std::numeric_limits<double>::max();

// if no RWM info available, all pmt_start_time_rwm are invalid
// return icarus::timing::NoTime as well for the flash
// return sbn::timing::NoTime as well for the flash
if (fRWMTimes.empty())
return icarus::timing::NoTime;
return sbn::timing::NoTime;

int nleft = 0;
int nright = 0;
Expand All @@ -501,9 +501,9 @@ double opana::ICARUSBeamStructureAna::getFlashBunchTime(std::vector<int> channel

// if any RWM copy is missing (therefore missing for an entire PMT crate),
// it might not be possible to use the first hits (they might not have a RMW time)
// so return icarus::timing::NoTime as in other bad cases
// so return sbn::timing::NoTime as in other bad cases
if (!fRWMTimes[i].isValid())
return icarus::timing::NoTime;
return sbn::timing::NoTime;

// count hits separetely on the two walls
if (side == 0)
Expand Down
22 changes: 11 additions & 11 deletions icaruscode/PMT/OpReco/ICARUSFlashAssAna_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "lardataobj/Simulation/BeamGateInfo.h"
#include "lardataobj/RawData/TriggerData.h"
#include "sbnobj/Common/Trigger/ExtraTriggerInfo.h"
#include "icaruscode/IcarusObj/PMTBeamSignal.h"
#include "sbnobj/Common/PMT/Data/PMTBeamSignal.hh"
#include "sbnobj/ICARUS/PMT/Data/WaveformBaseline.h"

#include "TTree.h"
Expand Down Expand Up @@ -102,7 +102,7 @@ class opana::ICARUSFlashAssAna : public art::EDAnalyzer

fhicl::Atom<art::InputTag> RWMLabel{
Name("RWMLabel"),
Comment("Tag for the RWM std::vector<icarus::timing::PMTBeamSignal> data product")};
Comment("Tag for the RWM std::vector<sbn::timing::PMTBeamSignal> data product")};

fhicl::Atom<float> PEOpHitThreshold{
Name("PEOpHitThreshold"),
Expand Down Expand Up @@ -251,7 +251,7 @@ class opana::ICARUSFlashAssAna : public art::EDAnalyzer

geo::GeometryCore const* fGeom;
geo::WireReadoutGeom const* fChannelMapAlg;
std::vector<icarus::timing::PMTBeamSignal> fRWMTimes;
std::vector<sbn::timing::PMTBeamSignal> fRWMTimes;
};

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -485,7 +485,7 @@ float opana::ICARUSFlashAssAna::getRWMRelativeTime(int channel, float t)
{

if (fRWMTimes.empty())
return icarus::timing::NoTime;
return sbn::timing::NoTime;

auto rwm = fRWMTimes.at(channel);
if (!rwm.isValid())
Expand All @@ -494,7 +494,7 @@ float opana::ICARUSFlashAssAna::getRWMRelativeTime(int channel, float t)
<< "(Crate " << rwm.crate << ", Board " << rwm.digitizerLabel
<< ", SpecialChannel " << rwm.specialChannel << ")"
<< " in event " << m_event << " gate " << m_gate_name;
return icarus::timing::NoTime;
return sbn::timing::NoTime;
}

float rwm_trigger = rwm.startTime; // rwm time w.r.t. trigger time [us]
Expand All @@ -511,9 +511,9 @@ float opana::ICARUSFlashAssAna::getFlashBunchTime(std::vector<double> pmt_start_
float tfirst_right = std::numeric_limits<float>::max();

// if no RWM info available, all pmt_start_time_rwm are invalid
// return icarus::timing::NoTime as well for the flash
// return sbn::timing::NoTime as well for the flash
if (fRWMTimes.empty())
return icarus::timing::NoTime;
return sbn::timing::NoTime;

int nleft = 0;
int nright = 0;
Expand All @@ -530,9 +530,9 @@ float opana::ICARUSFlashAssAna::getFlashBunchTime(std::vector<double> pmt_start_

// if any RWM copy is missing (therefore missing for an entire PMT crate),
// it might not be possible to use the first hits (they might not have a RMW time)
// so return icarus::timing::NoTime as in other bad cases
// so return sbn::timing::NoTime as in other bad cases
if (!fRWMTimes[i].isValid())
return icarus::timing::NoTime;
return sbn::timing::NoTime;

// count hits separetely on the two walls
if (side == 0)
Expand Down Expand Up @@ -768,9 +768,9 @@ void opana::ICARUSFlashAssAna::analyze(art::Event const &e)
if (!fRWMLabel.empty())
{

fRWMTimes = e.getProduct<std::vector<icarus::timing::PMTBeamSignal>>(fRWMLabel);
fRWMTimes = e.getProduct<std::vector<sbn::timing::PMTBeamSignal>>(fRWMLabel);
if (fRWMTimes.empty())
mf::LogTrace("ICARUSFlashAssAna") << "Data product std::vector<icarus::timing::PMTBeamSignal> for '"
mf::LogTrace("ICARUSFlashAssAna") << "Data product std::vector<sbn::timing::PMTBeamSignal> for '"
<< fRWMLabel.label() << "' is empty in " << m_gate_name << " event!";
}

Expand Down
2 changes: 2 additions & 0 deletions icaruscode/Timing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ cet_build_plugin( PMTTimingCorrectionService art::service LIBRARIES PUBLIC ${SER

cet_build_plugin( PMTBeamSignalsExtractor art::producer LIBRARIES PUBLIC ${MODULE_LIBRARIES})

cet_build_plugin( PMTBeamSignalNamespaceConverter art::producer LIBRARIES PUBLIC ${MODULE_LIBRARIES})

install_headers()
install_fhicl()
install_source()
113 changes: 113 additions & 0 deletions icaruscode/Timing/PMTBeamSignalNamespaceConverter_module.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
////////////////////////////////////////////////////////////////////////
// Class: PMTBeamSignalNameSpaceConverter_module
// Plugin Type: producer (Unknown Unknown)
// File: PMTBeamSignalNameSpaceConverter_module.cc
//
// Generated at Thu Jun 5 14:59:32 2025 by Anna Heggestuen using cetskelgen
// from cetlib version 3.18.02.
////////////////////////////////////////////////////////////////////////
#include "sbnobj/Common/PMT/Data/PMTBeamSignal.hh"
#include "icaruscode/IcarusObj/Legacy/PMTBeamSignal.h"

#include "art/Framework/Core/EDProducer.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/Handle.h"
#include "art/Framework/Principal/Run.h"
#include "art/Framework/Principal/SubRun.h"
#include "canvas/Utilities/InputTag.h"
#include "fhiclcpp/ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"

#include <memory>

namespace icarus::timing {
class PMTBeamSignalNamespaceConverter;
}
/**
* @brief Copy PMTBeamSignal data product from icaruscode/IcarusObj namespace to sbnobj/Common
*
* This producer module simply copies what is stored in the icaruscode/IcarusObj data product
* `std::vector<icarus::timing::PMTBeamSignal>` to a new sbnobj/Common data product
* `std::vector<sbn::timing::PMTBeamSignal>`. This is to help with backward compatibility for
* files that are produced with the `icarus::timing::PMTBeamSignal` data product. Converting
* the icarus::timing namespace to sbn::timing allows us to fill this variable in the CAFs.

* This module is set up to convert either the "RWM" or "EW" instance of the data product
* following what is set in the `SignalLabel` input parameter.
*
* Input parameters
* ------------------------
* * `SignalLabel` (input tag): tag for the "RWM" or "EW" instance of the
* std::vector<icarus::timing::PMTBeamSignal> data product.
*
* Output products
* -------------------------
* This module produces a `std::vector<sbn::timing::PMTBeamSignal>` with 360 elements
* representing the "RWM" or "EW" time for the corresponding PMT channel.
*
*/

class icarus::timing::PMTBeamSignalNamespaceConverter : public art::EDProducer {
public:
explicit PMTBeamSignalNamespaceConverter(fhicl::ParameterSet const& p);
// The compiler-generated destructor is fine for non-base
// classes without bare pointers or other resource use.

// Plugins should not be copied or assigned.
PMTBeamSignalNamespaceConverter(PMTBeamSignalNamespaceConverter const&) = delete;
PMTBeamSignalNamespaceConverter(PMTBeamSignalNamespaceConverter&&) = delete;
PMTBeamSignalNamespaceConverter& operator=(PMTBeamSignalNamespaceConverter const&) = delete;
PMTBeamSignalNamespaceConverter& operator=(PMTBeamSignalNamespaceConverter&&) = delete;

// Required functions.
void produce(art::Event& e) override;

private:

// RWM or EW waveform instance label from fcl
art::InputTag const fSignalLabel;

// Vector for input data product
std::vector<icarus::timing::PMTBeamSignal> fPMTBeamSignal;
};


icarus::timing::PMTBeamSignalNamespaceConverter::PMTBeamSignalNamespaceConverter(fhicl::ParameterSet const& p)
: EDProducer{p},
fSignalLabel(p.get<art::InputTag>("SignalLabel"))
{
// Call appropriate produces<>() functions here.
produces<std::vector<sbn::timing::PMTBeamSignal>>(fSignalLabel.instance());

// Call appropriate consumes<>() for any products to be retrieved by this module.
consumes<std::vector<icarus::timing::PMTBeamSignal>>(fSignalLabel);
}

void icarus::timing::PMTBeamSignalNamespaceConverter::produce(art::Event& e)
{
//old `icarus::timing::PMTBeamSignal` data product
fPMTBeamSignal = e.getProduct<std::vector<icarus::timing::PMTBeamSignal>>(fSignalLabel);

//new `sbn::timing::PMTBeamSignal` data product
auto PMTBeamSignalColl = std::make_unique<std::vector<sbn::timing::PMTBeamSignal>>();

if (fPMTBeamSignal.empty())
mf::LogTrace("ICARUSBeamStructureAna") << "Data product std::vector<icarus::timing::PMTBeamSignal> for '" << fSignalLabel.label()
<< "' is empty in event!";
else{
for (size_t i = 0; i < fPMTBeamSignal.size(); i++){
sbn::timing::PMTBeamSignal newPMTBeamSignal;
newPMTBeamSignal.specialChannel = fPMTBeamSignal[i].specialChannel;
newPMTBeamSignal.digitizerLabel = fPMTBeamSignal[i].digitizerLabel;
newPMTBeamSignal.crate = fPMTBeamSignal[i].crate;
newPMTBeamSignal.sample = fPMTBeamSignal[i].sample;
newPMTBeamSignal.startTimeAbs = fPMTBeamSignal[i].startTimeAbs;
newPMTBeamSignal.startTime = fPMTBeamSignal[i].startTime;
PMTBeamSignalColl->push_back(newPMTBeamSignal);
}
}
e.put(std::move(PMTBeamSignalColl), fSignalLabel.instance());
}

DEFINE_ART_MODULE(icarus::timing::PMTBeamSignalNamespaceConverter)
Loading