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

Implementation for the photon vertex selection tool. More...

#include <PhotonVertexSelectionTool.h>

Inheritance diagram for CP::PhotonVertexSelectionTool:

Public Types

enum  FailType {
  Unkown = -99 , NoFail = 0 , NoVxCont = 1 , NoEventInfo = 2 ,
  FailPointing = 3 , FailEgamVect = 4 , NoGdCandidate = 5 , MatchedTrack = 6
}
 Declare the interface that the class provides. More...
enum  yyVtxType { Unknown = -1 , ConvTrack = 0 , SiConvTrack = 1 , NoSiTracks = 2 }

Public Member Functions

 PhotonVertexSelectionTool (const std::string &name)
virtual ~PhotonVertexSelectionTool ()
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 sysInitialize () override
 Perform system initialization for an algorithm.
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 IPhotonVertexSelectionTool interface
StatusCode decorateInputs (const xAOD::EgammaContainer &egammas, FailType *failType=nullptr) const
 Given a list of photons, decorate vertex container with MVA variables.
StatusCode getVertex (const xAOD::EgammaContainer &egammas, const xAOD::Vertex *&vertex, bool ignoreConv=false) const
 Given a list of photons, return the most likely vertex based on MVA likelihood.
std::vector< std::pair< const xAOD::Vertex *, float > > getVertex (const xAOD::EgammaContainer &egammas, bool ignoreConv=false, bool noDecorate=false, yyVtxType *vtxCase=nullptr, FailType *failType=nullptr) const
 Given a list of photons, return the MLPs of all vertices in the event.
int getCase () const
 Return the last case treated:
const xAOD::VertexgetPrimaryVertexFromConv (const xAOD::PhotonContainer *photons) const
 Get possible vertex directly associated with photon conversions.
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.

Public Attributes

SG::WriteDecorHandleKey< xAOD::VertexContainerm_deltaPhiKey { this, "DeltaPhiKey", m_vertexContainer, "deltaPhi" }
SG::WriteDecorHandleKey< xAOD::VertexContainerm_deltaZKey { this, "DeltaZKey", m_vertexContainer, "deltaZ" }
SG::WriteDecorHandleKey< xAOD::VertexContainerm_sumPt2Key { this, "SumPt2Key", m_vertexContainer, "sumPt2" }
SG::WriteDecorHandleKey< xAOD::VertexContainerm_sumPtKey { this, "SumPtKey", m_vertexContainer, "sumPt" }

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.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

std::tuple< std::shared_ptr< Ort::Session >, Ort::AllocatorWithDefaultOptions > setONNXSession (Ort::Env &env, const std::string &modelFilePath)
std::tuple< std::vector< int64_t >, std::vector< const char * > > getInputNodes (const std::shared_ptr< Ort::Session > &sessionHandle, Ort::AllocatorWithDefaultOptions &allocator)
std::tuple< std::vector< int64_t >, std::vector< const char * > > getOutputNodes (const std::shared_ptr< Ort::Session > &sessionHandle, Ort::AllocatorWithDefaultOptions &allocator)
float getScore (int nVars, const std::vector< std::vector< float > > &input_data, const std::shared_ptr< Ort::Session > &sessionHandle, std::vector< int64_t > input_node_dims, std::vector< const char * > input_node_names, std::vector< const char * > output_node_names) const
TLorentzVector getEgammaVector (const xAOD::EgammaContainer *egammas, FailType &failType) const
 Get combined 4-vector of photon container.
StatusCode getVertexImp (const xAOD::EgammaContainer &egammas, const xAOD::Vertex *&vertex, bool ignoreConv, bool noDecorate, std::vector< std::pair< const xAOD::Vertex *, float > > &, yyVtxType &, FailType &) const
 Given a list of photons, return the MLPs of all vertices in the event.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Static Private Member Functions

static bool sortMLP (const std::pair< const xAOD::Vertex *, float > &a, const std::pair< const xAOD::Vertex *, float > &b)
 Sort MLP results.

Private Attributes

int m_nVars
 Create a proper constructor for Athena.
float m_convPtCut
bool m_doSkipByZSigma
std::string m_vertexContainerName
std::string m_derivationPrefix
SG::ReadHandleKey< xAOD::EventInfom_eventInfo
 Container declarations.
SG::ReadHandleKey< xAOD::VertexContainerm_vertexContainer
bool m_isTMVA
std::string m_TMVAModelFilePath1
std::string m_TMVAModelFilePath2
std::unique_ptr< TMVA::Reader > m_mva1
std::unique_ptr< TMVA::Reader > m_mva2
std::string m_ONNXModelFilePath1
std::string m_ONNXModelFilePath2
std::vector< int64_t > m_input_node_dims1
std::vector< int64_t > m_output_node_dims1
std::vector< const char * > m_input_node_names1
std::vector< const char * > m_output_node_names1
std::vector< int64_t > m_input_node_dims2
std::vector< int64_t > m_output_node_dims2
std::vector< const char * > m_input_node_names2
std::vector< const char * > m_output_node_names2
std::shared_ptr< Ort::Session > m_sessionHandle1
std::shared_ptr< Ort::Session > m_sessionHandle2
Ort::AllocatorWithDefaultOptions m_allocator1
Ort::AllocatorWithDefaultOptions m_allocator2
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 vertex selection tool.

Takes a list of photons (for example, to two leading photons) and the most likely primary vertex, based on an MVA.

Author
Christopher Meyer chris.nosp@m..mey.nosp@m.er@ce.nosp@m.rn.c.nosp@m.h
Bruno Lenzi bruno.nosp@m..len.nosp@m.zi@ce.nosp@m.rn.c.nosp@m.h

Definition at line 39 of file PhotonVertexSelectionTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Member Enumeration Documentation

◆ FailType

Declare the interface that the class provides.

enum indicating where the tool has failed

Enumerator
Unkown 
NoFail 
NoVxCont 
NoEventInfo 
FailPointing 
FailEgamVect 
NoGdCandidate 
MatchedTrack 

