SignalShapingServiceDUNE35t.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 ///
3 /// \file SignalShapingServiceDUNE35t.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 SIGNALSHAPINGSERVICEDUNE35T_H
30 #define SIGNALSHAPINGSERVICEDUNE35T_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  double GetASICGain(unsigned int const channel) const;
63  double GetShapingTime(unsigned int const channel) const;
64 
65  double GetRawNoise(unsigned int const channel) const ;
66  double GetDeconNoise(unsigned int const channel) const;
67 
68  // Accessors.
69 
70  const util::SignalShaping& SignalShaping(unsigned int channel) const;
71 
72  int FieldResponseTOffset(detinfo::DetectorClocksData const& clockData,
73  unsigned int const channel) const;
74 
75  // Do convolution calcution (for simulation).
76 
77  template <class T> void Convolute(detinfo::DetectorClocksData const& clockData,
78  unsigned int channel, std::vector<T>& func) const;
79 
80  // Do deconvolution calcution (for reconstruction).
81 
82  template <class T> void Deconvolute(detinfo::DetectorClocksData const& clockData,
83  unsigned int channel, std::vector<T>& func) const;
84 
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<SignalShapingServiceDUNE35t*>(this)->init();}
94  void init();
95 
96  // Calculate response functions.
97  // Copied from SimWireDUNE35t.
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; //Calibrated time offset in order to alogn U/V/Y planes
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  bool fUseFunctionFieldShape; ///< Flag that allows to use a parameterized field response instead of the hardcoded version
143  bool fUseHistogramFieldShape; ///< Flag that turns on field response shapes from histograms
144  bool fGetFilterFromHisto; ///< Flag that allows to use a filter function from a histogram instead of the functional dependency
145  TF1* fColFieldFunc; ///< Parameterized collection field shape function.
146  TF1* fIndUFieldFunc; ///< Parameterized induction field shape function.
147  TF1* fIndVFieldFunc; ///< Parameterized induction field shape function.
148  TH1F *fFieldResponseHist[3]; ///< Histogram used to hold the field response, hardcoded for the time being
149  TH1D *fFilterHist[3]; ///< Histogram used to hold the collection filter, hardcoded for the time being
150 
151  // Following attributes hold the convolution and deconvolution kernels
152 
156 
157  // Field response.
158 
159  std::vector<double> fColFieldResponse;
160  std::vector<double> fIndUFieldResponse;
161  std::vector<double> fIndVFieldResponse;
162 
163  // Electronics response.
164 
165  std::vector<double> fElectResponse;
166 
167  // Filters.
168 
169  std::vector<TComplex> fColFilter;
170  std::vector<TComplex> fIndUFilter;
171  std::vector<TComplex> fIndVFilter;
172 
173  bool fDebugFieldShape; ///< Save field response shape to a text file.
174 
175  };
176 }
177 //----------------------------------------------------------------------
178 // Do convolution.
179 template <class T> inline void util::SignalShapingServiceDUNE35t::Convolute(detinfo::DetectorClocksData const& clockData,
180  unsigned int channel, std::vector<T>& func) const
181 {
182  SignalShaping(channel).Convolute(func);
183 
184  //negative number
185  int time_offset = FieldResponseTOffset(clockData, channel);
186 
187  std::vector<T> temp;
188  if (time_offset <=0){
189  temp.assign(func.begin(),func.begin()-time_offset);
190  func.erase(func.begin(),func.begin()-time_offset);
191  func.insert(func.end(),temp.begin(),temp.end());
192  }else{
193  temp.assign(func.end()-time_offset,func.end());
194  func.erase(func.end()-time_offset,func.end());
195  func.insert(func.begin(),temp.begin(),temp.end());
196  }
197 }
198 
199 
200 //----------------------------------------------------------------------
201 // Do deconvolution.
202 template <class T> inline void util::SignalShapingServiceDUNE35t::Deconvolute(detinfo::DetectorClocksData const& clockData,
203  unsigned int channel, std::vector<T>& func) const
204 {
205  SignalShaping(channel).Deconvolute(func);
206 
207  int time_offset = FieldResponseTOffset(clockData, channel);
208 
209  std::vector<T> temp;
210  if (time_offset <=0){
211  temp.assign(func.end()+time_offset,func.end());
212  func.erase(func.end()+time_offset,func.end());
213  func.insert(func.begin(),temp.begin(),temp.end());
214  }else{
215  temp.assign(func.begin(),func.begin()+time_offset);
216  func.erase(func.begin(),func.begin()+time_offset);
217  func.insert(func.end(),temp.begin(),temp.end());
218  }
219 }
220 
222 #endif
TF1 * fIndUFilterFunc
Parameterized induction filter function.
TF1 * fIndVFieldFunc
Parameterized induction field shape function.
void Deconvolute(std::vector< T > &func) const
TF1 * fColFieldFunc
Parameterized collection field shape function.
Namespace for general, non-LArSoft-specific utilities.
std::vector< double > fShapeTimeConst
time constants for exponential shaping
TF1 * fColFilterFunc
Parameterized collection filter function.
bool fDebugFieldShape
Save field response shape to a text file.
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
double fColFieldRespAmp
amplitude of response to field
void Deconvolute(detinfo::DetectorClocksData const &clockData, unsigned int channel, std::vector< T > &func) const
void Convolute(std::vector< T > &func) const
bool fGetFilterFromHisto
Flag that allows to use a filter function from a histogram instead of the functional dependency...
Generic class for shaping signals on wires.
virtual void reconfigure(fhicl::ParameterSet const &pset)
#define DECLARE_ART_SERVICE(svc, scope)
TF1 * fIndUFieldFunc
Parameterized induction field shape function.
double fIndVFieldRespAmp
amplitude of response to field
bool fUseHistogramFieldShape
Flag that turns on field response shapes from histograms.
General LArSoft Utilities.
void Convolute(detinfo::DetectorClocksData const &clockData, unsigned int channel, std::vector< T > &func) const
std::vector< double > fFieldResponseTOffset
Time offset for field response in ns.
TF1 * fIndVFilterFunc
Parameterized induction filter function.
Contains all timing reference information for the detector.
double fADCPerPCAtLowestASICGain
Pulse amplitude gain for a 1 pc charge impulse after convoluting it the with field and electronics re...
def func()
Definition: docstring.py:7
double fIndUFieldRespAmp
amplitude of response to field
double fInputFieldRespSamplingPeriod
Sampling period in the input field response.
int fNFieldBins
number of bins for field response
std::vector< double > DoubleVec