ATLAS Offline Software
Loading...
Searching...
No Matches
TileCalCellMonAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TileCalCellMonAlg.h"
9
10#include "AthenaKernel/Units.h"
11
12using Athena::Units::GeV;
13
15
16 ATH_CHECK( detStore()->retrieve(m_tileID) );
17
18 ATH_CHECK( m_cellContainerKey.initialize() );
19 ATH_CHECK( m_caloNoiseKey.initialize() );
20
21 // Excluding histogram for Tile E sample, but including histogram for all samples instead
23 // Histogams per Tile sample
25
27}
28
29StatusCode TileCalCellMonAlg::fillHistograms( const EventContext& ctx ) const {
30
31 // In case you want to measure the execution time
32 auto timer = Monitored::Timer("TIME_execute");
33
34 bool ifPass = true;
35 bool passBeamBackgroundRemoval = false;
36 StatusCode sc = checkFilters(ifPass, passBeamBackgroundRemoval, m_monGroupName, ctx);
37 if(sc.isFailure() || !ifPass) return StatusCode::SUCCESS;
38
39 ATH_MSG_VERBOSE("::checkFilters() passed");
40
41 constexpr int nTileCells = 5184;
42 std::vector<float> cellEnergyToNoiseRatio;
43 cellEnergyToNoiseRatio.reserve(nTileCells);
44
45 std::vector<float> cellNoiseDB;
46 std::vector<float> cellNoiseDBeta;
47 std::vector<float> cellNoiseDBphi;
48 cellNoiseDB.reserve(nTileCells);
49 cellNoiseDBeta.reserve(nTileCells);
50 cellNoiseDBphi.reserve(nTileCells);
51
52 std::vector<float> sampleEta[N_TILE_SAMPLES];
53 std::vector<float> samplePhi[N_TILE_SAMPLES];
54 std::vector<IdentifierHash> hashes;
55
56 const int nCellsOverThr = 500;
57 std::vector<float> overThrEta;
58 std::vector<float> overThrPhi;
59 std::vector<float> overThrTower;
60 std::vector<float> overThrEnergyGeV;
61 overThrEta.reserve(nCellsOverThr);
62 overThrPhi.reserve(nCellsOverThr);
63 overThrTower.reserve(nCellsOverThr);
64 overThrEnergyGeV.reserve(nCellsOverThr);
65
66 std::vector<float> overThrModule[N_TILE_SAMPLES];
67 std::vector<float> overThrModuleEnergy[N_TILE_SAMPLES];
68
71 ATH_CHECK( cellContainer.isValid() );
72
73 for (const CaloCell* cell : *cellContainer) {
74 Identifier id = cell->ID();
75 if (m_tileID->is_tile(id)) {
76 IdentifierHash hash = m_tileID->cell_hash(id);
77 int sample = m_tileID->sample(id);
78 int module = m_tileID->module(id);
79 int tower = m_tileID->tower(id);
80 float energy = cell->energy();
81 double eta = cell->eta();
82 double phi = cell->phi();
83 bool isCellGood = !(cell->badcell());
84
85 if (isCellGood && sample < TileID::SAMP_E) {
86 float cellNoise = (m_twoGaussianNoise) ? caloNoise->getEffectiveSigma(id, cell->gain(), energy)
87 : caloNoise->getNoise(id, cell->gain());
88
89 if (std::isfinite(cellNoise) && cellNoise > 0 && energy != 0) {
90 float energyToNoiseRatio = energy / cellNoise;
91 cellEnergyToNoiseRatio.push_back(energyToNoiseRatio);
92
93 if (std::abs(energyToNoiseRatio) > 4.0) {
94 hashes.push_back(hash);
95 sampleEta[sample].push_back(eta);
96 samplePhi[sample].push_back(phi);
97
98 ATH_MSG_VERBOSE( "Cell rs=" << energyToNoiseRatio << " e=" << energy << " eta=" << eta << " phi="<< phi );
99 ATH_MSG_VERBOSE( "hash=" << hash << " module= " << module + 1 << " sample=" << sample );
100 }
101
102 cellNoiseDB.push_back(cellNoise);
103 cellNoiseDBeta.push_back(eta);
104 cellNoiseDBphi.push_back(phi);
105 }
106 }
107
108 if (energy > m_energyThreshold) {
109 float energyGeV = energy / GeV;
110
111 overThrEta.push_back(eta);
112 overThrPhi.push_back(phi);
113 overThrTower.push_back(tower + 1);
114 overThrEnergyGeV.push_back(energyGeV);
115 if (sample<0 or sample>=N_TILE_SAMPLES){
116 ATH_MSG_ERROR("TileCalCellMonAlg::fillHistograms: sample = "<<sample<<", array size = "<<N_TILE_SAMPLES);
117 continue;
118 }
119 overThrModule[sample].push_back(module + 1);
120 overThrModuleEnergy[sample].push_back(energyGeV);
121 }
122 }
123 }
124
125
126 // Excluding Tile E sample, but using all samples instead
127 int allSamples = TileID::SAMP_E;
128 for (int sample = 0; sample < TileID::SAMP_E; ++sample) {
129 if (!sampleEta[sample].empty()) {
130 auto monEta = Monitored::Collection("eta", sampleEta[sample]);
131 auto monPhi = Monitored::Collection("phi", samplePhi[sample]);
132 fill(m_tools[m_noiseEtaPhiGroups[sample]], monEta, monPhi);
133 fill(m_tools[m_noiseEtaPhiGroups[allSamples]], monEta, monPhi);
134 }
135 }
136
137 if (!hashes.empty()) {
138 auto monHash = Monitored::Collection("hash", hashes);
139 fill("CellsXNoiseXHash", monHash);
140 }
141
142 if (!cellEnergyToNoiseRatio.empty()) {
143 auto monCellEnergyToNoiseRatio = Monitored::Collection("noise", cellEnergyToNoiseRatio);
144 fill("CellsNoiseTile", monCellEnergyToNoiseRatio);
145 }
146
147 if (!cellNoiseDB.empty()) {
148 auto monCellNoise = Monitored::Collection("noise", cellNoiseDB);
149 auto monEta = Monitored::Collection("eta", cellNoiseDBeta);
150 auto monPhi = Monitored::Collection("phi", cellNoiseDBphi);
151 fill("CellsNoiseXEta", monEta, monCellNoise);
152 fill("CellsNoiseXPhi", monPhi, monCellNoise);
153 }
154
155
156 if (!overThrEnergyGeV.empty()) {
157
158 auto monCellsNumber = Monitored::Scalar<unsigned int>("nCells", overThrEnergyGeV.size());
159 fill("CellsXN", monCellsNumber);
160
161 auto monEnergy = Monitored::Collection("energy", overThrEnergyGeV);
162 fill("CellsXE", monEnergy);
163
164 auto monEta = Monitored::Collection("eta", overThrEta);
165 fill("CellsXEta", monEta, monEnergy);
166
167 auto monPhi = Monitored::Collection("phi", overThrPhi);
168 fill("CellsXPhi", monPhi, monEnergy);
169
170 auto monTower = Monitored::Collection("tower", overThrTower);
171 fill("CellsXTower", monTower, monEnergy);
172
173 fill("CellsXEtaVSPhi", monEta, monPhi);
174
175 for (int sample = 0; sample <= TileID::SAMP_E; ++sample) {
176 if (!overThrModuleEnergy[sample].empty()) {
177 auto monModule = Monitored::Collection("module", overThrModule[sample]);
178 auto monEnergy = Monitored::Collection("energy", overThrModuleEnergy[sample]);
179 fill(m_tools[m_energyModuleGroups[sample]], monModule, monEnergy);
180 }
181 }
182 }
183
184 fill("TileCalCellMonExecuteTime", timer);
185
186 return StatusCode::SUCCESS;
187}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
Handle class for reading from StoreGate.
Wrapper to avoid constant divisions when using units.
static const Attributes_t empty
const ServiceHandle< StoreGateSvc > & detStore() const
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
virtual StatusCode initialize()
initialize
StatusCode checkFilters(bool &ifPass, bool &passBeamBackgroundRemoval, const std::string &MonGroupName, const EventContext &ctx) const
This is a "hash" representation of an Identifier.
Declare a monitored scalar variable.
A monitored timer.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::vector< int > m_energyModuleGroups
static constexpr int N_TILE_SAMPLES
virtual StatusCode initialize() override
initialize
Gaudi::Property< bool > m_twoGaussianNoise
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
SG::ReadCondHandleKey< CaloNoise > m_caloNoiseKey
Key of the CaloNoise Conditions data object.
std::vector< int > m_noiseEtaPhiGroups
Gaudi::Property< std::string > m_monGroupName
Gaudi::Property< float > m_energyThreshold
const TileID * m_tileID
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
std::vector< V > buildToolMap(const ToolHandleArray< GenericMonitoringTool > &tools, const std::string &baseName, int nHist)
Builds an array of indices (base case)
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
void fill(H5::Group &out_file, size_t iterations)