SignalShapingServiceDUNEDPhase.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 ///
3 /// \file SignalShapingServiceDUNEDPhase.h
4 ///
5 /// \brief Service to provide DUNE dual-phase signal shaping for
6 /// simulation (convolution) and reconstruction (deconvolution).
7 ///
8 /// \author V. Galymov vgalymov@ipnl.in2p3.fr
9 ///
10 /// This service inherits from SignalShaping and supplies
11 /// DUNE dual-phase specific configuration.
12 /// It is intended that SimWire and CalWire modules will access this service.
13 ///
14 /// The general philosophy to follow is to split fC -> ADC conversion
15 /// in two parts
16 /// - area normalization factor (typicaly in units ADC x us / fC)
17 /// - pulse shaping
18 /// Since the hit charge should be calculated from the integral, the norm
19 /// factor should be an area normalization constant. The shape function
20 /// should then be area-normalized in order to eventually achive a proper
21 /// normalization of the hit integral. Note that in this case even if the
22 /// simulated pulse shape may not be exact, if correctly normalized the
23 /// resulting simulated hit charge should be correct.
24 /// The charge loss due to, for example, the detector capacitance should
25 /// not be included in the calibration constant here but treated elsewhere
26 /// to avoid lumping many effiiciency factors into one ambiguous number
27 ///
28 /// changes:
29 /// 11.20.2019, vgalymov
30 /// Changed pulse normalization to integral instead of amplitude.
31 /// For 3x1x1 the parameters specified in fcl were computed based
32 /// on what was originally put there for 3x1x1. Namely the pulse
33 /// function was calculated with original parameters and its integral
34 /// was then used to specify the area normalization in the service fcl.
35 /// Make the parameters for 1 m view optional, since this corresponds to
36 /// to a rather particular CRP configuration
37 ///
38 /// 02.17.2020, vgalymov
39 /// Updated filter function to sample up-to correct 1.25 MHz
40 /// This service now inherits from SignalShapingService
41 ///
42 ///
43 ////////////////////////////////////////////////////////////////////////
44 
45 #ifndef __SIGNALSHAPINGSERVICEDUNEDPHASE_H__
46 #define __SIGNALSHAPINGSERVICEDUNEDPHASE_H__
47 
49 
50 #include <vector>
51 #include "fhiclcpp/ParameterSet.h"
55 #include "TF1.h"
56 
57 namespace detinfo {
58  class DetectorClocksData;
59 }
60 
61 using DoubleVec = std::vector<double>;
62 
63 namespace util {
64 
66  public:
67 
68  // Constructor, destructor.
72 
73  // Update configuration parameters.
74  void reconfigure(const fhicl::ParameterSet& pset);
75 
76  double GetAreaNorm(unsigned int const channel) const;
77 
78  std::vector<DoubleVec> GetNoiseFactVec() const override;
79  double GetASICGain(Channel channel) const override;
80  double GetShapingTime(Channel channel) const override;
81  double GetRawNoise(Channel channel) const override;
82  double GetDeconNoise(Channel channel) const override;
83  double GetDeconNorm() const override;
84  unsigned int GetSignalSize() const override;
85 
86  //double GetDeconNorm() const {return fDeconNorm;};
87 
88  // Accessors.
89  int FieldResponseTOffset(detinfo::DetectorClocksData const& clockData,
90  unsigned int const channel) const override;
91  const util::SignalShaping& SignalShaping(unsigned int channel) const override;
92 
93  // Do convolution calcution (for simulation).
94  template <class T> void Convolute(unsigned int channel, std::vector<T>& func) const;
95  void Convolute(detinfo::DetectorClocksData const& clockData, Channel channel, FloatVector& func) const override;
96  void Convolute(detinfo::DetectorClocksData const& clockData, Channel channel, DoubleVector& func) const override;
97 
98  // Do deconvolution calcution (for reconstruction).
99  template <class T> void Deconvolute(unsigned int channel, std::vector<T>& func) const;
100  void Deconvolute(detinfo::DetectorClocksData const& clockData, Channel channel, DoubleVector& func) const override;
101  void Deconvolute(detinfo::DetectorClocksData const& clockData, Channel channel, FloatVector& func) const override;
102 
103  private:
104 
105  // Private configuration methods.
106 
107  // Post-constructor initialization.
108  void init() const{const_cast<SignalShapingServiceDUNEDPhase*>(this)->init();}
109  void init();
110 
111 
112  // Calculate response functions.
113  double SetElectResponse( const TF1* fshape, util::SignalShaping &sig, double areanorm );
114  void SetFieldResponse(std::vector<double> &fresp); //<- could be added later
115  double FieldResponse(double tval_us); //harcoded function to calcuate the field response
116 
117  // Calculate filter functions.
118  void SetFilters(detinfo::DetectorClocksData const& clockData);
119 
120  // Sample the response function, including a configurable drift velocity of electrons
121  void SetResponseSampling(detinfo::DetectorClocksData const& clockData,
122  util::SignalShaping &sig );
123 
124  // Attributes.
125  bool fInit; ///< Initialization flag.
126 
127  // Fcl parameters.
128  double fDeconNorm;
129  double fRespSamplingPeriod; ///< Sampling period for response in ns
130  double fAreaNorm; ///< in units (ADC x us) / fC
131  double fPulseHeight; ///< pulse height in mV per fC
133 
134  double fADCpermV; ///< Digitizer scale
135  double fAmpENC; ///< noise in num of electrons used where???
136  double fAmpENCADC; ///< noise rescaled to ADC
137 
138 
139  // the 3x1x1 stuff
140  bool fHave1mView;
141  double fAreaNorm1m; ///< in units (ADC x us) / fC for 1m strips
142  double fPulseHeight1m; ///< pulse amtplitide in mV per fC
144 
145 
146  ///
147  TF1* fColShapeFunc; // Parameterized collection shaping function
148  TF1* fColShapeFunc1m; // Parameterized collection shaping function for 1m 3x1x1 strips
149 
150  // Field response
151  bool fAddFieldFunction; ///< Enable the filed function
152  TF1* fColFieldFunc; ///< Parameterized collection field function.
153  double fColFieldRespAmp; ///< amplitude of response to field
154 
155  //
156  // Following attributes hold the convolution and deconvolution kernels
158 
159  //
160  util::SignalShaping fColSignalShaping1m; /// for 3x1x1 1m strips
161 
162  // Filters.
163  TF1* fColFilterFunc; ///< Parameterized collection filter function.
164  std::vector<TComplex> fColFilter;
165  std::vector<double>fParArray;
166  };
167 }
168 
169 //----------------------------------------------------------------------
170 // Do convolution.
171 template <class T> inline void util::SignalShapingServiceDUNEDPhase::Convolute(unsigned int channel, std::vector<T>& func) const
172 {
173  SignalShaping(channel).Convolute(func);
174 }
175 
176 
177 
178 //----------------------------------------------------------------------
179 // Do deconvolution.
180 template <class T> inline void util::SignalShapingServiceDUNEDPhase::Deconvolute(unsigned int channel,
181 std::vector<T>& func) const
182 {
183  SignalShaping(channel).Deconvolute(func);
184 }
185 
186 
188 #endif
void Deconvolute(std::vector< T > &func) const
Namespace for general, non-LArSoft-specific utilities.
std::string string
Definition: nybbler.cc:12
std::vector< float > FloatVector
double fAmpENC
noise in num of electrons used where???
double fRespSamplingPeriod
Sampling period for response in ns.
uint8_t channel
Definition: CRTFragment.hh:201
init
Definition: train.py:42
void Convolute(std::vector< T > &func) const
double fPulseHeight1m
pulse amtplitide in mV per fC
Generic class for shaping signals on wires.
virtual void reconfigure(fhicl::ParameterSet const &pset)
bool fAddFieldFunction
Enable the filed function.
#define DECLARE_ART_SERVICE(svc, scope)
void Convolute(unsigned int channel, std::vector< T > &func) const
General LArSoft Utilities.
TF1 * fColFieldFunc
Parameterized collection field function.
std::vector< double > DoubleVector
Contains all timing reference information for the detector.
def func()
Definition: docstring.py:7
double fColFieldRespAmp
amplitude of response to field
double fAreaNorm1m
in units (ADC x us) / fC for 1m strips
std::vector< double > DoubleVec
void Deconvolute(unsigned int channel, std::vector< T > &func) const