CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
l1t::GenToInputProducer Class Reference
Inheritance diagram for l1t::GenToInputProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GenToInputProducer (const ParameterSet &)
 
 ~GenToInputProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginJob ()
 
virtual void beginRun (Run const &iR, EventSetup const &iE)
 
int convertEtaToHW (double ieta, double minEta, double maxEta, int steps)
 
int convertPhiToHW (double iphi, int steps)
 
int convertPtToHW (double ipt, int maxPt, double step)
 
virtual void endJob ()
 
virtual void endRun (Run const &iR, EventSetup const &iE)
 
virtual void produce (Event &, EventSetup const &)
 

Private Attributes

int bxFirst_
 
int bxLast_
 
int counter_
 
std::vector< l1t::EGammaegammaVec_bx0
 
std::vector< l1t::EGammaegammaVec_bxm1
 
std::vector< l1t::EGammaegammaVec_bxm2
 
std::vector< l1t::EGammaegammaVec_bxp1
 
double egEtThreshold_
 
int emptyBxEvt_
 
int emptyBxTrailer_
 
std::vector< l1t::EtSumetsumVec_bx0
 
std::vector< l1t::EtSumetsumVec_bxm1
 
std::vector< l1t::EtSumetsumVec_bxm2
 
std::vector< l1t::EtSumetsumVec_bxp1
 
int eventCnt_
 
edm::EDGetTokenT
< reco::GenJetCollection
genJetsToken
 
edm::EDGetTokenT
< reco::GenMETCollection
genMetToken
 
edm::EDGetTokenT
< reco::GenParticleCollection
genParticlesToken
 
TRandom3 * gRandom
 
double jetEtThreshold_
 
std::vector< l1t::JetjetVec_bx0
 
std::vector< l1t::JetjetVec_bxm1
 
std::vector< l1t::JetjetVec_bxm2
 
std::vector< l1t::JetjetVec_bxp1
 
unsigned long long m_paramsCacheId
 
int maxNumEGCands_
 
int maxNumJetCands_
 
int maxNumMuCands_
 
int maxNumTauCands_
 
double muEtThreshold_
 
std::vector< l1t::MuonmuonVec_bx0
 
std::vector< l1t::MuonmuonVec_bxm1
 
std::vector< l1t::MuonmuonVec_bxm2
 
std::vector< l1t::MuonmuonVec_bxp1
 
double tauEtThreshold_
 
std::vector< l1t::TautauVec_bx0
 
std::vector< l1t::TautauVec_bxm1
 
std::vector< l1t::TautauVec_bxm2
 
std::vector< l1t::TautauVec_bxp1
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: Create Input Collections for the GT from MC gen particles. Allows testing of emulation.

Author
: D. Puigh OSU

Modeled after FakeInputProducer.cc

Definition at line 59 of file GenToInputProducer.cc.

Constructor & Destructor Documentation

l1t::GenToInputProducer::GenToInputProducer ( const ParameterSet iConfig)
explicit

Definition at line 141 of file GenToInputProducer.cc.

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

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  }
T getParameter(std::string const &) const
unsigned long long m_paramsCacheId
edm::EDGetTokenT< reco::GenJetCollection > genJetsToken
edm::EDGetTokenT< reco::GenMETCollection > genMetToken
edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken
l1t::GenToInputProducer::~GenToInputProducer ( )

Definition at line 180 of file GenToInputProducer.cc.

181  {
182  }

Member Function Documentation

void l1t::GenToInputProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 623 of file GenToInputProducer.cc.

