CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenToInputProducer.cc
Go to the documentation of this file.
1 
11 
12 // system include files
13 #include <boost/shared_ptr.hpp>
14 
15 // user include files
16 
27 
28 //#include <vector>
30 
36 
41 
42 #include "TMath.h"
43 #include "TRandom3.h"
44 #include <stdlib.h>
45 
46 using namespace std;
47 using namespace edm;
48 
49 #ifndef M_PI
50 #define M_PI 3.14159265358979323846
51 #endif
52 
53 namespace l1t {
54 
55 //
56 // class declaration
57 //
58 
59  class GenToInputProducer : public EDProducer {
60  public:
61  explicit GenToInputProducer(const ParameterSet&);
63 
64  static void fillDescriptions(ConfigurationDescriptions& descriptions);
65 
66  private:
67  virtual void produce(Event&, EventSetup const&);
68  virtual void beginJob();
69  virtual void endJob();
70  virtual void beginRun(Run const&iR, EventSetup const&iE);
71  virtual void endRun(Run const& iR, EventSetup const& iE);
72 
73  int convertPhiToHW(double iphi, int steps);
74  int convertEtaToHW(double ieta, double minEta, double maxEta, int steps);
75  int convertPtToHW(double ipt, int maxPt, double step);
76 
77  // ----------member data ---------------------------
78  unsigned long long m_paramsCacheId; // Cache-ID from current parameters, to check if needs to be updated.
79  //boost::shared_ptr<const CaloParams> m_dbpars; // Database parameters for the trigger, to be updated as needed.
80  //boost::shared_ptr<const FirmwareVersion> m_fwv;
81  //boost::shared_ptr<FirmwareVersion> m_fwv; //not const during testing.
82 
83  TRandom3* gRandom;
84 
85  // BX parameters
86  int bxFirst_;
87  int bxLast_;
88 
93 
98 
99  // Control how to end the job
103 
104  // Tokens
108 
109  int counter_;
110 
111  std::vector<l1t::Muon> muonVec_bxm2;
112  std::vector<l1t::Muon> muonVec_bxm1;
113  std::vector<l1t::Muon> muonVec_bx0;
114  std::vector<l1t::Muon> muonVec_bxp1;
115 
116  std::vector<l1t::EGamma> egammaVec_bxm2;
117  std::vector<l1t::EGamma> egammaVec_bxm1;
118  std::vector<l1t::EGamma> egammaVec_bx0;
119  std::vector<l1t::EGamma> egammaVec_bxp1;
120 
121  std::vector<l1t::Tau> tauVec_bxm2;
122  std::vector<l1t::Tau> tauVec_bxm1;
123  std::vector<l1t::Tau> tauVec_bx0;
124  std::vector<l1t::Tau> tauVec_bxp1;
125 
126  std::vector<l1t::Jet> jetVec_bxm2;
127  std::vector<l1t::Jet> jetVec_bxm1;
128  std::vector<l1t::Jet> jetVec_bx0;
129  std::vector<l1t::Jet> jetVec_bxp1;
130 
131  std::vector<l1t::EtSum> etsumVec_bxm2;
132  std::vector<l1t::EtSum> etsumVec_bxm1;
133  std::vector<l1t::EtSum> etsumVec_bx0;
134  std::vector<l1t::EtSum> etsumVec_bxp1;
135 
136  };
137 
138  //
139  // constructors and destructor
140  //
141  GenToInputProducer::GenToInputProducer(const ParameterSet& iConfig)
142  {
143  // register what you produce
144  produces<BXVector<l1t::EGamma>>();
145  produces<BXVector<l1t::Muon>>();
146  produces<BXVector<l1t::Tau>>();
147  produces<BXVector<l1t::Jet>>();
148  produces<BXVector<l1t::EtSum>>();
149 
150  // Setup parameters
151  bxFirst_ = iConfig.getParameter<int>("bxFirst");
152  bxLast_ = iConfig.getParameter<int>("bxLast");
153 
154  maxNumMuCands_ = iConfig.getParameter<int>("maxMuCand");
155  maxNumJetCands_ = iConfig.getParameter<int>("maxJetCand");
156  maxNumEGCands_ = iConfig.getParameter<int>("maxEGCand");
157  maxNumTauCands_ = iConfig.getParameter<int>("maxTauCand");
158 
159  jetEtThreshold_ = iConfig.getParameter<double>("jetEtThreshold");
160  tauEtThreshold_ = iConfig.getParameter<double>("tauEtThreshold");
161  egEtThreshold_ = iConfig.getParameter<double>("egEtThreshold");
162  muEtThreshold_ = iConfig.getParameter<double>("muEtThreshold");
163 
164 
165  emptyBxTrailer_ = iConfig.getParameter<int>("emptyBxTrailer");
166  emptyBxEvt_ = iConfig.getParameter<int>("emptyBxEvt");
167 
168 
169  genParticlesToken = consumes <reco::GenParticleCollection> (std::string("genParticles"));
170  genJetsToken = consumes <reco::GenJetCollection> (std::string("ak4GenJets"));
171  genMetToken = consumes <reco::GenMETCollection> (std::string("genMetCalo"));
172 
173 
174  // set cache id to zero, will be set at first beginRun:
175  m_paramsCacheId = 0;
176  eventCnt_ = 0;
177  }
178 
179 
180  GenToInputProducer::~GenToInputProducer()
181  {
182  }
183 
184 
185 
186 //
187 // member functions
188 //
189 
190 // ------------ method called to produce the data ------------
191 void
192 GenToInputProducer::produce(Event& iEvent, const EventSetup& iSetup)
193 {
194 
195  eventCnt_++;
196 
197  LogDebug("l1t|Global") << "GenToInputProducer::produce function called...\n";
198 
199  // Setup vectors
200  std::vector<l1t::Muon> muonVec;
201  std::vector<l1t::EGamma> egammaVec;
202  std::vector<l1t::Tau> tauVec;
203  std::vector<l1t::Jet> jetVec;
204  std::vector<l1t::EtSum> etsumVec;
205 
206  // Set the range of BX....TO DO...move to Params or determine from param set.
207  int bxFirst = bxFirst_;
208  int bxLast = bxLast_;
209 
210 
211  // Default values objects
212  double MaxLepPt_ = 255;
213  double MaxJetPt_ = 1023;
214  double MaxEt_ = 2047;
215 
216  double MaxCaloEta_ = 5.0;
217  double MaxMuonEta_ = 2.45;
218 
219  double PhiStepCalo_ = 144;
220  double PhiStepMuon_ = 576;
221 
222  // eta scale
223  double EtaStepCalo_ = 230;
224  double EtaStepMuon_ = 450;
225 
226  // Et scale (in GeV)
227  double PtStep_ = 0.5;
228 
229 
230  //outputs
231  std::auto_ptr<l1t::EGammaBxCollection> egammas (new l1t::EGammaBxCollection(0, bxFirst, bxLast));
232  std::auto_ptr<l1t::MuonBxCollection> muons (new l1t::MuonBxCollection(0, bxFirst, bxLast));
233  std::auto_ptr<l1t::TauBxCollection> taus (new l1t::TauBxCollection(0, bxFirst, bxLast));
234  std::auto_ptr<l1t::JetBxCollection> jets (new l1t::JetBxCollection(0, bxFirst, bxLast));
235  std::auto_ptr<l1t::EtSumBxCollection> etsums (new l1t::EtSumBxCollection(0, bxFirst, bxLast));
236 
237  std::vector<int> mu_cands_index;
238  std::vector<int> eg_cands_index;
239  std::vector<int> tau_cands_index;
241  // Make sure that you can get genParticles
242  if( iEvent.getByToken(genParticlesToken, genParticles) ){
243 
244  for( size_t k = 0; k < genParticles->size(); k++ ){
245  const reco::Candidate & mcParticle = (*genParticles)[k];
246 
247  int status = mcParticle.status();
248  int pdgId = mcParticle.pdgId();
249  double pt = mcParticle.pt();
250 
251  // Only use status 1 particles (Tau's need to be allowed through..take status 2 taus)
252  if( status!=1 && !(abs(pdgId)==15 && status==2) ) continue;
253 
254  int absId = abs(pdgId);
255 
256  if( absId==11 && pt>=egEtThreshold_ ) eg_cands_index.push_back(k);
257  else if( absId==13 && pt>=muEtThreshold_ ) mu_cands_index.push_back(k);
258  else if( absId==15 && pt>=tauEtThreshold_ ) tau_cands_index.push_back(k);
259  }
260  }
261  else {
262  LogTrace("l1t|Global") << ">>> GenParticles collection not found!" << std::endl;
263  }
264 
265 
266 
267  // Muon Collection
268  int numMuCands = int( mu_cands_index.size() );
269  Int_t idxMu[numMuCands];
270  double muPtSorted[numMuCands];
271  for( int iMu=0; iMu<numMuCands; iMu++ ) muPtSorted[iMu] = genParticles->at(mu_cands_index[iMu]).pt();
272 
273  TMath::Sort(numMuCands,muPtSorted,idxMu);
274  for( int iMu=0; iMu<numMuCands; iMu++ ){
275 
276  if( iMu>=maxNumMuCands_ ) continue;
277 
278  const reco::Candidate & mcParticle = (*genParticles)[mu_cands_index[idxMu[iMu]]];
279 
280  int pt = convertPtToHW( mcParticle.pt(), MaxLepPt_, PtStep_ );
281  int eta = convertEtaToHW( mcParticle.eta(), -MaxMuonEta_, MaxMuonEta_, EtaStepMuon_);
282  int phi = convertPhiToHW( mcParticle.phi(), PhiStepMuon_ );
283  int qual = gRandom->Integer(16);//4;
284  int iso = gRandom->Integer(4)%2;//1;
285  int charge = ( mcParticle.charge()<0 ) ? 1 : 0;
286  int chargeValid = 1;
287  int mip = 1;
288  int tag = 1;
289 
290  // Eta outside of acceptance
291  if( eta>=9999 ) continue;
292 
293  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
294 
295  l1t::Muon mu(*p4, pt, eta, phi, qual, charge, chargeValid, iso, mip, tag);
296  muonVec.push_back(mu);
297  }
298 
299 
300  // EG Collection
301  int numEgCands = int( eg_cands_index.size() );
302  Int_t idxEg[numEgCands];
303  double egPtSorted[numEgCands];
304  for( int iEg=0; iEg<numEgCands; iEg++ ) egPtSorted[iEg] = genParticles->at(eg_cands_index[iEg]).pt();
305 
306  TMath::Sort(numEgCands,egPtSorted,idxEg);
307  for( int iEg=0; iEg<numEgCands; iEg++ ){
308 
309  if( iEg>=maxNumEGCands_ ) continue;
310 
311  const reco::Candidate & mcParticle = (*genParticles)[eg_cands_index[idxEg[iEg]]];
312 
313  int pt = convertPtToHW( mcParticle.pt(), MaxLepPt_, PtStep_ );
314  int eta = convertEtaToHW( mcParticle.eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
315  int phi = convertPhiToHW( mcParticle.phi(), PhiStepCalo_ );
316  int qual = 1;
317  int iso = gRandom->Integer(4)%2;
318 
319  // Eta outside of acceptance
320  if( eta>=9999 ) continue;
321 
322  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
323 
324  l1t::EGamma eg(*p4, pt, eta, phi, qual, iso);
325  egammaVec.push_back(eg);
326  }
327 
328 
329 
330  // Tau Collection
331  int numTauCands = int( tau_cands_index.size() );
332  Int_t idxTau[numTauCands];
333  double tauPtSorted[numTauCands];
334  for( int iTau=0; iTau<numTauCands; iTau++ ) tauPtSorted[iTau] = genParticles->at(tau_cands_index[iTau]).pt();
335 
336  TMath::Sort(numTauCands,tauPtSorted,idxTau);
337  for( int iTau=0; iTau<numTauCands; iTau++ ){
338 
339  if( iTau>=maxNumTauCands_ ) continue;
340 
341  const reco::Candidate & mcParticle = (*genParticles)[tau_cands_index[idxTau[iTau]]];
342 
343  int pt = convertPtToHW( mcParticle.pt(), MaxLepPt_, PtStep_ );
344  int eta = convertEtaToHW( mcParticle.eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_);
345  int phi = convertPhiToHW( mcParticle.phi(), PhiStepCalo_ );
346  int qual = 1;
347  int iso = gRandom->Integer(4)%2;
348 
349  // Eta outside of acceptance
350  if( eta>=9999 ) continue;
351 
352  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
353 
354  l1t::Tau tau(*p4, pt, eta, phi, qual, iso);
355  tauVec.push_back(tau);
356  }
357 
358 
359  // Temporary hack to increase number of EGs and taus
360  int maxOtherEGs = 4;
361  int maxOtherTaus = 8;
362  int numCurrentEGs = int( egammaVec.size() );
363  int numCurrentTaus = int( tauVec.size() );
364 
365  int numExtraEGs=0, numExtraTaus=0;
366  // end hack
367 
368  // Use to sum the energy of the objects in the event for ETT and HTT
369  // sum all jets
370  double sumEt = 0;
371 
372  int nJet = 0;
374  // Make sure that you can get genJets
375  if( iEvent.getByToken(genJetsToken, genJets) ){ // Jet Collection
376  for(reco::GenJetCollection::const_iterator genJet = genJets->begin(); genJet!=genJets->end(); ++genJet ){
377 
378  //Keep running sum of total Et
379  sumEt += genJet->et();
380 
381  // Apply pt and eta cut?
382  if( genJet->pt()<jetEtThreshold_ ) continue;
383 
384  //
385  if( nJet>=maxNumJetCands_ ) continue;
386  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
387 
388  int pt = convertPtToHW( genJet->et(), MaxJetPt_, PtStep_ );
389  int eta = convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
390  int phi = convertPhiToHW( genJet->phi(), PhiStepCalo_ );
391 
392  // Eta outside of acceptance
393  if( eta>=9999 ) continue;
394 
395  int qual = 0;
396 
397  l1t::Jet jet(*p4, pt, eta, phi, qual);
398  jetVec.push_back(jet);
399 
400  nJet++;
401 
402  // Temporary hack to increase number of EGs and taus
403  if( (numExtraEGs+numCurrentEGs)<maxNumEGCands_ && numExtraEGs<maxOtherEGs ){
404  numExtraEGs++;
405 
406  int EGpt = convertPtToHW( genJet->et(), MaxLepPt_, PtStep_ );
407  int EGeta = convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
408  int EGphi = convertPhiToHW( genJet->phi(), PhiStepCalo_ );
409 
410  int EGqual = 1;
411  int EGiso = gRandom->Integer(4)%2;
412 
413  l1t::EGamma eg(*p4, EGpt, EGeta, EGphi, EGqual, EGiso);
414  egammaVec.push_back(eg);
415  }
416 
417  if( (numExtraTaus+numCurrentTaus)<maxNumTauCands_ && numExtraTaus<maxOtherTaus ){
418  numExtraTaus++;
419 
420  int Taupt = convertPtToHW( genJet->et(), MaxLepPt_, PtStep_ );
421  int Taueta = convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
422  int Tauphi = convertPhiToHW( genJet->phi(), PhiStepCalo_ );
423  int Tauqual = 1;
424  int Tauiso = gRandom->Integer(4)%2;
425 
426  l1t::Tau tau(*p4, Taupt, Taueta, Tauphi, Tauqual, Tauiso);
427  tauVec.push_back(tau);
428  }
429  // end hack
430  }
431  }
432  else {
433  LogTrace("l1t|Global") << ">>> GenJets collection not found!" << std::endl;
434  }
435 
436 
438  // Make sure that you can get genMET
439  if( iEvent.getByToken(genMetToken, genMet) ){
440  int pt = convertPtToHW( genMet->front().pt(), MaxEt_, PtStep_ );
441  int phi = convertPhiToHW( genMet->front().phi(), PhiStepCalo_ );
442 
443  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
444 
445  // Missing Et
446  l1t::EtSum etmiss(*p4, l1t::EtSum::EtSumType::kMissingEt,pt, 0,phi, 0);
447  etsumVec.push_back(etmiss);
448 
449  // Make Missing Ht slightly smaller and rotated (These are all fake inputs anyway...not supposed to be realistic)
450  pt = convertPtToHW( genMet->front().pt()*0.9, MaxEt_, PtStep_ );
451  phi = convertPhiToHW( genMet->front().phi()+ 3.14/5., PhiStepCalo_ );
452 
453  l1t::EtSum htmiss(*p4, l1t::EtSum::EtSumType::kMissingHt,pt, 0,phi, 0);
454  etsumVec.push_back(htmiss);
455 
456 
457  }
458  else {
459  LogTrace("l1t|Global") << ">>> GenMet collection not found!" << std::endl;
460  }
461 
462 
463 // Put the total Et into EtSums (Make HTT slightly smaller to tell them apart....not supposed to be realistic)
464  int pt = convertPtToHW( sumEt, 2047, PtStep_ );
465  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
466  l1t::EtSum etTotal(*p4, l1t::EtSum::EtSumType::kTotalEt,pt, 0, 0, 0);
467  etsumVec.push_back(etTotal);
468 
469  pt = convertPtToHW( sumEt*0.9, 2047, PtStep_ );
470  l1t::EtSum htTotal(*p4, l1t::EtSum::EtSumType::kTotalHt,pt, 0, 0, 0);
471  etsumVec.push_back(htTotal);
472 
473 
474  // Insert all the bx into the L1 Collections
475  printf("Event %i EmptyBxEvt %i emptyBxTrailer %i diff %i \n",eventCnt_,emptyBxEvt_,emptyBxTrailer_,(emptyBxEvt_ - eventCnt_));
476 
477  // Fill Muons
478  for( int iMu=0; iMu<int(muonVec_bxm2.size()); iMu++ ){
479  muons->push_back(-2, muonVec_bxm2[iMu]);
480  }
481  for( int iMu=0; iMu<int(muonVec_bxm1.size()); iMu++ ){
482  muons->push_back(-1, muonVec_bxm1[iMu]);
483  }
484  for( int iMu=0; iMu<int(muonVec_bx0.size()); iMu++ ){
485  muons->push_back(0, muonVec_bx0[iMu]);
486  }
487  for( int iMu=0; iMu<int(muonVec_bxp1.size()); iMu++ ){
488  muons->push_back(1, muonVec_bxp1[iMu]);
489  }
490  if(emptyBxTrailer_<=(emptyBxEvt_ - eventCnt_)) {
491  for( int iMu=0; iMu<int(muonVec.size()); iMu++ ){
492  muons->push_back(2, muonVec[iMu]);
493  }
494  } else {
495  // this event is part of empty trailer...clear out data
496  muonVec.clear();
497  }
498 
499  // Fill Egammas
500  for( int iEG=0; iEG<int(egammaVec_bxm2.size()); iEG++ ){
501  egammas->push_back(-2, egammaVec_bxm2[iEG]);
502  }
503  for( int iEG=0; iEG<int(egammaVec_bxm1.size()); iEG++ ){
504  egammas->push_back(-1, egammaVec_bxm1[iEG]);
505  }
506  for( int iEG=0; iEG<int(egammaVec_bx0.size()); iEG++ ){
507  egammas->push_back(0, egammaVec_bx0[iEG]);
508  }
509  for( int iEG=0; iEG<int(egammaVec_bxp1.size()); iEG++ ){
510  egammas->push_back(1, egammaVec_bxp1[iEG]);
511  }
512  if(emptyBxTrailer_<=(emptyBxEvt_ - eventCnt_)) {
513  for( int iEG=0; iEG<int(egammaVec.size()); iEG++ ){
514  egammas->push_back(2, egammaVec[iEG]);
515  }
516  } else {
517  // this event is part of empty trailer...clear out data
518  egammaVec.clear();
519  }
520 
521  // Fill Taus
522  for( int iTau=0; iTau<int(tauVec_bxm2.size()); iTau++ ){
523  taus->push_back(-2, tauVec_bxm2[iTau]);
524  }
525  for( int iTau=0; iTau<int(tauVec_bxm1.size()); iTau++ ){
526  taus->push_back(-1, tauVec_bxm1[iTau]);
527  }
528  for( int iTau=0; iTau<int(tauVec_bx0.size()); iTau++ ){
529  taus->push_back(0, tauVec_bx0[iTau]);
530  }
531  for( int iTau=0; iTau<int(tauVec_bxp1.size()); iTau++ ){
532  taus->push_back(1, tauVec_bxp1[iTau]);
533  }
534  if(emptyBxTrailer_<=(emptyBxEvt_ - eventCnt_)) {
535  for( int iTau=0; iTau<int(tauVec.size()); iTau++ ){
536  taus->push_back(2, tauVec[iTau]);
537  }
538  } else {
539  // this event is part of empty trailer...clear out data
540  tauVec.clear();
541  }
542 
543  // Fill Jets
544  for( int iJet=0; iJet<int(jetVec_bxm2.size()); iJet++ ){
545  jets->push_back(-2, jetVec_bxm2[iJet]);
546  }
547  for( int iJet=0; iJet<int(jetVec_bxm1.size()); iJet++ ){
548  jets->push_back(-1, jetVec_bxm1[iJet]);
549  }
550  for( int iJet=0; iJet<int(jetVec_bx0.size()); iJet++ ){
551  jets->push_back(0, jetVec_bx0[iJet]);
552  }
553  for( int iJet=0; iJet<int(jetVec_bxp1.size()); iJet++ ){
554  jets->push_back(1, jetVec_bxp1[iJet]);
555  }
556  if(emptyBxTrailer_<=(emptyBxEvt_ - eventCnt_)) {
557  for( int iJet=0; iJet<int(jetVec.size()); iJet++ ){
558  jets->push_back(2, jetVec[iJet]);
559  }
560  } else {
561  // this event is part of empty trailer...clear out data
562  jetVec.clear();
563  }
564 
565  // Fill Etsums
566  for( int iETsum=0; iETsum<int(etsumVec_bxm2.size()); iETsum++ ){
567  etsums->push_back(-2, etsumVec_bxm2[iETsum]);
568  }
569  for( int iETsum=0; iETsum<int(etsumVec_bxm1.size()); iETsum++ ){
570  etsums->push_back(-1, etsumVec_bxm1[iETsum]);
571  }
572  for( int iETsum=0; iETsum<int(etsumVec_bx0.size()); iETsum++ ){
573  etsums->push_back(0, etsumVec_bx0[iETsum]);
574  }
575  for( int iETsum=0; iETsum<int(etsumVec_bxp1.size()); iETsum++ ){
576  etsums->push_back(1, etsumVec_bxp1[iETsum]);
577  }
578  if(emptyBxTrailer_<=(emptyBxEvt_ - eventCnt_)) {
579  for( int iETsum=0; iETsum<int(etsumVec.size()); iETsum++ ){
580  etsums->push_back(2, etsumVec[iETsum]);
581  }
582  } else {
583  // this event is part of empty trailer...clear out data
584  etsumVec.clear();
585  }
586 
587 
588  iEvent.put(egammas);
589  iEvent.put(muons);
590  iEvent.put(taus);
591  iEvent.put(jets);
592  iEvent.put(etsums);
593 
594  // Now shift the bx data by one to prepare for next event.
595  muonVec_bxm2 = muonVec_bxm1;
596  egammaVec_bxm2 = egammaVec_bxm1;
597  tauVec_bxm2 = tauVec_bxm1;
598  jetVec_bxm2 = jetVec_bxm1;
599  etsumVec_bxm2 = etsumVec_bxm1;
600 
601  muonVec_bxm1 = muonVec_bx0;
602  egammaVec_bxm1 = egammaVec_bx0;
603  tauVec_bxm1 = tauVec_bx0;
604  jetVec_bxm1 = jetVec_bx0;
605  etsumVec_bxm1 = etsumVec_bx0;
606 
607  muonVec_bx0 = muonVec_bxp1;
608  egammaVec_bx0 = egammaVec_bxp1;
609  tauVec_bx0 = tauVec_bxp1;
610  jetVec_bx0 = jetVec_bxp1;
611  etsumVec_bx0 = etsumVec_bxp1;
612 
613  muonVec_bxp1 = muonVec;
614  egammaVec_bxp1 = egammaVec;
615  tauVec_bxp1 = tauVec;
616  jetVec_bxp1 = jetVec;
617  etsumVec_bxp1 = etsumVec;
618 
619 }
620 
621 // ------------ method called once each job just before starting event loop ------------
622 void
624 {
625 }
626 
627 // ------------ method called once each job just after ending the event loop ------------
628 void
629 GenToInputProducer::endJob() {
630 }
631 
632 // ------------ method called when starting to processes a run ------------
633 
634 void GenToInputProducer::beginRun(Run const&iR, EventSetup const&iE){
635 
636  LogDebug("l1t|Global") << "GenToInputProducer::beginRun function called...\n";
637 
638  counter_ = 0;
639  srand( 0 );
640 
641  gRandom = new TRandom3();
642 }
643 
644 // ------------ method called when ending the processing of a run ------------
645 void GenToInputProducer::endRun(Run const& iR, EventSetup const& iE){
646 
647 }
648 
649 
650 // ------------ methods to convert from physical to HW values ------------
651 int GenToInputProducer::convertPhiToHW(double iphi, int steps){
652 
653  double phiMax = 2 * M_PI;
654  if( iphi < 0 ) iphi += 2*M_PI;
655  if( iphi > phiMax) iphi -= phiMax;
656 
657  int hwPhi = int( (iphi/phiMax)*steps + 0.00001 );
658  return hwPhi;
659 }
660 
661 int GenToInputProducer::convertEtaToHW(double ieta, double minEta, double maxEta, int steps){
662 
663  double binWidth = (maxEta - minEta)/steps;
664 
665  //if we are outside the limits, set error
666  if(ieta < minEta) return 99999;//ieta = minEta+binWidth/2.;
667  if(ieta > maxEta) return 99999;//ieta = maxEta-binWidth/2.;
668 
669  int binNum = (int)(ieta/binWidth);
670  if(ieta<0.) binNum--;
671 
672 // unsigned int hwEta = binNum & bitMask;
673 // Remove masking for BXVectors...only assume in raw data
674 
675  return binNum;
676 }
677 
678 int GenToInputProducer::convertPtToHW(double ipt, int maxPt, double step){
679 
680  int hwPt = int( ipt/step + 0.0001 );
681  // if above max Pt, set to largest value
682  if( hwPt > maxPt ) hwPt = maxPt;
683 
684  return hwPt;
685 }
686 
687 
688 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
689 void
690 GenToInputProducer::fillDescriptions(ConfigurationDescriptions& descriptions) {
691  //The following says we do not know what parameters are allowed so do no validation
692  // Please change this to state exactly what you do use, even if it is no parameters
694  desc.setUnknown();
695  descriptions.addDefault(desc);
696 }
697 
698 } // namespace
699 
700 //define this as a plug-in
#define LogDebug(id)
double MaxEt_
T getParameter(std::string const &) const
std::vector< l1t::EtSum > etsumVec_bxm1
std::vector< l1t::Muon > muonVec_bxm1
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
std::vector< l1t::EtSum > etsumVec_bx0
virtual double pt() const =0
transverse momentum
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< l1t::Muon > muonVec_bxp1
virtual int status() const =0
status word
Definition: Tau.h:13
std::vector< l1t::Tau > tauVec_bx0
std::vector< l1t::Tau > tauVec_bxp1
std::vector< l1t::Tau > tauVec_bxm2
std::vector< l1t::Muon > muonVec_bxm2
std::vector< l1t::EtSum > etsumVec_bxp1
double maxEta
double MaxMuonEta_
void beginJob()
Definition: Breakpoints.cc:15
std::vector< l1t::EGamma > egammaVec_bxm1
Definition: Jet.h:13
double MaxJetPt_
double PhiStepCalo_
double EtaStepMuon_
int iEvent
Definition: GenABIO.cc:230
unsigned long long m_paramsCacheId
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< l1t::EGamma > egammaVec_bxm2
std::vector< l1t::EGamma > egammaVec_bxp1
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
edm::EDGetTokenT< reco::GenJetCollection > genJetsToken
double p4[4]
Definition: TauolaWrapper.h:92
std::vector< l1t::Muon > muonVec_bx0
vector< PseudoJet > jets
std::vector< l1t::Tau > tauVec_bxm1
std::vector< l1t::Jet > jetVec_bxm1
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double PtStep_
double MaxCaloEta_
double PhiStepMuon_
virtual int charge() const =0
electric charge
const int mu
Definition: Constants.h:22
std::vector< l1t::Jet > jetVec_bxp1
std::vector< l1t::EGamma > egammaVec_bx0
#define LogTrace(id)
Definition: Muon.h:12
virtual int pdgId() const =0
PDG identifier.
#define M_PI
double MaxLepPt_
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
Geom::Phi< T > phi() const
edm::EDGetTokenT< reco::GenMETCollection > genMetToken
tuple muons
Definition: patZpeak.py:38
edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken
tuple status
Definition: ntuplemaker.py:245
std::vector< l1t::Jet > jetVec_bxm2
std::vector< l1t::EtSum > etsumVec_bxm2
std::vector< l1t::Jet > jetVec_bx0
Definition: Run.h:43
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity
double EtaStepCalo_