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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &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_
 
GlobalExtBlk extCond_bx0
 
GlobalExtBlk extCond_bxm1
 
GlobalExtBlk extCond_bxm2
 
GlobalExtBlk extCond_bxp1
 
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 60 of file GenToInputProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 147 of file GenToInputProducer.cc.

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

148  {
149  // register what you produce
150  produces<BXVector<l1t::EGamma>>();
151  produces<BXVector<l1t::Muon>>();
152  produces<BXVector<l1t::Tau>>();
153  produces<BXVector<l1t::Jet>>();
154  produces<BXVector<l1t::EtSum>>();
155  produces<GlobalExtBlkBxCollection>();
156 
157  // Setup parameters
158  bxFirst_ = iConfig.getParameter<int>("bxFirst");
159  bxLast_ = iConfig.getParameter<int>("bxLast");
160 
161  maxNumMuCands_ = iConfig.getParameter<int>("maxMuCand");
162  maxNumJetCands_ = iConfig.getParameter<int>("maxJetCand");
163  maxNumEGCands_ = iConfig.getParameter<int>("maxEGCand");
164  maxNumTauCands_ = iConfig.getParameter<int>("maxTauCand");
165 
166  jetEtThreshold_ = iConfig.getParameter<double>("jetEtThreshold");
167  tauEtThreshold_ = iConfig.getParameter<double>("tauEtThreshold");
168  egEtThreshold_ = iConfig.getParameter<double>("egEtThreshold");
169  muEtThreshold_ = iConfig.getParameter<double>("muEtThreshold");
170 
171 
172  emptyBxTrailer_ = iConfig.getParameter<int>("emptyBxTrailer");
173  emptyBxEvt_ = iConfig.getParameter<int>("emptyBxEvt");
174 
175 
176  genParticlesToken = consumes <reco::GenParticleCollection> (std::string("genParticles"));
177  genJetsToken = consumes <reco::GenJetCollection> (std::string("ak4GenJets"));
178  genMetToken = consumes <reco::GenMETCollection> (std::string("genMetCalo"));
179 
180 
181  // set cache id to zero, will be set at first beginRun:
182  m_paramsCacheId = 0;
183  eventCnt_ = 0;
184  }
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 187 of file GenToInputProducer.cc.

188  {
189  }

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 655 of file GenToInputProducer.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 666 of file GenToInputProducer.cc.

References LogDebug.

666  {
667 
668  LogDebug("l1t|Global") << "GenToInputProducer::beginRun function called...\n";
669 
670  counter_ = 0;
671  srand( 0 );
672 
673  gRandom = new TRandom3();
674 }
#define LogDebug(id)
int l1t::GenToInputProducer::convertEtaToHW ( double  ieta,
double  minEta,
double  maxEta,
int  steps 
)
private

Definition at line 693 of file GenToInputProducer.cc.

References benchmark_cfg::minEta.

693  {
694 
695  double binWidth = (maxEta - minEta)/steps;
696 
697  //if we are outside the limits, set error
698  if(ieta < minEta) return 99999;//ieta = minEta+binWidth/2.;
699  if(ieta > maxEta) return 99999;//ieta = maxEta-binWidth/2.;
700 
701  int binNum = (int)(ieta/binWidth);
702  if(ieta<0.) binNum--;
703 
704 // unsigned int hwEta = binNum & bitMask;
705 // Remove masking for BXVectors...only assume in raw data
706 
707  return binNum;
708 }
double maxEta
int l1t::GenToInputProducer::convertPhiToHW ( double  iphi,
int  steps 
)
private

Definition at line 683 of file GenToInputProducer.cc.

References M_PI.

683  {
684 
685  double phiMax = 2 * M_PI;
686  if( iphi < 0 ) iphi += 2*M_PI;
687  if( iphi > phiMax) iphi -= phiMax;
688 
689  int hwPhi = int( (iphi/phiMax)*steps + 0.00001 );
690  return hwPhi;
691 }
#define M_PI
int l1t::GenToInputProducer::convertPtToHW ( double  ipt,
int  maxPt,
double  step 
)
private

Definition at line 710 of file GenToInputProducer.cc.

