ATLAS Offline Software
Loading...
Searching...
No Matches
TileTowerMonitorAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
7
9
11
12#include <algorithm>
13
15
16 ATH_MSG_INFO("in initialize()");
17
18 ATH_CHECK( m_caloTowerContainerKey.initialize() );
19
20 using Tile = TileCalibUtils;
21 using namespace Monitored;
22
23 int nL1Triggers = getNumberOfL1Triggers();
24
25 m_towerEtaPhiGroups = buildToolMap<int>(m_tools, "TileTowerEtaPhi", nL1Triggers);
26 m_towerEtaPhiDiffGroups = buildToolMap<int>(m_tools, "TileTowerEtaPhiDiff", nL1Triggers);
28 Tile::MAX_ROS, nL1Triggers);
29
31 Tile::MAX_ROS, nL1Triggers);
32
33 //=== TileID
34 ATH_CHECK( detStore()->retrieve(m_tileID) );
35
37}
38
39
40StatusCode TileTowerMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
41
42
43 // In case you want to measure the execution time
44 auto timer = Monitored::Timer("TIME_execute");
45
46 const xAOD::EventInfo* eventInfo = GetEventInfo(ctx).get();
47
48 int nTowers[MAX_PART] = { 0, 0, 0, 0, 0 };
49
50 // Indices of L1 trigger histograms to be filled in the current event
51 std::vector<int> l1TriggersIndices = getL1TriggerIndices(eventInfo->level1TriggerType());
52
54 ATH_CHECK( caloTowerContainer.isValid() );
55
56 const CaloTower* mostEnTower = *std::max_element(caloTowerContainer->begin(), caloTowerContainer->end(),
57 [] (const CaloTower* tower1, const CaloTower* tower2) {
58 return tower1->energy() < tower2->energy();
59 });
60
61
62 double mostEnTowerPhi = 0.0;
63
64 if (mostEnTower->energy() > 0.0) {
65 mostEnTowerPhi = mostEnTower->phi();
66
67 auto monEta = Monitored::Scalar<float>("eta", mostEnTower->eta());
68 auto monPhi = Monitored::Scalar<float>("phi", mostEnTower->phi());
69 for (int l1TriggerIdx : l1TriggersIndices) {
70 fill(m_tools[m_towerEtaPhiGroups[l1TriggerIdx]], monEta, monPhi);
71 }
72
73 int partition = getPartition(*(mostEnTower->cell_begin()), m_tileID);
74 if (partition < PART_ALL) {
75 auto monEt = Monitored::Scalar<float>("Et", mostEnTower->et());
76 for (int l1TriggerIdx : l1TriggersIndices) {
77 fill(m_tools[m_towerEtGroups[partition][l1TriggerIdx]], monEt);
78 fill(m_tools[m_towerEtGroups[PART_ALL][l1TriggerIdx]], monEt);
79 }
80 }
81 }
82
83
84 const CaloTower* correlTower = nullptr;
85 double correlTowerEnergy = 0.0;
86
87 for (const CaloTower* tower : *caloTowerContainer) {
88
89 double energy = tower->energy();
90 if (energy > 0.0) {
91 if (tower->getNumberOfCells() > 0) {
92 int partition = getPartition(*(tower->cell_begin()), m_tileID);
93 if (partition < PART_ALL) {
94 ++nTowers[partition];
95 ++nTowers[PART_ALL];
96
97 auto monEnergy = Monitored::Scalar<float>("energy", energy);
98 for (int l1TriggerIdx : l1TriggersIndices) {
99 fill(m_tools[m_towerEnergyGroups[partition][l1TriggerIdx]], monEnergy);
100 fill(m_tools[m_towerEnergyGroups[PART_ALL][l1TriggerIdx]], monEnergy);
101 }
102 }
103 }
104
105 if (tower->phi() * mostEnTowerPhi < 0.0 // Opposite to the most energetic tower
106 && tower->energy() > correlTowerEnergy) { // With maximum energy
107 correlTower = tower;
108 correlTowerEnergy = tower->energy();
109 }
110
111
112 ATH_MSG_VERBOSE( "Tower: nCells= " << tower->getNumberOfCells()
113 << ", Energy= " << energy
114 << ", Et()= " << tower->et()
115 << ", Eta= " << tower->eta()
116 << ", Phi= " << tower->phi() );
117
118 }
119 }
120
121 ATH_MSG_DEBUG( "Total Number of towers in the event: " << nTowers[PART_ALL] );
122
123 if (mostEnTower->energy() > 0.0 && correlTower) {
124 float etaDelta = std::abs(correlTower->eta()) - std::abs(mostEnTower->eta());
125 float phiDelta = std::abs(correlTower->phi() - mostEnTower->phi());
126
127 auto monEta = Monitored::Scalar<float>("eta", etaDelta);
128 auto monPhi = Monitored::Scalar<float>("phi", phiDelta);
129 for (int l1TriggerIdx : l1TriggersIndices) {
130 fill(m_tools[m_towerEtaPhiDiffGroups[l1TriggerIdx]], monEta, monPhi);
131 }
132 }
133
134
135 fill("TileTowerMonExecuteTime", timer);
136
137 return StatusCode::SUCCESS;
138}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
const ServiceHandle< StoreGateSvc > & detStore() const
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
cell_iterator cell_begin() const
Retrieve a STL-type begin() iterator for the cell store.
Data class for calorimeter cell towers.
virtual double energy() const override final
get energy data member
virtual double phi() const override final
get phi data member
virtual double eta() const override final
get eta data member
Declare a monitored scalar variable.
A monitored timer.
virtual double et() const
transverse energy defined to be e*sin(theta)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Static class providing several utility functions and constants.
int getNumberOfL1Triggers(void) const
Return number of L1 triggers for which histograms should be filled.
virtual StatusCode initialize() override
initialize
std::vector< int > getL1TriggerIndices(uint32_t lvl1TriggerType) const
Return indices of histograms to be filled according fired L1 trigger type.
Partition getPartition(const CaloCell *cell, const TileID *tileID) const
Return Partition for Tile cell or MAX_PART otherwise.
virtual StatusCode initialize() override
initialize
SG::ReadHandleKey< CaloTowerContainer > m_caloTowerContainerKey
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
std::vector< std::vector< int > > m_towerEtGroups
std::vector< std::vector< int > > m_towerEnergyGroups
uint16_t level1TriggerType() const
The Level-1 trigger type.
Generic monitoring tool for athena components.
std::vector< V > buildToolMap(const ToolHandleArray< GenericMonitoringTool > &tools, const std::string &baseName, int nHist)
Builds an array of indices (base case)
EventInfo_v1 EventInfo
Definition of the latest event info version.
void fill(H5::Group &out_file, size_t iterations)