Definition at line 33 of file IPhotonVertexSelectionTool.h.

33 {
34 Unkown = -99, // Init value
35 NoFail = 0, // Ok to run the MVA algorithm
36 NoVxCont = 1, // No vertex container
37 NoEventInfo = 2, // No EventInfo
38 FailPointing = 3, // Calo pointing failed
39 FailEgamVect = 4, // No diphoton event
40 NoGdCandidate = 5, // Pointing succeded but too distant from any other vertex
41 MatchedTrack = 6, // Conversion photon has a track attached to a primary/pileup vertex
42 };

◆ yyVtxType

Enumerator
Unknown 
ConvTrack 
SiConvTrack 
NoSiTracks 

Definition at line 44 of file IPhotonVertexSelectionTool.h.

44 {
45 Unknown = -1, // Init value
46 ConvTrack = 0, // conv track associated to vertex,
47 SiConvTrack = 1, // at least one conv track with Si hits,
48 NoSiTracks = 2, // no tracks with Si hits or conversions ignored
49 };

Constructor & Destructor Documentation

◆ PhotonVertexSelectionTool()

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

Definition at line 54 of file PhotonVertexSelectionTool.cxx.

55 : asg::AsgTool(name)
56 {
57 // run 2 NN model:
58 // m_doSkipByZSigma = true, m_isTMVA = true
59 // run 3 NN model:
60 // m_doSkipByZSigma = false, m_isTMVA = false
61
62 // default variables
63 declareProperty("nVars", m_nVars = 4);
64 declareProperty("conversionPtCut", m_convPtCut = 2e3);
65 declareProperty("DoSkipByZSigma", m_doSkipByZSigma = false);
66
67 declareProperty("derivationPrefix", m_derivationPrefix = "");
68
69 // boolean for TMVA, default true
70 declareProperty("isTMVA", m_isTMVA = false);
71
72 // config files (TMVA), default paths if not set
73 declareProperty("ConfigFileCase1",
74 m_TMVAModelFilePath1 = "PhotonVertexSelection/v1/DiphotonVertex_case1.weights.xml");
75 declareProperty("ConfigFileCase2",
76 m_TMVAModelFilePath2 = "PhotonVertexSelection/v1/DiphotonVertex_case2.weights.xml");
77
78 // config files (ONNX), default paths if not set
79 declareProperty("ONNXModelFileCase1", m_ONNXModelFilePath1 = "PhotonVertexSelection/run3nn/model1.onnx");
80 declareProperty("ONNXModelFileCase2", m_ONNXModelFilePath2 = "PhotonVertexSelection/run3nn/model2.onnx");
81 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
int m_nVars
Create a proper constructor for Athena.

◆ ~PhotonVertexSelectionTool()

CP::PhotonVertexSelectionTool::~PhotonVertexSelectionTool ( )
virtualdefault

Member Function Documentation

◆ 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>

◆ decorateInputs()

StatusCode CP::PhotonVertexSelectionTool::decorateInputs ( const xAOD::EgammaContainer & egammas,
FailType * failType = nullptr ) const
virtual

Given a list of photons, decorate vertex container with MVA variables.

Implements CP::IPhotonVertexSelectionTool.

Definition at line 282 of file PhotonVertexSelectionTool.cxx.

282 {
283 auto fail = FailType::NoFail;
284
285 const EventContext& ctx = Gaudi::Hive::currentContext();
286 SG::WriteDecorHandle<xAOD::VertexContainer, float> deltaPhi (m_deltaPhiKey, ctx);
287 SG::WriteDecorHandle<xAOD::VertexContainer, float> deltaZ (m_deltaZKey, ctx);
288 SG::WriteDecorHandle<xAOD::VertexContainer, float> sumPt2 (m_sumPt2Key, ctx);
289 SG::WriteDecorHandle<xAOD::VertexContainer, float> sumPt (m_sumPtKey, ctx);
290
291 // Get the EventInfo
292 SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfo, ctx);
293
294 // Find the common z-position from beam / photon pointing information
295 std::pair<float, float> zCommon = xAOD::PVHelpers::getZCommonAndError(&*eventInfo, &egammas, m_convPtCut);
296 // Vector sum of photons
297 TLorentzVector vegamma = getEgammaVector(&egammas, fail);
298
299 // Retrieve PV collection from TEvent
300 SG::ReadHandle<xAOD::VertexContainer> vertices(m_vertexContainer, ctx);
301
302 bool writeSumPt2 = !sumPt2.isAvailable();
303 bool writeSumPt = !sumPt.isAvailable();
304
305 for (const xAOD::Vertex* vertex: *vertices) {
306
307 // Skip dummy vertices
308 if (!(vertex->vertexType() == xAOD::VxType::VertexType::PriVtx ||
309 vertex->vertexType() == xAOD::VxType::VertexType::PileUp)) continue;
310
311 // Set input variables
312 if (writeSumPt) {
313 sumPt(*vertex) = xAOD::PVHelpers::getVertexSumPt(vertex, 1, false);
314 }
315
316 if (writeSumPt2) {
317 sumPt2(*vertex) = xAOD::PVHelpers::getVertexSumPt(vertex, 2);
318 }
319
320 // Get momentum vector of vertex
321 TLorentzVector vmom = xAOD::PVHelpers::getVertexMomentum(vertex, true, m_derivationPrefix);
322
323 deltaPhi(*vertex) = (fail != FailType::FailEgamVect) ? std::abs(vmom.DeltaPhi(vegamma)) : -999.;
324 deltaZ(*vertex) = std::abs((zCommon.first - vertex->z())/zCommon.second);
325
326 } // loop over vertices
327
328 ATH_MSG_DEBUG("DecorateInputs exit code "<< fail);
329 if(failType!=nullptr)
330 *failType = fail;
331 return StatusCode::SUCCESS;
332 }
#define ATH_MSG_DEBUG(x)
SG::WriteDecorHandleKey< xAOD::VertexContainer > m_sumPtKey
TLorentzVector getEgammaVector(const xAOD::EgammaContainer *egammas, FailType &failType) const
Get combined 4-vector of photon container.
SG::WriteDecorHandleKey< xAOD::VertexContainer > m_deltaZKey
SG::WriteDecorHandleKey< xAOD::VertexContainer > m_sumPt2Key
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Container declarations.
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer
SG::WriteDecorHandleKey< xAOD::VertexContainer > m_deltaPhiKey
fail(message)
float getVertexSumPt(const xAOD::Vertex *vertex, int power=1, bool useAux=true)
Loop over track particles associated with vertex and return scalar sum of pT^power in GeV (from auxda...
TLorentzVector getVertexMomentum(const xAOD::Vertex *vertex, bool useAux=true, const std::string &derivationPrefix="")
Return vector sum of tracks associated with vertex (from auxdata if available and useAux = true)
std::pair< float, float > getZCommonAndError(const xAOD::EventInfo *eventInfo, const xAOD::EgammaContainer *egammas, float convPtCut=2e3)
Return zCommon and zCommonError.
@ PileUp
Pile-up vertex.
@ PriVtx
Primary vertex.
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ 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.

◆ 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

◆ getCase()

int CP::PhotonVertexSelectionTool::getCase ( ) const
inlinevirtual

Return the last case treated:

Implements CP::IPhotonVertexSelectionTool.

Definition at line 159 of file PhotonVertexSelectionTool.h.

159{ return -1; }

◆ getEgammaVector()

TLorentzVector CP::PhotonVertexSelectionTool::getEgammaVector ( const xAOD::EgammaContainer * egammas,
FailType & failType ) const
private

Get combined 4-vector of photon container.

Definition at line 628 of file PhotonVertexSelectionTool.cxx.

629 {
630 TLorentzVector v, v1;
631 const xAOD::CaloCluster *cluster = nullptr;
632 for (const xAOD::Egamma* egamma: *egammas) {
633 if (egamma == nullptr) {
634 ATH_MSG_DEBUG("No egamma object to get four vector");
635 failType = FailType::FailEgamVect;
636 continue;
637 }
638 cluster = egamma->caloCluster();
639 if (cluster == nullptr) {
640 ATH_MSG_WARNING("No cluster associated to egamma, not adding to 4-vector.");
641 continue;
642 }
643
644 v1.SetPtEtaPhiM(egamma->e()/cosh(cluster->etaBE(2)),
645 cluster->etaBE(2),
646 cluster->phiBE(2),
647 0.0);
648 v += v1;
649 }
650 return v;
651 }
#define ATH_MSG_WARNING(x)
float phiBE(const unsigned layer) const
Get the phi in one layer of the EM Calo.
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.
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17

◆ getInputNodes()

std::tuple< std::vector< int64_t >, std::vector< const char * > > CP::PhotonVertexSelectionTool::getInputNodes ( const std::shared_ptr< Ort::Session > & sessionHandle,
Ort::AllocatorWithDefaultOptions & allocator )
private

Definition at line 137 of file PhotonVertexSelectionTool.cxx.

139 {
140 // input nodes
141 std::vector<int64_t> input_node_dims;
142 size_t num_input_nodes = sessionHandle->GetInputCount();
143 std::vector<const char*> input_node_names(num_input_nodes);
144
145 // Loop the input nodes
146 for( std::size_t i = 0; i < num_input_nodes; i++ ) {
147 // Print input node names
148 char* input_name = sessionHandle->GetInputNameAllocated(i, allocator).release();
149 ATH_MSG_DEBUG("Input "<<i<<" : "<<" name= "<<input_name);
150 input_node_names[i] = input_name;
151
152 // Print input node types
153 Ort::TypeInfo type_info = sessionHandle->GetInputTypeInfo(i);
154 auto tensor_info = type_info.GetTensorTypeAndShapeInfo();
155 ONNXTensorElementDataType type = tensor_info.GetElementType();
156 ATH_MSG_DEBUG("Input "<<i<<" : "<<" type= "<<type);
157
158 // Print input shapes/dims
159 input_node_dims = tensor_info.GetShape();
160 ATH_MSG_DEBUG("Input "<<i<<" : num_dims= "<<input_node_dims.size());
161 for (std::size_t j = 0; j < input_node_dims.size(); j++){
162 if(input_node_dims[j]<0){input_node_dims[j] =1;}
163 ATH_MSG_DEBUG("Input"<<i<<" : dim "<<j<<"= "<<input_node_dims[j]);
164 }
165 }
166 return std::make_tuple(input_node_dims, input_node_names);
167 }

◆ 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::TEvent 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::TEvent, 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::TEvent 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::TEvent, 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 }

