ATLAS Offline Software
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"
7 #include "StoreGate/ReadHandle.h"
9 
10 #include "AthenaKernel/Units.h"
11 
12 using Athena::Units::GeV;
13 
15 
17 
20 
21  // Excluding histogram for Tile E sample, but including histogram for all samples instead
22  m_noiseEtaPhiGroups = Monitored::buildToolMap<int>(m_tools, "CellsNoiseXEtaVSPhi", N_TILE_SAMPLES);
23  // Histogams per Tile sample
24  m_energyModuleGroups = Monitored::buildToolMap<int>(m_tools, "CellsXModule", N_TILE_SAMPLES);
25 
27 }
28 
29 StatusCode 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  const 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)) {
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  overThrModule[sample].push_back(module + 1);
116  overThrModuleEnergy[sample].push_back(energyGeV);
117  }
118  }
119  }
120 
121 
122  // Excluding Tile E sample, but using all samples instead
123  int allSamples = TileID::SAMP_E;
124  for (int sample = 0; sample < TileID::SAMP_E; ++sample) {
125  if (!sampleEta[sample].empty()) {
126  auto monEta = Monitored::Collection("eta", sampleEta[sample]);
127  auto monPhi = Monitored::Collection("phi", samplePhi[sample]);
128  fill(m_tools[m_noiseEtaPhiGroups[sample]], monEta, monPhi);
129  fill(m_tools[m_noiseEtaPhiGroups[allSamples]], monEta, monPhi);
130  }
131  }
132 
133  if (!hashes.empty()) {
134  auto monHash = Monitored::Collection("hash", hashes);
135  fill("CellsXNoiseXHash", monHash);
136  }
137 
138  if (!cellEnergyToNoiseRatio.empty()) {
139  auto monCellEnergyToNoiseRatio = Monitored::Collection("noise", cellEnergyToNoiseRatio);
140  fill("CellsNoiseTile", monCellEnergyToNoiseRatio);
141  }
142 
143  if (!cellNoiseDB.empty()) {
144  auto monCellNoise = Monitored::Collection("noise", cellNoiseDB);
145  auto monEta = Monitored::Collection("eta", cellNoiseDBeta);
146  auto monPhi = Monitored::Collection("phi", cellNoiseDBphi);
147  fill("CellsNoiseXEta", monEta, monCellNoise);
148  fill("CellsNoiseXPhi", monPhi, monCellNoise);
149  }
150 
151 
152  if (!overThrEnergyGeV.empty()) {
153 
154  auto monCellsNumber = Monitored::Scalar<unsigned int>("nCells", overThrEnergyGeV.size());
155  fill("CellsXN", monCellsNumber);
156 
157  auto monEnergy = Monitored::Collection("energy", overThrEnergyGeV);
158  fill("CellsXE", monEnergy);
159 
160  auto monEta = Monitored::Collection("eta", overThrEta);
161  fill("CellsXEta", monEta, monEnergy);
162 
163  auto monPhi = Monitored::Collection("phi", overThrPhi);
164  fill("CellsXPhi", monPhi, monEnergy);
165 
166  auto monTower = Monitored::Collection("tower", overThrTower);
167  fill("CellsXTower", monTower, monEnergy);
168 
169  fill("CellsXEtaVSPhi", monEta, monPhi);
170 
171  for (int sample = 0; sample <= TileID::SAMP_E; ++sample) {
172  if (!overThrModuleEnergy[sample].empty()) {
173  auto monModule = Monitored::Collection("module", overThrModule[sample]);
174  auto monEnergy = Monitored::Collection("energy", overThrModuleEnergy[sample]);
175  fill(m_tools[m_energyModuleGroups[sample]], monModule, monEnergy);
176  }
177  }
178  }
179 
180  fill("TileCalCellMonExecuteTime", timer);
181 
182  return StatusCode::SUCCESS;
183 }
python.root_lsr_rank.hashes
hashes
Definition: root_lsr_rank.py:34
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CaloMonAlgBase::checkFilters
StatusCode checkFilters(bool &ifPass, bool &passBeamBackgroundRemoval, const std::string &MonGroupName, const EventContext &ctx) const
Definition: CaloMonAlgBase.cxx:61
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
TileCalCellMonAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: TileCalCellMonAlg.cxx:29
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TileCalCellMonAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: TileCalCellMonAlg.cxx:14
Tile_Base_ID::sample
int sample(const Identifier &id) const
Definition: Tile_Base_ID.cxx:171
Tile_Base_ID::tower
int tower(const Identifier &id) const
Definition: Tile_Base_ID.cxx:165
Tile_Base_ID::SAMP_E
@ SAMP_E
Definition: Tile_Base_ID.h:55
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TileCalCellMonAlg.h
CaloMonAlgBase::initialize
virtual StatusCode initialize()
initialize
Definition: CaloMonAlgBase.cxx:25
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
ReadCondHandle.h
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:86
TileID.h
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
python.PyAthena.module
module
Definition: PyAthena.py:134
TileCalCellMonAlg::m_tileID
const TileID * m_tileID
Definition: TileCalCellMonAlg.h:45
TileCalCellMonAlg::m_energyThreshold
Gaudi::Property< float > m_energyThreshold
Definition: TileCalCellMonAlg.h:32
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
Tile_Base_ID::module
int module(const Identifier &id) const
Definition: Tile_Base_ID.cxx:159
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TileCalCellMonAlg::m_cellContainerKey
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
Definition: TileCalCellMonAlg.h:35
TileCalCellMonAlg.sc
sc
Definition: TileCalCellMonAlg.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AtlasDetectorID::is_tile
bool is_tile(Identifier id) const
Definition: AtlasDetectorID.h:695
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TileCalCellMonAlg::m_twoGaussianNoise
Gaudi::Property< bool > m_twoGaussianNoise
Definition: TileCalCellMonAlg.h:30
TileCalCellMonAlg::m_noiseEtaPhiGroups
std::vector< int > m_noiseEtaPhiGroups
Definition: TileCalCellMonAlg.h:48
AthMonitorAlgorithm::m_tools
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Definition: AthMonitorAlgorithm.h:338
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TileCalCellMonAlg::m_caloNoiseKey
SG::ReadCondHandleKey< CaloNoise > m_caloNoiseKey
Key of the CaloNoise Conditions data object.
Definition: TileCalCellMonAlg.h:42
Units.h
Wrapper to avoid constant divisions when using units.
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
TileCalCellMonAlg::N_TILE_SAMPLES
static const int N_TILE_SAMPLES
Definition: TileCalCellMonAlg.h:46
Tile_Base_ID::cell_hash
IdentifierHash cell_hash(const Identifier &cell_id) const
fast conversion from ID to hash for cells
Definition: Tile_Base_ID.cxx:1030
TileCalCellMonAlg::m_energyModuleGroups
std::vector< int > m_energyModuleGroups
Definition: TileCalCellMonAlg.h:49
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
ReadHandle.h
Handle class for reading from StoreGate.
TileCalCellMonAlg::m_monGroupName
Gaudi::Property< std::string > m_monGroupName
Definition: TileCalCellMonAlg.h:29
IdentifierHash
Definition: IdentifierHash.h:38
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
Monitored::Timer
A monitored timer.
Definition: MonitoredTimer.h:32