CFDHitReco_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: CFDHitReco
3 // Plugin Type: producer (art v2_12_00)
4 // File: CFDHitReco_module.cc
5 //
6 // Generated at Tue Mar 12 13:47:28 2019 by Dung Phan using cetskelgen
7 // from cetlib version v3_06_00.
8 //
9 // Description: Reconstruct hits from digitizer channels with CFD.
10 ////////////////////////////////////////////////////////////////////////
11 
12 // framework
20 #include "fhiclcpp/ParameterSet.h"
27 
28 // nova
33 #include "RawData/RawBeamline.h"
34 #include "Utilities/AssociationUtil.h"
35 
36 // stl
37 #include <iostream>
38 #include <memory>
39 
40 // -----------------------------------------------------------------------
41 namespace beamlinereco {
42  class CFDHitReco;
43 }
44 
45 // -----------------------------------------------------------------------
47 public:
48  explicit CFDHitReco(const fhicl::ParameterSet & p);
49 
50  void reconfigure(const fhicl::ParameterSet & p);
51  void produce(art::Event & e) override;
52 
53 private:
54 
60 
61  std::map<CFDParams, double> fCFDParamSet;
62 
63  // services
66 
67 };
68 
69 // -----------------------------------------------------------------------
71  produces<std::vector<brb::BeamlineDigit> >();
72  produces<art::Assns<brb::BeamlineDigit, rawdata::RawBeamlineDigit> >();
73 
74  reconfigure(p);
75 }
76 
77 // -----------------------------------------------------------------------
79  fRawDataLabel = p.get<art::InputTag>("RawDataLabel");
80  fInterpolationType = p.get<std::string>("valInterpolationType");
81  fDiscriminationType = p.get<std::string>("valDiscriminationType");
82  fFilterType = p.get<std::string>("valFilter");
83 
84  fCFDParamSet[kADCNBits] = p.get<double>("valADCNBits");
85  fCFDParamSet[kADCDynamicRange] = p.get<double>("valADCDynamicRange");
86  fCFDParamSet[kADCOffset] = p.get<double>("valADCOffset");
87  fCFDParamSet[kTimeSamplingInterval] = p.get<double>("valTimeSamplingInterval");
88  fCFDParamSet[kNSamplingPoints] = p.get<double>("valNSamplingPoints");
89  fCFDParamSet[kIsWaveformNegativePolarity] = p.get<bool> ("valIsWaveformNegativePolarity");
90  fCFDParamSet[kDiscriminationThreshold] = p.get<double>("valDiscriminationThreshold");
91  fCFDParamSet[kRawHitFinderThresholdInNoiseSigma] = p.get<double>("valRawHitFinderThresholdInNoiseSigma");
92  fCFDParamSet[kRawHitFinderTicksFromEnd] = p.get<double>("valRawHitFinderStopTicksFromEnd");
93  fCFDParamSet[kShortRawHitIgnoringDurationInTicks] = p.get<double>("valShortRawHitIgnoringDurationInTicks");
94  fCFDParamSet[kConsecutiveHitSeperationDurationInTicks] = p.get<double>("valConsecutiveHitSeperationDurationInTicks");
95  fCFDParamSet[kGSFilterWindow] = p.get<double>("valGSFilterWindow");
96  fCFDParamSet[kGSFilterDegree] = p.get<double>("valGSFilterDegree");
97  fCFDParamSet[kKalmanFilterProcessNoiseCovariance] = p.get<double>("valKalmanFilterProcessNoiseCovariance");
98  fCFDParamSet[kKalmanFilterMeasurementNoiseCovariance] = p.get<double>("valKalmanFilterMeasurementNoiseCovariance");
99  fCFDParamSet[kKalmanFilterGain] = p.get<double>("valKalmanFilterGain");
100  fCFDParamSet[kIntergratedWindowFixed] = p.get<bool> ("valIntergratedWindowFixed");
101  fCFDParamSet[kIntergratedWindowLowerLimitIndex] = p.get<double>("valIntergratedWindowLowerLimitIndex");
102  fCFDParamSet[kIntergratedWindowUpperLimitIndex] = p.get<double>("valIntergratedWindowUpperLimitIndex");
103 
105  fCFDHitFinderAlg->SetParams(fCFDParamSet);
106  fCFDHitFinderAlg->SetInterpolationType(fInterpolationType);
107  fCFDHitFinderAlg->SetDiscriminationType(fDiscriminationType);
108  fCFDHitFinderAlg->SetFilterType(fFilterType);
109 }
110 
111 // -----------------------------------------------------------------------
113 
114  std::unique_ptr<std::vector<brb::BeamlineDigit> >
115  digit_reco(new std::vector<brb::BeamlineDigit>);
116  std::unique_ptr<art::Assns<brb::BeamlineDigit, rawdata::RawBeamlineDigit> >
118 
119  // get the raw digits
121  std::vector<art::Ptr<rawdata::RawBeamlineDigit> > rawDigits;
122  if (evt.getByLabel(fRawDataLabel, rawDigitHandle))
123  art::fill_ptr_vector(rawDigits, rawDigitHandle);
124 
125  // run the reco algorithm here
126  for (auto rawDigit : rawDigits) {
127  unsigned int channelNumber = fChannelMap->OnlineDigitChannel(rawDigit->ChannelID());
128  std::vector<uint16_t> waveform = rawDigit->ADCs();
129  uint32_t timestamp = rawDigit->Timestamp();
130 
131  fCFDHitFinderAlg->SetWaveform(waveform, channelNumber, timestamp);
132  fCFDHitFinderAlg->Go();
133  std::map<double, hit_t<double> > HitCollection = fCFDHitFinderAlg->GetHitCollection();
134 
135  double pedestal = fCFDHitFinderAlg->GetPedestal();
136 
137  for (std::map<double, hit_t<double> >::iterator digitHCIt = HitCollection.begin();
138  digitHCIt != HitCollection.end(); digitHCIt++) {
139  brb::BeamlineDigit in_this_channel;
140  in_this_channel.SetChannelID(rawDigit->ChannelID());
141  in_this_channel.SetStartTimeInNanoSec((digitHCIt->second).TStartInNanoSec);
142  in_this_channel.SetPeakTimeInNanoSec((digitHCIt->second).TPeakInNanoSec);
143  in_this_channel.SetEndTimeInNanoSec((digitHCIt->second).TStartInNanoSec +
144  (digitHCIt->second).RiseTimeInNanoSec +
145  (digitHCIt->second).FallTimeInNanoSec);
146  in_this_channel.SetPeakADC((digitHCIt->second).AmplitudeInADC);
147  in_this_channel.SetAmplitudeInADC(abs((digitHCIt->second).AmplitudeInADC - pedestal));
148  in_this_channel.SetAreaInADCNanoSec((digitHCIt->second).IntegratedChargeInADCNanoSec);
149  in_this_channel.SetWidthInNanoSec((digitHCIt->second).WidthInNanoSec);
150 
151  digit_reco->push_back(in_this_channel);
152 
153  // make assn between the reconstructed and raw digits
154  util::CreateAssn(*this, evt, *(digit_reco.get()), rawDigit, *(digit_assn.get()), digit_reco->size()-1);
155  }
156  }
157 
158  evt.put(std::move(digit_reco));
159  evt.put(std::move(digit_assn));
160 }
161 
162 // -----------------------------------------------------------------------
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
const std::map< T, hit_t< T > > & GetHitCollection() const
void SetEndTimeInNanoSec(double time_ns)
void SetPeakTimeInNanoSec(double time_ns)
const char * p
Definition: xmltok.h:285
void SetWidthInNanoSec(double width_ns)
void SetStartTimeInNanoSec(double time_ns)
void abs(TH1 *hist)
art::ServiceHandle< beamlineutil::BeamlineCalibration > fCalibration
DEFINE_ART_MODULE(TestTMapFile)
unsigned int OnlineDigitChannel(ChannelID channel) const
Online digiziter channel number for this offline ChannelID.
void SetAmplitudeInADC(int adc)
CFDHitFinder< double > * fCFDHitFinderAlg
void SetParams(const std::map< CFDParams, double > &paramSet)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Encapsulation of reconstructed digitizer &#39;hits&#39;. Used for ToF PMTs and SiPMs, and Cherenkov and Muon ...
CFDHitReco(const fhicl::ParameterSet &p)
void produce(art::Event &e) override
T get(std::string const &key) const
Definition: ParameterSet.h:231
Calibration service to provide specific externally-measured values to the relevant reconstruction/ana...
void SetWaveform(std::vector< uint16_t > &waveform, unsigned int channelNo, uint32_t timestamp)
std::map< CFDParams, double > fCFDParamSet
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
void SetChannelID(beamlinegeo::ChannelID channel)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Raw data definitions for beamline data used in NOvA test beam experiment.
const T & GetPedestal() const
art::ServiceHandle< beamlineutil::BeamlineChannelMap > fChannelMap
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Float_t e
Definition: plot.C:35
void SetPeakADC(int adc)
void reconfigure(const fhicl::ParameterSet &p)
size_t size() const
Channel mapping service which may be used to interpret the channels which are read out by the various...
void SetAreaInADCNanoSec(double area_adcns)