◆ getOutputNodes()

std::tuple< std::vector< int64_t >, std::vector< const char * > > CP::PhotonVertexSelectionTool::getOutputNodes ( const std::shared_ptr< Ort::Session > & sessionHandle,
Ort::AllocatorWithDefaultOptions & allocator )
private

Definition at line 171 of file PhotonVertexSelectionTool.cxx.

173 {
174 // output nodes
175 std::vector<int64_t> output_node_dims;
176 size_t num_output_nodes = sessionHandle->GetOutputCount();
177 std::vector<const char*> output_node_names(num_output_nodes);
178
179 // Loop the output nodes
180 for( std::size_t i = 0; i < num_output_nodes; i++ ) {
181 // Print output node names
182 char* output_name = sessionHandle->GetOutputNameAllocated(i, allocator).release();
183 ATH_MSG_DEBUG("Output "<<i<<" : "<<" name= "<<output_name);
184 output_node_names[i] = output_name;
185
186 Ort::TypeInfo type_info = sessionHandle->GetOutputTypeInfo(i);
187 auto tensor_info = type_info.GetTensorTypeAndShapeInfo();
188 ONNXTensorElementDataType type = tensor_info.GetElementType();
189 ATH_MSG_DEBUG("Output "<<i<<" : "<<" type= "<<type);
190
191 // Print output shapes/dims
192 output_node_dims = tensor_info.GetShape();
193 ATH_MSG_DEBUG("Output "<<i<<" : num_dims= "<<output_node_dims.size());
194 for (std::size_t j = 0; j < output_node_dims.size(); j++){
195 if(output_node_dims[j]<0){output_node_dims[j] =1;}
196 ATH_MSG_DEBUG("Output"<<i<<" : dim "<<j<<"= "<<output_node_dims[j]);
197 }
198 }
199 return std::make_tuple(output_node_dims, output_node_names);
200 }

