LEHitReco_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: LEHitReco
3 // Plugin Type: producer (art v2_12_00)
4 // File: LEHitReco_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 // this version modifided by John Rabaey for LE discrimination, as opposed to CFD
9 //
10 // Description: Reconstruct hits from digitizer channels with LE.
11 ////////////////////////////////////////////////////////////////////////
12 
13 // framework
21 #include "fhiclcpp/ParameterSet.h"
29 
30 // nova
34 #include "RawData/RawBeamline.h"
35 #include "Utilities/AssociationUtil.h"
36 
37 // stl
38 #include <iostream>
39 #include <memory>
40 
41 namespace beamlinereco {
42  class LEHitReco;
43 }
44 
46 public:
47  explicit LEHitReco(const fhicl::ParameterSet & p);
48 
49  void reconfigure(const fhicl::ParameterSet & p);
50  void produce(art::Event & e) override;
51 
52 private:
55  std::map<LEParams, double> fLEParamSet;
56 
57  // services
59 };
60 
61 
63  produces<std::vector<brb::BeamlineDigit> >();
64  produces<art::Assns<brb::BeamlineDigit, rawdata::RawBeamlineDigit> >();
65 
66  reconfigure(p);
67 }
68 
70  fRawDataLabel = p.get<art::InputTag>("RawDataLabel");
71 
72  fLEParamSet[kADCNBits] = p.get<double>("valADCNBits");
73  fLEParamSet[kADCDynamicRange] = p.get<double>("valADCDynamicRange");
74  fLEParamSet[kADCOffset] = p.get<double>("valADCOffset");
75  fLEParamSet[kTimeSamplingInterval] = p.get<double>("valTimeSamplingInterval");
76  fLEParamSet[kNSamplingPoints] = p.get<double>("valNSamplingPoints");
77  fLEParamSet[kIsWaveformNegativePolarity] = p.get<bool> ("valIsWaveformNegativePolarity");
78  fLEParamSet[kLEThresholdInNoiseBands] = p.get<double>("valLEThresholdInNoiseBands");
79  fLEParamSet[kRawHitFinderThresholdInNoiseSigma] = p.get<double>("valRawHitFinderThresholdInNoiseSigma");
80  fLEParamSet[kShortRawHitIgnoringDurationInTicks] = p.get<double>("valShortRawHitIgnoringDurationInTicks");
81  fLEParamSet[kConsecutiveHitSeperationDurationInTicks] = p.get<double>("valConsecutiveHitSeperationDurationInTicks");
82  fLEParamSet[kGSFilter] = p.get<bool> ("valGSFilter");
83  fLEParamSet[kGSFilterWindow] = p.get<double>("valGSFilterWindow");
84  fLEParamSet[kGSFilterDegree] = p.get<double>("valGSFilterDegree");
85  fLEParamSet[kIntergratedWindowFixed] = p.get<bool> ("valIntergratedWindowFixed");
86  fLEParamSet[kIntergratedWindowLowerLimitIndex] = p.get<double>("valIntergratedWindowLowerLimitIndex");
87  fLEParamSet[kIntergratedWindowUpperLimitIndex] = p.get<double>("valIntergratedWindowUpperLimitIndex");
88 
90  fLEHitFinderAlg->SetParams(fLEParamSet);
91 }
92 
94  std::unique_ptr<std::vector<brb::BeamlineDigit> > digit_reco(new std::vector<brb::BeamlineDigit>);
95  std::unique_ptr<art::Assns<brb::BeamlineDigit, rawdata::RawBeamlineDigit> > digit_assn(new art::Assns<brb::BeamlineDigit, rawdata::RawBeamlineDigit>);
96 
97  // get the raw digits
99  std::vector<art::Ptr<rawdata::RawBeamlineDigit> > digits;
100  if (e.getByLabel(fRawDataLabel, digitHandle)) art::fill_ptr_vector(digits, digitHandle);
101 
102  // run the reco algorithm here
103  for (std::vector<art::Ptr<rawdata::RawBeamlineDigit> >::const_iterator digitIt = digits.begin(); digitIt != digits.end(); ++digitIt) {
104  unsigned int channelNumber = fChannelMap->OnlineDigitChannel((*digitIt)->ChannelID());
105  std::vector<uint16_t> waveform = (*digitIt)->ADCs();
106  uint32_t timestamp = (*digitIt)->Timestamp();
107 
108  fLEHitFinderAlg->SetWaveform(waveform, channelNumber, timestamp);
109  fLEHitFinderAlg->Go();
110  std::map<double, hit_t<double> > HitCollection = fLEHitFinderAlg->GetHitCollection();
111 
112  for (std::map<double, hit_t<double> >::iterator digitHCIt = HitCollection.begin(); digitHCIt != HitCollection.end(); digitHCIt++) {
113  brb::BeamlineDigit in_this_channel;
114  //in_this_channel.SetChannelID((digitHCIt->second).DigitizerChannel);
115  in_this_channel.SetChannelID((*digitIt)->ChannelID());
116  in_this_channel.SetStartTimeInNanoSec((digitHCIt->second).TStartInNanoSec);
117  in_this_channel.SetPeakTimeInNanoSec((digitHCIt->second).TPeakInNanoSec);
118  in_this_channel.SetEndTimeInNanoSec((digitHCIt->second).TStartInNanoSec + (digitHCIt->second).RiseTimeInNanoSec + (digitHCIt->second).FallTimeInNanoSec);
119  in_this_channel.SetPeakADC((digitHCIt->second).AmplitudeInADC);
120 
121  digit_reco->push_back(in_this_channel);
122 
123  // make assn between the reconstructed and raw digits
124  util::CreateAssn(*this, e, *(digit_reco.get()), *digitIt, *(digit_assn.get()), digit_reco->size()-1);
125  }
126  }
127 
128  e.put(std::move(digit_reco));
129  e.put(std::move(digit_assn));
130 }
131 
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.
void SetEndTimeInNanoSec(double time_ns)
void SetPeakTimeInNanoSec(double time_ns)
const char * p
Definition: xmltok.h:285
void SetStartTimeInNanoSec(double time_ns)
DEFINE_ART_MODULE(TestTMapFile)
void SetParams(const std::map< LEParams, double > &paramSet)
unsigned int OnlineDigitChannel(ChannelID channel) const
Online digiziter channel number for this offline ChannelID.
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
LEHitFinder< double > * fLEHitFinderAlg
Encapsulation of reconstructed digitizer &#39;hits&#39;. Used for ToF PMTs and SiPMs, and Cherenkov and Muon ...
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::map< LEParams, double > fLEParamSet
void produce(art::Event &e) override
LEHitReco(const fhicl::ParameterSet &p)
void SetWaveform(std::vector< uint16_t > &waveform, unsigned int channelNo, uint32_t timestamp)
void SetChannelID(beamlinegeo::ChannelID channel)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
const std::map< T, hit_t< T > > & GetHitCollection() const
Raw data definitions for beamline data used in NOvA test beam experiment.
void reconfigure(const fhicl::ParameterSet &p)
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)
Definition: fwd.h:28
art::ServiceHandle< beamlineutil::BeamlineChannelMap > fChannelMap
size_t size() const
Channel mapping service which may be used to interpret the channels which are read out by the various...