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 {
26  produces<L1GctEmCandCollection>("isoEm");
27  produces<L1GctEmCandCollection>("nonIsoEm");
28  produces<L1GctJetCandCollection>("cenJets");
29  produces<L1GctJetCandCollection>("forJets");
30  produces<L1GctJetCandCollection>("tauJets");
31  produces<L1GctJetCandCollection>("isoTauJets");
32  produces<L1GctInternJetDataCollection>();
33  produces<L1GctEtTotalCollection>();
34  produces<L1GctEtHadCollection>();
35  produces<L1GctEtMissCollection>();
36  produces<L1GctHtMissCollection>();
37  produces<L1GctInternEtSumCollection>();
38  produces<L1GctInternHtMissCollection>();
39  produces<L1GctHFBitCountsCollection>();
40  produces<L1GctHFRingEtSumsCollection>();
41 
42  // register what you consume and keep token for later access:
43  EGammaToken_ = consumes<EGammaBxCollection>(iConfig.getParameter<InputTag>("InputCollection"));
44  RlxTauToken_ = consumes<TauBxCollection>(iConfig.getParameter<InputTag>("InputRlxTauCollection"));
45  IsoTauToken_ = consumes<TauBxCollection>(iConfig.getParameter<InputTag>("InputIsoTauCollection"));
46  JetToken_ = consumes<JetBxCollection>(iConfig.getParameter<InputTag>("InputCollection"));
47  EtSumToken_ = consumes<EtSumBxCollection>(iConfig.getParameter<InputTag>("InputCollection"));
48  HfSumsToken_ = consumes<CaloSpareBxCollection>(iConfig.getParameter<edm::InputTag>("InputHFSumsCollection"));
49  HfCountsToken_ = consumes<CaloSpareBxCollection>(iConfig.getParameter<edm::InputTag>("InputHFCountsCollection"));
50 }
51 
52 
54 {
55 }
56 
57 
58 
59 
60 // ------------ method called to produce the data ------------
61 void
63 {
64  LogDebug("l1t|stage 1 Converter") << "L1TCaloUpgradeToGCTConverter::produce function called...\n";
65 
66  //inputs
68  e.getByToken(EGammaToken_,EGamma);
69 
71  e.getByToken(RlxTauToken_,RlxTau);
72 
74  e.getByToken(IsoTauToken_,IsoTau);
75 
77  e.getByToken(JetToken_,Jet);
78 
80  e.getByToken(EtSumToken_,EtSum);
81 
83  e.getByToken(HfSumsToken_, HfSums);
84 
86  e.getByToken(HfCountsToken_, HfCounts);
87 
88  // create the em and jet collections
89  std::auto_ptr<L1GctEmCandCollection> isoEmResult(new L1GctEmCandCollection( ) );
90  std::auto_ptr<L1GctEmCandCollection> nonIsoEmResult(new L1GctEmCandCollection( ) );
91  std::auto_ptr<L1GctJetCandCollection> cenJetResult(new L1GctJetCandCollection( ) );
92  std::auto_ptr<L1GctJetCandCollection> forJetResult(new L1GctJetCandCollection( ) );
93  std::auto_ptr<L1GctJetCandCollection> tauJetResult(new L1GctJetCandCollection( ) );
94  std::auto_ptr<L1GctJetCandCollection> isoTauJetResult(new L1GctJetCandCollection( ) );
95 
96  // create the energy sum digis
97  std::auto_ptr<L1GctEtTotalCollection> etTotResult (new L1GctEtTotalCollection( ) );
98  std::auto_ptr<L1GctEtHadCollection> etHadResult (new L1GctEtHadCollection ( ) );
99  std::auto_ptr<L1GctEtMissCollection> etMissResult(new L1GctEtMissCollection ( ) );
100  std::auto_ptr<L1GctHtMissCollection> htMissResult(new L1GctHtMissCollection ( ) );
101 
102  // create the Hf sums digis
103  std::auto_ptr<L1GctHFBitCountsCollection> hfBitCountResult (new L1GctHFBitCountsCollection ( ) );
104  std::auto_ptr<L1GctHFRingEtSumsCollection> hfRingEtSumResult(new L1GctHFRingEtSumsCollection( ) );
105 
106  // create internal data collections
107  std::auto_ptr<L1GctInternJetDataCollection> internalJetResult (new L1GctInternJetDataCollection( ));
108  std::auto_ptr<L1GctInternEtSumCollection> internalEtSumResult (new L1GctInternEtSumCollection ( ));
109  std::auto_ptr<L1GctInternHtMissCollection> internalHtMissResult(new L1GctInternHtMissCollection ( ));
110 
111  int bxCounter = 0;
112 
113  for(int itBX=EGamma->getFirstBX(); itBX<=EGamma->getLastBX(); ++itBX){
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  bxCounter++;
150  //looping over Tau elments with a specific BX
151  int tauCount = 0; //max 4
152  for(TauBxCollection::const_iterator itTau = RlxTau->begin(itBX);
153  itTau != RlxTau->end(itBX); ++itTau){
154  // taus are not allowed to be forward
155  const bool forward= false;
156 
157  L1GctJetCand TauCand(itTau->hwPt(), itTau->hwPhi(), itTau->hwEta(),
158  true, forward,0, 0, itBX);
159  //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
160  // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
161  if(tauCount != 4){
162  tauJetResult->push_back(TauCand);
163  tauCount++;
164  }
165  }
166  tauJetResult->resize(4*bxCounter);
167  }
168 
169  bxCounter = 0;
170  for(int itBX=IsoTau->getFirstBX(); itBX<=IsoTau->getLastBX(); ++itBX){
171  bxCounter++;
172  //looping over Iso Tau elments with a specific BX
173  int isoTauCount = 0; //max 4
174  for(TauBxCollection::const_iterator itTau = IsoTau->begin(itBX);
175  itTau != IsoTau->end(itBX); ++itTau){
176  // taus are not allowed to be forward
177  const bool forward= false;
178 
179  L1GctJetCand TauCand(itTau->hwPt(), itTau->hwPhi(), itTau->hwEta(),
180  true, forward,0, 0, itBX);
181  //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
182  // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
183  if(isoTauCount != 4){
184  isoTauJetResult->push_back(TauCand);
185  isoTauCount++;
186  }
187  }
188  isoTauJetResult->resize(4*bxCounter);
189  }
190 
191  bxCounter = 0;
192  for(int itBX=Jet->getFirstBX(); itBX<=Jet->getLastBX(); ++itBX){
193  bxCounter++;
194  //looping over Jet elments with a specific BX
195  int forCount = 0; //max 4
196  int cenCount = 0; //max 4
197  for(JetBxCollection::const_iterator itJet = Jet->begin(itBX);
198  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(),
202  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  }
211  else {
212  if(cenCount != 4){
213  cenJetResult->push_back(JetCand);
214  cenCount++;
215  }
216  }
217  }
218  forJetResult->resize(4*bxCounter);
219  cenJetResult->resize(4*bxCounter);
220  }
221 
222  bxCounter = 0;
223  for(int itBX=EtSum->getFirstBX(); itBX<=EtSum->getLastBX(); ++itBX){
224  bxCounter++;
225  //looping over EtSum elments with a specific BX
226  for (EtSumBxCollection::const_iterator itEtSum = EtSum->begin(itBX);
227  itEtSum != EtSum->end(itBX); ++itEtSum){
228 
229  if (EtSum::EtSumType::kMissingEt == itEtSum->getType()){
230  L1GctEtMiss Cand(itEtSum->hwPt(), itEtSum->hwPhi(), itEtSum->hwQual()&0x1, itBX);
231  etMissResult->push_back(Cand);
232  }else if (EtSum::EtSumType::kMissingHt == itEtSum->getType()){
233  L1GctHtMiss Cand(itEtSum->hwPt(), itEtSum->hwPhi(), itEtSum->hwQual()&0x1, itBX);
234  htMissResult->push_back(Cand);
235  }else if (EtSum::EtSumType::kTotalEt == itEtSum->getType()){
236  L1GctEtTotal Cand(itEtSum->hwPt(), itEtSum->hwQual()&0x1, itBX);
237  etTotResult->push_back(Cand);
238  }else if (EtSum::EtSumType::kTotalHt == itEtSum->getType()){
239  L1GctEtHad Cand(itEtSum->hwPt(), itEtSum->hwQual()&0x1, itBX);
240  etHadResult->push_back(Cand);
241  }else {
242  LogError("l1t|stage 1 Converter") <<" Unknown EtSumType --- EtSum collection will not be saved...\n ";
243  }
244  }
245  etMissResult->resize(1*bxCounter);
246  htMissResult->resize(1*bxCounter);
247  etTotResult->resize(1*bxCounter);
248  etHadResult->resize(1*bxCounter);
249  }
250 
251  bxCounter = 0;
252  for(int itBX=HfSums->getFirstBX(); itBX<=HfSums->getLastBX(); ++itBX){
253  bxCounter++;
255  0,
256  0,
257  0,
258  0);
259  for (CaloSpareBxCollection::const_iterator itCaloSpare = HfSums->begin(itBX);
260  itCaloSpare != HfSums->end(itBX); ++itCaloSpare){
261  // if (CaloSpare::CaloSpareType::V2 == itCaloSpare->getType())
262  // {
263  // sum.setEtSum(3, itCaloSpare->hwPt());
264  // } else if (CaloSpare::CaloSpareType::Centrality == itCaloSpare->getType())
265  // {
266  // sum.setEtSum(0, itCaloSpare->hwPt());
267  // } else if (CaloSpare::CaloSpareType::Tau == itCaloSpare->getType())
268  // {
269  // sum.setEtSum(0, itCaloSpare->hwPt() & 0x7);
270  // sum.setEtSum(1, (itCaloSpare->hwPt() >> 3) & 0x7);
271  // sum.setEtSum(2, (itCaloSpare->hwPt() >> 6) & 0x7);
272  // sum.setEtSum(3, (itCaloSpare->hwPt() >> 9) & 0x7);
273  // }
274  for(int i = 0; i < 4; i++)
275  {
276  sum.setEtSum(i, itCaloSpare->GetRing(i));
277  }
278  }
279  hfRingEtSumResult->push_back(sum);
280 
281  hfRingEtSumResult->resize(1*bxCounter);
282  //no hfBitCounts yet
283  hfBitCountResult->resize(1*bxCounter);
284  }
285 
286  e.put(isoEmResult,"isoEm");
287  e.put(nonIsoEmResult,"nonIsoEm");
288  e.put(cenJetResult,"cenJets");
289  e.put(forJetResult,"forJets");
290  e.put(tauJetResult,"tauJets");
291  e.put(isoTauJetResult,"isoTauJets");
292  e.put(etTotResult);
293  e.put(etHadResult);
294  e.put(etMissResult);
295  e.put(htMissResult);
296  e.put(hfBitCountResult);
297  e.put(hfRingEtSumResult);
298 
299  e.put(internalJetResult);
300  e.put(internalEtSumResult);
301  e.put(internalHtMissResult);
302 }
303 
304 // ------------ method called once each job just before starting event loop ------------
305 void
307 {
308 }
309 
310 // ------------ method called once each job just after ending the event loop ------------
311 void
313 }
314 
315 // ------------ method called when starting to processes a run ------------
316 
317 void
319 
320 }
321 
322 // ------------ method called when ending the processing of a run ------------
323 void
325 
326 }
327 
328 
329 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
330 void
332  //The following says we do not know what parameters are allowed so do no validation
333  // Please change this to state exactly what you do use, even if it is no parameters
335  desc.setUnknown();
336  descriptions.addDefault(desc);
337 }
338 
339 //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
void addDefault(ParameterSetDescription const &psetDescription)
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
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
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