12#include <TLorentzVector.h>
50 <<
" photons for pointing");
54 for (
unsigned int icut = 0;
57 "cut " << icut <<
": "
60 return StatusCode::SUCCESS;
78 const std::pair<float, float> z_common_and_error =
83 auto pointingVertices = std::make_unique<xAOD::VertexContainer>();
84 auto pointingVerticesAux = std::make_unique<xAOD::VertexAuxContainer>();
85 pointingVertices->setStore(pointingVerticesAux.get());
89 (*pointingVertices).push_back(std::make_unique<xAOD::Vertex>());
93 vtx_pointing->
setZ(z_common_and_error.first);
94 vtx_pointing->
setX(0.0);
95 vtx_pointing->
setY(0.0);
98 cov(2, 2) = z_common_and_error.second * z_common_and_error.second;
102 ANA_CHECK(writeHandle.record(std::move(pointingVertices),
103 std::move(pointingVerticesAux)));
107 const unsigned int n_good_photons =
108 std::count_if(photons_selected.
begin(), photons_selected.
end(),
110 return m_goodPhotonSelectionTool->accept(photon);
113 std::vector<ElementLink<xAOD::EgammaContainer>> ph_links;
114 ph_links.reserve(photons_selected.size());
116 ph_links.emplace_back(*original_photons, photon->index());
123 dec_nphotons(*vtx_pointing) = photons_selected.size();
124 dec_ph_links(*vtx_pointing) = ph_links;
125 dec_nphotons_good(*vtx_pointing) = n_good_photons;
128 const TLorentzVector p4_photons = std::accumulate(
129 photons_selected.
begin(), photons_selected.
end(),
130 TLorentzVector(0, 0, 0, 0),
134 v_ph.SetPtEtaPhiM(photon->e() / cosh(cluster->
etaBE(2)),
144 dec_photons_px(*vtx_pointing) = p4_photons.X();
145 dec_photons_py(*vtx_pointing) = p4_photons.Y();
146 dec_photons_pz(*vtx_pointing) = p4_photons.Z();
148 return StatusCode::SUCCESS;
156 photons_selected.push_back(photon);
157 ATH_MSG_DEBUG(
"photon selected for pointing: pT = " << photon->pt()
162 "number of photons selected for pointing: " << photons_selected.size());
167 std::sort(photons_selected.begin(), photons_selected.end(),
169 return a->pt() > b->pt();
174 ATH_MSG_DEBUG(
"number of photons selected for pointing after limiting: "
175 << photons_selected.size());
178 ATH_MSG_DEBUG(
"photon selected for pointing: pT = " << photon->pt()
#define ATH_CHECK
Evaluate an expression and check for errors.
DataVector adapter that acts like it holds const pointers.
#define AmgSymMatrix(dim)
bool msgLvl(const MSG::Level lvl) const
SG::ReadDecorHandleKey< xAOD::EgammaContainer > m_photon_errz_key
virtual StatusCode initialize()
void selectPhotons(const xAOD::EgammaContainer &original_photons, ConstDataVector< DataVector< xAOD::Egamma > > &photons_selected) const
SG::ReadDecorHandleKey< xAOD::EgammaContainer > m_photon_zvertex_key
SG::WriteDecorHandleKey< xAOD::VertexContainer > m_photons_px_key
SG::WriteDecorHandleKey< xAOD::VertexContainer > m_photon_links_key
Gaudi::Property< int > m_nphotons_to_use
Gaudi::Property< float > m_convPtCut
SG::WriteDecorHandleKey< xAOD::VertexContainer > m_z_common_nphotons_key
SG::WriteDecorHandleKey< xAOD::VertexContainer > m_nphotons_good_key
virtual StatusCode execute()
SG::WriteHandleKey< xAOD::VertexContainer > m_pointingVertexContainerKey
SG::ReadHandleKey< xAOD::EgammaContainer > m_photonContainerKey
BuildVertexPointingAlg(const std::string &name, ISvcLocator *svcLoc=nullptr)
SG::WriteDecorHandleKey< xAOD::VertexContainer > m_photons_py_key
ToolHandle< IAsgSelectionTool > m_selectionTool
SG::ReadDecorHandleKey< xAOD::EgammaContainer > m_photon_HPV_zvertex_key
SG::ReadDecorHandleKey< xAOD::EgammaContainer > m_photon_HPV_errz_key
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG::WriteDecorHandleKey< xAOD::VertexContainer > m_photons_pz_key
DataVector adapter that acts like it holds const pointers.
iterator begin() noexcept
Return an iterator pointing at the beginning of the collection.
iterator end() noexcept
Return an iterator pointing past the end of the collection.
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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.
Class providing the definition of the 4-vector interface.
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
void setZ(float value)
Sets the z position.
void setX(float value)
Sets the x position.
void setY(float value)
Sets the y position.
void setVertexType(VxType::VertexType vType)
Set the type of the vertex.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
std::pair< float, float > getZCommonAndError(const xAOD::EventInfo *eventInfo, const xAOD::EgammaContainer *egammas, float convPtCut=2e3)
Return zCommon and zCommonError.
EventInfo_v1 EventInfo
Definition of the latest event info version.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Vertex_v1 Vertex
Define the latest version of the vertex class.
Egamma_v1 Egamma
Definition of the current "egamma version".
EgammaContainer_v1 EgammaContainer
Definition of the current "egamma container version".