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.4 by amagnan, Tue Feb 9 14:52:23 2010 UTC vs.
Revision 1.12 by amagnan, Fri Mar 26 17:52:50 2010 UTC

# Line 19 | Line 19
19   #include "DataFormats/PatCandidates/interface/MET.h"
20  
21   #include "FWCore/ServiceRegistry/interface/Service.h"
22 < #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
22 > #include "CommonTools/UtilAlgos/interface/TFileService.h"
23  
24  
25   #include "UserCode/HbbAnalysis/interface/Electron.hh"
# Line 28 | 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 35 | Line 36 | using namespace HbbAnalysis;
36  
37   HbbTreeMaker::HbbTreeMaker(const edm::ParameterSet & pset):
38    debug_(pset.getParameter<int>("DEBUG")),
39 <  processData_(pset.getParameter<bool>("ProcessData")),
39 >  processData_(false),
40    flavour_(pset.getParameter<unsigned int>("JetFlavour")),
41    doGen_(pset.getParameter<bool>("DOGEN")),
42    genParticleSrc_(pset.getParameter<edm::InputTag>("GenParticles")),
# Line 69 | 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 83 | Line 84 | void HbbTreeMaker::beginJob(const edm::E
84    if (debug_) std::cout << "Initialising JetFlavour : " << std::endl;
85  
86    lDir = lFileService->mkdir("JetFlavours");
87 <
87 <  if (!processData_) jetFlav_.Initialise(lDir, debug_, flavour_);
87 >  jetFlav_.Initialise(lDir, debug_, flavour_);
88  
89   }//beginJob
90  
# Line 107 | 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 {
# Line 135 | 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 165 | Line 172 | void HbbTreeMaker::analyze(const edm::Ev
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 205 | 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 219 | 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 233 | 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 373 | Line 385 | void HbbTreeMaker::HbbElectrons(const ed
385            lID.hOverE = (*iter).hadronicOverEm();
386            lID.deltaPhiIn = (*iter).deltaPhiSuperClusterTrackAtVtx();
387            lID.deltaEtaIn = (*iter).deltaEtaSuperClusterTrackAtVtx();
388 +          lID.ecalDrivenSeed = (*iter).ecalDrivenSeed();
389 +          lID.trackerDrivenSeed = (*iter).trackerDrivenSeed();
390  
391            HbbAnalysis::Electron lObj(lGen,lReco,lSC,lIso,lID);
392            aVec.push_back(lObj);
# Line 687 | Line 701 | void HbbTreeMaker::HbbTaus(const edm::Ha
701            const std::vector<std::pair<std::string,float> > &  lIDs = (*iter).tauIDs();
702            bool lPrint = false;
703            //a few warning if additional discriminants are found:
704 <          if ((isPF && lIDs.size() != 7) ||
704 >          if ((isPF && lIDs.size() != 16) ||
705                (isCalo && lIDs.size() != 3))
706              lPrint = true;
707  
708            if (lPrint) {
709 <            std::cout << "!!!!!!! Discriminants changed, please update histograms !!!!!!!" << std::endl;
709 >            std::cout << "!!!!!!! Discriminants changed, please update tree !!!!!!!" << std::endl;
710              std::cout << "--- isCaloTau = " << isCalo << ", isPFTau = " << isPF << std::endl;
711              std::cout << "------ ID names = " << std::endl;
712            }
# Line 711 | Line 725 | void HbbTreeMaker::HbbTaus(const edm::Ha
725            lpfId.byIsolation = 0;
726            lpfId.againstElectron = 0;
727            lpfId.againstMuon = 0;
728 +          lpfId.byIsolationUsingLeadingPion = 0;
729 +          lpfId.byTaNC = 0;
730 +          lpfId.byTaNCfrHalfPercent = 0;
731 +          lpfId.byTaNCfrOnePercent = 0;
732 +          lpfId.byTaNCfrQuarterPercent = 0;
733 +          lpfId.byTaNCfrTenthPercent = 0;
734 +          lpfId.ecalIsolationUsingLeadingPion = 0;
735 +          lpfId.leadingPionPtCut = 0;
736 +          lpfId.trackIsolationUsingLeadingPion = 0;
737  
738  
739  
# Line 725 | Line 748 | void HbbTreeMaker::HbbTaus(const edm::Ha
748              if (isPF) {
749                if (lName.find("leadingTrackFinding") != lName.npos) lpfId.byLeadingTrackFinding = lDiscri;
750                if (lName.find("leadingTrackPtCut") != lName.npos) lpfId.byLeadingTrackPtCut = lDiscri;
751 <              if (lName.find("trackIsolation") != lName.npos) lpfId.byTrackIsolation = lDiscri;
752 <              if (lName.find("ecalIsolation") != lName.npos) lpfId.byECALIsolation = lDiscri;
753 <              if (lName.find("byIsolation") != lName.npos) lpfId.byIsolation = lDiscri;
751 >              if (lName.find("trackIsolationUsingLeadingPion") != lName.npos) lpfId.trackIsolationUsingLeadingPion = lDiscri;
752 >              if (lName.find("trackIsolation") != lName.npos &&
753 >                  lName.find("trackIsolationUsingLeadingPion") == lName.npos) lpfId.byTrackIsolation = lDiscri;
754 >              if (lName.find("ecalIsolationUsingLeadingPion") != lName.npos) lpfId.ecalIsolationUsingLeadingPion = lDiscri;
755 >              if (lName.find("ecalIsolation") != lName.npos &&
756 >                  lName.find("ecalIsolationUsingLeadingPion") == lName.npos) lpfId.byECALIsolation = lDiscri;
757 >              if (lName.find("byIsolationUsingLeadingPion") != lName.npos) lpfId.byIsolationUsingLeadingPion = lDiscri;
758 >              if (lName.find("byIsolation") != lName.npos &&
759 >                  lName.find("byIsolationUsingLeadingPion") == lName.npos) lpfId.byIsolation = lDiscri;
760                if (lName.find("againstElectron") != lName.npos) lpfId.againstElectron = lDiscri;
761                if (lName.find("againstMuon") != lName.npos) lpfId.againstMuon = lDiscri;
762 +              if (lName.find("byTaNCfrHalfPercent") != lName.npos) lpfId.byTaNCfrHalfPercent = lDiscri;
763 +              if (lName.find("byTaNCfrOnePercent") != lName.npos) lpfId.byTaNCfrOnePercent = lDiscri;
764 +              if (lName.find("byTaNCfrQuarterPercent") != lName.npos) lpfId.byTaNCfrQuarterPercent = lDiscri;
765 +              if (lName.find("byTaNCfrTenthPercent") != lName.npos) lpfId.byTaNCfrTenthPercent = lDiscri;
766 +              if (lName.find("byTaNC") != lName.npos &&
767 +                  lName.find("byTaNCfr") == lName.npos) lpfId.byTaNC = lDiscri;
768 +              if (lName.find("leadingPionPtCut") != lName.npos) lpfId.leadingPionPtCut = lDiscri;
769              }
770              if (isCalo){
771                if (lName.find("byIsolation") != lName.npos) lcaloId.byIsolation = lDiscri;
# Line 914 | Line 950 | void HbbTreeMaker::HbbJets(const edm::Ha
950            lCommon.rawpT = (*iter).pt();
951            if ((*iter).hasCorrFactors())
952              lCommon.rawpT = (*iter).pt()/((*iter).corrFactor((*iter).corrStep()));
953 +
954 +          lCommon.etaMean = (*iter).etaPhiStatistics().etaMean;
955 +          lCommon.phiMean = (*iter).etaPhiStatistics().phiMean;
956 +          lCommon.etaEtaMoment = (*iter).etaPhiStatistics().etaEtaMoment;
957 +          lCommon.phiPhiMoment = (*iter).etaPhiStatistics().phiPhiMoment;
958 +          lCommon.etaPhiMoment = (*iter).etaPhiStatistics().etaPhiMoment;
959 +          
960            //lCommon.rawEta = (*iter).;
961            //lCommon.rawPhi = (*iter).;
962            //    p_hasJetCorrFactors->Fill(aJet.hasJetCorrFactors());
# Line 925 | Line 968 | void HbbTreeMaker::HbbJets(const edm::Ha
968            lBtag.bProba = (*iter).bDiscriminator("jetBProbabilityBJetTags");
969            lBtag.probability = (*iter).bDiscriminator("jetProbabilityBJetTags");
970            lBtag.sSV = (*iter).bDiscriminator("simpleSecondaryVertexBJetTags");
971 <          lBtag.softElectron = (*iter).bDiscriminator("softElectronBJetTags");
972 <          lBtag.softMuon = (*iter).bDiscriminator("softMuonBJetTags");
973 <          lBtag.softMuonNoIP = (*iter).bDiscriminator("softMuonNoIPBJetTags");
971 >          lBtag.softElectronByPt = ((*iter).bDiscriminator("softElectronByPtBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softElectronByPtBJetTags");
972 >          lBtag.softElectronByIP3d = ((*iter).bDiscriminator("softElectronByIP3dBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softElectronByIP3dBJetTags");
973 >          lBtag.softMuon = ((*iter).bDiscriminator("softMuonBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonBJetTags");
974 >          lBtag.softMuonByPt = ((*iter).bDiscriminator("softMuonByPtBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonByPtBJetTags");
975 >          lBtag.softMuonByIP3d = ((*iter).bDiscriminator("softMuonByIP3dBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonByIP3dBJetTags");
976 >
977 >          //std::cout << " -- New values of b-discri for jet : " << iEle << std::endl
978 >          //        << " ---- softElecs: " << lBtag.softElectronByPt << " " << lBtag.softElectronByIP3d << std::endl
979 >          //        << " ---- softMus: " << lBtag.softMuon << " " << lBtag.softMuonByPt << " " << lBtag.softMuonByIP3d << std::endl;
980 >
981 >
982            lBtag.tCHE = (*iter).bDiscriminator("trackCountingHighEffBJetTags");
983            lBtag.tCHP = (*iter).bDiscriminator("trackCountingHighPurBJetTags");
984 <          
984 >
985 >
986            bool isCalo = (*iter).isCaloJet();
987            bool isPF = (*iter).isPFJet();
988  
989            assert (isCalo == !isPF);
990            if (isCalo) {
991 +            HbbAnalysis::JetIDVars lId;
992 +            lId.fHPD = (*iter).jetID().fHPD;
993 +            lId.fRBX = (*iter).jetID().fRBX;
994 +            lId.n90Hits = (*iter).jetID().n90Hits;
995 +            
996              HbbAnalysis::CaloJetVars lCalo;
997              lCalo.maxEInEmTowers = (*iter).maxEInEmTowers();
998              lCalo.maxEInHadTowers = (*iter).maxEInHadTowers();
# Line 952 | Line 1009 | void HbbTreeMaker::HbbJets(const edm::Ha
1009              lCalo.n90 = (*iter).n90();
1010              lCalo.n60 = (*iter).n60();
1011  
1012 <            HbbAnalysis::Jet lObj(lGen,lGenJet,lReco,lCommon,lCalo,lBtag);
1012 >            HbbAnalysis::Jet lObj(lGen,lGenJet,lReco,lCommon,lCalo,lBtag,lId);
1013              aVec.push_back(lObj);
1014            
1015            }
# Line 978 | Line 1035 | void HbbTreeMaker::HbbJets(const edm::Ha
1035            
1036            }
1037  
1038 +
1039 +
1040            iEle++;
1041          }//loop on element
1042      }//non empty
# Line 1115 | Line 1174 | void HbbTreeMaker::HbbParticles(const ed
1174  
1175  
1176   }//genparticles
1177 +
1178 +
1179 +
1180 + void HbbTreeMaker::HbbVertices(const edm::Handle<std::vector<reco::Vertex> > & aCol,
1181 +                               std::vector<HbbAnalysis::Vertex> & aVec)
1182 + {
1183 +
1184 +  for (std::vector<reco::Vertex>::const_iterator iter = aCol->begin();
1185 +       iter != aCol->end();
1186 +       iter++)
1187 +    {
1188 +
1189 +      if (!((*iter).isValid()) || (*iter).isFake()) continue;
1190 +
1191 +      HbbAnalysis::VertexVars lVtx;
1192 +
1193 +      if ((*iter).tracksSize() > 0) {
1194 +        for (std::vector<reco::TrackBaseRef>::const_iterator lTrk = (*iter).tracks_begin();
1195 +             lTrk != (*iter).tracks_end();
1196 +             lTrk++) {
1197 +          lVtx.trackWeights.push_back((*iter).trackWeight(*lTrk));
1198 +        }
1199 +      }
1200 +
1201 +      if (lVtx.trackWeights.size() != (*iter).tracksSize()) {
1202 +        std::cout<< " -- Problem with tracks, size is not as expected ! "
1203 +                 << std::endl
1204 +                 << " --- Size of recoVertex tracks = " << (*iter).tracksSize()
1205 +                 << std::endl
1206 +                 << " --- Size of trackWeights = " << lVtx.trackWeights.size()
1207 +                 << std::endl;
1208 +      }
1209 +
1210 +      lVtx.chi2 = (*iter).chi2();
1211 +      lVtx.ndof = (*iter).ndof();
1212 +      lVtx.x = (*iter).x();
1213 +      lVtx.y = (*iter).y();
1214 +      lVtx.z = (*iter).z();
1215 +      lVtx.xError = (*iter).xError();
1216 +      lVtx.yError = (*iter).yError();
1217 +      lVtx.zError = (*iter).zError();
1218 +      lVtx.cov01 = (*iter).covariance(0,1);
1219 +      lVtx.cov02 = (*iter).covariance(0,2);
1220 +      lVtx.cov12 = (*iter).covariance(1,2);
1221 +
1222 +      HbbAnalysis::Vertex lObj(lVtx);
1223 +      aVec.push_back(lObj);
1224 +    }
1225 +
1226 + }
1227 +
1228 + #include "FWCore/Framework/interface/MakerMacros.h"
1229 + DEFINE_FWK_MODULE(HbbTreeMaker);
1230 +
1231 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines