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