ATLAS Offline Software
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
11 #include "xAODMuon/MuonContainer.h"
13 
14 // Athena includes
15 #include "StoreGate/ReadHandle.h"
16 
17 #include <math.h>
18 
19 
21 
23  ATH_MSG_DEBUG("in initialize()");
24 
25  ATH_CHECK( m_cablingSvc.retrieve() );
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);
37  m_coinThrDGroup = buildToolMap<std::vector<std::vector<int>>>(m_tools, "TMDB_coincidence_threshold", 2, m_numberOfThresholds, 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) {
53  m_ampCell.push_back(buildToolMap<int>(m_tools,
54  "TMDB_RawCellAmplitude_" + partitionName[partition],
56  m_timeCell.push_back(buildToolMap<int>(m_tools,
57  "TMDB_RawCellTime_" + partitionName[partition],
59  }
60  }
61 
62  return StatusCode::SUCCESS;
63 }
64 
65 
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 
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]);
234  }
235  }
236  }
237  }
238  }
239  }
240  return StatusCode::SUCCESS;
241 }
242 
243 /*---------------------------------------------------------*/
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
muonContainer
xAOD::MuonContainer * muonContainer
Definition: TrigGlobEffCorrValidation.cxx:188
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
xAOD::MuonRoI_v1::Endcap
@ Endcap
The muon candidate was detected in the endcap region.
Definition: MuonRoI_v1.h:39
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
TileTMDBRawChannelMonitorAlgorithm::m_timeGroups
std::vector< int > m_timeGroups
Definition: TileTMDBRawChannelMonitorAlgorithm.h:72
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TileTMDBRawChannelMonitorAlgorithm::m_cablingSvc
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
Definition: TileTMDBRawChannelMonitorAlgorithm.h:66
TileTMDBRawChannelMonitorAlgorithm::m_muonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonContainerKey
Definition: TileTMDBRawChannelMonitorAlgorithm.h:54
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonRoIContainer.h
TileTMDBRawChannelMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: TileTMDBRawChannelMonitorAlgorithm.cxx:66
TileTMDBRawChannelMonitorAlgorithm::m_tileHWID
const TileHWID * m_tileHWID
Definition: TileTMDBRawChannelMonitorAlgorithm.h:69
TileCalibUtils.h
TileTMDBRawChannelMonitorAlgorithm::m_coinThrDGroup
std::vector< std::vector< std::vector< int > > > m_coinThrDGroup
Definition: TileTMDBRawChannelMonitorAlgorithm.h:77
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
TileTMDBRawChannelMonitorAlgorithm::tilemodule_to_check
int tilemodule_to_check(int sector) const
Definition: TileTMDBRawChannelMonitorAlgorithm.cxx:251
Example_ReadSampleNoise.drawer
drawer
Definition: Example_ReadSampleNoise.py:39
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
dq_defect_copy_defect_database.channels
def channels
Definition: dq_defect_copy_defect_database.py:56
TileTMDBRawChannelMonitorAlgorithm::m_numberOfThresholds
Gaudi::Property< bool > m_numberOfThresholds
Definition: TileTMDBRawChannelMonitorAlgorithm.h:48
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
TileTMDBRawChannelMonitorAlgorithm::m_nChannels
Gaudi::Property< std::vector< int > > m_nChannels
Definition: TileTMDBRawChannelMonitorAlgorithm.h:33
python.PyAthena.module
module
Definition: PyAthena.py:134
TileTMDBRawChannelMonitorAlgorithm::m_fillRawChannelHistograms
Gaudi::Property< bool > m_fillRawChannelHistograms
Definition: TileTMDBRawChannelMonitorAlgorithm.h:42
TileTMDBRawChannelMonitorAlgorithm::m_timeCell
std::vector< std::vector< int > > m_timeCell
Definition: TileTMDBRawChannelMonitorAlgorithm.h:74
Tile
Definition: TileVolumeBuilder.h:43
python.changerun.m1
m1
Definition: changerun.py:32
TileHWID.h
IdentifiableContainerMT::GetAllCurrentHashes
virtual std::vector< IdentifierHash > GetAllCurrentHashes() const override final
Returns a collection of all hashes availiable in this IDC.
Definition: IdentifiableContainerMT.h:231
TileTMDBRawChannelMonitorAlgorithm::m_amplitudeThreshold
Gaudi::Property< float > m_amplitudeThreshold
Definition: TileTMDBRawChannelMonitorAlgorithm.h:36
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
TileTMDBRawChannelMonitorAlgorithm::m_isDSP
Gaudi::Property< bool > m_isDSP
Definition: TileTMDBRawChannelMonitorAlgorithm.h:39
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
TauGNNUtils::Variables::Track::dPhi
bool dPhi(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:530
TileTMDBRawChannelMonitorAlgorithm::m_fillEfficiencyHistograms
Gaudi::Property< bool > m_fillEfficiencyHistograms
Definition: TileTMDBRawChannelMonitorAlgorithm.h:45
TileTMDBRawChannelMonitorAlgorithm::m_ampCell
std::vector< std::vector< int > > m_ampCell
Definition: TileTMDBRawChannelMonitorAlgorithm.h:73
xAOD::MuonRoI_v1
Class describing a LVL1 muon region of interest.
Definition: MuonRoI_v1.h:33
TileRawChannel
Definition: TileRawChannel.h:35
TileTMDBRawChannelMonitorAlgorithm::m_ampGroups
std::vector< int > m_ampGroups
Definition: TileTMDBRawChannelMonitorAlgorithm.h:71
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
maskDeadModules.ros
ros
Definition: maskDeadModules.py:35
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Trk::Combined
@ Combined
Definition: TrackSummaryTool.h:32
TileTMDBRawChannelMonitorAlgorithm::m_tileCondToolTMDB
ToolHandle< ITileCondToolTMDB > m_tileCondToolTMDB
Definition: TileTMDBRawChannelMonitorAlgorithm.h:60
TileRawDataCollection::identify
ID identify() const
Definition: TileRawDataCollection.h:71
AthMonitorAlgorithm::m_tools
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Definition: AthMonitorAlgorithm.h:338
TileTMDBRawChannelMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TileTMDBRawChannelMonitorAlgorithm.cxx:20
threshold
Definition: chainparser.cxx:74
TileRawChannelCollection
Definition: TileRawChannelCollection.h:12
MuonContainer.h
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
IdentifiableContainerMT::indexFindPtr
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
Definition: IdentifiableContainerMT.h:292
TileTMDBRawChannelMonitorAlgorithm::calc_dR
float calc_dR(float dEta, float dPhi) const
Definition: TileTMDBRawChannelMonitorAlgorithm.cxx:244
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
python.Classes.TileCalibUtils
TileCalibUtils
Definition: TileCalib/TileCalibBlobObjs/python/Classes.py:5
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
TileTMDBRawChannelMonitorAlgorithm::m_muonRoIsContainerKey
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_muonRoIsContainerKey
Definition: TileTMDBRawChannelMonitorAlgorithm.h:57
TileTMDBRawChannelMonitorAlgorithm.h
TileTMDBRawChannelMonitorAlgorithm::m_rawChannelContainerKey
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
Definition: TileTMDBRawChannelMonitorAlgorithm.h:51
ReadHandle.h
Handle class for reading from StoreGate.
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:525
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
GlobalMonitoring_CA.partitionName
partitionName
Definition: GlobalMonitoring_CA.py:22
dumpTgcDigiThreshold.threshold
list threshold
Definition: dumpTgcDigiThreshold.py:34
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
plot_times.times
def times(fn)
Definition: plot_times.py:11
TileTMDBRawChannelMonitorAlgorithm::m_tgcSectorGroup
std::vector< int > m_tgcSectorGroup
Definition: TileTMDBRawChannelMonitorAlgorithm.h:76