ATLAS Offline Software
Loading...
Searching...
No Matches
DumpAllSystematics Class Reference

#include <dumpAllSystematics.h>

Inheritance diagram for DumpAllSystematics:
Collaboration diagram for DumpAllSystematics:

Public Member Functions

 DumpAllSystematics (const std::string &name, ISvcLocator *svcLoc)
 Regular Algorithm constructor.
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
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 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

Public Attributes

std::string m_particle_name
std::string m_reco_container_name
bool m_keep_one

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

enum class  ParticleType { ELECTRON , PHOTON }
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode do_truth (const xAOD::Egamma &particle)
StatusCode do_egamma (const xAOD::Egamma &particle)
StatusCode do_energy (xAOD::Egamma &particle, int itool)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ParticleType m_particle_type = ParticleType::ELECTRON
TTree * m_tree {}
unsigned long long m_EventNumber {}
uint32_t m_RunNumber {}
int m_instance_index {}
float m_actualIntPerXing {}
float m_averageIntPerXing {}
float m_truth_pt {}
float m_truth_phi {}
float m_truth_eta {}
float m_truth_E {}
int m_truth_pdgId {}
int m_truth_parent_pdgId {}
bool m_truth_matched {}
bool m_truth_isConv {}
float m_truth_Rconv {}
int m_npv {}
float m_cl_phi {}
float m_cl_eta {}
float m_cl_etaCalo {}
float m_cl_rawcl_Es0 {}
float m_cl_rawcl_Es1 {}
float m_cl_rawcl_Es2 {}
float m_cl_rawcl_Es3 {}
float m_cl_E {}
float m_ph_Rconv {}
int m_ph_convFlag {}
float m_wstot {}
std::vector< float > m_nominal_E
std::vector< float > m_energy_variations_sum_up
std::vector< float > m_energy_variations_sum_down
std::vector< std::vector< float > > m_energy_variations
ToolHandleArray< CP::IEgammaCalibrationAndSmearingToolm_EgammaCalibrationAndSmearingTools
DataObjIDColl m_extendedExtraObjects
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

Definition at line 22 of file dumpAllSystematics.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Member Enumeration Documentation

◆ ParticleType

enum class DumpAllSystematics::ParticleType
strongprivate
Enumerator
ELECTRON 
PHOTON 

Definition at line 37 of file dumpAllSystematics.h.

38 {
40 PHOTON
41 };
static const int PHOTON
Definition AtlasPID.h:87
static const int ELECTRON
Definition AtlasPID.h:74

Constructor & Destructor Documentation

◆ DumpAllSystematics()

DumpAllSystematics::DumpAllSystematics ( const std::string & name,
ISvcLocator * svcLoc )

Regular Algorithm constructor.

Definition at line 34 of file dumpAllSystematics.cxx.

35 : AthAlgorithm(name, svcLoc)
36{
37 declareProperty("EgammaCalibrationAndSmearingTools", m_EgammaCalibrationAndSmearingTools);
38 declareProperty("particle", m_particle_name="", "electron/photon");
39 declareProperty("recoContainer", m_reco_container_name="", "reco container name");
40 declareProperty("keepOnlyOne", m_keep_one=false, "keep only the most energetic particle");
41}
AthAlgorithm()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::string m_reco_container_name
ToolHandleArray< CP::IEgammaCalibrationAndSmearingTool > m_EgammaCalibrationAndSmearingTools

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ do_egamma()

StatusCode DumpAllSystematics::do_egamma ( const xAOD::Egamma & particle)
private

Definition at line 298 of file dumpAllSystematics.cxx.

