ATLAS Offline Software
Macros | Functions | Variables
test_isolaitonTool.cxx File Reference
#include <iostream>
#include <memory>
#include <cstdlib>
#include <TFile.h>
#include <TTree.h>
#include <TError.h>
#include <TString.h>
#include <TH1F.h>
#include "xAODEventInfo/EventInfo.h"
#include "xAODJet/JetContainer.h"
#include "xAODEgamma/ElectronContainer.h"
#include "xAODEgamma/PhotonContainer.h"
#include "xAODMuon/MuonContainer.h"
#include "xAODMuon/Muon.h"
#include "IsolationTool/CaloIsolationTool.h"
#include "IsolationTool/TrackIsolationTool.h"
#include "IsolationTool/IsolationHelper.h"
#include "InDetTrackSelectionTool/InDetTrackSelectionTool.h"
#include "xAODCore/tools/IOStats.h"
#include "xAODCore/tools/ReadStats.h"

Go to the source code of this file.

Macros

#define CPANALYSISEXAMPLES_ERRORCHECK_H
 
#define CHECK(ARG)
 

Functions

int main (int argc, char **argv)
 

Variables

const float GeV = 1000.
 
const float iGeV = 0.001
 
const float PI = 3.1416
 

Macro Definition Documentation

◆ CHECK

