ATLAS Offline Software
Loading...
Searching...
No Matches
CP::PhotonPointingTool Class Reference

Implementation for the photon pointing tool. More...

#include <PhotonPointingTool.h>

Inheritance diagram for CP::PhotonPointingTool:
Collaboration diagram for CP::PhotonPointingTool:

Public Types

Definition of the StoreGate-like object's definition
typedef ServiceHandle< StoreGateSvc > MetaStore_t
 Type of the metadata store object in Athena.
typedef const ServiceHandle< StoreGateSvc > & MetaStorePtr_t
 Type of the metadata store pointer in standalone mode.

Public Member Functions

 PhotonPointingTool (const std::string &name)
virtual ~PhotonPointingTool ()
virtual StatusCode sysInitialize ()
 Function initialising the tool in the correct way in Athena.
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Function(s) implementing the asg::IAsgTool interface
virtual StatusCode initialize ()
 Function initialising the tool.
Function(s) implementing the IPhotonPointingTool interface
StatusCode updatePointingAuxdata (const xAOD::EgammaContainer &egammas) const
 Add calo and conversion (HPV) pointing variables.
std::pair< float, float > getCaloPointing (const xAOD::Egamma *egamma) const
 Return calo pointing variables.
std::pair< float, float > getConvPointing (const xAOD::Photon *photon) const
 Return conversion (HPV) pointing variables.
Functions providing access to the input/output metadata
MetaStorePtr_t inputMetaStore () const
 Accessor for the input metadata store.
MetaStorePtr_t outputMetaStore () const
 Accessor for the output metadata store.
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.
Callback functions helping in metadata reading/writing
void setUseIncidents (const bool flag)
virtual void handle (const Incident &inc)
 Function receiving incidents from IncidentSvc/Event.
virtual StatusCode beginInputFile ()
 Function called when a new input file is opened.
virtual StatusCode endInputFile ()
 Function called when the currently open input file got completely processed.
virtual StatusCode beginEvent ()
 Function called when a new events is loaded.
virtual StatusCode metaDataStop ()
 Function called when the tool should write out its metadata.

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

float getCorrectedZ (float zPointing, float etas2) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

TH1F * m_zCorrection
 Create a proper constructor for Athena.
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfo
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_zvertex
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_errz
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_HPV_zvertex
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_HPV_errz
bool m_isMC {}
std::string m_zOscFileMC
std::string m_zOscFileData
std::string m_zvertexDecorName
std::string m_errzDecorName
std::string m_HPV_zvertexDecorName
std::string m_HPV_errzDecorName
std::string m_ContainerName
MetaStore_t m_inputMetaStore
 Object accessing the input metadata store.
MetaStore_t m_outputMetaStore
 Object accessing the output metadata store.
bool m_beginInputFileCalled
 Flag helping to discover when the tool misses the opening of the first input file.
bool m_useIncidents
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Implementation for the photon pointing tool.

Takes photon shower shape and/or conversion vertex and extrapolates back to beamline

Author
Christopher Meyer chris.nosp@m..mey.nosp@m.er@ce.nosp@m.rn.c.nosp@m.h

Definition at line 34 of file PhotonPointingTool.h.

Member Typedef Documentation

◆ MetaStore_t

Type of the metadata store object in Athena.

Definition at line 66 of file AsgMetadataTool.h.

◆ MetaStorePtr_t

Type of the metadata store pointer in standalone mode.

Definition at line 68 of file AsgMetadataTool.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ PhotonPointingTool()

CP::PhotonPointingTool::PhotonPointingTool ( const std::string & name)

Definition at line 31 of file PhotonPointingTool.cxx.

32 : asg::AsgMetadataTool(name)
33 , m_zCorrection(nullptr)
34{
35 declareProperty("isSimulation", m_isMC);
36 declareProperty("zOscillationFileMC", m_zOscFileMC = "PhotonVertexSelection/v1/pointing_correction_mc.root");
37 declareProperty("zOscillationFileData", m_zOscFileData = "PhotonVertexSelection/v1/pointing_correction_data.root");
38 declareProperty("zvertex", m_zvertexDecorName = "zvertex");
39 declareProperty("errz", m_errzDecorName = "errz");
40 declareProperty("HPV_zvertex", m_HPV_zvertexDecorName = "HPV_zvertex");
41 declareProperty("HPV_errz", m_HPV_errzDecorName = "HPV_errz");
42 declareProperty("ContainerName", m_ContainerName = "Photons");
43}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
TH1F * m_zCorrection
Create a proper constructor for Athena.

