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;
300 if( eta>=9999 )
continue;
302 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *
p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
304 l1t::Muon mu(*p4, pt, eta, phi, qual, charge, chargeValid, iso, mip, tag);
305 muonVec.push_back(
mu);
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();
315 TMath::Sort(numEgCands,egPtSorted,idxEg);
316 for(
int iEg=0; iEg<numEgCands; iEg++ ){
320 const reco::Candidate & mcParticle = (*genParticles)[eg_cands_index[idxEg[iEg]]];
323 int eta =
convertEtaToHW( mcParticle.
eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
326 int iso =
gRandom->Integer(4)%2;
329 if( eta>=9999 )
continue;
331 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
334 egammaVec.push_back(eg);
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();
345 TMath::Sort(numTauCands,tauPtSorted,idxTau);
346 for(
int iTau=0; iTau<numTauCands; iTau++ ){
350 const reco::Candidate & mcParticle = (*genParticles)[tau_cands_index[idxTau[iTau]]];
353 int eta =
convertEtaToHW( mcParticle.
eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_);
356 int iso =
gRandom->Integer(4)%2;
359 if( eta>=9999 )
continue;
361 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
364 tauVec.push_back(
tau);
370 int maxOtherTaus = 8;
371 int numCurrentEGs = int( egammaVec.size() );
372 int numCurrentTaus = int( tauVec.size() );
374 int numExtraEGs=0, numExtraTaus=0;
385 for(reco::GenJetCollection::const_iterator genJet = genJets->begin(); genJet!=genJets->end(); ++genJet ){
388 sumEt += genJet->et();
395 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
398 int eta =
convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
402 if( eta>=9999 )
continue;
407 jetVec.push_back(
jet);
412 if( (numExtraEGs+numCurrentEGs)<
maxNumEGCands_ && numExtraEGs<maxOtherEGs ){
415 int EGpt =
convertPtToHW( genJet->et(), MaxLepPt_, PtStep_ );
416 int EGeta =
convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
420 int EGiso =
gRandom->Integer(4)%2;
422 l1t::EGamma eg(*p4, EGpt, EGeta, EGphi, EGqual, EGiso);
423 egammaVec.push_back(eg);
426 if( (numExtraTaus+numCurrentTaus)<
maxNumTauCands_ && numExtraTaus<maxOtherTaus ){
429 int Taupt =
convertPtToHW( genJet->et(), MaxLepPt_, PtStep_ );
430 int Taueta =
convertEtaToHW( genJet->eta(), -MaxCaloEta_, MaxCaloEta_, EtaStepCalo_ );
433 int Tauiso =
gRandom->Integer(4)%2;
435 l1t::Tau tau(*p4, Taupt, Taueta, Tauphi, Tauqual, Tauiso);
436 tauVec.push_back(
tau);
442 LogTrace(
"GtGenToInputProducer") <<
">>> GenJets collection not found!" << std::endl;
449 int pt =
convertPtToHW( genMet->front().pt(), MaxEt_, PtStep_ );
452 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
456 etsumVec.push_back(etmiss);
459 pt =
convertPtToHW( genMet->front().pt()*0.9, MaxEt_, PtStep_ );
460 phi =
convertPhiToHW( genMet->front().phi()+ 3.14/5., PhiStepCalo_ );
463 etsumVec.push_back(htmiss);
468 LogTrace(
"GtGenToInputProducer") <<
">>> GenMet collection not found!" << std::endl;
474 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =
new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
476 etsumVec.push_back(etTotal);
480 etsumVec.push_back(htTotal);
483 int hfP0val =
gRandom->Poisson(4.);
484 if(hfP0val>15) hfP0val = 15;
485 l1t::EtSum hfP0(*p4, l1t::EtSum::EtSumType::kMinBiasHFP0,hfP0val, 0, 0, 0);
486 etsumVec.push_back(hfP0);
488 int hfM0val =
gRandom->Poisson(4.);
489 if(hfM0val>15) hfM0val = 15;
490 l1t::EtSum hfM0(*p4, l1t::EtSum::EtSumType::kMinBiasHFM0,hfM0val, 0, 0, 0);
491 etsumVec.push_back(hfM0);
493 int hfP1val =
gRandom->Poisson(4.);
494 if(hfP1val>15) hfP1val = 15;
495 l1t::EtSum hfP1(*p4, l1t::EtSum::EtSumType::kMinBiasHFP1,hfP1val, 0, 0, 0);
496 etsumVec.push_back(hfP1);
498 int hfM1val =
gRandom->Poisson(4.);
499 if(hfM1val>15) hfM1val = 15;
500 l1t::EtSum hfM1(*p4, l1t::EtSum::EtSumType::kMinBiasHFM1,hfM1val, 0, 0, 0);
501 etsumVec.push_back(hfM1);
506 if((iEvent.
id().
event())%2 == 0 ) {
522 for(
int iMu=0; iMu<int(
muonVec_bx0.size()); iMu++ ){
529 for(
int iMu=0; iMu<int(muonVec.size()); iMu++ ){
530 muons->push_back(2, muonVec[iMu]);
551 for(
int iEG=0; iEG<int(egammaVec.size()); iEG++ ){
552 egammas->push_back(2, egammaVec[iEG]);
560 for(
int iTau=0; iTau<int(
tauVec_bxm2.size()); iTau++ ){
563 for(
int iTau=0; iTau<int(
tauVec_bxm1.size()); iTau++ ){
566 for(
int iTau=0; iTau<int(
tauVec_bx0.size()); iTau++ ){
569 for(
int iTau=0; iTau<int(
tauVec_bxp1.size()); iTau++ ){
573 for(
int iTau=0; iTau<int(tauVec.size()); iTau++ ){
574 taus->push_back(2, tauVec[iTau]);
582 for(
int iJet=0; iJet<int(
jetVec_bxm2.size()); iJet++ ){
585 for(
int iJet=0; iJet<int(
jetVec_bxm1.size()); iJet++ ){
588 for(
int iJet=0; iJet<int(
jetVec_bx0.size()); iJet++ ){
591 for(
int iJet=0; iJet<int(
jetVec_bxp1.size()); iJet++ ){
595 for(
int iJet=0; iJet<int(jetVec.size()); iJet++ ){
596 jets->push_back(2, jetVec[iJet]);
604 for(
int iETsum=0; iETsum<int(
etsumVec_bxm2.size()); iETsum++ ){
607 for(
int iETsum=0; iETsum<int(
etsumVec_bxm1.size()); iETsum++ ){
610 for(
int iETsum=0; iETsum<int(
etsumVec_bx0.size()); iETsum++ ){
613 for(
int iETsum=0; iETsum<int(
etsumVec_bxp1.size()); iETsum++ ){
617 for(
int iETsum=0; iETsum<int(etsumVec.size()); iETsum++ ){
618 etsums->push_back(2, etsumVec[iETsum]);
631 extCond->push_back(2, extCond_bx);
EventNumber_t event() const
BXVector< GlobalExtBlk > GlobalExtBlkBxCollection
void reset()
reset the content of a GlobalExtBlk
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual double pt() const =0
transverse momentum
virtual int status() const =0
status word
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Abs< T >::type abs(const T &t)
virtual int charge() const =0
electric charge
void setExternalDecision(unsigned int bit, bool val)
Set decision bits.
virtual int pdgId() const =0
PDG identifier.
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity