ATLAS Offline Software
PhysicsAnalysis
JetTagging
FlavourTaggingTests
util
test-associated-iparticles.cxx
Go to the documentation of this file.
1
// Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2
3
#include "
xAODRootAccess/Init.h
"
4
#include "
xAODRootAccess/tools/ReturnCheck.h
"
5
#include "
xAODRootAccess/TEvent.h
"
6
#include "
xAODJet/JetContainer.h
"
7
#include "
xAODTracking/TrackParticle.h
"
8
9
#include "
AsgMessaging/MessageCheck.h
"
10
11
#include "TFile.h"
12
#include "TTree.h"
13
#include "TError.h"
14
15
int
main
ATLAS_NOT_THREAD_SAFE
(
int
argc
,
char
*
argv
[]) {
16
17
ANA_CHECK_SET_TYPE
(
int
);
18
using namespace
asg::msgUserCode;
19
gErrorIgnoreLevel
=
kError
;
20
21
if
(
argc
!= 4) {
22
std::cerr <<
"usage: "
<<
argv
[0] <<
": <DAOD> <jet collection> <associated collection>"
23
<<
"\n\n"
24
<<
"Return codes:\n"
25
<<
" -1: usage error\n"
26
<<
" 1: broken association\n"
27
<<
" 2: some associated objects are not tracks\n"
28
<<
" 0: association works, is all tracks"
<< std::endl;
29
return
-1;
30
}
31
std::string
file
=
argv
[1];
32
std::string jets_name =
argv
[2];
33
std::string linked_particles_name =
argv
[3];
34
35
// The name of the application:
36
const
std::string
APP_NAME
=
"TestAssociatedIparticles"
;
37
38
// Set up the environment:
39
ANA_CHECK
(
xAOD::Init
() );
40
41
// Set up the event object:
42
xAOD::TEvent
event
(
xAOD::TEvent::kClassAccess
);
43
44
// Open the file:
45
std::unique_ptr<TFile>
ifile
(TFile::Open(
file
.c_str(),
"READ"
));
46
if
( !
ifile
.get() ||
ifile
->IsZombie()) {
47
std::cerr <<
"Couldn't open file: "
<<
file
<< std::endl;
48
return
1;
49
}
50
51
// Connect the event object to it:
52
ANA_CHECK
(
event
.
readFrom
(
ifile
.get()) );
53
54
unsigned
long
long
nbad = 0;
55
unsigned
long
long
ngood = 0;
56
unsigned
long
long
nIParticle = 0;
57
unsigned
long
long
nTrack = 0;
58
unsigned
long
long
entries
=
event
.getEntries();
59
for
(
unsigned
long
long
entry
= 0;
entry
<
entries
; ++
entry
) {
60
// Load the event:
61
if
(
event
.
getEntry
(
entry
) < 0) {
62
std::cerr <<
"Couldn't load entry "
<<
entry
<<
" from file"
63
<<
file
<< std::endl;
64
return
1;
65
}
66
const
xAOD::JetContainer
*
jets
=
nullptr
;
67
ANA_CHECK
(
event
.
retrieve
(
jets
, jets_name) );
68
for
(
const
xAOD::Jet
*
const
jet
: *
jets
) {
69
std::vector<const xAOD::IParticle*>
particles
;
70
if
(!
jet
->getAssociatedObjects(linked_particles_name,
particles
)){
71
nbad++;
72
}
else
{
73
ngood++;
74
nIParticle +=
particles
.size();
75
for
(
const
auto
*
part
:
particles
) {
76
if
(
dynamic_cast<
const
xAOD::TrackParticle
*
>
(
part
)) {
77
nTrack++;
78
}
79
}
80
}
81
}
82
}
83
std::cout <<
"Summary: found "
<< ngood <<
" out of "
<< nbad + ngood <<
" jets with valid links to associated particles "
<< std::endl;
84
std::cout <<
"Found "
<< nIParticle <<
" associated xAOD::IParticles, "
85
<< nTrack <<
" of which were tracks"
<< std::endl;
86
if
(nbad > 0)
return
1;
87
if
(nIParticle > nTrack)
return
2;
88
return
0;
89
}
LArG4FSStartPointFilter.part
part
Definition:
LArG4FSStartPointFilter.py:21
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition:
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition:
Control/xAODRootAccess/xAODRootAccess/TEvent.h:100
ReturnCheck.h
main
int main(int, char **)
Main class for all the CppUnit test classes
Definition:
CppUnit_SGtestdriver.cxx:141
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition:
PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:133
jet
Definition:
JetCalibTools_PlotJESFactors.cxx:23
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
POOL::TEvent::getEntry
int getEntry(long entry)
Definition:
PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:185
LArCellNtuple.argv
argv
Definition:
LArCellNtuple.py:152
Analysis::kError
@ kError
Definition:
CalibrationDataVariables.h:60
MessageCheck.h
macros for messaging and checking status codes
APP_NAME
#define APP_NAME
Definition:
BoostedXbbTag.cxx:23
TEvent.h
file
TFile * file
Definition:
tile_monitor.h:29
Init.h
DQHistogramMergeRegExp.argc
argc
Definition:
DQHistogramMergeRegExp.py:20
DataVector
Derived DataVector<T>.
Definition:
DataVector.h:794
GetAllXsec.entry
list entry
Definition:
GetAllXsec.py:132
ATLAS_NOT_THREAD_SAFE
int main ATLAS_NOT_THREAD_SAFE(int argc, char *argv[])
Definition:
test-associated-iparticles.cxx:15
gErrorIgnoreLevel
int gErrorIgnoreLevel
TrackParticle.h
xAOD::Jet_v1
Class describing a jet.
Definition:
Jet_v1.h:57
JetContainer.h
ANA_CHECK_SET_TYPE
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
Definition:
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:314
POOL::TEvent::retrieve
StatusCode retrieve(const T *&obj)
Definition:
PhysicsAnalysis/POOLRootAccess/POOLRootAccess/TEvent.h:74
LArG4FSStartPointFilter.particles
list particles
Definition:
LArG4FSStartPointFilter.py:84
entries
double entries
Definition:
listroot.cxx:49
defineDB.jets
list jets
Definition:
JetTagCalibration/share/defineDB.py:24
LArCellNtuple.ifile
string ifile
Definition:
LArCellNtuple.py:133
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition:
TrackParticle_v1.h:43
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition:
Control/xAODRootAccess/xAODRootAccess/TEvent.h:84
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition:
Init.cxx:31
Generated on Sun Dec 22 2024 21:19:11 for ATLAS Offline Software by
1.8.18