ATLAS Offline Software
Loading...
Searching...
No Matches
CaloMomentsDumper.cxx
Go to the documentation of this file.
1//
2// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3//
4// Dear emacs, this is -*- c++ -*-
5//
6
7#include "CaloMomentsDumper.h"
9
10#include <fstream>
11#include <filesystem>
12
13using namespace CaloRecGPU;
14
15
16StatusCode CaloMomentsDumper::execute (const EventContext & ctx, xAOD::CaloClusterContainer * cluster_collection) const
17{
18
19 const auto err1 = StandaloneDataIO::prepare_folder_for_output(std::string(m_savePath));
21 {
22 return StatusCode::FAILURE;
23 }
24
25 const std::filesystem::path save_file = m_savePath + "/" + StandaloneDataIO::build_filename((m_filePrefix.size() > 0 ? m_filePrefix + "_moments" : "moments"),
26 ctx.evt(), m_fileSuffix, "txt", m_numWidth);
27
28 std::ofstream out_file(save_file);
29
30 for (auto cluster_iter = cluster_collection->begin(); cluster_iter != cluster_collection->end(); ++cluster_iter)
31 {
32 const xAOD::CaloCluster * cluster = (*cluster_iter);
33 const CaloClusterCellLink * cell_links = cluster->getCellLinks();
34 if (!cell_links)
35 {
36 ATH_MSG_ERROR("Can't get valid links to CaloCells (CaloClusterCellLink)!");
37 return StatusCode::FAILURE;
38 }
39
40 out_file << cluster->pt() << " " << cluster->eta() << " " << cluster->phi() << " " << cluster->m() << " " << cluster->e() << " " << cluster->rapidity() << " " << cluster->et() << "\n";
41 out_file << "------------------------------------------------\n";
42
43 for (int i = 0; i < 28; ++i)
44 {
45 out_file << cluster->eSample((CaloSampling::CaloSample) i) << " " << cluster->etaSample((CaloSampling::CaloSample) i)
46 << " " << cluster->phiSample((CaloSampling::CaloSample) i) << " " << cluster->energy_max((CaloSampling::CaloSample) i)
47 << " " << cluster->etamax((CaloSampling::CaloSample) i) << " " << cluster->phimax((CaloSampling::CaloSample) i)
48 << " " << cluster->numberCellsInSampling((CaloSampling::CaloSample) i) << "\n";
49 }
50
51 out_file << "------------------------------------------------\n";
52 out_file << cluster->numberCells() << " " << cluster->time() << " " << cluster->secondTime() << " " << cluster->samplingPattern() << " " << cluster->size() << "\n";
53 out_file << "------------------------------------------------\n";
54
62
63 << "\n2:\n" << cluster->getMomentValue(xAOD::CaloCluster::CENTER_X)
70
71 << "\n3:\n" << cluster->getMomentValue(xAOD::CaloCluster::ENG_FRAC_EM)
77
87
88 << "\n5:\n" << cluster->getMomentValue(xAOD::CaloCluster::AVG_LAR_Q)
92 << " " << cluster->getMomentValue(xAOD::CaloCluster::PTD)
93 << " " << cluster->getMomentValue(xAOD::CaloCluster::MASS)
94
100
102
111
112 << "\n8:\n" << cluster->getMomentValue(xAOD::CaloCluster::ENG_CALIB_TOT)
122
135
136 out_file << "\n------------------------------------------------\n";
137 out_file << "------------------------------------------------\n";
138
139 out_file << "\n\n";
140
141 }
142
143 out_file << std::endl;
144
145 return StatusCode::SUCCESS;
146
147}
#define ATH_MSG_ERROR(x)
Gaudi::Property< std::string > m_savePath
The path specifying the folder to which the files should be saved.
Gaudi::Property< std::string > m_fileSuffix
The suffix of the saved files.
Gaudi::Property< std::string > m_filePrefix
The prefix of the saved files.
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *cluster_collection) const override
Gaudi::Property< unsigned int > m_numWidth
The number of digits to reserve for the events.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
double getMomentValue(MomentType type) const
Retrieve individual moment - no check for existance! Returns -999 on error.
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters)
float phiSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
float energy_max(const CaloSample sampling) const
Retrieve maximum cell energy in given sampling.
int numberCellsInSampling(const CaloSample samp, bool isInnerWheel=false) const
Returns number of cells in given sampling.
virtual double m() const
The invariant mass of the particle.
flt_t time() const
Access cluster time.
virtual double eta() const
The pseudorapidity ( ) of the particle.
int numberCells() const
Return total number of cells in cluster.
size_t size() const
size method (forwarded from CaloClusterCellLink obj)
virtual double e() const
The total energy of the particle.
float eSample(const CaloSample sampling) const
flt_t secondTime() const
Access second moment of cell timing distribution.
virtual double phi() const
The azimuthal angle ( ) of the particle.
float etamax(const CaloSample sampling) const
Retrieve of cell with maximum energy in given sampling.
@ ENG_CALIB_OUT_M
Attached Calibration Hit energy outside clusters but inside the calorimeter with medium matching (Ang...
@ PTD
relative spread of pT of constiuent cells = sqrt(n)*RMS/Mean
@ SECOND_ENG_DENS
Second Moment in E/V.
@ DELTA_PHI
Angular shower axis deviation ( ) from IP-to-Center.
@ ETA2CALOFRAME
Eta of sampling 2 in the calo frame (for egamma)
@ DELTA_ALPHA
Angular shower axis deviation ( ) from IP-to-Center.
@ OOC_WEIGHT
Out-of-cluster weight (E_ooc/E_w)
@ AVG_TILE_Q
Sum(E_cell_Tile^2 Q_cell_Tile)/Sum(E_cell_Tile^2)
@ DELTA_THETA
Angular shower axis deviation ( ) from IP-to-Center.
@ SECOND_LAMBDA
Second Moment in .
@ ETACALOFRAME
Eta in the calo frame (for egamma)
@ FIRST_PHI
First Moment in .
@ ENG_CALIB_OUT_L
Attached Calibration Hit energy outside clusters but inside the calorimeter with loose matching (Angl...
@ CELL_SIGNIFICANCE
Cell significance = E/sig of the cell with the largest |E|/sig.
@ CELL_SIG_SAMPLING
CaloSample of the cell with the largest |E|/sig.
@ EM_PROBABILITY
Classification probability to be em-like.
@ PHI2CALOFRAME
Phi of sampling 2 in the calo frame (for egamma)
@ VERTEX_FRACTION
Vertex fraction of this cluster wrt.
@ ENG_CALIB_DEAD_T
Attached Calibration Hit energy in dead material with tight matching (Angle < 0.3).
@ NVERTEX_FRACTION
slightly updated vertex fraction more pile up independent (similar to nJVF)
@ SECOND_TIME
Second moment of cell time distribution in cluster.
@ N_BAD_CELLS_CORR
Number of bad cells with energy density average correction applied.
@ DM_WEIGHT
Dead-material weight (E_dm/E_ooc)
@ LATERAL
Normalized lateral moment.
@ N_BAD_CELLS
number of bad cells
@ LONGITUDINAL
Normalized longitudinal moment.
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
@ AVG_LAR_Q
Sum(E_cell_LAr^2 Q_cell_LAr)/Sum(E_cell_LAr^2)
@ ENG_CALIB_DEAD_UNCLASS
Attached Calibration Hit energy in dead material in unclassified areas of the detector.
@ PHI1CALOFRAME
Phi of sampling 1 in the calo frame (for egamma)
@ ENG_FRAC_EM
Energy fraction in EM calorimeters.
@ SECOND_R
Second Moment in .
@ ENG_CALIB_DEAD_HEC0
Attached Calibration Hit energy in dead material between EME3 and HEC0.
@ FIRST_ETA
First Moment in .
@ PHICALOFRAME
Phi in the calo frame (for egamma)
@ ENG_BAD_HV_CELLS
Total em-scale energy of cells with bad HV in this cluster.
@ FIRST_ENG_DENS
First Moment in E/V.
@ HAD_WEIGHT
Hadronic weight (E_w/E_em)
@ ENG_CALIB_DEAD_TILEG3
Attached Calibration Hit energy in dead material before scintillator.
@ N_BAD_HV_CELLS
number of cells with bad HV
@ ENG_FRAC_CORE
Energy fraction of the sum of the hottest cells in each sampling.
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
@ SIGNIFICANCE
Cluster significance.
@ CENTER_MAG
Cluster Centroid ( )
@ MASS
cell based mass i.e. the mass of the 4-vector sum of all massless positive energetic cells
@ ENG_CALIB_DEAD_M
Attached Calibration Hit energy in dead material with medium matching (Angle < 0.5).
@ ENG_CALIB_FRAC_REST
Calibration Hit energy inside the cluster caused by other particles.
@ ENG_CALIB_DEAD_L
Attached Calibration Hit energy in dead material with loose matching (Angle < 1.0).
@ ENG_CALIB_DEAD_EME0
Attached Calibration Hit energy in dead material before EME0, between EME0 and EME1.
@ ENG_CALIB_DEAD_TILE0
Attached Calibration Hit energy in dead material between EMB3 and TILE0.
@ CENTER_Z
Cluster Centroid ( )
@ BAD_CELLS_CORR_E
Energy of bad cells with energy density average correction applied.
@ ETA1CALOFRAME
Eta of sampling 1 in the calo frame (for egamma)
@ ENG_CALIB_FRAC_EM
Calibration Hit energy inside the cluster caused by e/gamma/pi0.
@ ENG_BAD_CELLS
Total em-scale energy of bad cells in this cluster.
@ ENG_CALIB_DEAD_FCAL
Attached Calibration Hit energy in dead material before FCAL, between FCAL and HEC.
@ ENG_CALIB_TOT
Calibration Hit energy inside the cluster.
@ ENG_CALIB_OUT_T
Attached Calibration Hit energy outside clusters but inside the calorimeter with tight matching (Angl...
@ ENG_CALIB_DEAD_LEAKAGE
Attached Calibration Hit energy in dead material behind calorimeters.
@ ENG_CALIB_FRAC_HAD
Calibration Hit energy inside the cluster caused by charged pi+ and pi-.
@ ENG_CALIB_EMB0
Calibration Hit energy inside the cluster barrel presampler.
@ ENG_CALIB_EME0
Calibration Hit energy inside the cluster endcap presampler.
@ ENG_POS
Total positive Energy of this cluster.
@ BADLARQ_FRAC
Energy fraction of LAr cells with quality larger than a given cut.
@ CENTER_X
Cluster Centroid ( )
@ ENG_CALIB_DEAD_EMB0
Attached Calibration Hit energy in dead material before EMB0, between EMB0 and EMB1.
@ ISOLATION
Energy weighted fraction of non-clustered perimeter cells.
@ ENG_CALIB_DEAD_TOT
Attached Calibration Hit energy in dead material.
@ CENTER_Y
Cluster Centroid ( )
@ ENG_CALIB_TILEG3
Calibration Hit energy inside the cluster scintillator.
@ TILE_CONFIDENCE_LEVEL
Confidence Level of a tile calorimeter cluster to be noise.
float etaSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
virtual double rapidity() const
The true rapidity (y) of the particle.
float phimax(const CaloSample sampling) const
Retrieve of cell with maximum energy in given sampling.
unsigned samplingPattern() const
Access to sampling pattern (one bit per sampling) (Method may be removed later)
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
static std::string build_filename(const std::string &prefix, const std::string &text, const std::string &suffix, const std::string &ext)
static ErrorState prepare_folder_for_output(const std::filesystem::path &folder, const bool output_errors=true)