ATLAS Offline Software
Loading...
Searching...
No Matches
testAthenaEgammaCalibTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM include(s):
6
9#include "xAODEgamma/Egamma.h"
17#include "TString.h"
18// local include
20
21testAthenaEgammaCalibTool::testAthenaEgammaCalibTool( const std::string& name, ISvcLocator* svcLoc )
22 : AthAlgorithm( name, svcLoc ),
23 m_EgammaCalibrationAndSmearingTool("CP::EgammaCalibrationAndSmearingTool/EgammaCalibrationAndSmearingTool", this)
24{
25 declareProperty( "SG_Electrons", m_sg_electrons = "Electrons" );
26 declareProperty( "EgammaCalibrationAndSmearingTool", m_EgammaCalibrationAndSmearingTool);
27}
28
29
31{
32 // Greet the user:
33 ATH_MSG_INFO( "Initialising..." );
34
35 // Retrieve the tools:
37
38 return StatusCode::SUCCESS;
39}
40
41
43{
44 const xAOD::EventInfo* event_info = nullptr;
45 ATH_CHECK( evtStore()->retrieve( event_info) );
46
47 const xAOD::ElectronContainer* electrons;
48 ATH_CHECK( evtStore()->retrieve(electrons, m_sg_electrons) );
49
50 //Clone
52 xAOD::ElectronContainer* elsCorr = electrons_shallowCopy.first.get();
53 //Record in StoreGate
54 CHECK( evtStore()->record( std::move(electrons_shallowCopy.first), "ElectronCollectionCorr") );
55 CHECK( evtStore()->record( std::move(electrons_shallowCopy.second), "ElectronCollectionCorrAux.") );
56
57 //===========SYSTEMATICS
59 const CP::SystematicSet& recommendedSystematics = registry.recommendedSystematics();
60 std::vector<CP::SystematicSet> sysList;
61 // this is the nominal set
62 sysList.emplace_back();
63
64 ATH_MSG_INFO("SIZE of the systematics set:" << recommendedSystematics.size());
65
66 for(const auto & recommendedSystematic : recommendedSystematics)
67 {
68 sysList.emplace_back();
69 sysList.back().insert(recommendedSystematic);
70 }
71
72 std::vector<CP::SystematicSet>::const_iterator sysListItr;
73
74 //Iterate over the shallow copy
76 xAOD::ElectronContainer::iterator el_it_last = elsCorr->end();
77 unsigned int i = 0;
78 for (; el_it != el_it_last; ++el_it, ++i) {
79 xAOD::Electron* el = *el_it;
80 ATH_MSG_INFO("Electron " << i);
81 ATH_MSG_INFO("xAOD/raw pt, eta, phi = " << el->pt() << ", " << el->eta() << ", " << el->phi());
82
84 ATH_MSG_WARNING("Cannot calibrate electron");
85 }
86 ATH_MSG_INFO("Calibrated pt = " << el->pt());
87
88 //systematics
89 ATH_MSG_INFO("=============SYSTEMATICS CHECK NOW");
90 for (sysListItr = sysList.begin(); sysListItr != sysList.end(); ++sysListItr)
91 {
92 // Tell the calibration tool which variation to apply
93 if (m_EgammaCalibrationAndSmearingTool->applySystematicVariation(*sysListItr) != StatusCode::SUCCESS)
94 {
95 ATH_MSG_ERROR("Cannot configure calibration tool for systematics");
96 }
97 //For now remove by hand the photon ones
98 TString syst_name = TString(sysListItr->name());
99 if(!syst_name.BeginsWith("EL") && !syst_name.BeginsWith("EG")) continue;
100
102 ATH_MSG_WARNING("Cannot calibrate electron");
103 }
104
105 ATH_MSG_INFO("Calibrated pt with systematic " << syst_name << " = " << el->pt());
106 }
107 ATH_MSG_INFO("=============END SYSTEMATICS ");
108 }
109
110 //test the correctedCopy method
111 for (; el_it != el_it_last; ++el_it) {
112 xAOD::Electron *copy_el = nullptr; // new object
113 if (m_EgammaCalibrationAndSmearingTool->correctedCopy( **el_it, copy_el) != CP::CorrectionCode::Ok){
114 ATH_MSG_WARNING("Could not apply correction to new electron object");
115 continue;
116 }
117 }
118
119 return StatusCode::SUCCESS;
120}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define CHECK(...)
Evaluate an expression and check for errors.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
@ Ok
The correction was done successfully.
This module implements the central registry for handling systematic uncertainties with CP tools.
const SystematicSet & recommendedSystematics() const
returns: the recommended set of systematics
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Class to wrap a set of SystematicVariations.
size_t size() const
returns: size of the set
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
ToolHandle< CP::IEgammaCalibrationAndSmearingTool > m_EgammaCalibrationAndSmearingTool
virtual StatusCode execute()
Function executing the algorithm.
testAthenaEgammaCalibTool(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
virtual StatusCode initialize()
Function initialising the algorithm.
typename ShallowCopyResult< T >::type ShallowCopyResult_t
Return type of xAOD::shallowCopy.
Definition ShallowCopy.h:68
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
Electron_v1 Electron
Definition of the current "egamma version".