ATLAS Offline Software
MMRawDataMonAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
5 // Package : MMRawDataMonAlg
6 // Authors: M. Biglietti, E. Rossi (Roma Tre)
7 //
8 // DESCRIPTION:
9 // Subject: MM-->Offline Muon Data Quality
11 
18 
19 #include "MMRawDataMonAlg.h"
20 
29 #include <stdexcept>
30 
31 
32 namespace {
33 
34  //1e=1.6X10-4 fC
35  static constexpr double conversion_charge=1.6E-04;
36 
37  static const std::array<std::string,2> MM_Side = {"CSide", "ASide"};
38  static const std::array<std::string,2> EtaSector = {"1", "2"};
39 
40  struct MMOverviewHistogramStruct {
41  std::vector<int> statEta_strip;
42  std::vector<float> charge_all;
43  std::vector<int> strp_times;
44  std::vector<float> cl_times;
45  std::vector<int> strip_number;
46  std::vector<int> numberofstrips_percluster;
47  std::vector<float> R_mon;
48  std::vector<float> z_mon;
49  std::vector<float> x_mon;
50  std::vector<float> y_mon;
51 
52  std::vector<int> stationPhi_ASide_ontrack;
53  std::vector<int> stationPhi_CSide_ontrack;
54  std::vector<int> sector_ASide_ontrack;
55  std::vector<int> sector_CSide_ontrack;
56  std::vector<int> stationPhi_CSide;
57  std::vector<int> stationPhi_ASide;
58  std::vector<int> sector_CSide;
59  std::vector<int> sector_ASide;
60  std::vector<int> stationPhi_ASide_onseg;
61  std::vector<int> stationPhi_CSide_onseg;
62  std::vector<int> sector_ASide_onseg;
63  std::vector<int> sector_CSide_onseg;
64 
65  };
66 
67  struct MMByPhiStruct {
68  std::vector<int> sector_lb;
69  std::vector<int> sector_lb_ontrack;
70  std::vector<int> sector_lb_onseg;
71  };
72 
73  struct MMSummaryHistogramStruct {
74  std::vector<int> cl_size;
75  std::vector<int> pcb;
76  std::vector<int> pcb_strip;
77  std::vector<int> strip_number;
78  std::vector<int> sector_strip;
79  std::vector<float> charge;
80  std::vector<int> strp_times;
81  std::vector<float> cl_times;
82  std::vector<float> x_ontrack;
83  std::vector<float> y_ontrack;
84  std::vector<float> residuals;
85  };
86 
87  struct MMEfficiencyHistogramStruct {
88  std::vector<int> num;
89  std::vector<int> nGaps;
90  };
91 }
92 
94 // *********************************************************************
95 // Public Methods
96 // *********************************************************************
97 
98 MMRawDataMonAlg::MMRawDataMonAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
99  AthMonitorAlgorithm(name,pSvcLocator)
100 { }
101 
102 /*---------------------------------------------------------*/
104 /*---------------------------------------------------------*/
105 {
106  //init message stream
107  ATH_MSG_DEBUG("initialize MMRawDataMonAlg");
108  ATH_MSG_DEBUG("******************");
109  ATH_MSG_DEBUG("doMMESD: " << m_doMMESD );
110  ATH_MSG_DEBUG("******************");
111 
114  ATH_CHECK(m_idHelperSvc.retrieve());
115 
116  ATH_MSG_INFO(" Found the MuonIdHelperSvc ");
117  ATH_CHECK(m_muonKey.initialize());
118  ATH_CHECK(m_MMContainerKey.initialize());
120  ATH_CHECK(m_segm_type.initialize());
121  ATH_CHECK(m_mmtpRdoKey.initialize());
122 
123  ATH_MSG_DEBUG(" end of initialize " );
124  ATH_MSG_INFO("MMRawDataMonAlg initialization DONE " );
125 
126  return StatusCode::SUCCESS;
127 }
128 
129 StatusCode MMRawDataMonAlg::fillHistograms(const EventContext& ctx) const
130 {
131  int lumiblock = -1;
132  lumiblock = GetEventInfo(ctx)->lumiBlock();
133  ATH_MSG_DEBUG("MMRawDataMonAlg::MM RawData Monitoring Histograms being filled" );
134 
136  ATH_MSG_DEBUG("****** mmContainer->size() : " << mm_container->size());
137 
138  if(m_doMMESD) {
139  MMOverviewHistogramStruct overviewPlots;
140  MMSummaryHistogramStruct summaryPlots[2][16][2][2][4];
141  MMByPhiStruct occupancyPlots[16][2];
142 
143  //loop in MMPrepDataContainer
144  for(const Muon::MMPrepDataCollection* coll : *mm_container) {
145  for(const Muon::MMPrepData* prd : *coll) {
146  ATH_CHECK(fillMMOverviewVects(prd, overviewPlots, occupancyPlots));
147  ATH_CHECK(fillMMSummaryVects(prd, summaryPlots));
149  }
150  }
151 
152  if(m_do_mm_overview) fillMMOverviewHistograms(overviewPlots, occupancyPlots, lumiblock);
153 
154  ATH_CHECK(fillMMSummaryHistograms(summaryPlots));
156  if (!meTPContainer.isValid()) {
157  ATH_MSG_FATAL("Nope. Could not retrieve "<<m_meTrkKey.fullKey());
158  return StatusCode::FAILURE;
159  }
160  clusterFromTrack(meTPContainer.cptr(),lumiblock);
161  MMEfficiency(meTPContainer.cptr());
162 
163 
164 
165  //trigger
167  if (not rdos.isValid()) {
168  ATH_MSG_INFO("NSW MMTP failed. Skipping");
169  // return StatusCode::SUCCESS;
170  } else fillMMTrigger(rdos.cptr(),lumiblock);
171 
173 
174  if (!segms.isValid()) {
175  ATH_MSG_INFO("evtStore() does not contain MM segms Collection with name " << m_segm_type);
176  // return StatusCode::FAILURE;
177  }else
179  }
180 
181 
182  return StatusCode::SUCCESS;
183 }
184 
185 StatusCode MMRawDataMonAlg::fillMMOverviewVects( const Muon::MMPrepData* prd, MMOverviewHistogramStruct& vects, MMByPhiStruct (&occupancyPlots)[16][2] ) const
186 {
187  Identifier Id = prd->identify();
188  const std::vector<Identifier>& stripIds = prd->rdoList();
189  unsigned int nStrips = stripIds.size(); // number of strips in this cluster (cluster size)
190  const std::vector<uint16_t>& stripNumbers = prd->stripNumbers();
191 
192  std::string stName = m_idHelperSvc->mmIdHelper().stationNameString(m_idHelperSvc->mmIdHelper().stationName(Id));
193  int gas_gap = m_idHelperSvc->mmIdHelper().gasGap(Id);
194  int stationEta = m_idHelperSvc->mmIdHelper().stationEta(Id);
195  int stationPhi = m_idHelperSvc->mmIdHelper().stationPhi(Id);
196  int multiplet = m_idHelperSvc->mmIdHelper().multilayer(Id);
197  int channel = m_idHelperSvc->mmIdHelper().channel(Id);
198 
199  // Returns the charge (number of electrons) converted in fC
200  float charge = prd->charge()*conversion_charge;
201  // Returns the times of each strip (in ns)
202  std::vector<short int> strip_times = prd->stripTimes();
203 
205  float R = std::hypot(pos.x(),pos.y());
206 
207  // MM gaps are back to back, so the direction of the drift (time) is different for the even and odd gaps -> flip for the even gaps
208 
209  vects.charge_all.push_back(charge);
210  vects.numberofstrips_percluster.push_back(nStrips);
211  vects.x_mon.push_back(pos.x());
212  vects.y_mon.push_back(pos.y());
213  vects.z_mon.push_back(pos.z());
214  vects.R_mon.push_back(R);
215 
216  // 16 phi sectors, 8 stationPhi times 2 stName, MMS and MML
217  int sectorPhi = get_sectorPhi_from_stationPhi_stName(stationPhi,stName);
218 
219  // Occupancy plots with PCB granularity further divided for each eta sector: -2, -1, 1, 2
220  // CSide and ASide
221  int iside = (stationEta>0) ? 1 : 0;
222 
223  auto& thisSect = occupancyPlots[sectorPhi-1][iside];
224  const int gap_offset=4;
225  int gas_gap8 = (multiplet==1) ? gas_gap : gas_gap + gap_offset;
227 
228  int bin = get_bin_for_feb_occ(gas_gap8,FEB);
229 
230  thisSect.sector_lb.push_back(bin);
231 
232  if(stationEta<0) {
233  vects.sector_CSide.push_back(bin);
234  vects.stationPhi_CSide.push_back(sectorPhi);
235  } else {
236  vects.sector_ASide.push_back(bin);
237  vects.stationPhi_ASide.push_back(sectorPhi);
238  }
239 
240  // loop on each strip
241  int sIdx = 0; // index-counter for the vector of Id's
242  float cluster_time = 0;
243  for(const Identifier& id: stripIds) {
244 
245  std::string stName_strip = m_idHelperSvc->mmIdHelper().stationNameString(m_idHelperSvc->mmIdHelper().stationName(id));
246  int stationEta_strip = m_idHelperSvc->mmIdHelper().stationEta(id);
247  vects.statEta_strip.push_back(stationEta_strip);
248  vects.strip_number.push_back(stripNumbers[sIdx]);
249  vects.strp_times.push_back(strip_times.at(sIdx));
250  cluster_time += strip_times.at(sIdx);
251  ++sIdx;
252  }
253  cluster_time /= strip_times.size();
254  vects.cl_times.push_back(cluster_time);
255 
256  return StatusCode::SUCCESS;
257 }
258 
259 void MMRawDataMonAlg::fillMMOverviewHistograms( const MMOverviewHistogramStruct& vects, MMByPhiStruct (&occupancyPlots)[16][2], int lb ) const
260 {
261  auto charge_all = Monitored::Collection("charge_all", vects.charge_all);
262  auto numberofstrips_percluster = Monitored::Collection("numberofstrips_percluster", vects.numberofstrips_percluster);
263  fill("mmMonitor", charge_all, numberofstrips_percluster);
264 
265  auto strip_times = Monitored::Collection("strip_times", vects.strp_times);
266  auto cluster_times = Monitored::Collection("cluster_times", vects.cl_times);
267  auto strip_number = Monitored::Collection("strip_number", vects.strip_number);
268  auto statEta_strip = Monitored::Collection("statEta_strip", vects.statEta_strip);
269  fill("mmMonitor", strip_times, cluster_times, strip_number, statEta_strip);
270 
271  auto x_mon = Monitored::Collection("x_mon", vects.x_mon);
272  auto y_mon = Monitored::Collection("y_mon", vects.y_mon);
273  auto z_mon = Monitored::Collection("z_mon", vects.z_mon);
274  auto R_mon = Monitored::Collection("R_mon", vects.R_mon);
275  fill("mmMonitor", x_mon, y_mon, z_mon, R_mon);
276 
277  auto lb_mon = Monitored::Scalar<int>("lb_mon", lb);
278 
279  for(int statPhi=0; statPhi<16; ++statPhi) {
280  for(int iside=0; iside<2; ++iside) {
281  auto& occ_lb = occupancyPlots[statPhi][iside];
282  auto sector_lb = Monitored::Collection("sector_lb_"+MM_Side[iside]+"_phi"+std::to_string(statPhi+1),occ_lb.sector_lb);
283  std::string MM_sideGroup = "MM_sideGroup" + MM_Side[iside];
284  fill(MM_sideGroup, lb_mon, sector_lb);
285  }
286  }
287  auto sector_CSide = Monitored::Collection("sector_CSide",vects.sector_CSide);
288  auto sector_ASide = Monitored::Collection("sector_ASide",vects.sector_ASide);
289  auto stationPhi_CSide = Monitored::Collection("stationPhi_CSide",vects.stationPhi_CSide);
290  auto stationPhi_ASide = Monitored::Collection("stationPhi_ASide",vects.stationPhi_ASide);
291 
292  fill("mmMonitor", sector_CSide, sector_ASide, stationPhi_CSide, stationPhi_ASide );
293 }
294 
295 StatusCode MMRawDataMonAlg::fillMMSummaryVects( const Muon::MMPrepData* prd, MMSummaryHistogramStruct (&vects)[2][16][2][2][4]) const
296 {
297  Identifier Id = prd->identify();
298  const std::vector<Identifier>& stripIds = prd->rdoList();
299 
300  std::string stName = m_idHelperSvc->mmIdHelper().stationNameString(m_idHelperSvc->mmIdHelper().stationName(Id));
301  int thisStationEta = m_idHelperSvc->mmIdHelper().stationEta(Id);
302  int thisStationPhi = m_idHelperSvc->mmIdHelper().stationPhi(Id);
303  int thisMultiplet = m_idHelperSvc->mmIdHelper().multilayer(Id);
304  int thisGasgap = m_idHelperSvc->mmIdHelper().gasGap(Id);
305  int ch = m_idHelperSvc->mmIdHelper().channel(Id);
306  float thisCharge=prd->charge()*conversion_charge;
307  std::vector<short int> strip_times = prd->stripTimes();
308 
309 
310  int phi=get_sectorPhi_from_stationPhi_stName(thisStationPhi ,stName);
311 
312  // CSide and ASide
313  int iside = (thisStationEta>0) ? 1 : 0;
314 
315  // 2 eta sectors depending on Eta=+-1 (0) and +-2 (1)
316  int sectorEta=get_sectorEta_from_stationEta(thisStationEta);
317  unsigned int csize = stripIds.size();
318  int PCB = get_PCB_from_channel(ch);
319  auto& Vectors = vects[iside][phi-1][sectorEta][thisMultiplet-1][thisGasgap-1];
320 
321  // loop on strips
322  int sIdx = 0;
323  const std::vector<uint16_t>& stripNumbers=prd->stripNumbers();
324  float cluster_time = 0;
325  for ( const Identifier& id : stripIds) {
326 
327  int stationEta = m_idHelperSvc->mmIdHelper().stationEta(id);
328  int gas_gap = m_idHelperSvc->mmIdHelper().gasGap(Id);
329  int multiplet = m_idHelperSvc->mmIdHelper().multilayer(Id);
330  // Filling Vectors for both sides, considering each strip
331  if(m_doDetailedHists){
332  Vectors.strp_times.push_back(strip_times.at(sIdx));
333  cluster_time += strip_times.at(sIdx);
334  }
335  Vectors.strip_number.push_back(stripNumbers[sIdx]);
336  Vectors.pcb_strip.push_back( get_PCB_from_channel(stripNumbers[sIdx]));
337  ++sIdx;
338  if(iside==1) Vectors.sector_strip.push_back(get_bin_for_occ_ASide_hist(stationEta,multiplet,gas_gap));
339  if(iside==0) Vectors.sector_strip.push_back(get_bin_for_occ_CSide_hist(stationEta,multiplet,gas_gap));
340  }
341  if(m_doDetailedHists){
342  Vectors.cl_size.push_back(csize);
343  Vectors.pcb.push_back(PCB);
344  cluster_time /= strip_times.size();
345  Vectors.cl_times.push_back(cluster_time);
346  Vectors.charge.push_back(thisCharge);
347  }
348  return StatusCode::SUCCESS;
349 }
350 
351 StatusCode MMRawDataMonAlg::fillMMSummaryHistograms( const MMSummaryHistogramStruct (&vects)[2][16][2][2][4]) const {
352 
353  for(int iside=0; iside<2; ++iside) {
354  std::string MM_sideGroup = "MM_sideGroup" + MM_Side[iside];
355 
356 
357 
358  for(int statPhi=0; statPhi<16; ++statPhi) {
359  for(int multiplet=0; multiplet<2; ++multiplet) {
360 
361 
362  for(int statEta=0; statEta<2; ++statEta) {
363 
364  for(int gas_gap=0; gas_gap<4; ++gas_gap) {
365  auto& Vectors = vects[iside][statPhi][statEta][multiplet][gas_gap];
366  auto sector_strip = Monitored::Collection("sector_strip_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1), Vectors.sector_strip);
367  auto strip_number = Monitored::Collection("strip_number_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1), Vectors.strip_number);
368  if(m_doDetailedHists){
369  if(!Vectors.strip_number.empty())
370  {
371  auto cluster_size = Monitored::Collection("cluster_size_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), Vectors.cl_size);
372  auto strip_times = Monitored::Collection("strp_time_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), Vectors.strp_times);
373  auto cluster_time = Monitored::Collection("cluster_time_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), Vectors.cl_times);
374  auto charge_perPCB = Monitored::Collection("charge_perPCB_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), Vectors.charge);
375  auto charge_perlayer = Monitored::Collection("charge_perlayer_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), Vectors.charge);
376  auto cluster_size_perlayer = Monitored::Collection("cluster_size_perlayer_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), Vectors.cl_size);
377  auto pcb_mon = Monitored::Collection("pcb_mon_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), Vectors.pcb);
378  auto pcb_strip_mon = Monitored::Collection("pcb_strip_mon_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), Vectors.pcb_strip);
379  fill(MM_sideGroup, cluster_size, strip_times, cluster_time, charge_perPCB, pcb_mon, pcb_strip_mon, charge_perlayer, cluster_size_perlayer);
380  }
381  }
382 
383  fill(MM_sideGroup, strip_number, sector_strip);
384  }
385  }
386  }
387  }
388  }
389 
390  return StatusCode::SUCCESS;
391 }
392 
394  return StatusCode::SUCCESS;
395 }
396 
398 
399  auto lb_tri=Monitored::Scalar<int>("lb_tri",lb);
400 
401  for (const auto* rdo : *mmtp) {
402  auto sourceID = rdo->sourceID();
403  auto moduleID = rdo->moduleID();
404  int s_side = (sourceID >> 16) == 107 ? 1:-1; // 1 for A; -1 for C
405  auto side = Monitored::Scalar<int>("tri_side", s_side);
406  int iside= s_side>0 ? s_side : 0;
407  uint s_sector = (moduleID & 0xF) + 1; //0-15 --> 1-16
408  int oct = (int)((s_sector-1)/2.);
409  float sector_pos=(45/180.)*M_PI*oct; //large
410  if(s_sector%2==0 ) sector_pos=(45*oct+22.5)*M_PI/180.; //small
411  if(sector_pos>M_PI) sector_pos=sector_pos-2*M_PI;
412 
413  auto trig_sector = Monitored::Scalar<int>("trig_sector", s_sector*s_side);
414 
415  auto event_bcid=rdo->ROD_BCID();
416 
417  auto bcid=Monitored::Scalar<int>("bcid",event_bcid);
418 
419  std::vector<short unsigned int> art_bcids = rdo->art_BCID();
420  std::vector<unsigned char> layers=rdo->art_layer();
421  auto channels=rdo->art_channel();
422 
423  fill("mmTrigger", trig_sector, lb_tri);
424 
425  for (long unsigned int i=0; i< rdo->art_BCID().size(); i++ ){
426  auto art_layer=static_cast<unsigned int>(layers[i]);
427  auto art_channel = Monitored::Scalar<int>("art_channel", channels[i]);
428  auto art_sector_layer = Monitored::Scalar<int>("art_sector_layer", s_side*8*(s_sector-1)+art_layer);
429 
430  const int rollover=3564;
431  int art_bc=art_bcids[i];
432  int relative = art_bc - event_bcid;;
433  if (relative > rollover / 2) {
434  relative -= rollover;
435  } else if (relative <= -rollover / 2) {
436  relative += rollover;
437  }
438  if (relative > (rollover-2048) / 2) {
439  relative -= (rollover-2048);
440  }
441  auto art_deltaBC=Monitored::Scalar<int>("art_deltaBC",relative);
442  auto art_deltaBC_perSector=Monitored::Scalar<int>("art_deltaBC_"+MM_Side[iside]+"_s"+std::to_string(s_sector),relative);
443  auto art_bc_mon=Monitored::Scalar<int>("art_bc",art_bc);
444 
445  fill("mmTrigger", art_channel, trig_sector, art_sector_layer, art_deltaBC, art_bc_mon, bcid, lb_tri, art_deltaBC_perSector);
446  }
447 
448  auto bcids =rdo->trig_BCID();
449  auto dthetas=rdo->trig_dTheta();
450  auto rids=rdo->trig_ROI_rID();
451  auto phiids=rdo->trig_ROI_phiID() ;
452 
453 
454  std::unordered_map<int, int> NROIPerBC;
455  for (int bc : bcids) NROIPerBC[bc]++;
456  for (const auto& [value, count] : NROIPerBC) {
457  auto nROIPerBC=Monitored::Scalar<int>("nROIPerBC",count);
458  fill("mmTrigger_roi", nROIPerBC, trig_sector);
459  }
460 
461  int nROI=rdo->trig_BCID().size();
462  for (int i=0; i< nROI; i++ ){
463  auto phiID = (phiids[i] & 0b11111) * ((phiids[i] >> 5) ? 1 : -1);
464  int sign = phiID > 0 ? 1 : -1;
465  auto phi_conv = (phiID-0.5*sign)*(16./31.)*M_PI/180. + sector_pos;
466  if(phi_conv> M_PI)phi_conv = phi_conv - 2*M_PI;
467 
468  const float z_ref=7824.46;
469  const float r_step=(5000-900)/256.;
470  auto rID = static_cast<unsigned int>(rids[i]);
471  float r_conv=r_step*rID+900;
472  float eta_conv=-log(0.5*atan(r_conv/z_ref))*s_side;
473  // auto dTheta=Monitored::Scalar<float>("dTheta_roi",static_cast<float>(dthetas[i]));
474  auto deltaBC= Monitored::Scalar<int>("deltaBC", bcids[i]-event_bcid);
475  auto deltaBC_perSector= Monitored::Scalar<int>("deltaBC_"+MM_Side[iside]+"_s"+std::to_string(s_sector), bcids[i]-event_bcid);
476  auto rid=Monitored::Scalar<int>("rid",rID);
477  auto phiid=Monitored::Scalar<int>("phiid",phiID);
478  auto rid_sector=Monitored::Scalar<int>("rid_"+MM_Side[iside]+"_s"+std::to_string(s_sector),rID);
479  auto phiid_sector=Monitored::Scalar<int>("phiid_"+MM_Side[iside]+"_s"+std::to_string(s_sector),phiID);
480  auto r_roi=Monitored::Scalar<float>("r_roi",r_conv);
481  auto phi_roi=Monitored::Scalar<float>("phi_roi",phi_conv);
482  auto eta_roi=Monitored::Scalar<float>("eta_roi",eta_conv);
483  auto x_roi_sideA=Monitored::Scalar<float>("x_roi_sideA", r_conv*cos(phi_roi));
484  auto y_roi_sideA=Monitored::Scalar<float>("y_roi_sideA", r_conv*sin(phi_roi));
485  auto x_roi_sideC=Monitored::Scalar<float>("x_roi_sideC", r_conv*cos(phi_roi) );
486  auto y_roi_sideC=Monitored::Scalar<float>("y_roi_sideC", r_conv*sin(phi_roi));
487 
488  fill("mmTrigger_roi", deltaBC, phiid, rid, trig_sector, phi_roi, eta_roi,r_roi, lb_tri, rid_sector, phiid_sector, deltaBC_perSector);
489  if(s_side>0) fill("mmTrigger_roi", x_roi_sideA, y_roi_sideA);
490  if(s_side<0) fill("mmTrigger_roi", x_roi_sideC, y_roi_sideC);
491 
492  }
493  }
494 
495 }
496 
498 {
499  MMSummaryHistogramStruct summaryPlots[2][2][4]; // side, multilayer, gas gap
500  MMSummaryHistogramStruct summaryPlots_full[2][16][2][2][4]; // side, phi, eta, multilayer, gas gap
501  MMSummaryHistogramStruct sumPlots[2][16][2][2][4]; // side, phi, eta, multilayer, gas gap
502  MMOverviewHistogramStruct overviewPlots;
503  MMByPhiStruct occupancyPlots[16][2]; // sector, side
504  int ntrk=0;
505  for(const xAOD::TrackParticle* meTP : *muonContainer) {
506 
507  if(!meTP) continue;
508  auto eta_trk = Monitored::Scalar<float>("eta_trk", meTP->eta());
509  auto phi_trk = Monitored::Scalar<float>("phi_trk", meTP->phi());
510  auto pt_trk = Monitored::Scalar<float>("pt_trk", meTP->pt()/1000.);
511 
512  //retrieve the original track
513  const Trk::Track* meTrack = meTP->track();
514 
515  if(!meTrack) continue;
516 
517  // get the vector of measurements on track
519  bool isMM=false;
520  for(const Trk::MeasurementBase* it : *meas) {
521  const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(it);
522  if(!rot) continue;
523  Identifier rot_id = rot->identify();
524  if(!m_idHelperSvc->isMM(rot_id)) continue;
525  isMM=true;
526  const Muon::MMClusterOnTrack* cluster = dynamic_cast<const Muon::MMClusterOnTrack*>(rot);
527  if(!cluster) continue;
528 
529  std::string stName = m_idHelperSvc->mmIdHelper().stationNameString(m_idHelperSvc->mmIdHelper().stationName(rot_id));
530  int stEta = m_idHelperSvc->mmIdHelper().stationEta(rot_id);
531  int stPhi = m_idHelperSvc->mmIdHelper().stationPhi(rot_id);
532  int multi = m_idHelperSvc->mmIdHelper().multilayer(rot_id);
533  int gap = m_idHelperSvc->mmIdHelper().gasGap(rot_id);
534  int ch = m_idHelperSvc->mmIdHelper().channel(rot_id);
535 
536  // MMS and MML phi sectors
537  // int phisec = (stNumber%2==0) ? 1 : 0;
538  int sectorPhi = get_sectorPhi_from_stationPhi_stName(stPhi,stName); // 1->16
539  int PCB = get_PCB_from_channel(ch);
540  int iside = (stEta > 0) ? 1 : 0;
541  auto& vects = overviewPlots;
542  auto& thisSect = occupancyPlots[sectorPhi-1][iside];
543 
544 
545  const Muon::MMPrepData* prd = cluster->prepRawData();
546  const std::vector<Identifier>& stripIds = prd->rdoList();
547  unsigned int csize = stripIds.size();
548  const std::vector<uint16_t>& stripNumbers = prd->stripNumbers();
549  float charge = prd->charge()*conversion_charge;
550  std::vector<short int> s_times = prd->stripTimes();
551 
552  vects.charge_all.push_back(charge);
553 
554  float c_time = 0;
555  for(unsigned int sIdx=0; sIdx<stripIds.size(); ++sIdx){
556  vects.strp_times.push_back(s_times.at(sIdx));
557  c_time += s_times.at(sIdx);
558  }
559  c_time /= s_times.size();
560  vects.cl_times.push_back(c_time);
561 
562  if(m_doDetailedHists){
563  auto& vect = sumPlots[iside][sectorPhi-1][std::abs(stEta)-1][multi-1][gap-1];
564  vect.cl_size.push_back(csize);
565  vect.pcb.push_back(PCB);
566  for(unsigned int sIdx=0; sIdx<stripIds.size(); ++sIdx)
567  {
568  vect.strip_number.push_back(stripNumbers[sIdx]);
569  vect.strp_times.push_back(s_times.at(sIdx));
570  vect.pcb_strip.push_back(get_PCB_from_channel(stripNumbers[sIdx]));
571  }
572  vect.cl_times.push_back(c_time);
573  vect.charge.push_back(charge);
574  }
575 
576 
577  const int gap_offset=4;
578  int gas_gap8 = (multi==1) ? gap : gap + gap_offset;
579 
580  int FEB = get_FEB_from_channel(ch, stEta);
581  int bin = get_bin_for_feb_occ(gas_gap8,FEB);
582  thisSect.sector_lb_ontrack.push_back(bin);
583  // Occupancy plots with FEB granularity further divided for each eta sector: -2, -1, 1, 2
584  // Filling Vectors for stationEta=-1 - cluster on track
585  if(stEta<0) {
586  vects.sector_CSide_ontrack.push_back(bin);
587  vects.stationPhi_CSide_ontrack.push_back(sectorPhi);
588  } else {
589  vects.sector_ASide_ontrack.push_back(bin);
590  vects.stationPhi_ASide_ontrack.push_back(sectorPhi);
591  }
592 
593  float x = cluster->localParameters()[Trk::loc1];
594  for(const Trk::TrackStateOnSurface* trkState : *meTrack->trackStateOnSurfaces()) {
595 
596  if(!(trkState)) continue;
597  if (!trkState->type(Trk::TrackStateOnSurface::Measurement)) continue;
598 
599  Identifier surfaceId = (trkState)->surface().associatedDetectorElementIdentifier();
600  if(!m_idHelperSvc->isMM(surfaceId)) continue;
601 
602  int trk_stEta = m_idHelperSvc->mmIdHelper().stationEta(surfaceId);
603  int trk_stPhi = m_idHelperSvc->mmIdHelper().stationPhi(surfaceId);
604  int trk_multi = m_idHelperSvc->mmIdHelper().multilayer(surfaceId);
605  int trk_gap = m_idHelperSvc->mmIdHelper().gasGap(surfaceId);
606 
607  if( (trk_stPhi == stPhi) && (trk_stEta == stEta) && (trk_multi == multi) && (trk_gap == gap)) {
608  double x_trk = trkState->trackParameters()->parameters()[Trk::loc1];
609  int sectorPhi = get_sectorPhi_from_stationPhi_stName(trk_stPhi,stName); // 1->16
610  int side = (stEta > 0) ? 1 : 0;
611  float res_stereo = (x - x_trk);
613  float stereo_angle = ((multi == 1 && gap < 3) || (multi == 2 && gap > 2)) ? 0 : 0.02618;
614  double y_trk = trkState->trackParameters()->parameters()[Trk::locY];
615  float stereo_correction = ( (multi == 1 && gap < 3) || (multi == 2 && gap > 2) ) ? 0 : ( ((multi == 1 && gap == 3) || (multi == 2 && gap ==1 )) ? (-std::sin(stereo_angle)*y_trk) : std::sin(stereo_angle)*y_trk );
616  res_stereo = (x - x_trk)*std::cos(stereo_angle) - stereo_correction;
617  }
618  auto residual_mon = Monitored::Scalar<float>("residual", res_stereo);
619  auto stPhi_mon = Monitored::Scalar<float>("stPhi_mon",sectorPhi);
620 
621  fill("mmMonitor", residual_mon, eta_trk, phi_trk, stPhi_mon);
622  int abs_stEta = get_sectorEta_from_stationEta(stEta); // 0 or 1
623 
624  if(m_doDetailedHists){
625  auto& vectors = summaryPlots_full[side][sectorPhi-1][abs_stEta][multi-1][gap-1];
626  vectors.residuals.push_back(res_stereo);
627  }
628  }
629  }//TrackStates
630 
631  } // loop on meas
632  if(isMM) {
633  ++ntrk;
634  fill("mmMonitor", pt_trk);
635  }
636 
637  if(m_doDetailedHists){
638  for(int iside = 0; iside < 2; ++iside) {
639  std::string MM_sideGroup = "MM_sideGroup" + MM_Side[iside];
640  for(int statPhi = 0; statPhi < 16; ++statPhi) {
641  // for(int statEta = 0; statEta < 2; ++statEta) {
642  for(int multiplet = 0; multiplet < 2; ++multiplet) {
643  for(int gas_gap = 0; gas_gap < 4; ++gas_gap) {
644  auto layer=gas_gap+multiplet*4;
645  MMSummaryHistogramStruct vects;
646  for(int statEta = 0; statEta < 2; ++statEta) {
647  vects = summaryPlots_full[iside][statPhi][statEta][multiplet][gas_gap];
648  auto residuals_gap = Monitored::Collection("residuals_"+MM_Side[iside]+"_phi"+std::to_string(statPhi+1)+"_stationEta"+EtaSector[statEta]+"_multiplet"+std::to_string(multiplet+1)+"_gas_gap"+std::to_string(gas_gap+1),vects.residuals);
649  auto residuals_layer = Monitored::Collection("residuals_"+MM_Side[iside]+"_phi"+std::to_string(statPhi+1)+"_layer"+std::to_string(layer+1),vects.residuals);
650 
651  fill(MM_sideGroup, residuals_gap,residuals_layer);
652  }
653  }
654  }
655  }
656  }
657  }
658 
659  for(const Trk::TrackStateOnSurface* trkState : *meTrack->trackStateOnSurfaces()) {
660  if(!(trkState)) continue;
661  if (!trkState->type(Trk::TrackStateOnSurface::Measurement)) continue;
662  Identifier surfaceId = (trkState)->surface().associatedDetectorElementIdentifier();
663  if(!m_idHelperSvc->isMM(surfaceId)) continue;
664 
665  const Trk::MeasurementBase* meas = trkState->measurementOnTrack() ;
666  if(!meas) continue;
667 
668  const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(meas);
669  if(!rot) continue;
670  Identifier rot_id = rot->identify();
671  if(!m_idHelperSvc->isMM(rot_id)) continue;
672 
673  const Amg::Vector3D& pos = (trkState)->trackParameters()->position();
674  int stEta = m_idHelperSvc->mmIdHelper().stationEta(surfaceId);
675  int multi = m_idHelperSvc->mmIdHelper().multilayer(surfaceId);
676  int gap = m_idHelperSvc->mmIdHelper().gasGap(surfaceId);
677 
678  // CSide and ASide
679  int iside = (stEta > 0) ? 1 : 0;
680  auto& Vectors = summaryPlots[iside][multi-1][gap-1];
681 
682  // Filling x-y position vectors using the trackStateonSurface
683  Vectors.x_ontrack.push_back(pos.x());
684  Vectors.y_ontrack.push_back(pos.y());
685  }
686  } // loop on muonContainer
687 
688  auto ntrack = Monitored::Scalar<int>("ntrk",ntrk);
689  fill("mmMonitor", ntrack);
690 
691  auto& vects = overviewPlots;
692  auto stationPhi_CSide_ontrack = Monitored::Collection("stationPhi_CSide_ontrack",vects.stationPhi_CSide_ontrack);
693  auto stationPhi_ASide_ontrack = Monitored::Collection("stationPhi_ASide_ontrack",vects.stationPhi_ASide_ontrack);
694  auto sector_ASide_ontrack = Monitored::Collection("sector_ASide_ontrack",vects.sector_ASide_ontrack);
695  auto sector_CSide_ontrack = Monitored::Collection("sector_CSide_ontrack",vects.sector_CSide_ontrack);
696 
697  auto lb_ontrack = Monitored::Scalar<int>("lb_ontrack", lb);
698  auto csize = Monitored::Collection("nstrips_ontrack", vects.numberofstrips_percluster);
699  auto charge = Monitored::Collection("charge_ontrack", vects.charge_all);
700  auto stime = Monitored::Collection("strip_time_on_track", vects.strp_times);
701  auto ctime = Monitored::Collection("cluster_time_on_track", vects.cl_times);
702 
703  fill("mmMonitor", csize, charge, stime, ctime, stationPhi_CSide_ontrack, stationPhi_ASide_ontrack, sector_CSide_ontrack,sector_ASide_ontrack, lb_ontrack);
704 
705  for(int iside = 0; iside < 2; ++iside) {
706  std::string MM_sideGroup = "MM_sideGroup" + MM_Side[iside];
707  for(int statPhi = 0; statPhi < 16; ++statPhi) {
708  for(int statEta = 0; statEta < 2; ++statEta) {
709  for(int multiplet = 0; multiplet < 2; ++multiplet) {
710  for(int gas_gap = 0; gas_gap < 4; ++gas_gap) {
711  auto& vects = sumPlots[iside][statPhi][statEta][multiplet][gas_gap];
712  if(m_doDetailedHists){
713  if(!vects.strip_number.empty())
714  {
715  auto clus_size = Monitored::Collection("cluster_size_ontrack_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), vects.cl_size);
716  auto strip_times = Monitored::Collection("strp_time_ontrack_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), vects.strp_times);
717  auto cluster_time = Monitored::Collection("cluster_time_ontrack_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), vects.cl_times);
718  auto charge_perPCB = Monitored::Collection("charge_perPCB_ontrack_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), vects.charge);
719  auto charge_perlayer = Monitored::Collection("charge_perlayer_ontrack_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), vects.charge);
720  auto clus_size_perlayer = Monitored::Collection("cluster_size_perlayer_ontrack_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), vects.cl_size);
721  auto pcb_mon = Monitored::Collection("pcb_mon_ontrack_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), vects.pcb);
722  auto pcb_strip_mon = Monitored::Collection("pcb_strip_mon_ontrack_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), vects.pcb_strip);
723 
724  fill(MM_sideGroup, clus_size, strip_times, cluster_time, charge_perPCB, pcb_mon, pcb_strip_mon,charge_perlayer,clus_size_perlayer);
725  }
726  }
727 
728  }
729  }
730  }
731  auto& occ_lb = occupancyPlots[statPhi][iside];
732  auto sector_lb_ontrack = Monitored::Collection("sector_lb_"+MM_Side[iside]+"_phi"+std::to_string(statPhi+1)+"_ontrack",occ_lb.sector_lb_ontrack);
733  fill(MM_sideGroup, lb_ontrack, sector_lb_ontrack);
734  }
735  for(int multiplet=0; multiplet<2; ++multiplet) {
736  for(int gas_gap=0; gas_gap<4; ++gas_gap) {
737  auto& Vectors = summaryPlots[iside][multiplet][gas_gap];
738  auto x_ontrack = Monitored::Collection("x_"+MM_Side[iside]+"_multiplet"+std::to_string(multiplet+1)+"_gas_gap_"+std::to_string(gas_gap+1)+"_ontrack", Vectors.x_ontrack);
739  auto y_ontrack = Monitored::Collection("y_"+MM_Side[iside]+"_multiplet"+std::to_string(multiplet+1)+"_gas_gap_"+std::to_string(gas_gap+1)+"_ontrack", Vectors.y_ontrack);
740  fill(MM_sideGroup, x_ontrack, y_ontrack);
741  }
742  }
743  }
744 
745 }
746 
748 {
749  MMEfficiencyHistogramStruct effPlots[2][2][16][2][4];
750  MMEfficiencyHistogramStruct Gaps[2][2][16][2];
751 
752  static const std::array<std::string,2> MM_Side = {"CSide", "ASide"};
753  static const std::array<std::string,2> EtaSector = {"1","2"};
754 
755  for (const xAOD::TrackParticle* meTP : *muonContainer) {
756  if (!meTP) continue;
757  auto eta_trk = Monitored::Scalar<float>("eta_trk", meTP->eta());
758  auto phi_trk = Monitored::Scalar<float>("phi_trk", meTP->phi());
759 
760  float pt_trk = meTP->pt();
761  if(pt_trk < m_cut_pt) continue;
762  // retrieve the original track
763  const Trk::Track* meTrack = meTP->track();
764  if(!meTrack) continue;
765  // get the vector of measurements on track
767 
768  for(const Trk::MeasurementBase* it: *meas) {
769  const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(it);
770  if (!rot) continue;
771  Identifier rot_id = rot->identify();
772  if (!m_idHelperSvc->isMM(rot_id)) continue;
773 
774  const Muon::MMClusterOnTrack* cluster = dynamic_cast<const Muon::MMClusterOnTrack*>(rot);
775  if (!cluster) continue;
776  std::string stName = m_idHelperSvc->mmIdHelper().stationNameString(m_idHelperSvc->mmIdHelper().stationName(rot_id));
777  int stEta= m_idHelperSvc->mmIdHelper().stationEta(rot_id);
778  int stPhi= m_idHelperSvc->mmIdHelper().stationPhi(rot_id);
779  int phi = get_sectorPhi_from_stationPhi_stName(stPhi,stName);
780  int multi = m_idHelperSvc->mmIdHelper().multilayer(rot_id);
781  int gap= m_idHelperSvc->mmIdHelper().gasGap(rot_id);
782  int ch= m_idHelperSvc->mmIdHelper().channel(rot_id);
783  int pcb=get_PCB_from_channel(ch);
784  int abs_stEta= get_sectorEta_from_stationEta(stEta);
785  int iside = (stEta > 0) ? 1 : 0;
786  if( ! (std::find( Gaps[iside][abs_stEta][phi-1][multi-1].nGaps.begin(), Gaps[iside][abs_stEta][phi-1][multi-1].nGaps.end(), gap ) != Gaps[iside][abs_stEta][phi-1][multi-1].nGaps.end()) )
787  Gaps[iside][abs_stEta][phi-1][multi-1].nGaps.push_back(gap);
788  //numerator
789  if(effPlots[iside][abs_stEta][phi-1][multi-1][gap-1].num.size()==0) effPlots[iside][abs_stEta][phi-1][multi-1][gap-1].num.push_back(pcb-1);
790  }
791  } // loop on tracks
792 
793  unsigned int nGaptag=3;
794 
795  for(int s=0; s<2; ++s) {
796  std::string MM_sideGroup = "MM_sideGroup"+MM_Side[s];
797  for(int e=0; e<2; ++e) {
798  for(int p=0; p<16; ++p) {
799  for(int m=0; m<2; ++m) {
800  if(Gaps[s][e][p][m].nGaps.size()<nGaptag) continue;
801  if(Gaps[s][e][p][m].nGaps.size()>4) continue;
802  //find the missing gap
803  int gapsum=0;
804  for (unsigned int g=0; g<Gaps[s][e][p][m].nGaps.size(); ++g)
805  gapsum+= Gaps[s][e][p][m].nGaps.at(g);
806  int missing_gap=10-gapsum-1;
807  //if missing gap = -1 --> nGaps=4 --> all efficient
808  if(Gaps[s][e][p][m].nGaps.size()==4){
809  for (unsigned int ga=0; ga<Gaps[s][e][p][m].nGaps.size(); ++ga){
810  for (unsigned int i=0; i<effPlots[s][e][p][m][ga].num.size(); ++i){
811  int pcb = effPlots[s][e][p][m][ga].num.at(i);
812  auto traversed_pcb = Monitored::Scalar<int>("pcb_eta"+std::to_string(e+1)+"_"+MM_Side[s]+"_phi"+std::to_string(p)+"_multiplet"+std::to_string(m+1)+"_gas_gap"+std::to_string(ga+1),pcb);
813  int layer=ga+4*m+8*p;
814 
815  auto traversed_gap = Monitored::Scalar<int>(MM_Side[s]+"_eta"+std::to_string(e+1),layer);
816  auto isHit = 1;
817  auto hitcut = Monitored::Scalar<int>("hitcut", (int)isHit);
818  fill(MM_sideGroup, traversed_pcb, traversed_gap, hitcut);
819  }
820  }
821  } else {// 3 gaps, the fourth is inefficient
822  int ref_gap = missing_gap+1;
823  if(missing_gap==3) ref_gap=0;
824  if (ref_gap>3){
825  ATH_MSG_FATAL("ref_gap is out of range in MMRawDataMonAlg::MMEfficiency");
826  return;
827  }
828  int ref_pcb=effPlots[s][e][p][m][ref_gap].num.at(0);
829  auto traversed_pcb = Monitored::Scalar<int>("pcb_eta"+std::to_string(e+1)+"_"+MM_Side[s]+"_phi"+std::to_string(p)+"_multiplet"+std::to_string(m+1)+"_gas_gap"+std::to_string(missing_gap+1), ref_pcb);
830  int layer=missing_gap+4*m+8*p;
831  auto traversed_gap = Monitored::Scalar<int>(MM_Side[s]+"_eta"+std::to_string(e+1),layer);
832  auto isHit = 0;
833  auto hitcut = Monitored::Scalar<int>("hitcut", (int)isHit);
834  fill(MM_sideGroup, traversed_pcb, traversed_gap, hitcut);
835  }
836 
837 
838  }
839  }
840  }
841  }
842 }
843 
844 
846 {
847  MMOverviewHistogramStruct overviewPlots;
848  MMByPhiStruct occupancyPlots[16][2];
849  MMSummaryHistogramStruct summaryPlots[2][16][2][2][4];
850  int nseg=0;
851 
852  for (Trk::SegmentCollection::const_iterator s = segms->begin(); s != segms->end(); ++s) {
853  const Muon::MuonSegment* segment = dynamic_cast<const Muon::MuonSegment*>(*s);
854  if (segment == nullptr) {
855  ATH_MSG_DEBUG("no pointer to segment!!!");
856  break;
857  }
858  bool isMM=false;
859  for(unsigned int irot=0;irot<segment->numberOfContainedROTs();irot++){
860  const Trk::RIO_OnTrack* rot = segment->rioOnTrack(irot);
861  if(!rot) continue;
862  Identifier rot_id = rot->identify();
863  if(!m_idHelperSvc->isMM(rot_id)) continue;
864  isMM=true;
865  const Muon::MMClusterOnTrack* cluster = dynamic_cast<const Muon::MMClusterOnTrack*>(rot);
866  if(!cluster) continue;
867 
868  std::string stName = m_idHelperSvc->mmIdHelper().stationNameString(m_idHelperSvc->mmIdHelper().stationName(rot_id));
869  int stEta = m_idHelperSvc->mmIdHelper().stationEta(rot_id);
870  int stPhi = m_idHelperSvc->mmIdHelper().stationPhi(rot_id);
871  int multi = m_idHelperSvc->mmIdHelper().multilayer(rot_id);
872  int gap = m_idHelperSvc->mmIdHelper().gasGap(rot_id);
873  int ch = m_idHelperSvc->mmIdHelper().channel(rot_id);
874 
875  // MMS and MML phi sectors
876  int sectorPhi = get_sectorPhi_from_stationPhi_stName(stPhi,stName);
877  int PCB = get_PCB_from_channel(ch);
878  int iside = (stEta > 0) ? 1 : 0;
879 
880  const Muon::MMPrepData* prd = cluster->prepRawData();
881  const std::vector<Identifier>& stripIds = prd->rdoList();
882  unsigned int csize = stripIds.size();
883  const std::vector<uint16_t>& stripNumbers = prd->stripNumbers();
884 
885  auto& pcb_vects = summaryPlots[iside][sectorPhi-1][std::abs(stEta)-1][multi-1][gap-1];
886  pcb_vects.cl_size.push_back(csize);
887  pcb_vects.pcb.push_back(PCB);
888  std::vector<short int> s_times = prd->stripTimes();
889  float c_time = 0;
890  for(unsigned int sIdx=0; sIdx<csize; ++sIdx) {
891  pcb_vects.strp_times.push_back(s_times.at(sIdx));
892  pcb_vects.pcb_strip.push_back( get_PCB_from_channel(stripNumbers[sIdx]));
893  c_time += s_times.at(sIdx);
894  }
895  c_time /= s_times.size();
896  pcb_vects.cl_times.push_back(c_time);
897 
898  float charge = prd->charge()*conversion_charge;
899  pcb_vects.charge.push_back(charge);
900 
901  auto& vects = overviewPlots;
902 
903  auto& thisSect = occupancyPlots[sectorPhi-1][iside];
904 
905  const int gap_offset=4;
906  int gas_gap8 = (multi==1) ? gap : gap + gap_offset;
907  int FEB = get_FEB_from_channel(ch, stEta);
908 
909  int bin=get_bin_for_feb_occ(gas_gap8,FEB);
910  thisSect.sector_lb_onseg.push_back(bin);
911 
912  if(stEta<0) {
913  vects.sector_CSide_onseg.push_back(bin);
914  vects.stationPhi_CSide_onseg.push_back(sectorPhi);
915  } else {
916  vects.sector_ASide_onseg.push_back(bin);
917  vects.stationPhi_ASide_onseg.push_back(sectorPhi);
918  }
919 
920  } // loop on ROT container
921  if (isMM==true) ++nseg;
922 
923  } // loop on segment collection
924  auto nsegs = Monitored::Scalar<int>("nseg",nseg);
925  fill("mmMonitor", nsegs);
926 
927  auto& vects = overviewPlots;
928  auto stationPhi_CSide_onseg = Monitored::Collection("stationPhi_CSide_onseg",vects.stationPhi_CSide_onseg);
929  auto stationPhi_ASide_onseg = Monitored::Collection("stationPhi_ASide_onseg",vects.stationPhi_ASide_onseg);
930  auto sector_ASide_onseg = Monitored::Collection("sector_ASide_onseg",vects.sector_ASide_onseg);
931  auto sector_CSide_onseg = Monitored::Collection("sector_CSide_onseg",vects.sector_CSide_onseg);
932 
933  auto lb_onseg = Monitored::Scalar<int>("lb_onseg", lb);
934 
935  fill("mmMonitor", stationPhi_CSide_onseg, stationPhi_ASide_onseg, sector_CSide_onseg, sector_ASide_onseg, lb_onseg);
936 
937  for(int iside = 0; iside < 2; ++iside) {
938  std::string MM_sideGroup = "MM_sideGroup" + MM_Side[iside];
939  for(int statPhi=0; statPhi<16; ++statPhi) {
940  auto& occ_lb = occupancyPlots[statPhi][iside];
941  auto sector_lb_onseg = Monitored::Collection("sector_lb_"+MM_Side[iside]+"_phi"+std::to_string(statPhi+1)+"_onseg",occ_lb.sector_lb_onseg);
942  fill(MM_sideGroup, lb_onseg, sector_lb_onseg);
943 
944  for(int statEta = 0; statEta < 2; ++statEta) {
945  for(int multiplet = 0; multiplet < 2; ++multiplet) {
946  for(int gas_gap = 0; gas_gap < 4; ++gas_gap) {
947  auto& pcb_vects = summaryPlots[iside][statPhi][statEta][multiplet][gas_gap];
948 
949  if(pcb_vects.pcb.empty()) continue;
950  if(m_doDetailedHists){
951  auto pcb_mon = Monitored::Collection("pcb_mon_onseg_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), pcb_vects.pcb);
952  auto pcb_strip_mon = Monitored::Collection("pcb_strip_mon_onseg_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), pcb_vects.pcb_strip);
953  auto strip_times = Monitored::Collection("strp_time_onseg_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), pcb_vects.strp_times);
954  auto cluster_time = Monitored::Collection("cluster_time_onseg_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), pcb_vects.cl_times);
955  auto clus_size = Monitored::Collection("cluster_size_onseg_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), pcb_vects.cl_size);
956  auto charge_perPCB = Monitored::Collection("charge_perPCB_onseg_" + MM_Side[iside] + "_phi" + std::to_string(statPhi+1) + "_eta" + std::to_string(statEta+1) + "_ml" + std::to_string(multiplet+1) + "_gap" + std::to_string(gas_gap+1), pcb_vects.charge);
957 
958  fill(MM_sideGroup, clus_size, strip_times, charge_perPCB, cluster_time, pcb_mon, pcb_strip_mon);
959  }
960  auto clus_size_all = Monitored::Collection("cluster_size_onseg", pcb_vects.cl_size);
961  auto charge_all = Monitored::Collection("charge_onseg", pcb_vects.charge);
962  auto strip_times_all = Monitored::Collection("strp_time_onseg", pcb_vects.strp_times);
963  fill("mmMonitor", clus_size_all, charge_all, strip_times_all);
964  }
965  }
966  }
967  }
968  }
969 }
muonContainer
xAOD::MuonContainer * muonContainer
Definition: TrigGlobEffCorrValidation.cxx:188
MMRawDataMonAlg::m_doMMESD
Gaudi::Property< bool > m_doMMESD
Definition: MMRawDataMonAlg.h:106
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
MMRawDataMonAlg::m_MMContainerKey
SG::ReadHandleKey< Muon::MMPrepDataContainer > m_MMContainerKey
Definition: MMRawDataMonAlg.h:67
MMRawDataMonAlg::get_bin_for_occ_ASide_hist
int get_bin_for_occ_ASide_hist(const int stationEta, const int multiplet, const int gas_gap) const
Definition: MMRawDataUtils.cxx:106
Muon::nsw::STGTPSegments::moduleIDBits::stationPhi
constexpr uint8_t stationPhi
station Phi 1 to 8
Definition: NSWSTGTPDecodeBitmaps.h:158
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
Muon::MMPrepData
Class to represent MM measurements.
Definition: MMPrepData.h:22
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
MMRawDataMonAlg::m_do_mm_overview
Gaudi::Property< bool > m_do_mm_overview
Definition: MMRawDataMonAlg.h:107
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
Muon::MMPrepData::globalPosition
virtual const Amg::Vector3D & globalPosition() const override final
Returns the global position.
Definition: MMPrepData.h:211
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
MMRawDataMonAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: MMRawDataMonAlg.cxx:103
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
MMRawDataMonAlg::m_meTrkKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_meTrkKey
Definition: MMRawDataMonAlg.h:69
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
python.MagFieldUtils.lumiblock
lumiblock
Definition: MagFieldUtils.py:188
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MMRawDataMonAlg::m_mmtpRdoKey
SG::ReadHandleKey< xAOD::NSWMMTPRDOContainer > m_mmtpRdoKey
Definition: MMRawDataMonAlg.h:70
MMRawDataMonAlg::m_do_stereoCorrection
Gaudi::Property< bool > m_do_stereoCorrection
Definition: MMRawDataMonAlg.h:108
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
Trk::Track::trackStateOnSurfaces
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
MMRawDataMonAlg::m_cut_pt
Gaudi::Property< float > m_cut_pt
Definition: MMRawDataMonAlg.h:109
MMRawDataMonAlg::get_bin_for_feb_occ
int get_bin_for_feb_occ(const int gas_gap, const int FEB) const
Definition: MMRawDataUtils.cxx:136
MMRawDataMonAlg::m_muonKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonKey
Definition: MMRawDataMonAlg.h:68
module_driven_slicing.layers
layers
Definition: module_driven_slicing.py:114
skel.it
it
Definition: skel.GENtoEVGEN.py:396
MMRawDataMonAlg::fillMMOverviewHistograms
void fillMMOverviewHistograms(const MMOverviewHistogramStruct &vects, MMByPhiStruct(&occupancyPlots)[16][2], const int lb) const
Definition: MMRawDataMonAlg.cxx:259
Muon::MMClusterOnTrack::prepRawData
virtual const MMPrepData * prepRawData() const
Returns the MMPrepData - is a TRT_DriftCircle in this scope.
Definition: MMClusterOnTrack.h:128
IdentifiableContainerMT::size
size_t size() const
Duplicate of fullSize for backwards compatability.
Definition: IdentifiableContainerMT.h:209
M_PI
#define M_PI
Definition: ActiveFraction.h:11
bin
Definition: BinsDiffFromStripMedian.h:43
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
athena.value
value
Definition: athena.py:124
MMRawDataMonAlg::get_PCB_from_channel
int get_PCB_from_channel(const int channel) const
Definition: MMRawDataUtils.cxx:23
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
stime
std::string stime()
return the current data and time
Definition: computils.cxx:213
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
PlotCalibFromCool.multi
multi
Definition: PlotCalibFromCool.py:99
MuonPrepDataContainer.h
x
#define x
CaloSwCorrections.gap
def gap(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:212
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
MMRawDataMonAlg::clusterFromSegments
void clusterFromSegments(const Trk::SegmentCollection *, const int lb) const
Definition: MMRawDataMonAlg.cxx:845
MMClusterOnTrack.h
MMRawDataMonAlg::MMEfficiency
void MMEfficiency(const xAOD::TrackParticleContainer *) const
Definition: MMRawDataMonAlg.cxx:747
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
MMRawDataMonAlg.h
dq_defect_copy_defect_database.channels
def channels
Definition: dq_defect_copy_defect_database.py:56
MMRawDataMonAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: MMRawDataMonAlg.cxx:129
MuonChamberNameConverter.h
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
MMRawDataMonAlg::m_segm_type
SG::ReadHandleKey< Trk::SegmentCollection > m_segm_type
Definition: MMRawDataMonAlg.h:66
TRT::Hit::side
@ side
Definition: HitInfo.h:83
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
MMRawDataMonAlg::get_bin_for_occ_CSide_hist
int get_bin_for_occ_CSide_hist(const int stationEta, const int multiplet, const int gas_gap) const
Definition: MMRawDataUtils.cxx:97
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
MMRawDataMonAlg::fillMMTrigger
void fillMMTrigger(const xAOD::NSWMMTPRDOContainer *, const int) const
Definition: MMRawDataMonAlg.cxx:397
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
MMReadoutElement.h
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
MMRawDataMonAlg::get_FEB_from_channel
int get_FEB_from_channel(const int channel, const int stEta) const
Definition: MMRawDataUtils.cxx:34
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
MuonChambersRange.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
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
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
MMPrepData.h
MMRawDataMonAlg::get_sectorEta_from_stationEta
int get_sectorEta_from_stationEta(const int stationEta) const
Definition: MMRawDataUtils.cxx:87
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
AthenaMonManager.h
MMRawDataMonAlg::m_DetectorManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
Definition: MMRawDataMonAlg.h:65
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MMRawDataMonAlg::fillMMOverviewVects
StatusCode fillMMOverviewVects(const Muon::MMPrepData *, MMOverviewHistogramStruct &vects, MMByPhiStruct(&occupancyPlots)[16][2]) const
Definition: MMRawDataMonAlg.cxx:185
MMRawDataMonAlg::get_sectorPhi_from_stationPhi_stName
int get_sectorPhi_from_stationPhi_stName(const int stationPhi, const std::string &stName) const
Definition: MMRawDataUtils.cxx:64
AnalysisUtils::Delta::R
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)
Definition: AnalysisMisc.h:49
Muon::MMPrepData::stripNumbers
const std::vector< uint16_t > & stripNumbers() const
returns the list of strip numbers
Definition: MMPrepData.h:247
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
Muon::MuonPrepDataCollection
Template to hold collections of MuonPrepRawData objects.
Definition: MuonPrepDataCollection.h:46
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Muon::MMPrepData::stripTimes
const std::vector< short int > & stripTimes() const
returns the list of times
Definition: MMPrepData.h:252
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
Muon::MMClusterOnTrack
Class to represent calibrated clusters formed from TGC strips.
Definition: MMClusterOnTrack.h:26
Trk::MeasurementBase
Definition: MeasurementBase.h:58
MuonGM::nStrips
int nStrips(const MuonGM::TgcReadoutElement &readoutEle, int layer)
Definition: MuonDetDescr/MuonGeoModelTest/src/GeoModelTgcTest.cxx:46
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
MMRawDataMonAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MMRawDataMonAlg.h:62
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MMRawDataMonAlg::fillMMSummaryVects
StatusCode fillMMSummaryVects(const Muon::MMPrepData *, MMSummaryHistogramStruct(&vects)[2][16][2][2][4]) const
Definition: MMRawDataMonAlg.cxx:295
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
charge
double charge(const T &p)
Definition: AtlasPID.h:538
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
MMRawDataMonAlg::fillMMHistograms
StatusCode fillMMHistograms(const Muon::MMPrepData *) const
Definition: MMRawDataMonAlg.cxx:393
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonDetectorManager.h
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::MeasurementBase::localParameters
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Definition: MeasurementBase.h:132
MMRawDataMonAlg::m_doDetailedHists
Gaudi::Property< bool > m_doDetailedHists
Definition: MMRawDataMonAlg.h:110
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
MMRawDataMonAlg::MMRawDataMonAlg
MMRawDataMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MMRawDataMonAlg.cxx:98
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
Trk::Track::measurementsOnTrack
const DataVector< const MeasurementBase > * measurementsOnTrack() const
return a pointer to a vector of MeasurementBase (NOT including any that come from outliers).
Definition: Tracking/TrkEvent/TrkTrack/src/Track.cxx:178
TrackParticle.h
Trk::RIO_OnTrack::identify
Identifier identify() const
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:152
MMRawDataMonAlg::fillMMSummaryHistograms
StatusCode fillMMSummaryHistograms(const MMSummaryHistogramStruct(&vects)[2][16][2][2][4]) const
Definition: MMRawDataMonAlg.cxx:351
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MMRawDataMonAlg::clusterFromTrack
void clusterFromTrack(const xAOD::TrackParticleContainer *, const int lb) const
Definition: MMRawDataMonAlg.cxx:497
MuonSegment.h
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
Muon::MuonSegment
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
Muon::nsw::STGTPSegments::moduleIDBits::stationEta
constexpr uint8_t stationEta
1 to 3
Definition: NSWSTGTPDecodeBitmaps.h:156
MuonStation.h
Trk::loc1
@ loc1
Definition: ParamDefs.h:34
Muon::MMPrepData::charge
int charge() const
Returns the AD.
Definition: MMPrepData.h:227
TrackingPrimitives.h
MuonFixedId.h
TrackParticleContainer.h
Trk::TrackStateOnSurface::Measurement
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Definition: TrackStateOnSurface.h:101
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
Identifier
Definition: IdentifierFieldParser.cxx:14