710  {
711 
712  int hwPt = int( ipt/step + 0.0001 );
713  // if above max Pt, set to largest value
714  if( hwPt > maxPt ) hwPt = maxPt;
715 
716  return hwPt;
717 }
void l1t::GenToInputProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 661 of file GenToInputProducer.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 677 of file GenToInputProducer.cc.

677  {
678 
679 }
void l1t::GenToInputProducer::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 722 of file GenToInputProducer.cc.

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

722  {
723  //The following says we do not know what parameters are allowed so do no validation
724  // Please change this to state exactly what you do use, even if it is no parameters
726  desc.setUnknown();
727  descriptions.addDefault(desc);
728 }
void addDefault(ParameterSetDescription const &psetDescription)
void l1t::GenToInputProducer::produce ( Event iEvent,
EventSetup const &  iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 199 of file GenToInputProducer.cc.

References funct::abs(), RecoTauCleanerPlugins::charge, reco::Candidate::charge(), eta, reco::Candidate::eta(), EtaStepCalo_, EtaStepMuon_, edm::EventID::event(), HepMCValidationHelper::genMet(), genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByToken(), i, edm::EventBase::id(), metsig::jet, fwrapper::jets, relval_2017::k, L1Analysis::kMissingEt, L1Analysis::kMissingHt, L1Analysis::kTotalEt, L1Analysis::kTotalHt, LogDebug, LogTrace, MaxCaloEta_, MaxEt_, MaxJetPt_, MaxLepPt_, MaxMuonEta_, RPCpg::mu, patZpeak::muons, p4, SingleMuPt40Fwdv2_cfi_GEN_SIM::pdgId, reco::Candidate::pdgId(), reco::Candidate::phi(), phi(), PhiStepCalo_, PhiStepMuon_, EnergyCorrector::pt, reco::Candidate::pt(), PtStep_, edm::Event::put(), GlobalExtBlk::reset(), GlobalExtBlk::setExternalDecision(), reco::Candidate::status(), ntuplemaker::status, GlobalPosition_Frontier_DevDB_cff::tag, and metsig::tau.

200 {
201 
202  eventCnt_++;
203 
204  LogDebug("l1t|Global") << "GenToInputProducer::produce function called...\n";
205 
206  // Setup vectors
207  std::vector<l1t::Muon> muonVec;
208  std::vector<l1t::EGamma> egammaVec;
209  std::vector<l1t::Tau> tauVec;
210  std::vector<l1t::Jet> jetVec;
211  std::vector<l1t::EtSum> etsumVec;
212  GlobalExtBlk extCond_bx;
213 
214  // Set the range of BX....TO DO...move to Params or determine from param set.
215  int bxFirst = bxFirst_;
216  int bxLast = bxLast_;
217 
218 
219  // Default values objects
220  double MaxLepPt_ = 255;
221  double MaxJetPt_ = 1023;
222  double MaxEt_ = 2047;
223 
224  double MaxCaloEta_ = 5.0;
225  double MaxMuonEta_ = 2.45;
226 
227  double PhiStepCalo_ = 144;
228  double PhiStepMuon_ = 576;
229 
230  // eta scale
231  double EtaStepCalo_ = 230;
232  double EtaStepMuon_ = 450;
233 
234  // Et scale (in GeV)
235  double PtStep_ = 0.5;
236 
237 
238  //outputs
239  std::auto_ptr<l1t::EGammaBxCollection> egammas (new l1t::EGammaBxCollection(0, bxFirst, bxLast));
240  std::auto_ptr<l1t::MuonBxCollection> muons (new l1t::MuonBxCollection(0, bxFirst, bxLast));
241  std::auto_ptr<l1t::TauBxCollection> taus (new l1t::TauBxCollection(0, bxFirst, bxLast));
242  std::auto_ptr<l1t::JetBxCollection> jets (new l1t::JetBxCollection(0, bxFirst, bxLast));
243  std::auto_ptr<l1t::EtSumBxCollection> etsums (new l1t::EtSumBxCollection(0, bxFirst, bxLast));
244  std::auto_ptr<GlobalExtBlkBxCollection> extCond( new GlobalExtBlkBxCollection(0,bxFirst,bxLast));
245 
246  std::vector<int> mu_cands_index;
247  std::vector<int> eg_cands_index;
248  std::vector<int> tau_cands_index;
250  // Make sure that you can get genParticles
251  if( iEvent.getByToken(genParticlesToken, genParticles) ){
252 
253  for( size_t k = 0; k < genParticles->size(); k++ ){
254  const reco::Candidate & mcParticle = (*genParticles)[k];
255 
256  int status = mcParticle.status();
257  int pdgId = mcParticle.pdgId();
258  double pt = mcParticle.pt();
259 
260  // Only use status 1 particles (Tau's need to be allowed through..take status 2 taus)
261  if( status!=1 && !(abs(pdgId)==15 && status==2) ) continue;
262 
263  int absId = abs(pdgId);
264 
265  if( absId==11 && pt>=egEtThreshold_ ) eg_cands_index.push_back(k);
266  else if( absId==13 && pt>=muEtThreshold_ ) mu_cands_index.push_back(k);
267  else if( absId==15 && pt>=tauEtThreshold_ ) tau_cands_index.push_back(k);
268  }
269  }
270  else {
271  LogTrace("l1t|Global") << ">>> GenParticles collection not found!" << std::endl;
272  }
273 
274 
275 
276  // Muon Collection
277  int numMuCands = int( mu_cands_index.size() );
278  Int_t idxMu[numMuCands];
279  double muPtSorted[numMuCands];
280  for( int iMu=0; iMu<numMuCands; iMu++ ) muPtSorted[iMu] = genParticles->at(mu_cands_index[iMu]).pt();
281 
282  TMath::Sort(numMuCands,muPtSorted,idxMu);
283  for( int iMu=0; iMu<numMuCands; iMu++ ){
284 
285  if( iMu>=maxNumMuCands_ ) continue;
286 
287  const reco::Candidate & mcParticle = (*genParticles)[mu_cands_index[idxMu[iMu]]];
288 
289  int pt = convertPtToHW( mcParticle.pt(), MaxLepPt_, PtStep_ );
290  int eta = convertEtaToHW( mcParticle.eta(), -MaxMuonEta_, MaxMuonEta_, EtaStepMuon_);
291  int phi = convertPhiToHW( mcParticle.phi(), PhiStepMuon_ );
292  int qual = gRandom->Integer(16);//4;
293  int iso = gRandom->Integer(4)%2;//1;
294  int charge = ( mcParticle.charge()<0 ) ? 1 : 0;
295  int chargeValid = 1;
296  int mip = 1;
297  int tag = 1;
298 
299  // Eta outside of acceptance
300  if( eta>=9999 ) continue;
301 
302  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
303 
304  l1t::Muon mu(*p4, pt, eta, phi, qual, charge, chargeValid, iso, mip, tag);
305  muonVec.push_back(mu);
306  }
307 
308 
309  // EG Collection
310  int numEgCands = int( eg_cands_index.size() );
311  Int_t idxEg[numEgCands];
312  double egPtSorted[numEgCands];
313  for( int iEg=0; iEg<numEgCands; iEg++ ) egPtSorted[iEg] = genParticles->at(eg_cands_index[iEg]).pt();
314 
315  TMath::Sort(numEgCands,egPtSorted,idxEg);
316  for( int iEg=0; iEg<numEgCands; iEg++ ){
317 
318  if( iEg>=maxNumEGCands_ ) continue;
319 
320  const reco::Candidate & mcParticle = (*genParticles)[eg_cands_index[idxEg[iEg]]];
321 
322  int pt = convertPtToHW( mcParticle.pt(), MaxLepPt_, PtStep_ );
323  int eta = convertEtaToHW( mcParticle.eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
324  int phi = convertPhiToHW( mcParticle.phi(), PhiStepCalo_ );
325  int qual = 1;
326  int iso = gRandom->Integer(4)%2;
327 
328  // Eta outside of acceptance
329  if( eta>=9999 ) continue;
330 
331  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
332 
333  l1t::EGamma eg(*p4, pt, eta, phi, qual, iso);
334  egammaVec.push_back(eg);
335  }
336 
337 
338 
339  // Tau Collection
340  int numTauCands = int( tau_cands_index.size() );
341  Int_t idxTau[numTauCands];
342  double tauPtSorted[numTauCands];
343  for( int iTau=0; iTau<numTauCands; iTau++ ) tauPtSorted[iTau] = genParticles->at(tau_cands_index[iTau]).pt();
344 
345  TMath::Sort(numTauCands,tauPtSorted,idxTau);
346  for( int iTau=0; iTau<numTauCands; iTau++ ){
347 
348  if( iTau>=maxNumTauCands_ ) continue;
349 
350  const reco::Candidate & mcParticle = (*genParticles)[tau_cands_index[idxTau[iTau]]];
351 
352  int pt = convertPtToHW( mcParticle.pt(), MaxLepPt_, PtStep_ );
353  int eta = convertEtaToHW( mcParticle.eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_);
354  int phi = convertPhiToHW( mcParticle.phi(), PhiStepCalo_ );
355  int qual = 1;
356  int iso = gRandom->Integer(4)%2;
357 
358  // Eta outside of acceptance
359  if( eta>=9999 ) continue;
360 
361  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
362 
363  l1t::Tau tau(*p4, pt, eta, phi, qual, iso);
364  tauVec.push_back(tau);
365  }
366 
367 
368  // Temporary hack to increase number of EGs and taus
369  int maxOtherEGs = 4;
370  int maxOtherTaus = 8;
371  int numCurrentEGs = int( egammaVec.size() );
372  int numCurrentTaus = int( tauVec.size() );
373 
374  int numExtraEGs=0, numExtraTaus=0;
375  // end hack
376 
377  // Use to sum the energy of the objects in the event for ETT and HTT
378  // sum all jets
379  double sumEt = 0;
380 
381  int nJet = 0;
383  // Make sure that you can get genJets
384  if( iEvent.getByToken(genJetsToken, genJets) ){ // Jet Collection
385  for(reco::GenJetCollection::const_iterator genJet = genJets->begin(); genJet!=genJets->end(); ++genJet ){
386 
387  //Keep running sum of total Et
388  sumEt += genJet->et();
389 
390  // Apply pt and eta cut?
391  if( genJet->pt()<jetEtThreshold_ ) continue;
392 
393  //
394  if( nJet>=maxNumJetCands_ ) continue;
395  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
396 
397  int pt = convertPtToHW( genJet->et(), MaxJetPt_, PtStep_ );
398  int eta = convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
399  int phi = convertPhiToHW( genJet->phi(), PhiStepCalo_ );
400 
401  // Eta outside of acceptance
402  if( eta>=9999 ) continue;
403 
404  int qual = 0;
405 
406  l1t::Jet jet(*p4, pt, eta, phi, qual);
407  jetVec.push_back(jet);
408 
409  nJet++;
410 
411  // Temporary hack to increase number of EGs and taus
412  if( (numExtraEGs+numCurrentEGs)<maxNumEGCands_ && numExtraEGs<maxOtherEGs ){
413  numExtraEGs++;
414 
415  int EGpt = convertPtToHW( genJet->et(), MaxLepPt_, PtStep_ );
416  int EGeta = convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
417  int EGphi = convertPhiToHW( genJet->phi(), PhiStepCalo_ );
418 
419  int EGqual = 1;
420  int EGiso = gRandom->Integer(4)%2;
421 
422  l1t::EGamma eg(*p4, EGpt, EGeta, EGphi, EGqual, EGiso);
423  egammaVec.push_back(eg);
424  }
425 
426  if( (numExtraTaus+numCurrentTaus)<maxNumTauCands_ && numExtraTaus<maxOtherTaus ){
427  numExtraTaus++;
428 
429  int Taupt = convertPtToHW( genJet->et(), MaxLepPt_, PtStep_ );
430  int Taueta = convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
431  int Tauphi = convertPhiToHW( genJet->phi(), PhiStepCalo_ );
432  int Tauqual = 1;
433  int Tauiso = gRandom->Integer(4)%2;
434 
435  l1t::Tau tau(*p4, Taupt, Taueta, Tauphi, Tauqual, Tauiso);
436  tauVec.push_back(tau);
437  }
438  // end hack
439  }
440  }
441  else {
442  LogTrace("l1t|Global") << ">>> GenJets collection not found!" << std::endl;
443  }
444 
445 
447  // Make sure that you can get genMET
448  if( iEvent.getByToken(genMetToken, genMet) ){
449  int pt = convertPtToHW( genMet->front().pt(), MaxEt_, PtStep_ );
450  int phi = convertPhiToHW( genMet->front().phi(), PhiStepCalo_ );
451 
452  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
453 
454  // Missing Et
455  l1t::EtSum etmiss(*p4, l1t::EtSum::EtSumType::kMissingEt,pt, 0,phi, 0);
456  etsumVec.push_back(etmiss);
457 
458  // Make Missing Ht slightly smaller and rotated (These are all fake inputs anyway...not supposed to be realistic)
459  pt = convertPtToHW( genMet->front().pt()*0.9, MaxEt_, PtStep_ );
460  phi = convertPhiToHW( genMet->front().phi()+ 3.14/5., PhiStepCalo_ );
461 
462  l1t::EtSum htmiss(*p4, l1t::EtSum::EtSumType::kMissingHt,pt, 0,phi, 0);
463  etsumVec.push_back(htmiss);
464 
465 
466  }
467  else {
468  LogTrace("l1t|Global") << ">>> GenMet collection not found!" << std::endl;
469  }
470 
471 
472 // Put the total Et into EtSums (Make HTT slightly smaller to tell them apart....not supposed to be realistic)
473  int pt = convertPtToHW( sumEt, 2047, PtStep_ );
474  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 = new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
475  l1t::EtSum etTotal(*p4, l1t::EtSum::EtSumType::kTotalEt,pt, 0, 0, 0);
476  etsumVec.push_back(etTotal);
477 
478  pt = convertPtToHW( sumEt*0.9, 2047, PtStep_ );
479  l1t::EtSum htTotal(*p4, l1t::EtSum::EtSumType::kTotalHt,pt, 0, 0, 0);
480  etsumVec.push_back(htTotal);
481 
482 
483 // Fill in some external conditions for testing
484  if((iEvent.id().event())%2 == 0 ) {
485  for(int i=0; i<255; i=i+2) extCond_bx.setExternalDecision(i,true);
486  } else {
487  for(int i=1; i<255; i=i+2) extCond_bx.setExternalDecision(i,true);
488  }
489 
490  // Insert all the bx into the L1 Collections
491  //printf("Event %i EmptyBxEvt %i emptyBxTrailer %i diff %i \n",eventCnt_,emptyBxEvt_,emptyBxTrailer_,(emptyBxEvt_ - eventCnt_));
492 
493  // Fill Muons
494  for( int iMu=0; iMu<int(muonVec_bxm2.size()); iMu++ ){
495  muons->push_back(-2, muonVec_bxm2[iMu]);
496  }
497  for( int iMu=0; iMu<int(muonVec_bxm1.size()); iMu++ ){
498  muons->push_back(-1, muonVec_bxm1[iMu]);
499  }
500  for( int iMu=0; iMu<int(muonVec_bx0.size()); iMu++ ){
501  muons->push_back(0, muonVec_bx0[iMu]);
502  }
503  for( int iMu=0; iMu<int(muonVec_bxp1.size()); iMu++ ){
504  muons->push_back(1, muonVec_bxp1[iMu]);
505  }
507  for( int iMu=0; iMu<int(muonVec.size()); iMu++ ){
508  muons->push_back(2, muonVec[iMu]);
509  }
510  } else {
511  // this event is part of empty trailer...clear out data
512  muonVec.clear();
513  }
514 
515  // Fill Egammas
516  for( int iEG=0; iEG<int(egammaVec_bxm2.size()); iEG++ ){
517  egammas->push_back(-2, egammaVec_bxm2[iEG]);
518  }
519  for( int iEG=0; iEG<int(egammaVec_bxm1.size()); iEG++ ){
520  egammas->push_back(-1, egammaVec_bxm1[iEG]);
521  }
522  for( int iEG=0; iEG<int(egammaVec_bx0.size()); iEG++ ){
523  egammas->push_back(0, egammaVec_bx0[iEG]);
524  }
525  for( int iEG=0; iEG<int(egammaVec_bxp1.size()); iEG++ ){
526  egammas->push_back(1, egammaVec_bxp1[iEG]);
527  }
529  for( int iEG=0; iEG<int(egammaVec.size()); iEG++ ){
530  egammas->push_back(2, egammaVec[iEG]);
531  }
532  } else {
533  // this event is part of empty trailer...clear out data
534  egammaVec.clear();
535  }
536 
537  // Fill Taus
538  for( int iTau=0; iTau<int(tauVec_bxm2.size()); iTau++ ){
539  taus->push_back(-2, tauVec_bxm2[iTau]);
540  }
541  for( int iTau=0; iTau<int(tauVec_bxm1.size()); iTau++ ){
542  taus->push_back(-1, tauVec_bxm1[iTau]);
543  }
544  for( int iTau=0; iTau<int(tauVec_bx0.size()); iTau++ ){
545  taus->push_back(0, tauVec_bx0[iTau]);
546  }
547  for( int iTau=0; iTau<int(tauVec_bxp1.size()); iTau++ ){
548  taus->push_back(1, tauVec_bxp1[iTau]);
549  }
551  for( int iTau=0; iTau<int(tauVec.size()); iTau++ ){
552  taus->push_back(2, tauVec[iTau]);
553  }
554  } else {
555  // this event is part of empty trailer...clear out data
556  tauVec.clear();
557  }
558 
559  // Fill Jets
560  for( int iJet=0; iJet<int(jetVec_bxm2.size()); iJet++ ){
561  jets->push_back(-2, jetVec_bxm2[iJet]);
562  }
563  for( int iJet=0; iJet<int(jetVec_bxm1.size()); iJet++ ){
564  jets->push_back(-1, jetVec_bxm1[iJet]);
565  }
566  for( int iJet=0; iJet<int(jetVec_bx0.size()); iJet++ ){
567  jets->push_back(0, jetVec_bx0[iJet]);
568  }
569  for( int iJet=0; iJet<int(jetVec_bxp1.size()); iJet++ ){
570  jets->push_back(1, jetVec_bxp1[iJet]);
571  }
573  for( int iJet=0; iJet<int(jetVec.size()); iJet++ ){
574  jets->push_back(2, jetVec[iJet]);
575  }
576  } else {
577  // this event is part of empty trailer...clear out data
578  jetVec.clear();
579  }
580 
581  // Fill Etsums
582  for( int iETsum=0; iETsum<int(etsumVec_bxm2.size()); iETsum++ ){
583  etsums->push_back(-2, etsumVec_bxm2[iETsum]);
584  }
585  for( int iETsum=0; iETsum<int(etsumVec_bxm1.size()); iETsum++ ){
586  etsums->push_back(-1, etsumVec_bxm1[iETsum]);
587  }
588  for( int iETsum=0; iETsum<int(etsumVec_bx0.size()); iETsum++ ){
589  etsums->push_back(0, etsumVec_bx0[iETsum]);
590  }
591  for( int iETsum=0; iETsum<int(etsumVec_bxp1.size()); iETsum++ ){
592  etsums->push_back(1, etsumVec_bxp1[iETsum]);
593  }
595  for( int iETsum=0; iETsum<int(etsumVec.size()); iETsum++ ){
596  etsums->push_back(2, etsumVec[iETsum]);
597  }
598  } else {
599  // this event is part of empty trailer...clear out data
600  etsumVec.clear();
601  }
602 
603  // Fill Externals
604  extCond->push_back(-2, extCond_bxm2);
605  extCond->push_back(-1, extCond_bxm1);
606  extCond->push_back(0, extCond_bx0);
607  extCond->push_back(1, extCond_bxp1);
609  extCond->push_back(2, extCond_bx);
610  } else {
611  // this event is part of the empty trailer...clear out data
612  extCond_bx.reset();
613  }
614 
615 
616  iEvent.put(egammas);
617  iEvent.put(muons);
618  iEvent.put(taus);
619  iEvent.put(jets);
620  iEvent.put(etsums);
621  iEvent.put(extCond);
622 
623  // Now shift the bx data by one to prepare for next event.
630 
637 
644 
645  muonVec_bxp1 = muonVec;
646  egammaVec_bxp1 = egammaVec;
647  tauVec_bxp1 = tauVec;
648  jetVec_bxp1 = jetVec;
649  etsumVec_bxp1 = etsumVec;
650  extCond_bxp1 = extCond_bx;
651 }
#define LogDebug(id)
double MaxEt_
EventNumber_t event() const
Definition: EventID.h:41
BXVector< GlobalExtBlk > GlobalExtBlkBxCollection
Definition: GlobalExtBlk.h:30
int i
Definition: DBlmapReader.cc:9
std::vector< l1t::EtSum > etsumVec_bxm1
void reset()
reset the content of a GlobalExtBlk
Definition: GlobalExtBlk.cc:75
std::vector< l1t::Muon > muonVec_bxm1
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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:16
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:16
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:121
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)
void setExternalDecision(unsigned int bit, bool val)
Set decision bits.
Definition: GlobalExtBlk.cc:52
int convertPhiToHW(double iphi, int steps)
Definition: Muon.h:16
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
edm::EventID id() const
Definition: EventBase.h:59
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 87 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::bxLast_
private

