SignalShapingServiceDUNE.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 ///
3 /// \file SignalShapingServiceDUNE.h
4 ///
5 /// \brief Service to provide microboone-specific signal shaping for
6 /// simulation (convolution) and reconstruction (deconvolution).
7 ///
8 /// \author H. Greenlee (original class)
9 ///
10 /// This service inherits from SignalShaping and supplies
11 /// microboone-specific configuration. It is intended that SimWire and
12 /// CalWire modules will access this service.
13 ///
14 /// FCL parameters:
15 ///
16 /// FieldBins - Number of bins of field response.
17 /// Col3DCorrection - 3D path length correction for collection plane.
18 /// Ind3DCorrection - 3D path length correction for induction plane.
19 /// ColFieldRespAmp - Collection field response amplitude.
20 /// IndFieldRespAmp - Induction field response amplitude.
21 /// ShapeTimeConst - Time constants for exponential shaping.
22 /// ColFilter - Root parameterized collection plane filter function.
23 /// ColFilterParams - Collection filter function parameters.
24 /// IndFilter - Root parameterized induction plane filter function.
25 /// IndFilterParams - Induction filter function parameters.
26 ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 #ifndef SIGNALSHAPINGSERVICEDUNE_H
30 #define SIGNALSHAPINGSERVICEDUNE_H
31 
33 
34 #include "fhiclcpp/ParameterSet.h"
38 #include "TF1.h"
39 #include "TH1D.h"
40 
41 namespace detinfo {
42  class DetectorClocksData;
43  class DetectorPropertiesData;
44 }
45 
46 using DoubleVec = std::vector<double>;
47 namespace util {
48 
50 public:
51 
52  // Constructor, destructor.
53 
57 
58  // Update configuration parameters.
59 
60  void reconfigure(const fhicl::ParameterSet& pset);
61 
62  std::vector<DoubleVec> GetNoiseFactVec() const override;
63  double GetASICGain(Channel channel) const override;
64  double GetShapingTime(Channel channel) const override;
65  double GetRawNoise(Channel channel) const override;
66  double GetDeconNoise(Channel channel) const override;
67  double GetDeconNorm() const override;
68  unsigned int GetSignalSize() const override;
69 
70  // Accessors.
71  int FieldResponseTOffset(detinfo::DetectorClocksData const& clockData,
72  Channel const channel) const override;
73  const util::SignalShaping& SignalShaping(Channel channel) const override;
74  const util::SignalShaping& ElectronicShaping(unsigned int channel) const;
75 
76  // Do convolution calcution (for simulation).
77  template <class T> void Convolute(detinfo::DetectorClocksData const& clockData,
78  Channel channel, std::vector<T>& func) const;
79  template <class T> void ConvoluteElectronicResponse(detinfo::DetectorClocksData const& clockData,
80  Channel channel, std::vector<T>& func) const;
81  void Convolute(detinfo::DetectorClocksData const& clockData,
82  Channel channel, FloatVector& func) const override;
83  void Convolute(detinfo::DetectorClocksData const& clockData,
84  Channel channel, DoubleVector& func) const override;
85  void ConvoluteElectronicResponse(detinfo::DetectorClocksData const& clockData,
86  Channel channel, FloatVector& func) const;
87  void ConvoluteElectronicResponse(detinfo::DetectorClocksData const& clockData,
88  Channel channel, DoubleVector& func) const;
89 
90 
91  // Do deconvolution calcution (for reconstruction).
92  template <class T> void Deconvolute(detinfo::DetectorClocksData const& clockData,
93  Channel channel, std::vector<T>& func) const;
94  void Deconvolute(detinfo::DetectorClocksData const& clockData,
95  Channel channel, DoubleVector& func) const override;
96  void Deconvolute(detinfo::DetectorClocksData const& clockData,
97  Channel channel, FloatVector& func) const override;
98 
99 private:
100 
101  // Private configuration methods.
102 
103  // Post-constructor initialization.
104  void init() const{const_cast<SignalShapingServiceDUNE*>(this)->init();}
105  void init();
106 
107  // Calculate response functions.
108  void SetFieldResponse(detinfo::DetectorClocksData const& clockData,
109  detinfo::DetectorPropertiesData const& detProp);
110  void SetElectResponse(double shapingtime, double gain);
111  void SetRCResponse();
112 
113  // Calculate filter functions.
114  void SetFilters(detinfo::DetectorClocksData const& clockData);
115 
116  // Attributes.
117  bool fInit; ///< Initialization flag.
118 
119  // Sample the response function, including a configurable
120  // drift velocity of electrons
121  void SetResponseSampling(detinfo::DetectorClocksData const& clockData, bool elect_only=false);
122 
123  // Fcl parameters.
124  int fNFieldBins; ///< number of bins for field response
125  double fCol3DCorrection; ///< correction factor to account for 3D path of
126  double fInd3DCorrection; ///< correction factor to account for 3D path of
127  double fColFieldRespAmp; ///< amplitude of response to field
128  double fIndUFieldRespAmp; ///< amplitude of response to field
129  double fIndVFieldRespAmp; ///< amplitude of response to field
130  std::vector<double> fFieldResponseTOffset; ///< Time offset for field response in ns
131  std::vector<double> fCalibResponseTOffset;
132  double fInputFieldRespSamplingPeriod; ///< Sampling period in the input field response.
133  double fDeconNorm;
134  double fADCPerPCAtLowestASICGain; ///< Pulse amplitude gain for a 1 pc charge impulse after convoluting it the with field and electronics response with the lowest ASIC gain setting of 4.7 mV/fC
135  std::vector<DoubleVec> fNoiseFactVec;
136  std::vector<double> fASICGainInMVPerFC;
137  std::vector<double> fShapeTimeConst; ///< time constants for exponential shaping
138  TF1* fColFilterFunc; ///< Parameterized collection filter function.
139  TF1* fIndUFilterFunc; ///< Parameterized induction filter function.
140  TF1* fIndVFilterFunc; ///< Parameterized induction filter function.
141  bool fUseFunctionFieldShape; ///< Flag that allows to use a parameterized field response instead of the hardcoded version
142  bool fUseHistogramFieldShape; ///< Flag that turns on field response shapes from histograms
143  bool fGetFilterFromHisto; ///< Flag that allows to use a filter function from a histogram instead of the functional dependency
144  TF1* fColFieldFunc; ///< Parameterized collection field shape function.
145  TF1* fIndUFieldFunc; ///< Parameterized induction field shape function.
146  TF1* fIndVFieldFunc; ///< Parameterized induction field shape function.
147  TH1F *fFieldResponseHist[3]; ///< Histogram used to hold the field response, hardcoded for the time being
148  TH1D *fFilterHist[3]; ///< Histogram used to hold the collection filter, hardcoded for the time being
149 
150  // Following attributes hold the convolution and deconvolution kernels
154 
158 
159  // Field response.
160  std::vector<double> fColFieldResponse;
161  std::vector<double> fIndUFieldResponse;
162  std::vector<double> fIndVFieldResponse;
163 
164  // Electronics response.
165  std::vector<double> fElectResponse;
166 
167  // Filters.
168  std::vector<TComplex> fColFilter;
169  std::vector<TComplex> fIndUFilter;
170  std::vector<TComplex> fIndVFilter;
171 
172 };
173 
174 } // end namespace util
175 
176 //----------------------------------------------------------------------
177 
178 // Do convolution.
179 template <class T>
182  unsigned int channel, std::vector<T>& func) const {
183  SignalShaping(channel).Convolute(func);
184 
185  //negative number
186  int time_offset = FieldResponseTOffset(clockData, channel);
187 
188  std::vector<T> temp;
189  if (time_offset <=0){
190  temp.assign(func.begin(),func.begin()-time_offset);
191  func.erase(func.begin(),func.begin()-time_offset);
192  func.insert(func.end(),temp.begin(),temp.end());
193  }else{
194  temp.assign(func.end()-time_offset,func.end());
195  func.erase(func.end()-time_offset,func.end());
196  func.insert(func.begin(),temp.begin(),temp.end());
197  }
198 }
199 template <class T>
202  unsigned int channel, std::vector<T>& func) const {
203  ElectronicShaping(channel).Convolute(func);
204 
205  //negative number
206  int time_offset = FieldResponseTOffset(clockData, channel);
207 
208  std::vector<T> temp;
209  if (time_offset <=0){
210  temp.assign(func.begin(),func.begin()-time_offset);
211  func.erase(func.begin(),func.begin()-time_offset);
212  func.insert(func.end(),temp.begin(),temp.end());
213  }else{
214  temp.assign(func.end()-time_offset,func.end());
215  func.erase(func.end()-time_offset,func.end());
216  func.insert(func.begin(),temp.begin(),temp.end());
217  }
218 }
219 
220 //----------------------------------------------------------------------
221 
222 // Do deconvolution.
223 template <class T>
226  unsigned int channel, std::vector<T>& func) const {
227  SignalShaping(channel).Deconvolute(func);
228 
229  int time_offset = FieldResponseTOffset(clockData, channel);
230 
231  std::vector<T> temp;
232  if (time_offset <=0){
233  temp.assign(func.end()+time_offset,func.end());
234  func.erase(func.end()+time_offset,func.end());
235  func.insert(func.begin(),temp.begin(),temp.end());
236  }else{
237  temp.assign(func.begin(),func.begin()+time_offset);
238  func.erase(func.begin(),func.begin()+time_offset);
239  func.insert(func.end(),temp.begin(),temp.end());
240  }
241 }
242 
243 //----------------------------------------------------------------------
244 
246 
247 #endif
double fColFieldRespAmp
amplitude of response to field
TF1 * fColFilterFunc
Parameterized collection filter function.
void Deconvolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
bool fUseFunctionFieldShape
Flag that allows to use a parameterized field response instead of the hardcoded version.
void Deconvolute(std::vector< T > &func) const
Namespace for general, non-LArSoft-specific utilities.
util::SignalShaping fColElectResponseSignalShaping
bool fGetFilterFromHisto
Flag that allows to use a filter function from a histogram instead of the functional dependency...
std::vector< double > fShapeTimeConst
time constants for exponential shaping
std::vector< float > FloatVector
double fCol3DCorrection
correction factor to account for 3D path of
int fNFieldBins
number of bins for field response
uint8_t channel
Definition: CRTFragment.hh:201
init
Definition: train.py:42
TF1 * fIndUFieldFunc
Parameterized induction field shape function.
std::vector< double > fFieldResponseTOffset
Time offset for field response in ns.
std::vector< DoubleVec > fNoiseFactVec
double fIndVFieldRespAmp
amplitude of response to field
void Convolute(std::vector< T > &func) const
double fADCPerPCAtLowestASICGain
Pulse amplitude gain for a 1 pc charge impulse after convoluting it the with field and electronics re...
Generic class for shaping signals on wires.
virtual void reconfigure(fhicl::ParameterSet const &pset)
double fInd3DCorrection
correction factor to account for 3D path of
util::SignalShaping fIndUElectResponseSignalShaping
#define DECLARE_ART_SERVICE(svc, scope)
double fIndUFieldRespAmp
amplitude of response to field
TF1 * fIndUFilterFunc
Parameterized induction filter function.
bool fUseHistogramFieldShape
Flag that turns on field response shapes from histograms.
General LArSoft Utilities.
util::SignalShaping fIndVElectResponseSignalShaping
void ConvoluteElectronicResponse(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
TF1 * fIndVFieldFunc
Parameterized induction field shape function.
void Convolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
std::vector< double > DoubleVector
Contains all timing reference information for the detector.
TF1 * fColFieldFunc
Parameterized collection field shape function.
TF1 * fIndVFilterFunc
Parameterized induction filter function.
def func()
Definition: docstring.py:7
double fInputFieldRespSamplingPeriod
Sampling period in the input field response.
std::vector< double > DoubleVec