ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetAnalysisTools
JetTileCorrection
util
JetTileCorrectionTester.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
10
11
12
// System includes
13
#include <memory>
14
#include <cstdlib>
15
16
// ROOT includes
17
#include "TFile.h"
18
#include "TError.h"
19
#include "TString.h"
20
21
// Infrastructure includes
22
#ifdef ROOTCORE
23
# include "
xAODRootAccess/Init.h
"
24
# include "
xAODRootAccess/TEvent.h
"
25
#endif
// ROOTCORE
26
27
// EDM includes
28
#include "
xAODEventInfo/EventInfo.h
"
29
#include "
xAODJet/JetContainer.h
"
30
#include "
xAODCore/ShallowCopy.h
"
31
32
#include <
AsgTools/StandaloneToolHandle.h
>
33
#include "
AsgTools/AsgTool.h
"
34
#include "
PATInterfaces/CorrectionCode.h
"
35
36
37
// Local includes
38
#include "
JetTileCorrection/JetTileCorrectionTool.h
"
39
40
using namespace
JTC
;
41
42
//-----------------------------------------------------------------------------
43
// Error checking macro
44
//-----------------------------------------------------------------------------
45
#define CHECK( ARG ) \
46
do { \
47
const bool result = ARG; \
48
if(!result) { \
49
::Error(APP_NAME, "Failed to execute: \"%s\"", \
50
#ARG ); \
51
return 1; \
52
} \
53
} while( false )
54
55
56
//-----------------------------------------------------------------------------
57
// Global accessors and decorators
58
//-----------------------------------------------------------------------------
59
static
SG::AuxElement::Accessor<unsigned int>
acc_tileok
(
"TileStatus"
);
60
static
SG::AuxElement::Accessor<float>
acc_ptraw
(
"Ptraw"
);
61
62
//-----------------------------------------------------------------------------
63
// Main function
64
//-----------------------------------------------------------------------------
65
int
main
(
int
argc,
char
* argv[] )
66
{
67
68
// The application's name
69
const
char
*
APP_NAME
= argv[ 0 ];
70
71
// Check if we received a file name
72
if
(argc < 2) {
73
Error(
APP_NAME
,
"No file name received!"
);
74
Error(
APP_NAME
,
" Usage: %s [xAOD file name] [num events]"
,
APP_NAME
);
75
return
1;
76
}
77
78
// Initialise the application
79
CHECK
(
xAOD::Init
(
APP_NAME
) );
80
StatusCode::enableFailure();
81
82
// Open the input file
83
const
TString fileName = argv[ 1 ];
84
Info(
APP_NAME
,
"Opening file: %s"
, fileName.Data());
85
std::unique_ptr<TFile> ifile(TFile::Open(fileName,
"READ"
));
86
CHECK
( ifile.get() );
87
88
// Create a TEvent object
89
xAOD::TEvent
event(
xAOD::TEvent::kAthenaAccess
);
90
xAOD::TStore
store;
91
CHECK
( event.readFrom(ifile.get()) );
92
Info(
APP_NAME
,
"Number of events in the file: %i"
,
93
static_cast<
int
>
(event.getEntries()));
94
95
// Decide how many events to run over
96
Long64_t
entries
=
event
.getEntries();
97
if
(argc > 2) {
98
const
Long64_t e = atoll(argv[2]);
99
entries
= std::min(e,
entries
);
100
}
101
102
// Initialize the tool
103
asg::StandaloneToolHandle<CP::IJetTileCorrectionTool>
tool_jtc;
104
tool_jtc.
setTypeAndName
(
"CP::JetTileCorrectionTool/JetTileCorrectionTool"
);
105
106
//Set properties if needed
107
CHECK
( tool_jtc.
setProperty
(
"CorrectionFileName"
,
"JetTileCorrection/JetTile_pFile_010216.root"
) );
//default anyway
108
// std::vector<std::string> dead_modules = {"1 04","1 05","1 06","1 07","1 08","1 09",
109
// "2 04","2 05","2 06","2 07","2 08","2 09" }; // LBA/C5-10 : NOT REAL SCENARIO !! just trying to get some magnified effect for testing!
110
// CHECK( tool_jtc.setProperty("UserMaskedRegions", dead_modules));
111
112
CHECK
( tool_jtc.
retrieve
() );
113
114
// Loop over the events
115
std::cout <<
"Starting loop"
<< std::endl;
116
for
(Long64_t entry = 0; entry <
entries
; ++entry){
117
118
event
.getEntry(entry);
119
120
// Print some event information for fun
121
const
xAOD::EventInfo
* evtInfo = 0;
122
CHECK
( event.retrieve(evtInfo,
"EventInfo"
) );
123
if
( entry%100==0 ){
124
Info(
APP_NAME
,
"===>>> Processing entry %lli, run %u, event %lu <<<==="
,
125
entry, evtInfo->
runNumber
(), evtInfo->
eventNumber
());
126
}
127
128
// Get jets
129
const
xAOD::JetContainer
* jets = 0;
130
CHECK
( event.retrieve(jets,
"AntiKt4EMTopoJets"
) );
131
132
auto
[jets_sc, jets_scaux] =
xAOD::shallowCopy
( *jets );
133
134
for
(
xAOD::Jet
*
jet
: *jets_sc ){
135
136
if
(
jet
->pt() < 20000. || fabs(
jet
->eta()) > 2.8)
continue
;
137
138
//--- apply tile dead module correction
139
const
CP::CorrectionCode
retCode = tool_jtc->applyCorrection(*
jet
);
140
141
if
( retCode ==
CP::CorrectionCode::OutOfValidityRange
){
142
Warning(
"JetTileCorrectionTester"
,
"No valid pt/eta range. No correction applied."
);
// It might get too verbosed, just here to illustrate all return values.
143
}
144
else
if
( retCode !=
CP::CorrectionCode::Ok
){
145
Error(
"JetTileCorrectionTester"
,
"Failed to apply JetTileCorrection!"
);
146
//return StatusCode::FAILURE;
147
}
148
149
unsigned
int
j_status =
acc_tileok
(*
jet
);
150
151
std::string str_status=
""
;
152
if
(j_status == (
unsigned
int
)
JTC::TS::GOOD
)
153
str_status =
"NotAffected"
;
154
else
if
(j_status == (
unsigned
int
)
JTC::TS::EDGE
)
155
str_status =
"EdgeAffected"
;
156
else
if
(j_status == (
unsigned
int
)
JTC::TS::CORE
)
157
str_status =
"CoreAffected"
;
158
else
159
str_status =
"Unknown"
;
160
161
Info(
APP_NAME
,
"Jet status : %s, Pt raw = %.3f GeV, Pt corrected %.3f GeV"
, str_status.c_str(),
acc_ptraw
(*
jet
)*0.001,
jet
->pt()*0.001);
162
}
163
164
165
166
// //Check status only
167
// tool_jtc->setRJET(0.1); //change jet radius (for tile status checks only!)
168
// for( xAOD::Jet* jet : *jets_sc ){
169
170
// JTC::TS j_status = tool_jtc->getTileStatus(*jet);
171
172
// //or well:
173
// //CHECK( tool_jtc->addTileStatus(*jet) );
174
// //unsigned int j_status = acc_tileok(*jet);
175
176
// std::string str_status="";
177
// if(j_status == JTC::TS::GOOD)
178
// str_status = "NotAffected";
179
// else if(j_status == JTC::TS::EDGE)
180
// str_status = "EdgeAffected";
181
// else if(j_status == JTC::TS::CORE)
182
// str_status = "CoreAffected";
183
// else
184
// str_status = "Unknown";
185
186
// Info(APP_NAME, "Jet status : %s, Pt raw = %.3f GeV, Pt corrected %.3f GeV", str_status.c_str(), acc_ptraw(*jet)*0.001, jet->pt()*0.001);
187
188
// }
189
// //back to default
190
// tool_jtc->setRJET(0.4);
191
192
}
193
194
Info(
APP_NAME
,
"Application finished successfully"
);
195
196
return
0;
197
}
AsgTool.h
APP_NAME
#define APP_NAME
Definition
BoostedXbbTag.cxx:25
TEvent.h
CorrectionCode.h
Init.h
JetContainer.h
acc_tileok
static const SG::Accessor< unsigned int > acc_tileok("TileStatus")
acc_ptraw
static const SG::Accessor< float > acc_ptraw("Ptraw")
CHECK
#define CHECK(ARG)
Definition
JetTileCorrectionTester.cxx:45
JetTileCorrectionTool.h
ShallowCopy.h
StandaloneToolHandle.h
CP::CorrectionCode
Return value from object correction CP tools.
Definition
CorrectionCode.h:31
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition
CorrectionCode.h:37
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition
CorrectionCode.h:38
asg::StandaloneToolHandle
an "initializing" ToolHandle for stand-alone applications
Definition
StandaloneToolHandle.h:44
asg::StandaloneToolHandle::setProperty
StatusCode setProperty(const std::string &name, T2 &&value)
Definition
StandaloneToolHandle.h:105
asg::StandaloneToolHandle::retrieve
StatusCode retrieve()
initialize the tool, will succeed if the tool was already initialized
Definition
StandaloneToolHandle.h:147
asg::StandaloneToolHandle::setTypeAndName
void setTypeAndName(const std::string &typeAndName)
Definition
StandaloneToolHandle.h:101
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:59
xAOD::TEvent::kAthenaAccess
@ kAthenaAccess
Access containers/objects like Athena does.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:74
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition
TStore.h:45
main
int main()
Definition
hello.cxx:18
entries
double entries
Definition
listroot.cxx:49
JTC
Definition
IJetTileCorrectionTool.h:23
JTC::TS::GOOD
@ GOOD
Definition
IJetTileCorrectionTool.h:27
JTC::TS::EDGE
@ EDGE
Definition
IJetTileCorrectionTool.h:27
JTC::TS::CORE
@ CORE
Definition
IJetTileCorrectionTool.h:27
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition
Init.cxx:31
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
xAOD::shallowCopy
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
EventInfo.h
Generated on
for ATLAS Offline Software by
1.17.0