Definition at line 88 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::counter_
private

Definition at line 110 of file GenToInputProducer.cc.

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

Definition at line 119 of file GenToInputProducer.cc.

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

Definition at line 118 of file GenToInputProducer.cc.

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

Definition at line 117 of file GenToInputProducer.cc.

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

Definition at line 120 of file GenToInputProducer.cc.

double l1t::GenToInputProducer::egEtThreshold_
private

Definition at line 97 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::emptyBxEvt_
private

Definition at line 102 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::emptyBxTrailer_
private

Definition at line 101 of file GenToInputProducer.cc.

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

Definition at line 134 of file GenToInputProducer.cc.

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

Definition at line 133 of file GenToInputProducer.cc.

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

Definition at line 132 of file GenToInputProducer.cc.

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

Definition at line 135 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::eventCnt_
private

Definition at line 103 of file GenToInputProducer.cc.

GlobalExtBlk l1t::GenToInputProducer::extCond_bx0
private

Definition at line 139 of file GenToInputProducer.cc.

GlobalExtBlk l1t::GenToInputProducer::extCond_bxm1
private

Definition at line 138 of file GenToInputProducer.cc.

GlobalExtBlk l1t::GenToInputProducer::extCond_bxm2
private

Definition at line 137 of file GenToInputProducer.cc.

