ATLAS Offline Software
L1JetElementTools.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
5 // L1JetElementTools.cxx,
7 
8 #include "L1JetElementTools.h"
12 
15 
16 #include <vector>
17 
18 namespace LVL1 {
19 
20 typedef std::vector<TriggerTowerMap_t::mapped_type> TriggerTowerVector_t;
21 
25  const std::string& n,
26  const IInterface* p )
27  :
28  AthAlgTool(t,n,p)
29 {
30  declareInterface<IL1JetElementTools>(this);
31 
32 }
33 
37 {
38 }
39 
40 
44 {
45  return StatusCode::SUCCESS;
46 }
47 
51 {
52  return StatusCode::SUCCESS;
53 }
54 
57 
58  // Clear collection before filling
59  jetElements->clear();
60 
65  std::map< int, std::vector<const xAOD::TriggerTower*> > Sums;
66 
67  // Step over all TriggerTowers, and put into map
69  JetElementKey testKey(0.0, 0.0);
70 
71  for ( it = tts->begin(); it != tts->end(); ++it ) {
72  // Find JetElementKey for this TriggerTower
73  int key = testKey.jeKey((*it)->phi(),(*it)->eta());
74  // Does the map already contain an entry for this JetElement?
75  std::map< int, std::vector<const xAOD::TriggerTower*> >::iterator mapIt=Sums.find(key);
76  if (mapIt != Sums.end()) {
77  // Add pointer to this tower to the list
78  (mapIt->second).push_back((*it));
79  }
80  else {
81  // New entry in map.
82  std::vector<const xAOD::TriggerTower*> vec;
83  vec.push_back((*it));
84  Sums.insert(std::map< int, std::vector<const xAOD::TriggerTower*> >::value_type(key,vec));
85  }
86  } // end of loop over towers
87 
96  for (std::map< int, std::vector<const xAOD::TriggerTower*> >::iterator mapIt = Sums.begin();
97  mapIt != Sums.end(); ++mapIt) {
98 
99  // Get first TT for this JE
101  if (it != (mapIt->second).end()) {
102  // Get JE eta, phi using first tower in vector (any tower in JE should do)
103  unsigned int key = testKey.jeKey((*it)->phi(),(*it)->eta());
104  float phi = testKey.phi();
105  float eta = testKey.eta();
106  // peak position in ET vectors
107  int peak = 0;
108  // create empty ET vectors with 1 element each
109  std::vector<uint16_t> emET(1);
110  std::vector<uint16_t> hadET(1);
111  // now loop through all TT present and add their ET values
112  // if tower saturated, saturate corresponding sum also
113  // Note that this version will only create 1 time sample per JE
114  for (; it != (mapIt->second).end(); ++it) {
115  int layer = (*it)->layer();
116  int et = (*it)->jepET();
117  if (layer == 0) emET[peak] += ( et < m_ttSat ? et : m_layerSat );
118  else hadET[peak] += ( et < m_ttSat ? et : m_layerSat );
119  }
120 
122  std::vector<uint32_t> Dummy(emET.size());
123  xAOD::JetElement* jetElement = new xAOD::JetElement();
124  jetElements->push_back(jetElement);
125  jetElement->initialize(eta, phi, key, emET, hadET, Dummy, Dummy, Dummy, peak);
126 
127  } // end of check that first element of vector present
128 
129  } // end of loop through Sums map
130 
131  return;
132 }
133 
134 
137 
138  // Clear map before filling
139  map->clear();
140 
141  // Iterate through the DataVector and insert into the map
142 
143  for (xAOD::JetElementContainer::const_iterator it = jetElements->begin();
144  it != jetElements->end(); ++it) {
145  // As long as JetElement contains the key value, lazy (& quick) option is to use it
146  int key = (*it)->key();
147  map->insert(std::make_pair(key,(*it)));
148  }
149 
150  return;
151 }
152 
155 
156  // Clear collection before filling
157  jetElements->clear();
158 
163  std::map< int, TriggerTowerVector_t> Sums;
164 
165  // Step over all TriggerTowers, and put into map
167  JetElementKey testKey(0.0, 0.0);
168 
169  for( it = tts->begin(); it != tts->end(); ++it ) {
170  // Find JetElementKey for this TriggerTower
171  int key = testKey.jeKey((*it)->phi(),(*it)->eta());
172  // Does the map already contain an entry for this JetElement?
174  if (mapIt != Sums.end()) {
175  // Add pointer to this tower to the list
176  (mapIt->second).push_back((*it));
177  }
178  else {
179  // New entry in map.
181  vec.push_back((*it));
182  Sums.insert(std::map< int, TriggerTowerVector_t >::value_type(key,vec));
183  }
184  } // end of loop over towers
185 
194  for (std::map< int, TriggerTowerVector_t >::iterator mapIt = Sums.begin();
195  mapIt != Sums.end(); ++mapIt) {
196 
197  // Get first TT for this JE
198  TriggerTowerVector_t::iterator it = (mapIt->second).begin();
199  if (it != (mapIt->second).end()) {
200  // Get JE eta, phi using first tower in vector (any tower in JE should do)
201  unsigned int key = testKey.jeKey((*it)->phi(),(*it)->eta());
202  double phi = testKey.phi();
203  double eta = testKey.eta();
204  // get peak positions in ET vectors
205  int emPeak = (*it)->emPeak();
206  int hadPeak = (*it)->hadPeak();
207  // create empty ET vectors
208  std::vector<int> emET;
209  std::vector<int> hadET;
210  // now loop through all TT present and add their ET values
211  // if tower saturated, saturate corresponding sum also
212  for (; it != (mapIt->second).end(); ++it) {
213  std::vector<int> tempEM = (*it)->emLUT();
214  if (tempEM.size() > emET.size()) emET.resize(tempEM.size(),0);
215  for (size_t iem = 0; iem < tempEM.size(); ++iem)
216  emET[iem] += (tempEM[iem] < m_ttSat ? tempEM[iem] : m_layerSat);
217  std::vector<int> tempHad = (*it)->hadLUT();
218  if (tempHad.size() > hadET.size()) hadET.resize(tempHad.size(),0);
219  for (size_t ihd = 0; ihd < tempHad.size(); ++ihd)
220  hadET[ihd] += (tempHad[ihd] < m_ttSat ? tempHad[ihd] : m_layerSat);
221  }
224  if (emET.size() == hadET.size() && emPeak == hadPeak) {
225  std::vector<int> Dummy(emET.size());
226  JetElement* jetElement = new JetElement(phi, eta, emET, hadET, key, Dummy, Dummy, Dummy, emPeak);
227  jetElements->push_back(jetElement);
228  }
231  else {
232  std::vector<int> emSums;
233  std::vector<int> hadSums;
234  int Peak = (emPeak < hadPeak ? emPeak : hadPeak);
235  int Tail = (emET.size() - emPeak < hadET.size() - hadPeak ?
236  emET.size() - emPeak : hadET.size() - hadPeak) - 1;
237  for (int j = emPeak - Peak; j <= emPeak + Tail; ++j) emSums.push_back(emET[j]);
238  for (int j = hadPeak - Peak; j <= hadPeak + Tail; ++j) hadSums.push_back(hadET[j]);
239 
240  std::vector<int> Dummy(emSums.size());
241  JetElement* jetElement = new JetElement(phi, eta, emSums, hadSums, key, Dummy, Dummy, Dummy, Peak);
242  jetElements->push_back(jetElement);
243  } // unequal EM and Had readout
244 
245  } // end of check that first element of vector present
246 
247  } // end of loop through Sums map
248 
249  return;
250 }
251 
252 
253 
254 } // end of namespace
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
LVL1::KeyUtilities::phi
virtual double phi() const
returns phi coordinate of centre of relevant trigger tower.
Definition: KeyUtilities.cxx:159
LVL1::L1JetElementTools::makeJetElements
virtual void makeJetElements(const xAOD::TriggerTowerContainer *tts, xAOD::JetElementContainer *jetElements) const
Fill DataVector of JetElements from user-supplied TriggerTowers.
Definition: L1JetElementTools.cxx:56
et
Extra patterns decribing particle interation process.
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
LVL1::JetElementKeyBase::jeKey
virtual unsigned int jeKey(const xAOD::TriggerTower &tower)
returns key of passed tower
Definition: JetElementKeyBase.cxx:157
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
JetElementKey.h
LVL1::L1JetElementTools::L1JetElementTools
L1JetElementTools(const std::string &, const std::string &, const IInterface *)
Constructor.
Definition: L1JetElementTools.cxx:24
xAOD::JetElement_v2
Description of JetElement_v2.
Definition: JetElement_v2.h:26
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:396
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
xAOD::JetElement_v2::initialize
virtual void initialize(const float eta, const float phi, const unsigned int key)
initialize
Definition: JetElement_v2.cxx:24
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
LVL1::L1JetElementTools::m_layerSat
static const int m_layerSat
Definition: L1JetElementTools.h:63
LVL1::KeyUtilities::eta
virtual double eta() const
returns the centre of the TT at eta_coord:
Definition: KeyUtilities.cxx:150
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
LVL1::L1JetElementTools::~L1JetElementTools
virtual ~L1JetElementTools()
default destructor
Definition: L1JetElementTools.cxx:36
LVL1::JetElement
Jet elements are the inputs to the Jet, ETmiss and ETsum triggers.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/JetElement.h:43
xAOD::JetElementMap_t
std::map< int, const JetElement * > JetElementMap_t
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/JetElement.h:18
xAOD::JetElement
JetElement_v2 JetElement
Define the latest version of the JetElement class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/JetElement.h:16
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
DataVector::clear
void clear()
Erase all the elements in the collection.
LVL1::JetElementKey
The JetElementKey object provides the key for each JetElement depending on its eta,...
Definition: JetElementKey.h:51
TriggerTower_ClassDEF.h
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
LVL1::L1JetElementTools::finalize
virtual StatusCode finalize()
standard Athena-Algorithm method
Definition: L1JetElementTools.cxx:50
TrigT1CaloDefs.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
AthAlgTool
Definition: AthAlgTool.h:26
LVL1::L1JetElementTools::initialize
virtual StatusCode initialize()
standard Athena-Algorithm method
Definition: L1JetElementTools.cxx:43
value_type
Definition: EDM_MasterSearch.h:11
LVL1::L1JetElementTools::mapJetElements
virtual void mapJetElements(const xAOD::JetElementContainer *jetElements, xAOD::JetElementMap_t *map) const
Fill map of JetElements from user-supplied vector of TriggerTowers.
Definition: L1JetElementTools.cxx:136
TriggerTower.h
LVL1::L1JetElementTools::m_ttSat
static const int m_ttSat
Trigger Tower and Jet Element properties.
Definition: L1JetElementTools.h:62
JetElement.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
L1JetElementTools.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37