624 {
625 }
void l1t::GenToInputProducer::beginRun ( Run const &  iR,
EventSetup const &  iE 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 634 of file GenToInputProducer.cc.

References LogDebug.

634  {
635 
636  LogDebug("l1t|Global") << "GenToInputProducer::beginRun function called...\n";
637 
638  counter_ = 0;
639  srand( 0 );
640 
641  gRandom = new TRandom3();
642 }
#define LogDebug(id)
int l1t::GenToInputProducer::convertEtaToHW ( double  ieta,
double  minEta,
double  maxEta,
int  steps 
)
private

Definition at line 661 of file GenToInputProducer.cc.

References benchmark_cfg::minEta.

661  {
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 }
double maxEta
int l1t::GenToInputProducer::convertPhiToHW ( double  iphi,
int  steps 
)
private

Definition at line 651 of file GenToInputProducer.cc.

References M_PI.

651  {
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 }
#define M_PI
int l1t::GenToInputProducer::convertPtToHW ( double  ipt,
int  maxPt,
double  step 
)
private

Definition at line 678 of file GenToInputProducer.cc.

678  {
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 }
void l1t::GenToInputProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 629 of file GenToInputProducer.cc.

629  {
630 }
void l1t::GenToInputProducer::endRun ( Run const &  iR,
EventSetup const &  iE 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 645 of file GenToInputProducer.cc.

645  {
646 
647 }
void l1t::GenToInputProducer::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 690 of file GenToInputProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

690  {
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 }
void addDefault(ParameterSetDescription const &psetDescription)
void l1t::GenToInputProducer::produce ( Event iEvent,
EventSetup const &  iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 192 of file GenToInputProducer.cc.

References funct::abs(), runGlobalFakeInputProducer::bxFirst, runGlobalFakeInputProducer::bxLast, RecoTauCleanerPlugins::charge, reco::Candidate::charge(), eta, reco::Candidate::eta(), EtaStepCalo_, EtaStepMuon_, HepMCValidationHelper::genMet(), genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByToken(), metsig::jet, fwrapper::jets, relval_steps::k, LogDebug, LogTrace, MaxCaloEta_, MaxEt_, MaxJetPt_, MaxLepPt_, MaxMuonEta_, RPCpg::mu, patZpeak::muons, p4, benchmark_cfg::pdgId, reco::Candidate::pdgId(), reco::Candidate::phi(), phi(), PhiStepCalo_, PhiStepMuon_, EnergyCorrector::pt, reco::Candidate::pt(), PtStep_, edm::Event::put(), reco::Candidate::status(), ntuplemaker::status, GlobalPosition_Frontier_DevDB_cff::tag, and metsig::tau.

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  }
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  }
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  }
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  }
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  }
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.
600 
606 
612 
613  muonVec_bxp1 = muonVec;
614  egammaVec_bxp1 = egammaVec;
615  tauVec_bxp1 = tauVec;
616  jetVec_bxp1 = jetVec;
617  etsumVec_bxp1 = etsumVec;
618 
619 }
#define LogDebug(id)
double MaxEt_
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
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 MaxMuonEta_
std::vector< l1t::EGamma > egammaVec_bxm1
Definition: Jet.h:13
double MaxJetPt_
int convertPtToHW(double ipt, int maxPt, double step)
double PhiStepCalo_
double EtaStepMuon_
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)
int convertPhiToHW(double iphi, int steps)
Definition: Muon.h:12
virtual int pdgId() const =0
PDG identifier.
double MaxLepPt_
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
int convertEtaToHW(double ieta, double minEta, double maxEta, int steps)
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
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity
double EtaStepCalo_

Member Data Documentation

int l1t::GenToInputProducer::bxFirst_
private

Definition at line 86 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::bxLast_
private

Definition at line 87 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::counter_
private

Definition at line 109 of file GenToInputProducer.cc.

std::vector<l1t::EGamma> l1t::GenToInputProducer::egammaVec_bx0
private

Definition at line 118 of file GenToInputProducer.cc.

std::vector<l1t::EGamma> l1t::GenToInputProducer::egammaVec_bxm1
private

Definition at line 117 of file GenToInputProducer.cc.

std::vector<l1t::EGamma> l1t::GenToInputProducer::egammaVec_bxm2
private

Definition at line 116 of file GenToInputProducer.cc.

std::vector<l1t::EGamma> l1t::GenToInputProducer::egammaVec_bxp1
private

Definition at line 119 of file GenToInputProducer.cc.

double l1t::GenToInputProducer::egEtThreshold_
private

Definition at line 96 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::emptyBxEvt_
private

Definition at line 101 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::emptyBxTrailer_
private

Definition at line 100 of file GenToInputProducer.cc.

std::vector<l1t::EtSum> l1t::GenToInputProducer::etsumVec_bx0
private

Definition at line 133 of file GenToInputProducer.cc.

std::vector<l1t::EtSum> l1t::GenToInputProducer::etsumVec_bxm1
private

Definition at line 132 of file GenToInputProducer.cc.

std::vector<l1t::EtSum> l1t::GenToInputProducer::etsumVec_bxm2
private

Definition at line 131 of file GenToInputProducer.cc.

std::vector<l1t::EtSum> l1t::GenToInputProducer::etsumVec_bxp1
private

Definition at line 134 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::eventCnt_
private

Definition at line 102 of file GenToInputProducer.cc.

edm::EDGetTokenT<reco::GenJetCollection> l1t::GenToInputProducer::genJetsToken
private

Definition at line 106 of file GenToInputProducer.cc.

edm::EDGetTokenT<reco::GenMETCollection> l1t::GenToInputProducer::genMetToken
private

Definition at line 107 of file GenToInputProducer.cc.

edm::EDGetTokenT<reco::GenParticleCollection> l1t::GenToInputProducer::genParticlesToken
private

Definition at line 105 of file GenToInputProducer.cc.

TRandom3* l1t::GenToInputProducer::gRandom
private

Definition at line 83 of file GenToInputProducer.cc.

double l1t::GenToInputProducer::jetEtThreshold_
private

Definition at line 94 of file GenToInputProducer.cc.

std::vector<l1t::Jet> l1t::GenToInputProducer::jetVec_bx0
private

Definition at line 128 of file GenToInputProducer.cc.

std::vector<l1t::Jet> l1t::GenToInputProducer::jetVec_bxm1
private

Definition at line 127 of file GenToInputProducer.cc.

std::vector<l1t::Jet> l1t::GenToInputProducer::jetVec_bxm2
private

Definition at line 126 of file GenToInputProducer.cc.

std::vector<l1t::Jet> l1t::GenToInputProducer::jetVec_bxp1
private

Definition at line 129 of file GenToInputProducer.cc.

unsigned long long l1t::GenToInputProducer::m_paramsCacheId
private

Definition at line 78 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::maxNumEGCands_
private

Definition at line 91 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::maxNumJetCands_
private

Definition at line 90 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::maxNumMuCands_
private

Definition at line 89 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::maxNumTauCands_
private

Definition at line 92 of file GenToInputProducer.cc.

double l1t::GenToInputProducer::muEtThreshold_
private

Definition at line 97 of file GenToInputProducer.cc.

std::vector<l1t::Muon> l1t::GenToInputProducer::muonVec_bx0
private

Definition at line 113 of file GenToInputProducer.cc.

std::vector<l1t::Muon> l1t::GenToInputProducer::muonVec_bxm1
private

Definition at line 112 of file GenToInputProducer.cc.

std::vector<l1t::Muon> l1t::GenToInputProducer::muonVec_bxm2
private

Definition at line 111 of file GenToInputProducer.cc.

std::vector<l1t::Muon> l1t::GenToInputProducer::muonVec_bxp1
private

Definition at line 114 of file GenToInputProducer.cc.

double l1t::GenToInputProducer::tauEtThreshold_
private

Definition at line 95 of file GenToInputProducer.cc.

std::vector<l1t::Tau> l1t::GenToInputProducer::tauVec_bx0
private

Definition at line 123 of file GenToInputProducer.cc.

std::vector<l1t::Tau> l1t::GenToInputProducer::tauVec_bxm1
private

Definition at line 122 of file GenToInputProducer.cc.

std::vector<l1t::Tau> l1t::GenToInputProducer::tauVec_bxm2
private

Definition at line 121 of file GenToInputProducer.cc.

std::vector<l1t::Tau> l1t::GenToInputProducer::tauVec_bxp1
private

Definition at line 124 of file GenToInputProducer.cc.