CMS 3D CMS Logo

L1ParticleMap.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger
4 // Class : L1ParticleMap
5 //
8 //
9 // Original Author: Werner Sun
10 // Created: Wed Jul 26 14:42:56 EDT 2006
11 //
12 
13 // system include files
14 
15 // user include files
21 
22 using namespace l1extra;
23 
24 //
25 // constants, enums and typedefs
26 //
27 
28 //
29 // static data member definitions
30 //
31 
32 // EG = isolated OR non-isolated
33 // Jet = central OR forward OR tau
34 const std::string L1ParticleMap::triggerNames_[kNumOfL1TriggerTypes] = {"L1_SingleMu3",
35  "L1_SingleMu5",
36  "L1_SingleMu7",
37  "L1_SingleMu10",
38  "L1_SingleMu14",
39  "L1_SingleMu20",
40  "L1_SingleMu25",
41  "L1_SingleIsoEG5",
42  "L1_SingleIsoEG8",
43  "L1_SingleIsoEG10",
44  "L1_SingleIsoEG12",
45  "L1_SingleIsoEG15",
46  "L1_SingleIsoEG20",
47  "L1_SingleIsoEG25",
48  "L1_SingleEG5",
49  "L1_SingleEG8",
50  "L1_SingleEG10",
51  "L1_SingleEG12",
52  "L1_SingleEG15",
53  "L1_SingleEG20",
54  "L1_SingleEG25",
55  "L1_SingleJet15",
56  "L1_SingleJet20",
57  "L1_SingleJet30",
58  "L1_SingleJet50",
59  "L1_SingleJet70",
60  "L1_SingleJet100",
61  "L1_SingleJet150",
62  "L1_SingleJet200",
63  "L1_SingleTauJet10",
64  "L1_SingleTauJet20",
65  "L1_SingleTauJet30",
66  "L1_SingleTauJet35",
67  "L1_SingleTauJet40",
68  "L1_SingleTauJet60",
69  "L1_SingleTauJet80",
70  "L1_SingleTauJet100",
71  "L1_HTT100",
72  "L1_HTT200",
73  "L1_HTT250",
74  "L1_HTT300",
75  "L1_HTT400",
76  "L1_HTT500",
77  "L1_ETM10",
78  "L1_ETM15",
79  "L1_ETM20",
80  "L1_ETM30",
81  "L1_ETM40",
82  "L1_ETM50",
83  "L1_ETM60",
84  "L1_ETT60",
85  "L1_DoubleMu3",
86  "L1_DoubleIsoEG8",
87  "L1_DoubleIsoEG10",
88  "L1_DoubleEG5",
89  "L1_DoubleEG10",
90  "L1_DoubleEG15",
91  "L1_DoubleJet70",
92  "L1_DoubleJet100",
93  "L1_DoubleTauJet20",
94  "L1_DoubleTauJet30",
95  "L1_DoubleTauJet35",
96  "L1_DoubleTauJet40",
97  "L1_Mu3_IsoEG5",
98  "L1_Mu5_IsoEG10",
99  "L1_Mu3_EG12",
100  "L1_Mu3_Jet15",
101  "L1_Mu5_Jet15",
102  "L1_Mu3_Jet70",
103  "L1_Mu5_Jet20",
104  "L1_Mu5_TauJet20",
105  "L1_Mu5_TauJet30",
106  "L1_IsoEG10_EG10",
107  "L1_IsoEG10_Jet15",
108  "L1_IsoEG10_Jet20",
109  "L1_IsoEG10_Jet30",
110  "L1_IsoEG10_Jet70",
111  "L1_IsoEG10_TauJet20",
112  "L1_IsoEG10_TauJet30",
113  "L1_EG10_Jet15",
114  "L1_EG12_Jet20",
115  "L1_EG12_Jet70",
116  "L1_EG12_TauJet40",
117  "L1_Jet70_TauJet40",
118  "L1_Mu3_HTT200",
119  "L1_IsoEG10_HTT200",
120  "L1_EG12_HTT200",
121  "L1_Jet70_HTT200",
122  "L1_TauJet40_HTT200",
123  "L1_Mu3_ETM30",
124  "L1_IsoEG10_ETM30",
125  "L1_EG12_ETM30",
126  "L1_Jet70_ETM40",
127  "L1_TauJet20_ETM20",
128  "L1_TauJet30_ETM30",
129  "L1_TauJet30_ETM40",
130  "L1_HTT100_ETM30",
131  "L1_TripleMu3",
132  "L1_TripleIsoEG5",
133  "L1_TripleEG10",
134  "L1_TripleJet50",
135  "L1_TripleTauJet40",
136  "L1_DoubleMu3_IsoEG5",
137  "L1_DoubleMu3_EG10",
138  "L1_DoubleIsoEG5_Mu3",
139  "L1_DoubleEG10_Mu3",
140  "L1_DoubleMu3_HTT200",
141  "L1_DoubleIsoEG5_HTT200",
142  "L1_DoubleEG10_HTT200",
143  "L1_DoubleJet50_HTT200",
144  "L1_DoubleTauJet40_HTT200",
145  "L1_DoubleMu3_ETM20",
146  "L1_DoubleIsoEG5_ETM20",
147  "L1_DoubleEG10_ETM20",
148  "L1_DoubleJet50_ETM20",
149  "L1_DoubleTauJet40_ETM20",
150  "L1_QuadJet30",
151  "L1_ExclusiveDoubleIsoEG4",
152  "L1_ExclusiveDoubleJet60",
153  "L1_ExclusiveJet25_Gap_Jet25",
154  "L1_IsoEG10_Jet20_ForJet10",
155  "L1_MinBias_HTT10",
156  "L1_ZeroBias"};
157 
158 namespace {
159  enum IndexComboStates { kUnset, kSetting, kSet };
160 }
161 
162 //
163 // constructors and destructor
164 //
166 
168  bool triggerDecision,
170  const L1EmParticleVectorRef& emParticles,
171  const L1JetParticleVectorRef& jetParticles,
172  const L1MuonParticleVectorRef& muonParticles,
173  const L1EtMissParticleRefProd& etMissParticle,
174  const L1IndexComboVector& indexCombos)
175  : triggerType_(triggerType),
176  triggerDecision_(triggerDecision),
177  indexCombosState_{static_cast<char>(!indexCombos.empty() ? kSet : IndexComboStates::kUnset)},
178  objectTypes_(objectTypes),
179  emParticles_(emParticles),
180  jetParticles_(jetParticles),
181  muonParticles_(muonParticles),
182  etMissParticle_(etMissParticle),
183  indexCombos_(indexCombos) {}
184 
186  : triggerType_(rhs.triggerType_),
187  triggerDecision_(rhs.triggerDecision_),
188  indexCombosState_(IndexComboStates::kUnset),
189  objectTypes_(rhs.objectTypes_),
190  emParticles_(rhs.emParticles_),
191  jetParticles_(rhs.jetParticles_),
192  muonParticles_(rhs.muonParticles_),
193  etMissParticle_(rhs.etMissParticle_),
194  indexCombos_() {
195  // do actual copying here;
196  if (rhs.indexCombosState_.load(std::memory_order_acquire) == kSet) {
198  indexCombosState_.store(kSet, std::memory_order_release);
199  }
200 }
201 
203 
204 //
205 // assignment operators
206 //
208  //An exception safe implementation is
209  L1ParticleMap temp(rhs);
210  swap(temp);
211 
212  return *this;
213 }
214 
215 //
216 // member functions
217 //
221  indexCombosState_.store(
222  rhs.indexCombosState_.exchange(indexCombosState_.load(std::memory_order_acquire), std::memory_order_acq_rel),
223  std::memory_order_release);
230 }
231 
232 //
233 // const member functions
234 //
235 
237  if (kSet != indexCombosState_.load(std::memory_order_acquire)) {
238  setIndexCombos();
239  }
240  return indexCombos_;
241 }
242 
244  // Determine the number of non-global objects. There should be 0 or 1.
245  int numNonGlobal = 0;
246  L1ObjectType nonGlobalType = kNumOfL1ObjectTypes;
247  int nonGlobalIndex = -1;
248 
249  L1IndexComboVector tempIndexCombos;
250  for (int i = 0; i < numOfObjects(); ++i) {
252  ++numNonGlobal;
253  nonGlobalType = objectTypes_[i];
254  nonGlobalIndex = i;
255  }
256  }
257 
258  if (numNonGlobal == 0) {
259  // Dummy entry for each object type.
260  L1IndexCombo tmpCombo;
261  tmpCombo.reserve(numOfObjects());
262  for (int i = 0; i < numOfObjects(); ++i) {
263  tmpCombo.push_back(0);
264  }
265 
266  tempIndexCombos.push_back(tmpCombo);
267  } else if (numNonGlobal == 1) {
268  int nParticles = 0;
269 
270  if (nonGlobalType == kEM) {
271  nParticles = emParticles_.size();
272  } else if (nonGlobalType == kJet) {
273  nParticles = jetParticles_.size();
274  } else if (nonGlobalType == kMuon) {
275  nParticles = muonParticles_.size();
276  }
277 
278  tempIndexCombos.reserve(nParticles);
279  for (int i = 0; i < nParticles; ++i) {
280  L1IndexCombo tmpCombo;
281  tmpCombo.reserve(numOfObjects());
282  for (int j = 0; j < numOfObjects(); ++j) {
283  if (j == nonGlobalIndex) {
284  tmpCombo.push_back(i);
285  } else {
286  tmpCombo.push_back(0);
287  }
288  }
289 
290  tempIndexCombos.push_back(tmpCombo);
291  }
292  }
293  char expected = IndexComboStates::kUnset;
294  if (indexCombosState_.compare_exchange_strong(expected, kSetting, std::memory_order_acq_rel)) {
295  //If this was read from an old file, it is possible that indexCombos_ is already set.
296  // This is the only safe place to check since we know no other thread can be attempting
297  // to change this value.
298  if (indexCombos_.empty()) {
299  indexCombos_.swap(tempIndexCombos);
300  }
301  indexCombosState_.store(kSet, std::memory_order_release);
302  } else {
303  //have to wait
304  while (kSet != indexCombosState_.load(std::memory_order_acquire)) {
305  hardware_pause();
306  }
307  }
308 }
309 
310 const reco::LeafCandidate* L1ParticleMap::candidateInCombo(int aIndexInCombo, const L1IndexCombo& aCombo) const {
311  L1ObjectType type = objectTypes_[aIndexInCombo];
312  int particleInList = aCombo[aIndexInCombo];
313 
314  if (type == kEM) {
315  return dynamic_cast<const reco::LeafCandidate*>(emParticles_[particleInList].get());
316  } else if (type == kJet) {
317  return dynamic_cast<const reco::LeafCandidate*>(jetParticles_[particleInList].get());
318  } else if (type == kMuon) {
319  return dynamic_cast<const reco::LeafCandidate*>(muonParticles_[particleInList].get());
320  } else if (type == kEtMiss || type == kEtTotal || type == kEtHad) {
321  return dynamic_cast<const reco::LeafCandidate*>(etMissParticle_.get());
322  } else {
323  return nullptr;
324  }
325 }
326 
327 const L1EmParticle* L1ParticleMap::emParticleInCombo(int aIndexInCombo, const L1IndexCombo& aCombo) const {
328  L1ObjectType type = objectTypes_[aIndexInCombo];
329  int particleInList = aCombo[aIndexInCombo];
330 
331  if (type == kEM) {
332  return emParticles_[particleInList].get();
333  } else {
334  return nullptr;
335  }
336 }
337 
338 const L1JetParticle* L1ParticleMap::jetParticleInCombo(int aIndexInCombo, const L1IndexCombo& aCombo) const {
339  L1ObjectType type = objectTypes_[aIndexInCombo];
340  int particleInList = aCombo[aIndexInCombo];
341 
342  if (type == kJet) {
343  return jetParticles_[particleInList].get();
344  } else {
345  return nullptr;
346  }
347 }
348 
349 const L1MuonParticle* L1ParticleMap::muonParticleInCombo(int aIndexInCombo, const L1IndexCombo& aCombo) const {
350  L1ObjectType type = objectTypes_[aIndexInCombo];
351  int particleInList = aCombo[aIndexInCombo];
352 
353  if (type == kMuon) {
354  return muonParticles_[particleInList].get();
355  } else {
356  return nullptr;
357  }
358 }
359 
360 const L1EtMissParticle* L1ParticleMap::etMissParticleInCombo(int aIndexInCombo, const L1IndexCombo& aCombo) const {
361  L1ObjectType type = objectTypes_[aIndexInCombo];
362 
363  if (type == kEtMiss || type == kEtTotal || type == kEtHad) {
364  return etMissParticle_.get();
365  } else {
366  return nullptr;
367  }
368 }
369 
370 std::vector<const reco::LeafCandidate*> L1ParticleMap::candidateCombo(const L1IndexCombo& aCombo) const {
371  std::vector<const reco::LeafCandidate*> tmp;
372 
373  for (int i = 0; i < numOfObjects(); ++i) {
374  tmp.push_back(candidateInCombo(i, aCombo));
375  }
376 
377  return tmp;
378 }
379 
380 //
381 // static member functions
382 //
384 
386  for (int i = 0; i < kNumOfL1TriggerTypes; ++i) {
387  if (triggerNames_[i] == name) {
388  return (L1TriggerType)i;
389  }
390  }
391 
392  return kNumOfL1TriggerTypes;
393 }
394 
396  return type == kEtMiss || type == kEtTotal || type == kEtHad;
397 }
edm::RefProd< L1EtMissParticle >
mps_fire.i
i
Definition: mps_fire.py:355
l1extra::L1ParticleMap::triggerName
const std::string & triggerName() const
Definition: L1ParticleMap.h:284
l1extra::L1ParticleMap::muonParticles_
L1MuonParticleVectorRef muonParticles_
Definition: L1ParticleMap.h:361
kSet
const char * kSet
Definition: RootMinuitCommands.h:19
l1extra::L1ParticleMap::L1IndexComboVector
std::vector< L1IndexCombo > L1IndexComboVector
Definition: L1ParticleMap.h:263
l1extra::L1ParticleMap::muonParticleInCombo
const L1MuonParticle * muonParticleInCombo(int aIndexInCombo, const L1IndexCombo &aCombo) const
Definition: L1ParticleMap.cc:349
l1extra::L1ParticleMap::candidateInCombo
const reco::LeafCandidate * candidateInCombo(int aIndexInCombo, const L1IndexCombo &aCombo) const
Definition: L1ParticleMap.cc:310
l1extra::L1ParticleMap::kJet
Definition: L1ParticleMap.h:121
l1extra::L1ParticleMap::~L1ParticleMap
virtual ~L1ParticleMap()
Definition: L1ParticleMap.cc:202
l1extra::L1ParticleMap::objectTypes_
L1ObjectTypeVector objectTypes_
Definition: L1ParticleMap.h:355
l1extra::L1ParticleMap::jetParticles_
L1JetParticleVectorRef jetParticles_
Definition: L1ParticleMap.h:360
l1extra::L1JetParticleVectorRef
std::vector< L1JetParticleRef > L1JetParticleVectorRef
Definition: L1JetParticleFwd.h:34
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
l1extra::L1ParticleMap::triggerType_
L1TriggerType triggerType_
Definition: L1ParticleMap.h:345
l1extra::L1ParticleMap::indexCombos
const L1IndexComboVector & indexCombos() const
Definition: L1ParticleMap.cc:236
l1extra::L1EtMissParticle
Definition: L1EtMissParticle.h:27
l1extra::L1ParticleMap::triggerDecision_
bool triggerDecision_
Definition: L1ParticleMap.h:347
edm::RefProd::get
product_type const * get() const
Definition: RefProd.h:106
l1extra::L1ParticleMap::kEtMiss
Definition: L1ParticleMap.h:123
l1extra::L1ParticleMap::triggerType
L1TriggerType triggerType() const
Definition: L1ParticleMap.h:282
l1extra::L1ParticleMap::emParticles_
L1EmParticleVectorRef emParticles_
Definition: L1ParticleMap.h:359
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
l1extra::L1ParticleMap::emParticleInCombo
const L1EmParticle * emParticleInCombo(int aIndexInCombo, const L1IndexCombo &aCombo) const
Definition: L1ParticleMap.cc:327
l1extra::L1ParticleMap::indexCombosState_
std::atomic< char > indexCombosState_
Definition: L1ParticleMap.h:349
l1extra::L1EmParticle
Definition: L1EmParticle.h:28
l1extra::L1ParticleMap::swap
void swap(L1ParticleMap &)
Definition: L1ParticleMap.cc:218
l1extra::L1ParticleMap::objectTypeIsGlobal
static bool objectTypeIsGlobal(L1ObjectType type)
Definition: L1ParticleMap.cc:395
l1extra::L1ParticleMap::kEtHad
Definition: L1ParticleMap.h:125
l1extra::L1ParticleMap::jetParticleInCombo
const L1JetParticle * jetParticleInCombo(int aIndexInCombo, const L1IndexCombo &aCombo) const
Definition: L1ParticleMap.cc:338
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
l1extra::L1ParticleMap::kNumOfL1ObjectTypes
Definition: L1ParticleMap.h:126
l1extra::L1ParticleMap::L1ObjectTypeVector
std::vector< L1ObjectType > L1ObjectTypeVector
Definition: L1ParticleMap.h:264
l1extra::L1ParticleMap::setIndexCombos
void setIndexCombos() const
Definition: L1ParticleMap.cc:243
l1extra::L1ParticleMap::L1ObjectType
L1ObjectType
Definition: L1ParticleMap.h:119
l1extra::L1ParticleMap::L1ParticleMap
L1ParticleMap()
Definition: L1ParticleMap.cc:165
l1extra::L1MuonParticleVectorRef
std::vector< L1MuonParticleRef > L1MuonParticleVectorRef
Definition: L1MuonParticleFwd.h:34
l1extra::L1ParticleMap
Definition: L1ParticleMap.h:117
l1extra::L1JetParticle
Definition: L1JetParticle.h:28
hardware_pause
hardware_pause.h
L1ParticleMap.h
L1EmParticle.h
get
#define get
l1extra::L1ParticleMap::etMissParticleInCombo
const L1EtMissParticle * etMissParticleInCombo(int aIndexInCombo, const L1IndexCombo &aCombo) const
Definition: L1ParticleMap.cc:360
l1extra::L1ParticleMap::kNumOfL1TriggerTypes
Definition: L1ParticleMap.h:259
type
type
Definition: HCALResponse.h:21
l1extra::L1ParticleMap::operator=
L1ParticleMap & operator=(const L1ParticleMap &)
Definition: L1ParticleMap.cc:207
l1extra::L1ParticleMap::triggerNames_
static const std::string triggerNames_[kNumOfL1TriggerTypes]
Definition: L1ParticleMap.h:379
l1extra::L1ParticleMap::kMuon
Definition: L1ParticleMap.h:122
l1extra::L1EmParticleVectorRef
std::vector< L1EmParticleRef > L1EmParticleVectorRef
Definition: L1EmParticleFwd.h:34
l1extra::L1ParticleMap::kEtTotal
Definition: L1ParticleMap.h:124
l1extra::L1ParticleMap::numOfObjects
int numOfObjects() const
Definition: L1ParticleMap.h:294
L1MuonParticle.h
l1extra::L1ParticleMap::L1IndexCombo
std::vector< unsigned int > L1IndexCombo
Definition: L1ParticleMap.h:262
IndexComboStates
IndexComboStates
Definition: L1ParticleMap.cc:159
l1extra::L1ParticleMap::L1TriggerType
L1TriggerType
Definition: L1ParticleMap.h:135
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HLT_2018_cff.triggerType
triggerType
Definition: HLT_2018_cff.py:7443
l1extra::L1ParticleMap::kEM
Definition: L1ParticleMap.h:120
l1extra::L1MuonParticle
Definition: L1MuonParticle.h:27
reco::LeafCandidate
Definition: LeafCandidate.h:16
l1extra::L1ParticleMap::etMissParticle_
L1EtMissParticleRefProd etMissParticle_
Definition: L1ParticleMap.h:365
l1extra::L1ParticleMap::indexCombos_
L1IndexComboVector indexCombos_
Definition: L1ParticleMap.h:376
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
L1MuTriggerScaleKeysOnlineProd_cfi.objectTypes
objectTypes
Definition: L1MuTriggerScaleKeysOnlineProd_cfi.py:11
l1extra
Definition: L1EmParticle.h:26
l1extra::L1ParticleMap::candidateCombo
std::vector< const reco::LeafCandidate * > candidateCombo(const L1IndexCombo &aCombo) const
Definition: L1ParticleMap.cc:370
L1JetParticle.h