◆ getPrimaryVertexFromConv()

const xAOD::Vertex * CP::PhotonVertexSelectionTool::getPrimaryVertexFromConv ( const xAOD::PhotonContainer * photons) const
virtual

Get possible vertex directly associated with photon conversions.

Implements CP::IPhotonVertexSelectionTool.

Definition at line 574 of file PhotonVertexSelectionTool.cxx.

575 {
576 if (photons == nullptr) {
577 ATH_MSG_WARNING("Passed nullptr photon container, returning nullptr vertex from getPrimaryVertexFromConv");
578 return nullptr;
579 }
580
581 std::vector<const xAOD::Vertex*> vertices;
582 const xAOD::Vertex *conversionVertex = nullptr, *primary = nullptr;
583 const xAOD::TrackParticle *tp = nullptr;
584 size_t NumberOfTracks = 0;
585
586 // Retrieve PV collection from TEvent
587 SG::ReadHandle<xAOD::VertexContainer> all_vertices(m_vertexContainer);
588
589
590 for (const auto *photon: *photons) {
591 conversionVertex = photon->vertex();
592 if (conversionVertex == nullptr) continue;
593
594 NumberOfTracks = conversionVertex->nTrackParticles();
595 for (size_t i = 0; i < NumberOfTracks; ++i) {
596 // Get trackParticle in GSF collection
597 const auto *gsfTp = conversionVertex->trackParticle(i);
598 if (gsfTp == nullptr) continue;
599 if (!xAOD::PVHelpers::passConvSelection(*conversionVertex, i, m_convPtCut)) continue;
600
601 // Get trackParticle in InDet collection
603 if (tp == nullptr) continue;
604
605 primary = getVertexFromTrack(tp, &*all_vertices);
606 if (primary == nullptr) continue;
607
608 if (primary->vertexType() == xAOD::VxType::VertexType::PriVtx ||
609 primary->vertexType() == xAOD::VxType::VertexType::PileUp) {
610 if (std::find(vertices.begin(), vertices.end(), primary) == vertices.end()) {
611 vertices.push_back(primary);
612 continue;
613 }
614 }
615 }
616 }
617
618 if (!vertices.empty()) {
619 if (vertices.size() > 1)
620 ATH_MSG_WARNING("Photons associated to different vertices! Returning lead photon association.");
621 return vertices[0];
622 }
623
624 return nullptr;
625 }
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
const xAOD::Vertex * getVertexFromTrack(const xAOD::TrackParticle *track, const xAOD::VertexContainer *vertices)
const xAOD::TrackParticle * getOriginalTrackParticleFromGSF(const xAOD::TrackParticle *trkPar)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the GSF Track Particle...
bool passConvSelection(const xAOD::Photon *photon, float convPtCut=2e3)
Check if photon is converted, and tracks have Si hits and pass selection.
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ getProperty()

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

Get one of the tool's properties.

◆ getScore()

float CP::PhotonVertexSelectionTool::getScore ( int nVars,
const std::vector< std::vector< float > > & input_data,
const std::shared_ptr< Ort::Session > & sessionHandle,
std::vector< int64_t > input_node_dims,
std::vector< const char * > input_node_names,
std::vector< const char * > output_node_names ) const
private

Definition at line 89 of file PhotonVertexSelectionTool.cxx.

94 {
95 //*************************************************************************
96 // score the model using sample data, and inspect values
97 // loading input data
98 std::vector<std::vector<float>> input_tensor_values_ = input_data;
99
100 //preparing container to hold input data
101 size_t input_tensor_size = nVars;
102 std::vector<float> input_tensor_values(nVars);
103 input_tensor_values = input_tensor_values_[0]; //0th element since only batch_size of 1, otherwise loop
104
105 // create input tensor object from data values
106 auto memory_info =
107 Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault);
108 // create tensor using info from inputs
109 Ort::Value input_tensor = Ort::Value::CreateTensor<float>(
110 memory_info, input_tensor_values.data(), input_tensor_size,
111 input_node_dims.data(), input_node_dims.size());
112
113 // check if input is of type tensor
114 assert(input_tensor.IsTensor());
115
116 // run the inference
117 auto output_tensors =
118 sessionHandle->Run(Ort::RunOptions{nullptr}, input_node_names.data(),
119 &input_tensor, input_node_names.size(),
120 output_node_names.data(), output_node_names.size());
121
122 // check size of output tensor
123 assert(output_tensors.size() == 1 && output_tensors.front().IsTensor());
124
125 // get pointer to output tensor float values
126 // float* floatarr = output_tensors.front().GetTensorMutableData<float>();
127 float* floatarr = output_tensors[0].GetTensorMutableData<float>();
128
129 int arrSize = sizeof(*floatarr) / sizeof(floatarr[0]);
130 ATH_MSG_DEBUG("The size of the array is: " << arrSize);
131 ATH_MSG_DEBUG("floatarr[0] = " << floatarr[0]);
132 return floatarr[0];
133 }

◆ getVertex() [1/2]

std::vector< std::pair< const xAOD::Vertex *, float > > CP::PhotonVertexSelectionTool::getVertex ( const xAOD::EgammaContainer & egammas,
bool ignoreConv = false,
bool noDecorate = false,
yyVtxType * vtxCase = nullptr,
FailType * failType = nullptr ) const
virtual

Given a list of photons, return the MLPs of all vertices in the event.

Implements CP::IPhotonVertexSelectionTool.

Definition at line 336 of file PhotonVertexSelectionTool.cxx.

