8 |
|
#include "DataFormats/HepMCCandidate/interface/GenParticle.h" |
9 |
|
#include "DataFormats/GeometryVector/interface/GlobalPoint.h" |
10 |
|
#include "DataFormats/JetReco/interface/GenJet.h" |
11 |
+ |
#include "DataFormats/JetReco/interface/Jet.h" |
12 |
|
#include "SimDataFormats/GeneratorProducts/interface/GenRunInfoProduct.h" |
13 |
|
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" |
14 |
|
#include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h" |
30 |
|
genParticleSrc_(pset.getParameter<edm::InputTag>("GenParticles")), |
31 |
|
genJetSrc_(pset.getParameter<edm::InputTag>("GenJets")), |
32 |
|
partonJetSrc_(pset.getParameter<edm::InputTag>("PartonJets")), |
33 |
+ |
pfJetSrc_(pset.getParameter<edm::InputTag>("PFJets")), |
34 |
|
status1ToKeep_(pset.getParameter<std::vector<std::string> >("Status1ToKeep")), |
35 |
|
status2ToKeep_(pset.getParameter<std::vector<std::string> >("Status2ToKeep")), |
36 |
|
status3ToKeep_(pset.getParameter<std::vector<std::string> >("Status3ToKeep")), |
162 |
|
//if (doGen_) HbbParticles(lGenParticles,event_->particles()); |
163 |
|
HbbParticles(lGenParticles,event_->particles(), event_->p4total()); |
164 |
|
|
165 |
+ |
edm::Handle<std::vector<pat::Jet> > lPfJetCollection; |
166 |
+ |
|
167 |
+ |
try { |
168 |
+ |
aEvt.getByLabel(pfJetSrc_,lPfJetCollection); |
169 |
+ |
if (!lPfJetCollection.isValid()){ |
170 |
+ |
edm::LogInfo("ERROR")<< "Error! Can't get pfJets by label. "; |
171 |
+ |
} |
172 |
+ |
if (debug_) std::cout << "** pfJetcollection = " << lPfJetCollection->size() << " elements." << std::endl; |
173 |
+ |
} catch(cms::Exception& e) { |
174 |
+ |
std::cout << "AMM: Collection " << pfJetSrc_ << " not available! Exception : " << e.what() << ". " << std::endl; |
175 |
+ |
} |
176 |
+ |
|
177 |
+ |
//std::cout << "Processing PF jets:" << std::endl; |
178 |
+ |
HbbJets(lPfJetCollection,lGenParticles,event_->pfjets()); |
179 |
+ |
|
180 |
|
|
181 |
|
tree_->Fill(); |
182 |
|
firstEvent = false; |
290 |
|
}//loop on particles |
291 |
|
|
292 |
|
|
293 |
< |
if (debug_>1){ |
293 |
> |
if (debug_>2){ |
294 |
|
for (unsigned int imc(0); imc < aVec.size(); ++imc){ |
295 |
|
HbbAnalysis::GenParticle & p = aVec.at(imc); |
296 |
|
p.Print(); |
431 |
|
|
432 |
|
}//loop on particles |
433 |
|
|
434 |
< |
if (debug_>1){ |
434 |
> |
if (debug_>2){ |
435 |
|
for (unsigned int imc(0); imc < aVec.size(); ++imc){ |
436 |
|
//HbbAnalysis::GenParticle & p = aVec.at(imc); |
437 |
|
//p.print(); |
439 |
|
} |
440 |
|
} |
441 |
|
|
442 |
+ |
|
443 |
+ |
void MCTreeMaker::HbbJets(const edm::Handle<std::vector<pat::Jet> > & aCol, |
444 |
+ |
const edm::Handle<reco::GenParticleCollection> & aGenParticles, |
445 |
+ |
std::vector<HbbAnalysis::Jet> & aVec) |
446 |
+ |
{//HbbJets |
447 |
+ |
|
448 |
+ |
if (aCol.isValid()){//valid |
449 |
+ |
if (aCol->size() > 0) {//non empty |
450 |
+ |
|
451 |
+ |
unsigned int iEle = 0; |
452 |
+ |
for (std::vector<pat::Jet>::const_iterator iter = aCol->begin(); |
453 |
+ |
iter != aCol->end(); |
454 |
+ |
++iter,++iEle) |
455 |
+ |
{//loop on element |
456 |
+ |
if (debug_ > 1) std::cout << "**** Ele #" << iEle << ", pT,eta,phi = " << (*iter).pt() << " " << (*iter).eta() << " " << (*iter).phi() << std::endl; |
457 |
+ |
|
458 |
+ |
//---------------------------------------------------------------------- |
459 |
+ |
HbbAnalysis::FourMomentum lFourVec; |
460 |
+ |
//---------------------------------------------------------------------- |
461 |
+ |
lFourVec.e = (*iter).energy(); |
462 |
+ |
lFourVec.px = (*iter).px(); |
463 |
+ |
lFourVec.py = (*iter).py(); |
464 |
+ |
lFourVec.pz = (*iter).pz(); |
465 |
+ |
//---------------------------------------------------------------------- |
466 |
+ |
HbbAnalysis::JetVars lJet; |
467 |
+ |
//---------------------------------------------------------------------- |
468 |
+ |
lJet.partonFlavour = (*iter).partonFlavour(); |
469 |
+ |
lJet.nAssociatedTracks = ((*iter).associatedTracks()).size(); |
470 |
+ |
lJet.etaMean = (*iter).etaPhiStatistics().etaMean; |
471 |
+ |
lJet.phiMean = (*iter).etaPhiStatistics().phiMean; |
472 |
+ |
lJet.etaEtaMoment = (*iter).etaPhiStatistics().etaEtaMoment; |
473 |
+ |
lJet.phiPhiMoment = (*iter).etaPhiStatistics().phiPhiMoment; |
474 |
+ |
lJet.etaPhiMoment = (*iter).etaPhiStatistics().etaPhiMoment; |
475 |
+ |
//Construct a GenParticle if processing MC and a match has been found by PAT |
476 |
+ |
if ((*iter).genParton()){ |
477 |
+ |
HbbAnalysis::FourMomentum lGenFourVec; |
478 |
+ |
HbbAnalysis::GenVars lGen; |
479 |
+ |
lGenFourVec.px = (*iter).genParton()->px(); |
480 |
+ |
lGenFourVec.py = (*iter).genParton()->py(); |
481 |
+ |
lGenFourVec.pz = (*iter).genParton()->pz(); |
482 |
+ |
lGenFourVec.e = (*iter).genParton()->energy(); |
483 |
+ |
lGen.charge = (*iter).genParton()->charge(); |
484 |
+ |
lGen.pdgId = (*iter).genParton()->pdgId(); |
485 |
+ |
lGen.status = (*iter).genParton()->status(); |
486 |
+ |
lGen.vertex.vx = (*iter).genParton()->vx(); |
487 |
+ |
lGen.vertex.vy = (*iter).genParton()->vy(); |
488 |
+ |
lGen.vertex.vz = (*iter).genParton()->vz(); |
489 |
+ |
lJet.genMatches.push_back(HbbAnalysis::GenParticle(lGenFourVec, lGen)); |
490 |
+ |
} |
491 |
+ |
//Construct a GenJet if processing MC and a match has been found by PAT |
492 |
+ |
if ((*iter).genJet()){ |
493 |
+ |
HbbAnalysis::FourMomentum lGenJetFourVec; |
494 |
+ |
HbbAnalysis::GenJetVars lGenJet; |
495 |
+ |
lGenJetFourVec.px = (*iter).genJet()->px(); |
496 |
+ |
lGenJetFourVec.py = (*iter).genJet()->py(); |
497 |
+ |
lGenJetFourVec.pz = (*iter).genJet()->pz(); |
498 |
+ |
lGenJetFourVec.e = (*iter).genJet()->energy(); |
499 |
+ |
lGenJet.flavour = 0; //Flavour unknown in this context (will be filled for parton jets) |
500 |
+ |
lGenJet.mass = (*iter).genJet()->mass(); |
501 |
+ |
lGenJet.nConstituents = (*iter).genJet()->getGenConstituents().size(); |
502 |
+ |
lJet.genJetMatches.push_back(HbbAnalysis::GenJet(lGenJetFourVec, lGenJet)); |
503 |
+ |
} |
504 |
+ |
|
505 |
+ |
HbbAnalysis::JetECorVars lEnergyCorrections; |
506 |
+ |
if ((*iter).jecSetsAvailable()){ |
507 |
+ |
std::vector<std::string> lJECnames = (*iter).availableJECSets(); |
508 |
+ |
for (unsigned int iSet(0); iSet < lJECnames.size(); ++iSet){ |
509 |
+ |
if (debug_>1) std::cout << " -- JEC SET " << iSet << " " << lJECnames[iSet] << std::endl; |
510 |
+ |
std::vector<std::string> lJEClevels = (*iter).availableJECLevels(iSet); |
511 |
+ |
for (unsigned int iLev(0); iLev<lJEClevels.size(); ++iLev){ |
512 |
+ |
if (debug_>1) std::cout << " ---- JEC level " << iLev << " " << lJEClevels[iLev] |
513 |
+ |
<< " , factor = " << (*iter).jecFactor(iLev,pat::JetCorrFactors::NONE,iSet) |
514 |
+ |
<< std::endl; |
515 |
+ |
lEnergyCorrections.Levels[(lJEClevels[iLev])] = (*iter).jecFactor(iLev,pat::JetCorrFactors::NONE,iSet); |
516 |
+ |
} |
517 |
+ |
} |
518 |
+ |
} |
519 |
+ |
|
520 |
+ |
HbbAnalysis::JetBtagVars lBtag; |
521 |
+ |
if (debug_>1) { |
522 |
+ |
const std::vector<std::pair<std::string, float> > & lDiscris = (*iter).getPairDiscri(); |
523 |
+ |
std::cout << " -- btaggers: " << lDiscris.size() << " elements" |
524 |
+ |
<< std::endl; |
525 |
+ |
for (unsigned int iD(0); iD<lDiscris.size(); ++iD){ |
526 |
+ |
std::cout << "---- " << iD << " " << lDiscris[iD].first << std::endl; |
527 |
+ |
} |
528 |
+ |
} |
529 |
+ |
|
530 |
+ |
lBtag.cSV = (*iter).bDiscriminator("combinedSecondaryVertexBJetTags"); |
531 |
+ |
lBtag.cSVMVA = (*iter).bDiscriminator("combinedSecondaryVertexMVABJetTags"); |
532 |
+ |
//lBtag.iPMVA = (*iter).bDiscriminator("impactParameterMVABJetTags"); |
533 |
+ |
lBtag.bProba = (*iter).bDiscriminator("jetBProbabilityBJetTags"); |
534 |
+ |
lBtag.probability = (*iter).bDiscriminator("jetProbabilityBJetTags"); |
535 |
+ |
lBtag.sSVHP = (*iter).bDiscriminator("simpleSecondaryVertexHighPurBJetTags"); |
536 |
+ |
lBtag.sSVHE = (*iter).bDiscriminator("simpleSecondaryVertexHighEffBJetTags"); |
537 |
+ |
//lBtag.softElectronByPt = ((*iter).bDiscriminator("softElectronByPtBJetTags") < -100) ? -100 : (*iter).bDiscriminator("softElectronByPtBJetTags"); |
538 |
+ |
//lBtag.softElectronByIP3d = ((*iter).bDiscriminator("softElectronByIP3dBJetTags") < -100) ? -100 : (*iter).bDiscriminator("softElectronByIP3dBJetTags"); |
539 |
+ |
lBtag.softMuon = ((*iter).bDiscriminator("softMuonBJetTags") < -100) ? -100 : (*iter).bDiscriminator("softMuonBJetTags"); |
540 |
+ |
lBtag.softMuonByPt = ((*iter).bDiscriminator("softMuonByPtBJetTags") < -100) ? -100 : (*iter).bDiscriminator("softMuonByPtBJetTags"); |
541 |
+ |
lBtag.softMuonByIP3d = ((*iter).bDiscriminator("softMuonByIP3dBJetTags") < -100) ? -100 : (*iter).bDiscriminator("softMuonByIP3dBJetTags"); |
542 |
+ |
lBtag.tCHE = (*iter).bDiscriminator("trackCountingHighEffBJetTags"); |
543 |
+ |
lBtag.tCHP = (*iter).bDiscriminator("trackCountingHighPurBJetTags"); |
544 |
+ |
|
545 |
+ |
//std::cout << " -- New values of b-discri for jet : " << iEle << std::endl |
546 |
+ |
// << " ---- softElecs: " << lBtag.softElectronByPt << " " << lBtag.softElectronByIP3d << std::endl |
547 |
+ |
// << " ---- softMus: " << lBtag.softMuon << " " << lBtag.softMuonByPt << " " << lBtag.softMuonByIP3d << std::endl; |
548 |
+ |
|
549 |
+ |
if (debug_>1) { |
550 |
+ |
std::cout << " -- Filling tag info variables : " |
551 |
+ |
<< (*iter).hasTagInfo("SecondaryVertex") |
552 |
+ |
<< std::endl; |
553 |
+ |
} |
554 |
+ |
|
555 |
+ |
std::vector<HbbAnalysis::JetSecVertexVars> jetSecVertexVars; |
556 |
+ |
|
557 |
+ |
for (unsigned iVtx = 0; iVtx < (*iter).tagInfoSecondaryVertex()->nVertices(); ++iVtx){ |
558 |
+ |
HbbAnalysis::JetSecVertexVars jetSecVertexVarsTmp; |
559 |
+ |
math::XYZTLorentzVectorD vec = (*iter).tagInfoSecondaryVertex()->secondaryVertex(iVtx).p4(); |
560 |
+ |
jetSecVertexVarsTmp.fourVec.e = vec.E(); |
561 |
+ |
jetSecVertexVarsTmp.fourVec.px = vec.Px(); |
562 |
+ |
jetSecVertexVarsTmp.fourVec.py = vec.Py(); |
563 |
+ |
jetSecVertexVarsTmp.fourVec.pz = vec.Pz(); |
564 |
+ |
jetSecVertexVarsTmp.vertex.vx = (*iter).tagInfoSecondaryVertex()->secondaryVertex(iVtx).x(); |
565 |
+ |
jetSecVertexVarsTmp.vertex.vy = (*iter).tagInfoSecondaryVertex()->secondaryVertex(iVtx).y(); |
566 |
+ |
jetSecVertexVarsTmp.vertex.vz = (*iter).tagInfoSecondaryVertex()->secondaryVertex(iVtx).z(); |
567 |
+ |
jetSecVertexVars.push_back(jetSecVertexVarsTmp); |
568 |
+ |
} |
569 |
+ |
|
570 |
+ |
|
571 |
+ |
bool isPF = (*iter).isPFJet(); |
572 |
+ |
if (debug_>1) { |
573 |
+ |
std::cout << " -- Filling JPTPF jet variables " << std::endl; |
574 |
+ |
} |
575 |
+ |
|
576 |
+ |
HbbAnalysis::JPTPFJetVars lJPTPF; |
577 |
+ |
if (isPF){ |
578 |
+ |
lJPTPF.chargedEmEnergy = (*iter).chargedEmEnergy(); |
579 |
+ |
lJPTPF.neutralEmEnergy = (*iter).neutralEmEnergy(); |
580 |
+ |
lJPTPF.muonMultiplicity = (*iter).muonMultiplicity(); |
581 |
+ |
lJPTPF.chargedHadronEnergy = (*iter).chargedHadronEnergy(); |
582 |
+ |
lJPTPF.neutralHadronEnergy = (*iter).neutralHadronEnergy(); |
583 |
+ |
lJPTPF.chargedMultiplicity = (*iter).chargedMultiplicity(); |
584 |
+ |
lJPTPF.chargedHadronEnergyFraction = (*iter).chargedHadronEnergyFraction(); |
585 |
+ |
lJPTPF.neutralHadronEnergyFraction = (*iter).neutralHadronEnergyFraction(); |
586 |
+ |
lJPTPF.chargedEmEnergyFraction = (*iter).chargedEmEnergyFraction(); |
587 |
+ |
lJPTPF.neutralEmEnergyFraction = (*iter).neutralEmEnergyFraction(); |
588 |
+ |
} |
589 |
+ |
if (debug_>1) { |
590 |
+ |
std::cout << " -- Filling PF jet variables " << std::endl; |
591 |
+ |
} |
592 |
+ |
if (isPF) { |
593 |
+ |
HbbAnalysis::PFJetVars lPF; |
594 |
+ |
lPF.chargedMuEnergy = (*iter).chargedMuEnergy(); |
595 |
+ |
lPF.chargedMuEnergyFraction = (*iter).chargedMuEnergyFraction(); |
596 |
+ |
lPF.neutralMultiplicity = (*iter).neutralMultiplicity(); |
597 |
+ |
lPF.numberOfDaughters = (*iter).numberOfDaughters(); |
598 |
+ |
lPF.HFHadronEnergy = (*iter).HFHadronEnergy(); |
599 |
+ |
|
600 |
+ |
HbbAnalysis::Jet lObj(lFourVec,lJet,lPF,lJPTPF,lBtag,lEnergyCorrections); |
601 |
+ |
lObj.secVertexVars(jetSecVertexVars); |
602 |
+ |
aVec.push_back(lObj); |
603 |
+ |
} |
604 |
+ |
|
605 |
+ |
if (debug_>1) { |
606 |
+ |
std::cout << " -- Element added. " << std::endl; |
607 |
+ |
} |
608 |
+ |
|
609 |
+ |
}//loop on element |
610 |
+ |
}//non empty |
611 |
+ |
}//valid |
612 |
+ |
|
613 |
+ |
}//HbbJets |
614 |
+ |
|
615 |
+ |
|
616 |
|
#include "FWCore/Framework/interface/MakerMacros.h" |
617 |
|
DEFINE_FWK_MODULE(MCTreeMaker); |
618 |
|
|