#define CHECK (   ARG)
Value:
do { \
const bool result = ARG; \
if( ! result ) { \
::Error( APP_NAME, "Failed to execute: \"%s\"", \
#ARG ); \
return 1; \
} \
} while( false )

Definition at line 10 of file test_isolaitonTool.cxx.

◆ CPANALYSISEXAMPLES_ERRORCHECK_H

#define CPANALYSISEXAMPLES_ERRORCHECK_H

Definition at line 8 of file test_isolaitonTool.cxx.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 63 of file test_isolaitonTool.cxx.

63  {
64 
66  const char* APP_NAME = "ISOTEST";
67  CHECK( xAOD::Init());
68 
69  TString fileName = "root://eosatlas.cern.ch//eos/atlas/atlastier0/tzero/prod/valid1/PowhegPythia8_AU2CT10_Zmumu/147807/valid1.147807.PowhegPythia8_AU2CT10_Zmumu.recon.AOD.e2658_s1967_s1964_r5787_v114/valid1.147807.PowhegPythia8_AU2CT10_Zmumu.recon.AOD.e2658_s1967_s1964_r5787_v114._000187.1";
70 // TString fileName = "root://eosatlas.cern.ch//eos/atlas/atlastier0/tzero/prod/valid1/PowhegPythia_P2011C_ttbar/117050/valid1.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e2658_s1967_s1964_r5787_v111/valid1.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e2658_s1967_s1964_r5787_v111._000001.4";
71 // TString fileName = "root://eosatlas.cern.ch//eos/atlas/atlastier0/tzero/prod/valid1/PowhegPythia8_AU2CT10_Zee/147806/valid1.147806.PowhegPythia8_AU2CT10_Zee.recon.AOD.e2658_s1967_s1964_r5787_v114/valid1.147806.PowhegPythia8_AU2CT10_Zee.recon.AOD.e2658_s1967_s1964_r5787_v114._000001.1";
72 // TString fileName = "root://eosatlas.cern.ch//eos/atlas/atlastier0/tzero/prod/valid1/PowhegPythia8_AU2CT10_ggH125_gamgam/160009/valid1.160009.PowhegPythia8_AU2CT10_ggH125_gamgam.recon.AOD.e2658_s1967_s1964_r5787_v114/valid1.160009.PowhegPythia8_AU2CT10_ggH125_gamgam.recon.AOD.e2658_s1967_s1964_r5787_v114._000001.1";
73  if(argc>1) {
74  fileName = argv[1];
75  }
76 
77  const TString tag = "t2_";
78  Info( APP_NAME, "Opening file: %s", fileName.Data() );
79  std::unique_ptr< TFile > ifile( TFile::Open( fileName, "READ" ) );
80 
81  CP::IsolationHelper *m_helperTool = new CP::IsolationHelper("helperTool");
82 
83  xAOD::CaloIsolationTool m_caloIsoTool("CaloIsolationTool");
84 // m_caloIsoTool.msg().setLevel( MSG::DEBUG );
85 // m_caloIsoTool.msg().setLevel( MSG::INFO );
86  InDet::InDetTrackSelectionTool selTool( "TrackSelection" );
87  selTool.setProperty("maxZ0SinTheta", 3.);
88  selTool.setProperty("minPt", 1000.);
89  selTool.setProperty("CutLevel", "Loose");
90 
91 
92  xAOD::TrackIsolationTool m_trkIsoTool("TrackIsolationTool");
93 // m_trkIsoTool.msg().setLevel( MSG::INFO );
94 // m_trkIsoTool.msg().setLevel( MSG::DEBUG );
95  m_trkIsoTool.setProperty( "TrackSelectionTool", ToolHandle< InDet::IInDetTrackSelectionTool >(selTool.name()) );
96 
97  if(!m_caloIsoTool.initialize().isSuccess()){
98  Info( APP_NAME, "m_caloIsoTool.initialize() failed");
99  }
100 
101  if(!selTool.initialize().isSuccess()){
102  Info( APP_NAME, "selTool.initialize() failed");
103  }
104 
105  if(!m_trkIsoTool.initialize().isSuccess()){
106  Info( APP_NAME, "m_trkIsoTool.initialize() failed");
107  }
108 
109  vector<xAOD::Iso::IsolationType> isoTypes;
110  isoTypes.push_back(xAOD::Iso::ptcone40);
111  isoTypes.push_back(xAOD::Iso::ptcone30);
112  isoTypes.push_back(xAOD::Iso::ptcone20);
113  xAOD::TrackCorrection corrlist;
114  corrlist.trackbitset.set(static_cast<unsigned int>(xAOD::Iso::coreTrackPtr));
115 
116  vector<xAOD::Iso::IsolationType> isoTypesCalo;
117  isoTypesCalo.push_back(xAOD::Iso::topoetcone40);
118  isoTypesCalo.push_back(xAOD::Iso::topoetcone30);
119  isoTypesCalo.push_back(xAOD::Iso::topoetcone20);
120  xAOD::CaloCorrection corrlist2;
121  corrlist2.calobitset.set(static_cast<unsigned int>(xAOD::Iso::coreCone));
122  corrlist2.calobitset.set(static_cast<unsigned int>(xAOD::Iso::pileupCorrection));
123 
124  vector<xAOD::Iso::IsolationType> isoTypesPFlow;
125  isoTypesPFlow.push_back(xAOD::Iso::neflowisol40);
126  isoTypesPFlow.push_back(xAOD::Iso::neflowisol30);
127  isoTypesPFlow.push_back(xAOD::Iso::neflowisol20);
128  xAOD::CaloCorrection corrlist3;
129  corrlist3.calobitset.set(static_cast<unsigned int>(xAOD::Iso::coreCone));
130  corrlist3.calobitset.set(static_cast<unsigned int>(xAOD::Iso::pileupCorrection));
131 
132  // Create a TEvent object:
134  CHECK(event.readFrom(ifile.get()));
135 
136 
137 // Long64_t maxEVT = 10;
138  Long64_t maxEVT = -1;
139  Long64_t entries = event.getEntries();
140  if((entries < maxEVT) || (maxEVT <= 0)) {
141  maxEVT = entries;
142  }
143  Info( APP_NAME, "%lld events found, %lld events will be processed.", entries, maxEVT);
144  const int INTERVAL = maxEVT > 20000? 10000: maxEVT/10;
145  for( Long64_t entry = 0; entry < maxEVT; ++entry ) {
146  event.getEntry( entry );
147  const xAOD::EventInfo* ei = 0;
148  CHECK( event.retrieve( ei, "EventInfo" ) );
149 
150  // Print some event information for fun:
151  if(entry%INTERVAL==0){
152  Info( APP_NAME, "%lld events processed, on event %llu of run %u", entry, ei->eventNumber(), ei->runNumber() );
153  }
154 
155 
156  // get muon container of interest
157  const xAOD::MuonContainer* muons = 0;
158  CHECK( event.retrieve( muons, "Muons" ) );
159 
160  // get electron container of interest
162  CHECK( event.retrieve( electrons, "Electrons" ) );
163 
164  // get photon container of interest
165  const xAOD::PhotonContainer* photons = 0;
166  CHECK( event.retrieve( photons, "Photons" ) );
167 
168  for(auto muon: *muons){
169  Info(APP_NAME, "---------NEW MUON -------");
171  if(m_trkIsoTool.trackIsolation(result, *muon, isoTypes, corrlist)){
172  for(unsigned int i=0; i<isoTypes.size(); i++){
173  float iso = result.ptcones[i];
174  float isoV = result.ptvarcones_10GeVDivPt[i];
175  float value0 = -999;
176  if(!m_helperTool->isolation(value0, *muon, isoTypes[i])) Info(APP_NAME, "Muon default track iso not got.");
177  Info(APP_NAME, "Muon track isolation %d is %f and %f (=%f?)", i, iso, isoV, value0);
178  }
179  }
180  xAOD::CaloIsolation result2;
181  if(m_caloIsoTool.caloTopoClusterIsolation(result2, *muon, isoTypesCalo, corrlist2)){
182  for(unsigned int i=0; i<isoTypesCalo.size(); i++){
183  float value0 = -999;
184  if(!m_helperTool->isolation(value0, *muon, isoTypesCalo[i], corrlist2.calobitset)) Info(APP_NAME, "Muon coreCone Calo iso not got.");
185  Info(APP_NAME, "Muon topo isolation %d is %f (=%f?)", i, result2.etcones[i], value0);
186  }
187  }
188  xAOD::CaloIsolation result3;
189  if(m_caloIsoTool.neutralEflowIsolation(result3, *muon, isoTypesPFlow, corrlist3)){
190  for(unsigned int i=0; i<isoTypesPFlow.size(); i++){
191  float value0 = -999;
192  if(!m_helperTool->isolation(value0, *muon, isoTypesPFlow[i])) Info(APP_NAME, "Muon default pflow iso not got.");
193  Info(APP_NAME, "Muon neflow isolation %d is %f (=%f?)", i, result3.etcones[i], value0);
194  }
195  }
196  }
197 
198  for(auto electron: *electrons){
199  Info(APP_NAME, "---------NEW ELECTRON -------");
201  if(m_trkIsoTool.trackIsolation(result, *electron, isoTypes, corrlist)){
202  for(unsigned int i=0; i<isoTypes.size(); i++){
203  float iso = result.ptcones[i];
204  float isoV = result.ptvarcones_10GeVDivPt[i];
205  float value0 = -999;
206  if(!m_helperTool->isolation(value0, *electron, isoTypes[i])) Info(APP_NAME, "Electron default track iso not got.");
207  Info(APP_NAME, "Electron track isolation %d is %f and %f (=%f?)", i, iso, isoV, value0);
208  }
209  }
210  xAOD::CaloIsolation result2;
211  if(m_caloIsoTool.caloTopoClusterIsolation(result2, *electron, isoTypesCalo, corrlist2)){
212  for(unsigned int i=0; i<isoTypesCalo.size(); i++){
213  float value0 = -999;
214  if(!m_helperTool->isolation(value0, *electron, isoTypesCalo[i], corrlist2.calobitset)) Info(APP_NAME, "Electron coreCone Calo iso not got.");
215  Info(APP_NAME, "Electron topo isolation %d is %f (=%f?)", i, result2.etcones[i], value0);
216  }
217  }
218  xAOD::CaloIsolation result3;
219  }
220 
221  for(auto photon: *photons){
222  Info(APP_NAME, "---------NEW photon -------");
224  if(m_trkIsoTool.trackIsolation(result, *photon, isoTypes, corrlist)){
225  for(unsigned int i=0; i<isoTypes.size(); i++){
226  float iso = result.ptcones[i];
227  float isoV = result.ptvarcones_10GeVDivPt[i];
228  float value0 = -999;
229  if(!m_helperTool->isolation(value0, *photon, isoTypes[i])) Info(APP_NAME, "photon default track iso not got.");
230  Info(APP_NAME, "Photon track isolation %d is %f and %f (=%f?)", i, iso, isoV, value0);
231  }
232  }
233  xAOD::CaloIsolation result2;
234  if(m_caloIsoTool.caloTopoClusterIsolation(result2, *photon, isoTypesCalo, corrlist2)){
235  for(unsigned int i=0; i<isoTypesCalo.size(); i++){
236  float value0 = -999;
237  if(!m_helperTool->isolation(value0, *photon, isoTypesCalo[i], corrlist2.calobitset)) Info(APP_NAME, "photon coreCone Calo iso not got.");
238  Info(APP_NAME, "Photon topo isolation %d is %f (=%f?)", i, result2.etcones[i], value0);
239  }
240  }
241  xAOD::CaloIsolation result3;
242 
243  }
244  }
245 
246  Info(APP_NAME, "Finished successfully!");
247 
248 // xAOD::IOStats::instance().stats().printSmartSlimmingBranchList();
249 
250  delete m_helperTool;
251 
252  return 0;
253 
254 }

Variable Documentation

◆ GeV

const float GeV = 1000.

Definition at line 59 of file test_isolaitonTool.cxx.

◆ iGeV

const float iGeV = 0.001

Definition at line 60 of file test_isolaitonTool.cxx.

◆ PI

const float PI = 3.1416

Definition at line 61 of file test_isolaitonTool.cxx.

xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
CHECK
#define CHECK(ARG)
Definition: test_isolaitonTool.cxx:9
xAOD::Iso::topoetcone20
@ topoetcone20
Topo-cluster ET-sum.
Definition: IsolationType.h:48
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::Iso::neflowisol20
@ neflowisol20
Neutral eflow isolation.
Definition: IsolationType.h:64
xAOD::TrackCorrection
Definition: IsolationCommon.h:18
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
xAOD::Iso::coreTrackPtr
@ coreTrackPtr
tracks pointer
Definition: Event/xAOD/xAODPrimitives/xAODPrimitives/IsolationCorrection.h:66
CP::IsolationHelper::isolation
bool isolation(float &value, const xAOD::IParticle &par, xAOD::Iso::IsolationType type) const
Definition: IsolationHelper.cxx:37
xAOD::TrackCorrection::trackbitset
Iso::IsolationTrackCorrectionBitset trackbitset
Definition: IsolationCommon.h:19
xAOD::Iso::ptcone30
@ ptcone30
Definition: IsolationType.h:41
xAOD::Iso::neflowisol30
@ neflowisol30
Definition: IsolationType.h:65
xAOD::Iso::ptcone20
@ ptcone20
Track isolation.
Definition: IsolationType.h:40
xAOD::Iso::topoetcone30
@ topoetcone30
Definition: IsolationType.h:49
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:100
ZDCMsg::Info
@ Info
Definition: ZDCMsg.h:20
xAOD::TrackIsolationTool
Definition: TrackIsolationTool.h:39
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
xAOD::Iso::neflowisol40
@ neflowisol40
Definition: IsolationType.h:66
xAOD::CaloIsolation
Definition: IsolationCommon.h:22
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:133
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
APP_NAME
#define APP_NAME
Definition: BoostedXbbTag.cxx:23
CP::IsolationHelper
Definition: IsolationHelper.h:21
xAOD::CaloIsolationTool
Definition: CaloIsolationTool.h:53
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::TrackIsolation
Definition: IsolationCommon.h:33
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
xAOD::CaloIsolation::etcones
std::vector< float > etcones
Definition: IsolationCommon.h:30
xAOD::Iso::coreCone
@ coreCone
core energy (in dR<0.1).
Definition: Event/xAOD/xAODPrimitives/xAODPrimitives/IsolationCorrection.h:29
gErrorIgnoreLevel
int gErrorIgnoreLevel
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
xAOD::Iso::ptcone40
@ ptcone40
Definition: IsolationType.h:42
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
POOL::TEvent::retrieve
StatusCode retrieve(const T *&obj)
Definition: PhysicsAnalysis/POOLRootAccess/POOLRootAccess/TEvent.h:74
xAOD::CaloCorrection
Definition: IsolationCommon.h:14
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
InDet::InDetTrackSelectionTool
Implementation of the track selector tool.
Definition: InDetTrackSelectionTool.h:52
entries
double entries
Definition: listroot.cxx:49
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
LArCellNtuple.ifile
string ifile
Definition: LArCellNtuple.py:133
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
xAOD::Iso::topoetcone40
@ topoetcone40
Definition: IsolationType.h:50
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:84
xAOD::CaloCorrection::calobitset
Iso::IsolationCaloCorrectionBitset calobitset
Definition: IsolationCommon.h:15
xAOD::Iso::pileupCorrection
@ pileupCorrection
fully corrected
Definition: Event/xAOD/xAODPrimitives/xAODPrimitives/IsolationCorrection.h:35
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31