ATLAS Offline Software
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 
10 #include "StoreGate/ReadHandle.h"
11 
12 #include <algorithm>
13 
15 
16  ATH_MSG_INFO("in initialize()");
17 
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);
27  m_towerEtGroups = buildToolMap<std::vector<int>>(m_tools, "TileTowerEt",
28  Tile::MAX_ROS, nL1Triggers);
29 
30  m_towerEnergyGroups = buildToolMap<std::vector<int>>(m_tools, "TileAllTowerEnergy",
31  Tile::MAX_ROS, nL1Triggers);
32 
33  //=== TileID
35 
37 }
38 
39 
40 StatusCode 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 }
CaloEnergyCluster::cell_begin
cell_iterator cell_begin() const
Retrieve a STL-type begin() iterator for the cell store.
Definition: CaloEnergyCluster.cxx:270
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TileMonitorAlgorithm::getL1TriggerIndices
std::vector< int > getL1TriggerIndices(uint32_t lvl1TriggerType) const
Return indices of histograms to be filled according fired L1 trigger type.
Definition: TileMonitorAlgorithm.cxx:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
CaloTowerContainer::end
iterator end()
Definition: Calorimeter/CaloEvent/CaloEvent/CaloTowerContainer.h:685
TileCalibUtils.h
TileTowerMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TileTowerMonitorAlgorithm.cxx:14
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
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
TileMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TileMonitorAlgorithm.cxx:10
Tile
Definition: TileVolumeBuilder.h:43
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
TileTowerMonitorAlgorithm::m_towerEtGroups
std::vector< std::vector< int > > m_towerEtGroups
Definition: TileTowerMonitorAlgorithm.h:38
CaloTower::phi
virtual double phi() const override final
get phi data member
Definition: Calorimeter/CaloEvent/CaloEvent/CaloTower.h:144
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TileMonitorAlgorithm::PART_ALL
@ PART_ALL
Definition: TileMonitorAlgorithm.h:47
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
AthMonitorAlgorithm::GetEventInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Definition: AthMonitorAlgorithm.cxx:107
TileTowerMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: TileTowerMonitorAlgorithm.cxx:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
CaloTower
Data class for calorimeter cell towers.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloTower.h:55
CaloTower::energy
virtual double energy() const override final
get energy data member
Definition: Calorimeter/CaloEvent/CaloEvent/CaloTower.h:138
AthMonitorAlgorithm::m_tools
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Definition: AthMonitorAlgorithm.h:338
TileTowerMonitorAlgorithm::m_towerEnergyGroups
std::vector< std::vector< int > > m_towerEnergyGroups
Definition: TileTowerMonitorAlgorithm.h:39
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
TileTowerMonitorAlgorithm::m_caloTowerContainerKey
SG::ReadHandleKey< CaloTowerContainer > m_caloTowerContainerKey
Definition: TileTowerMonitorAlgorithm.h:32
TileMonitorAlgorithm::getNumberOfL1Triggers
int getNumberOfL1Triggers(void) const
Return number of L1 triggers for which histograms should be filled.
Definition: TileMonitorAlgorithm.h:66
TileMonitorAlgorithm::MAX_PART
@ MAX_PART
Definition: TileMonitorAlgorithm.h:47
python.Classes.TileCalibUtils
TileCalibUtils
Definition: TileCalib/TileCalibBlobObjs/python/Classes.py:5
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
xAOD::EventInfo_v1::level1TriggerType
uint16_t level1TriggerType() const
The Level-1 trigger type.
TileTowerMonitorAlgorithm::m_towerEtaPhiGroups
std::vector< int > m_towerEtaPhiGroups
Definition: TileTowerMonitorAlgorithm.h:36
TileTowerMonitorAlgorithm.h
P4EEtaPhiMBase::et
virtual double et() const
transverse energy defined to be e*sin(theta)
Definition: P4EEtaPhiMBase.cxx:106
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
ReadHandle.h
Handle class for reading from StoreGate.
TileTowerMonitorAlgorithm::m_towerEtaPhiDiffGroups
std::vector< int > m_towerEtaPhiDiffGroups
Definition: TileTowerMonitorAlgorithm.h:37
TileTowerMonitorAlgorithm::m_tileID
const TileID * m_tileID
Definition: TileTowerMonitorAlgorithm.h:41
CaloTowerContainer::begin
iterator begin()
Definition: Calorimeter/CaloEvent/CaloEvent/CaloTowerContainer.h:680
Monitored::Timer
A monitored timer.
Definition: MonitoredTimer.h:32
TileMonitorAlgorithm::getPartition
Partition getPartition(const CaloCell *cell, const TileID *tileID) const
Return Partition for Tile cell or MAX_PART otherwise.
Definition: TileMonitorAlgorithm.cxx:109
CaloTower::eta
virtual double eta() const override final
get eta data member
Definition: Calorimeter/CaloEvent/CaloEvent/CaloTower.h:141