204 LogDebug(
"GtGenToInputProducer") <<
"GenToInputProducer::produce function called...\n";
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;
220 double MaxLepPt_ = 255;
221 double MaxJetPt_ = 1023;
222 double MaxEt_ = 2047;
224 double MaxCaloEta_ = 5.0;
225 double MaxMuonEta_ = 2.45;
227 double PhiStepCalo_ = 144;
228 double PhiStepMuon_ = 576;
231 double EtaStepCalo_ = 230;
232 double EtaStepMuon_ = 450;
235 double PtStep_ = 0.5;
246 std::vector<int> mu_cands_index;
247 std::vector<int> eg_cands_index;
248 std::vector<int> tau_cands_index;
253 for(
size_t k = 0;
k < genParticles->size();
k++ ){
258 double pt = mcParticle.
pt();
261 if( status!=1 && !(
abs(pdgId)==15 && status==2) )
continue;
263 int absId =
abs(pdgId);
266 else if( absId==13 && pt>=
muEtThreshold_ ) mu_cands_index.push_back(
k);
271 LogTrace(
"GtGenToInputProducer") <<
">>> GenParticles collection not found!" << std::endl;
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();
282 TMath::Sort(numMuCands,muPtSorted,idxMu);
283 for(
int iMu=0; iMu<numMuCands; iMu++ ){
287 const reco::Candidate & mcParticle = (*genParticles)[mu_cands_index[idxMu[iMu]]];
292 int qual =
gRandom->Integer(16);
293 int iso =
gRandom->Integer(4)%2;
303 int hwEtaAtVtx =
eta;
304 int hwPhiAtVtx =
phi;
307 if( eta>=9999 )
continue;
309 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
311 l1t::Muon mu(*p4, pt, eta, phi, qual, charge, chargeValid, iso, tfMuIdx, tag, debug, isoSum, dPhi, dEta, rank, hwEtaAtVtx, hwPhiAtVtx);
312 muonVec.push_back(
mu);
317 int numEgCands =
int( eg_cands_index.size() );
318 Int_t idxEg[numEgCands];
319 double egPtSorted[numEgCands];
320 for(
int iEg=0; iEg<numEgCands; iEg++ ) egPtSorted[iEg] = genParticles->at(eg_cands_index[iEg]).pt();
322 TMath::Sort(numEgCands,egPtSorted,idxEg);
323 for(
int iEg=0; iEg<numEgCands; iEg++ ){
327 const reco::Candidate & mcParticle = (*genParticles)[eg_cands_index[idxEg[iEg]]];
330 int eta =
convertEtaToHW( mcParticle.
eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
333 int iso =
gRandom->Integer(4)%2;
336 if( eta>=9999 )
continue;
338 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
341 egammaVec.push_back(eg);
347 int numTauCands =
int( tau_cands_index.size() );
348 Int_t idxTau[numTauCands];
349 double tauPtSorted[numTauCands];
350 for(
int iTau=0; iTau<numTauCands; iTau++ ) tauPtSorted[iTau] = genParticles->at(tau_cands_index[iTau]).pt();
352 TMath::Sort(numTauCands,tauPtSorted,idxTau);
353 for(
int iTau=0; iTau<numTauCands; iTau++ ){
357 const reco::Candidate & mcParticle = (*genParticles)[tau_cands_index[idxTau[iTau]]];
360 int eta =
convertEtaToHW( mcParticle.
eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_);
363 int iso =
gRandom->Integer(4)%2;
366 if( eta>=9999 )
continue;
368 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
371 tauVec.push_back(
tau);
377 int maxOtherTaus = 8;
378 int numCurrentEGs =
int( egammaVec.size() );
379 int numCurrentTaus =
int( tauVec.size() );
381 int numExtraEGs=0, numExtraTaus=0;
392 for(reco::GenJetCollection::const_iterator genJet = genJets->begin(); genJet!=genJets->end(); ++genJet ){
395 sumEt += genJet->et();
402 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
405 int eta =
convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
409 if( eta>=9999 )
continue;
414 jetVec.push_back(
jet);
419 if( (numExtraEGs+numCurrentEGs)<
maxNumEGCands_ && numExtraEGs<maxOtherEGs ){
422 int EGpt =
convertPtToHW( genJet->et(), MaxLepPt_, PtStep_ );
423 int EGeta =
convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
427 int EGiso =
gRandom->Integer(4)%2;
429 l1t::EGamma eg(*p4, EGpt, EGeta, EGphi, EGqual, EGiso);
430 egammaVec.push_back(eg);
433 if( (numExtraTaus+numCurrentTaus)<
maxNumTauCands_ && numExtraTaus<maxOtherTaus ){
436 int Taupt =
convertPtToHW( genJet->et(), MaxLepPt_, PtStep_ );
437 int Taueta =
convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
440 int Tauiso =
gRandom->Integer(4)%2;
442 l1t::Tau tau(*p4, Taupt, Taueta, Tauphi, Tauqual, Tauiso);
443 tauVec.push_back(
tau);
449 LogTrace(
"GtGenToInputProducer") <<
">>> GenJets collection not found!" << std::endl;
455 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
460 l1t::EtSum etEmTotal(*p4, l1t::EtSum::EtSumType::kTotalEtEm,pt, 0, 0, 0);
464 l1t::EtSum towerCounts(*p4, l1t::EtSum::EtSumType::kTowerCount,nTowers, 0, 0, 0);
470 int hfP0val =
gRandom->Poisson(4.);
471 if(hfP0val>15) hfP0val = 15;
472 l1t::EtSum hfP0(*p4, l1t::EtSum::EtSumType::kMinBiasHFP0,hfP0val, 0, 0, 0);
474 int hfM0val =
gRandom->Poisson(4.);
475 if(hfM0val>15) hfM0val = 15;
476 l1t::EtSum hfM0(*p4, l1t::EtSum::EtSumType::kMinBiasHFM0,hfM0val, 0, 0, 0);
478 int hfP1val =
gRandom->Poisson(4.);
479 if(hfP1val>15) hfP1val = 15;
480 l1t::EtSum hfP1(*p4, l1t::EtSum::EtSumType::kMinBiasHFP1,hfP1val, 0, 0, 0);
482 int hfM1val =
gRandom->Poisson(4.);
483 if(hfM1val>15) hfM1val = 15;
484 l1t::EtSum hfM1(*p4, l1t::EtSum::EtSumType::kMinBiasHFM1,hfM1val, 0, 0, 0);
496 mpt =
convertPtToHW( genMet->front().pt(), MaxEt_, PtStep_ );
500 mptHf =
convertPtToHW( genMet->front().pt()*1.1, MaxEt_, PtStep_ );
501 mphiHf =
convertPhiToHW( genMet->front().phi()+ 3.14/7., PhiStepCalo_ );
504 mhpt =
convertPtToHW( genMet->front().pt()*0.9, MaxEt_, PtStep_ );
505 mhphi =
convertPhiToHW( genMet->front().phi()+ 3.14/5., PhiStepCalo_ );
508 LogTrace(
"GtGenToInputProducer") <<
">>> GenMet collection not found!" << std::endl;
513 l1t::EtSum etmissHF(*p4, l1t::EtSum::EtSumType::kMissingEtHF,mptHf, 0,mphiHf, 0);
517 etsumVec.push_back(etTotal);
518 etsumVec.push_back(etEmTotal);
519 etsumVec.push_back(hfP0);
520 etsumVec.push_back(htTotal);
521 etsumVec.push_back(hfM0);
522 etsumVec.push_back(etmiss);
523 etsumVec.push_back(hfP1);
524 etsumVec.push_back(htmiss);
525 etsumVec.push_back(hfM1);
526 etsumVec.push_back(etmissHF);
527 etsumVec.push_back(towerCounts);
530 if((
iEvent.id().event())%2 == 0 ) {
553 for(
int iMu=0; iMu<
int(muonVec.size()); iMu++ ){
554 muons->push_back(2, muonVec[iMu]);
575 for(
int iEG=0; iEG<
int(egammaVec.size()); iEG++ ){
576 egammas->push_back(2, egammaVec[iEG]);
597 for(
int iTau=0; iTau<
int(tauVec.size()); iTau++ ){
598 taus->push_back(2, tauVec[iTau]);
619 for(
int iJet=0; iJet<
int(jetVec.size()); iJet++ ){
620 jets->push_back(2, jetVec[iJet]);
641 for(
int iETsum=0; iETsum<
int(etsumVec.size()); iETsum++ ){
642 etsums->push_back(2, etsumVec[iETsum]);
655 extCond->push_back(2, extCond_bx);
BXVector< GlobalExtBlk > GlobalExtBlkBxCollection
void reset()
reset the content of a GlobalExtBlk
virtual int status() const =0
status word
virtual int pdgId() const =0
PDG identifier.
Abs< T >::type abs(const T &t)
void setExternalDecision(unsigned int bit, bool val)
Set decision bits.
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
virtual int charge() const =0
electric charge
isoSum
===> compute the isolation and find the most isolated track
virtual double phi() const =0
momentum azimuthal angle