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