ATLAS Offline Software
PhotonVertexSelectionAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // PhotonVertexSelectionAlg.cxx
6 
13 
14 namespace CP {
15 
16  using std::string;
17  using namespace xAOD;
18 
19  //**********************************************************************
20 
22  ISvcLocator* pSvcLocator )
23  : ::AthAlgorithm( name, pSvcLocator ),
24  m_vxSelTool("CP::PhotonVertexSelectionTool/PhotonVtxSel")
25  {
26  declareProperty( "InputVertices", m_inVxColl ="PrimaryVertices" );
27  declareProperty( "InputPhotons", m_inGamColl="Photons" );
28  declareProperty( "OutputVertices", m_outVxColl="HggPrimaryVertices" );
29  declareProperty( "VxSelTool", m_vxSelTool );
30 
31  }
32 
33  //**********************************************************************
34 
36 
37  //**********************************************************************
38 
40  ATH_MSG_INFO("Initializing " << name() << "...");
41 
42  return StatusCode::SUCCESS;
43  }
44 
45  //**********************************************************************
46 
48  ATH_MSG_INFO ("Finalizing " << name() << "...");
49 
50  return StatusCode::SUCCESS;
51  }
52 
53  //**********************************************************************
54 
56  ATH_MSG_VERBOSE("Executing " << name() << "...");
57 
58  VertexContainer* vxOut(new VertexContainer);
60  vxOut->setStore(vxOutAux);
61  vxOut->push_back(new Vertex);
62  // Immediately add one vertex, because we will always want one in the container.
63  // Strictly speaking, if the event has no vertex, this could wind up being a dummy.
64  ATH_CHECK( evtStore()->record(vxOut, m_outVxColl) );
65  ATH_CHECK( evtStore()->record(vxOutAux, m_outVxColl+"Aux.") );
66 
67  const PhotonContainer* photons(nullptr);
68  ATH_CHECK( evtStore()->retrieve(photons, m_inGamColl) );
69 
71  for(const auto *const ph : *photons) {
72  if(acceptPhoton(*ph)) photons_presel.push_back( ph );
73  }
74 
75  const Vertex* photonVx(nullptr);
76  if( m_vxSelTool->getVertex(*photons_presel.asDataVector(), photonVx).isSuccess() && photonVx) {
77  *vxOut->front() = *photonVx; // deep copy of photon vertex, to record
78  vxOut->front()->setVertexType(VxType::PriVtx);
79  } else {
80  const VertexContainer* vxIn(nullptr);
82  for(const auto *const vx : *vxIn) {
83  if(vx->vertexType()==VxType::PriVtx) *vxOut->front() = *vx;
84  }
85  }
86 
87  return StatusCode::SUCCESS;
88  }
89 
90  //**********************************************************************
91 
92  // add some reasonable preselection here a la
93  // https://svnweb.cern.ch/trac/atlasoff/browser/PhysicsAnalysis/HiggsPhys/Run2/HGamma/xAOD/HGamAnalysisFramework/trunk/Root/PhotonHandler.cxx#L511
94  bool PhotonVertexSelectionAlg::acceptPhoton(const xAOD::Photon& /*gam*/) {return true;}
95 
96 }
97 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CP::PhotonVertexSelectionAlg::m_vxSelTool
ToolHandle< CP::IPhotonVertexSelectionTool > m_vxSelTool
Definition: PhotonVertexSelectionAlg.h:45
xAOD::VertexAuxContainer_v1
Temporary container used until we have I/O for AuxStoreInternal.
Definition: VertexAuxContainer_v1.h:32
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CP::PhotonVertexSelectionAlg::m_inGamColl
std::string m_inGamColl
Definition: PhotonVertexSelectionAlg.h:42
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
CP::PhotonVertexSelectionAlg::m_inVxColl
std::string m_inVxColl
Definition: PhotonVertexSelectionAlg.h:41
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
PhotonVertexSelectionAlg.h
CP::PhotonVertexSelectionAlg::acceptPhoton
static bool acceptPhoton(const xAOD::Photon &gam)
Definition: PhotonVertexSelectionAlg.cxx:94
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CP::PhotonVertexSelectionAlg::execute
StatusCode execute()
Definition: PhotonVertexSelectionAlg.cxx:55
CP::PhotonVertexSelectionAlg::finalize
StatusCode finalize()
Definition: PhotonVertexSelectionAlg.cxx:47
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
CP::PhotonVertexSelectionAlg::initialize
StatusCode initialize()
Athena algorithm's Hooks.
Definition: PhotonVertexSelectionAlg.cxx:39
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IPhotonVertexSelectionTool.h
CP::PhotonVertexSelectionAlg::PhotonVertexSelectionAlg
PhotonVertexSelectionAlg()
Default constructor:
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AthAlgorithm
Definition: AthAlgorithm.h:47
CP::PhotonVertexSelectionAlg::m_outVxColl
std::string m_outVxColl
Definition: PhotonVertexSelectionAlg.h:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
VertexContainer.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
xAOD::Photon_v1
Definition: Photon_v1.h:37
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
PhotonContainer.h
VertexAuxContainer.h
CP::PhotonVertexSelectionAlg::~PhotonVertexSelectionAlg
~PhotonVertexSelectionAlg()
Destructor: