CMS 3D CMS Logo

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