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.7 by amagnan, Wed Feb 10 18:17:17 2010 UTC

# 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  
115    edm::Handle<reco::GenParticleCollection> lGenParticles;
116    try {
# Line 135 | Line 139 | void HbbTreeMaker::analyze(const edm::Ev
139      std::cout << "AMM: Collection " << vertexSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
140    }
141  
142 +  HbbVertices(lRecoVertices,event_->vertices());
143 +
144    edm::Handle<std::vector<pat::Electron> > lElectronCollection;
145    
146    try {
# Line 165 | Line 171 | void HbbTreeMaker::analyze(const edm::Ev
171    HbbMuons(lMuonCollection,lRecoVertices,event_->muons());
172  
173  
174 <  edm::Handle<std::vector<pat::Tau> > lTauCollection;
174 >  if (!( caloTauSrc_.label()=="" && caloTauSrc_.instance()=="" )) {
175 >    edm::Handle<std::vector<pat::Tau> > lTauCollection;
176    
177 <  try {
178 <    aEvt.getByLabel(caloTauSrc_,lTauCollection);
179 <    if (!lTauCollection.isValid()){
180 <      edm::LogInfo("ERROR")<< "Error! Can't get caloTau by label. ";
181 <    }
182 <    if (debug_) std::cout << "** caloTaucollection = " << lTauCollection->size() << " elements." << std::endl;
183 <  } catch(cms::Exception& e)  {
184 <    std::cout << "AMM: Collection " << caloTauSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
185 <  }
177 >    try {
178 >      aEvt.getByLabel(caloTauSrc_,lTauCollection);
179 >      if (!lTauCollection.isValid()){
180 >        edm::LogInfo("ERROR")<< "Error! Can't get caloTau by label. ";
181 >      }
182 >      if (debug_) std::cout << "** caloTaucollection = " << lTauCollection->size() << " elements." << std::endl;
183 >    } catch(cms::Exception& e)  {
184 >      std::cout << "AMM: Collection " << caloTauSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
185 >    }
186  
187 <  HbbTaus(lTauCollection,lRecoVertices,event_->caloTaus());
187 >    HbbTaus(lTauCollection,lRecoVertices,event_->caloTaus());
188 >  }
189  
190    edm::Handle<std::vector<pat::Tau> > lPFTauCollection;
191    
# Line 205 | Line 213 | void HbbTreeMaker::analyze(const edm::Ev
213      std::cout << "AMM: Collection " << caloJetSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
214    }
215  
216 +  //std::cout << "Processing calo jets:" << std::endl;
217    HbbJets(lCaloJetCollection,jetFlav_,lGenParticles,event_->caloJets());
218    
219    edm::Handle<std::vector<pat::Jet> > lJptJetCollection;
# Line 219 | Line 228 | void HbbTreeMaker::analyze(const edm::Ev
228      std::cout << "AMM: Collection " << jptJetSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
229    }
230  
231 +  //std::cout << "Processing JPT jets:" << std::endl;
232    HbbJets(lJptJetCollection,jetFlav_,lGenParticles,event_->jptJets());
233    
234    edm::Handle<std::vector<pat::Jet> > lPfJetCollection;
# Line 233 | Line 243 | void HbbTreeMaker::analyze(const edm::Ev
243      std::cout << "AMM: Collection " << pfJetSrc_  << " not available! Exception : " << e.what() << ". " << std::endl;
244    }
245  
246 +  //std::cout << "Processing PF jets:" << std::endl;
247    HbbJets(lPfJetCollection,jetFlav_,lGenParticles,event_->pfJets());
248    
249    edm::Handle<std::vector<pat::MET> > lCaloMetCol;
# Line 687 | Line 698 | void HbbTreeMaker::HbbTaus(const edm::Ha
698            const std::vector<std::pair<std::string,float> > &  lIDs = (*iter).tauIDs();
699            bool lPrint = false;
700            //a few warning if additional discriminants are found:
701 <          if ((isPF && lIDs.size() != 7) ||
701 >          if ((isPF && lIDs.size() != 16) ||
702                (isCalo && lIDs.size() != 3))
703              lPrint = true;
704  
705            if (lPrint) {
706 <            std::cout << "!!!!!!! Discriminants changed, please update histograms !!!!!!!" << std::endl;
706 >            std::cout << "!!!!!!! Discriminants changed, please update tree !!!!!!!" << std::endl;
707              std::cout << "--- isCaloTau = " << isCalo << ", isPFTau = " << isPF << std::endl;
708              std::cout << "------ ID names = " << std::endl;
709            }
# Line 711 | Line 722 | void HbbTreeMaker::HbbTaus(const edm::Ha
722            lpfId.byIsolation = 0;
723            lpfId.againstElectron = 0;
724            lpfId.againstMuon = 0;
725 +          lpfId.byIsolationUsingLeadingPion = 0;
726 +          lpfId.byTaNC = 0;
727 +          lpfId.byTaNCfrHalfPercent = 0;
728 +          lpfId.byTaNCfrOnePercent = 0;
729 +          lpfId.byTaNCfrQuarterPercent = 0;
730 +          lpfId.byTaNCfrTenthPercent = 0;
731 +          lpfId.ecalIsolationUsingLeadingPion = 0;
732 +          lpfId.leadingPionPtCut = 0;
733 +          lpfId.trackIsolationUsingLeadingPion = 0;
734  
735  
736  
# Line 725 | Line 745 | void HbbTreeMaker::HbbTaus(const edm::Ha
745              if (isPF) {
746                if (lName.find("leadingTrackFinding") != lName.npos) lpfId.byLeadingTrackFinding = lDiscri;
747                if (lName.find("leadingTrackPtCut") != lName.npos) lpfId.byLeadingTrackPtCut = lDiscri;
748 <              if (lName.find("trackIsolation") != lName.npos) lpfId.byTrackIsolation = lDiscri;
749 <              if (lName.find("ecalIsolation") != lName.npos) lpfId.byECALIsolation = lDiscri;
750 <              if (lName.find("byIsolation") != lName.npos) lpfId.byIsolation = lDiscri;
748 >              if (lName.find("trackIsolationUsingLeadingPion") != lName.npos) lpfId.trackIsolationUsingLeadingPion = lDiscri;
749 >              if (lName.find("trackIsolation") != lName.npos &&
750 >                  lName.find("trackIsolationUsingLeadingPion") == lName.npos) lpfId.byTrackIsolation = lDiscri;
751 >              if (lName.find("ecalIsolationUsingLeadingPion") != lName.npos) lpfId.ecalIsolationUsingLeadingPion = lDiscri;
752 >              if (lName.find("ecalIsolation") != lName.npos &&
753 >                  lName.find("ecalIsolationUsingLeadingPion") == lName.npos) lpfId.byECALIsolation = lDiscri;
754 >              if (lName.find("byIsolationUsingLeadingPion") != lName.npos) lpfId.byIsolationUsingLeadingPion = lDiscri;
755 >              if (lName.find("byIsolation") != lName.npos &&
756 >                  lName.find("byIsolationUsingLeadingPion") == lName.npos) lpfId.byIsolation = lDiscri;
757                if (lName.find("againstElectron") != lName.npos) lpfId.againstElectron = lDiscri;
758                if (lName.find("againstMuon") != lName.npos) lpfId.againstMuon = lDiscri;
759 +              if (lName.find("byTaNCfrHalfPercent") != lName.npos) lpfId.byTaNCfrHalfPercent = lDiscri;
760 +              if (lName.find("byTaNCfrOnePercent") != lName.npos) lpfId.byTaNCfrOnePercent = lDiscri;
761 +              if (lName.find("byTaNCfrQuarterPercent") != lName.npos) lpfId.byTaNCfrQuarterPercent = lDiscri;
762 +              if (lName.find("byTaNCfrTenthPercent") != lName.npos) lpfId.byTaNCfrTenthPercent = lDiscri;
763 +              if (lName.find("byTaNC") != lName.npos &&
764 +                  lName.find("byTaNCfr") == lName.npos) lpfId.byTaNC = lDiscri;
765 +              if (lName.find("leadingPionPtCut") != lName.npos) lpfId.leadingPionPtCut = lDiscri;
766              }
767              if (isCalo){
768                if (lName.find("byIsolation") != lName.npos) lcaloId.byIsolation = lDiscri;
# Line 925 | Line 958 | void HbbTreeMaker::HbbJets(const edm::Ha
958            lBtag.bProba = (*iter).bDiscriminator("jetBProbabilityBJetTags");
959            lBtag.probability = (*iter).bDiscriminator("jetProbabilityBJetTags");
960            lBtag.sSV = (*iter).bDiscriminator("simpleSecondaryVertexBJetTags");
961 <          lBtag.softElectron = (*iter).bDiscriminator("softElectronBJetTags");
962 <          lBtag.softMuon = (*iter).bDiscriminator("softMuonBJetTags");
963 <          lBtag.softMuonNoIP = (*iter).bDiscriminator("softMuonNoIPBJetTags");
961 >          lBtag.softElectronByPt = ((*iter).bDiscriminator("softElectronByPtBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softElectronByPtBJetTags");
962 >          lBtag.softElectronByIP3d = ((*iter).bDiscriminator("softElectronByIP3dBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softElectronByIP3dBJetTags");
963 >          lBtag.softMuon = ((*iter).bDiscriminator("softMuonBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonBJetTags");
964 >          lBtag.softMuonByPt = ((*iter).bDiscriminator("softMuonByPtBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonByPtBJetTags");
965 >          lBtag.softMuonByIP3d = ((*iter).bDiscriminator("softMuonByIP3dBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonByIP3dBJetTags");
966 >
967 >          //std::cout << " -- New values of b-discri for jet : " << iEle << std::endl
968 >          //        << " ---- softElecs: " << lBtag.softElectronByPt << " " << lBtag.softElectronByIP3d << std::endl
969 >          //        << " ---- softMus: " << lBtag.softMuon << " " << lBtag.softMuonByPt << " " << lBtag.softMuonByIP3d << std::endl;
970 >
971 >
972            lBtag.tCHE = (*iter).bDiscriminator("trackCountingHighEffBJetTags");
973            lBtag.tCHP = (*iter).bDiscriminator("trackCountingHighPurBJetTags");
974 <          
974 >
975 >
976            bool isCalo = (*iter).isCaloJet();
977            bool isPF = (*iter).isPFJet();
978  
979            assert (isCalo == !isPF);
980            if (isCalo) {
981 +            HbbAnalysis::JetIDVars lId;
982 +            lId.fHPD = (*iter).jetID().fHPD;
983 +            lId.fRBX = (*iter).jetID().fRBX;
984 +            lId.n90Hits = (*iter).jetID().n90Hits;
985 +            
986              HbbAnalysis::CaloJetVars lCalo;
987              lCalo.maxEInEmTowers = (*iter).maxEInEmTowers();
988              lCalo.maxEInHadTowers = (*iter).maxEInHadTowers();
# Line 952 | Line 999 | void HbbTreeMaker::HbbJets(const edm::Ha
999              lCalo.n90 = (*iter).n90();
1000              lCalo.n60 = (*iter).n60();
1001  
1002 <            HbbAnalysis::Jet lObj(lGen,lGenJet,lReco,lCommon,lCalo,lBtag);
1002 >            HbbAnalysis::Jet lObj(lGen,lGenJet,lReco,lCommon,lCalo,lBtag,lId);
1003              aVec.push_back(lObj);
1004            
1005            }
# Line 978 | Line 1025 | void HbbTreeMaker::HbbJets(const edm::Ha
1025            
1026            }
1027  
1028 +
1029 +
1030            iEle++;
1031          }//loop on element
1032      }//non empty
# Line 1115 | Line 1164 | void HbbTreeMaker::HbbParticles(const ed
1164  
1165  
1166   }//genparticles
1167 +
1168 +
1169 +
1170 + void HbbTreeMaker::HbbVertices(const edm::Handle<std::vector<reco::Vertex> > & aCol,
1171 +                               std::vector<HbbAnalysis::Vertex> & aVec)
1172 + {
1173 +
1174 +  for (std::vector<reco::Vertex>::const_iterator iter = aCol->begin();
1175 +       iter != aCol->end();
1176 +       iter++)
1177 +    {
1178 +
1179 +      if (!((*iter).isValid()) || (*iter).isFake()) continue;
1180 +
1181 +      HbbAnalysis::VertexVars lVtx;
1182 +
1183 +      if ((*iter).tracksSize() > 0) {
1184 +        for (std::vector<reco::TrackBaseRef>::const_iterator lTrk = (*iter).tracks_begin();
1185 +             lTrk != (*iter).tracks_end();
1186 +             lTrk++) {
1187 +          lVtx.trackWeights.push_back((*iter).trackWeight(*lTrk));
1188 +        }
1189 +      }
1190 +
1191 +      if (lVtx.trackWeights.size() != (*iter).tracksSize()) {
1192 +        std::cout<< " -- Problem with tracks, size is not as expected ! "
1193 +                 << std::endl
1194 +                 << " --- Size of recoVertex tracks = " << (*iter).tracksSize()
1195 +                 << std::endl
1196 +                 << " --- Size of trackWeights = " << lVtx.trackWeights.size()
1197 +                 << std::endl;
1198 +      }
1199 +
1200 +      lVtx.chi2 = (*iter).chi2();
1201 +      lVtx.ndof = (*iter).ndof();
1202 +      lVtx.x = (*iter).x();
1203 +      lVtx.y = (*iter).y();
1204 +      lVtx.z = (*iter).z();
1205 +      lVtx.xError = (*iter).xError();
1206 +      lVtx.yError = (*iter).yError();
1207 +      lVtx.zError = (*iter).zError();
1208 +      lVtx.cov01 = (*iter).covariance(0,1);
1209 +      lVtx.cov02 = (*iter).covariance(0,2);
1210 +      lVtx.cov12 = (*iter).covariance(1,2);
1211 +
1212 +      HbbAnalysis::Vertex lObj(lVtx);
1213 +      aVec.push_back(lObj);
1214 +    }
1215 +
1216 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines