ATLAS Offline Software
Loading...
Searching...
No Matches
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
13namespace LVL1 {
14
15// Static constants
16
20
22
23const double CpmMappingTool::s_etaGran = 0.1;
24const 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
43bool 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
84bool 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
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
static const int s_etaBinsPerRow
static const int s_channels
virtual StatusCode finalize() override
virtual StatusCode initialize() override
static const int s_modules
static const double s_etaGran
static const int s_crates
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.
static const double s_phiGran
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
MsgStream & msg
Definition testRead.cxx:32