299{
300 m_cl_phi = particle.phi();
301 m_cl_eta = particle.caloCluster()->eta();
302 m_cl_etaCalo = xAOD::get_eta_calo(*particle.caloCluster(),particle.author());
303 m_cl_rawcl_Es0 = particle.caloCluster()->energyBE(0);
304 m_cl_rawcl_Es1 = particle.caloCluster()->energyBE(1);
305 m_cl_rawcl_Es2 = particle.caloCluster()->energyBE(2);
306 m_cl_rawcl_Es3 = particle.caloCluster()->energyBE(3);
307 static const SG::AuxElement::Accessor<float> wstot_accessor("wtots1");
308 m_wstot = wstot_accessor.isAvailable(particle) ? wstot_accessor(particle) : -999;
309 m_cl_E = particle.caloCluster()->e();
310
311 return StatusCode::SUCCESS;
312}
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
float get_eta_calo(const xAOD::CaloCluster &cluster, int author, bool do_throw=false)

◆ do_energy()

StatusCode DumpAllSystematics::do_energy ( xAOD::Egamma & particle,
int itool )
private

Definition at line 314 of file dumpAllSystematics.cxx.

315{
317 std::fill(m_energy_variations[itool].begin(), m_energy_variations[itool].end(), -999.);
318
319 if (m_EgammaCalibrationAndSmearingTools[itool]->applySystematicVariation(CP::SystematicSet()) != StatusCode::SUCCESS) {
320 ATH_MSG_ERROR("cannot apply nominal energy");
321 return StatusCode::FAILURE;
322 }
323 if (m_EgammaCalibrationAndSmearingTools[itool]->applyCorrection(particle) == CP::CorrectionCode::Ok) {
324 m_nominal_E[itool] = particle.e();
325 ATH_MSG_DEBUG("nominal energy: " << particle.e());
326 }
327 else {
328 ATH_MSG_WARNING("Cannot calibrate electron, eta: " << particle.eta() << " phi: " << particle.phi());
329 return StatusCode::FAILURE;
330 }
331
332 // systematics
333 m_energy_variations_sum_up[itool] = 0.;
335
336 const CP::SystematicSet& sys_set = m_EgammaCalibrationAndSmearingTools[itool]->recommendedSystematics();
337 int isys = -1; // ugly
338 for (const auto& sys : sys_set) {
339 ++isys;
340 CP::SystematicSet ss;
341 ss.insert(sys);
342
343 if (m_EgammaCalibrationAndSmearingTools[itool]->applySystematicVariation(ss) != StatusCode::SUCCESS) {
344 ATH_MSG_ERROR("Cannot configure calibration tool for systematic");
345 continue;
346 }
347
348 if (m_EgammaCalibrationAndSmearingTools[itool]->applyCorrection(particle) == CP::CorrectionCode::Ok) {
349 m_energy_variations[itool][isys] = particle.e() / m_nominal_E[itool] - 1;
350
351 if (sys.basename().find("SCALE") != std::string::npos) { // sum only the scale variations
352 if (sys.parameter() == 1) m_energy_variations_sum_up[itool] += m_energy_variations[itool][isys] * m_energy_variations[itool][isys];
353 else if (sys.parameter() == -1) m_energy_variations_sum_down[itool] += m_energy_variations[itool][isys] * m_energy_variations[itool][isys];
354 }
355 ATH_MSG_DEBUG("calibrated with systematic " << sys.name() << ": " << particle.e());
356 }
357 else {
358 ATH_MSG_WARNING("Cannot calibrate electron with systematic");
359 }
360 }
361
364
365 return StatusCode::SUCCESS;
366}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t ss
@ Ok
The correction was done successfully.
std::vector< float > m_energy_variations_sum_down
std::vector< std::vector< float > > m_energy_variations
std::vector< float > m_nominal_E
std::vector< float > m_energy_variations_sum_up

◆ do_truth()

StatusCode DumpAllSystematics::do_truth ( const xAOD::Egamma & particle)
private

Definition at line 265 of file dumpAllSystematics.cxx.

266{
267 // truth
268 const xAOD::TruthParticle* true_particle = nullptr;
269 true_particle = xAOD::TruthHelpers::getTruthParticle(particle);
270
271 if (true_particle) {
272 m_truth_matched = true;
273 m_truth_pt = true_particle->pt();
274 m_truth_phi = true_particle->phi();
275 m_truth_eta = true_particle->eta();
276 m_truth_E = true_particle->e();
277 m_truth_pdgId = true_particle->pdgId();
278
280 for (size_t p = 0; p < true_particle->nParents(); ++p) {
281 if (true_particle->parent(p)) { m_truth_parent_pdgId = true_particle->parent(p)->pdgId(); break; }
282 }
283
286 m_truth_Rconv = (true_particle->pdgId() == 22) ? (true_particle->hasDecayVtx() ? true_particle->decayVtx()->perp() : 0) : -999;
287 }
288
289 }
290 else {
292 m_truth_matched = false;
293 m_truth_isConv = false; // careful here (always check truth_matched before)
294 }
295 return StatusCode::SUCCESS;
296}
ParticleType m_particle_type
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.
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)
TruthParticle_v1 TruthParticle
Typedef to implementation.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode DumpAllSystematics::execute ( )
virtual

Definition at line 190 of file dumpAllSystematics.cxx.

191{
192 const xAOD::EventInfo* eventInfo = nullptr;
193 ATH_CHECK(evtStore()->retrieve(eventInfo));
194
197 m_EventNumber = eventInfo->eventNumber();
198 m_RunNumber = eventInfo->runNumber();
199
200 // vertex information
201 const xAOD::VertexContainer* vtx_container = nullptr;
202 if (!evtStore()->retrieve(vtx_container, "PrimaryVertices")) { m_npv = -999; }
203 else {
204 m_npv = 0;
205 for (const auto* vtx : *vtx_container) { if (vtx->vertexType() == xAOD::VxType::PriVtx or vtx->vertexType() == xAOD::VxType::PileUp) ++m_npv; }
206 }
207
208
209 if (m_particle_type == ParticleType::ELECTRON) { // TODO: find a better way to generalize to electron / photons
210
211 const xAOD::ElectronContainer* electrons = nullptr;
213
214 std::pair<xAOD::ElectronContainer*, xAOD::ShallowAuxContainer*> electrons_shallowCopy = xAOD::shallowCopyContainer(*electrons);
215 for (xAOD::Electron* el : *electrons_shallowCopy.first) {
216 ATH_MSG_DEBUG("new electron eta: " << el->eta());
217
218
219 CHECK(do_truth(*el));
220 CHECK(do_egamma(*el));
221 for (unsigned int itool = 0; itool != m_EgammaCalibrationAndSmearingTools.size(); ++itool) {
222 CHECK(do_energy(*el, itool));
223 }
224
225 m_tree->Fill();
226
227 if (m_keep_one) break;
228 }
229 }
231
232 const xAOD::PhotonContainer* photons = nullptr;
234
235 std::pair<xAOD::PhotonContainer*, xAOD::ShallowAuxContainer*> photons_shallowCopy = xAOD::shallowCopyContainer(*photons);
236 for (xAOD::Photon* ph : *photons_shallowCopy.first) {
237 ATH_MSG_DEBUG("new photon eta: " << ph->eta());
238
239 CHECK(do_truth(*ph));
240 CHECK(do_egamma(*ph));
241
242 if (const auto* vertex = ph->vertex()) {
243 m_ph_Rconv = hypot(vertex->position().x(), vertex->position().y());
244 }
245 else { m_ph_Rconv = 0; }
246
247 const auto original = xAOD::EgammaHelpers::conversionType(ph);
248 if (original == 3) m_ph_convFlag = 2;
249 else if (original != 0) m_ph_convFlag = 1;
250 else m_ph_convFlag = original;
251
252 for (unsigned int itool = 0; itool != m_EgammaCalibrationAndSmearingTools.size(); ++itool) {
253 CHECK(do_energy(*ph, itool));
254 }
255
256 m_tree->Fill();
257
258 if (m_keep_one) break;
259 }
260 }
261
262 return StatusCode::SUCCESS;
263}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define CHECK(...)
Evaluate an expression and check for errors.
StatusCode do_egamma(const xAOD::Egamma &particle)
StatusCode do_truth(const xAOD::Egamma &particle)
StatusCode do_energy(xAOD::Egamma &particle, int itool)
unsigned long long m_EventNumber
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition Egamma_v1.cxx:71
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.
Definition Photon_v1.cxx:61
retrieve(aClass, aKey=None)
Definition PyKernel.py:110
xAOD::EgammaParameters::ConversionType conversionType(const xAOD::Photon *ph)
return the photon conversion type (see EgammaEnums)
@ PileUp
Pile-up vertex.
@ PriVtx
Primary vertex.
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".
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::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

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ finalize()

StatusCode DumpAllSystematics::finalize ( )
virtual

Definition at line 182 of file dumpAllSystematics.cxx.

182 {
183 ATH_MSG_INFO("Particle saved: " << m_tree->GetEntries());
184 if (m_tree->GetEntries() == 0) ATH_MSG_WARNING("no particle saved");
185 ATH_MSG_INFO("Finalizing " << name() << "...");
186
187 return StatusCode::SUCCESS;
188}
#define ATH_MSG_INFO(x)

◆ initialize()

StatusCode DumpAllSystematics::initialize ( )
virtual

Definition at line 44 of file dumpAllSystematics.cxx.

45{
46 // Greet the user:
47 ATH_MSG_INFO ("Initializing " << name() << "...");
48
49 if (m_particle_name.empty()) {
50 ATH_MSG_WARNING("particle property is empty, choose between \"photon\" or \"electron\". Assuming electron.");
51 m_particle_name = "electron";
52 }
53 if (m_particle_name != "electron" and m_particle_name != "photon")
54 {
55 ATH_MSG_FATAL("cannot understand particle property: must be \"electron\" or \"photon\"");
56 }
57
59
60 // Retrieve the tools:
61 ATH_MSG_INFO("retrieving tools");
62 if (!m_EgammaCalibrationAndSmearingTools.retrieve().isSuccess())
63 { ATH_MSG_ERROR("Cannot retrieve calibration tools"); }
64 ATH_MSG_INFO("retrieving tools, done");
65
67 ATH_MSG_FATAL("no tool specified in the job options");
68 return StatusCode::FAILURE;
69 }
70 ATH_MSG_INFO("number of tools: " << m_EgammaCalibrationAndSmearingTools.size());
71 if (m_reco_container_name.empty()) {
73 else m_reco_container_name = "Photons";
74 }
75
76 ATH_MSG_INFO("================================================================================");
77 ATH_MSG_INFO("particle: " << m_particle_name);
78 ATH_MSG_INFO("keep only one: " << m_keep_one);
79 ATH_MSG_INFO("reco container: " << m_reco_container_name);
80 ATH_MSG_INFO("================================================================================");
81
82
83
84 ATH_MSG_DEBUG("creating tree");
85
86 const std::string prefix = m_particle_type == ParticleType::ELECTRON ? "el_" : "ph_";
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");
89 m_tree->Branch("actualIntPerXing", &m_actualIntPerXing, "actualIntPerXing/F");
90 m_tree->Branch("eventNumber", &m_EventNumber, "eventNumber/I");
91 m_tree->Branch("runNumber", &m_RunNumber, "runNumber/I");
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());
97 m_tree->Branch((prefix + "truth_parent_pdgId").c_str(), &m_truth_parent_pdgId, (prefix + "truth_parent_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());
109 m_tree->Branch("ph_truth_isConv", &m_truth_isConv, "ph_truth_isConv/O");
110 m_tree->Branch("ph_truth_Rconv", &m_truth_Rconv, "ph_truth_Rconv/F");
111 m_tree->Branch("ph_Rconv", &m_ph_Rconv, "ph_Rconv/F");
112 m_tree->Branch("ph_convFlag", &m_ph_convFlag, "ph_convFlag/I");
113 }
114 m_tree->Branch("npv", &m_npv, "npv/I");
115
120
121 std::vector<std::vector<std::string> > all_sys_names_per_tool;
122 std::set<std::string> all_sys_names;
123
124 for (unsigned int itool = 0; itool != m_EgammaCalibrationAndSmearingTools.size(); ++itool) {
125 const std::string tool_name = m_EgammaCalibrationAndSmearingTools[itool].name();
126 {
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());
129 }
130
131 const CP::SystematicSet& sys_set = m_EgammaCalibrationAndSmearingTools[itool]->recommendedSystematics();
132 ATH_MSG_INFO("size of the systematics set for tool [" << itool << "] " + m_EgammaCalibrationAndSmearingTools[itool].name() << ": " << sys_set.size());
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);
137
138
139 m_energy_variations[itool].resize(sys_set.size());
140
141 int isys = 0;
142 for (const auto& sys : sys_set) {
143 const std::string branch_name = prefix + tool_name + "_ratio_" + sys.name();
144 m_tree->Branch(branch_name.c_str(), &m_energy_variations[itool][isys],
145 (branch_name + "/F").c_str());
146 ++isys;
147 }
148
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());
151 }
152
153 {
154 std::string header = std::string(45, ' ');
155 for (unsigned int i = 0; i != m_EgammaCalibrationAndSmearingTools.size(); ++i) {
156 header += std::format(" [{}] ", i);
157 }
158 ATH_MSG_INFO(header);
159 }
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 ";
164 else line += " ";
165 }
166 ATH_MSG_INFO(line);
167 }
168
169 if (m_particle_type == ParticleType::ELECTRON) ATH_MSG_INFO("dumping electrons");
170 else if (m_particle_type == ParticleType::PHOTON) ATH_MSG_INFO("dumping photons");
171
172 // output configuration
173 ServiceHandle<ITHistSvc> histSvc("THistSvc", name());
174 CHECK(histSvc.retrieve());
175 const std::string tree_stream = "/DATASTREAM";
176 CHECK(histSvc->regTree(tree_stream + "/myTree", m_tree));
177
178 return StatusCode::SUCCESS;
179}
#define ATH_MSG_FATAL(x)
size_t size() const
returns: size of the set
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::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< Algorithm > >::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.

