ATLAS Offline Software
CpmMappingTool.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 #include <cmath>
6 
7 #include "GaudiKernel/IInterface.h"
8 #include "GaudiKernel/MsgStream.h"
9 #include "GaudiKernel/StatusCode.h"
10 
11 #include "CpmMappingTool.h"
12 
13 namespace LVL1 {
14 
15 // Static constants
16 
17 const int CpmMappingTool::s_crates;
20 
22 
23 const double CpmMappingTool::s_etaGran = 0.1;
24 const double CpmMappingTool::s_phiGran = M_PI/32.;
25 
26 // Initialise the mappings
27 
29 {
30  msg(MSG::INFO) << "Initializing " << name() << endmsg;
31 
32  return StatusCode::SUCCESS;
33 }
34 
36 {
37 
38  return StatusCode::SUCCESS;
39 }
40 
41 // Return eta, phi and layer mapping for given crate/module/channel
42 
43 bool CpmMappingTool::mapping(const int crate, const int module,
44  const int channel, double& eta, double& phi, int& layer) const
45 {
46  if (crate < 0 || crate >= s_crates || module < 1 || module > s_modules ||
47  channel < 0 || channel >= s_channels) return false;
48 
49  // Channels numbered thus:
50  //
51  // : : : : :
52  // | 9 | 11 | 13 | 15 |
53  // | 8 | 10 | 12 | 14 | phi
54  // | 1 | 3 | 5 | 7 |
55  // | 0 | 2 | 4 | 6 |
56  // +----+----+----+----+
57  // eta
58 
59  const int etaBin = (channel / 2) % s_etaBinsPerRow;
60  const int phiBin = ((channel / 2) / s_etaBinsPerRow) * 2
61  + channel % 2 - 2; // allow for overlap
62 
63  // End modules only have one column
64  if ((module == 1 && etaBin != s_etaBinsPerRow - 1) ||
65  (module == s_modules && etaBin != 0)) return false;
66 
67  const double twoPi = 2.*M_PI;
68  const double phiBase = M_PI/2. * double(crate);
69  phi = phiBase + s_phiGran * (double(phiBin) + 0.5);
70  if (phi < 0.) phi += twoPi;
71  else if (phi >= twoPi) phi -= twoPi;
72 
73  const double etaBase = s_etaGran * s_etaBinsPerRow *
74  (module - 1 - s_modules/2);
75  eta = etaBase + s_etaGran * (double(etaBin) + 0.5);
76 
77  // Set layer to 1 for overlap channel, 0 for core
78  layer = (phiBin < 0 || phiBin > 15) ? 1 : 0;
79  return true;
80 }
81 
82 // Return crate, module and channel mapping for given eta/phi/layer
83 
84 bool CpmMappingTool::mapping(const double /*eta*/, const double /*phi*/,
85  const int /*layer*/, int& crate, int& module, int& channel) const
86 {
87  // Not implemented
88  crate = 0;
89  module = 0;
90  channel = 0;
91  return false;
92 }
93 
94 } // end namespace
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
LVL1::CpmMappingTool::s_etaBinsPerRow
static const int s_etaBinsPerRow
Definition: CpmMappingTool.h:54
M_PI
#define M_PI
Definition: ActiveFraction.h:11
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::CpmMappingTool::s_etaGran
static const double s_etaGran
Definition: CpmMappingTool.h:57
LVL1::CpmMappingTool::initialize
virtual StatusCode initialize() override
Definition: CpmMappingTool.cxx:28
python.PyAthena.module
module
Definition: PyAthena.py:131
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
LVL1::CpmMappingTool::mapping
virtual bool mapping(int crate, int module, int channel, double &eta, double &phi, int &layer) const override
Return eta, phi and layer mapping for given crate/module/channel.
Definition: CpmMappingTool.cxx:43
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
LVL1::CpmMappingTool::s_modules
static const int s_modules
Definition: CpmMappingTool.h:51
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
LVL1::CpmMappingTool::s_crates
static const int s_crates
Definition: CpmMappingTool.h:50
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
Definition: L2StandAloneMuon_v2.cxx:144
LVL1::CpmMappingTool::finalize
virtual StatusCode finalize() override
Definition: CpmMappingTool.cxx:35
LVL1::CpmMappingTool::s_channels
static const int s_channels
Definition: CpmMappingTool.h:52
CpmMappingTool.h
LVL1::CpmMappingTool::s_phiGran
static const double s_phiGran
Definition: CpmMappingTool.h:56
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7