ATLAS Offline Software
TileMuonFitMonitorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 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 
18  ATH_CHECK( m_cosmicMuonContainerKey.initialize() );
19 
20  using namespace Monitored;
21  int nL1Triggers = getNumberOfL1Triggers();
22 
23  m_nMuGroups = buildToolMap<int>(m_tools, "TileMuonFitNum", nL1Triggers);
24  m_muEneGroups = buildToolMap<int>(m_tools, "TileMuonFitEnergy", nL1Triggers);
25  m_muTimeGroups = buildToolMap<int>(m_tools, "TileMuonFitTime", nL1Triggers);
26  m_muPathGroups = buildToolMap<int>(m_tools, "TileMuonFitPath", nL1Triggers);
27  m_muNCellsGroups = buildToolMap<int>(m_tools, "TileMuonFitNCells", nL1Triggers);
28  m_muPositionGroups = buildToolMap<int>(m_tools, "TileMuonFitPosition", nL1Triggers);
29  m_muPositionTimeGroups = buildToolMap<int>(m_tools, "TileMuonFitPositionTime", nL1Triggers);
30  m_muEneDensityGroups = buildToolMap<int>(m_tools, "TileMuonFitEneDensity", nL1Triggers);
31  m_muDirectionPhiGroups = buildToolMap<int>(m_tools, "TileMuonFitDirectionPhi", nL1Triggers);
32  m_muDirectionThetaGroups = buildToolMap<int>(m_tools, "TileMuonFitDirectionTheta", nL1Triggers);
33  m_muPosDirectionThetaGroups = buildToolMap<int>(m_tools, "TileMuonFitPosDirectionTheta", nL1Triggers);
34  m_muPartitionTimeGroups = buildToolMap<int>(m_tools, "TileMuonFitPartitionTime", nL1Triggers);
35 
36  //=== TileID
38 
40 }
41 
42 
43 StatusCode TileMuonFitMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
44 
45 
46  // In case you want to measure the execution time
47  auto timer = Monitored::Timer("TIME_execute");
48 
49  const xAOD::EventInfo* eventInfo = GetEventInfo(ctx).get();
50 
51  // Indices of L1 trigger histograms to be filled in the current event
52  std::vector<int> l1TriggersIndices = getL1TriggerIndices(eventInfo->level1TriggerType());
53 
54  std::vector<int> muNCells;
55  std::vector<float> muTime;
56  std::vector<float> muFullPath;
57  std::vector<float> muFullEnergy;
58  std::vector<float> muEnergyDensity;
59  std::vector<float> muPositionX;
60  std::vector<float> muPositionZ;
61  std::vector<float> muDirectionPhi;
62  std::vector<float> muDirectionTheta;
63  std::vector<float> muPosTime;
64  std::vector<float> muPosTimeZ;
65  std::vector<float> muPartition;
66  std::vector<float> muPartitionTime;
67 
69  ATH_CHECK( cosmicMuonContainer.isValid() );
70 
71  for (const TileCosmicMuon* cosmicMuon : *cosmicMuonContainer) {
72  int muTrackNCells = cosmicMuon->GetTrackNCells();
73 
74  if (muTrackNCells > 2) { // we want the number of cells in the track to be more than 2
75 
76  muNCells.push_back(muTrackNCells);
77  muTime.push_back(cosmicMuon->GetTime());
78  muPositionX.push_back(cosmicMuon->GetPositionX());
79  muPositionZ.push_back(cosmicMuon->GetPositionZ());
80  muDirectionPhi.push_back(std::sin(cosmicMuon->GetDirectionPhi()));
81  muDirectionTheta.push_back(std::sin(cosmicMuon->GetDirectionTheta()));
82 
83  float fullPath = cosmicMuon->GetFullPath();
84  float fullEnergy = cosmicMuon->GetFullEnergy();
85  muFullPath.push_back(fullPath);
86  muFullEnergy.push_back(fullEnergy);
87 
88  if (fullPath > 0.) {
89  float eneDensity = fullEnergy / fullPath;
90  muEnergyDensity.push_back(eneDensity);
91 
92  if ((fullPath < 10000.) && (eneDensity > 1.05) && (eneDensity < 7.5)) {
93  muPosTime.push_back(cosmicMuon->GetTime());
94  muPosTimeZ.push_back(cosmicMuon->GetPositionZ());
95 
96  // Find Tile cells partitions
97  std::set<int> partitions;
98  for (int cellIdx = 0; cellIdx < muTrackNCells; ++cellIdx) {
99  IdentifierHash hash = cosmicMuon->GetTrackCellHash(cellIdx);
101  if (partition != MAX_PART) {
102  partitions.insert(partition);
103  }
104  }
105 
106  if (partitions.size() == 1) { // Check that all Tile cells belong to the same partiton
107  int partition = *partitions.begin();
108  muPartition.push_back(partition);
109  muPartitionTime.push_back(cosmicMuon->GetTime());
110  }
111 
112  }
113  }
114  }
115  }
116 
117 
118  if (!muTime.empty()) {
119  auto nMuons = Monitored::Scalar<float>("nMuons", muTime.size());
120  auto monNCells = Monitored::Collection("nCells", muNCells);
121  auto monTime = Monitored::Collection("time", muTime);
122  auto monPath = Monitored::Collection("path", muFullPath);
123  auto monEnergy = Monitored::Collection("energy", muFullEnergy);
124  auto monPositionX = Monitored::Collection("xPosition", muPositionX);
125  auto monPositionZ = Monitored::Collection("zPosition", muPositionZ);
126  auto monDirectionPhi = Monitored::Collection("phi", muDirectionPhi);
127  auto monDirectionTheta = Monitored::Collection("theta", muDirectionTheta);
128  for (int l1TriggerIdx : l1TriggersIndices) {
129  fill(m_tools[m_nMuGroups[l1TriggerIdx]], nMuons);
130  fill(m_tools[m_muTimeGroups[l1TriggerIdx]], monTime);
131  fill(m_tools[m_muPathGroups[l1TriggerIdx]], monPath);
132  fill(m_tools[m_muEneGroups[l1TriggerIdx]], monEnergy);
133  fill(m_tools[m_muNCellsGroups[l1TriggerIdx]], monNCells);
134  fill(m_tools[m_muDirectionPhiGroups[l1TriggerIdx]], monDirectionPhi);
135  fill(m_tools[m_muDirectionThetaGroups[l1TriggerIdx]], monDirectionTheta);
136  fill(m_tools[m_muPositionGroups[l1TriggerIdx]], monPositionZ, monPositionX);
137  fill(m_tools[m_muPosDirectionThetaGroups[l1TriggerIdx]], monPositionZ, monDirectionTheta);
138  }
139  }
140 
141  if (!muPosTime.empty()) {
142  auto monTime = Monitored::Collection("time", muPosTime);
143  auto monPositionZ = Monitored::Collection("zPosition", muPosTimeZ);
144  for (int l1TriggerIdx : l1TriggersIndices) {
145  fill(m_tools[m_muPositionTimeGroups[l1TriggerIdx]], monPositionZ, monTime);
146  }
147  }
148 
149  if (!muPartitionTime.empty()) {
150  auto monTime = Monitored::Collection("time", muPartitionTime);
151  auto monPartition = Monitored::Collection("partition", muPartition);
152  for (int l1TriggerIdx : l1TriggersIndices) {
153  fill(m_tools[m_muPartitionTimeGroups[l1TriggerIdx]], monPartition, monTime);
154  }
155  }
156 
157  if (!muEnergyDensity.empty()) {
158  auto monEneDensity = Monitored::Collection("eneDensity", muEnergyDensity);
159  for (int l1TriggerIdx : l1TriggersIndices) {
160  fill(m_tools[m_muEneDensityGroups[l1TriggerIdx]], monEneDensity);
161  }
162  }
163 
164  fill("TileMuonFitMonExecuteTime", timer);
165 
166  return StatusCode::SUCCESS;
167 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TileMuonFitMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TileMuonFitMonitorAlgorithm.cxx:14
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
TileMuonFitMonitorAlgorithm::m_muEneDensityGroups
std::vector< int > m_muEneDensityGroups
Definition: TileMuonFitMonitorAlgorithm.h:42
TileMuonFitMonitorAlgorithm::m_nMuGroups
std::vector< int > m_nMuGroups
Definition: TileMuonFitMonitorAlgorithm.h:35
TileCosmicMuon
Class containing detailed results from TileMuonFitter.
Definition: TileCosmicMuon.h:35
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TileMuonFitMonitorAlgorithm::m_muEneGroups
std::vector< int > m_muEneGroups
Definition: TileMuonFitMonitorAlgorithm.h:36
CscCalibQuery.fullPath
string fullPath
Definition: CscCalibQuery.py:360
TileMuonFitMonitorAlgorithm::m_muPathGroups
std::vector< int > m_muPathGroups
Definition: TileMuonFitMonitorAlgorithm.h:38
TileCalibUtils.h
TileMuonFitMonitorAlgorithm::m_muTimeGroups
std::vector< int > m_muTimeGroups
Definition: TileMuonFitMonitorAlgorithm.h:37
TileMuonFitMonitorAlgorithm::m_cosmicMuonContainerKey
SG::ReadHandleKey< TileCosmicMuonContainer > m_cosmicMuonContainerKey
Definition: TileMuonFitMonitorAlgorithm.h:32
TileMuonFitMonitorAlgorithm::m_muPartitionTimeGroups
std::vector< int > m_muPartitionTimeGroups
Definition: TileMuonFitMonitorAlgorithm.h:46
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
TileMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TileMonitorAlgorithm.cxx:10
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
TileMuonFitMonitorAlgorithm::m_muPositionGroups
std::vector< int > m_muPositionGroups
Definition: TileMuonFitMonitorAlgorithm.h:40
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.
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
DeMoScan.partitions
dictionary partitions
Definition: DeMoScan.py:67
TileMuonFitMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: TileMuonFitMonitorAlgorithm.cxx:43
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
AthMonitorAlgorithm::m_tools
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Definition: AthMonitorAlgorithm.h:338
TileMuonFitMonitorAlgorithm::m_muNCellsGroups
std::vector< int > m_muNCellsGroups
Definition: TileMuonFitMonitorAlgorithm.h:39
TileMuonFitMonitorAlgorithm.h
TileMuonFitMonitorAlgorithm::m_muPosDirectionThetaGroups
std::vector< int > m_muPosDirectionThetaGroups
Definition: TileMuonFitMonitorAlgorithm.h:45
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
TileMuonFitMonitorAlgorithm::m_muPositionTimeGroups
std::vector< int > m_muPositionTimeGroups
Definition: TileMuonFitMonitorAlgorithm.h:41
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
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
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
xAOD::EventInfo_v1::level1TriggerType
uint16_t level1TriggerType() const
The Level-1 trigger type.
TileMuonFitMonitorAlgorithm::m_muDirectionThetaGroups
std::vector< int > m_muDirectionThetaGroups
Definition: TileMuonFitMonitorAlgorithm.h:44
TileMuonFitMonitorAlgorithm::m_tileID
const TileID * m_tileID
Definition: TileMuonFitMonitorAlgorithm.h:48
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
TileMuonFitMonitorAlgorithm::m_muDirectionPhiGroups
std::vector< int > m_muDirectionPhiGroups
Definition: TileMuonFitMonitorAlgorithm.h:43
ReadHandle.h
Handle class for reading from StoreGate.
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