◆ 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< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
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)

◆ renounceArray()

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

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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_actualIntPerXing

float DumpAllSystematics::m_actualIntPerXing {}
private

Definition at line 53 of file dumpAllSystematics.h.

53{};

◆ m_averageIntPerXing

float DumpAllSystematics::m_averageIntPerXing {}
private

Definition at line 54 of file dumpAllSystematics.h.

54{};

◆ m_cl_E

float DumpAllSystematics::m_cl_E {}
private

Definition at line 73 of file dumpAllSystematics.h.

73{};

◆ m_cl_eta

float DumpAllSystematics::m_cl_eta {}
private

Definition at line 67 of file dumpAllSystematics.h.

67{};

◆ m_cl_etaCalo

float DumpAllSystematics::m_cl_etaCalo {}
private

Definition at line 68 of file dumpAllSystematics.h.

68{};

◆ m_cl_phi

float DumpAllSystematics::m_cl_phi {}
private

Definition at line 66 of file dumpAllSystematics.h.

66{};

◆ m_cl_rawcl_Es0

float DumpAllSystematics::m_cl_rawcl_Es0 {}
private

Definition at line 69 of file dumpAllSystematics.h.

69{};

◆ m_cl_rawcl_Es1

float DumpAllSystematics::m_cl_rawcl_Es1 {}
private

Definition at line 70 of file dumpAllSystematics.h.

70{};

◆ m_cl_rawcl_Es2

float DumpAllSystematics::m_cl_rawcl_Es2 {}
private

Definition at line 71 of file dumpAllSystematics.h.

71{};

◆ m_cl_rawcl_Es3

float DumpAllSystematics::m_cl_rawcl_Es3 {}
private

Definition at line 72 of file dumpAllSystematics.h.

72{};

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_EgammaCalibrationAndSmearingTools

ToolHandleArray<CP::IEgammaCalibrationAndSmearingTool> DumpAllSystematics::m_EgammaCalibrationAndSmearingTools
private

