ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonDigitization
MDT_Response
src
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
5
#include "
MDT_Response/Amplifier.h
"
6
7
#include <cmath>
8
9
Amplifier::Amplifier
():
10
m_integrationWindow
(0),
11
m_integral
(0.),
12
m_adcResponse
(0.)
13
{
14
InitAmplifierParameters
();
15
}
16
17
Amplifier::~Amplifier
()
18
=
default
;
19
20
void
Amplifier::InitAmplifierParameters
()
21
{
22
m_threshold
= 0.;
23
m_responseMax
= 0.;
24
m_triggerElectron
= 20.;
25
m_adcOffset
= 35.;
// determined from Z -> mumu data as of 2025
26
m_adcFactor
= 150.;
// determined from Z -> mumu data as of 2025
27
m_adcFraction
= 10.;
28
m_binsize
= 1.;
29
m_integrationWindowNs
= 18.5;
30
}
31
32
double
Amplifier::ResponseFunction
(
double
time)
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)(
m_integrationWindowNs
/binsize)-1;
101
102
m_response
.resize(
bins
);
103
m_signal
.resize(
bins
);
104
105
cluster_vec_it
it =
m_response
.begin();
106
double
i(0.);
107
double
resp(0),
max
(0.);
//,integral(0.);
108
while
( it !=
m_response
.end() ){
109
resp =
m_binsize
*
ResponseFunction
(
m_binsize
*i);
110
if
(resp>
max
)
max
= resp;
111
*it = resp;
112
++it;++i;
113
}
114
m_responseMax
=
max
;
115
m_threshold
=
m_triggerElectron
*
max
;
116
Reset
();
117
}
118
119
void
Amplifier::Reset
()
120
{
121
m_integral
= -10000.;
122
std::vector<double>::iterator dit =
m_signal
.begin();
123
for
( ; dit !=
m_signal
.end(); ++dit)
124
*dit = 0.;
125
m_signal_th
=
m_signal
.begin();
126
m_signal_stop
=
m_signal
.end();
127
}
128
129
bool
Amplifier::AddClusters
(
const
std::vector<double>& clusters)
130
{
131
if
(clusters.empty()){
// no clusters, no signal!
132
return
false
;
133
}
134
135
// reset cluster iterators
136
m_cluster_begin
= clusters.begin();
137
m_cluster_stop
= clusters.end();
// stop iterator can be changed in the AddCluster-routine
138
cluster_vec_const_it
cit =
m_cluster_begin
;
139
int
bin
(0);
140
for
( ; cit!=
m_cluster_stop
;++cit){
// iterate over all clusters
141
if
(*cit == 0.)
continue
;
// check if the cluster size in the current bin is not zero
142
bin
= cit -
m_cluster_begin
;
// calculate the corresponding bin number
143
AddCluster
(
bin
,*cit);
// add response of cluster to total detector response
144
}
145
Integral
();
// calculate the Q-integral
146
DoAdcResponse
();
// get the ADC response
147
148
return
PassedThreshold
();
149
}
150
151
void
Amplifier::AddCluster
(
int
startbin,
double
charge
)
152
{
153
// set start values for signal and response iterator
154
cluster_vec_it
response_it =
m_response
.begin();
155
cluster_vec_it
signal_it =
m_signal
.begin() + startbin;
156
157
// fill signal vector until stop
158
while
(signal_it !=
m_signal_stop
) {
159
160
*signal_it += *response_it*
charge
;
// add response to signal
161
if
( *signal_it >
m_threshold
) {
// check if signal above threshold
162
163
// if new threshold found
164
if
( signal_it -
m_signal_th
< 0 ||
m_signal_th
==
m_signal
.begin()){
165
m_signal_th
= signal_it;
// store new threshold
166
167
/* if the bin (threshold + integration window) lies
168
within the signal vector, point the stop iterator to it.
169
nessicary to make sure m_signal_stop never points beyond the m_signal.end() */
170
171
if
(
m_signal
.end()-signal_it >
m_integrationWindow
){
172
m_signal_stop
=
m_signal_th
+
m_integrationWindow
;
173
m_cluster_stop
=
m_cluster_begin
+ (
m_signal_stop
-
m_signal
.begin());
174
}
175
}
176
++signal_it;++response_it;
// go to next bin
177
while
(signal_it !=
m_signal_stop
) {
// loop over the remaining bins
178
*signal_it += *response_it*
charge
;
179
++signal_it;++response_it;
180
}
181
break
;
// exit loop
182
}
183
++signal_it;++response_it;
184
}
185
}
186
187
double
Amplifier::Integral
()
188
{
189
cluster_vec_it
s =
m_signal_th
;
190
m_integral
= 0.;
191
while
(s !=
m_signal_stop
){
// sum charge within integration window
192
m_integral
+= *s;
193
++s;
194
}
195
return
m_integral
;
196
}
197
198
void
Amplifier::DoAdcResponse
()
199
{
200
if
(
m_integral
> 0){
201
m_adcResponse
=
m_adcOffset
+
m_adcFactor
*(log(
m_integral
)/log(
m_adcFraction
)-1);
202
}
else
{
203
m_adcResponse
= -1000;
204
}
205
}
206
Amplifier.h
TAU
static const int TAU
Definition
AtlasPID.h:79
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
bins
static const std::vector< std::string > bins
Definition
MuonTriggerSFFilesTest.cxx:22
max
#define max(a, b)
Definition
cfImp.cxx:41
Amplifier::DoAdcResponse
void DoAdcResponse()
Definition
Amplifier.cxx:198
Amplifier::ResponseFunction
static double ResponseFunction(double time)
Definition
Amplifier.cxx:32
Amplifier::m_responseMax
double m_responseMax
Definition
Amplifier.h:60
Amplifier::m_adcResponse
double m_adcResponse
Definition
Amplifier.h:65
Amplifier::m_integral
double m_integral
Definition
Amplifier.h:64
Amplifier::m_signal_th
cluster_vec_it m_signal_th
Definition
Amplifier.h:68
Amplifier::InitResponse
void InitResponse(unsigned int bins, double binsize)
Definition
Amplifier.cxx:97
Amplifier::InitAmplifierParameters
void InitAmplifierParameters()
Definition
Amplifier.cxx:20
Amplifier::m_binsize
double m_binsize
Definition
Amplifier.h:53
Amplifier::cluster_vec_const_it
std::vector< double >::const_iterator cluster_vec_const_it
Definition
Amplifier.h:15
Amplifier::m_adcFraction
double m_adcFraction
Definition
Amplifier.h:77
Amplifier::~Amplifier
~Amplifier()
Amplifier::m_signal
cluster_vec m_signal
Definition
Amplifier.h:63
Amplifier::PassedThreshold
bool PassedThreshold() const
Definition
Amplifier.h:104
Amplifier::AddClusters
bool AddClusters(const cluster_vec &clusters)
Definition
Amplifier.cxx:129
Amplifier::m_threshold
double m_threshold
Definition
Amplifier.h:55
Amplifier::m_integrationWindowNs
double m_integrationWindowNs
Definition
Amplifier.h:57
Amplifier::m_triggerElectron
double m_triggerElectron
Definition
Amplifier.h:54
Amplifier::Reset
void Reset()
Definition
Amplifier.cxx:119
Amplifier::cluster_vec_it
std::vector< double >::iterator cluster_vec_it
Definition
Amplifier.h:14
Amplifier::m_adcOffset
double m_adcOffset
Definition
Amplifier.h:75
Amplifier::AddCluster
void AddCluster(int bin, double charge)
Definition
Amplifier.cxx:151
Amplifier::m_signal_stop
cluster_vec_it m_signal_stop
Definition
Amplifier.h:69
Amplifier::Integral
double Integral()
Definition
Amplifier.cxx:187
Amplifier::Amplifier
Amplifier()
Definition
Amplifier.cxx:9
Amplifier::m_cluster_begin
cluster_vec_const_it m_cluster_begin
Definition
Amplifier.h:71
Amplifier::m_cluster_stop
cluster_vec_const_it m_cluster_stop
Definition
Amplifier.h:70
Amplifier::m_adcFactor
double m_adcFactor
Definition
Amplifier.h:76
Amplifier::m_integrationWindow
int m_integrationWindow
Definition
Amplifier.h:56
Amplifier::m_response
cluster_vec m_response
Definition
Amplifier.h:62
bin
Definition
BinsDiffFromStripMedian.h:43
Generated on
for ATLAS Offline Software by
1.17.0