340 {
341 const xAOD::Vertex *vertex = nullptr;
342 std::vector<std::pair<const xAOD::Vertex*, float> > vertexMLP;
344 FailType failType = FailType::NoFail;
345 if (getVertexImp( egammas, vertex, ignoreConv, noDecorate, vertexMLP, vtxCase, failType ).isSuccess()) {
346 std::sort(vertexMLP.begin(), vertexMLP.end(), sortMLP);
347 }
348 if(vtxCasePtr!=nullptr)
349 *vtxCasePtr = vtxCase;
350 if(failTypePtr!=nullptr)
351 *failTypePtr = failType;
352
353 return vertexMLP;
354 }
FailType
Declare the interface that the class provides.
static bool sortMLP(const std::pair< const xAOD::Vertex *, float > &a, const std::pair< const xAOD::Vertex *, float > &b)
Sort MLP results.
StatusCode getVertexImp(const xAOD::EgammaContainer &egammas, const xAOD::Vertex *&vertex, bool ignoreConv, bool noDecorate, std::vector< std::pair< const xAOD::Vertex *, float > > &, yyVtxType &, FailType &) const
Given a list of photons, return the MLPs of all vertices in the event.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ getVertex() [2/2]

StatusCode CP::PhotonVertexSelectionTool::getVertex ( const xAOD::EgammaContainer & egammas,
const xAOD::Vertex *& vertex,
bool ignoreConv = false ) const
virtual

Given a list of photons, return the most likely vertex based on MVA likelihood.

Implements CP::IPhotonVertexSelectionTool.

Definition at line 357 of file PhotonVertexSelectionTool.cxx.

360 {
361 std::vector<std::pair<const xAOD::Vertex*, float> > vertexMLP;
363 FailType failType = FailType::NoFail;
364 return getVertexImp( egammas, prime_vertex, ignoreConv, false, vertexMLP, vtxcase, failType );
365 }

◆ getVertexImp()

StatusCode CP::PhotonVertexSelectionTool::getVertexImp ( const xAOD::EgammaContainer & egammas,
const xAOD::Vertex *& vertex,
bool ignoreConv,
bool noDecorate,
std::vector< std::pair< const xAOD::Vertex *, float > > & vertexMLP,
yyVtxType & vtxCase,
FailType & fail ) const
private

Given a list of photons, return the MLPs of all vertices in the event.

Definition at line 367 of file PhotonVertexSelectionTool.cxx.

