Skip to content
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

Minor fix to OpHitFinderDeco_module. #62

Merged
merged 1 commit into from
Sep 26, 2024
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
37 changes: 17 additions & 20 deletions duneopdet/OpticalDetector/OpHitFinder/OpHitAlg_deco.cxx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// ========================================================================================
// OpHitAlg_deco.cxx
// This module is based on the larana/OpHitAlg.cxx. It has been updated to deal with
// deconvolved signals. These are the algorithms used by OpHitFinderDeco to produce optical
// This module is based on the larana/OpHitAlg.cxx. It has been updated to deal with
// deconvolved signals. These are the algorithms used by OpHitFinderDeco to produce optical
// hits. recob::OpWaveform object has been included inside the RunHitFinder_deco function.
// Added the scaling factor inside the new RunHitFinder_deco function. It scales the values
// Added the scaling factor inside the new RunHitFinder_deco function. It scales the values
// of the deconvolved signals before the hit finder.
//
//
// @authors : Daniele Guffanti, Maritza Delgado, Sergio Manthey Corchado
// @created : Oct, 2022
// @created : Oct, 2022
//=========================================================================================

#include "OpHitAlg_deco.h"
Expand All @@ -26,7 +26,7 @@

namespace opdet {


void RunHitFinder(std::vector<raw::OpDetWaveform> const& opDetWaveformVector,
std::vector<recob::OpHit>& hitVector,
pmtana::PulseRecoManager const& pulseRecoMgr,
Expand Down Expand Up @@ -69,7 +69,6 @@ namespace opdet {

//----------------------------------------------------------------------------
void RunHitFinder_deco(std::vector<recob::OpWaveform>const& opWaveformVector,
std::vector<raw::OpDetWaveform> const& opDetWaveformVector,
std::vector<recob::OpHit>& hitVector,
pmtana::PulseRecoManager const& pulseRecoMgr,
pmtana::PMTPulseRecoBase const& threshAlg,
Expand All @@ -80,29 +79,27 @@ namespace opdet {
calib::IPhotonCalibrator const& calibrator,
bool use_start_time)
{

for (int i=0; i< int (opWaveformVector.size()); i++){
recob::OpWaveform deco_waveform=opWaveformVector.at(i);
int channel = static_cast<int>(deco_waveform.Channel());
//The raw timestamp is used
raw::OpDetWaveform waveform=opDetWaveformVector.at(i);
const double timeStamp = waveform.TimeStamp();

const double timeStamp = deco_waveform.TimeStamp();

if (!geometry.IsValidOpChannel(channel)) {
mf::LogError("OpHitFinder")
<< "Error! unrecognized channel number " << channel << ". Ignoring pulse";
continue;
}

// Loop to convert from float to short
std::vector<short int> short_deco_waveform; //vector used to convert from float to short.
for (unsigned int i_tick=0; i_tick < deco_waveform.Signal().size(); ++i_tick)
{
short_deco_waveform.emplace_back(static_cast<short int>(scale*deco_waveform.Signal().at(i_tick)));
}

pulseRecoMgr.Reconstruct(short_deco_waveform);

// Get the result
auto const& pulses = threshAlg.GetPulses();
for (auto const& pulse : pulses)
Expand All @@ -116,7 +113,7 @@ namespace opdet {
use_start_time);
}
}

//----------------------------------------------------------------------------
void ConstructHit(float hitThreshold,
int channel,
Expand All @@ -137,10 +134,10 @@ namespace opdet {
int frame = clocksData.OpticalClock().Frame(timeStamp);
double PE = 0.0;

if (calibrator.UseArea())
if (calibrator.UseArea())
PE = calibrator.PE(pulse.area, channel);
else
PE = calibrator.PE(pulse.peak, channel);
else
PE = calibrator.PE(pulse.peak, channel);

double width = (pulse.t_end - pulse.t_start) * clocksData.OpticalClock().TickPeriod();

Expand All @@ -156,6 +153,6 @@ namespace opdet {
PE,
0.0);
}


} // End namespace opdet
15 changes: 7 additions & 8 deletions duneopdet/OpticalDetector/OpHitFinder/OpHitAlg_deco.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// ========================================================================================
// OpHitAlg_deco.h
// This module is based on the larana/OpHitAlg.h. It has been updated to deal with
// deconvolved signals. These are the algorithms used by OpHitFinderDeco to produce optical
// This module is based on the larana/OpHitAlg.h. It has been updated to deal with
// deconvolved signals. These are the algorithms used by OpHitFinderDeco to produce optical
// hits. recob::OpWaveform object has been included inside the RunHitFinder_deco function.
// Added the scaling factor inside the new RunHitFinder_deco function. It scales the values
// Added the scaling factor inside the new RunHitFinder_deco function. It scales the values
// of the deconvolved signals before the hit finder.
//
//
// @authors : Daniele Guffanti, Maritza Delgado, Sergio Manthey Corchado
// @created : Oct, 2022
// @created : Oct, 2022
//=========================================================================================

#ifndef OPHITALG_DECO_H
Expand All @@ -34,7 +34,7 @@ namespace pmtana {
}

namespace opdet {

void RunHitFinder(std::vector<raw::OpDetWaveform> const&,
std::vector<recob::OpHit>&,
pmtana::PulseRecoManager const&,
Expand All @@ -46,7 +46,6 @@ namespace opdet {
bool use_start_time = false);

void RunHitFinder_deco(std::vector<recob::OpWaveform> const&,
std::vector<raw::OpDetWaveform> const&,
std::vector<recob::OpHit>&,
pmtana::PulseRecoManager const&,
pmtana::PMTPulseRecoBase const&,
Expand All @@ -57,7 +56,7 @@ namespace opdet {
calib::IPhotonCalibrator const&,
bool use_start_time = false);

void ConstructHit(float,
void ConstructHit(float,
int,
double,
pmtana::pulse_param const&,
Expand Down
33 changes: 14 additions & 19 deletions duneopdet/OpticalDetector/OpHitFinder/OpHitFinderDeco_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
// OpHitFinderDeco_module.cc
// This module is based on the larana/OpHitFinder module. It has been updated
// to deal with deconvolved waveforms.The module takes either raw::OpDetWaveforms
// (raw signals) or recob:OpWaveforms (deconvolved signals) as input,
// (raw signals) or recob:OpWaveforms (deconvolved signals) as input,
// and generates OpHits as output.
// The HitFinder algorithm can be chosen by the user.
// Added the scaling factor inside the new RunHitFinder_deco function.
// Added the scaling factor inside the new RunHitFinder_deco function.
// It scales the values of the deconvolved signals before the hit finder.
//
// @authors : Daniele Guffanti, Maritza Delgado, Sergio Manthey Corchado
// @created : Oct, 2022
// @created : Oct, 2022
//================================================================================

// LArSoft includes
#include "larcore/CoreUtils/ServiceUtil.h"
#include "larcore/CoreUtils/ServiceUtil.h"
#include "larcore/Geometry/Geometry.h"
#include "larana/OpticalDetector/OpHitFinder/AlgoCFD.h"
#include "larana/OpticalDetector/OpHitFinder/AlgoFixedWindow.h"
Expand Down Expand Up @@ -76,7 +76,7 @@ namespace opdet {

// The parameters we'll read from the .fcl file.
std::string fInputModule; // Input tag for OpDetWaveform collection
std::string fInputModuledigi;
std::string fInputModuledigi;
std::string fGenModule;
std::string fInputDigiType;
std::vector<std::string> fInputLabels;
Expand Down Expand Up @@ -119,7 +119,7 @@ namespace opdet {

auto const& geometry(*lar::providerFrom<geo::Geometry>());
fMaxOpChannel = geometry.MaxOpChannel();

// If useCalibrator, get it from ART
if (useCalibrator) {fCalib = lar::providerFrom<calib::IPhotonCalibratorService>();}
// If not useCalibrator, make an internal one based on fhicl settings to hit finder.
Expand Down Expand Up @@ -202,16 +202,11 @@ namespace opdet {
std::cout << "\nRunning Ophitfinder with InputDigiType = 'recob'\n";
// Load pulses into WaveformVector
art::Handle<std::vector<recob::OpWaveform>> decoHandle;
art::Handle<std::vector<raw::OpDetWaveform>> rawHandle;


evt.getByLabel(fInputModule, decoHandle);
evt.getByLabel(fInputModuledigi,rawHandle);

assert(decoHandle.isValid());
assert(rawHandle.isValid());


RunHitFinder_deco(*decoHandle,
*rawHandle,
*HitPtr,
fPulseRecoMgr,
*fThreshAlg,
Expand All @@ -221,15 +216,15 @@ namespace opdet {
clock_data,
calibrator,
fUseStartTime);
}
}

if (fInputDigiType == "raw"){
std::cout << "\nRunning Ophitfinder with InputDigiType = 'raw'\n";
// Load pulses into WaveformVector
art::Handle<std::vector<raw::OpDetWaveform>> rawHandle;
evt.getByLabel(fInputModuledigi,rawHandle);
assert(rawHandle.isValid());

if (fChannelMasks.empty() && fInputLabels.size() < 2){
art::Handle<std::vector<raw::OpDetWaveform>> rawHandle;
if (fInputLabels.empty()) {evt.getByLabel(fInputModuledigi, rawHandle);}
Expand All @@ -243,7 +238,7 @@ namespace opdet {
fHitThreshold,
clock_data,
calibrator,
fUseStartTime);
fUseStartTime);
}

else{
Expand Down Expand Up @@ -282,5 +277,5 @@ namespace opdet {
// Store results into the event
std:: cout << "Found hits: " << HitPtr->size() << "!\n";
evt.put(std::move(HitPtr));
}
} // namespace opdet
}
} // namespace opdet