SignalShapingServiceDUNE34kt.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 ///
3 /// \file SignalShapingServiceDUNE34kt.h
4 ///
5 /// \brief Service to provide microboone-specific signal shaping for
6 /// simulation (convolution) and reconstruction (deconvolution).
7 ///
8 /// \author H. Greenlee
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 SIGNALSHAPINGSERVICEDUNE34KT_H
30 #define SIGNALSHAPINGSERVICEDUNE34KT_H
31 
32 #include <vector>
33 #include "fhiclcpp/ParameterSet.h"
37 #include "TF1.h"
38 #include "TH1D.h"
39 
40 namespace detinfo {
41  class DetectorClocksData;
42  class DetectorPropertiesData;
43 }
44 
45 using DoubleVec = std::vector<double>;
46 
47 namespace util {
49  public:
50 
51  // Constructor, destructor.
52 
56 
57  // Update configuration parameters.
58 
59  void reconfigure(const fhicl::ParameterSet& pset);
60 
61  std::vector<DoubleVec> GetNoiseFactVec() { return fNoiseFactVec; }
62 
63  double GetASICGain(unsigned int const channel) const;
64  double GetShapingTime(unsigned int const channel) const;
65 
66  double GetRawNoise(unsigned int const channel) const ;
67  double GetDeconNoise(unsigned int const channel) const;
68 
69 
70  // Accessors.
71 
72  int FieldResponseTOffset(detinfo::DetectorClocksData const& clockData,
73  unsigned int const channel) const;
74  const util::SignalShaping& SignalShaping(unsigned int channel) const;
75 
76  // Do convolution calcution (for simulation).
77 
78  template <class T> void Convolute(detinfo::DetectorClocksData const& clockData,
79  unsigned int channel, std::vector<T>& func) const;
80 
81  // Do deconvolution calcution (for reconstruction).
82 
83  template <class T> void Deconvolute(detinfo::DetectorClocksData const& clockData,
84  unsigned int channel, std::vector<T>& func) const;
85  double GetDeconNorm(){return fDeconNorm;};
86 
87  private:
88 
89  // Private configuration methods.
90 
91  // Post-constructor initialization.
92 
93  void init() const{const_cast<SignalShapingServiceDUNE34kt*>(this)->init();}
94  void init();
95 
96  // Calculate response functions.
97  // Copied from SimWireDUNE34kt.
98 
99  void SetFieldResponse(detinfo::DetectorClocksData const& clockData,
100  detinfo::DetectorPropertiesData const& detProp);
101  void SetElectResponse(double shapingtime, double gain);
102 
103  // Calculate filter functions.
104 
105  void SetFilters(detinfo::DetectorClocksData const& clockData);
106 
107  // Attributes.
108 
109  bool fInit; ///< Initialization flag.
110 
111  // Sample the response function, including a configurable
112  // drift velocity of electrons
113 
114  void SetResponseSampling(detinfo::DetectorClocksData const& clockData);
115 
116  // Fcl parameters.
117 
118  int fNFieldBins; ///< number of bins for field response
119  double fCol3DCorrection; ///< correction factor to account for 3D path of
120  ///< electrons thru wires
121  double fInd3DCorrection; ///< correction factor to account for 3D path of
122  ///< electrons thru wires
123  double fColFieldRespAmp; ///< amplitude of response to field
124  double fIndUFieldRespAmp; ///< amplitude of response to field
125  double fIndVFieldRespAmp; ///< amplitude of response to field
126 
127  std::vector<double> fFieldResponseTOffset; ///< Time offset for field response in ns
128  std::vector<double> fCalibResponseTOffset;
129  double fInputFieldRespSamplingPeriod; ///< Sampling period in the input field response.
130 
131  double fDeconNorm;
132  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
133  std::vector<DoubleVec> fNoiseFactVec;
134 
135  std::vector<double> fASICGainInMVPerFC;
136 
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 
142 
143  bool fUseFunctionFieldShape; ///< Flag that allows to use a parameterized field response instead of the hardcoded version
144  bool fUseHistogramFieldShape; ///< Flag that turns on field response shapes from histograms
145  bool fGetFilterFromHisto; ///< Flag that allows to use a filter function from a histogram instead of the functional dependency
146  TF1* fColFieldFunc; ///< Parameterized collection field shape function.
147  TF1* fIndUFieldFunc; ///< Parameterized induction field shape function.
148  TF1* fIndVFieldFunc; ///< Parameterized induction field shape function.
149 
150  TH1F *fFieldResponseHist[3]; ///< Histogram used to hold the field response, hardcoded for the time being
151  TH1D *fFilterHist[3]; ///< Histogram used to hold the collection filter, hardcoded for the time being
152 
153  // Following attributes hold the convolution and deconvolution kernels
154 
158 
159  // Field response.
160 
161  std::vector<double> fColFieldResponse;
162  std::vector<double> fIndUFieldResponse;
163  std::vector<double> fIndVFieldResponse;
164 
165  // Electronics response.
166 
167  std::vector<double> fElectResponse;
168 
169  // Filters.
170 
171  std::vector<TComplex> fColFilter;
172  std::vector<TComplex> fIndUFilter;
173  std::vector<TComplex> fIndVFilter;
174  };
175 }
176 //----------------------------------------------------------------------
177 // Do convolution.
178 template <class T> inline void util::SignalShapingServiceDUNE34kt::Convolute(detinfo::DetectorClocksData const& clockData,
179  unsigned int channel, std::vector<T>& func) const
180 {
181  SignalShaping(channel).Convolute(func);
182 
183  //negative number
184  int time_offset = FieldResponseTOffset(clockData, channel);
185 
186  std::vector<T> temp;
187  if (time_offset <=0){
188  temp.assign(func.begin(),func.begin()-time_offset);
189  func.erase(func.begin(),func.begin()-time_offset);
190  func.insert(func.end(),temp.begin(),temp.end());
191  }else{
192  temp.assign(func.end()-time_offset,func.end());
193  func.erase(func.end()-time_offset,func.end());
194  func.insert(func.begin(),temp.begin(),temp.end());
195  }
196 }
197 
198 
199 //----------------------------------------------------------------------
200 // Do deconvolution.
201 template <class T> inline void util::SignalShapingServiceDUNE34kt::Deconvolute(detinfo::DetectorClocksData const& clockData,
202  unsigned int channel, std::vector<T>& func) const
203 {
204  SignalShaping(channel).Deconvolute(func);
205 
206  int time_offset = FieldResponseTOffset(clockData, channel);
207 
208  std::vector<T> temp;
209  if (time_offset <=0){
210  temp.assign(func.end()+time_offset,func.end());
211  func.erase(func.end()+time_offset,func.end());
212  func.insert(func.begin(),temp.begin(),temp.end());
213  }else{
214  temp.assign(func.begin(),func.begin()+time_offset);
215  func.erase(func.begin(),func.begin()+time_offset);
216  func.insert(func.end(),temp.begin(),temp.end());
217  }
218 }
219 
221 #endif
double fIndVFieldRespAmp
amplitude of response to field
TF1 * fIndUFilterFunc
Parameterized induction filter function.
std::vector< double > fShapeTimeConst
time constants for exponential shaping
std::vector< double > fFieldResponseTOffset
Time offset for field response in ns.
void Deconvolute(std::vector< T > &func) const
Namespace for general, non-LArSoft-specific utilities.
TF1 * fIndVFieldFunc
Parameterized induction field shape function.
bool fUseFunctionFieldShape
Flag that allows to use a parameterized field response instead of the hardcoded version.
uint8_t channel
Definition: CRTFragment.hh:201
init
Definition: train.py:42
void Convolute(std::vector< T > &func) const
double fInputFieldRespSamplingPeriod
Sampling period in the input field response.
Generic class for shaping signals on wires.
TF1 * fColFilterFunc
Parameterized collection filter function.
TF1 * fColFieldFunc
Parameterized collection field shape function.
double fColFieldRespAmp
amplitude of response to field
virtual void reconfigure(fhicl::ParameterSet const &pset)
#define DECLARE_ART_SERVICE(svc, scope)
TF1 * fIndUFieldFunc
Parameterized induction field shape function.
General LArSoft Utilities.
bool fUseHistogramFieldShape
Flag that turns on field response shapes from histograms.
double fIndUFieldRespAmp
amplitude of response to field
void Deconvolute(detinfo::DetectorClocksData const &clockData, unsigned int channel, std::vector< T > &func) const
bool fGetFilterFromHisto
Flag that allows to use a filter function from a histogram instead of the functional dependency...
Contains all timing reference information for the detector.
def func()
Definition: docstring.py:7
int fNFieldBins
number of bins for field response
double fADCPerPCAtLowestASICGain
Pulse amplitude gain for a 1 pc charge impulse after convoluting it the with field and electronics re...
void Convolute(detinfo::DetectorClocksData const &clockData, unsigned int channel, std::vector< T > &func) const
TF1 * fIndVFilterFunc
Parameterized induction filter function.
std::vector< double > DoubleVec