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