GlobalExtBlk l1t::GenToInputProducer::extCond_bxp1
private

Definition at line 140 of file GenToInputProducer.cc.

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

Definition at line 107 of file GenToInputProducer.cc.

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

Definition at line 108 of file GenToInputProducer.cc.

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

Definition at line 106 of file GenToInputProducer.cc.

TRandom3* l1t::GenToInputProducer::gRandom
private

Definition at line 84 of file GenToInputProducer.cc.

double l1t::GenToInputProducer::jetEtThreshold_
private

Definition at line 95 of file GenToInputProducer.cc.

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

Definition at line 129 of file GenToInputProducer.cc.

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

Definition at line 128 of file GenToInputProducer.cc.

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

Definition at line 127 of file GenToInputProducer.cc.

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

Definition at line 130 of file GenToInputProducer.cc.

unsigned long long l1t::GenToInputProducer::m_paramsCacheId
private

Definition at line 79 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::maxNumEGCands_
private

Definition at line 92 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::maxNumJetCands_
private

Definition at line 91 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::maxNumMuCands_
private

Definition at line 90 of file GenToInputProducer.cc.

int l1t::GenToInputProducer::maxNumTauCands_
private

Definition at line 93 of file GenToInputProducer.cc.

double l1t::GenToInputProducer::muEtThreshold_
private

Definition at line 98 of file GenToInputProducer.cc.

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

Definition at line 114 of file GenToInputProducer.cc.

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

Definition at line 113 of file GenToInputProducer.cc.

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

Definition at line 112 of file GenToInputProducer.cc.

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

Definition at line 115 of file GenToInputProducer.cc.

double l1t::GenToInputProducer::tauEtThreshold_
private

Definition at line 96 of file GenToInputProducer.cc.

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

Definition at line 124 of file GenToInputProducer.cc.

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

Definition at line 123 of file GenToInputProducer.cc.

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

Definition at line 122 of file GenToInputProducer.cc.

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

Definition at line 125 of file GenToInputProducer.cc.