37 return StatusCode::SUCCESS;
42 if (fullPathToFile.empty()) {
44 <<
"'. Please check if the "
46 return StatusCode::FAILURE;
49 std::unique_ptr<TFile> rootFile(TFile::Open(fullPathToFile.c_str(),
"READ"));
53 <<
"'. Please check if the file "
54 "exists and is not corrupted.");
56 return StatusCode::FAILURE;
58 std::unique_ptr<TTree>
tree((TTree*)rootFile->Get(
m_bdt_name.value().c_str()));
61 << fullPathToFile <<
"'.");
65 << fullPathToFile <<
"'.");
66 m_bdt = std::make_unique<MVAUtils::BDT>(
tree.get());
68 return StatusCode::SUCCESS;
75 if (pointingVertexContainer->size() != 1) {
77 << pointingVertexContainer->size()
81 const xAOD::Vertex* pointingVertex = pointingVertexContainer->front();
83 const float zcommon = pointingVertex->
z();
84 const float zcommon_error =
85 std::sqrt(pointingVertex->covariancePosition()(2, 2));
88 const float nph_good = acc_nph_good(*pointingVertex);
91 const float vtx_z = vertex.z();
93 const float deltaz_sig_photons = std::abs(vtx_z - zcommon) / zcommon_error;
98 TVector3 photon_sump(acc_photons_px(*pointingVertex),
99 acc_photons_py(*pointingVertex),
100 acc_photons_pz(*pointingVertex));
102 const float deltaphi_sig_photons = vertex_p4.Vect().DeltaPhi(photon_sump);
105 << nph_good <<
", vtx_sumpt: " << vtx_sumpt
106 <<
", vtx_sumpt2: " << vtx_sumpt2
107 <<
", deltaz_sig_photons: " << deltaz_sig_photons
108 <<
", deltaphi_sig_photons: " << deltaphi_sig_photons);
110 return {nph_good, vtx_sumpt, vtx_sumpt2, deltaz_sig_photons,
111 deltaphi_sig_photons};
121 if (input_values.empty()) {
return 0.; }
122 return m_bdt->GetClassification(input_values);
127 float best_score = std::numeric_limits<float>::lowest();
138 if (score > best_score) {
144 if (vertex ==
nullptr) {
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Helper class to provide constant type-safe access to aux data.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
SG::ReadDecorHandleKey< xAOD::VertexContainer > m_photons_py_key
virtual ~BDTVertexWeightCalculator() override
const xAOD::Vertex * getVertex(const xAOD::VertexContainer &vertices) const
SG::ReadDecorHandleKey< xAOD::VertexContainer > m_photons_px_key
SG::ReadHandleKey< xAOD::VertexContainer > m_pointingVertexContainerKey
BDTVertexWeightCalculator(const std::string &name)
SG::ReadDecorHandleKey< xAOD::VertexContainer > m_nphotons_good_key
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
StatusCode initialize_BDT()
std::unique_ptr< MVAUtils::BDT > m_bdt
std::vector< float > get_input_values(const xAOD::Vertex &vertex) const
Gaudi::Property< std::string > m_bdt_file
SG::ReadDecorHandleKey< xAOD::VertexContainer > m_photons_pz_key
virtual double estimateSignalCompatibility(const xAOD::Vertex &vertex) const override
Estimate the compatibility of the vertex with a hard scatter vertex, with respect to pileup vertices.
Gaudi::Property< std::string > m_bdt_name
Helper class to provide constant type-safe access to aux data.
float z() const
Returns the z position.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
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)
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.