ATLAS Offline Software
Functions
testIsoCorrection.cxx File Reference
#include "TFile.h"
#include "TString.h"
#include "xAODEgamma/PhotonContainer.h"
#include "xAODEgamma/PhotonAuxContainer.h"
#include "xAODEgamma/Photon.h"
#include "EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase.h"
#include "AsgMessaging/AsgMessaging.h"
#include "IsolationCorrections/IsolationCorrectionTool.h"
#include "xAODCore/ShallowCopy.h"
Include dependency graph for testIsoCorrection.cxx:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 Test code to compare output of ElectronPhotonVariableCorrectionBase correction to the isolation correction tool. More...
 

Function Documentation

◆ main()

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

Test code to compare output of ElectronPhotonVariableCorrectionBase correction to the isolation correction tool.

Author
Nils Gillwald (DESY) nils..nosp@m.gill.nosp@m.wald@.nosp@m.desy.nosp@m..de
Date
February 2020

Definition at line 35 of file testIsoCorrection.cxx.

36 {
37  using namespace asg::msgUserCode;
38  // The application's name:
39  const char* APP_NAME = argv[0];
40  // Check if we received a file name:
41  if (argc < 2)
42  {
43  ANA_MSG_ERROR("No file name received!" );
44  ANA_MSG_ERROR( " Usage: %s [xAOD file name] %d Num of events to process %d (0 photons , 1 electrons)");
45  return EXIT_FAILURE;
46  }
47 
48  //open input file
49  const TString fileName = argv[1];
50  ANA_MSG_INFO(APP_NAME << " Opening file: " << fileName.Data());
51  std::unique_ptr<TFile> inputFile(TFile::Open(fileName, "READ"));
52  ANA_CHECK(inputFile.get());
53 
54  // Create a TEvent object (persistent store)
56  // Create a TStore object (transient store)
57  xAOD::TStore trans;
58  ANA_CHECK(pers.readFrom(inputFile.get()));
59 
60  ANA_MSG_INFO("Number of events in the file: " << pers.getEntries());
61 
62  // Decide how many events to run over:
63  Long64_t entries = pers.getEntries();
64  if (argc > 2)
65  {
66  const Long64_t userInputEntries = atoll(argv[2]);
67  if (userInputEntries < entries)
68  {
69  entries = userInputEntries;
70  }
71  }
72 
73  //initialise the tool
74  ElectronPhotonVariableCorrectionBase fudgeTool("fudgeTool");
75  ANA_CHECK(fudgeTool.setProperty("ConfigFile","EGammaVariableCorrection/ElectronPhotonVariableCorrectionBase_ExampleIsoCorrectionConf.conf"));
76  ANA_CHECK(fudgeTool.initialize());
77 
78  //crosscheck with isolationcorrectiontool
79  // check these StatusCodes once update to a newer AnalysisBase version (not 21.2.56, probably > 21.2.94)
80  CP::IsolationCorrectionTool isoCorrToolFull("isoCorrToolFull");
81  ANA_CHECK(isoCorrToolFull.setProperty("Apply_etaEDPar_mc_correction", true));
82  ANA_CHECK(isoCorrToolFull.setProperty("Apply_etaEDParPU_correction", true));
83  ANA_CHECK(isoCorrToolFull.initialize());
84 
85  CP::IsolationCorrectionTool isoCorrToolStep("isoCorrToolStep");
86  ANA_CHECK(isoCorrToolStep.setProperty("Apply_etaEDPar_mc_correction", false));
87  ANA_CHECK(isoCorrToolStep.setProperty("Apply_etaEDParPU_correction", true));
88  ANA_CHECK(isoCorrToolStep.initialize());
89 
90  //loop over the events
91  for (Long64_t entry = 0; entry < entries; entry++)
92  {
93  //get entry
94  pers.getEntry(entry);
95  ANA_MSG_INFO("============================");
96  ANA_MSG_INFO("Event: " << entry);
97 
98  //get photon container
99  const xAOD::PhotonContainer* photons;
100  ANA_CHECK(pers.retrieve(photons, "Photons"));
101  std::pair< xAOD::PhotonContainer*, xAOD::ShallowAuxContainer* > photons_isocorr = xAOD::shallowCopyContainer( *photons );
102  std::pair< xAOD::PhotonContainer*, xAOD::ShallowAuxContainer* > photons_fudge = xAOD::shallowCopyContainer( *photons );
103 
104  //loop over photon container
105  for (unsigned int idx = 0; idx < photons->size(); idx++)
106  {
107  ANA_MSG_INFO("---------------------------");
108  ANA_MSG_INFO("Photon: " << idx);
109  ANA_CHECK(isoCorrToolFull.applyCorrection(*(photons_isocorr.first->at(idx))));
110  ANA_CHECK(isoCorrToolStep.applyCorrection(*(photons_fudge.first->at(idx))));
111  ANA_CHECK(fudgeTool.applyCorrection(*(photons_fudge.first->at(idx))));
112  ANA_MSG_INFO("topoetcone40 fudge before applyCorrection: " << photons_fudge.first->at(idx)->auxdata<float>("topoetcone40_original"));
113  ANA_MSG_INFO("topoetcone40 fudge after applyCorrection : " << photons_fudge.first->at(idx)->auxdata<float>("topoetcone40"));
114  ANA_MSG_INFO("topoetcone40 with IsolationCorrectionTool : " << photons_isocorr.first->at(idx)->auxdata<float>("topoetcone40"));
115  } // loop over photon container
116  } // loop over events
117 
118  return 0;
119 }
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:97
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
CaloCondBlobAlgs_fillNoiseFromASCII.inputFile
string inputFile
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:17
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
APP_NAME
#define APP_NAME
Definition: BoostedXbbTag.cxx:23
ElectronPhotonVariableCorrectionBase
Class to correct electron and photon MC variables.
Definition: ElectronPhotonVariableCorrectionBase.h:39
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
CP::IsolationCorrectionTool
Definition: IsolationCorrectionTool.h:27
xAOD::shallowCopyContainer
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, [[maybe_unused]] const EventContext &ctx)
Function making a shallow copy of a constant container.
Definition: ShallowCopy.h:110
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
entries
double entries
Definition: listroot.cxx:49
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:81