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  static const SG::ConstAccessor<float> topoEtCone40OriginalAcc("topoetcone40_original");
91  static const SG::ConstAccessor<float> topoEtCone40Acc("topoetcone40");
92 
93  //loop over the events
94  for (Long64_t entry = 0; entry < entries; entry++)
95  {
96  //get entry
97  pers.getEntry(entry);
98  ANA_MSG_INFO("============================");
99  ANA_MSG_INFO("Event: " << entry);
100 
101  //get photon container
102  const xAOD::PhotonContainer* photons;
103  ANA_CHECK(pers.retrieve(photons, "Photons"));
104  std::pair< xAOD::PhotonContainer*, xAOD::ShallowAuxContainer* > photons_isocorr = xAOD::shallowCopyContainer( *photons );
105  std::pair< xAOD::PhotonContainer*, xAOD::ShallowAuxContainer* > photons_fudge = xAOD::shallowCopyContainer( *photons );
106 
107  //loop over photon container
108  for (unsigned int idx = 0; idx < photons->size(); idx++)
109  {
110  ANA_MSG_INFO("---------------------------");
111  ANA_MSG_INFO("Photon: " << idx);
112  ANA_CHECK(isoCorrToolFull.applyCorrection(*(photons_isocorr.first->at(idx))));
113  ANA_CHECK(isoCorrToolStep.applyCorrection(*(photons_fudge.first->at(idx))));
114  ANA_CHECK(fudgeTool.applyCorrection(*(photons_fudge.first->at(idx))));
115  ANA_MSG_INFO("topoetcone40 fudge before applyCorrection: " << topoEtCone40OriginalAcc(*photons_fudge.first->at(idx)));
116  ANA_MSG_INFO("topoetcone40 fudge after applyCorrection : " << topoEtCone40Acc(*photons_fudge.first->at(idx)));
117  ANA_MSG_INFO("topoetcone40 with IsolationCorrectionTool : " << topoEtCone40Acc(*photons_isocorr.first->at(idx)));
118  } // loop over photon container
119  } // loop over events
120 
121  return 0;
122 }
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
SG::ConstAccessor< float >
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:100
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
CaloCondBlobAlgs_fillNoiseFromASCII.inputFile
string inputFile
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:17
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
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:42
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
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:84