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 
23 {
24  produces<L1GctEmCandCollection>("isoEm");
25  produces<L1GctEmCandCollection>("nonIsoEm");
26  produces<L1GctJetCandCollection>("cenJets");
27  produces<L1GctJetCandCollection>("forJets");
28  produces<L1GctJetCandCollection>("tauJets");
29  produces<L1GctInternJetDataCollection>();
30  produces<L1GctEtTotalCollection>();
31  produces<L1GctEtHadCollection>();
32  produces<L1GctEtMissCollection>();
33  produces<L1GctHtMissCollection>();
34  produces<L1GctInternEtSumCollection>();
35  produces<L1GctInternHtMissCollection>();
36  produces<L1GctHFBitCountsCollection>();
37  produces<L1GctHFRingEtSumsCollection>();
38 
39  // register what you consume and keep token for later access:
40  EGammaToken_ = consumes<l1t::EGammaBxCollection>(iConfig.getParameter<InputTag>("InputCollection"));
41  TauToken_ = consumes<l1t::TauBxCollection>(iConfig.getParameter<InputTag>("InputCollection"));
42  JetToken_ = consumes<l1t::JetBxCollection>(iConfig.getParameter<InputTag>("InputCollection"));
43  EtSumToken_ = consumes<l1t::EtSumBxCollection>(iConfig.getParameter<InputTag>("InputCollection"));
44 }
45 
46 
48 {
49 }
50 
51 
52 
53 
54 // ------------ method called to produce the data ------------
55 void
57 {
58  LogDebug("l1t|stage 1 Converter") << "L1TCaloUpgradeToGCTConverter::produce function called...\n";
59 
60  //inputs
62  e.getByToken(EGammaToken_,EGamma);
63 
65  e.getByToken(TauToken_,Tau);
66 
68  e.getByToken(JetToken_,Jet);
69 
71  e.getByToken(EtSumToken_,EtSum);
72 
74  es.get< L1EmEtScaleRcd >().get( emScale ) ;
75 
77  es.get< L1JetEtScaleRcd >().get( jetScale ) ;
78 
79 
80  // create the em and jet collections
81  std::auto_ptr<L1GctEmCandCollection> isoEmResult(new L1GctEmCandCollection( ) );
82  std::auto_ptr<L1GctEmCandCollection> nonIsoEmResult(new L1GctEmCandCollection( ) );
83  std::auto_ptr<L1GctJetCandCollection> cenJetResult(new L1GctJetCandCollection( ) );
84  std::auto_ptr<L1GctJetCandCollection> forJetResult(new L1GctJetCandCollection( ) );
85  std::auto_ptr<L1GctJetCandCollection> tauJetResult(new L1GctJetCandCollection( ) );
86 
87  // create the energy sum digis
88  std::auto_ptr<L1GctEtTotalCollection> etTotResult (new L1GctEtTotalCollection( ) );
89  std::auto_ptr<L1GctEtHadCollection> etHadResult (new L1GctEtHadCollection ( ) );
90  std::auto_ptr<L1GctEtMissCollection> etMissResult(new L1GctEtMissCollection ( ) );
91  std::auto_ptr<L1GctHtMissCollection> htMissResult(new L1GctHtMissCollection ( ) );
92 
93  // create the Hf sums digis
94  std::auto_ptr<L1GctHFBitCountsCollection> hfBitCountResult (new L1GctHFBitCountsCollection ( ) );
95  std::auto_ptr<L1GctHFRingEtSumsCollection> hfRingEtSumResult(new L1GctHFRingEtSumsCollection( ) );
96 
97  // create internal data collections
98  std::auto_ptr<L1GctInternJetDataCollection> internalJetResult (new L1GctInternJetDataCollection( ));
99  std::auto_ptr<L1GctInternEtSumCollection> internalEtSumResult (new L1GctInternEtSumCollection ( ));
100  std::auto_ptr<L1GctInternHtMissCollection> internalHtMissResult(new L1GctInternHtMissCollection ( ));
101 
102 
103  // Assume BX is the same for all collections
104  int firstBX = EGamma->getFirstBX();
105  int lastBX = EGamma->getLastBX();
106  // //Finding the BX range for each input collection
107  // int firstBxEGamma = EGamma->getFirstBX();
108  // int lastBxEGamma = EGamma->getLastBX();
109  // int firstBxTau = Tau->getFirstBX();
110  // int lastBxTau = Tau->getLastBX();
111  // int firstBxJet = Jet->getFirstBX();
112  // int lastBxJet = Jet->getLastBX();
113  // int firstBxEtSum = EtSum->getFirstBX();
114  // int lastBxEtSum = EtSum->getLastBX();
115 
116  for(int itBX=firstBX; itBX!=lastBX+1; ++itBX){
117 
118  //looping over EGamma elments with a specific BX
119  int nonIsoCount = 0;
120  int isoCount = 0;
121  for(l1t::EGammaBxCollection::const_iterator itEGamma = EGamma->begin(itBX);
122  itEGamma != EGamma->end(itBX); ++itEGamma){
123  bool iso = itEGamma->hwIso();
124 
125  L1GctEmCand EmCand(itEGamma->hwPt(), itEGamma->hwPhi(), itEGamma->hwEta(),
126  iso, 0, 0, itBX);
127  //L1GctEmCand(unsigned rank, unsigned phi, unsigned eta,
128  // bool iso, uint16_t block, uint16_t index, int16_t bx);
129 
130  if(iso){
131  if(isoCount != 4)
132  {
133  isoEmResult->push_back(EmCand);
134  isoCount++;
135  }
136  }
137  else{
138  if(nonIsoCount != 4)
139  {
140  nonIsoEmResult->push_back(EmCand);
141  nonIsoCount++;
142  }
143  }
144  }
145 
146  //looping over Tau elments with a specific BX
147  int tauCount = 0; //max 4
148  for(l1t::TauBxCollection::const_iterator itTau = Tau->begin(itBX);
149  itTau != Tau->end(itBX); ++itTau){
150  // forward def is okay for Taus
151  const bool forward= (itTau->hwEta() < 4 || itTau->hwEta() > 17);
152  const uint16_t rankPt = jetScale->rank((uint16_t)itTau->hwPt());
153 
154  unsigned iEta = itTau->hwEta();
155  unsigned rctEta = (iEta<11 ? 10-iEta : iEta-11);
156  unsigned gtEta=(((rctEta % 7) & 0x7) | (iEta<11 ? 0x8 : 0));
157 
158  L1GctJetCand TauCand(rankPt, itTau->hwPhi(), gtEta,
159  true, forward,0, 0, itBX);
160  //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
161  // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
162  if(tauCount != 4){
163  tauJetResult->push_back(TauCand);
164  tauCount++;
165  }
166  }
167 
168  //looping over Jet elments with a specific BX
169  int forCount = 0; //max 4
170  int cenCount = 0; //max 4
171  for(l1t::JetBxCollection::const_iterator itJet = Jet->begin(itBX);
172  itJet != Jet->end(itBX); ++itJet){
173  // use 2nd quality bit to define forward
174  const bool forward = ((itJet->hwQual() & 0x2) != 0);
175  const uint16_t rankPt = jetScale->rank((uint16_t)itJet->hwPt());
176 
177  unsigned iEta = itJet->hwEta();
178  unsigned rctEta = (iEta<11 ? 10-iEta : iEta-11);
179  unsigned gtEta=(((rctEta % 7) & 0x7) | (iEta<11 ? 0x8 : 0));
180 
181  L1GctJetCand JetCand(rankPt, itJet->hwPhi(), gtEta,
182  false, forward,0, 0, itBX);
183  //L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
184  // bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
185  if(forward) {
186  if(forCount !=4 ){
187  forJetResult->push_back(JetCand);
188  forCount++;
189  }
190  }
191  else {
192  if(cenCount != 4){
193  cenJetResult->push_back(JetCand);
194  cenCount++;
195  }
196  }
197  }
198  //looping over EtSum elments with a specific BX
199  for (l1t::EtSumBxCollection::const_iterator itEtSum = EtSum->begin(itBX);
200  itEtSum != EtSum->end(itBX); ++itEtSum){
201 
202  if (EtSum::EtSumType::kMissingEt == itEtSum->getType()){
203  L1GctEtMiss Cand(itEtSum->hwPt(), itEtSum->hwPhi(), 0, itBX);
204  etMissResult->push_back(Cand);
205  }else if (EtSum::EtSumType::kMissingHt == itEtSum->getType()){
206  L1GctHtMiss Cand(itEtSum->hwPt(), itEtSum->hwPhi(), 0, itBX);
207  htMissResult->push_back(Cand);
208  }else if (EtSum::EtSumType::kTotalEt == itEtSum->getType()){
209  L1GctEtTotal Cand(itEtSum->hwPt(), 0, itBX);
210  etTotResult->push_back(Cand);
211  }else if (EtSum::EtSumType::kTotalHt == itEtSum->getType()){
212  L1GctEtHad Cand(itEtSum->hwPt(), 0, itBX);
213  etHadResult->push_back(Cand);
214  }else {
215  LogError("l1t|stage 1 Converter") <<" Unknown EtSumType --- EtSum collection will not be saved...\n ";
216  }
217  }
218  }
219 
220 
221 
222  //*isoEmResult =
223  //this->ConvertToNonIsoEmCand(EGamma);
224  // DataFormatter.ConvertToNonIsoEmCand(*EGamma, nonIsoEmResult);
225  // DataFormatter.ConvertToCenJetCand(*Jet, cenJetResult);
226  // DataFormatter.ConvertToForJetCand(*Jet, forJetResult);
227  // DataFormatter.ConvertToTauJetCand(*Tau, tauJetResult);
228 
229  // DataFormatter.ConvertToEtTotal(EtSum, etTotResult);
230  // DataFormatter.ConvertToEtHad(EtSum,etHadResult);
231  // DataFormatter.ConvertToEtMiss(EtSum,etMissResult);
232  // DataFormatter.ConvertToHtMiss(EtSum,htMissResult);
233  // DataFormatter.ConvertToHFBitCounts(EtSum,hfBitCountResult);
234  // DataFormatter.ConvertToHFRingEtSums(EtSum, hfRingEtSumResult);
235 
236  // DataFormatter.ConvertToIntJet(Jet, internalJetResult);
237  // DataFormatter.ConvertToIntEtSum(EtSum,internalEtSumResult);
238  // DataFormatter.ConvertToIntHtMiss(EtSum,internalHtMissResult);
239 
240 
241 
242  e.put(isoEmResult,"isoEm");
243  e.put(nonIsoEmResult,"nonIsoEm");
244  e.put(cenJetResult,"cenJets");
245  e.put(forJetResult,"forJets");
246  e.put(tauJetResult,"tauJets");
247  e.put(etTotResult);
248  e.put(etHadResult);
249  e.put(etMissResult);
250  e.put(htMissResult);
251  e.put(hfBitCountResult);
252  e.put(hfRingEtSumResult);
253 
254  e.put(internalJetResult);
255  e.put(internalEtSumResult);
256  e.put(internalHtMissResult);
257 }
258 
259 // ------------ method called once each job just before starting event loop ------------
260 void
262 {
263 }
264 
265 // ------------ method called once each job just after ending the event loop ------------
266 void
268 }
269 
270 // ------------ method called when starting to processes a run ------------
271 
272 void
274 
275 }
276 
277 // ------------ method called when ending the processing of a run ------------
278 void
280 
281 }
282 
283 
284 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
285 void
287  //The following says we do not know what parameters are allowed so do no validation
288  // Please change this to state exactly what you do use, even if it is no parameters
290  desc.setUnknown();
291  descriptions.addDefault(desc);
292 }
293 
294 //define this as a plug-in
#define LogDebug(id)
T getParameter(std::string const &) const
std::vector< L1GctEtMiss > L1GctEtMissCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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
virtual void beginRun(Run const &iR, EventSetup const &iE)
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
Definition: Jet.h:13
virtual void produce(Event &, EventSetup const &) override
void addDefault(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
Persistable copy of total Et measured at Level-1.
Definition: L1GctEtTotal.h:18
Persistable copy of total Ht measured at Level-1.
Definition: L1GctEtHad.h:18
std::vector< L1GctHtMiss > L1GctHtMissCollection
Persistable copy of missing Et measured at Level-1.
Definition: L1GctHtMiss.h:16
const T & get() const
Definition: EventSetup.h:55
std::vector< L1GctInternJetData > L1GctInternJetDataCollection
std::vector< L1GctInternEtSum > L1GctInternEtSumCollection
virtual void endRun(Run const &iR, EventSetup const &iE)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: Run.h:41
std::vector< EGamma >::const_iterator const_iterator
Definition: BXVector.h:16
std::vector< L1GctEmCand > L1GctEmCandCollection