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