CMS 3D CMS Logo

L1TCaloUpgradeToGCTConverter.cc
Go to the documentation of this file.
1 // L1TCaloUpgradeToGCTConverter.cc
2 // Authors: Ivan Cali
3 // R. Alex Barbieri
4 
5 // Stage 1 upgrade to old GT format converter
6 // Assumes input collections are sorted, but not truncated.
7 
8 // In the 'gct' eta coordinates the HF is 0-3 and 18-21. Jets which
9 // include any energy at all from the HF should be considered
10 // 'forward' jets, however, so jets with centers in 0-4 and 17-21 are
11 // considered 'forward'.
12 
14 #include <memory>
15 
19 
20 using namespace std;
21 using namespace edm;
22 using namespace l1t;
23 
25  : // register what you consume and keep token for later access:
26  EGammaToken_(consumes<EGammaBxCollection>(iConfig.getParameter<InputTag>("InputCollection"))),
27  RlxTauToken_(consumes<TauBxCollection>(iConfig.getParameter<InputTag>("InputRlxTauCollection"))),
28  IsoTauToken_(consumes<TauBxCollection>(iConfig.getParameter<InputTag>("InputIsoTauCollection"))),
29  JetToken_(consumes<JetBxCollection>(iConfig.getParameter<InputTag>("InputCollection"))),
30  EtSumToken_(consumes<EtSumBxCollection>(iConfig.getParameter<InputTag>("InputCollection"))),
31  HfSumsToken_(consumes<CaloSpareBxCollection>(iConfig.getParameter<edm::InputTag>("InputHFSumsCollection"))),
32  HfCountsToken_(consumes<CaloSpareBxCollection>(iConfig.getParameter<edm::InputTag>("InputHFCountsCollection"))),
33  bxMin_(iConfig.getParameter<int>("bxMin")),
34  bxMax_(iConfig.getParameter<int>("bxMax")) {
35  produces<L1GctEmCandCollection>("isoEm");
36  produces<L1GctEmCandCollection>("nonIsoEm");
37  produces<L1GctJetCandCollection>("cenJets");
38  produces<L1GctJetCandCollection>("forJets");
39  produces<L1GctJetCandCollection>("tauJets");
40  produces<L1GctJetCandCollection>("isoTauJets");
41  produces<L1GctInternJetDataCollection>();
42  produces<L1GctEtTotalCollection>();
43  produces<L1GctEtHadCollection>();
44  produces<L1GctEtMissCollection>();
45  produces<L1GctHtMissCollection>();
46  produces<L1GctInternEtSumCollection>();
47  produces<L1GctInternHtMissCollection>();
48  produces<L1GctHFBitCountsCollection>();
49  produces<L1GctHFRingEtSumsCollection>();
50 }
51 
52 // ------------ method called to produce the data ------------
54  LogDebug("l1t|stage 1 Converter") << "L1TCaloUpgradeToGCTConverter::produce function called...\n";
55 
56  //inputs
58  e.getByToken(EGammaToken_, EGamma);
59 
61  e.getByToken(RlxTauToken_, RlxTau);
62 
64  e.getByToken(IsoTauToken_, IsoTau);
65 
67  e.getByToken(JetToken_, Jet);
68 
70  e.getByToken(EtSumToken_, EtSum);
71 
73  e.getByToken(HfSumsToken_, HfSums);
74 
76  e.getByToken(HfCountsToken_, HfCounts);
77 
78  // create the em and jet collections
79  std::unique_ptr<L1GctEmCandCollection> isoEmResult(new L1GctEmCandCollection());
80  std::unique_ptr<L1GctEmCandCollection> nonIsoEmResult(new L1GctEmCandCollection());
81  std::unique_ptr<L1GctJetCandCollection> cenJetResult(new L1GctJetCandCollection());
82  std::unique_ptr<L1GctJetCandCollection> forJetResult(new L1GctJetCandCollection());
83  std::unique_ptr<L1GctJetCandCollection> tauJetResult(new L1GctJetCandCollection());
84  std::unique_ptr<L1GctJetCandCollection> isoTauJetResult(new L1GctJetCandCollection());
85 
86  // create the energy sum digis
87  std::unique_ptr<L1GctEtTotalCollection> etTotResult(new L1GctEtTotalCollection());
88  std::unique_ptr<L1GctEtHadCollection> etHadResult(new L1GctEtHadCollection());
89  std::unique_ptr<L1GctEtMissCollection> etMissResult(new L1GctEtMissCollection());
90  std::unique_ptr<L1GctHtMissCollection> htMissResult(new L1GctHtMissCollection());
91 
92  // create the Hf sums digis
93  std::unique_ptr<L1GctHFBitCountsCollection> hfBitCountResult(new L1GctHFBitCountsCollection());
94  std::unique_ptr<L1GctHFRingEtSumsCollection> hfRingEtSumResult(new L1GctHFRingEtSumsCollection());
95 
96  // create internal data collections
97  std::unique_ptr<L1GctInternJetDataCollection> internalJetResult(new L1GctInternJetDataCollection());
98  std::unique_ptr<L1GctInternEtSumCollection> internalEtSumResult(new L1GctInternEtSumCollection());
99  std::unique_ptr<L1GctInternHtMissCollection> internalHtMissResult(new L1GctInternHtMissCollection());
100 
101  int bxCounter = 0;
102 
103  for (int itBX = EGamma->getFirstBX(); itBX <= EGamma->getLastBX(); ++itBX) {
104  if (itBX < bxMin_)
105  continue;
106  if (itBX > bxMax_)
107  continue;
108 
109  bxCounter++;
110 
111  //looping over EGamma elments with a specific BX
112  int nonIsoCount = 0;
113  int isoCount = 0;
114  for (EGammaBxCollection::const_iterator itEGamma = EGamma->begin(itBX); itEGamma != EGamma->end(itBX); ++itEGamma) {
115  bool iso = itEGamma->hwIso();
116 
117  L1GctEmCand EmCand(itEGamma->hwPt(), itEGamma->hwPhi(), itEGamma->hwEta(), iso, 0, 0, itBX);
118  //L1GctEmCand(unsigned rank, unsigned phi, unsigned eta,
119  // bool iso, uint16_t block, uint16_t index, int16_t bx);
120 
121  if (iso) {
122  if (isoCount != 4) {
123  isoEmResult->push_back(EmCand);
124  isoCount++;
125  }
126  } else {
127  if (nonIsoCount != 4) {
128  nonIsoEmResult->push_back(EmCand);
129  nonIsoCount++;
130  }
131  }
132  }
133  isoEmResult->resize(4 * bxCounter);
134  nonIsoEmResult->resize(4 * bxCounter);
135  }
136 
137  bxCounter = 0;
138  for (int itBX = RlxTau->getFirstBX(); itBX <= RlxTau->getLastBX(); ++itBX) {
139  if (itBX < bxMin_)
140  continue;
141  if (itBX > bxMax_)
142  continue;
143 
144  bxCounter++;
145  //looping over Tau elments with a specific BX
146  int tauCount = 0; //max 4
147  for (TauBxCollection::const_iterator itTau = RlxTau->begin(itBX); itTau != RlxTau->end(itBX); ++itTau) {
148  // taus are not allowed to be forward
149  const bool forward = false;
150 
151  L1GctJetCand TauCand(itTau->hwPt(), itTau->hwPhi(), itTau->hwEta(), true, forward, 0, 0, itBX);
152  //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
153  // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
154  if (tauCount != 4) {
155  tauJetResult->push_back(TauCand);
156  tauCount++;
157  }
158  }
159  tauJetResult->resize(4 * bxCounter);
160  }
161 
162  bxCounter = 0;
163  for (int itBX = IsoTau->getFirstBX(); itBX <= IsoTau->getLastBX(); ++itBX) {
164  if (itBX < bxMin_)
165  continue;
166  if (itBX > bxMax_)
167  continue;
168 
169  bxCounter++;
170  //looping over Iso Tau elments with a specific BX
171  int isoTauCount = 0; //max 4
172  for (TauBxCollection::const_iterator itTau = IsoTau->begin(itBX); itTau != IsoTau->end(itBX); ++itTau) {
173  // taus are not allowed to be forward
174  const bool forward = false;
175 
176  L1GctJetCand TauCand(itTau->hwPt(), itTau->hwPhi(), itTau->hwEta(), true, forward, 0, 0, itBX);
177  //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
178  // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
179  if (isoTauCount != 4) {
180  isoTauJetResult->push_back(TauCand);
181  isoTauCount++;
182  }
183  }
184  isoTauJetResult->resize(4 * bxCounter);
185  }
186 
187  bxCounter = 0;
188  for (int itBX = Jet->getFirstBX(); itBX <= Jet->getLastBX(); ++itBX) {
189  if (itBX < bxMin_)
190  continue;
191  if (itBX > bxMax_)
192  continue;
193 
194  bxCounter++;
195  //looping over Jet elments with a specific BX
196  int forCount = 0; //max 4
197  int cenCount = 0; //max 4
198  for (JetBxCollection::const_iterator itJet = Jet->begin(itBX); itJet != Jet->end(itBX); ++itJet) {
199  // use 2nd quality bit to define forward
200  const bool forward = ((itJet->hwQual() & 0x2) != 0);
201  L1GctJetCand JetCand(itJet->hwPt(), itJet->hwPhi(), itJet->hwEta(), false, forward, 0, 0, itBX);
202  //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
203  // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
204  if (forward) {
205  if (forCount != 4) {
206  forJetResult->push_back(JetCand);
207  forCount++;
208  }
209  } else {
210  if (cenCount != 4) {
211  cenJetResult->push_back(JetCand);
212  cenCount++;
213  }
214  }
215  }
216  forJetResult->resize(4 * bxCounter);
217  cenJetResult->resize(4 * bxCounter);
218  }
219 
220  bxCounter = 0;
221  for (int itBX = EtSum->getFirstBX(); itBX <= EtSum->getLastBX(); ++itBX) {
222  if (itBX < bxMin_)
223  continue;
224  if (itBX > bxMax_)
225  continue;
226 
227  bxCounter++;
228  //looping over EtSum elments with a specific BX
229  for (EtSumBxCollection::const_iterator itEtSum = EtSum->begin(itBX); itEtSum != EtSum->end(itBX); ++itEtSum) {
230  if (EtSum::EtSumType::kMissingEt == itEtSum->getType()) {
231  L1GctEtMiss Cand(itEtSum->hwPt(), itEtSum->hwPhi(), itEtSum->hwQual() & 0x1, itBX);
232  etMissResult->push_back(Cand);
233  } else if (EtSum::EtSumType::kMissingHt == itEtSum->getType()) {
234  L1GctHtMiss Cand(itEtSum->hwPt(), itEtSum->hwPhi(), itEtSum->hwQual() & 0x1, itBX);
235  htMissResult->push_back(Cand);
236  } else if (EtSum::EtSumType::kTotalEt == itEtSum->getType()) {
237  L1GctEtTotal Cand(itEtSum->hwPt(), itEtSum->hwQual() & 0x1, itBX);
238  etTotResult->push_back(Cand);
239  } else if (EtSum::EtSumType::kTotalHt == itEtSum->getType()) {
240  L1GctEtHad Cand(itEtSum->hwPt(), itEtSum->hwQual() & 0x1, itBX);
241  etHadResult->push_back(Cand);
242  } else {
243  LogError("l1t|stage 1 Converter") << " Unknown EtSumType --- EtSum collection will not be saved...\n ";
244  }
245  }
246  etMissResult->resize(1 * bxCounter);
247  htMissResult->resize(1 * bxCounter);
248  etTotResult->resize(1 * bxCounter);
249  etHadResult->resize(1 * bxCounter);
250  }
251 
252  bxCounter = 0;
253  for (int itBX = HfSums->getFirstBX(); itBX <= HfSums->getLastBX(); ++itBX) {
254  if (itBX < bxMin_)
255  continue;
256  if (itBX > bxMax_)
257  continue;
258 
259  bxCounter++;
261  for (CaloSpareBxCollection::const_iterator itCaloSpare = HfSums->begin(itBX); itCaloSpare != HfSums->end(itBX);
262  ++itCaloSpare) {
263  // if (CaloSpare::CaloSpareType::V2 == itCaloSpare->getType())
264  // {
265  // sum.setEtSum(3, itCaloSpare->hwPt());
266  // } else if (CaloSpare::CaloSpareType::Centrality == itCaloSpare->getType())
267  // {
268  // sum.setEtSum(0, itCaloSpare->hwPt());
269  // } else if (CaloSpare::CaloSpareType::Tau == itCaloSpare->getType())
270  // {
271  // sum.setEtSum(0, itCaloSpare->hwPt() & 0x7);
272  // sum.setEtSum(1, (itCaloSpare->hwPt() >> 3) & 0x7);
273  // sum.setEtSum(2, (itCaloSpare->hwPt() >> 6) & 0x7);
274  // sum.setEtSum(3, (itCaloSpare->hwPt() >> 9) & 0x7);
275  // }
276  for (int i = 0; i < 4; i++) {
277  sum.setEtSum(i, itCaloSpare->GetRing(i));
278  }
279  }
280  hfRingEtSumResult->push_back(sum);
281 
282  hfRingEtSumResult->resize(1 * bxCounter);
283  }
284 
285  bxCounter = 0;
286  for (int itBX = HfCounts->getFirstBX(); itBX <= HfCounts->getLastBX(); ++itBX) {
287  if (itBX < bxMin_)
288  continue;
289  if (itBX > bxMax_)
290  continue;
291 
292  bxCounter++;
294  for (CaloSpareBxCollection::const_iterator itCaloSpare = HfCounts->begin(itBX); itCaloSpare != HfCounts->end(itBX);
295  ++itCaloSpare) {
296  for (int i = 0; i < 4; i++) {
297  count.setBitCount(i, itCaloSpare->GetRing(i));
298  }
299  }
300  hfBitCountResult->push_back(count);
301  hfBitCountResult->resize(1 * bxCounter);
302  }
303 
304  e.put(std::move(isoEmResult), "isoEm");
305  e.put(std::move(nonIsoEmResult), "nonIsoEm");
306  e.put(std::move(cenJetResult), "cenJets");
307  e.put(std::move(forJetResult), "forJets");
308  e.put(std::move(tauJetResult), "tauJets");
309  e.put(std::move(isoTauJetResult), "isoTauJets");
310  e.put(std::move(etTotResult));
311  e.put(std::move(etHadResult));
312  e.put(std::move(etMissResult));
313  e.put(std::move(htMissResult));
314  e.put(std::move(hfBitCountResult));
315  e.put(std::move(hfRingEtSumResult));
316 
317  e.put(std::move(internalJetResult));
318  e.put(std::move(internalEtSumResult));
319  e.put(std::move(internalHtMissResult));
320 }
321 
322 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
325  desc.add<int>("bxMin", 0);
326  desc.add<int>("bxMax", 0);
327  desc.add<edm::InputTag>("InputCollection", edm::InputTag("caloStage1Digis"));
328  desc.add<edm::InputTag>("InputRlxTauCollection", edm::InputTag("caloStage1Digis:rlxTaus"));
329  desc.add<edm::InputTag>("InputIsoTauCollection", edm::InputTag("caloStage1Digis:isoTaus"));
330  desc.add<edm::InputTag>("InputHFSumsCollection", edm::InputTag("caloStage1Digis:HFRingSums"));
331  desc.add<edm::InputTag>("InputHFCountsCollection", edm::InputTag("caloStage1Digis:HFBitCounts"));
332  descriptions.add("L1TCaloUpgradeToGCTConverter", desc);
333 }
334 
335 //define this as a plug-in
static L1GctHFRingEtSums fromGctEmulator(const int16_t bx, const uint16_t etSumPosEtaRing1, const uint16_t etSumNegEtaRing1, const uint16_t etSumPosEtaRing2, const uint16_t etSumNegEtaRing2)
named ctor for GCT emulator
int getLastBX() const
int getFirstBX() const
std::vector< L1GctEtMiss > L1GctEtMissCollection
std::vector< L1GctHFRingEtSums > L1GctHFRingEtSumsCollection
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< L1GctEtHad > L1GctEtHadCollection
Level-1 Trigger jet candidate.
Definition: L1GctJetCand.h:17
std::vector< L1GctInternHtMiss > L1GctInternHtMissCollection
Persistable copy of missing Et measured at Level-1.
Definition: L1GctEtMiss.h:17
delete x;
Definition: CaloConfig.h:22
Log< level::Error, false > LogError
Level-1 Trigger EM candidate at output of GCT.
Definition: L1GctEmCand.h:21
std::vector< L1GctEtTotal > L1GctEtTotalCollection
const_iterator begin(int bx) const
std::vector< L1GctHFBitCounts > L1GctHFBitCountsCollection
std::vector< L1GctJetCand > L1GctJetCandCollection
std::vector< T >::const_iterator const_iterator
Definition: BXVector.h:18
L1 GCT HF ring Et sums.
Definition: Jet.py:1
Persistable copy of total Et measured at Level-1.
Definition: L1GctEtTotal.h:17
void setEtSum(unsigned i, uint16_t et)
set a sum
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:145
Persistable copy of total Ht measured at Level-1.
Definition: L1GctEtHad.h:17
L1 GCT HF ring Et sums.
std::vector< L1GctHtMiss > L1GctHtMissCollection
Persistable copy of missing Et measured at Level-1.
Definition: L1GctHtMiss.h:16
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< L1GctInternJetData > L1GctInternJetDataCollection
const_iterator end(int bx) const
HLT enums.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< L1GctInternEtSum > L1GctInternEtSumCollection
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
static L1GctHFBitCounts fromGctEmulator(const int16_t bx, const uint16_t bitCountPosEtaRing1, const uint16_t bitCountNegEtaRing1, const uint16_t bitCountPosEtaRing2, const uint16_t bitCountNegEtaRing2)
named ctor for GCT emulator
def move(src, dest)
Definition: eostools.py:511
std::vector< L1GctEmCand > L1GctEmCandCollection
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:143
#define LogDebug(id)
L1TCaloUpgradeToGCTConverter(const edm::ParameterSet &)