◆ ~PhotonPointingTool()

CP::PhotonPointingTool::~PhotonPointingTool ( )
virtual

Definition at line 46 of file PhotonPointingTool.cxx.

47{
48 SafeDelete(m_zCorrection);
49}

Member Function Documentation

◆ beginEvent()

StatusCode asg::AsgMetadataTool::beginEvent ( )
protectedvirtualinherited

Function called when a new events is loaded.

Dummy implementation that can be overridden by the derived tool.

Reimplemented in Trig::TrigConfBunchCrossingTool, Trig::TrigDecisionTool, Trig::xAODBunchCrossingTool, TrigConf::xAODConfigTool, and xAODMaker::TriggerMenuMetaDataTool.

Definition at line 201 of file AsgMetadataTool.cxx.

201 {
202
203 // Return gracefully:
204 return StatusCode::SUCCESS;
205 }

◆ beginInputFile()

StatusCode asg::AsgMetadataTool::beginInputFile ( )
protectedvirtualinherited

Function called when a new input file is opened.

Dummy implementation that can be overridden by the derived tool.

Reimplemented in BookkeeperDumperTool, BookkeeperTool, PMGTools::PMGTruthWeightTool, Trig::TrigDecisionTool, Trig::xAODBunchCrossingTool, TrigConf::xAODConfigTool, xAODMaker::TriggerMenuMetaDataTool, and xAODMaker::TruthMetaDataTool.

Definition at line 185 of file AsgMetadataTool.cxx.

185 {
186
187 // Return gracefully:
188 return StatusCode::SUCCESS;
189 }

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ endInputFile()

StatusCode asg::AsgMetadataTool::endInputFile ( )
protectedvirtualinherited

Function called when the currently open input file got completely processed.

Dummy implementation that can be overridden by the derived tool.

Reimplemented in BookkeeperDumperTool, BookkeeperTool, TrigConf::xAODConfigTool, xAODMaker::TriggerMenuMetaDataTool, and xAODMaker::TruthMetaDataTool.

Definition at line 193 of file AsgMetadataTool.cxx.

193 {
194
195 // Return gracefully:
196 return StatusCode::SUCCESS;
197 }

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getCaloPointing()

std::pair< float, float > CP::PhotonPointingTool::getCaloPointing ( const xAOD::Egamma * egamma) const
virtual

Return calo pointing variables.

Implements CP::IPhotonPointingTool.

Definition at line 175 of file PhotonPointingTool.cxx.

176 {
177 if (egamma == nullptr) {
178 ATH_MSG_WARNING("Passed Egamma was a nullptr, returning (0,0).");
179 return std::make_pair(0,0);
180 }
181
182 // Get the EventInfo
183 SG::ReadHandle<xAOD::EventInfo> eventInfo(m_evtInfo);
184 if(!eventInfo.isValid()){
185 ATH_MSG_WARNING("Couldn't retrieve EventInfo from TEvent, egamma won't be decorated.");
186 return std::make_pair(0, 0);
187 }
188
189 // Beam parameters
190 double d_beamSpot = std::hypot(eventInfo->beamPosY(), eventInfo->beamPosX());
191 double phi_beamSpot = std::atan2(eventInfo->beamPosY(), eventInfo->beamPosX());
192
193 // Photon variables
194 const xAOD::CaloCluster *cluster = egamma->caloCluster();
195 if (cluster == nullptr) {
196 ATH_MSG_WARNING("Couldn't retrieve CaloCluster from Photon, egammas won't be decorated.");
197 return std::make_pair(0, 0);
198 }
199
200 float cl_e = cluster->e();
201 float etas1 = cluster->etaBE(1);
202 float etas2 = cluster->etaBE(2);
203 float phis2 = cluster->phiBE(2);
204 float cl_theta = 2.0*std::atan(std::exp(-1.0*cluster->eta()));
205
206 // Shower depths
207 std::pair<float, float> RZ1 = CP::ShowerDepthUtil::getRZ(etas1, 1);
208 std::pair<float, float> RZ2 = CP::ShowerDepthUtil::getRZ(etas2, 2);
209
210 // Calo cluster pointing calculation
211 double r0_with_beamSpot = d_beamSpot*std::cos(phis2 - phi_beamSpot);
212
213 float s_zvertex = 0, s_errz = 0;
214 s_zvertex = (RZ1.second * (RZ2.first - r0_with_beamSpot) -
215 RZ2.second * (RZ1.first - r0_with_beamSpot)) /
216 (RZ2.first - RZ1.first);
217 s_zvertex = getCorrectedZ(s_zvertex, etas2);
218
219 s_errz = 0.5 * (RZ2.first + RZ1.first) * (0.060 / std::sqrt(cl_e * 0.001)) /
220 (std::sin(cl_theta) * std::sin(cl_theta));
221
222 return std::make_pair(s_zvertex, s_errz);
223 }
#define ATH_MSG_WARNING(x,...)
float getCorrectedZ(float zPointing, float etas2) const
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfo
static std::pair< float, float > getRZ(float eta, int sampling)
Shower depth in R,Z for the given sampling.
float phiBE(const unsigned layer) const
Get the phi in one layer of the EM Calo.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

