ATLAS Offline Software
Loading...
Searching...
No Matches
L1CPMTools.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
5// L1CPMTools.cxx,
7
8#include "L1CPMTools.h"
12
13#include <math.h>
14
15namespace LVL1 {
16
18
19L1CPMTools::L1CPMTools(const std::string& t, const std::string& n, const IInterface* p)
20: base_class(t,n,p) {}
21
23
25{
26 return StatusCode::SUCCESS;
27}
28
30
32{
33 return StatusCode::SUCCESS;
34}
35
36
38
39void L1CPMTools::findCPMResults(const TrigConf::L1Menu* l1menu, const xAOD::CPMTowerMap_t* towers, int crate, int module,
40 DataVector<CPMTobRoI>* rois, std::vector<unsigned int>& emCMXData,
41 std::vector<unsigned int>& tauCMXData, int slice) const {
42
45 emCMXData.clear();
46 emCMXData.resize(4);
47 tauCMXData.clear();
48 tauCMXData.resize(4);
49
51 int nEmTobs = 0;
52 int nTauTobs = 0;
53
55
56 int iPhiMin = crate*16;
57 int iEtaMin = (module-1)*4 - 28;
58
61 for (int iChip = 0; iChip < 8; ++iChip) {
62 for (int iSide = 0; iSide < 2; ++iSide) {
63 for (int iPhi = 0; iPhi < 2; ++iPhi) {
64 int ip = iPhiMin + 2*iChip + iPhi;
65 for (int iEta = 0; iEta < 2; ++iEta) {
66 int ie = iEtaMin + 2*iSide + iEta;
67
68 float eta = ie*0.1 + 0.05;
69 float phi = ip*M_PI/32 + M_PI/64;
70
73
75 CPMTobAlgorithm tob(eta, phi, towers, l1menu, slice); // quicker to do both in one go, though maybe not cleaner
76
81 if (tob.isEMRoI()) {
82 int et = tob.EMClusET();
83 int isol = tob.EMIsolWord();
84 int location = (iSide << 2) + (iPhi << 1) + iEta;
85
86 CPMTobRoI* emRoI = new CPMTobRoI(crate, module, iChip, location, TrigT1CaloDefs::emTobType, et, isol);
87 rois->push_back(emRoI);
88
89 unsigned int offset = iChip*2 + iSide;
90 emCMXData[0] |= (1 << offset);
91
92 unsigned int lc = (iPhi << 1) + iEta;
93 switch (nEmTobs) {
94 case 0:
95 emCMXData[1] += et;
96 emCMXData[0] += (isol<<18);
97 emCMXData[0] += (lc<<16);
98 break;
99 case 1:
100 emCMXData[1] += (et<<8);
101 emCMXData[1] += (isol<<18);
102 emCMXData[1] += (lc<<16);
103 break;
104 case 2:
105 emCMXData[2] += et;
106 emCMXData[2] += (isol<<18);
107 emCMXData[2] += (lc<<16);
108 break;
109 case 3:
110 emCMXData[2] += (et<<8);
111 emCMXData[3] += (isol<<10);
112 emCMXData[3] += (lc<<8);
113 break;
114 case 4:
115 emCMXData[3] += et;
116 emCMXData[3] += (isol<<18);
117 emCMXData[3] += (lc<<16);
118 break;
119 }
120 nEmTobs++;
121
122 } // Found EM TOB
123
125 if (tob.isTauRoI()) {
126 int et = tob.TauClusET();
127 int isol = tob.TauIsolWord();
128 int location = (iSide << 2) + (iPhi << 1) + iEta;
129
130 CPMTobRoI* tauRoI = new CPMTobRoI(crate, module, iChip, location, TrigT1CaloDefs::tauTobType, et, isol);
131 rois->push_back(tauRoI);
132
133 unsigned int offset = iChip*2 + iSide;
134 tauCMXData[0] |= (1 << offset);
135
136 unsigned int lc = (iPhi << 1) + iEta;
137 switch (nTauTobs) {
138 case 0:
139 tauCMXData[1] += et;
140 tauCMXData[0] += (isol<<18);
141 tauCMXData[0] += (lc<<16);
142 break;
143 case 1:
144 tauCMXData[1] += (et<<8);
145 tauCMXData[1] += (isol<<18);
146 tauCMXData[1] += (lc<<16);
147 break;
148 case 2:
149 tauCMXData[2] += et;
150 tauCMXData[2] += (isol<<18);
151 tauCMXData[2] += (lc<<16);
152 break;
153 case 3:
154 tauCMXData[2] += (et<<8);
155 tauCMXData[3] += (isol<<10);
156 tauCMXData[3] += (lc<<8);
157 break;
158 case 4:
159 tauCMXData[3] += et;
160 tauCMXData[3] += (isol<<18);
161 tauCMXData[3] += (lc<<16);
162 break;
163 }
164 nTauTobs++;
165
166 } // Found Tau TOB
167
168 } // eta within chip/side
169 } // phi within chip/side
170 } // side (L/R) of chip
171 } // chip (0-7) within module
172
173 // Finally set parity bits for data words
174 for (unsigned int word = 0; word < 4; ++word) {
175 unsigned int parity = 1;
176 for (unsigned int bit = 0; bit < 24; ++bit) if ( ( (emCMXData[word]>>bit) & 1) > 0 ) parity++;
177 parity &= 1;
178 emCMXData[word] |= (parity<<23);
179
180 parity = 1;
181 for (unsigned int bit = 0; bit < 24; ++bit) if ( ( (tauCMXData[word]>>bit) & 1) > 0 ) parity++;
182 parity &= 1;
183 tauCMXData[word] |= (parity<<23);
184 }
185
186
187}
188
189
191
193
196 mapTowers(cpmts, towers);
197
199 findCPMTobRoIs(l1menu, towers, rois, slice);
200
202 for (xAOD::CPMTowerMap_t::iterator it = towers->begin(); it != towers->end(); ++it) {
203 delete (*it).second;
204 }
205 delete towers;
206
207}
208
210
211void L1CPMTools::findCPMTobRoIs(const TrigConf::L1Menu* l1menu, const xAOD::CPMTowerMap_t* towers, xAOD::CPMTobRoIContainer* rois, int slice) const {
212
214 rois->clear();
215
220
221 TriggerTowerKey testKey(0.0, 0.0);
222 std::map<int, int> analysed;
223 xAOD::CPMTowerMap_t::const_iterator cpmt = towers->begin();
224 for ( ; cpmt != towers->end(); ++cpmt) {
225 double eta = (*cpmt).second->eta();
226 double phi = (*cpmt).second->phi();
227 for (int i = -1; i <= 0; ++i) {
228 for (int j = -1; j <= 0; ++j) {
229 double tempEta = eta + i*0.1;
230 double tempPhi = phi + j*0.1;
231 int key = testKey.ttKey(tempPhi,tempEta);
232 std::map<int, int>::iterator test = analysed.find(key);
233 if (test == analysed.end()) {
234 analysed.insert(std::map<int, int>::value_type(key,1));
235
236 CPMTobAlgorithm tob(tempEta, tempPhi, towers, l1menu, slice);
237
238 // Did this pass as an EM TOB?
239 if (tob.isEMRoI()) {
240 xAOD::CPMTobRoI* emRoI = tob.EMCPMTobRoI();
241 if (emRoI != 0) rois->push_back(emRoI);
242 }
243
244 // Did this pass as a Tau TOB?
245 if (tob.isTauRoI()) {
246 xAOD::CPMTobRoI* tauRoI = tob.TauCPMTobRoI();
247 if (tauRoI != 0) rois->push_back(tauRoI);
248 }
249
250 } // Not analysed this one already
251 } // phi neighbours
252 } // eta neighbours
253 } // iterate over CPM Towers
254
255}
256
258void L1CPMTools::findRoIs(const TrigConf::L1Menu* l1menu, const DataVector<xAOD::CPMTower>* cpmts, DataVector<CPMTobAlgorithm>* tobs, int slice) const {
259
262 mapTowers(cpmts, towers);
263
265 findRoIs(l1menu, towers, tobs, slice);
266
268 for (xAOD::CPMTowerMap_t::iterator it = towers->begin(); it != towers->end(); ++it) {
269 delete (*it).second;
270 }
271 delete towers;
272}
273
274
276void L1CPMTools::findRoIs(const TrigConf::L1Menu* l1menu, const xAOD::CPMTowerMap_t* towers, DataVector<CPMTobAlgorithm>* tobs, int slice) const {
277
279 tobs->clear();
280
285
286 TriggerTowerKey testKey(0.0, 0.0);
287 std::map<int, int> analysed;
288 xAOD::CPMTowerMap_t::const_iterator cpmt = towers->begin();
289 for ( ; cpmt != towers->end(); ++cpmt) {
290 double eta = (*cpmt).second->eta();
291 double phi = (*cpmt).second->phi();
292 for (int i = -1; i <= 0; ++i) {
293 for (int j = -1; j <= 0; ++j) {
294 double tempEta = eta + i*0.1;
295 double tempPhi = phi + j*0.1;
296 int key = testKey.ttKey(tempPhi,tempEta);
297 std::map<int, int>::iterator test = analysed.find(key);
298 if (test == analysed.end()) {
299 analysed.insert(std::map<int, int>::value_type(key,1));
300
301 CPMTobAlgorithm* tob = new CPMTobAlgorithm(tempEta, tempPhi, towers, l1menu, slice);
302 if ( (tob->isEMRoI() || tob->isTauRoI()) ) tobs->push_back(tob);
303 else delete tob;
304 } // not done this one already
305 } // phi neighbours
306 } // eta neighbours
307 } // iterate over CPM Towers
308
309}
310
313
314 // Clear map before filling
315 towers->clear();
316
317 // Step over all CPMTowers and put into map
319 TriggerTowerKey testKey(0.0, 0.0);
320
321 for( it = cpmts->begin(); it != cpmts->end(); ++it ){
322 double TriggerTowerEta=(*it)->eta();
323 if (fabs(TriggerTowerEta) < 2.5) { // limit of em/tau coverage
324 double TriggerTowerPhi=(*it)->phi();
325 int key = testKey.ttKey(TriggerTowerPhi,TriggerTowerEta);
326 xAOD::CPMTowerMap_t::iterator test=towers->find( key );
327 if (test != towers->end()){
328 ATH_MSG_ERROR( "ERROR: tower already in map!" );
329 }
330 else {
331 std::vector<uint8_t> emEt = (*it)->emEnergyVec();
332 std::vector<uint8_t> hadEt = (*it)->hadEnergyVec();
333 bool nonZero = false;
334 for (std::vector<uint8_t>::iterator it2 = emEt.begin(); it2 != emEt.end(); ++it2)
335 if ((*it2) > 0) nonZero = true;
336 for (std::vector<uint8_t>::iterator it2 = hadEt.begin(); it2 != hadEt.end(); ++it2)
337 if ((*it2) > 0) nonZero = true;
338 if (nonZero) towers->insert(xAOD::CPMTowerMap_t::value_type(key,(*it)));
339 }
340 }
341 }//endfor
342
343 return;
344}
345
347
348CPMTobAlgorithm L1CPMTools::findRoI(const TrigConf::L1Menu* l1menu, double RoIeta, double RoIphi, const xAOD::CPMTowerMap_t* towers, int slice) const {
349 // Performs all processing for this location
350 return CPMTobAlgorithm(RoIeta, RoIphi, towers, l1menu, slice);
351}
352
354
355CPMTobAlgorithm L1CPMTools::formSums(const TrigConf::L1Menu* l1menu, double RoIeta, double RoIphi, const xAOD::CPMTowerMap_t* towers, int slice) const {
356 // Performs all processing for this location
357 return CPMTobAlgorithm(RoIeta, RoIphi, towers, l1menu, slice);
358}
359
361
362CPMTobAlgorithm L1CPMTools::formSums(const TrigConf::L1Menu* l1menu, uint32_t roiWord, const xAOD::CPMTowerMap_t* towers, int slice) const {
363 // Find RoI coordinate
364 CoordinateRange coord = m_conv.coordinate(roiWord);
365 float RoIphi = coord.phi();
366 float RoIeta = coord.eta();
367
368 // Performs all processing for this location
369 return CPMTobAlgorithm(RoIeta, RoIphi, towers, l1menu, slice);
370}
371
372} // end of namespace
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x)
double coord
Type of coordination system.
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
void clear()
Erase all the elements in the collection.
This is an internal class, used in the EM/Tau trigger.
int EMIsolWord()
Returns EM isolation word (5 bits)
int TauIsolWord()
Returns Tau isolation word (5 bits)
int EMClusET()
Returns EM cluster ET, limited to 8 bits.
bool isTauRoI()
Report whether this passed as a Tau TOB.
xAOD::CPMTobRoI * EMCPMTobRoI()
Create CPMTobRoIs and return pointers to them.
int TauClusET()
Returns Tau cluster ET, limited to 8 bits.
xAOD::CPMTobRoI * TauCPMTobRoI()
Returns CPMTobRoI for TAU hypothesis, provided TAU Tob conditions passed.
bool isEMRoI()
Report whether this passed as an EM TOB.
CoordinateRange class declaration.
virtual CPMTobAlgorithm formSums(const TrigConf::L1Menu *l1menu, double RoIeta, double RoIphi, const xAOD::CPMTowerMap_t *towers, int slice=-1) const override
Form cluster/isolation sums for a given RoI location.
virtual void mapTowers(const DataVector< xAOD::CPMTower > *cpmts, xAOD::CPMTowerMap_t *towers) const override
Tool-based EM/tau algorithm implementation.
virtual void findCPMTobRoIs(const TrigConf::L1Menu *l1menu, const xAOD::CPMTowerMap_t *towers, xAOD::CPMTobRoIContainer *rois, int slice=-1) const override
Form CPM results for specified crate/module using user-supplied map of input towers This version fill...
virtual StatusCode initialize() override
standard Athena-Algorithm method
CPRoIDecoder m_conv
Utility for decoding RoI words.
Definition L1CPMTools.h:92
L1CPMTools(const std::string &, const std::string &, const IInterface *)
Constructor.
virtual void findRoIs(const TrigConf::L1Menu *l1menu, const xAOD::CPMTowerMap_t *towers, DataVector< CPMTobAlgorithm > *tobs, int slice=-1) const override
Find RoIs in user-supplied map of input towers.
virtual void findCPMResults(const TrigConf::L1Menu *l1menu, const xAOD::CPMTowerMap_t *towers, int crate, int module, DataVector< CPMTobRoI > *rois, std::vector< unsigned int > &emCMXData, std::vector< unsigned int > &tauCMXData, int slice=-1) const override
Form CPM results for specified crate/module using user-supplied map of input towers This version adds...
virtual CPMTobAlgorithm findRoI(const TrigConf::L1Menu *l1menu, double RoIeta, double RoIphi, const xAOD::CPMTowerMap_t *towers, int slice=-1) const override
Return RoI object for a specified location.
virtual StatusCode finalize() override
standard Athena-Algorithm method
The TriggerTowerKey object provides the key for each trigger tower depending on its eta-phi coords.
virtual unsigned int ttKey(const TriggerTower &tower)
returns the key of the passed tower
L1 menu configuration.
Definition L1Menu.h:28
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
CPMTobRoI_v1 CPMTobRoI
Define the latest version of the CPMTobRoI class.
std::map< int, const CPMTower * > CPMTowerMap_t
CPMTobRoIContainer_v1 CPMTobRoIContainer
Define the latest version of the CPMTobRoI class.
Extra patterns decribing particle interation process.