374 {
375 // Set default vertex case and declare photon container
376 vtxCase = yyVtxType::Unknown;
377 const xAOD::PhotonContainer *photons = dynamic_cast<const xAOD::PhotonContainer*>(&egammas);
378
379 // Retrieve PV collection from TEvent
380 SG::ReadHandle<xAOD::VertexContainer> vertices(m_vertexContainer);
381
382 if (!noDecorate && !decorateInputs(egammas).isSuccess()){
383 return StatusCode::FAILURE;
384 }
385
386 // Check if a conversion photon has a track attached to a primary/pileup vertex
387 if (!ignoreConv && photons) {
388 prime_vertex = getPrimaryVertexFromConv(photons);
389 if (prime_vertex != nullptr) {
390 vtxCase = yyVtxType::ConvTrack;
392 vertexMLP.emplace_back(prime_vertex, 0.);
393 return StatusCode::SUCCESS;
394 }
395 }
396
397 if (fail != FailType::NoFail){
398 ATH_MSG_VERBOSE("Returning hardest vertex. Fail detected (type="<< fail <<")");
399 vertexMLP.clear();
400 prime_vertex = xAOD::PVHelpers::getHardestVertex(&*vertices);
401 vertexMLP.emplace_back(prime_vertex, 10.);
402 return StatusCode::SUCCESS;
403 }
404
405 // Get the EventInfo
406 SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfo);
407
408 // If there are any silicon conversions passing selection
409 // ==> use Model 1 (Conv) otherwise Model 2 (Unconv)
410 // Set default for conversion bool as false unless otherwise
411 bool isConverted = false;
412
413 // assume default NoSiTrack (unconverted) unless otherwise
414 vtxCase = yyVtxType::NoSiTracks;
415 if (!ignoreConv && photons) {
416 for (const auto *photon: *photons) {
417 if (!photon)
418 {
419 ATH_MSG_WARNING("Null pointer to photon");
420 return StatusCode::FAILURE;
421 }
422 // find out if pass conversion selection criteria and tag as SiConvTrack case
424 {
425 isConverted = true;
426 vtxCase = yyVtxType::SiConvTrack;
427 }
428 }
429 }
430
431 // if TMVA chosen, declare tmva_reader only once (before for looping vertex)
432 TMVA::Reader *tmva_reader = new TMVA::Reader();
433 if(m_isTMVA){
434 if(isConverted){
435 // If there are any silicon conversions passing selection, use MVA1 (converted case)
436 tmva_reader = m_mva1.get();
437 }
438 // Otherwise, use MVA2 (unconverted case)
439 if(!isConverted){
440 tmva_reader = m_mva2.get();
441 }
442 }
443 ATH_MSG_DEBUG("Vtx Case: " << vtxCase);
444
445 // Vector sum of photons
446 TLorentzVector vegamma = getEgammaVector(&egammas, fail);
447
448 SG::AuxElement::ConstAccessor<float> sumPtA(m_derivationPrefix + "sumPt");
449 SG::AuxElement::ConstAccessor<float> sumPt2A(m_derivationPrefix + "sumPt2");
450 SG::AuxElement::ConstAccessor<float> deltaPhiA(m_derivationPrefix + "deltaPhi");
451 SG::AuxElement::ConstAccessor<float> deltaZA(m_derivationPrefix + "deltaZ");
452
453 // Loop over vertices and find best candidate
454 std::vector<float> ONNXInputVector;
455 std::vector<std::vector<float>> onnx_input_tensor_values;
456 std::vector<float> TMVAInputVector;
457 TString TMVAMethod;
458 float mlp = 0.0, mlp_max = -99999.0;
459 float doSkipByZSigmaScore = -9999.0;
460 // assign threshold score value to compare later for good vtx
461 float thresGoodVtxScore;
462 if(m_doSkipByZSigma){thresGoodVtxScore = doSkipByZSigmaScore;}
463 else{thresGoodVtxScore = mlp_max;}
464 for (const xAOD::Vertex* vertex: *vertices) {
465 // Skip dummy vertices
466 if (!(vertex->vertexType() == xAOD::VxType::VertexType::PriVtx ||
467 vertex->vertexType() == xAOD::VxType::VertexType::PileUp)) continue;
468
469 onnx_input_tensor_values.clear();
470
471 // Variables used as input features in classifier
472 float sumPt, sumPt2, deltaPhi, deltaZ;
473 float log10_sumPt, log10_sumPt2;
474
475 sumPt = (sumPtA)(*vertex);
476 sumPt2 = (sumPt2A)(*vertex);
477 deltaPhi = (deltaPhiA)(*vertex);
478 deltaZ = (deltaZA)(*vertex);
479 ATH_MSG_VERBOSE("sumPt: " << sumPt <<
480 " sumPt2: " << sumPt2 <<
481 " deltaPhi: " << deltaPhi <<
482 " deltaZ: " << deltaZ);
483
484 // setup the vector of input features based on selected inference framework
485 if(m_isTMVA){
486 // Get likelihood probability from TMVA model
487 TMVAMethod = "MLP method";
488 log10_sumPt = static_cast<float>(log10(sumPt));
489 log10_sumPt2 = static_cast<float>(log10(sumPt2));
490 TMVAInputVector = {deltaZ,deltaPhi,log10_sumPt,log10_sumPt2};
491 }
492 else{ //assume ony ONNX for now
493 // Get likelihood probability from onnx model
494 // check if value is 0, assign small number like 1e-8 as dummy, as we will take log later (log(0) is nan)
495 // note that the ordering here is a bit different, following the order used when training
496 ONNXInputVector = {sumPt2, sumPt, deltaPhi, deltaZ};
497 for (long unsigned int i = 0; i < ONNXInputVector.size(); i++) {
498 // skip log for deltaPhi and take log for the rest
499 if (i == 2) {
500 continue;
501 }
502 if (ONNXInputVector[i] != 0 && std::isinf(ONNXInputVector[i]) != true && std::isnan(ONNXInputVector[i]) != true){
503 ONNXInputVector[i] = log(std::abs(ONNXInputVector[i]));
504 }
505 else{
506 ONNXInputVector[i] = log(std::abs(0.00000001)); //log(abs(1e-8))
507 }
508 } //end ONNXInputVector for loop
509 onnx_input_tensor_values.push_back(ONNXInputVector);
510 }
511
512 // Do the actual calculation of classifier score part
513 if(m_isTMVA){
514 mlp = tmva_reader->EvaluateMVA(TMVAInputVector, TMVAMethod);
515 ATH_MSG_VERBOSE("TMVA output: " << (tmva_reader == m_mva1.get() ? "MVA1 ": "MVA2 ")<< mlp);
516 }
517 else{ //assume ony ONNX for now
518 if(isConverted){
519 mlp = getScore(m_nVars, onnx_input_tensor_values,
522 }
523 if(!isConverted){
524 mlp = getScore(m_nVars, onnx_input_tensor_values,
527 }
528 ATH_MSG_VERBOSE("log(abs(sumPt)): " << sumPt <<
529 " log(abs(sumPt2)): " << sumPt2 <<
530 " deltaPhi: " << deltaPhi <<
531 " log(abs(deltaZ)): " << deltaZ);
532 ATH_MSG_VERBOSE("ONNX output, isConverted = " << isConverted << ", mlp=" << mlp);
533 }
534
535 // Skip vertices above 10 sigma from pointing or 15 sigma from conversion (HPV)
536 // Simply displace the mlp variable we calculate before by a predefined value
538 if ((isConverted && deltaZ > 15) || (!isConverted && deltaZ > 10)) {
539 mlp = doSkipByZSigmaScore;
540 }
541 }
542
543 // add the new vertex and its score to vertexMLP container
544 vertexMLP.emplace_back(vertex, mlp);
545
546 // Keep track of maximal likelihood vertex
547 if (mlp > mlp_max) {
548 mlp_max = mlp;
549 prime_vertex = vertex;
550 }
551 } // end loop over vertices
552
553 // from all the looped vertices, decide the max score which should be more than the minimum we set
554 // (which should be more than the initial mlp_max value above or more than the skip vertex by z-sigma score)
555 // if this does not pass, return hardest primary vertex
556 if (mlp_max <= thresGoodVtxScore) {
557 ATH_MSG_DEBUG("No good vertex candidates from pointing, returning hardest vertex.");
558 prime_vertex = xAOD::PVHelpers::getHardestVertex(&*vertices);
560 vertexMLP.clear();
561 vertexMLP.emplace_back(xAOD::PVHelpers::getHardestVertex(&*vertices), 20.);
562 }
563
564 ATH_MSG_VERBOSE("getVertex case "<< (int)vtxCase << " exit code "<< (int)fail);
565 return StatusCode::SUCCESS;
566 }
#define ATH_MSG_VERBOSE(x)
const xAOD::Vertex * getPrimaryVertexFromConv(const xAOD::PhotonContainer *photons) const
Get possible vertex directly associated with photon conversions.
std::vector< const char * > m_output_node_names2
std::shared_ptr< Ort::Session > m_sessionHandle2
std::unique_ptr< TMVA::Reader > m_mva2
std::vector< const char * > m_output_node_names1
std::unique_ptr< TMVA::Reader > m_mva1
float getScore(int nVars, const std::vector< std::vector< float > > &input_data, const std::shared_ptr< Ort::Session > &sessionHandle, std::vector< int64_t > input_node_dims, std::vector< const char * > input_node_names, std::vector< const char * > output_node_names) const
std::vector< const char * > m_input_node_names2
StatusCode decorateInputs(const xAOD::EgammaContainer &egammas, FailType *failType=nullptr) const
Given a list of photons, decorate vertex container with MVA variables.
std::shared_ptr< Ort::Session > m_sessionHandle1
std::vector< const char * > m_input_node_names1
const xAOD::Vertex * getHardestVertex(const xAOD::VertexContainer *vertices)
Return vertex with highest sum pT^2.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".

