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 |
|
|
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")), |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
< |
void HbbTreeMaker::beginJob(const edm::EventSetup&){//beginJob |
73 |
> |
void HbbTreeMaker::beginJob(){//beginJob |
74 |
|
|
75 |
|
|
76 |
|
edm::Service<TFileService> lFileService; |
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 |
|
|
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 { |
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 { |
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 |
|
|
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; |
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; |
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; |
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 |
|
} |
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 |
|
|
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; |
948 |
|
lCommon.rawpT = (*iter).pt(); |
949 |
|
if ((*iter).hasCorrFactors()) |
950 |
|
lCommon.rawpT = (*iter).pt()/((*iter).corrFactor((*iter).corrStep())); |
951 |
+ |
|
952 |
+ |
lCommon.etaMean = (*iter).etaPhiStatistics().etaMean; |
953 |
+ |
lCommon.phiMean = (*iter).etaPhiStatistics().phiMean; |
954 |
+ |
lCommon.etaEtaMoment = (*iter).etaPhiStatistics().etaEtaMoment; |
955 |
+ |
lCommon.phiPhiMoment = (*iter).etaPhiStatistics().phiPhiMoment; |
956 |
+ |
lCommon.etaPhiMoment = (*iter).etaPhiStatistics().etaPhiMoment; |
957 |
+ |
|
958 |
|
//lCommon.rawEta = (*iter).; |
959 |
|
//lCommon.rawPhi = (*iter).; |
960 |
|
// p_hasJetCorrFactors->Fill(aJet.hasJetCorrFactors()); |
966 |
|
lBtag.bProba = (*iter).bDiscriminator("jetBProbabilityBJetTags"); |
967 |
|
lBtag.probability = (*iter).bDiscriminator("jetProbabilityBJetTags"); |
968 |
|
lBtag.sSV = (*iter).bDiscriminator("simpleSecondaryVertexBJetTags"); |
969 |
< |
lBtag.softElectron = (*iter).bDiscriminator("softElectronBJetTags"); |
970 |
< |
lBtag.softMuon = (*iter).bDiscriminator("softMuonBJetTags"); |
971 |
< |
lBtag.softMuonNoIP = (*iter).bDiscriminator("softMuonNoIPBJetTags"); |
969 |
> |
lBtag.softElectronByPt = ((*iter).bDiscriminator("softElectronByPtBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softElectronByPtBJetTags"); |
970 |
> |
lBtag.softElectronByIP3d = ((*iter).bDiscriminator("softElectronByIP3dBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softElectronByIP3dBJetTags"); |
971 |
> |
lBtag.softMuon = ((*iter).bDiscriminator("softMuonBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonBJetTags"); |
972 |
> |
lBtag.softMuonByPt = ((*iter).bDiscriminator("softMuonByPtBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonByPtBJetTags"); |
973 |
> |
lBtag.softMuonByIP3d = ((*iter).bDiscriminator("softMuonByIP3dBJetTags") < -1000) ? -1000 : (*iter).bDiscriminator("softMuonByIP3dBJetTags"); |
974 |
> |
|
975 |
> |
//std::cout << " -- New values of b-discri for jet : " << iEle << std::endl |
976 |
> |
// << " ---- softElecs: " << lBtag.softElectronByPt << " " << lBtag.softElectronByIP3d << std::endl |
977 |
> |
// << " ---- softMus: " << lBtag.softMuon << " " << lBtag.softMuonByPt << " " << lBtag.softMuonByIP3d << std::endl; |
978 |
> |
|
979 |
> |
|
980 |
|
lBtag.tCHE = (*iter).bDiscriminator("trackCountingHighEffBJetTags"); |
981 |
|
lBtag.tCHP = (*iter).bDiscriminator("trackCountingHighPurBJetTags"); |
982 |
< |
|
982 |
> |
|
983 |
> |
|
984 |
|
bool isCalo = (*iter).isCaloJet(); |
985 |
|
bool isPF = (*iter).isPFJet(); |
986 |
|
|
987 |
|
assert (isCalo == !isPF); |
988 |
|
if (isCalo) { |
989 |
+ |
HbbAnalysis::JetIDVars lId; |
990 |
+ |
lId.fHPD = (*iter).jetID().fHPD; |
991 |
+ |
lId.fRBX = (*iter).jetID().fRBX; |
992 |
+ |
lId.n90Hits = (*iter).jetID().n90Hits; |
993 |
+ |
|
994 |
|
HbbAnalysis::CaloJetVars lCalo; |
995 |
|
lCalo.maxEInEmTowers = (*iter).maxEInEmTowers(); |
996 |
|
lCalo.maxEInHadTowers = (*iter).maxEInHadTowers(); |
1007 |
|
lCalo.n90 = (*iter).n90(); |
1008 |
|
lCalo.n60 = (*iter).n60(); |
1009 |
|
|
1010 |
< |
HbbAnalysis::Jet lObj(lGen,lGenJet,lReco,lCommon,lCalo,lBtag); |
1010 |
> |
HbbAnalysis::Jet lObj(lGen,lGenJet,lReco,lCommon,lCalo,lBtag,lId); |
1011 |
|
aVec.push_back(lObj); |
1012 |
|
|
1013 |
|
} |
1033 |
|
|
1034 |
|
} |
1035 |
|
|
1036 |
+ |
|
1037 |
+ |
|
1038 |
|
iEle++; |
1039 |
|
}//loop on element |
1040 |
|
}//non empty |
1172 |
|
|
1173 |
|
|
1174 |
|
}//genparticles |
1175 |
+ |
|
1176 |
+ |
|
1177 |
+ |
|
1178 |
+ |
void HbbTreeMaker::HbbVertices(const edm::Handle<std::vector<reco::Vertex> > & aCol, |
1179 |
+ |
std::vector<HbbAnalysis::Vertex> & aVec) |
1180 |
+ |
{ |
1181 |
+ |
|
1182 |
+ |
for (std::vector<reco::Vertex>::const_iterator iter = aCol->begin(); |
1183 |
+ |
iter != aCol->end(); |
1184 |
+ |
iter++) |
1185 |
+ |
{ |
1186 |
+ |
|
1187 |
+ |
if (!((*iter).isValid()) || (*iter).isFake()) continue; |
1188 |
+ |
|
1189 |
+ |
HbbAnalysis::VertexVars lVtx; |
1190 |
+ |
|
1191 |
+ |
if ((*iter).tracksSize() > 0) { |
1192 |
+ |
for (std::vector<reco::TrackBaseRef>::const_iterator lTrk = (*iter).tracks_begin(); |
1193 |
+ |
lTrk != (*iter).tracks_end(); |
1194 |
+ |
lTrk++) { |
1195 |
+ |
lVtx.trackWeights.push_back((*iter).trackWeight(*lTrk)); |
1196 |
+ |
} |
1197 |
+ |
} |
1198 |
+ |
|
1199 |
+ |
if (lVtx.trackWeights.size() != (*iter).tracksSize()) { |
1200 |
+ |
std::cout<< " -- Problem with tracks, size is not as expected ! " |
1201 |
+ |
<< std::endl |
1202 |
+ |
<< " --- Size of recoVertex tracks = " << (*iter).tracksSize() |
1203 |
+ |
<< std::endl |
1204 |
+ |
<< " --- Size of trackWeights = " << lVtx.trackWeights.size() |
1205 |
+ |
<< std::endl; |
1206 |
+ |
} |
1207 |
+ |
|
1208 |
+ |
lVtx.chi2 = (*iter).chi2(); |
1209 |
+ |
lVtx.ndof = (*iter).ndof(); |
1210 |
+ |
lVtx.x = (*iter).x(); |
1211 |
+ |
lVtx.y = (*iter).y(); |
1212 |
+ |
lVtx.z = (*iter).z(); |
1213 |
+ |
lVtx.xError = (*iter).xError(); |
1214 |
+ |
lVtx.yError = (*iter).yError(); |
1215 |
+ |
lVtx.zError = (*iter).zError(); |
1216 |
+ |
lVtx.cov01 = (*iter).covariance(0,1); |
1217 |
+ |
lVtx.cov02 = (*iter).covariance(0,2); |
1218 |
+ |
lVtx.cov12 = (*iter).covariance(1,2); |
1219 |
+ |
|
1220 |
+ |
HbbAnalysis::Vertex lObj(lVtx); |
1221 |
+ |
aVec.push_back(lObj); |
1222 |
+ |
} |
1223 |
+ |
|
1224 |
+ |
} |
1225 |
+ |
|
1226 |
+ |
#include "FWCore/Framework/interface/MakerMacros.h" |
1227 |
+ |
DEFINE_FWK_MODULE(HbbTreeMaker); |
1228 |
+ |
|
1229 |
+ |
|