ATLAS Offline Software
Loading...
Searching...
No Matches
TileTMDBRawChannelMonitorAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Tile includes
9
10// Muon includes
13
14// Athena includes
16
17#include <math.h>
18
19
21
23 ATH_MSG_DEBUG("in initialize()");
24
25 ATH_CHECK( m_cablingSvc.retrieve() );
26 ATH_CHECK( detStore()->retrieve(m_tileHWID) );
27 ATH_CHECK( m_rawChannelContainerKey.initialize() );
30 ATH_CHECK( m_tileCondToolTMDB.retrieve(EnableTool{m_fillEfficiencyHistograms}) );
31
32 using Tile = TileCalibUtils;
33 using namespace Monitored;
34
36 m_tgcSectorGroup = buildToolMap<int>(m_tools, "TGC_TrSec_number_Good_Muons", 2);
38
39 }
40
42 m_ampGroups = buildToolMap<int>(m_tools, "TMDB_RawAmplitude", Tile::MAX_ROS - 1);
43 m_timeGroups = buildToolMap<int>(m_tools, "TMDB_RawTime", Tile::MAX_ROS - 1);
44
45 if (m_nChannels.size() != (Tile::MAX_ROS - 1)) {
46 ATH_MSG_FATAL( "Size of NumberOfChannels should be 4 (LBA, LBC, EBA, EBC), but is " << m_nChannels.size() );
47 return StatusCode::FAILURE;
48 }
49
50 std::vector<std::string> partitionName = {"LBA", "LBC", "EBA", "EBC"}; // ROS - 1 to partition name map
51
52 for (unsigned int partition = 0; partition < Tile::MAX_ROS-1; ++partition) {
54 "TMDB_RawCellAmplitude_" + partitionName[partition],
55 m_nChannels[partition]));
57 "TMDB_RawCellTime_" + partitionName[partition],
58 m_nChannels[partition]));
59 }
60 }
61
62 return StatusCode::SUCCESS;
63}
64
65
66StatusCode TileTMDBRawChannelMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
67
68 ATH_MSG_DEBUG( "in fillHistograms()" );
69 using Tile = TileCalibUtils;
70 std::vector<int> drawers[Tile::MAX_ROS - 1];
71 std::vector<int> channels[Tile::MAX_ROS - 1];
72 std::vector<float> amplitudes[Tile::MAX_ROS - 1];
73
74 std::vector<int> timeDrawers[Tile::MAX_ROS - 1];
75 std::vector<int> timeChannels[Tile::MAX_ROS - 1];
76 std::vector<float> times[Tile::MAX_ROS - 1];
77
78 static constexpr int TMDB_MAX_CHANNEL = 8;
79 std::vector<float> cellAmplitudes[Tile::MAX_ROS - 1][TMDB_MAX_CHANNEL];
80 std::vector<float> cellTimes[Tile::MAX_ROS - 1][TMDB_MAX_CHANNEL];
81
82 static constexpr int TMDB_EB_NUMBER_CELLS = 2; // (D5 and D5+D6)
83 static constexpr int TMDB_EB_NUMBER_PARTITIONS = 2; // EBA and EBC
84 std::vector<float> tgcSectors[2];
85
86 // Thresholds x (EBA and EBC) x (D5 and D5+D6)
87 auto coinThrModules = std::make_unique<std::vector<float>[][TMDB_EB_NUMBER_PARTITIONS][TMDB_EB_NUMBER_CELLS]>(m_numberOfThresholds);
88
89 float TMDB_D6_amplitude[TMDB_EB_NUMBER_PARTITIONS][64] = {{0}}; // (EBA and EBC) x 64 modules
90 float TMDB_D56_amplitude[TMDB_EB_NUMBER_PARTITIONS][64] = {{0}}; // (EBA and EBC) x 64 modules
91
93 for (IdentifierHash hash : rawContainer->GetAllCurrentHashes()) {
94 const TileRawChannelCollection* rawChannelCollection = rawContainer->indexFindPtr(hash);
95 if (rawChannelCollection->empty()) continue;
96 int fragId = rawChannelCollection->identify();
97 unsigned int drawer = (fragId & 0x3F);
98 unsigned int ros = fragId >> 8;
99 unsigned int partition = ros - 1;
100
101 for (const TileRawChannel* rawChannel : *rawChannelCollection) {
102 HWIdentifier adc_id = rawChannel->adc_HWID();
103 int channel = m_tileHWID->channel(adc_id);
104 float amplitude = rawChannel->amplitude();
105
106 if(channel < m_nChannels[partition]){
107
109 if (partition > 1) {
110 TMDB_D56_amplitude[partition - 2][drawer] += amplitude;
111 if (channel == 2 || channel == 3) {
112 TMDB_D6_amplitude[partition - 2][drawer] += amplitude;
113 }
114 }
115 }
116
118 channels[partition].push_back(channel);
119 drawers[partition].push_back(drawer);
120 amplitudes[partition].push_back(amplitude);
121 cellAmplitudes[partition][channel].push_back(amplitude);
122 if(!m_isDSP){
123 if (amplitude > m_amplitudeThreshold) {
124 timeChannels[partition].push_back(channel);
125 timeDrawers[partition].push_back(drawer);
126 float time = rawChannel->time();
127 times[partition].push_back(time);
128 cellTimes[partition][channel].push_back(time);
129 }
130 }
131 }
132
133 }
134 }
135 }
136
137 for (unsigned int partition = 0; partition < Tile::MAX_ROS - 1; ++partition) {
138 if (!amplitudes[partition].empty()) {
139 auto monModule = Monitored::Collection("module", drawers[partition]);
140 auto monChannel = Monitored::Collection("channel", channels[partition]);
141 auto monAmplitude = Monitored::Collection("amplitude", amplitudes[partition]);
142 fill(m_tools[m_ampGroups[partition]], monModule, monChannel, monAmplitude);
143 for (int channel = 0; channel < int(m_nChannels[partition]); ++channel) {
144 if (!cellAmplitudes[partition][channel].empty()) {
145 auto monAmplitude = Monitored::Collection("amplitude", cellAmplitudes[partition][channel]);
146 fill(m_tools[m_ampCell[partition][channel]], monAmplitude);
147 }
148 }
149 }
150
151 if (!times[partition].empty()) {
152 auto monModule = Monitored::Collection("module", timeDrawers[partition]);
153 auto monChannel = Monitored::Collection("channel", timeChannels[partition]);
154 auto monTime = Monitored::Collection("time", times[partition]);
155 fill(m_tools[m_timeGroups[partition]], monModule, monChannel, monTime);
156 for (int channel = 0; channel < int(m_nChannels[partition]); ++channel) {
157 if (!cellAmplitudes[partition][channel].empty()) {
158 auto monTime = Monitored::Collection("time", cellTimes[partition][channel]);
159 fill(m_tools[m_timeCell[partition][channel]], monTime);
160 }
161 }
162 }
163 }
164
166
168 ATH_CHECK( muonContainer.isValid() );
169
171 ATH_CHECK( muonRoIsContainer.isValid() );
172
173 for ( const xAOD::MuonRoI* roi_mu : *muonRoIsContainer ) {
174 float eta = roi_mu->eta();
175 float phi = roi_mu->phi();
176 int pt_thr = roi_mu->getThrNumber();
177 int sector = (roi_mu->getSectorAddress()>>1) & (0x3F);
178
179 if(!(roi_mu->getSource() == xAOD::MuonRoI::Endcap && (pt_thr == 5 || pt_thr == 6))) { continue; }
180 if( fabs(eta) < 1.0 || 1.3 < fabs(eta) ) { continue; }
181
182 int m1 = tilemodule_to_check( sector );
183
184 for ( const xAOD::Muon* mu : *muonContainer ) {
185 float muon_eta = mu->eta();
186 float muon_phi = mu->phi();
187 float muon_pt = mu->pt();
188 float dR = calc_dR(eta-muon_eta, phi-muon_phi);
189
190 if(dR > 0.1) {continue;} // dR cut
191 if(muon_pt < 15000) {continue;} // pt cut
192 if(mu->muonType() != xAOD::Muon::Combined) {continue;} // combined muon
193
194 unsigned int partition = (muon_eta > 0.0) ? 0 : 1;
195 tgcSectors[partition].push_back(sector);
196
197 unsigned int drawerIdx;
198
199 for(unsigned int partition = 0; partition < TMDB_EB_NUMBER_PARTITIONS; ++partition) {
200 for(int module = m1; module <= m1 + 1; ++module) {
201
202 drawerIdx = Tile::getDrawerIdx(partition + 3, module);
203
204 if( TMDB_D6_amplitude[partition][module] > m_tileCondToolTMDB->getThreshold(drawerIdx, 0) ) {
205 coinThrModules[0][partition][0].push_back(module);
206 }
207 if( (TMDB_D56_amplitude[partition][module] > m_tileCondToolTMDB->getThreshold(drawerIdx, 2) )) {
208 coinThrModules[0][partition][1].push_back(module);
209 }
210
211 if(m_numberOfThresholds == 2){
212 if( (TMDB_D6_amplitude[partition][module] > m_tileCondToolTMDB->getThreshold(drawerIdx, 1) )) {
213 coinThrModules[1][partition][0].push_back(module);
214 }
215 if( (TMDB_D56_amplitude[partition][module] > m_tileCondToolTMDB->getThreshold(drawerIdx, 3) )) {
216 coinThrModules[1][partition][1].push_back(module);
217 }
218 }
219 }
220 }
221 } //mu_loop
222 } //trig_mu_loop
223
224
225 for (unsigned int partition = 0; partition < TMDB_EB_NUMBER_PARTITIONS; ++partition) {
226 if (!tgcSectors[partition].empty()) {
227 auto monSector = Monitored::Collection("sector", tgcSectors[partition]);
228 fill(m_tools[m_tgcSectorGroup[partition]], monSector);
229 for(unsigned int threshold = 0; threshold < m_numberOfThresholds; ++threshold){
230 for(unsigned int cell = 0; cell < TMDB_EB_NUMBER_CELLS; ++cell){
231 if (!coinThrModules[threshold][partition][cell].empty()) {
232 auto monModule = Monitored::Collection("module", coinThrModules[threshold][partition][cell]);
233 fill(m_tools[m_coinThrDGroup[partition][threshold][cell]], monModule);
234 }
235 }
236 }
237 }
238 }
239 }
240 return StatusCode::SUCCESS;
241}
242
243/*---------------------------------------------------------*/
244float TileTMDBRawChannelMonitorAlgorithm::calc_dR(float dEta, float dPhi) const {
245/*---------------------------------------------------------*/
246 float dR = sqrt( (dEta*dEta) + (dPhi*dPhi) );
247 return(dR);
248}
249
250/*---------------------------------------------------------*/
252/*---------------------------------------------------------*/
253 int module = 0;
254 switch ( sector )
255 {
256 case 0:
257 module = 61;
258 break;
259 case 1:
260 module = 62;
261 break;
262 case 2:
263 module = 0;
264 break;
265 case 3:
266 module = 1;
267 break;
268 case 4:
269 module = 2;
270 break;
271 case 5:
272 module = 4;
273 break;
274 case 6:
275 module = 5;
276 break;
277 case 7:
278 module = 6;
279 break;
280 case 8:
281 module = 8;
282 break;
283 case 9:
284 module = 9;
285 break;
286 case 10:
287 module = 10;
288 break;
289 case 11:
290 module = 12;
291 break;
292 case 12:
293 module = 13;
294 break;
295 case 13:
296 module = 14;
297 break;
298 case 14:
299 module = 16;
300 break;
301 case 15:
302 module = 17;
303 break;
304 case 16:
305 module = 18;
306 break;
307 case 17:
308 module = 20;
309 break;
310 case 18:
311 module = 21;
312 break;
313 case 19:
314 module = 22;
315 break;
316 case 20:
317 module = 24;
318 break;
319 case 21:
320 module = 25;
321 break;
322 case 22:
323 module = 26;
324 break;
325 case 23:
326 module = 28;
327 break;
328 case 24:
329 module = 29;
330 break;
331 case 25:
332 module = 30;
333 break;
334 case 26:
335 module = 32;
336 break;
337 case 27:
338 module = 33;
339 break;
340 case 28:
341 module = 34;
342 break;
343 case 29:
344 module = 36;
345 break;
346 case 30:
347 module = 37;
348 break;
349 case 31:
350 module = 38;
351 break;
352 case 32:
353 module = 40;
354 break;
355 case 33:
356 module = 41;
357 break;
358 case 34:
359 module = 42;
360 break;
361 case 35:
362 module = 44;
363 break;
364 case 36:
365 module = 45;
366 break;
367 case 37:
368 module = 46;
369 break;
370 case 38:
371 module = 48;
372 break;
373 case 39:
374 module = 49;
375 break;
376 case 40:
377 module = 50;
378 break;
379 case 41:
380 module = 52;
381 break;
382 case 42:
383 module = 53;
384 break;
385 case 43:
386 module = 54;
387 break;
388 case 44:
389 module = 56;
390 break;
391 case 45:
392 module = 57;
393 break;
394 case 46:
395 module = 58;
396 break;
397 case 47:
398 module = 60;
399 break;
400 }
401 return module;
402} // End of tilemoudle_to_check
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
xAOD::MuonContainer * muonContainer
static const Attributes_t empty
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode initialize() override
initialize
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
bool empty() const noexcept
Returns true if the collection is empty.
This is a "hash" representation of an Identifier.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Static class providing several utility functions and constants.
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_muonRoIsContainerKey
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
SG::ReadHandleKey< xAOD::MuonContainer > m_muonContainerKey
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
virtual StatusCode initialize() override
initialize
std::vector< std::vector< std::vector< int > > > m_coinThrDGroup
Gaudi::Property< std::vector< int > > m_nChannels
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
@ Endcap
The muon candidate was detected in the endcap region.
Definition MuonRoI_v1.h:35
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.
Muon_v1 Muon
Reference the current persistent version:
MuonRoI_v1 MuonRoI
Definition MuonRoI.h:15
void fill(H5::Group &out_file, size_t iterations)