◆ initialize()

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

Function initialising the tool.

Reimplemented from asg::AsgTool.

Definition at line 224 of file PhotonVertexSelectionTool.cxx.

225 {
226 ATH_MSG_INFO("Initializing PhotonVertexSelectionTool...");
227 // initialize the readers or sessions
228 if(m_isTMVA){
229 // Get full path of configuration files for MVA
232 // Setup MVAs
233 std::vector<std::string> var_names = {
234 "deltaZ := TMath::Min(abs(PrimaryVerticesAuxDyn.z-zCommon)/zCommonError,20)",
235 "deltaPhi := abs(deltaPhi(PrimaryVerticesAuxDyn.phi,egamma_phi))" ,
236 "logSumpt := log10(PrimaryVerticesAuxDyn.sumPt)" ,
237 "logSumpt2 := log10(PrimaryVerticesAuxDyn.sumPt2)"
238 };
239 auto *mva1 = new TMVA::Reader(var_names, "!Silent:Color");
240 mva1->BookMVA ("MLP method", m_TMVAModelFilePath1 );
241 m_mva1 = std::unique_ptr<TMVA::Reader>( mva1 );
242
243 auto mva2 = std::make_unique<TMVA::Reader>(var_names, "!Silent:Color");
244 mva2->BookMVA ("MLP method", m_TMVAModelFilePath2 );
245 m_mva2 = std::unique_ptr<TMVA::Reader>( std::move(mva2) );
246 }
247 else{ // assume only ONNX for now
248 // create onnx environment
249 Ort::Env env;
250 // converted
254
255 // unconverted
259 }
260
261 // initialize the containers
262 ATH_CHECK( m_eventInfo.initialize() );
263 ATH_CHECK( m_vertexContainer.initialize() );
264
269 ATH_CHECK( m_deltaPhiKey.initialize() );
270 ATH_CHECK( m_deltaZKey.initialize() );
271 ATH_CHECK( m_sumPt2Key.initialize() );
272 ATH_CHECK( m_sumPtKey.initialize() );
273#ifndef XAOD_STANDALONE
276#endif
277
278 return StatusCode::SUCCESS;
279 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
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)
Ort::AllocatorWithDefaultOptions m_allocator2
Ort::AllocatorWithDefaultOptions m_allocator1
std::tuple< std::shared_ptr< Ort::Session >, Ort::AllocatorWithDefaultOptions > setONNXSession(Ort::Env &env, const std::string &modelFilePath)
std::tuple< std::vector< int64_t >, std::vector< const char * > > getOutputNodes(const std::shared_ptr< Ort::Session > &sessionHandle, Ort::AllocatorWithDefaultOptions &allocator)
std::tuple< std::vector< int64_t >, std::vector< const char * > > getInputNodes(const std::shared_ptr< Ort::Session > &sessionHandle, Ort::AllocatorWithDefaultOptions &allocator)
std::string decorKeyFromKey(const std::string &key, const std::string &deflt)
Extract the decoration part of key.

◆ 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.

◆ 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.

◆ print()

◆ 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 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }

◆ renounceArray()

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

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setONNXSession()

std::tuple< std::shared_ptr< Ort::Session >, Ort::AllocatorWithDefaultOptions > CP::PhotonVertexSelectionTool::setONNXSession ( Ort::Env & env,
const std::string & modelFilePath )
private

Definition at line 204 of file PhotonVertexSelectionTool.cxx.

205 {
206 // Find the model file.
207 const std::string modelFileName = PathResolverFindCalibFile( modelFilePath );
208 ATH_MSG_INFO( "Using model file: " << modelFileName );
209
210 // set onnx session options
211 Ort::SessionOptions sessionOptions;
212 sessionOptions.SetIntraOpNumThreads( 1 );
213 sessionOptions.SetGraphOptimizationLevel( ORT_ENABLE_BASIC );
214 // set allocator
215 Ort::AllocatorWithDefaultOptions allocator;
216 // set the onnx runtime session
217 std::shared_ptr<Ort::Session> sessionHandle = std::make_shared<Ort::Session>( env, modelFileName.c_str(), sessionOptions );
218
219 ATH_MSG_INFO( "Created the ONNX Runtime session for model file = " << modelFileName);
220 return std::make_tuple(sessionHandle, allocator);
221 }

◆ sortMLP()

bool CP::PhotonVertexSelectionTool::sortMLP ( const std::pair< const xAOD::Vertex *, float > & a,
const std::pair< const xAOD::Vertex *, float > & b )
staticprivate

Sort MLP results.

Definition at line 569 of file PhotonVertexSelectionTool.cxx.

571 { return a.second > b.second; }
static Double_t a

◆ sysInitialize()

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

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ 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.

◆ updateVHKA()

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

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_allocator1

Ort::AllocatorWithDefaultOptions CP::PhotonVertexSelectionTool::m_allocator1
private

Definition at line 88 of file PhotonVertexSelectionTool.h.

◆ m_allocator2

Ort::AllocatorWithDefaultOptions CP::PhotonVertexSelectionTool::m_allocator2
private

Definition at line 89 of file PhotonVertexSelectionTool.h.

◆ m_convPtCut

float CP::PhotonVertexSelectionTool::m_convPtCut
private

Definition at line 48 of file PhotonVertexSelectionTool.h.

◆ m_deltaPhiKey

SG::WriteDecorHandleKey<xAOD::VertexContainer> CP::PhotonVertexSelectionTool::m_deltaPhiKey { this, "DeltaPhiKey", m_vertexContainer, "deltaPhi" }

Definition at line 166 of file PhotonVertexSelectionTool.h.

167{ this, "DeltaPhiKey", m_vertexContainer, "deltaPhi" };

