coldelecResponse.h
Go to the documentation of this file.
1 // coldelecReponse.cxx
2 //
3 // David Adams
4 // May 2018
5 // -----
6 // From Brett Viren May 2018
7 // Cold Electronics response function.
8 // How was this function derived?
9 // 1. Hucheng provided a transfer function of our electronics, which
10 // is the Laplace transformation of the shaping function.
11 // 2. We did a anti-Laplace inverse of the shaping function
12 // 3. The one you saw in the code is basically the result of the inversion
13 // - time is time in system of units
14 // - gain in units of volts/charge gives peak value of the response to
15 // a delta function of current integrating to unit charge.
16 // - shaping is the shaping time in system of units
17 // - the hard-coded numbers are the result of the inverting the
18 // Lapalace transformation in Mathematica.
19 // -----
20 //
21 // See section 2.2 of C. Adams et al, JINST 13 P07007 (2018).
22 
23 #ifndef coldelecReponse_H
24 #define coldelecReponse_H
25 
26 #include "TF1.h"
27 #include <string>
28 
29 inline
30 double coldelecResponse(double time, double gain, double shaping) {
31  if (time <=0 || time >= 10*shaping) { // range of validity
32  return 0.0;
33  }
34 
35  const double reltime = time/shaping;
36 
37  // a scaling is needed to make the anti-Lapalace peak match the expected gain
38  // fixme: this scaling is slightly dependent on shaping time. See response.py
39  gain *= 10*1.012;
40 
41  return 4.31054*exp(-2.94809*reltime)*gain
42  -2.6202*exp(-2.82833*reltime)*cos(1.19361*reltime)*gain
43  -2.6202*exp(-2.82833*reltime)*cos(1.19361*reltime)*cos(2.38722*reltime)*gain
44  +0.464924*exp(-2.40318*reltime)*cos(2.5928*reltime)*gain
45  +0.464924*exp(-2.40318*reltime)*cos(2.5928*reltime)*cos(5.18561*reltime)*gain
46  +0.762456*exp(-2.82833*reltime)*sin(1.19361*reltime)*gain
47  -0.762456*exp(-2.82833*reltime)*cos(2.38722*reltime)*sin(1.19361*reltime)*gain
48  +0.762456*exp(-2.82833*reltime)*cos(1.19361*reltime)*sin(2.38722*reltime)*gain
49  -2.620200*exp(-2.82833*reltime)*sin(1.19361*reltime)*sin(2.38722*reltime)*gain
50  -0.327684*exp(-2.40318*reltime)*sin(2.5928*reltime)*gain +
51  +0.327684*exp(-2.40318*reltime)*cos(5.18561*reltime)*sin(2.5928*reltime)*gain
52  -0.327684*exp(-2.40318*reltime)*cos(2.5928*reltime)*sin(5.18561*reltime)*gain
53  +0.464924*exp(-2.40318*reltime)*sin(2.5928*reltime)*sin(5.18561*reltime)*gain;
54 }
55 
56 inline
57 double coldelecResponseFunction(double* x, double* pars) {
58  double gain = pars[0];
59  double time = x[0];
60  double shaping = pars[1];
61  double offset = pars[2];
62  return coldelecResponse(time-offset, gain, shaping);
63 }
64 
65 inline
66 TF1* coldelecResponseTF1(double gainIn, double shapingIn, double t0, std::string fname ="ceresp") {
67  double gain = gainIn != 0.0 ? gainIn : 10.0;
68  double shaping = shapingIn > 0 ? shapingIn : 1.0;
69  bool havePars = gainIn > 0 && shaping > 0.0;
70  //TF1* pf = new TF1(fname.c_str(), coldelecResponseFunction, t0, t0+10.0, 3, 1, false);
71  TF1* pf = new TF1(fname.c_str(), coldelecResponseFunction, t0, t0+10.0*shaping, 3);
72  pf->SetParName(0, "Height");
73  pf->SetParName(1, "Shaping");
74  pf->SetParName(2, "T0");
75  pf->SetParameter(0, gain);
76  pf->SetParameter(1, shaping);
77  pf->SetParameter(2, t0);
78  double limfac = havePars ? 2.0 : 10.0;
79  if ( gain > 0.0 ) {
80  pf->SetParLimits(0, gain/limfac, limfac*gain);
81  } else {
82  pf->SetParLimits(0, limfac*gain, gain/limfac);
83  }
84  pf->SetParLimits(1, shaping/limfac, limfac*shaping);
85  return pf;
86 }
87 
88 #endif
code to link reconstructed objects back to the MC truth information
double coldelecResponseFunction(double *x, double *pars)
std::string string
Definition: nybbler.cc:12
double coldelecResponse(double time, double gain, double shaping)
TF1 * coldelecResponseTF1(double gainIn, double shapingIn, double t0, std::string fname="ceresp")
list x
Definition: train.py:276