28#include "GaudiKernel/ITHistSvc.h"
50 ATH_MSG_WARNING(
"particle property is empty, choose between \"photon\" or \"electron\". Assuming electron.");
55 ATH_MSG_FATAL(
"cannot understand particle property: must be \"electron\" or \"photon\"");
68 return StatusCode::FAILURE;
76 ATH_MSG_INFO(
"================================================================================");
80 ATH_MSG_INFO(
"================================================================================");
87 m_tree =
new TTree(
"all_sys",
"all_sys");
88 m_tree->Branch(
"index", &
m_instance_index,
"index/I")->SetTitle(
"index of the particle as in the original dataset");
92 m_tree->Branch((prefix +
"truth_E").c_str(), &
m_truth_E, (prefix +
"truth_E/F").c_str());
93 m_tree->Branch((prefix +
"truth_eta").c_str(), &
m_truth_eta, (prefix +
"truth_eta/F").c_str());
94 m_tree->Branch((prefix +
"truth_pt").c_str(), &
m_truth_pt, (prefix +
"truth_pt/F").c_str());
95 m_tree->Branch((prefix +
"truth_phi").c_str(), &
m_truth_phi, (prefix +
"truth_phi/F").c_str());
96 m_tree->Branch((prefix +
"truth_pdgId").c_str(), &
m_truth_pdgId, (prefix +
"truth_pdgId/I").c_str());
98 m_tree->Branch((prefix +
"truth_matched").c_str(), &
m_truth_matched, (prefix +
"truth_matched/O").c_str());
99 m_tree->Branch((prefix +
"cl_eta").c_str(), &
m_cl_eta, (prefix +
"cl_eta/F").c_str());
100 m_tree->Branch((prefix +
"cl_etaCalo").c_str(), &
m_cl_etaCalo, (prefix +
"cl_etaCalo/F").c_str());
101 m_tree->Branch((prefix +
"cl_phi").c_str(), &
m_cl_phi, (prefix +
"cl_phi/F").c_str());
102 m_tree->Branch((prefix +
"cl_rawcl_Es0").c_str(), &
m_cl_rawcl_Es0, (prefix +
"cl_rawcl_Es0/F").c_str());
103 m_tree->Branch((prefix +
"cl_rawcl_Es1").c_str(), &
m_cl_rawcl_Es1, (prefix +
"cl_rawcl_Es1/F").c_str());
104 m_tree->Branch((prefix +
"cl_rawcl_Es2").c_str(), &
m_cl_rawcl_Es2, (prefix +
"cl_rawcl_Es2/F").c_str());
105 m_tree->Branch((prefix +
"cl_rawcl_Es3").c_str(), &
m_cl_rawcl_Es3, (prefix +
"cl_rawcl_Es3/F").c_str());
106 m_tree->Branch((prefix +
"cl_E").c_str(), &
m_cl_E, (prefix +
"cl_E/F").c_str())->SetTitle(
"original xAOD caloCluster energy");
107 m_tree->Branch((prefix +
"wstot").c_str(), &
m_wstot, (prefix +
"wstot/F").c_str());
121 std::vector<std::vector<std::string> > all_sys_names_per_tool;
122 std::set<std::string> all_sys_names;
127 const std::string branch_name = prefix + tool_name +
"_nominal_E";
128 m_tree->Branch(branch_name.c_str(), &
m_nominal_E[itool], (branch_name +
"/F").c_str());
133 std::vector<std::string> sys_names; sys_names.reserve(sys_set.
size());
134 for (
const auto& sys : sys_set) {
if (sys.parameter() == 1) { sys_names.push_back(sys.name()); all_sys_names.insert(sys.name()); } }
135 std::sort(sys_names.begin(), sys_names.end());
136 all_sys_names_per_tool.push_back(sys_names);
142 for (
const auto& sys : sys_set) {
143 const std::string branch_name = prefix + tool_name +
"_ratio_" + sys.name();
145 (branch_name +
"/F").c_str());
149 m_tree->Branch((prefix + tool_name +
"_ratio_SCALE_sum__1up").c_str(), &
m_energy_variations_sum_up[itool], (prefix + tool_name +
"_ratio_SCALE_sum__1up/F").c_str());
150 m_tree->Branch((prefix + tool_name +
"_ratio_SCALE_sum__1down").c_str(), &
m_energy_variations_sum_down[itool], (prefix + tool_name +
"_ratio_SCALE_sum__1down/F").c_str());
154 std::string
header = std::string(45,
' ');
156 header += std::format(
" [{}] ", i);
160 for (
auto sysname : all_sys_names) {
161 std::string line = std::format(
"{:>45}", sysname);
162 for (
const auto& sys_per_tool : all_sys_names_per_tool) {
163 if (std::find(sys_per_tool.begin(), sys_per_tool.end(), sysname) != sys_per_tool.end()) line +=
" X ";
174 CHECK(histSvc.retrieve());
175 const std::string tree_stream =
"/DATASTREAM";
176 CHECK(histSvc->regTree(tree_stream +
"/myTree",
m_tree));
178 return StatusCode::SUCCESS;
187 return StatusCode::SUCCESS;
202 if (!
evtStore()->retrieve(vtx_container,
"PrimaryVertices")) {
m_npv = -999; }
214 std::pair<xAOD::ElectronContainer*, xAOD::ShallowAuxContainer*> electrons_shallowCopy =
xAOD::shallowCopyContainer(*electrons);
242 if (
const auto* vertex = ph->
vertex()) {
243 m_ph_Rconv = hypot(vertex->position().x(), vertex->position().y());
262 return StatusCode::SUCCESS;
280 for (
size_t p = 0; p < true_particle->
nParents(); ++p) {
295 return StatusCode::SUCCESS;
301 m_cl_eta = particle.caloCluster()->eta();
309 m_cl_E = particle.caloCluster()->e();
311 return StatusCode::SUCCESS;
321 return StatusCode::FAILURE;
328 ATH_MSG_WARNING(
"Cannot calibrate electron, eta: " << particle.eta() <<
" phi: " << particle.phi());
329 return StatusCode::FAILURE;
338 for (
const auto& sys : sys_set) {
344 ATH_MSG_ERROR(
"Cannot configure calibration tool for systematic");
351 if (sys.basename().find(
"SCALE") != std::string::npos) {
355 ATH_MSG_DEBUG(
"calibrated with systematic " << sys.name() <<
": " << particle.e());
365 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define CHECK(...)
Evaluate an expression and check for errors.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
@ Ok
The correction was done successfully.
Class to wrap a set of SystematicVariations.
size_t size() const
returns: size of the set
StatusCode do_egamma(const xAOD::Egamma &particle)
StatusCode do_truth(const xAOD::Egamma &particle)
std::string m_particle_name
virtual StatusCode finalize()
DumpAllSystematics(const std::string &name, ISvcLocator *svcLoc)
Regular Algorithm constructor.
StatusCode do_energy(xAOD::Egamma &particle, int itool)
float m_averageIntPerXing
std::vector< float > m_energy_variations_sum_down
ParticleType m_particle_type
std::vector< std::vector< float > > m_energy_variations
virtual StatusCode execute()
unsigned long long m_EventNumber
std::vector< float > m_nominal_E
std::string m_reco_container_name
virtual StatusCode initialize()
ToolHandleArray< CP::IEgammaCalibrationAndSmearingTool > m_EgammaCalibrationAndSmearingTools
std::vector< float > m_energy_variations_sum_up
SG::Accessor< T, ALLOC > Accessor
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
const xAOD::Vertex * vertex(size_t index=0) const
Pointer to the xAOD::Vertex/es that match the photon candidate.
int pdgId() const
PDG ID code.
const TruthVertex_v1 * decayVtx() const
The decay vertex of this particle.
const TruthParticle_v1 * parent(size_t i) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
bool hasDecayVtx() const
Check for a decay vertex on this particle.
virtual double e() const override final
The total energy of the particle.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
size_t nParents() const
Number of parents of this particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
float perp() const
Vertex transverse distance from the beam line.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
xAOD::EgammaParameters::ConversionType conversionType(const xAOD::Photon *ph)
return the photon conversion type (see EgammaEnums)
bool isTrueConvertedPhoton(const xAOD::Photon *ph, float maxRadius=800.)
is the object matched to a true converted photon with R < maxRadius
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any)
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, const EventContext &ctx)
Function making a shallow copy of a constant container.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Egamma_v1 Egamma
Definition of the current "egamma version".
float get_eta_calo(const xAOD::CaloCluster &cluster, int author, bool do_throw=false)
TruthParticle_v1 TruthParticle
Typedef to implementation.
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".