◆ getConvPointing()

std::pair< float, float > CP::PhotonPointingTool::getConvPointing ( const xAOD::Photon * photon) const
virtual

Return conversion (HPV) pointing variables.

Implements CP::IPhotonPointingTool.

Definition at line 226 of file PhotonPointingTool.cxx.

227 {
228 if (photon == nullptr) {
229 ATH_MSG_WARNING("Passed Egamma was a nullptr, returning (0,0).");
230 return std::make_pair(0,0);
231 }
232
233 // Get the EventInfo
234 SG::ReadHandle<xAOD::EventInfo> eventInfo(m_evtInfo);
235 if(!eventInfo.isValid()){
236 ATH_MSG_WARNING("Couldn't retrieve EventInfo from TEvent, photons won't be decorated.");
237 return std::make_pair(0, 0);
238 }
239
240 // Beam parameters
241 double d_beamSpot = std::hypot(eventInfo->beamPosY(), eventInfo->beamPosX());
242 double phi_beamSpot = std::atan2(eventInfo->beamPosY(), eventInfo->beamPosX());
243
244 // Photon variables
245 const xAOD::CaloCluster *cluster = photon->caloCluster();
246 if (cluster == nullptr) {
247 ATH_MSG_WARNING("Couldn't retrieve CaloCluster from Photon, photons won't be decorated.");
248 return std::make_pair(0, 0);
249 }
250
251 float etas1 = cluster->etaBE(1);
252 float phis2 = cluster->phiBE(2);
253
254 const xAOD::Vertex *conv = photon->vertex();
255 if (cluster == nullptr) {
256 ATH_MSG_WARNING("Couldn't retrieve conversion Vertex from Photon, photons won't be decorated.");
257 return std::make_pair(0, 0);
258 }
259
260 float conv_x = conv->x();
261 float conv_y = conv->y();
262 float conv_z = conv->z();
263
264 // Shower depths
265 std::pair<float, float> RZ1 = CP::ShowerDepthUtil::getRZ(etas1, 1);
266
267 // Photon conversion
268 double conv_r = std::hypot(conv_x, conv_y);
269
270 // HPV pointing calculation
271 double phi_Calo = std::atan2(std::sin(phis2), std::cos(phis2));
272 double r0_with_beamSpot = d_beamSpot*std::cos(phi_Calo - phi_beamSpot);
273
274 float s_zvertex = (RZ1.second*(conv_r - r0_with_beamSpot) - conv_z*(RZ1.first - r0_with_beamSpot)) / (conv_r - RZ1.first);
275
276 float dist_vtx_to_conv = std::hypot(conv_r - r0_with_beamSpot, conv_z - s_zvertex);
277 float dist_conv_to_s1 = std::hypot(RZ1.first - conv_r, RZ1.second - conv_z);
278
279 float error_etaS1 = 0.001; // FIXME is there a tool which provides a better value?
280 float s_errz = 0.0;
281
282 if ((cluster->inBarrel() && !cluster->inEndcap()) ||
283 (cluster->inBarrel() && cluster->inEndcap() && cluster->eSample(CaloSampling::EMB1) > cluster->eSample(CaloSampling::EME1))) {
284 // Barrel case
285 float error_Z_Calo_1st_Sampling_barrel = error_etaS1*RZ1.first*std::fabs(std::cosh(etas1));
286 s_errz = error_Z_Calo_1st_Sampling_barrel*dist_vtx_to_conv/dist_conv_to_s1;
287 } else {
288 // Endcap case
289 float error_R_Calo_1st_Sampling_endcap = error_etaS1*std::cosh(etas1)*RZ1.first*RZ1.first/std::fabs(RZ1.second);
290 s_errz = error_R_Calo_1st_Sampling_endcap*std::fabs(std::sinh(etas1))*dist_vtx_to_conv/dist_conv_to_s1;
291 }
292
293 return std::make_pair(s_zvertex, s_errz);
294 }
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
float eSample(const CaloSample sampling) const
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ getCorrectedZ()