Definition at line 84 of file dumpAllSystematics.h.

◆ m_energy_variations

std::vector<std::vector<float> > DumpAllSystematics::m_energy_variations
private

Definition at line 81 of file dumpAllSystematics.h.

◆ m_energy_variations_sum_down

std::vector<float> DumpAllSystematics::m_energy_variations_sum_down
private

Definition at line 80 of file dumpAllSystematics.h.

◆ m_energy_variations_sum_up

std::vector<float> DumpAllSystematics::m_energy_variations_sum_up
private

Definition at line 79 of file dumpAllSystematics.h.

◆ m_EventNumber

unsigned long long DumpAllSystematics::m_EventNumber {}
private

Definition at line 50 of file dumpAllSystematics.h.

50{};

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_instance_index

int DumpAllSystematics::m_instance_index {}
private

Definition at line 52 of file dumpAllSystematics.h.

52{};

◆ m_keep_one

bool DumpAllSystematics::m_keep_one

Definition at line 34 of file dumpAllSystematics.h.

◆ m_nominal_E

std::vector<float> DumpAllSystematics::m_nominal_E
private

Definition at line 78 of file dumpAllSystematics.h.

◆ m_npv

int DumpAllSystematics::m_npv {}
private

Definition at line 64 of file dumpAllSystematics.h.

64{};

◆ m_particle_name

std::string DumpAllSystematics::m_particle_name

Definition at line 32 of file dumpAllSystematics.h.

◆ m_particle_type

ParticleType DumpAllSystematics::m_particle_type = ParticleType::ELECTRON
private

Definition at line 42 of file dumpAllSystematics.h.

◆ m_ph_convFlag

int DumpAllSystematics::m_ph_convFlag {}
private

Definition at line 75 of file dumpAllSystematics.h.

75{};

◆ m_ph_Rconv

float DumpAllSystematics::m_ph_Rconv {}
private

Definition at line 74 of file dumpAllSystematics.h.

74{};

◆ m_reco_container_name

std::string DumpAllSystematics::m_reco_container_name

Definition at line 33 of file dumpAllSystematics.h.

◆ m_RunNumber

uint32_t DumpAllSystematics::m_RunNumber {}
private

Definition at line 51 of file dumpAllSystematics.h.

51{};

◆ m_tree

TTree* DumpAllSystematics::m_tree {}
private

Definition at line 44 of file dumpAllSystematics.h.

44{};

◆ m_truth_E

float DumpAllSystematics::m_truth_E {}
private

Definition at line 58 of file dumpAllSystematics.h.

58{};

◆ m_truth_eta

float DumpAllSystematics::m_truth_eta {}
private

Definition at line 57 of file dumpAllSystematics.h.

57{};

◆ m_truth_isConv

bool DumpAllSystematics::m_truth_isConv {}
private

Definition at line 62 of file dumpAllSystematics.h.

62{};

◆ m_truth_matched

bool DumpAllSystematics::m_truth_matched {}
private

Definition at line 61 of file dumpAllSystematics.h.

61{};

◆ m_truth_parent_pdgId

int DumpAllSystematics::m_truth_parent_pdgId {}
private

Definition at line 60 of file dumpAllSystematics.h.

60{};

◆ m_truth_pdgId

int DumpAllSystematics::m_truth_pdgId {}
private

Definition at line 59 of file dumpAllSystematics.h.

59{};

◆ m_truth_phi

float DumpAllSystematics::m_truth_phi {}
private

Definition at line 56 of file dumpAllSystematics.h.

56{};

◆ m_truth_pt

float DumpAllSystematics::m_truth_pt {}
private

Definition at line 55 of file dumpAllSystematics.h.

55{};

◆ m_truth_Rconv

float DumpAllSystematics::m_truth_Rconv {}
private

Definition at line 63 of file dumpAllSystematics.h.

63{};

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_wstot

float DumpAllSystematics::m_wstot {}
private

Definition at line 76 of file dumpAllSystematics.h.

76{};

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