ATLAS Offline Software
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 
15 namespace LVL1 {
16 
19 L1CPMTools::L1CPMTools(const std::string& t, const std::string& n, const IInterface* p)
20 : base_class(t,n,p) {}
21 
25 {
26  return StatusCode::SUCCESS;
27 }
28 
32 {
33  return StatusCode::SUCCESS;
34 }
35 
36 
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 
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 
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 
193 
196  mapTowers(cpmts, towers);
197 
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 
212 
214  rois->clear();
215 
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 
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 
277 
279  tobs->clear();
280 
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);
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 
348 CPMTobAlgorithm 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 
355 CPMTobAlgorithm 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 
363  // Find RoI coordinate
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
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
LVL1::CPMTobAlgorithm::EMIsolWord
int EMIsolWord()
Returns EM isolation word (5 bits)
Definition: CPMTobAlgorithm.cxx:395
LVL1::CPMTobAlgorithm::isTauRoI
bool isTauRoI()
Report whether this passed as a Tau TOB.
Definition: CPMTobAlgorithm.cxx:370
LVL1::L1CPMTools::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: L1CPMTools.cxx:24
et
Extra patterns decribing particle interation process.
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
LVL1::L1CPMTools::finalize
virtual StatusCode finalize() override
standard Athena-Algorithm method
Definition: L1CPMTools.cxx:31
L1CPMTools.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TriggerTowerKey.h
skel.it
it
Definition: skel.GENtoEVGEN.py:396
M_PI
#define M_PI
Definition: ActiveFraction.h:11
LVL1::CPMTobAlgorithm::EMClusET
int EMClusET()
Returns EM cluster ET, limited to 8 bits.
Definition: CPMTobAlgorithm.cxx:385
LVL1::CPMTobAlgorithm
This is an internal class, used in the EM/Tau trigger.
Definition: CPMTobAlgorithm.h:43
LVL1::CPMTobAlgorithm::TauClusET
int TauClusET()
Returns Tau cluster ET, limited to 8 bits.
Definition: CPMTobAlgorithm.cxx:390
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
python.LumiCalcHtml.lc
lc
Definition: LumiCalcHtml.py:579
LVL1::CPMTobAlgorithm::TauIsolWord
int TauIsolWord()
Returns Tau isolation word (5 bits)
Definition: CPMTobAlgorithm.cxx:400
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::L1CPMTools::findCPMResults
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...
Definition: L1CPMTools.cxx:39
PlotCalibFromCool.ie
ie
Definition: PlotCalibFromCool.py:420
xAOD::roiWord
roiWord
Definition: TrigMissingET_v1.cxx:36
python.PyAthena.module
module
Definition: PyAthena.py:131
LVL1::L1CPMTools::L1CPMTools
L1CPMTools(const std::string &, const std::string &, const IInterface *)
Constructor.
Definition: L1CPMTools.cxx:19
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
LVL1::CoordinateRange
CoordinateRange class declaration.
Definition: CoordinateRange.h:36
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
perfmonmt-refit.slice
slice
Definition: perfmonmt-refit.py:52
LVL1::L1CPMTools::formSums
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.
Definition: L1CPMTools.cxx:355
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::CPMTowerMap_t
std::map< int, const CPMTower * > CPMTowerMap_t
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CPMTower.h:18
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DataVector::clear
void clear()
Erase all the elements in the collection.
LVL1::TrigT1CaloDefs::tauTobType
@ tauTobType
Definition: TrigT1CaloDefs.h:163
LVL1::CPMTobRoI
CPM RoI data.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTobRoI.h:19
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
LVL1::L1CPMTools::mapTowers
virtual void mapTowers(const DataVector< xAOD::CPMTower > *cpmts, xAOD::CPMTowerMap_t *towers) const override
Tool-based EM/tau algorithm implementation.
Definition: L1CPMTools.cxx:312
TrigT1CaloDefs.h
LVL1::CPMTobAlgorithm::isEMRoI
bool isEMRoI()
Report whether this passed as an EM TOB.
Definition: CPMTobAlgorithm.cxx:362
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
Trk::iPhi
@ iPhi
Definition: ParamDefs.h:47
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
CoordinateRange.h
RunTileMonitoring.towers
towers
Definition: RunTileMonitoring.py:133
LVL1::CPRoIDecoder::coordinate
virtual CoordinateRange coordinate(const unsigned int roiWord) const override
RoI coordinate information.
Definition: CPRoIDecoder.cxx:50
TriggerTest.rois
rois
Definition: TriggerTest.py:23
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
LVL1::L1CPMTools::findRoIs
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.
Definition: L1CPMTools.cxx:276
LVL1::L1CPMTools::findCPMTobRoIs
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...
Definition: L1CPMTools.cxx:211
LVL1::TrigT1CaloDefs::emTobType
@ emTobType
Definition: TrigT1CaloDefs.h:162
LVL1::CPMTobAlgorithm::EMCPMTobRoI
xAOD::CPMTobRoI * EMCPMTobRoI()
Create CPMTobRoIs and return pointers to them.
Definition: CPMTobAlgorithm.cxx:475
LVL1::L1CPMTools::m_conv
CPRoIDecoder m_conv
Utility for decoding RoI words.
Definition: L1CPMTools.h:92
LVL1::L1CPMTools::findRoI
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.
Definition: L1CPMTools.cxx:348
LVL1::TriggerTowerKey::ttKey
virtual unsigned int ttKey(const TriggerTower &tower)
returns the key of the passed tower
Definition: TriggerTowerKey.cxx:143
xAOD::iEta
setScale setgFexType iEta
Definition: gFexJetRoI_v1.cxx:77
LVL1::TriggerTowerKey
The TriggerTowerKey object provides the key for each trigger tower depending on its eta-phi coords.
Definition: TriggerTowerKey.h:56
LVL1::CPMTobAlgorithm::TauCPMTobRoI
xAOD::CPMTobRoI * TauCPMTobRoI()
Returns CPMTobRoI for TAU hypothesis, provided TAU Tob conditions passed.
Definition: CPMTobAlgorithm.cxx:486
xAOD::CPMTobRoI
CPMTobRoI_v1 CPMTobRoI
Define the latest version of the CPMTobRoI class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CPMTobRoI.h:17
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
xAOD::CPMTobRoI_v1
Description of CPMTobRoI_v1.
Definition: CPMTobRoI_v1.h:24
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37