◆ m_deltaZKey

SG::WriteDecorHandleKey<xAOD::VertexContainer> CP::PhotonVertexSelectionTool::m_deltaZKey { this, "DeltaZKey", m_vertexContainer, "deltaZ" }

Definition at line 168 of file PhotonVertexSelectionTool.h.

169{ this, "DeltaZKey", m_vertexContainer, "deltaZ" };

◆ m_derivationPrefix

std::string CP::PhotonVertexSelectionTool::m_derivationPrefix
private

Definition at line 51 of file PhotonVertexSelectionTool.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doSkipByZSigma

bool CP::PhotonVertexSelectionTool::m_doSkipByZSigma
private

Definition at line 49 of file PhotonVertexSelectionTool.h.

◆ m_eventInfo

SG::ReadHandleKey<xAOD::EventInfo> CP::PhotonVertexSelectionTool::m_eventInfo
private
Initial value:
{
this, "EventInfoContName", "EventInfo", "event info key"}

Container declarations.

Definition at line 54 of file PhotonVertexSelectionTool.h.

54 {
55 this, "EventInfoContName", "EventInfo", "event info key"};

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_input_node_dims1

std::vector<int64_t> CP::PhotonVertexSelectionTool::m_input_node_dims1
private

Definition at line 78 of file PhotonVertexSelectionTool.h.

◆ m_input_node_dims2

std::vector<int64_t> CP::PhotonVertexSelectionTool::m_input_node_dims2
private

Definition at line 81 of file PhotonVertexSelectionTool.h.

◆ m_input_node_names1

std::vector<const char*> CP::PhotonVertexSelectionTool::m_input_node_names1
private

Definition at line 79 of file PhotonVertexSelectionTool.h.

◆ m_input_node_names2

std::vector<const char*> CP::PhotonVertexSelectionTool::m_input_node_names2
private

Definition at line 82 of file PhotonVertexSelectionTool.h.

◆ m_isTMVA

bool CP::PhotonVertexSelectionTool::m_isTMVA
private

TMVA

Definition at line 61 of file PhotonVertexSelectionTool.h.

◆ m_mva1

std::unique_ptr<TMVA::Reader> CP::PhotonVertexSelectionTool::m_mva1
private

Definition at line 67 of file PhotonVertexSelectionTool.h.

◆ m_mva2

std::unique_ptr<TMVA::Reader> CP::PhotonVertexSelectionTool::m_mva2
private

Definition at line 68 of file PhotonVertexSelectionTool.h.

◆ m_nVars

int CP::PhotonVertexSelectionTool::m_nVars
private

Create a proper constructor for Athena.

Configuration variables

Definition at line 47 of file PhotonVertexSelectionTool.h.

◆ m_ONNXModelFilePath1

std::string CP::PhotonVertexSelectionTool::m_ONNXModelFilePath1
private

Definition at line 73 of file PhotonVertexSelectionTool.h.

◆ m_ONNXModelFilePath2

std::string CP::PhotonVertexSelectionTool::m_ONNXModelFilePath2
private

Definition at line 74 of file PhotonVertexSelectionTool.h.

◆ m_output_node_dims1

std::vector<int64_t> CP::PhotonVertexSelectionTool::m_output_node_dims1
private

Definition at line 78 of file PhotonVertexSelectionTool.h.

◆ m_output_node_dims2

std::vector<int64_t> CP::PhotonVertexSelectionTool::m_output_node_dims2
private

Definition at line 81 of file PhotonVertexSelectionTool.h.

◆ m_output_node_names1

std::vector<const char*> CP::PhotonVertexSelectionTool::m_output_node_names1
private

Definition at line 79 of file PhotonVertexSelectionTool.h.

◆ m_output_node_names2

std::vector<const char*> CP::PhotonVertexSelectionTool::m_output_node_names2
private

Definition at line 82 of file PhotonVertexSelectionTool.h.

◆ m_sessionHandle1

std::shared_ptr<Ort::Session> CP::PhotonVertexSelectionTool::m_sessionHandle1
private

Definition at line 85 of file PhotonVertexSelectionTool.h.

◆ m_sessionHandle2

std::shared_ptr<Ort::Session> CP::PhotonVertexSelectionTool::m_sessionHandle2
private

Definition at line 86 of file PhotonVertexSelectionTool.h.

◆ m_sumPt2Key

SG::WriteDecorHandleKey<xAOD::VertexContainer> CP::PhotonVertexSelectionTool::m_sumPt2Key { this, "SumPt2Key", m_vertexContainer, "sumPt2" }

Definition at line 170 of file PhotonVertexSelectionTool.h.

171{ this, "SumPt2Key", m_vertexContainer, "sumPt2" };

◆ m_sumPtKey

SG::WriteDecorHandleKey<xAOD::VertexContainer> CP::PhotonVertexSelectionTool::m_sumPtKey { this, "SumPtKey", m_vertexContainer, "sumPt" }

Definition at line 172 of file PhotonVertexSelectionTool.h.

173{ this, "SumPtKey", m_vertexContainer, "sumPt" };

◆ m_TMVAModelFilePath1

std::string CP::PhotonVertexSelectionTool::m_TMVAModelFilePath1
private

Definition at line 62 of file PhotonVertexSelectionTool.h.

◆ m_TMVAModelFilePath2

std::string CP::PhotonVertexSelectionTool::m_TMVAModelFilePath2
private

Definition at line 63 of file PhotonVertexSelectionTool.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vertexContainer

SG::ReadHandleKey<xAOD::VertexContainer> CP::PhotonVertexSelectionTool::m_vertexContainer
private
Initial value:
{
this, "VertexContainer", "PrimaryVertices", "Vertex container name"}

Definition at line 56 of file PhotonVertexSelectionTool.h.

56 {
57 this, "VertexContainer", "PrimaryVertices", "Vertex container name"};

◆ m_vertexContainerName

std::string CP::PhotonVertexSelectionTool::m_vertexContainerName
private

Definition at line 50 of file PhotonVertexSelectionTool.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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