ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
ElectronPhotonID
ElectronPhotonFourMomentumCorrection
Root
LinearityADC.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
ElectronPhotonFourMomentumCorrection/LinearityADC.h
"
6
7
#include "TFile.h"
8
9
LinearityADC::LinearityADC
(
const
std::string& filename,
const
std::string& name)
10
:
asg
::
AsgMessaging
(name) {
11
ATH_MSG_INFO
(
"Initialize LinearityADC with file "
<< filename);
12
std::unique_ptr<TFile> adcFile(TFile::Open(filename.c_str(),
"READ"
));
13
static
const
std::map<TString, PATCore::ParticleType::Type> pN = {
14
{
"elec"
,
PATCore::ParticleType::Electron
},
15
{
"unco"
,
PATCore::ParticleType::UnconvertedPhoton
},
16
{
"conv"
,
PATCore::ParticleType::ConvertedPhoton
}};
17
for
(
const
auto
& [ptclName, ptclType] : pN) {
18
m_hcorr
[ptclType].reset(
dynamic_cast<
TProfile2D*
>
(
19
adcFile->Get(Form(
"linearity_%s"
, ptclName.Data()))));
20
m_hcorr
[ptclType]->SetDirectory(
nullptr
);
21
}
22
adcFile->Close();
23
}
24
25
//===============================================================================
26
float
LinearityADC::getCorr
(
float
etaCalo,
float
et
,
27
PATCore::ParticleType::Type
pType)
const
{
28
float
corr = 0.;
29
float
etGeV =
et
/ 1000.;
30
if
(etGeV < 6.)
31
etGeV = 6.;
32
if
(etGeV > 2999.)
33
etGeV = 2999.;
34
35
auto
it =
m_hcorr
.find(pType);
36
if
(it ==
m_hcorr
.end()) {
37
ATH_MSG_ERROR
(
"unknown particle type "
<< pType);
38
return
1.;
39
}
40
TProfile2D* hh = it->second.get();
41
42
float
aeta = std::abs(etaCalo);
43
if
(aeta > 2.49)
44
aeta = 2.49;
45
46
int
ix = hh->GetXaxis()->FindBin(aeta);
47
int
iy = hh->GetYaxis()->FindBin(etGeV);
48
float
y
= hh->GetYaxis()->GetBinCenter(iy);
49
int
iy0, iy1;
50
if
(
y
> etGeV) {
51
iy0 = iy - 1;
52
iy1 = iy;
53
}
else
{
54
iy0 = iy;
55
iy1 = iy + 1;
56
}
57
58
int
iyc = hh->GetYaxis()->FindBin(40.);
59
60
if
(iy0 < 1)
61
corr = hh->GetBinContent(ix, iy1);
62
if
(iy1 > hh->GetYaxis()->GetNbins())
63
corr = hh->GetBinContent(ix, iy0);
64
65
float
y0 = hh->GetYaxis()->GetBinCenter(iy0);
66
float
y1 = hh->GetYaxis()->GetBinCenter(iy1);
67
// subtract effect for 40 GeV Et electrons
68
it =
m_hcorr
.find(
PATCore::ParticleType::Electron
);
69
if
(it ==
m_hcorr
.end()){
70
ATH_MSG_ERROR
(
"Unknown particle type "
<< pType<<
" in LinearityADC::getCorr"
);
71
return
1.;
72
}
73
float
c0 = hh->GetBinContent(ix, iy0) - it->second->GetBinContent(ix, iyc);
74
float
c1 = hh->GetBinContent(ix, iy1) - it->second->GetBinContent(ix, iyc);
75
76
corr = (c1 * (etGeV - y0) + c0 * (y1 - etGeV)) / (y1 - y0);
77
ATH_MSG_VERBOSE
(
"correction from ADC non linearity = "
<< corr);
78
79
return
(1. + corr);
80
}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x,...)
Definition
AthMsgStreamMacros.h:42
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
LinearityADC.h
y
#define y
LinearityADC::m_hcorr
std::map< PATCore::ParticleType::Type, std::unique_ptr< TProfile2D > > m_hcorr
Definition
LinearityADC.h:42
LinearityADC::getCorr
float getCorr(float etaCalo, float et, PATCore::ParticleType::Type ptype=PATCore::ParticleType::Electron) const
get relative correction factor to apply to energy: corrected energy should be original energy * corre...
Definition
LinearityADC.cxx:26
LinearityADC::LinearityADC
LinearityADC(const std::string &filename, const std::string &name="ADCNonLinearityCorrection")
constructor (initialization done there reading a root file for the HV maps per period
Definition
LinearityADC.cxx:9
asg::AsgMessaging::AsgMessaging
AsgMessaging(const std::string &name)
Constructor with a name.
Definition
AsgMessaging.cxx:17
PATCore::ParticleType::Type
Type
Definition
PATCoreEnums.h:35
PATCore::ParticleType::ConvertedPhoton
@ ConvertedPhoton
Definition
PATCoreEnums.h:39
PATCore::ParticleType::Electron
@ Electron
Definition
PATCoreEnums.h:40
PATCore::ParticleType::UnconvertedPhoton
@ UnconvertedPhoton
Definition
PATCoreEnums.h:38
asg
Definition
DataHandleTestTool.h:28
et
Extra patterns decribing particle interation process.
Generated on
for ATLAS Offline Software by
1.17.0