ATLAS Offline Software
L1CPMTowerTools.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
5 // L1CPMTowerTools.cxx,
7 
8 #include "L1CPMTowerTools.h"
12 #include <vector>
13 
14 namespace LVL1 {
15 
16 typedef std::vector<TriggerTowerMap_t::mapped_type> TriggerTowerVector_t;
17 typedef std::vector<xAOD::TriggerTowerMap_t::mapped_type> xAODTriggerTowerVector_t;
18 
22  const std::string& n,
23  const IInterface* p )
24  :
25  AthAlgTool(t,n,p)
26 {
27  declareInterface<IL1CPMTowerTools>(this);
28 
29 }
30 
34 {
35 }
36 
37 
41 {
42  return StatusCode::SUCCESS;
43 }
44 
48 {
49  return StatusCode::SUCCESS;
50 }
51 
53 void L1CPMTowerTools::makeCPMTowers(const DataVector<TriggerTower>* triggerTowers, DataVector<CPMTower>* cpmTowers, bool zeroSuppress){
54 
55  // Clear collection before filling
56  cpmTowers->clear();
57 
64  std::map< int, TriggerTowerVector_t > Sums;
65 
66  // Step over all TriggerTowers, and put into map
68  TriggerTowerKey testKey(0.0, 0.0);
69 
70  for( it = triggerTowers->begin(); it != triggerTowers->end(); ++it ) {
71  // Check within CPM tower coverage
72  if (fabs((*it)->eta()) > 2.5) continue;
73 
74  // Find TriggerTowerKey for this TriggerTower
75  int key = testKey.ttKey((*it)->phi(),(*it)->eta());
76  // Does the map already contain an entry for this CPMTower?
78  if (mapIt != Sums.end()) {
79  // Add pointer to this tower to the list
80  (mapIt->second).push_back((*it));
81  }
82  else {
83  // New entry in map.
85  vec.push_back((*it));
86  Sums.insert(std::map< int, TriggerTowerVector_t >::value_type(key,vec));
87  }
88  } // end of loop over towers
89 
98  for (std::map< int, TriggerTowerVector_t >::iterator mapIt = Sums.begin();
99  mapIt != Sums.end(); ++mapIt) {
100 
101  // Get first TT for this CPMT
102  TriggerTowerVector_t::iterator it = (mapIt->second).begin();
103  if (it != (mapIt->second).end()) {
104  // Get CPMT eta, phi using first tower in vector (either tower in CPMT should do)
105  double phi = (*it)->phi();
106  double eta = (*it)->eta();
107  // create empty result vectors
108  std::vector<int> emET;
109  std::vector<int> hadET;
110  std::vector<int> emError;
111  std::vector<int> hadError;
112  // Both should contain same number of samples, and same peak position
113  int Peak = 0;
114  // now loop through all TT present and add their ET values to CPMT
115  for (; it != (mapIt->second).end(); ++it) {
116  // Right now there should only be one TT. Add logic for dual layers later.
117  Peak = (*it)->emPeak();
118  emET = (*it)->emLUT();
119  hadET = (*it)->hadLUT();
120  emError.assign(emET.size(),(*it)->emError());
121  hadError.assign(hadET.size(),(*it)->hadError());
122  }
123 
128  if (!zeroSuppress || emET[Peak] > 0 || hadET[Peak] > 0) {
129  CPMTower* cpmTower = new CPMTower(phi, eta, emET, emError, hadET, hadError, Peak);
130  cpmTowers->push_back(cpmTower);
131  }
132  } // end of check that first element of vector present
133 
134  } // end of loop through Sums map
135 
136  return;
137 }
138 
139 
141 void L1CPMTowerTools::makeCPMTowers(const DataVector<xAOD::TriggerTower>* triggerTowers, DataVector<CPMTower>* cpmTowers, bool zeroSuppress){
142 
143  // Clear collection before filling
144  cpmTowers->clear();
145 
152  std::map< int, xAODTriggerTowerVector_t > Sums;
153 
154  // Step over all TriggerTowers, and put into map
156  TriggerTowerKey testKey(0.0, 0.0);
157 
158  for( it = triggerTowers->begin(); it != triggerTowers->end(); ++it ) {
159  // Check within CPM tower coverage
160  if (fabs((*it)->eta()) > 2.5) continue;
161 
162  // Find TriggerTowerKey for this TriggerTower
163  int key = testKey.ttKey((*it)->phi(),(*it)->eta());
164  // Does the map already contain an entry for this CPMTower?
166  if (mapIt != Sums.end()) {
167  // Add pointer to this tower to the list
168  (mapIt->second).push_back((*it));
169  }
170  else {
171  // New entry in map.
173  vec.push_back((*it));
174  Sums.insert(std::map< int, xAODTriggerTowerVector_t >::value_type(key,vec));
175  }
176  } // end of loop over towers
177 
186  for (std::map< int, xAODTriggerTowerVector_t >::iterator mapIt = Sums.begin();
187  mapIt != Sums.end(); ++mapIt) {
188 
189  // create empty result vectors containing a single element
190  // That way if one layer is missing from TT collection we have a 0 entered already
191  std::vector<int> emET(1);
192  std::vector<int> hadET(1);
193  std::vector<int> emError(1);
194  std::vector<int> hadError(1);
195  // Both should contain same number of samples, and same peak position
196  int Peak = 0;
197 
198  // Get first TT for this CPMT
199  xAODTriggerTowerVector_t::iterator it = (mapIt->second).begin();
200  if (it != (mapIt->second).end()) {
201  // Get CPMT eta, phi using first tower in vector (either tower in CPMT should do)
202  double phi = (*it)->phi();
203  double eta = (*it)->eta();
204  // now loop through all TT present and add their ET values to CPMT
205  for (; it != (mapIt->second).end(); ++it) {
206  // Going to play safe and fill just one entry into each vector
207  // Avoids potential problem of different vector lengths in EM and Had
208  if ((*it)->layer() == 0) {
209  emET[Peak] = (*it)->cpET();
210  emError[Peak] = (*it)->errorWord();
211  }
212  else {
213  hadET[Peak] = (*it)->cpET();
214  hadError[Peak] = (*it)->errorWord();
215  }
216 
217  } // Loop through TT for this CPMT
218 
220  if (!zeroSuppress || emET[Peak] > 0 || hadET[Peak] > 0) {
221  CPMTower* cpmTower = new CPMTower(phi, eta, emET, emError, hadET, hadError, Peak);
222  cpmTowers->push_back(cpmTower);
223  }
224 
225  } // Check vector has non-zero length
226  } // end of loop through Sums map
227 
228  return;
229 }
230 
231 
232 
234 void L1CPMTowerTools::makeCPMTowers(const DataVector<xAOD::TriggerTower>* triggerTowers, DataVector<xAOD::CPMTower>* cpmTowers, bool zeroSuppress){
235 
236  // Clear collection before filling
237  cpmTowers->clear();
238 
245  std::map< int, xAODTriggerTowerVector_t > Sums;
246 
247  // Step over all TriggerTowers, and put into map
249  TriggerTowerKey testKey(0.0, 0.0);
250 
251  for( it = triggerTowers->begin(); it != triggerTowers->end(); ++it ) {
252  // Check within CPM tower coverage
253  if (fabs((*it)->eta()) > 2.5) continue;
254 
255  // Find TriggerTowerKey for this TriggerTower
256  int key = testKey.ttKey((*it)->phi(),(*it)->eta());
257  // Does the map already contain an entry for this CPMTower?
259  if (mapIt != Sums.end()) {
260  // Add pointer to this tower to the list
261  (mapIt->second).push_back((*it));
262  }
263  else {
264  // New entry in map.
266  vec.push_back((*it));
267  Sums.insert(std::map< int, xAODTriggerTowerVector_t >::value_type(key,vec));
268  }
269  } // end of loop over towers
270 
279  for (std::map< int, xAODTriggerTowerVector_t >::iterator mapIt = Sums.begin();
280  mapIt != Sums.end(); ++mapIt) {
281 
282  // create empty result vectors containing a single element
283  // That way if one layer is missing from TT collection we have a 0 entered already
284  std::vector<uint8_t> emET(1);
285  std::vector<uint8_t> hadET(1);
286  std::vector<uint32_t> emError(1);
287  std::vector<uint32_t> hadError(1);
288  // Both should contain same number of samples, and same peak position
289  int Peak = 0;
290 
291  // Get first TT for this CPMT
292  xAODTriggerTowerVector_t::iterator it = (mapIt->second).begin();
293  if (it != (mapIt->second).end()) {
294  // Get CPMT eta, phi using first tower in vector (either tower in CPMT should do)
295  double phi = (*it)->phi();
296  double eta = (*it)->eta();
297  // now loop through all TT present and add their ET values to CPMT
298  for (; it != (mapIt->second).end(); ++it) {
299  // Going to play safe and fill just one entry into each vector
300  // Avoids potential problem of different vector lengths in EM and Had
301  if ((*it)->layer() == 0) {
302  emET[Peak] = int((*it)->cpET());
303  emError[Peak] = (*it)->errorWord();
304  }
305  else {
306  hadET[Peak] = int((*it)->cpET());
307  hadError[Peak] = (*it)->errorWord();
308  }
309 
310  } // Loop through TT for this CPMT
311 
313  if (!zeroSuppress || emET[Peak] > 0 || hadET[Peak] > 0) {
314  xAOD::CPMTower* cpmTower = new xAOD::CPMTower();
315  cpmTowers->push_back(cpmTower);
316  cpmTower->initialize(eta, phi, emET, hadET, emError, hadError, Peak);
317  }
318 
319  } // Check vector has non-zero length
320  } // end of loop through Sums map
321 
322  return;
323 }
324 
325 
326 } // end of namespace
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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
TriggerTowerKey.h
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:423
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
xAOD::CPMTower
CPMTower_v2 CPMTower
Define the latest version of the CPMTower class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CPMTower.h:16
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
L1CPMTowerTools.h
LVL1::xAODTriggerTowerVector_t
std::vector< xAOD::TriggerTowerMap_t::mapped_type > xAODTriggerTowerVector_t
Definition: L1CPMTowerTools.cxx:17
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
LVL1::TriggerTowerVector_t
std::vector< TriggerTowerMap_t::mapped_type > TriggerTowerVector_t
Definition: L1CPMTowerTools.cxx:16
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
LVL1::CPMTower
The CPMTower class contains the TriggerTower information received by the Cluster Processor Modules.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTower.h:36
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LVL1::L1CPMTowerTools::initialize
virtual StatusCode initialize()
standard Athena-Algorithm method
Definition: L1CPMTowerTools.cxx:40
LVL1::L1CPMTowerTools::L1CPMTowerTools
L1CPMTowerTools(const std::string &, const std::string &, const IInterface *)
Constructor.
Definition: L1CPMTowerTools.cxx:21
LVL1::L1CPMTowerTools::makeCPMTowers
virtual void makeCPMTowers(const DataVector< TriggerTower > *triggerTowers, DataVector< CPMTower > *cpmTowers, bool zeroSuppress=true)
Fill DataVector of CPMTowers from user-supplied TriggerTowers.
Definition: L1CPMTowerTools.cxx:53
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
LVL1::L1CPMTowerTools::~L1CPMTowerTools
virtual ~L1CPMTowerTools()
default destructor
Definition: L1CPMTowerTools.cxx:33
DataVector::clear
void clear()
Erase all the elements in the collection.
LVL1::L1CPMTowerTools::finalize
virtual StatusCode finalize()
standard Athena-Algorithm method
Definition: L1CPMTowerTools.cxx:47
TriggerTower_ClassDEF.h
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
TrigT1CaloDefs.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::CPMTower_v2::initialize
virtual void initialize(const float eta, const float phi)
initialize
Definition: CPMTower_v2.cxx:24
AthAlgTool
Definition: AthAlgTool.h:26
LVL1::TriggerTowerKey::ttKey
virtual unsigned int ttKey(const TriggerTower &tower)
returns the key of the passed tower
Definition: TriggerTowerKey.cxx:143
LVL1::TriggerTowerKey
The TriggerTowerKey object provides the key for each trigger tower depending on its eta-phi coords.
Definition: TriggerTowerKey.h:56
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
xAOD::CPMTower_v2
Description of CPMTower_v2.
Definition: CPMTower_v2.h:26