ATLAS Offline Software
Loading...
Searching...
No Matches
FsrPhotonToolTester.cxx File Reference

Go to the source code of this file.

Macros

#define CHECK(ARG)

Functions

int main (int argc, char *argv[])

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 )
#define APP_NAME

Definition at line 29 of file FsrPhotonToolTester.cxx.

29#define CHECK( ARG ) \
30 do { \
31 const bool result = ARG; \
32 if(!result) { \
33 ::Error(APP_NAME, "Failed to execute: \"%s\"", \
34 #ARG ); \
35 return 1; \
36 } \
37 } while( false )

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 53 of file FsrPhotonToolTester.cxx.

54{
55
56 // The application's name
57 const char* APP_NAME = argv[ 0 ];
58
59 // Check if we received a file name
60 if(argc < 2) {
61 Error( APP_NAME, "No file name received!" );
62 Error( APP_NAME, " Usage: %s [xAOD file name]", APP_NAME );
63 return 1;
64 }
65
66 // Initialise the application
68 StatusCode::enableFailure();
69
70 // Open the input file
71 const TString fileName = argv[ 1 ];
72 Info(APP_NAME, "Opening file: %s", fileName.Data());
73 std::unique_ptr<TFile> ifile(TFile::Open(fileName, "READ"));
74 CHECK( ifile.get() );
75
76 // Create a TEvent object
78 CHECK( event.readFrom(ifile.get()) );
79 Info(APP_NAME, "Number of events in the file: %i",
80 static_cast<int>(event.getEntries()));
81
82 // Create a Store object for shallow copies
84
85
86 // Decide how many events to run over
87 Long64_t entries = event.getEntries();
88 if(argc > 2) {
89 const Long64_t e = atoll(argv[2]);
90 if(e < entries) {
91 entries = e;
92 }
93 }
94
95 // Must provide and egamma calib tool to the FSRTool
96 CP::EgammaCalibrationAndSmearingTool * energyRescaler =
97 new CP::EgammaCalibrationAndSmearingTool("EgammaCalibrationAndSmearingTool");
98 std::string esModel = "es2017_R21_v1"; // move to v1, 2018/09/04
99 CHECK( energyRescaler->setProperty( "ESModel", esModel) );
100 CHECK( energyRescaler->initialize() );
101 ToolHandle<CP::IEgammaCalibrationAndSmearingTool> energyRescalerTool(energyRescaler->name());
102
103 // Create and configure the tool
104 FSR::FsrPhotonTool fsrTool("FsrPhotonTool");
105 CHECK( fsrTool.setProperty<double>("far_fsr_drcut", 0.12) );
106 fsrTool.msg().setLevel(MSG::DEBUG);
107 CHECK( fsrTool.setProperty( "egCalibToolName", energyRescaler->name()) );
108 CHECK( fsrTool.initialize() );
109
110
111 FSR::FsrCandidate candidate;
112
113 // Loop over the events
114 for(Long64_t entry = 0; entry < entries; ++entry) {
115
116 store->clear(); // must clear store each event
117
118 // Tell the object which entry to look at
119 event.getEntry(entry);
120
121 // Print some event information for fun
122 // Need to link against xAODEventInfo for this to work
123 //const xAOD::EventInfo* ei = 0;
124 //CHECK( event.retrieve(ei, "EventInfo") );
125 //Info( APP_NAME,
126 // "===>>> start processing event #%i, "
127 // "run #%i %i events processed so far <<<===",
128 // static_cast<int>(ei->eventNumber()),
129 // static_cast<int>(ei->runNumber()),
130 // static_cast<int>(entry));
131
132 // Retrieve the muons
133 const xAOD::MuonContainer* muons = 0;
134 CHECK( event.retrieve( muons, "Muons" ) );
135
136 // get ElectronContainer and clone it in order to apply corrections
137 const xAOD::ElectronContainer* els = 0;
138 CHECK( event.retrieve( els, "Electrons" ) );
139
140 std::pair< xAOD::ElectronContainer*, xAOD::ShallowAuxContainer* > electrons_shallowCopy =
142
143 // Record then in the Store
144 CHECK( store->record( electrons_shallowCopy.first, "ElectronsCorr" ) );
145 CHECK( store->record( electrons_shallowCopy.second, "ElectronsCorrAux." ) );
146
147 xAOD::ElectronContainer* elsCorr = electrons_shallowCopy.first;
148
149 // Must set links between shallow copy and original container
150 if (!xAOD::setOriginalObjectLink( *els, *elsCorr )) {
151 Error(APP_NAME, "Unable to setOriginalObjectLink for electron containers ");
152 return 1;
153 }
154
155 // get PhotonContainer and clone it in order to apply corrections
156 const xAOD::PhotonContainer* phs = 0;
157 CHECK( event.retrieve( phs, "Photons" ) );
158
159 std::pair< xAOD::PhotonContainer*, xAOD::ShallowAuxContainer* > photons_shallowCopy =
161
162 // Record then in the Store
163 CHECK( store->record( photons_shallowCopy.first, "PhotonsCorr" ) );
164 CHECK( store->record( photons_shallowCopy.second, "PhotonsCorrAux." ) );
165 xAOD::PhotonContainer* phsCorr = photons_shallowCopy.first;
166 // Must set links between shallow copy and original container
167 if (!xAOD::setOriginalObjectLink( *phs, *phsCorr )) {
168 Error(APP_NAME, "Unable to setOriginalObjectLink for photon containers ");
169 return 1;
170 }
171
172
173 //std::vector<const xAOD::Muon*> selectedMuons;
174 double tmp_energy = -999.;
175 double fsr_energy = 0.;
176 TLorentzVector fsr_tlv;
177
178 // Loop over muons
179 for( auto muon : *muons ) {
180
181 if (CP::CorrectionCode::Ok != fsrTool.getFsrPhoton(muon, candidate, phsCorr, elsCorr))
182 {
183 Info( APP_NAME, " FSR candidate found !!!!!!!! ");
184 Info( APP_NAME, " container = %s deltaR = %f Et = %f f1 = %f"
185 " eta = %f phi = %f phIso = %f fsrtype = %i",
186 candidate.container.c_str(),
187 candidate.deltaR, candidate.Et, candidate.f1,
188 candidate.eta, candidate.phi,
189 candidate.phIso, candidate.type );
190 }
191
192 if (candidate.container == "photon" ) {
193 const xAOD::Photon* photon = dynamic_cast<const xAOD::Photon*>(candidate.particle);
194 if (photon) fsr_energy = photon->e();
195 }
196 else if (candidate.container == "electron" ) {
197 const xAOD::Electron* electron = dynamic_cast<const xAOD::Electron*>(candidate.particle);
198 if (electron) fsr_energy = electron->e();
199 } else
200 Info(APP_NAME, " FSR candidate particle is unknown " );
201
202 if ( fsr_energy > tmp_energy ) {
203 tmp_energy = fsr_energy;
204 fsr_tlv.SetPtEtaPhiE(candidate.Et, candidate.eta, candidate.phi, fsr_energy);
205 }
206
207 }
208
210
211 }
212
213 delete store;
214
215 return EXIT_SUCCESS;
216
217}
#define CHECK(ARG)
@ Ok
The correction was done successfully.
Simple interface for searching the FSR candidate.
const xAOD::IParticle * particle
std::string container
Implementation for the "FSR" provider tool.
void record(const T *p, const std::string &key)
Definition TestStore.h:81
ReadStats & stats()
Access the object belonging to the current thread.
Definition IOStats.cxx:17
static IOStats & instance()
Singleton object accessor.
Definition IOStats.cxx:11
void printSmartSlimmingBranchList(bool autoIncludeLinks=false) const
Print the accessed variables, formatted for smart slimming.
Tool for accessing xAOD files outside of Athena.
@ kClassAccess
Access auxiliary data using the aux containers.
A relatively simple transient store for objects created in analysis.
Definition TStore.h:45
double entries
Definition listroot.cxx:49
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition Error.h:16
TestStore store
Definition TestStore.cxx:23
@ Info
Definition ZDCMsg.h:20
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition Init.cxx:31
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, const EventContext &ctx)
Function making a shallow copy of a constant container.
bool setOriginalObjectLink(const IParticle &original, IParticle &copy)
This function should be used by CP tools when they make a deep copy of an object in their correctedCo...
Photon_v1 Photon
Definition of the current "egamma version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Electron_v1 Electron
Definition of the current "egamma version".