ATLAS Offline Software
Amplifier.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <cmath>
8 
10  m_integrationWindow(0),
11  m_integral(0.),
12  m_adcResponse(0.)
13 {
15 }
16 
18 = default;
19 
21 {
22  m_threshold = 0.;
23  m_responseMax = 0.;
24  m_triggerElectron = 20.;
25  m_adcOffset = 30.;
26  m_adcFactor = 90.;
27  m_adcFraction = 10.;
28  m_binsize = 1.;
29  //std::cout << "Amplifier Threshold " << m_triggerElectron << std::endl;
30 }
31 
33 {
34  /*
35  amplifier f(t) = (t/tau)**3 exp(-t/tau) u(t)
36 
37  signal I(t) = I0/(t+t0) u(t)
38 
39  u(t) step function
40  tau 15 ns, t0=12 nsec, I0=1
41 
42  */
43  //double TP=20.;
44  double TP=15.;
45  double T0=12./2.;
46  /*
47  FI1=1./3.
48  FI2=2./3.
49  signal = ( FI1 exp(t/t0)/t0 + FI2 exp(-t/(9*t0))/(9*t0))
50  ion/electron fraction electron delta function ion signal
51  */
52  double FI1=1./3.;
53  double FI2=2./3.;
54  double face=2.0;
55 
56  /* third order amplifier
57 
58  f(t)= u(t) * t/tau**3* exp(-t/tau)/3!/tau
59  I(t)= u(t) * exp(-t/t0)/ t0
60 
61  */
62  double TAU=TP/3.;
63  double a=1./TAU;
64  double b =1./T0;
65  double a4 = a*a*a*a;
66  double ab4 = a-b;
67  ab4 = ab4*ab4*ab4*ab4;
68  double dt = (a-b)*time;
69  double dt2 = dt*dt;
70  double dt3 = dt2*dt;
71  // double dt4 = dt2*dt2; // not used
72 
73  double F3 = a4*time*time*time*exp(-a*time)/6.;
74  double xnor = b*a4/ab4;
75  double res31= xnor*(exp(-b*time) - exp(-a*time)
76  -dt*exp(-a*time)
77  -dt2/2.*exp(-a*time)
78  -dt3/6.*exp(-a*time));
79 
80  b =1./T0/9.;
81  ab4 = a-b;
82  ab4 = ab4*ab4*ab4*ab4;
83  dt = (a-b)*time;
84  dt2 = dt*dt;
85  dt3 = dt2*dt;
86  // dt4 = dt2*dt2; // not used
87  xnor = b*a4/ ab4;
88  double res32= xnor*(exp(-b*time) - exp(-a*time)
89  -dt*exp(-a*time)
90  -dt2/2.*exp(-a*time)
91  -dt3/6.*exp(-a*time));
92  double resolution=(face*(res31*FI1+res32*FI2)+F3)/(1.+face);
93 
94  return resolution;
95 }
96 
97 void Amplifier::InitResponse(unsigned int bins, double binsize)
98 {
99  m_binsize = binsize;
100  m_integrationWindow = (int)(20./binsize)-1 ;
101 
102  m_response.resize(bins);
103  m_signal.resize(bins);
104  //std::cout << "Amplifier Initialize: new response vector with " << m_response.size() << " bins" << std::endl;
105 
106  cluster_vec_it it = m_response.begin();
107  double i(0.);
108  double resp(0),max(0.);//,integral(0.);
109  while( it != m_response.end() ){
111  if(resp>max) max = resp;
112  //integral+=resp;
113  *it = resp;
114  ++it;++i;
115  }
116  m_responseMax = max;
118  //std::cout << "max " << max << " integral " << integral << " threshold " << m_threshold <<std::endl;
119  Reset();
120 }
121 
123 {
124  m_integral = -10000.;
126  for( ; dit != m_signal.end(); ++dit)
127  *dit = 0.;
128  m_signal_th = m_signal.begin();
129  m_signal_stop = m_signal.end();
130 }
131 
132 bool Amplifier::AddClusters(const std::vector<double>& clusters)
133 {
134  if(clusters.empty()){ // no clusters, no signal!
135  return false;
136  }
137 
138  // reset cluster iterators
139  m_cluster_begin = clusters.begin();
140  m_cluster_stop = clusters.end(); // stop iterator can be changed in the AddCluster-routine
142  int bin(0);
143  for( ; cit!=m_cluster_stop;++cit){ // iterate over all clusters
144  if(*cit == 0.) continue; // check if the cluster size in the current bin is not zero
145  bin = cit - m_cluster_begin; // calculate the corresponding bin number
146  AddCluster(bin,*cit); // add response of cluster to total detector response
147  }
148  Integral(); // calculate the Q-integral
149  DoAdcResponse(); // get the ADC response
150 
151  return PassedThreshold();
152 }
153 
154 void Amplifier::AddCluster(int startbin, double charge)
155 {
156  // set start values for signal and response iterator
157  cluster_vec_it response_it = m_response.begin();
158  cluster_vec_it signal_it = m_signal.begin() + startbin;
159 
160  // fill signal vector until stop
161  while(signal_it != m_signal_stop) {
162 
163  *signal_it += *response_it*charge; // add response to signal
164  if( *signal_it > m_threshold ) { // check if signal above threshold
165 
166  // if new threshold found
167  if( signal_it - m_signal_th < 0 || m_signal_th == m_signal.begin()){
168  m_signal_th = signal_it; // store new threshold
169 
170  /* if the bin (threshold + integration window) lies
171  within the signal vector, point the stop iterator to it.
172  nessicary to make sure m_signal_stop never points beyond the m_signal.end() */
173 
174  if( m_signal.end()-signal_it > m_integrationWindow ){
177  }
178  }
179  ++signal_it;++response_it; // go to next bin
180  while(signal_it != m_signal_stop) { // loop over the remaining bins
181  *signal_it += *response_it*charge;
182  ++signal_it;++response_it;
183  }
184  break; // exit loop
185  }
186  ++signal_it;++response_it;
187  }
188 }
189 
191 {
193  m_integral = 0.;
194  while(s != m_signal_stop){ // sum charge within integration window
195  m_integral += *s;
196  ++s;
197  }
198  return m_integral;
199 }
200 
202 {
203  if(m_integral > 0){
205  }else{
206  m_adcResponse = -1000;
207  }
208 }
209 
Amplifier::m_threshold
double m_threshold
Definition: Amplifier.h:56
Amplifier::m_cluster_stop
cluster_vec_const_it m_cluster_stop
Definition: Amplifier.h:70
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Amplifier::InitAmplifierParameters
void InitAmplifierParameters()
Definition: Amplifier.cxx:20
Amplifier.h
Amplifier::ResponseFunction
static double ResponseFunction(double time)
Definition: Amplifier.cxx:32
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Amplifier::cluster_vec_it
std::vector< double >::iterator cluster_vec_it
Definition: Amplifier.h:15
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
Amplifier::PassedThreshold
bool PassedThreshold() const
Definition: Amplifier.h:105
Amplifier::AddCluster
void AddCluster(int bin, double charge)
Definition: Amplifier.cxx:154
skel.it
it
Definition: skel.GENtoEVGEN.py:396
bin
Definition: BinsDiffFromStripMedian.h:43
Amplifier::m_integrationWindow
int m_integrationWindow
Definition: Amplifier.h:57
Amplifier::DoAdcResponse
void DoAdcResponse()
Definition: Amplifier.cxx:201
Amplifier::m_integral
double m_integral
Definition: Amplifier.h:64
Amplifier::AddClusters
bool AddClusters(const cluster_vec &clusters)
Definition: Amplifier.cxx:132
Amplifier::m_adcOffset
double m_adcOffset
Definition: Amplifier.h:75
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
Dedxcorrection::resolution
double resolution[nGasTypes][nParametersResolution]
Definition: TRT_ToT_Corrections.h:46
Amplifier::InitResponse
void InitResponse(unsigned int bins, double binsize)
Definition: Amplifier.cxx:97
Amplifier::m_adcResponse
double m_adcResponse
Definition: Amplifier.h:65
Amplifier::~Amplifier
~Amplifier()
lumiFormat.i
int i
Definition: lumiFormat.py:85
Amplifier::m_adcFactor
double m_adcFactor
Definition: Amplifier.h:76
Amplifier::m_signal_stop
cluster_vec_it m_signal_stop
Definition: Amplifier.h:69
CaloNoise_fillDB.dt
dt
Definition: CaloNoise_fillDB.py:58
Amplifier::m_signal
cluster_vec m_signal
Definition: Amplifier.h:63
Amplifier::Integral
double Integral()
Definition: Amplifier.cxx:190
plotting.yearwise_luminosity_vs_mu.bins
bins
Definition: yearwise_luminosity_vs_mu.py:30
Amplifier::m_triggerElectron
double m_triggerElectron
Definition: Amplifier.h:55
Amplifier::Reset
void Reset()
Definition: Amplifier.cxx:122
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
charge
double charge(const T &p)
Definition: AtlasPID.h:756
Amplifier::m_response
cluster_vec m_response
Definition: Amplifier.h:62
a
TList * a
Definition: liststreamerinfos.cxx:10
Amplifier::cluster_vec_const_it
std::vector< double >::const_iterator cluster_vec_const_it
Definition: Amplifier.h:16
Amplifier::m_binsize
double m_binsize
Definition: Amplifier.h:54
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
Amplifier::Amplifier
Amplifier()
Definition: Amplifier.cxx:9
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
Amplifier::m_adcFraction
double m_adcFraction
Definition: Amplifier.h:77
Amplifier::m_responseMax
double m_responseMax
Definition: Amplifier.h:60
Amplifier::m_cluster_begin
cluster_vec_const_it m_cluster_begin
Definition: Amplifier.h:71
Amplifier::m_signal_th
cluster_vec_it m_signal_th
Definition: Amplifier.h:68