ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HbbAnalysis/plugins/HbbTreeMaker.cc
(Generate patch)

Comparing UserCode/HbbAnalysis/plugins/HbbTreeMaker.cc (file contents):
Revision 1.1 by amagnan, Thu Sep 17 19:39:51 2009 UTC vs.
Revision 1.9 by amagnan, Tue Mar 2 12:11:54 2010 UTC

# Line 6 | Line 6
6   #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
7   #include "DataFormats/MuonReco/interface/Muon.h"
8   #include "DataFormats/MuonReco/interface/MuonFwd.h"
9 + #include "DataFormats/MuonReco/interface/MuonSelectors.h"
10   #include "DataFormats/VertexReco/interface/Vertex.h"
11   #include "DataFormats/HLTReco/interface/TriggerEvent.h"
12   #include "DataFormats/TrackReco/interface/TrackFwd.h"
# Line 27 | Line 28
28   #include "UserCode/HbbAnalysis/interface/Jet.hh"
29   #include "UserCode/HbbAnalysis/interface/Met.hh"
30   #include "UserCode/HbbAnalysis/interface/Trigger.hh"
31 + #include "UserCode/HbbAnalysis/interface/Vertex.hh"
32  
33   #include "UserCode/HbbAnalysis/plugins/HbbTreeMaker.hh"
34  
# Line 34 | Line 36 | using namespace HbbAnalysis;
36  
37   HbbTreeMaker::HbbTreeMaker(const edm::ParameterSet & pset):
38    debug_(pset.getParameter<int>("DEBUG")),
39 +  processData_(false),
40    flavour_(pset.getParameter<unsigned int>("JetFlavour")),
41    doGen_(pset.getParameter<bool>("DOGEN")),
42    genParticleSrc_(pset.getParameter<edm::InputTag>("GenParticles")),
# Line 67 | Line 70 | HbbTreeMaker::~HbbTreeMaker(){//destruct
70  
71  
72  
73 < void HbbTreeMaker::beginJob(const edm::EventSetup&){//beginJob
73 > void HbbTreeMaker::beginJob(){//beginJob
74  
75  
76    edm::Service<TFileService> lFileService;
# Line 81 | Line 84 | void HbbTreeMaker::beginJob(const edm::E
84    if (debug_) std::cout << "Initialising JetFlavour : " << std::endl;
85  
86    lDir = lFileService->mkdir("JetFlavours");
84
87    jetFlav_.Initialise(lDir, debug_, flavour_);
88  
89   }//beginJob
90  
91   void HbbTreeMaker::endJob(){//endJob
92 <  jetFlav_.printSummary();
92 >  if (!processData_) jetFlav_.printSummary();
93  
94    //tree_->Write();
95    //delete tree_;
# Line 105 | Line 107 | void HbbTreeMaker::analyze(const edm::Ev
107  
108    event_->Clear();
109    event_->event(aEvt.id().event());
110 +  processData_ = aEvt.isRealData();
111 +
112 +  event_->run(aEvt.run());
113 +  event_->lumiBlock(aEvt.luminosityBlock());
114 +  event_->isRealData(aEvt.isRealData());
115  
116    edm::Handle<reco::GenParticleCollection> lGenParticles;
117    try {
118      aEvt.getByLabel(genParticleSrc_,lGenParticles);  
119      if (debug_) std::cout << "** ngenParticles = " << lGenParticles->size() << std::endl;
120    } catch(cms::Exception& e)  {
121 <    std::cout << "AMM: Collection genParticles not available! Exception : " << e.what() << ". " << std::endl;
121 >    if (!processData_) std::cout << "AMM: Collection genParticles not available! Exception : " << e.what() << ". " << std::endl;
122    }
123  
124 <  if (doGen_) HbbParticles(lGenParticles,event_->particles());
124 >  if (doGen_ && !processData_) HbbParticles(lGenParticles,event_->particles());
125  
126 <  unsigned int lNPartons = jetFlav_.fillPartons(lGenParticles);
126 >  unsigned int lNPartons = 0;
127 >  if (!processData_) lNPartons = jetFlav_.fillPartons(lGenParticles);
128    
129 <  if (debug_) std::cout << "--- Number of partons = " << lNPartons << "." << std::endl;
129 >  if (debug_ && !processData_) std::cout << "--- Number of partons = " << lNPartons << "." << std::endl;
130  
131  
132    edm::Handle<std::vector<reco::Vertex> > lRecoVertices;
# Line 132 | Line 140 | void HbbTreeMaker::analyze(const edm::Ev
140      std::cout << "AMM: Collection " << vertexSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
141    }
142  
143 +  HbbVertices(lRecoVertices,event_->vertices());
144 +
145    edm::Handle<std::vector<pat::Electron> > lElectronCollection;
146    
147    try {
# Line 159 | Line 169 | void HbbTreeMaker::analyze(const edm::Ev
169      std::cout << "AMM: Collection " << muonSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
170    }
171  
172 <  HbbMuons(lMuonCollection,event_->muons());
172 >  HbbMuons(lMuonCollection,lRecoVertices,event_->muons());
173  
174  
175 <  edm::Handle<std::vector<pat::Tau> > lTauCollection;
175 >  if (!( caloTauSrc_.label()=="" && caloTauSrc_.instance()=="" )) {
176 >    edm::Handle<std::vector<pat::Tau> > lTauCollection;
177    
178 <  try {
179 <    aEvt.getByLabel(caloTauSrc_,lTauCollection);
180 <    if (!lTauCollection.isValid()){
181 <      edm::LogInfo("ERROR")<< "Error! Can't get caloTau by label. ";
182 <    }
183 <    if (debug_) std::cout << "** caloTaucollection = " << lTauCollection->size() << " elements." << std::endl;
184 <  } catch(cms::Exception& e)  {
185 <    std::cout << "AMM: Collection " << caloTauSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
186 <  }
178 >    try {
179 >      aEvt.getByLabel(caloTauSrc_,lTauCollection);
180 >      if (!lTauCollection.isValid()){
181 >        edm::LogInfo("ERROR")<< "Error! Can't get caloTau by label. ";
182 >      }
183 >      if (debug_) std::cout << "** caloTaucollection = " << lTauCollection->size() << " elements." << std::endl;
184 >    } catch(cms::Exception& e)  {
185 >      std::cout << "AMM: Collection " << caloTauSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
186 >    }
187  
188 <  HbbTaus(lTauCollection,lRecoVertices,event_->caloTaus());
188 >    HbbTaus(lTauCollection,lRecoVertices,event_->caloTaus());
189 >  }
190  
191    edm::Handle<std::vector<pat::Tau> > lPFTauCollection;
192    
# Line 202 | Line 214 | void HbbTreeMaker::analyze(const edm::Ev
214      std::cout << "AMM: Collection " << caloJetSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
215    }
216  
217 +  //std::cout << "Processing calo jets:" << std::endl;
218    HbbJets(lCaloJetCollection,jetFlav_,lGenParticles,event_->caloJets());
219    
220    edm::Handle<std::vector<pat::Jet> > lJptJetCollection;
# Line 216 | Line 229 | void HbbTreeMaker::analyze(const edm::Ev
229      std::cout << "AMM: Collection " << jptJetSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
230    }
231  
232 +  //std::cout << "Processing JPT jets:" << std::endl;
233    HbbJets(lJptJetCollection,jetFlav_,lGenParticles,event_->jptJets());
234    
235    edm::Handle<std::vector<pat::Jet> > lPfJetCollection;
# Line 230 | Line 244 | void HbbTreeMaker::analyze(const edm::Ev
244      std::cout << "AMM: Collection " << pfJetSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
245    }
246  
247 +  //std::cout << "Processing PF jets:" << std::endl;
248    HbbJets(lPfJetCollection,jetFlav_,lGenParticles,event_->pfJets());
249    
250    edm::Handle<std::vector<pat::MET> > lCaloMetCol;
# Line 298 | Line 313 | void HbbTreeMaker::analyze(const edm::Ev
313  
314  
315   void HbbTreeMaker::HbbElectrons(const edm::Handle<std::vector<pat::Electron> > & aCol,
316 <                           std::vector<HbbAnalysis::Electron> & aVec)
316 >                                std::vector<HbbAnalysis::Electron> & aVec)
317   {//HbbElectrons
318  
319    if (aCol.isValid()){
# Line 312 | Line 327 | void HbbTreeMaker::HbbElectrons(const ed
327            //if (debug_ > 1) std::cout << "**** Ele #" << iEle << ", pT,eta,phi =  " << (*iter).pt() << " " << (*iter).eta() << " " << (*iter).phi() << std::endl;
328  
329            HbbAnalysis::GenVars lGen;
330 <          if ((*iter).genLepton()){
330 >          if (!processData_ && (*iter).genLepton()){
331              lGen.valid = true;
332 +            lGen.E = (*iter).genLepton()->energy();
333              lGen.pT = (*iter).genLepton()->pt();
334              lGen.eta = (*iter).genLepton()->eta();
335              lGen.phi = (*iter).genLepton()->phi();
# Line 327 | Line 343 | void HbbTreeMaker::HbbElectrons(const ed
343            }
344            else {
345              lGen.valid = false;
346 +            lGen.E = 0;
347              lGen.pT = 0;
348              lGen.eta = 0;
349              lGen.phi = 0;
# Line 340 | Line 357 | void HbbTreeMaker::HbbElectrons(const ed
357            }
358  
359            HbbAnalysis::BaseVars lReco;
360 +          lReco.E = (*iter).energy();
361            lReco.pT = (*iter).pt();
362            lReco.eta = (*iter).eta();
363            lReco.phi = (*iter).phi();
# Line 379 | Line 397 | void HbbTreeMaker::HbbElectrons(const ed
397  
398  
399   void HbbTreeMaker::HbbMuons(const edm::Handle<std::vector<pat::Muon> > & aCol,
400 <                       std::vector<HbbAnalysis::Muon> & aVec)
400 >                            const edm::Handle<std::vector<reco::Vertex> > & aRecoVertices,
401 >                            std::vector<HbbAnalysis::Muon> & aVec)
402   {//HbbMuons
403  
404    if (aCol.isValid()){
# Line 393 | Line 412 | void HbbTreeMaker::HbbMuons(const edm::H
412            const reco::Muon* recoMuon = dynamic_cast<const reco::Muon*>((*iter).originalObject());
413  
414            HbbAnalysis::GenVars lGen;
415 <          if ((*iter).genLepton()){
415 >          if (!processData_ && (*iter).genLepton()){
416              lGen.valid = true;
417 +            lGen.E = (*iter).genLepton()->energy();
418              lGen.pT = (*iter).genLepton()->pt();
419              lGen.eta = (*iter).genLepton()->eta();
420              lGen.phi = (*iter).genLepton()->phi();
# Line 408 | Line 428 | void HbbTreeMaker::HbbMuons(const edm::H
428            }
429            else {
430              lGen.valid = false;
431 +            lGen.E = 0;
432              lGen.pT = 0;
433              lGen.eta = 0;
434              lGen.phi = 0;
# Line 421 | Line 442 | void HbbTreeMaker::HbbMuons(const edm::H
442            }
443  
444            HbbAnalysis::BaseVars lReco;
445 +          lReco.E = (*iter).energy();
446            lReco.pT = (*iter).pt();
447            lReco.eta = (*iter).eta();
448            lReco.phi = (*iter).phi();
# Line 429 | Line 451 | void HbbTreeMaker::HbbMuons(const edm::H
451            lReco.vy = (*iter).vy();
452            lReco.vz = (*iter).vz();
453  
454 +          HbbAnalysis::MuTrkVars lTrk;
455 +
456 +          reco::TrackRef lTrackerTrk = (*iter).innerTrack();
457 +          if ( lTrackerTrk.isAvailable() && lTrackerTrk.isNonnull() ) {
458 +            if ( aRecoVertices->size() >= 1 ) {
459 +              const reco::Vertex& thePrimaryEventVertex = (*aRecoVertices->begin());
460 +              lTrk.IPd0 = -lTrackerTrk->dxy(thePrimaryEventVertex.position());
461 +              lTrk.IPdz = lTrackerTrk->dz(thePrimaryEventVertex.position());
462 +            }
463 +            else {
464 +              lTrk.IPd0 = 0;
465 +              lTrk.IPdz = 0;
466 +            }
467 +
468 +            lTrk.nHits =  lTrackerTrk->numberOfValidHits();
469 +          }
470 +          else {
471 +            lTrk.IPd0 = 0;
472 +            lTrk.IPdz = 0;
473 +            lTrk.nHits = 0;
474 +          }
475 +
476            HbbAnalysis::MuIsoVars lIsoR03;
477            lIsoR03.sumPt = recoMuon->isolationR03().sumPt;
478            lIsoR03.emEt = recoMuon->isolationR03().emEt;
# Line 450 | Line 494 | void HbbTreeMaker::HbbMuons(const edm::H
494            else if (recoMuon->isCaloMuon()) lID.type = 4;
495            else lID.type = 0;
496  
497 <          if (recoMuon->isGood(reco::Muon::AllGlobalMuons)) lID.ids.push_back(1);
498 <          if (recoMuon->isGood(reco::Muon::AllStandAloneMuons)) lID.ids.push_back(2);
499 <          if (recoMuon->isGood(reco::Muon::AllTrackerMuons)) lID.ids.push_back(3);
500 <          if (recoMuon->isGood(reco::Muon::TrackerMuonArbitrated)) lID.ids.push_back(4);
501 <          if (recoMuon->isGood(reco::Muon::AllArbitrated)) lID.ids.push_back(5);
502 <          if (recoMuon->isGood(reco::Muon::GlobalMuonPromptTight)) lID.ids.push_back(6);
503 <          if (recoMuon->isGood(reco::Muon::TMLastStationLoose)) lID.ids.push_back(7);
504 <          if (recoMuon->isGood(reco::Muon::TMLastStationTight)) lID.ids.push_back(8);
505 <          if (recoMuon->isGood(reco::Muon::TM2DCompatibilityLoose)) lID.ids.push_back(9);
506 <          if (recoMuon->isGood(reco::Muon::TM2DCompatibilityTight)) lID.ids.push_back(10);
507 <          if (recoMuon->isGood(reco::Muon::TMOneStationLoose)) lID.ids.push_back(11);
508 <          if (recoMuon->isGood(reco::Muon::TMOneStationTight)) lID.ids.push_back(12);
509 <          if (recoMuon->isGood(reco::Muon::TMLastStationOptimizedLowPtLoose)) lID.ids.push_back(13);
510 <          if (recoMuon->isGood(reco::Muon::TMLastStationOptimizedLowPtTight)) lID.ids.push_back(14);
497 >          if (muon::isGoodMuon(*recoMuon,muon::AllGlobalMuons)) lID.ids.push_back(1);
498 >          if (muon::isGoodMuon(*recoMuon,muon::AllStandAloneMuons)) lID.ids.push_back(2);
499 >          if (muon::isGoodMuon(*recoMuon,muon::AllTrackerMuons)) lID.ids.push_back(3);
500 >          if (muon::isGoodMuon(*recoMuon,muon::TrackerMuonArbitrated)) lID.ids.push_back(4);
501 >          if (muon::isGoodMuon(*recoMuon,muon::AllArbitrated)) lID.ids.push_back(5);
502 >          if (muon::isGoodMuon(*recoMuon,muon::GlobalMuonPromptTight)) lID.ids.push_back(6);
503 >          if (muon::isGoodMuon(*recoMuon,muon::TMLastStationLoose)) lID.ids.push_back(7);
504 >          if (muon::isGoodMuon(*recoMuon,muon::TMLastStationTight)) lID.ids.push_back(8);
505 >          if (muon::isGoodMuon(*recoMuon,muon::TM2DCompatibilityLoose)) lID.ids.push_back(9);
506 >          if (muon::isGoodMuon(*recoMuon,muon::TM2DCompatibilityTight)) lID.ids.push_back(10);
507 >          if (muon::isGoodMuon(*recoMuon,muon::TMOneStationLoose)) lID.ids.push_back(11);
508 >          if (muon::isGoodMuon(*recoMuon,muon::TMOneStationTight)) lID.ids.push_back(12);
509 >          if (muon::isGoodMuon(*recoMuon,muon::TMLastStationOptimizedLowPtLoose)) lID.ids.push_back(13);
510 >          if (muon::isGoodMuon(*recoMuon,muon::TMLastStationOptimizedLowPtTight)) lID.ids.push_back(14);
511 >          if (muon::isGoodMuon(*recoMuon,muon::GMTkChiCompatibility)) lID.ids.push_back(15);
512 >          if (muon::isGoodMuon(*recoMuon,muon::GMStaChiCompatibility)) lID.ids.push_back(16);
513 >          if (muon::isGoodMuon(*recoMuon,muon::GMTkKinkTight)) lID.ids.push_back(17);
514 >          if (muon::isGoodMuon(*recoMuon,muon::TMLastStationAngLoose)) lID.ids.push_back(18);
515 >          if (muon::isGoodMuon(*recoMuon,muon::TMLastStationAngTight)) lID.ids.push_back(19);
516 >          if (muon::isGoodMuon(*recoMuon,muon::TMOneStationAngLoose)) lID.ids.push_back(20);
517 >          if (muon::isGoodMuon(*recoMuon,muon::TMOneStationAngTight)) lID.ids.push_back(21);
518 >          if (muon::isGoodMuon(*recoMuon,muon::TMLastStationOptimizedBarrelLowPtLoose)) lID.ids.push_back(22);
519 >          if (muon::isGoodMuon(*recoMuon,muon::TMLastStationOptimizedBarrelLowPtTight)) lID.ids.push_back(23);
520  
521            lID.caloCompat = recoMuon->caloCompatibility();
522 <          lID.segCompat = recoMuon->segmentCompatibility();
522 >          lID.segCompat = muon::segmentCompatibility(*recoMuon);
523            lID.nChambers = recoMuon->numberOfChambers();
524            lID.nMatchesLoose = recoMuon->numberOfMatches(reco::Muon::NoArbitration);
525            lID.nMatchesMedium = recoMuon->numberOfMatches(reco::Muon::SegmentArbitration);
526            lID.nMatchesTight = recoMuon->numberOfMatches(reco::Muon::SegmentAndTrackArbitration);
527  
528 <          HbbAnalysis::Muon lObj(lGen,lReco,lIsoR03,lIsoR05,lID);
528 >          HbbAnalysis::Muon lObj(lGen,lReco,lTrk,lIsoR03,lIsoR05,lID);
529            aVec.push_back(lObj);
530            iEle++;
531          }
# Line 482 | Line 535 | void HbbTreeMaker::HbbMuons(const edm::H
535   }//HbbMuons
536  
537   void HbbTreeMaker::HbbTaus(const edm::Handle<std::vector<pat::Tau> > & aCol,
538 <                      const edm::Handle<std::vector<reco::Vertex> > & aRecoVertices,
539 <                      std::vector<HbbAnalysis::Tau> & aVec)
538 >                           const edm::Handle<std::vector<reco::Vertex> > & aRecoVertices,
539 >                           std::vector<HbbAnalysis::Tau> & aVec)
540   {//HbbTaus
541    
542    if (aCol.isValid()){
# Line 497 | Line 550 | void HbbTreeMaker::HbbTaus(const edm::Ha
550            //if (debug_ > 1) std::cout << "**** Ele #" << iEle << ", pT,eta,phi =  " << (*iter).pt() << " " << (*iter).eta() << " " << (*iter).phi() << std::endl;
551  
552            HbbAnalysis::GenVars lGen;
553 <          if ((*iter).genLepton()){
553 >          if (!processData_ && (*iter).genLepton()){
554              lGen.valid = true;
555 +            lGen.E = (*iter).genLepton()->energy();
556              lGen.pT = (*iter).genLepton()->pt();
557              lGen.eta = (*iter).genLepton()->eta();
558              lGen.phi = (*iter).genLepton()->phi();
# Line 512 | Line 566 | void HbbTreeMaker::HbbTaus(const edm::Ha
566            }
567            else {
568              lGen.valid = false;
569 +            lGen.E = 0;
570              lGen.pT = 0;
571              lGen.eta = 0;
572              lGen.phi = 0;
# Line 526 | Line 581 | void HbbTreeMaker::HbbTaus(const edm::Ha
581  
582  
583            HbbAnalysis::GenVars lGenJet;
584 <          if ((*iter).genJet()){
584 >          if (!processData_ && (*iter).genJet()){
585              lGenJet.valid = true;
586 +            lGenJet.E = (*iter).genJet()->energy();
587              lGenJet.pT = (*iter).genJet()->pt();
588              lGenJet.eta = (*iter).genJet()->eta();
589              lGenJet.phi = (*iter).genJet()->phi();
# Line 541 | Line 597 | void HbbTreeMaker::HbbTaus(const edm::Ha
597            }
598            else {
599              lGenJet.valid = false;
600 +            lGenJet.E = 0;
601              lGenJet.pT = 0;
602              lGenJet.eta = 0;
603              lGenJet.phi = 0;
# Line 554 | Line 611 | void HbbTreeMaker::HbbTaus(const edm::Ha
611            }
612  
613            HbbAnalysis::BaseVars lReco;
614 +          lReco.E = (*iter).energy();
615            lReco.pT = (*iter).pt();
616            lReco.eta = (*iter).eta();
617            lReco.phi = (*iter).phi();
# Line 641 | Line 699 | void HbbTreeMaker::HbbTaus(const edm::Ha
699            const std::vector<std::pair<std::string,float> > &  lIDs = (*iter).tauIDs();
700            bool lPrint = false;
701            //a few warning if additional discriminants are found:
702 <          if ((isPF && lIDs.size() != 7) ||
702 >          if ((isPF && lIDs.size() != 16) ||
703                (isCalo && lIDs.size() != 3))
704              lPrint = true;
705  
706            if (lPrint) {
707 <            std::cout << "!!!!!!! Discriminants changed, please update histograms !!!!!!!" << std::endl;
707 >            std::cout << "!!!!!!! Discriminants changed, please update tree !!!!!!!" << std::endl;
708              std::cout << "--- isCaloTau = " << isCalo << ", isPFTau = " << isPF << std::endl;
709              std::cout << "------ ID names = " << std::endl;
710            }
711  
712  
655          HbbAnalysis::PFTauIDVars lpfId;
713            HbbAnalysis::CaloTauIDVars lcaloId;
714 +          lcaloId.byIsolation = 0;
715 +          lcaloId.byLeadingTrackFinding = 0;
716 +          lcaloId.byLeadingTrackPtCut = 0;
717 +
718 +          HbbAnalysis::PFTauIDVars lpfId;
719 +          lpfId.byLeadingTrackFinding = 0;
720 +          lpfId.byLeadingTrackPtCut = 0;
721 +          lpfId.byTrackIsolation = 0;
722 +          lpfId.byECALIsolation = 0;
723 +          lpfId.byIsolation = 0;
724 +          lpfId.againstElectron = 0;
725 +          lpfId.againstMuon = 0;
726 +          lpfId.byIsolationUsingLeadingPion = 0;
727 +          lpfId.byTaNC = 0;
728 +          lpfId.byTaNCfrHalfPercent = 0;
729 +          lpfId.byTaNCfrOnePercent = 0;
730 +          lpfId.byTaNCfrQuarterPercent = 0;
731 +          lpfId.byTaNCfrTenthPercent = 0;
732 +          lpfId.ecalIsolationUsingLeadingPion = 0;
733 +          lpfId.leadingPionPtCut = 0;
734 +          lpfId.trackIsolationUsingLeadingPion = 0;
735 +
736 +
737  
738            for (unsigned int id(0); id<lIDs.size(); id++){
739  
# Line 666 | Line 746 | void HbbTreeMaker::HbbTaus(const edm::Ha
746              if (isPF) {
747                if (lName.find("leadingTrackFinding") != lName.npos) lpfId.byLeadingTrackFinding = lDiscri;
748                if (lName.find("leadingTrackPtCut") != lName.npos) lpfId.byLeadingTrackPtCut = lDiscri;
749 <              if (lName.find("trackIsolation") != lName.npos) lpfId.byTrackIsolation = lDiscri;
750 <              if (lName.find("ecalIsolation") != lName.npos) lpfId.byECALIsolation = lDiscri;
751 <              if (lName.find("byIsolation") != lName.npos) lpfId.byIsolation = lDiscri;
749 >              if (lName.find("trackIsolationUsingLeadingPion") != lName.npos) lpfId.trackIsolationUsingLeadingPion = lDiscri;
750 >              if (lName.find("trackIsolation") != lName.npos &&
751 >                  lName.find("trackIsolationUsingLeadingPion") == lName.npos) lpfId.byTrackIsolation = lDiscri;
752 >              if (lName.find("ecalIsolationUsingLeadingPion") != lName.npos) lpfId.ecalIsolationUsingLeadingPion = lDiscri;
753 >              if (lName.find("ecalIsolation") != lName.npos &&
754 >                  lName.find("ecalIsolationUsingLeadingPion") == lName.npos) lpfId.byECALIsolation = lDiscri;
755 >              if (lName.find("byIsolationUsingLeadingPion") != lName.npos) lpfId.byIsolationUsingLeadingPion = lDiscri;
756 >              if (lName.find("byIsolation") != lName.npos &&
757 >                  lName.find("byIsolationUsingLeadingPion") == lName.npos) lpfId.byIsolation = lDiscri;
758                if (lName.find("againstElectron") != lName.npos) lpfId.againstElectron = lDiscri;
759                if (lName.find("againstMuon") != lName.npos) lpfId.againstMuon = lDiscri;
760 +              if (lName.find("byTaNCfrHalfPercent") != lName.npos) lpfId.byTaNCfrHalfPercent = lDiscri;
761 +              if (lName.find("byTaNCfrOnePercent") != lName.npos) lpfId.byTaNCfrOnePercent = lDiscri;
762 +              if (lName.find("byTaNCfrQuarterPercent") != lName.npos) lpfId.byTaNCfrQuarterPercent = lDiscri;
763 +              if (lName.find("byTaNCfrTenthPercent") != lName.npos) lpfId.byTaNCfrTenthPercent = lDiscri;
764 +              if (lName.find("byTaNC") != lName.npos &&
765 +                  lName.find("byTaNCfr") == lName.npos) lpfId.byTaNC = lDiscri;
766 +              if (lName.find("leadingPionPtCut") != lName.npos) lpfId.leadingPionPtCut = lDiscri;
767              }
768              if (isCalo){
769                if (lName.find("byIsolation") != lName.npos) lcaloId.byIsolation = lDiscri;
# Line 719 | Line 812 | void HbbTreeMaker::HbbTaus(const edm::Ha
812              HbbAnalysis::PFTauCandVars lNeutr;
813              lNeutr.nSigCands = (*iter).signalPFNeutrHadrCands().size();
814              lNeutr.nIsoCands = (*iter).isolationPFNeutrHadrCands().size();
815 <            lNeutr.isolationPtSum = 0;
815 >            lNeutr.isolationPtSum = (*iter).neutralHadronIso();
816  
817              HbbAnalysis::PFTauCandVars lGamma;
818              lGamma.nSigCands = (*iter).signalPFGammaCands().size();
# Line 773 | Line 866 | void HbbTreeMaker::HbbJets(const edm::Ha
866            //if (debug_ > 1) std::cout << "**** Ele #" << iEle << ", pT,eta,phi =  " << (*iter).pt() << " " << (*iter).eta() << " " << (*iter).phi() << std::endl;
867  
868            HbbAnalysis::GenVars lGen;
869 <          if ((*iter).genParton()){
869 >          if (!processData_ && (*iter).genParton()){
870              lGen.valid = true;
871 +            lGen.E = (*iter).genParton()->energy();
872              lGen.pT = (*iter).genParton()->pt();
873              lGen.eta = (*iter).genParton()->eta();
874              lGen.phi = (*iter).genParton()->phi();
# Line 788 | Line 882 | void HbbTreeMaker::HbbJets(const edm::Ha
882            }
883            else {
884              lGen.valid = false;
885 +            lGen.E = 0;
886              lGen.pT = 0;
887              lGen.eta = 0;
888              lGen.phi = 0;
# Line 802 | Line 897 | void HbbTreeMaker::HbbJets(const edm::Ha
897  
898  
899            HbbAnalysis::GenVars lGenJet;
900 <          if ((*iter).genJet()){
900 >          if (!processData_ && (*iter).genJet()){
901              lGenJet.valid = true;
902 +            lGenJet.E = (*iter).genJet()->energy();
903              lGenJet.pT = (*iter).genJet()->pt();
904              lGenJet.eta = (*iter).genJet()->eta();
905              lGenJet.phi = (*iter).genJet()->phi();
# Line 817 | Line 913 | void HbbTreeMaker::HbbJets(const edm::Ha
913            }
914            else {
915              lGenJet.valid = false;
916 +            lGenJet.E = 0;
917              lGenJet.pT = 0;
918              lGenJet.eta = 0;
919              lGenJet.phi = 0;
# Line 830 | Line 927 | void HbbTreeMaker::HbbJets(const edm::Ha
927            }
928  
929            HbbAnalysis::BaseVars lReco;
930 +          lReco.E = (*iter).energy();
931            lReco.pT = (*iter).pt();
932            lReco.eta = (*iter).eta();
933            lReco.phi = (*iter).phi();
# Line 839 | Line 937 | void HbbTreeMaker::HbbJets(const edm::Ha
937            lReco.vz = (*iter).vz();
938  
939            unsigned int lFlav = 0;
940 <          if (aJetFlav.nPartons()) {
940 >          if (!processData_ && aJetFlav.nPartons()) {
941              lFlav = aJetFlav.partonMatchingGenJet((*iter),aGenParticles,0.4).second;
942            }
943  
# Line 848 | Line 946 | void HbbTreeMaker::HbbJets(const edm::Ha
946            lCommon.partonFlavour = (*iter).partonFlavour();
947            lCommon.nAssociatedTracks = ((*iter).associatedTracks()).size();
948            lCommon.rawpT = (*iter).pt();
949 <          if ((*iter).hasJetCorrFactors())
950 <            lCommon.rawpT = (*iter).pt()/((*iter).jetCorrFactors().scaleDefault());
949 >          if ((*iter).hasCorrFactors())
950 >            lCommon.rawpT = (*iter).pt()/((*iter).corrFactor((*iter).corrStep()));
951            //lCommon.rawEta = (*iter).;
952            //lCommon.rawPhi = (*iter).;
953            //    p_hasJetCorrFactors->Fill(aJet.hasJetCorrFactors());
# Line 861 | Line 959 | void HbbTreeMaker::HbbJets(const edm::Ha
959            lBtag.bProba = (*iter).bDiscriminator("jetBProbabilityBJetTags");
960            lBtag.probability = (*iter).bDiscriminator("jetProbabilityBJetTags");
961            lBtag.sSV = (*iter).bDiscriminator("simpleSecondaryVertexBJetTags");
962 <          lBtag.softElectron = (*iter).bDiscriminator("softElectronBJetTags");
963 <          lBtag.softMuon = (*iter).bDiscriminator("softMuonBJetTags");
964 <          lBtag.softMuonNoIP = (*iter).bDiscriminator("softMuonNoIPBJetTags");
962 >          lBtag.softElectronByPt = ((*iter).bDiscriminator("softElectronByPtBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softElectronByPtBJetTags");
963 >          lBtag.softElectronByIP3d = ((*iter).bDiscriminator("softElectronByIP3dBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softElectronByIP3dBJetTags");
964 >          lBtag.softMuon = ((*iter).bDiscriminator("softMuonBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonBJetTags");
965 >          lBtag.softMuonByPt = ((*iter).bDiscriminator("softMuonByPtBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonByPtBJetTags");
966 >          lBtag.softMuonByIP3d = ((*iter).bDiscriminator("softMuonByIP3dBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonByIP3dBJetTags");
967 >
968 >          //std::cout << " -- New values of b-discri for jet : " << iEle << std::endl
969 >          //        << " ---- softElecs: " << lBtag.softElectronByPt << " " << lBtag.softElectronByIP3d << std::endl
970 >          //        << " ---- softMus: " << lBtag.softMuon << " " << lBtag.softMuonByPt << " " << lBtag.softMuonByIP3d << std::endl;
971 >
972 >
973            lBtag.tCHE = (*iter).bDiscriminator("trackCountingHighEffBJetTags");
974            lBtag.tCHP = (*iter).bDiscriminator("trackCountingHighPurBJetTags");
975 <          
975 >
976 >
977            bool isCalo = (*iter).isCaloJet();
978            bool isPF = (*iter).isPFJet();
979  
980            assert (isCalo == !isPF);
981            if (isCalo) {
982 +            HbbAnalysis::JetIDVars lId;
983 +            lId.fHPD = (*iter).jetID().fHPD;
984 +            lId.fRBX = (*iter).jetID().fRBX;
985 +            lId.n90Hits = (*iter).jetID().n90Hits;
986 +            
987              HbbAnalysis::CaloJetVars lCalo;
988              lCalo.maxEInEmTowers = (*iter).maxEInEmTowers();
989              lCalo.maxEInHadTowers = (*iter).maxEInHadTowers();
# Line 888 | Line 1000 | void HbbTreeMaker::HbbJets(const edm::Ha
1000              lCalo.n90 = (*iter).n90();
1001              lCalo.n60 = (*iter).n60();
1002  
1003 <            HbbAnalysis::Jet lObj(lGen,lGenJet,lReco,lCommon,lCalo,lBtag);
1003 >            HbbAnalysis::Jet lObj(lGen,lGenJet,lReco,lCommon,lCalo,lBtag,lId);
1004              aVec.push_back(lObj);
1005            
1006            }
# Line 914 | Line 1026 | void HbbTreeMaker::HbbJets(const edm::Ha
1026            
1027            }
1028  
1029 +
1030 +
1031            iEle++;
1032          }//loop on element
1033      }//non empty
# Line 939 | Line 1053 | void HbbTreeMaker::HbbMet(const edm::Han
1053  
1054    const reco::GenMET *lGenMET = lMet.genMET();
1055  
1056 <  if (lGenMET){
1056 >  if (!processData_ && lGenMET){
1057      lGen.mET = lGenMET->pt();
1058      lGen.mEx = lGenMET->px();
1059      lGen.mEy = lGenMET->py();
# Line 999 | Line 1113 | void HbbTreeMaker::HbbParticles(const ed
1113  
1114        HbbAnalysis::MCVars lMC;
1115        lMC.index = mccount;
1116 +      lMC.E = p.energy();
1117        lMC.pT = p.pt();
1118        lMC.eta = p.eta();
1119        lMC.phi = p.phi();
# Line 1050 | Line 1165 | void HbbTreeMaker::HbbParticles(const ed
1165  
1166  
1167   }//genparticles
1168 +
1169 +
1170 +
1171 + void HbbTreeMaker::HbbVertices(const edm::Handle<std::vector<reco::Vertex> > & aCol,
1172 +                               std::vector<HbbAnalysis::Vertex> & aVec)
1173 + {
1174 +
1175 +  for (std::vector<reco::Vertex>::const_iterator iter = aCol->begin();
1176 +       iter != aCol->end();
1177 +       iter++)
1178 +    {
1179 +
1180 +      if (!((*iter).isValid()) || (*iter).isFake()) continue;
1181 +
1182 +      HbbAnalysis::VertexVars lVtx;
1183 +
1184 +      if ((*iter).tracksSize() > 0) {
1185 +        for (std::vector<reco::TrackBaseRef>::const_iterator lTrk = (*iter).tracks_begin();
1186 +             lTrk != (*iter).tracks_end();
1187 +             lTrk++) {
1188 +          lVtx.trackWeights.push_back((*iter).trackWeight(*lTrk));
1189 +        }
1190 +      }
1191 +
1192 +      if (lVtx.trackWeights.size() != (*iter).tracksSize()) {
1193 +        std::cout<< " -- Problem with tracks, size is not as expected ! "
1194 +                 << std::endl
1195 +                 << " --- Size of recoVertex tracks = " << (*iter).tracksSize()
1196 +                 << std::endl
1197 +                 << " --- Size of trackWeights = " << lVtx.trackWeights.size()
1198 +                 << std::endl;
1199 +      }
1200 +
1201 +      lVtx.chi2 = (*iter).chi2();
1202 +      lVtx.ndof = (*iter).ndof();
1203 +      lVtx.x = (*iter).x();
1204 +      lVtx.y = (*iter).y();
1205 +      lVtx.z = (*iter).z();
1206 +      lVtx.xError = (*iter).xError();
1207 +      lVtx.yError = (*iter).yError();
1208 +      lVtx.zError = (*iter).zError();
1209 +      lVtx.cov01 = (*iter).covariance(0,1);
1210 +      lVtx.cov02 = (*iter).covariance(0,2);
1211 +      lVtx.cov12 = (*iter).covariance(1,2);
1212 +
1213 +      HbbAnalysis::Vertex lObj(lVtx);
1214 +      aVec.push_back(lObj);
1215 +    }
1216 +
1217 + }
1218 +
1219 + #include "FWCore/Framework/interface/MakerMacros.h"
1220 + DEFINE_FWK_MODULE(HbbTreeMaker);
1221 +
1222 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines