ATLAS Offline Software
MdtRegionDefiner.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MdtRegionDefiner.h"
6 
7 #include "MdtRegion.h"
12 #include <cmath>
13 
14 // --------------------------------------------------------------------------------
15 // --------------------------------------------------------------------------------
16 
18  const std::string& name,
19  const IInterface* parent):
21 {
22 }
23 
24 // --------------------------------------------------------------------------------
25 // --------------------------------------------------------------------------------
26 
28 {
29  ATH_CHECK(m_muDetMgrKey.initialize());
30  ATH_CHECK(m_idHelperSvc.retrieve());
31  return StatusCode::SUCCESS;
32 }
33 
34 // --------------------------------------------------------------------------------
35 // --------------------------------------------------------------------------------
36 
38  const TrigL2MuonSA::RpcFitResult& rpcFitResult,
39  TrigL2MuonSA::MuonRoad& muonRoad,
40  TrigL2MuonSA::MdtRegion& mdtRegion) const
41 {
42  constexpr double ZERO_LIMIT = 1e-5;
43  mdtRegion.Clear();
44 
45  int sectors[2];
46 
47  sectors[0] = muonRoad.MDT_sector_trigger;
48  sectors[1] = muonRoad.MDT_sector_overlap;
49 
51 
52  SG::ReadCondHandle<MuonGM::MuonDetectorManager> muDetMgrHandle{m_muDetMgrKey};
53  const MuonGM::MuonDetectorManager* muDetMgr = muDetMgrHandle.cptr();
54 
55  for(int i_station=0; i_station<6; i_station++) {
56  int chamber = 0;
62  if (i_station==5) chamber = xAOD::L2MuonParameters::Chamber::Backup; // BMG
63  for(int i_sector=0; i_sector<2; i_sector++) { // 0: normal, 1: overlap
64  int sector = sectors[i_sector];
65  ATH_MSG_DEBUG("--- chamber/sector=" << chamber << "/" << sector);
66 
67  if( sector==99 ) continue;
68  float zMin = 0;
69  float zMax = 0;
70  float rMin = 0;
71  float rMax = 0;
72  float etaMin = 0;
73  float etaMax = 0;
74  float phiMin = 0;
75  float phiMax = 0;
76  int types[2];
77  int& ty1 = types[0];
78  int& ty2 = types[1];
79 
80  float tmp_rMin = 0;
81  float tmp_rMax = 0;
82  float tmp_zMin = 0;
83  float tmp_zMax = 0;
84  ty1 = -1;
85  ty2 = -1;
86  int sign = 1;
87 
88  for(unsigned int sta_iter=0; sta_iter< muonRoad.stationList.size(); sta_iter++){
89 
90  Identifier id = muonRoad.stationList[sta_iter];
91  int stationPhi = m_idHelperSvc->mdtIdHelper().stationPhi(id);
92  std::string name = m_idHelperSvc->mdtIdHelper().stationNameString(m_idHelperSvc->mdtIdHelper().stationName(id));
93  int chamber_this = 99;
94  int sector_this = 99;
95  bool isEndcap;
96  find_station_sector(name, stationPhi, isEndcap, chamber_this, sector_this);
97 
98  if(chamber_this == chamber && sector_this == sector ){
99  if(ty1 == -1)
100  ty1 = m_idHelperSvc->mdtIdHelper().stationNameIndex(name)+1;
101  else if(ty2 == -1)
102  ty2 = m_idHelperSvc->mdtIdHelper().stationNameIndex(name)+1;
103 
104  const MuonGM::MdtReadoutElement* mdtReadout = muDetMgr->getMdtReadoutElement(id);
105  const MuonGM::MuonStation* muonStation = mdtReadout->parentMuonStation();
106 
107  Amg::Transform3D trans =muonStation->getNominalAmdbLRSToGlobal();
108 
109  Amg::Vector3D OrigOfMdtInAmdbFrame = muonStation->getBlineFixedPointInAmdbLRS() ;
110 
111  tmp_rMin = (trans*OrigOfMdtInAmdbFrame).perp();
112  tmp_rMax = tmp_rMin+muonStation->Rsize();
113 
114  if(rMin==0 || tmp_rMin < rMin)rMin = tmp_rMin;
115  if(rMax==0 || tmp_rMax > rMax)rMax = tmp_rMax;
116  if ( chamber_this == endcap_inner ){
117  tmp_zMin = (trans*OrigOfMdtInAmdbFrame).z();
118  if(tmp_zMin < 0) sign = -1;
119  else if(tmp_zMin > 0) sign = 1;
120  tmp_zMax = tmp_zMin + sign*muonStation->Zsize();
121  if(zMin==0 || tmp_zMin < zMin)zMin = tmp_zMin;
122  if(zMax==0 || tmp_zMax > zMax)zMax = tmp_zMax;
123  }
124 
125  }
126  }
127 
128  if ( chamber == endcap_inner ){
129  find_endcap_road_dim(muonRoad.rWidth[chamber][0],
130  muonRoad.aw[chamber][i_sector],
131  muonRoad.bw[chamber][i_sector],
132  zMin,zMax,
133  &rMin,&rMax);
134  } else {
135  float max_road = muonRoad.MaxWidth(chamber);
136  find_barrel_road_dim(max_road,
137  muonRoad.aw[chamber][i_sector],
138  muonRoad.bw[chamber][i_sector],
139  rMin,rMax,
140  &zMin,&zMax);
141  }
142 
143  ATH_MSG_DEBUG("...zMin/zMax/ty1/ty2=" << zMin << "/" << zMax << "/" << types[0] << "/" << types[1]);
144  ATH_MSG_DEBUG("...rMin/rMax=" << rMin << "/" << rMax);
145 
146  find_eta_min_max(zMin, rMin, zMax, rMax, etaMin, etaMax);
147 
148  find_phi_min_max(muonRoad.phiRoI, phiMin, phiMax);
149 
150  ATH_MSG_DEBUG("...etaMin/etaMax/phiMin/phiMax=" << etaMin << "/" << etaMax << "/" << phiMin << "/" << phiMax);
151 
152  mdtRegion.zMin[chamber][i_sector] = zMin;
153  mdtRegion.zMax[chamber][i_sector] = zMax;
154  mdtRegion.rMin[chamber][i_sector] = rMin;
155  mdtRegion.rMax[chamber][i_sector] = rMax;
156  mdtRegion.etaMin[chamber][i_sector] = etaMin;
157  mdtRegion.etaMax[chamber][i_sector] = etaMax;
158  mdtRegion.phiMin[chamber][i_sector] = phiMin;
159  mdtRegion.phiMax[chamber][i_sector] = phiMax;
160  for(int i_type=0; i_type<2; i_type++) {
161  int type = types[i_type];
162  if( type == -1 ) continue;
163  mdtRegion.chamberType[chamber][i_sector][i_type] = type;
164  }
165  }
166  }
167 
168  if (m_use_rpc && rpcFitResult.isSuccess) {
169  // use phi from fit
170  for (int i=0; i<6; i++){
171  for (int j=0; j<2; j++){
172  if (i==4) muonRoad.phi[9][j] = rpcFitResult.phi;
173  else if (i==5) muonRoad.phi[10][j] = rpcFitResult.phi;
174  else muonRoad.phi[i][j] = rpcFitResult.phi;
175  }
176  }
177  }
178  else {
179  for (int i=0; i<6; i++){
180  for (int j=0; j<2; j++){
181  if (std::abs(muonRoad.extFtfMiddlePhi) > ZERO_LIMIT) { // for inside-out
182  if (i==4) muonRoad.phi[9][j] = muonRoad.extFtfMiddlePhi;
183  else if (i==5) muonRoad.phi[10][j] = muonRoad.extFtfMiddlePhi;
184  else muonRoad.phi[i][j] = muonRoad.extFtfMiddlePhi;
185  }
186  if (i==4) muonRoad.phi[9][j] = p_roids->phi();
187  else if (i==5) muonRoad.phi[10][j] = p_roids->phi();
188  else muonRoad.phi[i][j] = p_roids->phi();
189  }
190  }
191  }
192 
193  return StatusCode::SUCCESS;
194 }
195 
196 // --------------------------------------------------------------------------------
197 // --------------------------------------------------------------------------------
198 
200  const TrigL2MuonSA::TgcFitResult& tgcFitResult,
201  TrigL2MuonSA::MuonRoad& muonRoad,
202  TrigL2MuonSA::MdtRegion& mdtRegion) const
203 {
204  mdtRegion.Clear();
205 
206  int sectors[2];
207 
208  sectors[0] = muonRoad.MDT_sector_trigger;
209  sectors[1] = muonRoad.MDT_sector_overlap;
210 
214 
215  SG::ReadCondHandle<MuonGM::MuonDetectorManager> muDetMgrHandle{m_muDetMgrKey};
216  const MuonGM::MuonDetectorManager* muDetMgr = muDetMgrHandle.cptr();
217 
218  for(int i_station=0; i_station<7; i_station++) {
219  int chamber = 0;
225  if (i_station==5) chamber = xAOD::L2MuonParameters::Chamber::BEE;
227  for(int i_sector=0; i_sector<2; i_sector++) { // 0: normal, 1: overlap
228  int sector = sectors[i_sector];
229  ATH_MSG_DEBUG("--- chamber/sector=" << chamber << "/" << sector);
230  if( sector==99 ) continue;
231  float zMin = 0;
232  float zMax = 0;
233  float rMin = 0;
234  float rMax = 0;
235  float etaMin = 0;
236  float etaMax = 0;
237  float phiMin = 0;
238  float phiMax = 0;
239  int types[2];
240  int& ty1 = types[0];
241  int& ty2 = types[1];
242  float sta_zMin = 0;
243  float sta_zMax = 0;
244 
245  float tmp_zMin = 0;
246  float tmp_zMax = 0;
247  float tmp_rMin = 0;
248  float tmp_rMax = 0;
249  int sign = 1;
250  ty1 = -1;
251  ty2 = -1;
252 
253  for(unsigned int sta_iter=0; sta_iter<muonRoad.stationList.size(); sta_iter++){
254  Identifier id = muonRoad.stationList[sta_iter];
255  int stationPhi = m_idHelperSvc->mdtIdHelper().stationPhi(id);
256  std::string name = m_idHelperSvc->mdtIdHelper().stationNameString(m_idHelperSvc->mdtIdHelper().stationName(id));
257  int chamber_this = 99;
258  int sector_this = 99;
259  bool isEndcap;
260  find_station_sector(name, stationPhi, isEndcap, chamber_this, sector_this);
261  ATH_MSG_DEBUG("name/stationPhi/isEndcap/chamber_this/sector_this=" <<
262  name << "/" << stationPhi << "/" << isEndcap << "/" << chamber_this << "/" << sector_this);
263 
264  if(chamber_this == chamber && sector_this == sector){
265  if(ty1 == -1)
266  ty1 = m_idHelperSvc->mdtIdHelper().stationNameIndex(name)+1;
267  else if(ty2 == -1)
268  ty2 = m_idHelperSvc->mdtIdHelper().stationNameIndex(name)+1;
269 
270  const MuonGM::MdtReadoutElement* mdtReadout = muDetMgr->getMdtReadoutElement(id);
271  const MuonGM::MuonStation* muonStation = mdtReadout->parentMuonStation();
272 
273  float scale = 10.;
274 
275  Amg::Transform3D trans = muonStation->getNominalAmdbLRSToGlobal();
276 
277  Amg::Vector3D OrigOfMdtInAmdbFrame = muonStation->getBlineFixedPointInAmdbLRS();
278 
279  tmp_zMin = (trans*OrigOfMdtInAmdbFrame).z();
280  if(tmp_zMin < 0) sign = -1;
281  else if(tmp_zMin > 0) sign = 1;
282  tmp_zMax = tmp_zMin + sign*muonStation->Zsize();
283 
284  if(sta_zMin==0 || tmp_zMin<sta_zMin) sta_zMin = tmp_zMin;
285  if(sta_zMin==0 || tmp_zMax<sta_zMin) sta_zMin = tmp_zMax;
286  if(sta_zMax==0 || tmp_zMax>sta_zMax) sta_zMax = tmp_zMax;
287  if(sta_zMax==0 || tmp_zMin>sta_zMax) sta_zMax = tmp_zMin;
288 
289  if (chamber_this==barrel_inner){//barrel inner
290  tmp_rMin = (trans*OrigOfMdtInAmdbFrame).perp()/scale;
291  tmp_rMax = tmp_rMin+muonStation->Rsize()/scale;
292  if(rMin==0 || tmp_rMin < rMin)rMin = tmp_rMin;
293  if(rMax==0 || tmp_rMax > rMax)rMax = tmp_rMax;
294  }
295 
296  if (chamber_this==bee){//BEE
297  tmp_rMin = (trans*OrigOfMdtInAmdbFrame).perp()/scale;
298  tmp_rMax = tmp_rMin+muonStation->Rsize()/scale;
299  if(rMin==0 || tmp_rMin < rMin)rMin = tmp_rMin;
300  if(rMax==0 || tmp_rMax > rMax)rMax = tmp_rMax;
301  }
302 
303  }
304  }
305 
306  if (chamber==endcap_middle) { // endcap middle
307 
308  if (tgcFitResult.isSuccess) { // TGC data is properly read
309  if (tgcFitResult.tgcMid1[3] < tgcFitResult.tgcMid2[3]) {
310  zMin = tgcFitResult.tgcMid1[3];
311  zMax = tgcFitResult.tgcMid2[3];
312  } else {
313  zMin = tgcFitResult.tgcMid2[3];
314  zMax = tgcFitResult.tgcMid1[3];
315  }
316 
317  } else { // Failed to read TGC data
318 
319  zMin = sta_zMin;
320  zMax = sta_zMax;
321  }
322  }
323  else if (chamber==barrel_inner || chamber==bee) { //barrel inner || BEE
324  float max_road = 50 /*muonRoad.MaxWidth(chamber)*/;
325  find_barrel_road_dim(max_road,
326  muonRoad.aw[chamber][i_sector],
327  muonRoad.bw[chamber][i_sector],
328  rMin,rMax,
329  &zMin,&zMax);
330  }else {// endcap inner,outer,ee
331 
332  zMin = sta_zMin;
333  zMax = sta_zMax;
334  }
335 
336  if (chamber!=barrel_inner && chamber!=bee){//Endcap chamber
337  find_endcap_road_dim(muonRoad.rWidth[chamber][0],
338  muonRoad.aw[chamber][i_sector],
339  muonRoad.bw[chamber][i_sector],
340  zMin,zMax,
341  &rMin,&rMax);
342  }
343 
344  ATH_MSG_DEBUG("...zMin/zMax/ty1/ty2=" << zMin << "/" << zMax << "/" << types[0] << "/" << types[1]);
345  ATH_MSG_DEBUG("...rMin/rMax=" << rMin << "/" << rMax);
346 
347  find_eta_min_max(zMin, rMin, zMax, rMax, etaMin, etaMax);
348 
349  find_phi_min_max(muonRoad.phiRoI, phiMin, phiMax);
350 
351  ATH_MSG_DEBUG("...etaMin/etaMax/phiMin/phiMax=" << etaMin << "/" << etaMax << "/" << phiMin << "/" << phiMax);
352 
353  mdtRegion.zMin[chamber][i_sector] = zMin;
354  mdtRegion.zMax[chamber][i_sector] = zMax;
355  mdtRegion.rMin[chamber][i_sector] = rMin;
356  mdtRegion.rMax[chamber][i_sector] = rMax;
357  mdtRegion.etaMin[chamber][i_sector] = etaMin;
358  mdtRegion.etaMax[chamber][i_sector] = etaMax;
359  mdtRegion.phiMin[chamber][i_sector] = phiMin;
360  mdtRegion.phiMax[chamber][i_sector] = phiMax;
361  for(int i_type=0; i_type<2; i_type++) {
362  int type = types[i_type];
363  if( type == -1 ) continue;
364  mdtRegion.chamberType[chamber][i_sector][i_type] = type;
365  }
366  }
367  }
368 
369  StatusCode sc = computePhi(p_roids, tgcFitResult, mdtRegion, muonRoad);
370  if (sc.isFailure()) {
371  ATH_MSG_ERROR("Error in comupting phi");
372  return sc;
373  }
374 
375  return StatusCode::SUCCESS;
376 }
377 
378 // --------------------------------------------------------------------------------
379 // --------------------------------------------------------------------------------
380 
381 void TrigL2MuonSA::MdtRegionDefiner::find_station_sector(const std::string& name, int phi, bool& endcap,
382  int& chamber, int& sector)
383 {
384  if(name[0]=='E' || name[0]=='F' || (name[0]=='B' && name[1]=='E'))
385  endcap = true;
386  else
387  endcap = false;
388  int largeSmall=0;
389  if(name[2]=='S' || name[2]=='F' || name[2]=='G') largeSmall = 1;//Small
390  if (name[1]=='E' && name[2]=='E') largeSmall=1;//BEE
391  sector = (phi-1)*2 + largeSmall;
392  if (endcap){
393  if(name[1]=='I')
394  chamber = 3;
395  if(name[1]=='M')
396  chamber = 4;
397  if(name[1]=='O')
398  chamber = 5;
399  if(name[1]=='E')
400  chamber = 6;
401  if(name[1]=='E' && name[2]=='E')//BEE
402  chamber = 8;
403  }else {
404  if(name[1]=='I')
405  chamber = 0;
406  if(name[1]=='M')
407  chamber = 1;
408  if(name[1]=='O')
409  chamber = 2;
410  if(name[1]=='M' && name[2]=='E')//BME
411  chamber = 9;
412  if(name[1]=='M' && name[2]=='G')//BMG
413  chamber = 10;
414  if (name[0]=='E'&&name[1]=='I') //EI
415  chamber = 3;
416  }
417 }
418 
419 // --------------------------------------------------------------------------------
420 // --------------------------------------------------------------------------------
421 
422 void TrigL2MuonSA::MdtRegionDefiner::find_phi_min_max(float phiMiddle, float& phiMin, float& phiMax) const
423 {
424  phiMin = phiMiddle - 0.1;
425  phiMax = phiMiddle + 0.1;
426  if ( phiMin < -1.*M_PI ) phiMin += 2.*M_PI;
427  if ( phiMax > 1.*M_PI ) phiMax -= 2.*M_PI;
428 }
429 
430 // --------------------------------------------------------------------------------
431 // --------------------------------------------------------------------------------
432 
433 void TrigL2MuonSA::MdtRegionDefiner::find_eta_min_max(float zMin, float rMin, float zMax, float rMax,
434  float& etaMin, float& etaMax) const
435 {
436  // const bool doEmulateMuFast = true;
437  const bool doEmulateMuFast = false;
438 
439  etaMin = 0.;
440  etaMax = 0.;
441 
442  if(rMin > 0 && rMax > 0)
443  {
444  float eta[4];
445  float theta;
446 
447  theta = (std::abs(zMin)>0.1)? std::atan(rMin/std::abs(zMin)): M_PI/2.;
448  eta[0] = (zMin>0.)? -std::log(std::tan(theta/2.)) : std::log(std::tan(theta/2.));
449 
450  theta = (std::abs(zMax)>0.1)? std::atan(rMin/std::abs(zMax)): M_PI/2.;
451  eta[1] = (zMax>0.)? -std::log(std::tan(theta/2.)) : std::log(std::tan(theta/2.));
452  if(doEmulateMuFast) eta[1] = eta[0];
453 
454  theta = (std::abs(zMax)>0.1)? std::atan(rMax/std::abs(zMax)): M_PI/2.;
455  eta[2] = (zMax>0.)? -std::log(std::tan(theta/2.)) : std::log(std::tan(theta/2.));
456 
457  theta = (std::abs(zMin)>0.1)? std::atan(rMax/std::abs(zMin)): M_PI/2.;
458  eta[3] = (zMin>0.)? -std::log(std::tan(theta/2.)) : std::log(std::tan(theta/2.));
459  if(doEmulateMuFast) eta[3] = eta[2];
460 
461  etaMin = eta[0];
462  etaMax = eta[0];
463  for(int i=1; i<4; i++) {
464  if( eta[i] < etaMin ) etaMin = eta[i];
465  if( eta[i] > etaMax ) etaMax = eta[i];
466  }
467 
468  if (etaMin > etaMax) {
469  float tmp = etaMax;
470  etaMax = etaMin;
471  etaMin = tmp;
472  }
473  }
474 }
475 
476 // --------------------------------------------------------------------------------
477 // --------------------------------------------------------------------------------
478 
479 void TrigL2MuonSA::MdtRegionDefiner::find_barrel_road_dim(float max_road, float aw, float bw,
480  float rMin,float rMax,float *zMin,float *zMax) const
481 {
482  float ia,iaq,dz,z,points[4];
483  int i;
484 
485  *zMin = 9999.;
486  *zMax = -9999.;
487 
488  if(aw) {
489  ia = 1/aw;
490  iaq = ia*ia;
491  } else {
492  ia = 0;
493  iaq = 0;
494  }
495 
496  dz = max_road*std::sqrt(1.+iaq);
497  z = (ia)? (rMin-bw)*ia : bw;
498  points[0] = z - dz;
499  points[1] = z + dz;
500  z = (ia)? (rMax-bw)*ia : bw;
501  points[2] = z - dz;
502  points[3] = z + dz;
503 
504  for(i=0;i<4;i++) {
505  if(*zMin>=points[i]) *zMin = points[i];
506  if(*zMax<=points[i]) *zMax = points[i];
507  }
508 
509  return;
510 }
511 
512 // --------------------------------------------------------------------------------
513 // --------------------------------------------------------------------------------
514 
515 void TrigL2MuonSA::MdtRegionDefiner::find_endcap_road_dim(float road,float aw, float bw, float zMin,
516  float zMax,float *rMin,float *rMax) const
517 {
518  float r,points[4];
519  int i;
520 
521  *rMin = 999999.;
522  *rMax = 0.;
523 
524  if(zMin>=99999. && zMax<=-99999.)
525  {
526  *rMin = 0.;
527  *rMax = 0.;
528  return;
529  }
530 
531  r = zMin*aw + bw;
532  points[0] = r - road;
533  points[1] = r + road;
534  r = zMax*aw + bw;
535  points[2] = r - road;
536  points[3] = r + road;
537 
538  for(i=0;i<4;i++) {
539  if(*rMin>=points[i]) *rMin = points[i];
540  if(*rMax<=points[i]) *rMax = points[i];
541  }
542 
543  if(*rMin<0.) *rMin = 0.;
544  if(*rMax<0.) *rMax = 0.;
545 
546  return;
547 }
548 
549 // --------------------------------------------------------------------------------
550 // --------------------------------------------------------------------------------
551 
553 {
554  const double PHI_BOUNDARY = 0.2;
555 
556  // loop over TGC digits.
557  unsigned int iHit;
558  for (iHit = 0; iHit < tgcHits.size(); iHit++)
559  {
560  // Get the digit point.
561  const TrigL2MuonSA::TgcHitData& hit = tgcHits[iHit];
562 
563  // reject width=0 hits
564  const double ZERO_LIMIT = 1e-5;
565  if( std::abs(hit.width) < ZERO_LIMIT ) continue;
566 
567  double w = 12.0 / hit.width / hit.width;
568  if (hit.isStrip)
569  {
570  w *= hit.r * hit.r;
571  double phi = hit.phi;
572  if( phi < 0 && ( (M_PI+phi)<PHI_BOUNDARY) ) phi += M_PI*2;
573  if ( hit.sta < 3 ) { m_tgcStripMidPoints.push_back(TgcFit::Point(iHit + 1, hit.sta, hit.z, phi, w)); }
574  else if ( hit.sta ==3 ) { m_tgcStripInnPoints.push_back(TgcFit::Point(iHit + 1, hit.sta, hit.z, phi, w)); }
575  }
576  else
577  {
578  if ( hit.sta < 3 ) { m_tgcWireMidPoints.push_back(TgcFit::Point(iHit + 1, hit.sta, hit.z, hit.r, w)); }
579  else if ( hit.sta ==3 ) { m_tgcWireInnPoints.push_back(TgcFit::Point(iHit + 1, hit.sta, hit.z, hit.r, w)); }
580  }
581  }
582 
583  return StatusCode::SUCCESS;
584 
585 }
586 
587 // --------------------------------------------------------------------------------
588 // --------------------------------------------------------------------------------
589 
591  const TrigL2MuonSA::RpcFitResult& rpcFitResult,
592  const TrigL2MuonSA::MdtRegion& mdtRegion,
593  TrigL2MuonSA::MuonRoad& muonRoad) const
594 {
598 
599  for(int i_station=0; i_station<3; i_station++) {
600  int chamber = 0;
604  for( int i_sector=0; i_sector<2; i_sector++) {
605 
606  if ( rpcFitResult.isSuccess ) {
607 
608  if (chamber==barrel_middle || !rpcFitResult.isPhiDir) {
609  muonRoad.phi[chamber][i_sector] = rpcFitResult.phi;
610  continue;
611  }
612 
613  double dz = 0.;
614 
615  if (chamber==barrel_outer) {
616 
617  double MiddleR = std::abs(mdtRegion.rMin[barrel_middle][i_sector] + mdtRegion.rMax[barrel_middle][i_sector])/2.;
618  double MiddleZ = MiddleR*muonRoad.aw[barrel_middle][i_sector] + muonRoad.bw[barrel_middle][i_sector];
619 
620  double mm = (muonRoad.aw[barrel_outer][i_sector]!=0)? 1./muonRoad.aw[barrel_outer][i_sector] : 0.;
621  double OuterR = std::abs(mdtRegion.rMin[barrel_outer][i_sector]+mdtRegion.rMax[barrel_outer][i_sector])/2.;
622  double OuterZ = (mm)? (OuterR-muonRoad.bw[barrel_outer][i_sector])/mm : muonRoad.bw[barrel_outer][i_sector];
623  double DzOuter = std::abs(OuterZ-MiddleZ);
624  dz = std::sqrt((OuterR-MiddleR)*(OuterR-MiddleR) + DzOuter*DzOuter);
625  dz = (OuterR-MiddleR);
626 
627  } else if (chamber==barrel_inner) {
628 
629  double MiddleR = 0;
630  double MiddleZ = 0;
631 
632  double mm = (muonRoad.aw[barrel_inner][i_sector]!=0)? 1./muonRoad.aw[barrel_inner][i_sector] : 0.;
633  double InnerR = std::abs(mdtRegion.rMin[barrel_inner][i_sector]+mdtRegion.rMax[barrel_inner][i_sector])/2.;
634  double InnerZ = (mm)? (InnerR-muonRoad.bw[barrel_inner][i_sector])/mm : muonRoad.bw[barrel_inner][i_sector];
635  double DzInner = std::abs(InnerZ-MiddleZ);
636  dz = -std::sqrt((InnerR-MiddleR)*(InnerR-MiddleR) + DzInner*DzInner);
637  dz = - std::abs(InnerR-MiddleR);
638 
639  }
640 
641  muonRoad.phi[chamber][i_sector] = (dz)* rpcFitResult.dPhidZ + rpcFitResult.phi;
642 
643  while (muonRoad.phi[chamber][i_sector] > M_PI)
644  muonRoad.phi[chamber][i_sector] -= 2*M_PI;
645 
646  while (muonRoad.phi[chamber][i_sector] <-M_PI)
647  muonRoad.phi[chamber][i_sector] += 2*M_PI;
648 
649  } else {
650  // RPC data is not read -> use RoI
651  muonRoad.phi[chamber][i_sector] = p_roids->phi();
652  }
653  }
654  }
655  return StatusCode::SUCCESS;
656 }
657 
658 // --------------------------------------------------------------------------------
659 // --------------------------------------------------------------------------------
660 
662  const TrigL2MuonSA::TgcFitResult& tgcFitResult,
663  const TrigL2MuonSA::MdtRegion& mdtRegion,
664  TrigL2MuonSA::MuonRoad& muonRoad) const
665 {
670 
671  for(int i_station=0; i_station<5; i_station++) {
672  int chamber = 0;
678  for( int i_sector=0; i_sector<2; i_sector++) {
679 
680  if ( tgcFitResult.isSuccess ) {
681  if (chamber==endcap_middle || !tgcFitResult.isPhiDir) {
682  muonRoad.phi[chamber][i_sector] = tgcFitResult.phi;
683  continue;
684  }
685 
686  muonRoad.phi[chamber][i_sector] = 0.;
687  double dz = 0.;
688 
689  if (chamber==endcap_outer) {
690 
691  double MiddleZ = std::abs(mdtRegion.zMin[endcap_middle][i_sector] + mdtRegion.zMax[endcap_middle][i_sector])/2.;
692  double MiddleR = MiddleZ*muonRoad.aw[endcap_middle][i_sector] + muonRoad.bw[endcap_middle][i_sector];
693 
694  double OuterZ = std::abs(mdtRegion.zMin[endcap_outer][i_sector] + mdtRegion.zMax[endcap_outer][i_sector])/2.;
695  double OuterR = OuterZ*muonRoad.aw[endcap_outer][i_sector] + muonRoad.bw[endcap_outer][i_sector];
696  double DrOuter = std::abs(OuterR-MiddleR);
697  dz = std::sqrt((OuterZ-MiddleZ)*(OuterZ-MiddleZ) + DrOuter*DrOuter);
698  dz = (OuterZ-MiddleZ);
699 
700  } if (chamber==endcap_inner || chamber==barrel_inner) {
701 
702  double MiddleZ = 0;
703  double MiddleR = 0;
704 
705  if(tgcFitResult.tgcInn[2] != 0.) {
706  muonRoad.phi[chamber][i_sector] = tgcFitResult.tgcInn[1];
707  continue;
708  }
709  double InnerZ = std::abs(mdtRegion.zMin[endcap_inner][i_sector] + mdtRegion.zMax[endcap_inner][i_sector])/2.;
710  double InnerR = InnerZ*muonRoad.aw[endcap_inner][i_sector] + muonRoad.bw[endcap_inner][i_sector];
711  double DrInner = std::abs(InnerR-MiddleR);
712  dz = -std::sqrt((InnerZ-MiddleZ)*(InnerZ-MiddleZ) + DrInner*DrInner);
713  dz = -std::abs(InnerZ-MiddleZ);
714  }
715 
716  muonRoad.phi[chamber][i_sector] = (dz)* tgcFitResult.dPhidZ + tgcFitResult.phi;
717  while (muonRoad.phi[chamber][i_sector] > M_PI) muonRoad.phi[chamber][i_sector] -= 2*M_PI;
718  while (muonRoad.phi[chamber][i_sector] <-M_PI) muonRoad.phi[chamber][i_sector] += 2*M_PI;
719 
720  } else {
721  // TGC data is not read -> use RoI
722  muonRoad.phi[chamber][i_sector] = p_roids->phi();
723  }
724  }
725  }
726  return StatusCode::SUCCESS;
727 }
MdtRegionDefiner.h
TrigL2MuonSA::MuonRoad::MDT_sector_overlap
int MDT_sector_overlap
Definition: MuonRoad.h:87
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
beamspotman.r
def r
Definition: beamspotman.py:676
MdtReadoutElement.h
TrigL2MuonSA::MdtRegionDefiner::initialize
virtual StatusCode initialize() override
Definition: MdtRegionDefiner.cxx:27
TrigL2MuonSA::MdtRegionDefiner::getMdtRegions
StatusCode getMdtRegions(const TrigRoiDescriptor *p_roids, const TrigL2MuonSA::RpcFitResult &rpcFitResult, TrigL2MuonSA::MuonRoad &muonRoad, TrigL2MuonSA::MdtRegion &mdtRegion) const
Definition: MdtRegionDefiner.cxx:37
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
TrigL2MuonSA::TgcHitData::sta
int sta
Definition: TgcData.h:34
TrigL2MuonSA::TgcHitData::phi
double phi
Definition: TgcData.h:30
TrigL2MuonSA::RpcFitResult::phi
double phi
Definition: RpcFitResult.h:44
perp
Scalar perp() const
perp method - perpenticular length
Definition: AmgMatrixBasePlugin.h:44
TrigL2MuonSA::RpcFitResult
Definition: RpcFitResult.h:14
calibdata.chamber
chamber
Definition: calibdata.py:32
xAOD::L2MuonParameters::BEE
@ BEE
BEE measurement point.
Definition: TrigMuonDefs.h:24
xAOD::L2MuonParameters::EndcapExtra
@ EndcapExtra
Extra station in the endcap spectrometer.
Definition: TrigMuonDefs.h:22
TrigL2MuonSA::TgcFitResult
Definition: TgcFitResult.h:11
TrigL2MuonSA::MdtRegion::rMin
double rMin[11][2]
Definition: MdtRegion.h:38
TrigL2MuonSA::TgcHits
std::vector< TgcHitData > TgcHits
Definition: TgcData.h:43
TrigL2MuonSA::MdtRegion::zMin
double zMin[11][2]
Definition: MdtRegion.h:33
TrigL2MuonSA::MuonRoad::bw
double bw[N_STATION][N_SECTOR]
Definition: MuonRoad.h:82
xAOD::L2MuonParameters::BME
@ BME
BME measurement point.
Definition: TrigMuonDefs.h:25
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::L2MuonParameters::BarrelInner
@ BarrelInner
Inner station in the barrel spectrometer.
Definition: TrigMuonDefs.h:16
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
TrigL2MuonSA::MdtRegion::zMax
double zMax[11][2]
Definition: MdtRegion.h:37
TrigL2MuonSA::MdtRegion::Clear
void Clear()
Definition: MdtRegion.h:18
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
TrigL2MuonSA::MdtRegionDefiner::find_endcap_road_dim
void find_endcap_road_dim(float road, float aw, float bw, float zMin, float zMax, float *rMin, float *rMax) const
Definition: MdtRegionDefiner.cxx:515
TrigL2MuonSA::MuonRoad::MaxWidth
double MaxWidth(int i_station)
Definition: MuonRoad.h:58
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
TrigL2MuonSA::MdtRegion::chamberType
int chamberType[11][2][2]
Definition: MdtRegion.h:44
while
while((inf=(TStreamerInfo *) nextinfo()) !=0)
Definition: liststreamerinfos.cxx:13
TrigL2MuonSA::MuonRoad::aw
double aw[N_STATION][N_SECTOR]
Definition: MuonRoad.h:81
TrigL2MuonSA::MdtRegion
Definition: MdtRegion.h:14
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TrigL2MuonSA::TgcHitData::isStrip
bool isStrip
Definition: TgcData.h:35
TrigL2MuonSA::MuonRoad::phiRoI
double phiRoI
Definition: MuonRoad.h:80
TrigL2MuonSA::MuonRoad::stationList
std::vector< Identifier > stationList
Definition: MuonRoad.h:100
TrigL2MuonSA::MdtRegionDefiner::MdtRegionDefiner
MdtRegionDefiner(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MdtRegionDefiner.cxx:17
MuonGM::MuonStation::Zsize
double Zsize() const
Definition: MuonStation.h:175
TrigL2MuonSA::TgcFit::Point
Definition: TgcFit.h:35
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigL2MuonSA::TgcFitResult::tgcMid2
float tgcMid2[4]
Definition: TgcFitResult.h:46
MuonGM::MuonDetectorManager::getMdtReadoutElement
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:204
TrigL2MuonSA::TgcFitResult::isSuccess
bool isSuccess
Definition: TgcFitResult.h:39
MuonGM::MuonStation::Rsize
double Rsize() const
Definition: MuonStation.h:173
MuonGM::MdtReadoutElement
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.h:51
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigL2MuonSA::MuonRoad
Definition: MuonRoad.h:20
z
#define z
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
MuonGM::MuonReadoutElement::parentMuonStation
const MuonStation * parentMuonStation() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:135
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
TrigL2MuonSA::MuonRoad::MDT_sector_trigger
int MDT_sector_trigger
Definition: MuonRoad.h:86
MuonGM::MuonStation
Definition: MuonStation.h:51
test_pyathena.parent
parent
Definition: test_pyathena.py:15
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
MuonGM::MuonStation::getNominalAmdbLRSToGlobal
const Amg::Transform3D & getNominalAmdbLRSToGlobal() const
Definition: MuonStation.h:184
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigL2MuonSA::TgcFitResult::tgcMid1
float tgcMid1[4]
Definition: TgcFitResult.h:45
TrigL2MuonSA::RpcFitResult::isPhiDir
bool isPhiDir
Definition: RpcFitResult.h:43
TrigL2MuonSA::TgcHitData
Definition: TgcData.h:14
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
TrigL2MuonSA::TgcHitData::width
double width
Definition: TgcData.h:33
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
TrigL2MuonSA::TgcHitData::r
double r
Definition: TgcData.h:31
TrigL2MuonSA::MdtRegionDefiner::find_eta_min_max
void find_eta_min_max(float zMin, float rMin, float zMax, float rMax, float &etaMin, float &etaMax) const
Definition: MdtRegionDefiner.cxx:433
TrigL2MuonSA::MdtRegionDefiner::prepareTgcPoints
StatusCode prepareTgcPoints(const TrigL2MuonSA::TgcHits &tgcHits)
Definition: MdtRegionDefiner.cxx:552
MdtRegion.h
TrigL2MuonSA::MdtRegion::etaMin
double etaMin[11][2]
Definition: MdtRegion.h:40
ZERO_LIMIT
const float ZERO_LIMIT
Definition: VP1TriggerHandleL2.cxx:37
TrigL2MuonSA::MdtRegionDefiner::find_station_sector
static void find_station_sector(const std::string &name, int phi, bool &endcap, int &chamber, int &sector)
Definition: MdtRegionDefiner.cxx:381
TrigL2MuonSA::MuonRoad::phi
double phi[N_STATION][N_SECTOR]
Definition: MuonRoad.h:83
TrigL2MuonSA::TgcFitResult::dPhidZ
double dPhidZ
Definition: TgcFitResult.h:71
xAOD::L2MuonParameters::EndcapMiddle
@ EndcapMiddle
Middle station in the endcap spectrometer.
Definition: TrigMuonDefs.h:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigL2MuonSA::TgcFitResult::phi
double phi
Definition: TgcFitResult.h:70
TrigL2MuonSA::TgcFitResult::tgcInn
float tgcInn[4]
Definition: TgcFitResult.h:55
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonDetectorManager.h
TrigMuonDefs.h
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
TrigL2MuonSA::RpcFitResult::isSuccess
bool isSuccess
Definition: RpcFitResult.h:38
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
TrigL2MuonSA::MuonRoad::rWidth
double rWidth[N_STATION][N_LAYER]
Definition: MuonRoad.h:84
TrigL2MuonSA::TgcHitData::z
double z
Definition: TgcData.h:32
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
RoiDescriptor::phi
virtual double phi() const override final
Methods to retrieve data members.
Definition: RoiDescriptor.h:100
xAOD::L2MuonParameters::EndcapInner
@ EndcapInner
Inner station in the endcap spectrometer.
Definition: TrigMuonDefs.h:19
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::L2MuonParameters::BarrelOuter
@ BarrelOuter
Outer station in the barrel spectrometer.
Definition: TrigMuonDefs.h:18
TrigL2MuonSA::MdtRegion::phiMax
double phiMax[11][2]
Definition: MdtRegion.h:43
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TrigL2MuonSA::MuonRoad::extFtfMiddlePhi
double extFtfMiddlePhi
Definition: MuonRoad.h:91
TrigL2MuonSA::MdtRegionDefiner::find_barrel_road_dim
void find_barrel_road_dim(float max_road, float aw, float bw, float rMmin, float rMax, float *zMin, float *zMax) const
Definition: MdtRegionDefiner.cxx:479
TrigL2MuonSA::MdtRegionDefiner::computePhi
StatusCode computePhi(const TrigRoiDescriptor *p_roids, const TrigL2MuonSA::RpcFitResult &rpcFitResult, const TrigL2MuonSA::MdtRegion &mdtRegion, TrigL2MuonSA::MuonRoad &muonRoad) const
Definition: MdtRegionDefiner.cxx:590
TrigL2MuonSA::TgcFitResult::isPhiDir
bool isPhiDir
Definition: TgcFitResult.h:69
TrigL2MuonSA::MdtRegion::etaMax
double etaMax[11][2]
Definition: MdtRegion.h:41
AthAlgTool
Definition: AthAlgTool.h:26
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
MuonGM::MuonStation::getBlineFixedPointInAmdbLRS
const Amg::Vector3D & getBlineFixedPointInAmdbLRS() const
Definition: MuonStation.cxx:81
MuonStation.h
TrigL2MuonSA::MdtRegionDefiner::find_phi_min_max
void find_phi_min_max(float phiMiddle, float &phiMin, float &phiMax) const
Definition: MdtRegionDefiner.cxx:422
TrigL2MuonSA::RpcFitResult::dPhidZ
double dPhidZ
Definition: RpcFitResult.h:45
xAOD::L2MuonParameters::Backup
@ Backup
Backup.
Definition: TrigMuonDefs.h:26
xAOD::L2MuonParameters::BarrelMiddle
@ BarrelMiddle
Middle station in the barrel spectrometer.
Definition: TrigMuonDefs.h:17
xAOD::L2MuonParameters::EndcapOuter
@ EndcapOuter
Outer station in the endcap spectrometer.
Definition: TrigMuonDefs.h:21
jobOptions.points
points
Definition: jobOptions.GenevaPy8_Zmumu.py:97
TrigL2MuonSA::MdtRegion::rMax
double rMax[11][2]
Definition: MdtRegion.h:39
TrigL2MuonSA::MdtRegion::phiMin
double phiMin[11][2]
Definition: MdtRegion.h:42
Identifier
Definition: IdentifierFieldParser.cxx:14