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