float CP::PhotonPointingTool::getCorrectedZ ( float zPointing,
float etas2 ) const
private

Definition at line 168 of file PhotonPointingTool.cxx.

169 {
170 if (std::fabs(etas2) < 1.37) return zPointing;
171 return zPointing - m_zCorrection->Interpolate(etas2);
172 }

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::Event, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::Event, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ handle()

void asg::AsgMetadataTool::handle ( const Incident & inc)
protectedvirtualinherited

Function receiving incidents from IncidentSvc/Event.

Reimplemented in Trig::TrigDecisionTool.

Definition at line 135 of file AsgMetadataTool.cxx.

135 {
136
137 // Tell the user what's happening:
138 ATH_MSG_VERBOSE( "Callback received with incident: " << inc.type() );
139
140 // Call the appropriate member function:
141 if( inc.type() == IncidentType::BeginInputFile ) {
143 if( beginInputFile().isFailure() ) {
144 ATH_MSG_FATAL( "Failed to call beginInputFile()" );
145 throw std::runtime_error( "Couldn't call beginInputFile()" );
146 }
147 } else if( inc.type() == IncidentType::EndInputFile ) {
148 if( endInputFile().isFailure() ) {
149 ATH_MSG_FATAL( "Failed to call endInputFile()" );
150 throw std::runtime_error( "Couldn't call endInputFile()" );
151 }
152 } else if( inc.type() == IncidentType::BeginEvent ) {
153 // If the tool didn't catch the begin input file incident for the
154 // first input file of the job, then call the appropriate function
155 // now.
156 if( ! m_beginInputFileCalled ) {
158 if( beginInputFile().isFailure() ) {
159 ATH_MSG_FATAL( "Failed to call beginInputFile()" );
160 throw std::runtime_error( "Couldn't call beginInputFile()" );
161 }
162 }
163 if( beginEvent().isFailure() ) {
164 ATH_MSG_FATAL( "Failed to call beginEvent()" );
165 throw std::runtime_error( "Couldn't call beginEvent()" );
166 }
167
168 #ifdef XAOD_STANDALONE
169 } else if( inc.type() == IncidentType::MetaDataStop ) {
170 if( metaDataStop().isFailure() ) {
171 ATH_MSG_FATAL( "Failed to call metaDataStop()" );
172 throw std::runtime_error( "Couldn't call metaDataStop()" );
173 }
174
175 #endif // XAOD_STANDALONE
176 } else {
177 ATH_MSG_WARNING( "Unknown incident type received in AsgMetaDataTool: " << inc.type() );
178 }
179
180 return;
181 }
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_FATAL(x,...)
virtual StatusCode beginInputFile()
Function called when a new input file is opened.
virtual StatusCode beginEvent()
Function called when a new events is loaded.
bool m_beginInputFileCalled
Flag helping to discover when the tool misses the opening of the first input file.
virtual StatusCode endInputFile()
Function called when the currently open input file got completely processed.
virtual StatusCode metaDataStop()
Function called when the tool should write out its metadata.

◆ initialize()

StatusCode CP::PhotonPointingTool::initialize ( void )
virtual

Function initialising the tool.

Reimplemented from asg::AsgTool.

Definition at line 52 of file PhotonPointingTool.cxx.

