ATLAS Offline Software
eFEXTOBEtTool.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 //***************************************************************************
6 // eFEXTOBEtTool - description
7 // -------------------
8 // begin : 13 12 2022
9 // email : Alan.Watson@CERN.CH
10 // ***************************************************************************/
14 #include <vector>
15 
16 namespace LVL1 {
17 
18  // default constructor for persistency
19 
20 eFEXTOBEtTool::eFEXTOBEtTool(const std::string& type,const std::string& name,const IInterface* parent):
22 {
23  declareInterface<IeFEXTOBEtTool>(this);
24 }
25 
26 
29  {
30  }
31 
32 //---------------- Initialisation -------------------------------------------------
33 
35 {
36 
37  ATH_CHECK( m_eFEXegAlgoTool.retrieve() );
38  ATH_CHECK( m_eFEXtauAlgoTool.retrieve() );
39 
40  return StatusCode::SUCCESS;
41 }
42 
43 // The main user calls
44 StatusCode eFEXTOBEtTool::getegSums(float etaTOB, float phiTOB, int seed, int UnD,
45  std::vector<unsigned int> &ClusterCellETs,
46  std::vector<unsigned int> &RetaSums,
47  std::vector<unsigned int> &RhadSums,
48  std::vector<unsigned int> &WstotSums)
49 {
50 
52  int tobtable[3][3];
53 
54  for (int iphi = -1; iphi <= 1; ++iphi) {
55  float phiTable = phiTOB + iphi*m_dphiTower;
56  if (phiTable > M_PI) phiTable -= 2*M_PI;
57  if (phiTable < -M_PI) phiTable += 2*M_PI;
58 
59  for (int ieta = -1; ieta <= 1; ++ieta) {
60  float etaTable = etaTOB + ieta*m_detaTower;
61 
62  // Set the tower ID if within acceptance, else 0
63  if (std::abs(etaTable)<2.5) tobtable[iphi+1][ieta+1] = eTowerID(etaTable, phiTable);
64  else tobtable[iphi+1][ieta+1] = 0;
65 
66  } // eta loop
67  } // phi loop
68 
70  int eFEX, FPGA, fpgaEta;
71  location(etaTOB,phiTOB, eFEX, FPGA, fpgaEta);
72 
73  // Set up e/g algorithm for this location
74  ATH_CHECK( m_eFEXegAlgoTool->safetyTest() );
75  m_eFEXegAlgoTool->setup(tobtable, eFEX, FPGA, fpgaEta);
76 
77  // Get ETs of cells making up the ET clusters
78  m_eFEXegAlgoTool->getClusterCells(ClusterCellETs);
79 
80  // Get sums from algorithm
81  // This will override the seed calculated by the algorithm with the one supplied here
82  m_eFEXegAlgoTool->getSums(seed, UnD, RetaSums, RhadSums, WstotSums);
83 
84  // and we're done
85  return StatusCode::SUCCESS;
86 
87 }
88 
89 
90 StatusCode eFEXTOBEtTool::gettauSums(float etaTOB, float phiTOB, int seed, int UnD,
91  std::vector<unsigned int> &RcoreSums,
92  std::vector<unsigned int> &RemSums)
93 {
94 
96  int tobtable[3][3];
97 
98  for (int iphi = -1; iphi <= 1; ++iphi) {
99  float phiTable = phiTOB + iphi*m_dphiTower;
100  if (phiTable > M_PI) phiTable -= 2*M_PI;
101  if (phiTable < -M_PI) phiTable += 2*M_PI;
102 
103  for (int ieta = -1; ieta <= 1; ++ieta) {
104  float etaTable = etaTOB + ieta*m_detaTower;
105 
106  // Set the tower ID if within acceptance, else 0
107  if (std::abs(etaTable)<2.5) tobtable[iphi+1][ieta+1] = eTowerID(etaTable, phiTable);
108  else tobtable[iphi+1][ieta+1] = 0;
109 
110  } // eta loop
111  } // phi loop
112 
114  int eFEX, FPGA, fpgaEta;
115  location(etaTOB,phiTOB, eFEX, FPGA, fpgaEta);
116 
117  // Set up e/g algorithm for this location
118  ATH_CHECK( m_eFEXtauAlgoTool->safetyTest() );
119  m_eFEXtauAlgoTool->setup(tobtable, eFEX, FPGA, fpgaEta);
120 
121  // Get sums from algorithm
122  // This will override the seed calculated by the algorithm with the one supplied here
123  m_eFEXtauAlgoTool->getSums(seed, UnD, RcoreSums, RemSums);
124 
125  // and we're done
126  return StatusCode::SUCCESS;
127 
128 }
129 
130 
131 // Find eTower ID from a floating point coordinate pair
132 unsigned int eFEXTOBEtTool::eTowerID(float eta, float phi) const
133 {
134  // Calculate ID by hand from coordinate
135  int posneg = (eta >= 0 ? 1 : -1);
136  int towereta = std::abs(eta)/0.1;
137  if (phi < 0) phi += 2*M_PI;
138  int towerphi = int(32*phi/M_PI);
139  unsigned int tower_id = towerphi + 64*towereta;
140 
141  if (towereta < 14) {
142  tower_id += (posneg > 0 ? 200000 : 100000);
143  }
144  else if (towereta == 14) {
145  tower_id += (posneg > 0 ? 400000 : 300000);
146  }
147  else {
148  tower_id += (posneg > 0 ? 600000 : 500000);
149  }
150 
151  return tower_id;
152 }
153 
154 
155 // Find eFEX and FPGA numbers and eta index within FPGA
156 void eFEXTOBEtTool::location(float etaTOB, float phiTOB, int& eFEX, int& FPGA, int& etaIndex)
157 {
158  // indices of central tower within a 0->49, 0->63 eta,phi map
159  int ieta = (etaTOB + 2.5)/m_detaTower;
160  float phiShifted = phiTOB + 2*m_dphiTower; // eFEX boundary does not line up with phi = 0
161  int iphi = (phiShifted > 0 ? phiShifted/m_dphiTower : (phiShifted + 2*M_PI)/m_dphiTower );
162 
163  // Now we have global 0->N indices we can simply calculate which eFEX these come from
164  int eFEXPhi = iphi/8;
165  int eFEXeta = 0;
166  if (ieta > 16) eFEXeta = 1;
167  if (ieta > 32) eFEXeta = 2;
168 
169  // eFEX number in range 0 -> 23
170  eFEX = eFEXeta + 3*eFEXPhi;
171 
172  // Now which FPGA within the eFEX?
173  // This logic will give an index: 0 -> 16 for eFEX 0
174  // 1 -> 16 for eFEX 1
175  // 1 -> 17 for eFEX 2
176  // which puts FPGA boundaries at 4, 8, 12 in all cases
177  int eFEXIndex;
178  switch(eFEXeta) {
179  case 0: {
180  eFEXIndex = ieta;
181  break;
182  }
183  case 1: {
184  eFEXIndex = ieta -16;
185  break;
186  }
187  case 2: {
188  eFEXIndex = ieta -32;
189  break;
190  }
191  }
192 
193  // Finally we can calculate the FPGA number
194  if (eFEXIndex <= 4) FPGA = 0;
195  else if (eFEXIndex <= 8) FPGA = 1;
196  else if (eFEXIndex <= 12) FPGA = 2;
197  else FPGA = 3;
198 
199  // And eta index within the FPGA = 1-4 in most cases
200  // except for eFEX 0 FPGA 0 => 0-4 and eFEX 2 FPGA 3 => 1-5
201  etaIndex = eFEXIndex - 4*FPGA;
202 
203  // And return the results by reference
204  return;
205 }
206 
207 } // end of namespace bracket
eFEXTOBEtTool.h
LVL1::eFEXTOBEtTool::m_eFEXtauAlgoTool
ToolHandle< IeFEXtauAlgo > m_eFEXtauAlgoTool
Definition: eFEXTOBEtTool.h:76
LVL1::eFEXTOBEtTool::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: eFEXTOBEtTool.cxx:34
LVL1::eFEXTOBEtTool::eTowerID
virtual unsigned int eTowerID(float eta, float phi) const override
Tool to find eTower identifier from an eta, phi coordinate pair.
Definition: eFEXTOBEtTool.cxx:132
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
M_PI
#define M_PI
Definition: ActiveFraction.h:11
LVL1::eFEXTOBEtTool::m_eFEXegAlgoTool
ToolHandle< IeFEXegAlgo > m_eFEXegAlgoTool
Definition: eFEXTOBEtTool.h:79
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::eFEXTOBEtTool::eFEXTOBEtTool
eFEXTOBEtTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
Definition: eFEXTOBEtTool.cxx:20
LVL1::eFEXTOBEtTool::m_dphiTower
const float m_dphiTower
Internal data.
Definition: eFEXTOBEtTool.h:73
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
eFEXegAlgo.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LVL1::eFEXTOBEtTool::gettauSums
virtual StatusCode gettauSums(float etaTOB, float phiTOB, int seed, int UnD, std::vector< unsigned int > &RcoreSums, std::vector< unsigned int > &RemSums) override
Tool to calculate eTaudiscriminant sums.
Definition: eFEXTOBEtTool.cxx:90
LVL1::eFEXTOBEtTool::location
virtual void location(float etaTOB, float phiTOB, int &eFEX, int &FPGA, int &fpgaEta) override
Tool to find eFEX and FPGA numbers and eta index of a TOB within the FPGA.
Definition: eFEXTOBEtTool.cxx:156
LVL1::eFEXTOBEtTool::getegSums
virtual StatusCode getegSums(float etaTOB, float phiTOB, int seed, int UnD, std::vector< unsigned int > &ClusterCellETs, std::vector< unsigned int > &RetaSums, std::vector< unsigned int > &RhadSums, std::vector< unsigned int > &WstotSums) override
Tool to calculate eEM discriminant sums.
Definition: eFEXTOBEtTool.cxx:44
LVL1::eFEXTOBEtTool::~eFEXTOBEtTool
virtual ~eFEXTOBEtTool()
Destructor.
Definition: eFEXTOBEtTool.cxx:28
TrigConf::name
Definition: HLTChainList.h:35
LVL1::eFEXTOBEtTool::m_detaTower
const float m_detaTower
Definition: eFEXTOBEtTool.h:74
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
FEXReprocessingRun3.eFEX
eFEX
Definition: FEXReprocessingRun3.py:114
LVL1::gFEX::FPGA
FPGA
Definition: GTowerHelpers.h:17
AthAlgTool
Definition: AthAlgTool.h:26
eFEXtauAlgo.h