ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
HeavyIonPhys
HIEventUtils
Root
ZdcRecTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
HIEventUtils/ZdcRecTool.h
"
7
#include "TGraph.h"
8
#include "TEnv.h"
9
#include "TSystem.h"
10
11
namespace
ZDC
12
{
13
14
ZdcRecTool::ZdcRecTool
(
const
std::string& name) :
asg
::
AsgTool
(name),
15
m_name
(name),
16
m_init
(false)
17
{
18
declareProperty
(
"ZdcModuleContainerName"
,
m_zdcModuleContainerName
=
"ZdcModules"
,
"Location of ZDC processed data"
);
19
declareProperty
(
"ZdcRecConfigPath"
,
m_zdcRecConfigPath
=
"$ROOTCOREDIR/data/HIEventUtils/"
,
"ZDC Rec config file path"
);
20
21
ATH_MSG_DEBUG
(
"Creating ZdcRecoTool named "
<<
m_name
);
22
ATH_MSG_INFO
(
"ZDC config file path "
<<
m_zdcRecConfigPath
);
23
24
}
25
26
ZdcRecTool::~ZdcRecTool
()
27
{
28
ATH_MSG_DEBUG
(
"Deleting ZdcRecoTool named "
<<
m_name
);
29
}
30
31
StatusCode
ZdcRecTool::initializeTool
()
32
{
33
m_init
=
true
;
34
m_tf1SincInterp
=
new
TF1(
"SincInterp"
,
SincInterp
,-5.,160.,8);
35
m_tf1SincInterp
->SetNpx(300);
36
m_tf1FermiExpFit
=
new
TF1(
"FermiExpFit"
,
FermiExpFit
,-5.,160.,7);
37
m_tf1FermiExpFit
->SetNpx(300);
38
39
char
* path = gSystem->ExpandPathName(
m_zdcRecConfigPath
.c_str());
40
ATH_MSG_INFO
(
"Resolved file path "
<< path);
41
42
TString zdcConf(path);
43
zdcConf +=
"/ZdcRecConfig.conf"
;
44
45
TEnv env(zdcConf);
46
47
ATH_MSG_INFO
(
"ZdcC calibration LG "
<< env.GetValue(
"ZdcCCalibrationLG"
,
"1.;1.;1.;1."
));
48
49
return
StatusCode::SUCCESS;
50
51
}
52
53
StatusCode
ZdcRecTool::recoZdcModule
(
const
xAOD::ZdcModule
& module)
54
{
55
56
ATH_MSG_DEBUG
(
"Not processing ZDC module S/T/M/C = "
57
<< module.zdcSide() <<
" "
58
<< module.zdcType() <<
" "
59
<< module.zdcModule() <<
" "
60
<< module.zdcChannel()
61
);
62
63
64
return
StatusCode::SUCCESS;
65
}
66
67
StatusCode
ZdcRecTool::recoZdcModules
(
const
xAOD::ZdcModuleContainer
& moduleContainer)
68
{
69
if
(!
m_eventReady
)
70
{
71
ATH_MSG_INFO
(
"Event not ready for ZDC reco!"
);
72
return
StatusCode::FAILURE;
73
}
74
75
for
(
const
auto
zdcModule : moduleContainer)
76
{
77
ATH_CHECK
(
recoZdcModule
(*zdcModule));
78
}
79
return
StatusCode::SUCCESS;
80
}
81
82
StatusCode
ZdcRecTool::reprocessZdc
()
83
{
84
if
(!
m_init
)
85
{
86
ATH_MSG_INFO
(
"Tool not initialized!"
);
87
return
StatusCode::FAILURE;
88
}
89
m_eventReady
=
false
;
90
ATH_CHECK
(
evtStore
()->retrieve(
m_zdcModules
,
m_zdcModuleContainerName
));
91
m_eventReady
=
true
;
92
93
ATH_CHECK
(
recoZdcModules
(*
m_zdcModules
));
94
95
return
StatusCode::SUCCESS;
96
}
97
98
bool
ZdcRecTool::sigprocMaxFinder
(
const
std::vector<unsigned short>& adc,
float
deltaT,
float
& amp,
float
& time,
float
& qual)
99
{
100
size_t
nsamp = adc.size();
101
float
presamp = adc.at(0);
102
unsigned
short
max_adc = 0;
103
int
max_index = -1;
104
for
(
size_t
i = 0;i<nsamp;i++)
105
{
106
if
(adc[i]>max_adc)
107
{
108
max_adc = adc[i];
109
max_index = i;
110
}
111
}
112
amp = max_adc - presamp;
113
time = max_index*deltaT;
114
qual = 1.;
115
116
if
(max_index==-1)
117
{
118
qual=0.;
119
return
false
;
120
}
121
122
return
true
;
123
}
124
125
bool
ZdcRecTool::sigprocPeakFitter
(
const
std::vector<unsigned short>& adc,
float
deltaT,
float
& amp,
float
& time,
float
& qual)
126
{
127
TGraph g;
128
size_t
nsamp = adc.size();
129
float
presamp = adc.at(0);
130
unsigned
short
max_adc = 0;
131
for
(
size_t
i = 0;i<nsamp;i++)
132
{
133
if
(adc.at(i)>max_adc)
134
{
135
max_adc = adc.at(i);
136
}
137
g.SetPoint(i,i*deltaT,adc.at(i)-presamp);
138
}
139
double
timeScale = deltaT/12.5;
140
m_tf1FermiExpFit
->SetParameters(max_adc-presamp,30*timeScale, 2.5*timeScale, 25*timeScale);
141
m_tf1FermiExpFit
->SetParLimits(0,0,1024);
142
m_tf1FermiExpFit
->SetParLimits(1,10*timeScale,50*timeScale);
143
m_tf1FermiExpFit
->FixParameter(2,2.5*timeScale);
144
m_tf1FermiExpFit
->SetParLimits(3,10*timeScale,40*timeScale);
145
g.Fit(
"FermiExpFit"
,
"QWR"
,
""
);
146
amp =
m_tf1FermiExpFit
->GetMaximum();
147
time =
m_tf1FermiExpFit
->GetMaximumX();
148
qual = 1.;
149
return
true
;
150
}
151
152
bool
ZdcRecTool::sigprocSincInterp
(
const
std::vector<unsigned short>& adc,
float
deltaT,
float
& amp,
float
& time,
float
& qual)
153
{
154
size_t
nsamp = adc.size();
155
float
presamp = adc.at(0);
156
m_tf1SincInterp
->SetParameter(0,deltaT);
157
for
(
size_t
i = 0;i<nsamp;i++)
158
{
159
m_tf1SincInterp
->SetParameter(i+1,adc.at(i)-presamp);
160
}
161
amp =
m_tf1SincInterp
->GetMaximum();
162
time =
m_tf1SincInterp
->GetMaximumX();
163
qual = 1.;
164
return
true
;
165
}
166
167
double
SincInterp
(
double
* xvec,
double
*
pvec
)
168
{
169
// pvec are the sample values
170
double
ret = 0;
171
double
T =
pvec
[0];
// deltaT
172
double
t = xvec[0];
173
for
(
int
isamp = 0;isamp<7;isamp++)
174
{
175
double
arg = (t - isamp*T)/T;
176
if
(arg!=0.0)
177
{
178
ret +=
pvec
[isamp+1] * std::sin(TMath::Pi()*arg)/(TMath::Pi()*arg);
179
}
180
}
181
return
ret;
182
}
183
184
double
FermiExpFit
(
double
* xvec,
double
*
pvec
)
185
{
186
const
float
offsetScale = 3;
187
188
double
t = xvec[0];
189
190
double
amp =
pvec
[0];
191
double
t0
=
pvec
[1];
192
double
tau1 =
pvec
[2];
193
double
tau2 =
pvec
[3];
194
195
double
tauRatio = tau2/tau1;
196
double
tauRatioMinunsOne = tauRatio - 1;
197
198
double
norm = ( std::exp(-offsetScale/tauRatio)*pow(1./tauRatioMinunsOne, 1./(1 + tauRatio))/
199
( 1 + pow(1./tauRatioMinunsOne, 1./(1 + 1/tauRatio))) );
200
201
double
deltaT = t - (
t0
- offsetScale*tau1);
202
if
(deltaT < 0) deltaT = 0;
203
204
double
expTerm = std::exp(-deltaT/tau2);
205
double
fermiTerm = 1./(1. + std::exp(-(t -
t0
)/tau1));
206
207
return
amp*expTerm*fermiTerm/norm;
208
}
209
210
}
// namespace ZDC
211
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
pvec
std::array< fp_t, 2 > pvec
Definition
FPGATrackSimLLPDoubletHoughTransformTool.cxx:9
t0
static Double_t t0
Definition
LArPhysWaveHECTool.cxx:38
ZdcRecTool.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
ZDC::ZdcRecTool::sigprocMaxFinder
bool sigprocMaxFinder(const std::vector< unsigned short > &adc, float deltaT, float &, float &time, float &qual)
Definition
ZdcRecTool.cxx:98
ZDC::ZdcRecTool::ZdcRecTool
ZdcRecTool(const std::string &name)
Definition
ZdcRecTool.cxx:14
ZDC::ZdcRecTool::m_tf1FermiExpFit
TF1 * m_tf1FermiExpFit
Definition
ZdcRecTool.h:48
ZDC::ZdcRecTool::m_zdcModuleContainerName
std::string m_zdcModuleContainerName
Definition
ZdcRecTool.h:58
ZDC::ZdcRecTool::m_zdcRecConfigPath
std::string m_zdcRecConfigPath
Definition
ZdcRecTool.h:55
ZDC::ZdcRecTool::m_init
bool m_init
Definition
ZdcRecTool.h:53
ZDC::ZdcRecTool::sigprocSincInterp
bool sigprocSincInterp(const std::vector< unsigned short > &adc, float deltaT, float &, float &time, float &qual)
Definition
ZdcRecTool.cxx:152
ZDC::ZdcRecTool::sigprocPeakFitter
bool sigprocPeakFitter(const std::vector< unsigned short > &adc, float deltaT, float &, float &time, float &qual)
Definition
ZdcRecTool.cxx:125
ZDC::ZdcRecTool::m_eventReady
bool m_eventReady
Definition
ZdcRecTool.h:57
ZDC::ZdcRecTool::m_name
std::string m_name
Definition
ZdcRecTool.h:51
ZDC::ZdcRecTool::m_tf1SincInterp
TF1 * m_tf1SincInterp
Definition
ZdcRecTool.h:47
ZDC::ZdcRecTool::~ZdcRecTool
virtual ~ZdcRecTool()
Definition
ZdcRecTool.cxx:26
ZDC::ZdcRecTool::recoZdcModules
virtual StatusCode recoZdcModules(const xAOD::ZdcModuleContainer &moduleContainer) override
Definition
ZdcRecTool.cxx:67
ZDC::ZdcRecTool::recoZdcModule
virtual StatusCode recoZdcModule(const xAOD::ZdcModule &module) override
Definition
ZdcRecTool.cxx:53
ZDC::ZdcRecTool::reprocessZdc
virtual StatusCode reprocessZdc() override
Definition
ZdcRecTool.cxx:82
ZDC::ZdcRecTool::m_zdcModules
const xAOD::ZdcModuleContainer * m_zdcModules
Definition
ZdcRecTool.h:59
ZDC::ZdcRecTool::initializeTool
virtual StatusCode initializeTool() override
Initialize the tool.
Definition
ZdcRecTool.cxx:31
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
ZDC
Definition
LISAnalysisTool.cxx:19
ZDC::SincInterp
double SincInterp(const double *xvec, const double *pvec)
Definition
ZdcSincInterp.cxx:11
ZDC::FermiExpFit
double FermiExpFit(double *xvec, double *pvec)
Definition
ZdcRecTool.cxx:184
asg
Definition
DataHandleTestTool.h:28
xAOD::ZdcModuleContainer
ZdcModuleContainer_v1 ZdcModuleContainer
Definition
ZdcModuleContainer.h:18
xAOD::ZdcModule
ZdcModule_v1 ZdcModule
Definition
ZdcModule.h:15
Generated on
for ATLAS Offline Software by
1.17.0