53{
54 ATH_MSG_INFO("Initializing PhotonVertexSelectionTool..." << name());
55
56 ATH_CHECK( m_evtInfo.initialize() );
57
58 if(m_ContainerName.empty()) m_ContainerName = "Photons";
59
64
65 ATH_CHECK(m_zvertex.initialize());
66 ATH_CHECK(m_errz.initialize());
67 ATH_CHECK(m_HPV_zvertex.initialize());
68 ATH_CHECK(m_HPV_errz.initialize());
69
70 // Determine if this is MC or data
71 std::string dataType("");
72 m_isMC = true;
73 if (inputMetaStore()->contains<xAOD::FileMetaData>("FileMetaData")) {
74 const xAOD::FileMetaData* fmd = nullptr;
75 ATH_CHECK(inputMetaStore()->retrieve(fmd, "FileMetaData"));
76 std::string simType("");
77 const bool s = fmd->value(xAOD::FileMetaData::simFlavour, simType);
78 if (!s) {
79 ATH_MSG_DEBUG("no sim flavour from metadata: must be data");
80 m_isMC = false;
81 }
82 } else {
83 ATH_MSG_WARNING("Failed to retrieve FileMetaData : assuming to be MC");
84 }
85
86
89 TFile *file = TFile::Open(filepath.c_str(), "READ");
90
91 if (file == nullptr) {
92 ATH_MSG_WARNING("Couldn't find file for z-correction: " << filepath.c_str());
93 ATH_MSG_WARNING("Failed to initialize.");
94 return StatusCode::FAILURE;
95 }
96
97 TH1F *temp = nullptr;
98 file->GetObject("dz_trk_pointing_vs_etas2", temp);
99
100 if (temp == nullptr) {
101 ATH_MSG_WARNING("Couldn't find 'dz_trk_pointing_vs_etas2' histogram in file: " << filepath.c_str());
102 ATH_MSG_WARNING("Failed to initialize.");
103 return StatusCode::FAILURE;
104 }
105
106 bool status = TH1::AddDirectoryStatus();
107 TH1::AddDirectory(false);
108 m_zCorrection = dynamic_cast<TH1F*>(temp->Clone("zCorrection"));
109 SafeDelete(file);
110 TH1::AddDirectory(status);
111
112 return StatusCode::SUCCESS;
113}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_INFO(x,...)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_errz
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_HPV_zvertex
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_zvertex
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_HPV_errz
MetaStorePtr_t inputMetaStore() const
Accessor for the input metadata store.
@ simFlavour
Fast or Full sim [string].
bool value(MetaDataType type, std::string &val) const
Get a pre-defined string value out of the object.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
status
Definition merge.py:16
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
FileMetaData_v1 FileMetaData
Declare the latest version of the class.
TFile * file

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ inputMetaStore()

AsgMetadataTool::MetaStorePtr_t asg::AsgMetadataTool::inputMetaStore ( ) const
inherited

Accessor for the input metadata store.

Definition at line 93 of file AsgMetadataTool.cxx.

93 {
94
95#ifdef XAOD_STANDALONE
96 return &m_inputMetaStore;
97#else // XAOD_STANDALONE
98 return m_inputMetaStore;
99#endif // XAOD_STANDALONE
100 }
MetaStore_t m_inputMetaStore
Object accessing the input metadata store.

◆ metaDataStop()

StatusCode asg::AsgMetadataTool::metaDataStop ( )
protectedvirtualinherited

Function called when the tool should write out its metadata.

Dummy implementation that can be overridden by the derived tool.

Reimplemented in BookkeeperDumperTool, BookkeeperTool, xAODMaker::TriggerMenuMetaDataTool, and xAODMaker::TruthMetaDataTool.

Definition at line 209 of file AsgMetadataTool.cxx.

209 {
210
211 // Return gracefully:
212 return StatusCode::SUCCESS;
213 }

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ outputMetaStore()

AsgMetadataTool::MetaStorePtr_t asg::AsgMetadataTool::outputMetaStore ( ) const
inherited

Accessor for the output metadata store.

Definition at line 102 of file AsgMetadataTool.cxx.

102 {
103
104#ifdef XAOD_STANDALONE
105 return &m_outputMetaStore;
106#else // XAOD_STANDALONE
107 return m_outputMetaStore;
108#endif // XAOD_STANDALONE
109 }
MetaStore_t m_outputMetaStore
Object accessing the output metadata store.

