ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
37 ATH_CHECK( detStore()->retrieve(m_tileID) );
38
40}
41
42
43StatusCode 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);
100 int partition = getPartition(hash, m_tileID);
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(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.
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?
Class containing detailed results from TileMuonFitter.
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 fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
virtual StatusCode initialize() override
initialize
SG::ReadHandleKey< TileCosmicMuonContainer > m_cosmicMuonContainerKey
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)
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
EventInfo_v1 EventInfo
Definition of the latest event info version.
void fill(H5::Group &out_file, size_t iterations)