◆ print()

void asg::AsgTool::print ( ) const
virtualinherited

Print the state of the tool.

Implements asg::IAsgTool.

Reimplemented in AsgHelloTool, HI::HIPileupTool, JetFromPseudojet, JetPileupLabelingTool, JetPseudojetRetriever, JetSubStructureMomentToolsBase, JetTruthLabelingTool, and KtDeltaRTool.

Definition at line 131 of file AsgTool.cxx.

131 {
132
133 ATH_MSG_INFO( "AsgTool " << name() << " @ " << this );
134 return;
135 }

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ setUseIncidents()

void asg::AsgMetadataTool::setUseIncidents ( const bool flag)
inlineprotectedinherited

Definition at line 132 of file AsgMetadataTool.h.

133 {
135 }
bool flag
Definition master.py:29

◆ sysInitialize()

StatusCode asg::AsgMetadataTool::sysInitialize ( )
virtualinherited

Function initialising the tool in the correct way in Athena.

This function is used to set up the callbacks from IncidentSvc in Athena at the right time during initialisation, without the user having to do anything special in his/her code.

Reimplemented from AthCommonDataStore< AthCommonMsg< AlgTool > >.

Definition at line 115 of file AsgMetadataTool.cxx.

115 {
116
117#ifndef XAOD_STANDALONE
118 if (m_useIncidents) {
119 // Connect to the IncidentSvc:
120 ServiceHandle< IIncidentSvc > incSvc( "IncidentSvc", name() );
121 ATH_CHECK( incSvc.retrieve() );
122
123 // Set up the right callbacks: don't rethrow exceptions, any failure and we should end
124 incSvc->addListener( this, IncidentType::BeginEvent, 0, false );
125 }
126 // Let the base class do its thing:
127 ATH_CHECK( AlgTool::sysInitialize() );
128
129#endif // not XAOD_STANDALONE
130
131 // Return gracefully:
132 return StatusCode::SUCCESS;
133 }

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updatePointingAuxdata()

StatusCode CP::PhotonPointingTool::updatePointingAuxdata ( const xAOD::EgammaContainer & egammas) const
virtual

Add calo and conversion (HPV) pointing variables.

Implements CP::IPhotonPointingTool.

Definition at line 116 of file PhotonPointingTool.cxx.

117{
118 const EventContext& ctx = Gaudi::Hive::currentContext();
119
120 // create the decorators
121 SG::WriteDecorHandle<xAOD::EgammaContainer, float> s_zvertex(m_zvertex, ctx);
122 SG::WriteDecorHandle<xAOD::EgammaContainer, float> s_errz(m_errz, ctx);
123 SG::WriteDecorHandle<xAOD::EgammaContainer, float> s_HPV_zvertex(m_HPV_zvertex, ctx);
124 SG::WriteDecorHandle<xAOD::EgammaContainer, float> s_HPV_errz(m_HPV_errz, ctx);
125
126 bool isDecorAvailable = s_zvertex.isAvailable();
127
128 // Loop over photons and add calo pointing auxdata
129 std::pair<float, float> result;
130 for (const auto *egamma: egammas) {
131 if(egamma==nullptr){
132 ATH_MSG_DEBUG("Passed Egamma was a nullptr -- skipping");
133 continue;
134 }
135 // Get calo pointing variables
136 result = getCaloPointing(egamma);
137
138 // Set photon auxdata with new value
139 if(isDecorAvailable){
140 ATH_MSG_DEBUG("Called updatePointingAuxdata but decoration is already available");
141 }
142 else{
143 s_zvertex(*egamma) = result.first;
144 s_errz(*egamma) = result.second;
145 }
146
147 // Get conv pointing variables
148 if (egamma->type() == xAOD::Type::Photon) {
149 const xAOD::Egamma *eg = static_cast<const xAOD::Egamma*>(egamma);
150 const xAOD::Photon *photon = dynamic_cast<const xAOD::Photon*>(eg);
151
154 }
155
156 // Set photon auxdata with new value
157 if(!isDecorAvailable){
158 s_HPV_zvertex(*egamma) = result.first;
159 s_HPV_errz(*egamma) = result.second;
160 }
161
162 }
163
164 return StatusCode::SUCCESS;
165}
std::pair< float, float > getCaloPointing(const xAOD::Egamma *egamma) const
Return calo pointing variables.
std::pair< float, float > getConvPointing(const xAOD::Photon *photon) const
Return conversion (HPV) pointing variables.
@ Photon
The object is a photon.
Definition ObjectType.h:47
std::size_t numberOfSiTracks(const xAOD::Photon *eg)
return the number of Si tracks in the conversion
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
Photon_v1 Photon
Definition of the current "egamma version".
Definition Photon.h:17

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_beginInputFileCalled

bool asg::AsgMetadataTool::m_beginInputFileCalled
privateinherited

Flag helping to discover when the tool misses the opening of the first input file.

Definition at line 126 of file AsgMetadataTool.h.

◆ m_ContainerName

std::string CP::PhotonPointingTool::m_ContainerName
private

Definition at line 67 of file PhotonPointingTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_errz

SG::WriteDecorHandleKey<xAOD::EgammaContainer> CP::PhotonPointingTool::m_errz
private

Definition at line 53 of file PhotonPointingTool.h.

◆ m_errzDecorName

std::string CP::PhotonPointingTool::m_errzDecorName
private

Definition at line 64 of file PhotonPointingTool.h.

◆ m_evtInfo

SG::ReadHandleKey<xAOD::EventInfo> CP::PhotonPointingTool::m_evtInfo
private
Initial value:
{
this,
"EventInfo",
"EventInfo",
"SG key of xAOD::EventInfo"
}

Definition at line 44 of file PhotonPointingTool.h.

44 {
45 this,
46 "EventInfo",
47 "EventInfo",
48 "SG key of xAOD::EventInfo"
49 };

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_HPV_errz

SG::WriteDecorHandleKey<xAOD::EgammaContainer> CP::PhotonPointingTool::m_HPV_errz
private

Definition at line 55 of file PhotonPointingTool.h.

◆ m_HPV_errzDecorName

std::string CP::PhotonPointingTool::m_HPV_errzDecorName
private

Definition at line 66 of file PhotonPointingTool.h.

◆ m_HPV_zvertex

SG::WriteDecorHandleKey<xAOD::EgammaContainer> CP::PhotonPointingTool::m_HPV_zvertex
private

Definition at line 54 of file PhotonPointingTool.h.

◆ m_HPV_zvertexDecorName

std::string CP::PhotonPointingTool::m_HPV_zvertexDecorName
private

Definition at line 65 of file PhotonPointingTool.h.

◆ m_inputMetaStore

MetaStore_t asg::AsgMetadataTool::m_inputMetaStore
privateinherited

Object accessing the input metadata store.

Definition at line 119 of file AsgMetadataTool.h.

◆ m_isMC

bool CP::PhotonPointingTool::m_isMC {}
private

Definition at line 61 of file PhotonPointingTool.h.

61{};

◆ m_outputMetaStore

MetaStore_t asg::AsgMetadataTool::m_outputMetaStore
privateinherited

Object accessing the output metadata store.

Definition at line 121 of file AsgMetadataTool.h.

◆ m_useIncidents

bool asg::AsgMetadataTool::m_useIncidents
privateinherited

Definition at line 128 of file AsgMetadataTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 386 of file AthCommonDataStore.h.

◆ m_zCorrection

TH1F* CP::PhotonPointingTool::m_zCorrection
private

Create a proper constructor for Athena.

Correction histogram

Definition at line 42 of file PhotonPointingTool.h.

◆ m_zOscFileData

std::string CP::PhotonPointingTool::m_zOscFileData
private

Definition at line 62 of file PhotonPointingTool.h.

◆ m_zOscFileMC

std::string CP::PhotonPointingTool::m_zOscFileMC
private

Definition at line 62 of file PhotonPointingTool.h.

◆ m_zvertex

SG::WriteDecorHandleKey<xAOD::EgammaContainer> CP::PhotonPointingTool::m_zvertex
private

Definition at line 52 of file PhotonPointingTool.h.

◆ m_zvertexDecorName

std::string CP::PhotonPointingTool::m_zvertexDecorName
private

Definition at line 63 of file PhotonPointingTool.h.


The documentation for this class was generated from the following files: