From eb9325df37d229bfb5b85d59a735111ffb4944d3 Mon Sep 17 00:00:00 2001 From: Sebastien Wertz Date: Thu, 27 Apr 2017 17:04:55 +0200 Subject: [PATCH] Add efficiency plots vs. eta and phi for cut on discriminators --- DQMOffline/RecoB/interface/EtaPtBin.h | 2 +- DQMOffline/RecoB/interface/JetTagPlotter.h | 24 ++- .../plugins/BTagPerformanceAnalyzerOnData.cc | 121 ++++++++------- .../RecoB/plugins/BTagPerformanceHarvester.cc | 136 ++++++++--------- DQMOffline/RecoB/python/bTagCommon_cff.py | 34 +++-- DQMOffline/RecoB/src/JetTagPlotter.cc | 63 ++++++-- .../plugins/BTagPerformanceAnalyzerMC.cc | 138 +++++++++--------- 7 files changed, 296 insertions(+), 222 deletions(-) diff --git a/DQMOffline/RecoB/interface/EtaPtBin.h b/DQMOffline/RecoB/interface/EtaPtBin.h index e618a5584dc46..7b41d6eb82ca8 100644 --- a/DQMOffline/RecoB/interface/EtaPtBin.h +++ b/DQMOffline/RecoB/interface/EtaPtBin.h @@ -8,7 +8,7 @@ /** \class EtaPtBin * - * Decide if jet/parton lie within desired rapidity/pt range. + * Decide if jet/parton lie within desired abs(pseudo-rapidity)/pt range. * */ diff --git a/DQMOffline/RecoB/interface/JetTagPlotter.h b/DQMOffline/RecoB/interface/JetTagPlotter.h index e50e8e8dab9a8..733496e09e794 100644 --- a/DQMOffline/RecoB/interface/JetTagPlotter.h +++ b/DQMOffline/RecoB/interface/JetTagPlotter.h @@ -17,7 +17,7 @@ class JetTagPlotter : public BaseBTagPlotter { JetTagPlotter (const std::string & tagName, const EtaPtBin & etaPtBin, const edm::ParameterSet& pSet, const unsigned int& mc , - const bool& willFinalize, DQMStore::IBooker & ibook, const bool & doCTagPlots = false); + const bool& willFinalize, DQMStore::IBooker & ibook, const bool & doCTagPlots = false, bool doDifferentialPlots=false, double discrCut=-999.); virtual ~JetTagPlotter () ; @@ -45,17 +45,21 @@ class JetTagPlotter : public BaseBTagPlotter { // binning and bounds // 1) for 'efficiency' versus discriminator cut histos - int discrBins ; - double discrStart_ ; - double discrEnd_ ; - int nBinEffPur_ ; - double startEffPur_ ; - double endEffPur_ ; + int discrBins; + double discrStart_; + double discrEnd_; + int nBinEffPur_; + double startEffPur_; + double endEffPur_; unsigned int mcPlots_; bool willFinalize_; bool doCTagPlots_; + + // Differential plots: efficiency vs. variable for cut on discrimator > cutValue_ + bool doDifferentialPlots_; + double cutValue_; int *nJets; // jet multiplicity @@ -80,6 +84,12 @@ class JetTagPlotter : public BaseBTagPlotter { // reconstructed jet phi FlavourHistograms * dJetRecPhi; + + // jet Phi larger than requested discrimnator cut + FlavourHistograms * dJetPhiDiscrCut; + + // jet Eta larger than requested discrimnator cut + FlavourHistograms * dJetPseudoRapidityDiscrCut; }; #endif diff --git a/DQMOffline/RecoB/plugins/BTagPerformanceAnalyzerOnData.cc b/DQMOffline/RecoB/plugins/BTagPerformanceAnalyzerOnData.cc index 2abed1c8d8bea..58618c134d92d 100644 --- a/DQMOffline/RecoB/plugins/BTagPerformanceAnalyzerOnData.cc +++ b/DQMOffline/RecoB/plugins/BTagPerformanceAnalyzerOnData.cc @@ -28,6 +28,12 @@ BTagPerformanceAnalyzerOnData::BTagPerformanceAnalyzerOnData(const edm::Paramete slInfoToken = consumes(pSet.getParameter("softLeptonInfo")); jecMCToken = mayConsume(pSet.getParameter( "JECsourceMC" )); jecDataToken = consumes(pSet.getParameter( "JECsourceData" )); + + if (etaRanges.size() == 0) + etaRanges = { pSet.getParameter("etaMin"), pSet.getParameter("etaMax") }; + if (ptRanges.size() == 0) + ptRanges = { pSet.getParameter("ptRecJetMin"), pSet.getParameter("ptRecJetMax") }; + for (vector::const_iterator iModule = moduleConfig.begin(); iModule != moduleConfig.end(); ++iModule) { @@ -56,13 +62,13 @@ BTagPerformanceAnalyzerOnData::BTagPerformanceAnalyzerOnData(const edm::Paramete const std::vector listInfo = iModule->getParameter>("listTagInfos"); for(unsigned int ITi=0; ITi >(listInfo[ITi])); - vIP.push_back(listInfo[ITi]); - } + vIP.push_back(listInfo[ITi]); + } } else { const InputTag& moduleLabel = iModule->getParameter("label"); tokens.push_back(consumes< View >(moduleLabel)); - vIP.push_back(moduleLabel); + vIP.push_back(moduleLabel); } tagInfoToken.push_back(tokens); tagInfoInputTags.push_back(vIP); @@ -95,17 +101,22 @@ void BTagPerformanceAnalyzerOnData::bookHistograms(DQMStore::IBooker & ibook, ed // eta loop for ( int iEta = iEtaStart ; iEta < iEtaEnd ; ++iEta ) { - // pt loop - for ( int iPt = iPtStart ; iPt < iPtEnd ; ++iPt ) { - - const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); - - // Instantiate the genertic b tag plotter - JetTagPlotter *jetTagPlotter = new JetTagPlotter(folderName, etaPtBin, - iModule->getParameter("parameters"), 0, false, ibook); - binJetTagPlotters.at(iTag).push_back ( jetTagPlotter ) ; - - } + // pt loop + for ( int iPt = iPtStart ; iPt < iPtEnd ; ++iPt ) { + + const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); + + // Instantiate the genertic b tag plotter + bool doDifferentialPlots = false; + double discrCut = -999.; + if (iModule->exists("differentialPlots") && iModule->getParameter("differentialPlots") == true) { + doDifferentialPlots = true; + discrCut = iModule->getParameter("discrCut"); + } + JetTagPlotter *jetTagPlotter = new JetTagPlotter(folderName, etaPtBin, iModule->getParameter("parameters"), 0, false, ibook, false, doDifferentialPlots, discrCut); + binJetTagPlotters.at(iTag).push_back ( jetTagPlotter ) ; + + } } } else if(dataFormatType == "TagCorrelation") { @@ -133,18 +144,18 @@ void BTagPerformanceAnalyzerOnData::bookHistograms(DQMStore::IBooker & ibook, ed // eta loop for ( int iEta = iEtaStart ; iEta < iEtaEnd ; ++iEta ) { - // pt loop - for ( int iPt = iPtStart ; iPt < iPtEnd ; ++iPt ) { - const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); - - // Instantiate the tagInfo plotter - - BaseTagInfoPlotter *jetTagPlotter = theFactory.buildPlotter(dataFormatType, moduleLabel.label(), - etaPtBin, iModule->getParameter("parameters"), folderName, - 0, false, ibook); - binTagInfoPlotters.at(iInfoTag).push_back ( jetTagPlotter ) ; + // pt loop + for ( int iPt = iPtStart ; iPt < iPtEnd ; ++iPt ) { + const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); + + // Instantiate the tagInfo plotter + + BaseTagInfoPlotter *jetTagPlotter = theFactory.buildPlotter(dataFormatType, moduleLabel.label(), + etaPtBin, iModule->getParameter("parameters"), folderName, + 0, false, ibook); + binTagInfoPlotters.at(iInfoTag).push_back ( jetTagPlotter ) ; binTagInfoPlottersToModuleConfig.insert(make_pair(jetTagPlotter, iModule - moduleConfig.begin())); - } + } } } } @@ -154,31 +165,30 @@ EtaPtBin BTagPerformanceAnalyzerOnData::getEtaPtBin(const int& iEta, const int& { // DEFINE BTagBin: bool etaActive_ , ptActive_; - double etaMin_, etaMax_, ptMin_, ptMax_ ; + double etaMin_, etaMax_, ptMin_, ptMax_; if ( iEta != -1 ) { - etaActive_ = true ; - etaMin_ = etaRanges[iEta] ; - etaMax_ = etaRanges[iEta+1] ; + etaActive_ = true; + etaMin_ = etaRanges[iEta]; + etaMax_ = etaRanges[iEta+1]; } else { - etaActive_ = false ; - etaMin_ = etaRanges[0] ; - etaMax_ = etaRanges[etaRanges.size() - 1] ; + etaActive_ = false; + etaMin_ = etaRanges[0]; + etaMax_ = etaRanges[etaRanges.size() - 1]; } if ( iPt != -1 ) { - ptActive_ = true ; - ptMin_ = ptRanges[iPt] ; - ptMax_ = ptRanges[iPt+1] ; + ptActive_ = true; + ptMin_ = ptRanges[iPt]; + ptMax_ = ptRanges[iPt+1]; } else { - ptActive_ = false ; - ptMin_ = ptRanges[0] ; - ptMax_ = ptRanges[ptRanges.size() - 1] ; + ptActive_ = false; + ptMin_ = ptRanges[0]; + ptMax_ = ptRanges[ptRanges.size() - 1]; } - return EtaPtBin(etaActive_ , etaMin_ , etaMax_ , - ptActive_ , ptMin_ , ptMax_ ); + return EtaPtBin(etaActive_, etaMin_, etaMax_, ptActive_, ptMin_ , ptMax_); } BTagPerformanceAnalyzerOnData::~BTagPerformanceAnalyzerOnData() @@ -238,24 +248,23 @@ void BTagPerformanceAnalyzerOnData::analyze(const edm::Event& iEvent, const edm: LogDebug("Info") << "Found " << tagColl.size() << " B candidates in collection " << jetTagInputTags[iJetLabel]; int plotterSize = binJetTagPlotters[iJetLabel].size(); - for (JetTagCollection::const_iterator tagI = tagColl.begin(); - tagI != tagColl.end(); ++tagI) { + for (JetTagCollection::const_iterator tagI = tagColl.begin(); tagI != tagColl.end(); ++tagI) { //JEC reco::Jet correctedJet = *(tagI->first); double jec = 1.0; if(doJEC && corrector) { - jec = corrector->correction(*(tagI->first)); + jec = corrector->correction(*(tagI->first)); } if (!jetSelector(*(tagI->first), -1, infoHandle, jec)) - continue; + continue; for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) { - bool inBin = binJetTagPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*tagI->first, jec); - // Fill histograms if in desired pt/rapidity bin. - if (inBin) - binJetTagPlotters[iJetLabel][iPlotter]->analyzeTag(*tagI, jec, -1); + bool inBin = binJetTagPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*tagI->first, jec); + // Fill histograms if in desired pt/rapidity bin. + if (inBin) + binJetTagPlotters[iJetLabel][iPlotter]->analyzeTag(*tagI, jec, -1); } } for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) { @@ -280,7 +289,7 @@ void BTagPerformanceAnalyzerOnData::analyze(const edm::Event& iEvent, const edm: reco::Jet correctedJet = *(tagI->first); double jec = 1.0; if(doJEC && corrector) { - jec = corrector->correction(*(tagI->first)); + jec = corrector->correction(*(tagI->first)); } if (!jetSelector(*(tagI->first), -1, infoHandle, jec)) @@ -323,8 +332,8 @@ void BTagPerformanceAnalyzerOnData::analyze(const edm::Event& iEvent, const edm: // protect against missing products // if (tagInfoHandle.isValid() == false){ - edm::LogWarning("BTagPerformanceAnalyzerOnData")<<" Collection "<size(); @@ -355,17 +364,17 @@ void BTagPerformanceAnalyzerOnData::analyze(const edm::Event& iEvent, const edm: reco::Jet correctedJet = *(jetRef); double jec = 1.0; if(doJEC && corrector) { - jec = corrector->correction(*(jetRef)); + jec = corrector->correction(*(jetRef)); } if (!jetSelector(*jetRef, -1, infoHandle, jec)) continue; for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) { - bool inBin = binTagInfoPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*jetRef, jec); - // Fill histograms if in desired pt/rapidity bin. - if (inBin) - binTagInfoPlotters[iJetLabel][iPlotter]->analyzeTag(baseTagInfos, jec, -1); + bool inBin = binTagInfoPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*jetRef, jec); + // Fill histograms if in desired pt/rapidity bin. + if (inBin) + binTagInfoPlotters[iJetLabel][iPlotter]->analyzeTag(baseTagInfos, jec, -1); } } } diff --git a/DQMOffline/RecoB/plugins/BTagPerformanceHarvester.cc b/DQMOffline/RecoB/plugins/BTagPerformanceHarvester.cc index 7c5fa3675bb58..c6d2e9c1eb73f 100644 --- a/DQMOffline/RecoB/plugins/BTagPerformanceHarvester.cc +++ b/DQMOffline/RecoB/plugins/BTagPerformanceHarvester.cc @@ -61,31 +61,30 @@ EtaPtBin BTagPerformanceHarvester::getEtaPtBin(const int& iEta, const int& iPt) { // DEFINE BTagBin: bool etaActive_ , ptActive_; - double etaMin_, etaMax_, ptMin_, ptMax_ ; + double etaMin_, etaMax_, ptMin_, ptMax_; if ( iEta != -1 ) { - etaActive_ = true ; - etaMin_ = etaRanges[iEta] ; - etaMax_ = etaRanges[iEta+1] ; + etaActive_ = true; + etaMin_ = etaRanges[iEta]; + etaMax_ = etaRanges[iEta+1]; } else { - etaActive_ = false ; - etaMin_ = etaRanges[0] ; - etaMax_ = etaRanges[etaRanges.size() - 1] ; + etaActive_ = false; + etaMin_ = etaRanges[0]; + etaMax_ = etaRanges[etaRanges.size() - 1]; } if ( iPt != -1 ) { ptActive_ = true ; - ptMin_ = ptRanges[iPt] ; - ptMax_ = ptRanges[iPt+1] ; + ptMin_ = ptRanges[iPt]; + ptMax_ = ptRanges[iPt+1]; } else { - ptActive_ = false ; - ptMin_ = ptRanges[0] ; - ptMax_ = ptRanges[ptRanges.size() - 1] ; + ptActive_ = false; + ptMin_ = ptRanges[0]; + ptMax_ = ptRanges[ptRanges.size() - 1]; } - return EtaPtBin(etaActive_ , etaMin_ , etaMax_ , - ptActive_ , ptMin_ , ptMax_ ); + return EtaPtBin(etaActive_, etaMin_, etaMax_, ptActive_, ptMin_, ptMax_); } BTagPerformanceHarvester::~BTagPerformanceHarvester() @@ -100,7 +99,7 @@ BTagPerformanceHarvester::~BTagPerformanceHarvester() iJetLabel != differentialPlots.end(); ++iJetLabel) for (vector::iterator iPlotter = iJetLabel->begin(); iPlotter != iJetLabel->end(); ++ iPlotter) - delete *iPlotter; + delete *iPlotter; } for (vector >::iterator iJetLabel = binTagCorrelationPlotters.begin(); @@ -135,10 +134,10 @@ void BTagPerformanceHarvester::dqmEndJob(DQMStore::IBooker & ibook, DQMStore::IG const string& dataFormatType = iModule->exists("type") ? iModule->getParameter("type") : "JetTag"; - const bool& doCTagPlots = iModule->exists("doCTagPlots") ? + const bool& doCTagPlots = iModule->exists("doCTagPlots") ? iModule->getParameter("doCTagPlots") : false; - + if (dataFormatType == "JetTag") { iTag++; const string& folderName = iModule->getParameter("folder"); @@ -147,55 +146,56 @@ void BTagPerformanceHarvester::dqmEndJob(DQMStore::IBooker & ibook, DQMStore::IG vector * differentialPlotsConstantEta = new vector () ; vector * differentialPlotsConstantPt = new vector () ; if (mcPlots_ && makeDiffPlots_){ - // the constant b-efficiency for the differential plots versus pt and eta - const double& effBConst = - iModule->getParameter("parameters").getParameter("effBConst"); + // the constant b-efficiency for the differential plots versus pt and eta + const double& effBConst = + iModule->getParameter("parameters").getParameter("effBConst"); - // the objects for the differential plots vs. eta,pt for - for ( int iEta = iEtaStart ; iEta < iEtaEnd ; iEta++ ) { - BTagDifferentialPlot * etaConstDifferentialPlot = new BTagDifferentialPlot - (effBConst, BTagDifferentialPlot::constETA, folderName, mcPlots_); - differentialPlotsConstantEta->push_back ( etaConstDifferentialPlot ); - } + // the objects for the differential plots vs. eta,pt for + for ( int iEta = iEtaStart ; iEta < iEtaEnd ; iEta++ ) { + BTagDifferentialPlot * etaConstDifferentialPlot = new BTagDifferentialPlot + (effBConst, BTagDifferentialPlot::constETA, folderName, mcPlots_); + differentialPlotsConstantEta->push_back ( etaConstDifferentialPlot ); + } - for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) { - // differentialPlots for this pt bin - BTagDifferentialPlot * ptConstDifferentialPlot = new BTagDifferentialPlot - (effBConst, BTagDifferentialPlot::constPT, folderName, mcPlots_); - differentialPlotsConstantPt->push_back ( ptConstDifferentialPlot ); - } + for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) { + // differentialPlots for this pt bin + BTagDifferentialPlot * ptConstDifferentialPlot = new BTagDifferentialPlot + (effBConst, BTagDifferentialPlot::constPT, folderName, mcPlots_); + differentialPlotsConstantPt->push_back ( ptConstDifferentialPlot ); + } } // eta loop for ( int iEta = iEtaStart ; iEta < iEtaEnd ; iEta++ ) { - // pt loop - for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) { + // pt loop + for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) { - const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); + const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); - // Instantiate the genertic b tag plotter - JetTagPlotter *jetTagPlotter = new JetTagPlotter(folderName, etaPtBin, - iModule->getParameter("parameters"),mcPlots_,true, ibook, doCTagPlots); - binJetTagPlotters.at(iTag).push_back ( jetTagPlotter ) ; + // Instantiate the genertic b tag plotter + bool doDifferentialPlots = iModule->exists("differentialPlots") && iModule->getParameter("differentialPlots") == true; + JetTagPlotter *jetTagPlotter = new JetTagPlotter(folderName, etaPtBin, + iModule->getParameter("parameters"),mcPlots_,true, ibook, doCTagPlots, doDifferentialPlots); + binJetTagPlotters.at(iTag).push_back ( jetTagPlotter ) ; - // Add to the corresponding differential plotters - if (mcPlots_ && makeDiffPlots_){ - (*differentialPlotsConstantEta)[iEta+1]->addBinPlotter ( jetTagPlotter ) ; - (*differentialPlotsConstantPt )[iPt+1] ->addBinPlotter ( jetTagPlotter ) ; - } - } + // Add to the corresponding differential plotters + if (mcPlots_ && makeDiffPlots_){ + (*differentialPlotsConstantEta)[iEta+1]->addBinPlotter ( jetTagPlotter ) ; + (*differentialPlotsConstantPt )[iPt+1] ->addBinPlotter ( jetTagPlotter ) ; + } + } } // the objects for the differential plots vs. eta, pt: collect all from constant eta and constant pt if (mcPlots_ && makeDiffPlots_){ - differentialPlots.at(iTag).reserve(differentialPlotsConstantEta->size()+differentialPlotsConstantPt->size()) ; - differentialPlots.at(iTag).insert(differentialPlots.at(iTag).end(), differentialPlotsConstantEta->begin(), differentialPlotsConstantEta->end()); - differentialPlots.at(iTag).insert(differentialPlots.at(iTag).end(), differentialPlotsConstantPt->begin(), differentialPlotsConstantPt->end()); + differentialPlots.at(iTag).reserve(differentialPlotsConstantEta->size()+differentialPlotsConstantPt->size()) ; + differentialPlots.at(iTag).insert(differentialPlots.at(iTag).end(), differentialPlotsConstantEta->begin(), differentialPlotsConstantEta->end()); + differentialPlots.at(iTag).insert(differentialPlots.at(iTag).end(), differentialPlotsConstantPt->begin(), differentialPlotsConstantPt->end()); - edm::LogInfo("Info") - << "====>>>> ## sizeof differentialPlots = " << differentialPlots.size(); + edm::LogInfo("Info") + << "====>>>> ## sizeof differentialPlots = " << differentialPlots.size(); - // the intermediate ones are no longer needed - delete differentialPlotsConstantEta ; - delete differentialPlotsConstantPt ; + // the intermediate ones are no longer needed + delete differentialPlotsConstantEta ; + delete differentialPlotsConstantPt ; } } else if(dataFormatType == "TagCorrelation") { iTagCorr++; @@ -221,21 +221,21 @@ void BTagPerformanceHarvester::dqmEndJob(DQMStore::IBooker & ibook, DQMStore::IG const string& folderName = iModule->getParameter("folder"); // eta loop for ( int iEta = iEtaStart ; iEta < iEtaEnd ; iEta++ ) { - // pt loop - for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) { - const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); + // pt loop + for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) { + const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); - // Instantiate the tagInfo plotter + // Instantiate the tagInfo plotter - BaseTagInfoPlotter *jetTagPlotter = theFactory.buildPlotter(dataFormatType, moduleLabel.label(), - etaPtBin, iModule->getParameter("parameters"), folderName, - mcPlots_, true, ibook); - binTagInfoPlotters.at(iInfoTag).push_back ( jetTagPlotter ) ; - binTagInfoPlottersToModuleConfig.insert(make_pair(jetTagPlotter, iModule - moduleConfig.begin())); - } + BaseTagInfoPlotter *jetTagPlotter = theFactory.buildPlotter(dataFormatType, moduleLabel.label(), + etaPtBin, iModule->getParameter("parameters"), folderName, + mcPlots_, true, ibook); + binTagInfoPlotters.at(iInfoTag).push_back ( jetTagPlotter ) ; + binTagInfoPlottersToModuleConfig.insert(make_pair(jetTagPlotter, iModule - moduleConfig.begin())); + } } edm::LogInfo("Info") - << "====>>>> ## sizeof differentialPlots = " << differentialPlots.size(); + << "====>>>> ## sizeof differentialPlots = " << differentialPlots.size(); } } @@ -250,10 +250,10 @@ void BTagPerformanceHarvester::dqmEndJob(DQMStore::IBooker & ibook, DQMStore::IG if(makeDiffPlots_) { for (vector::iterator iPlotter = differentialPlots[iJetLabel].begin(); - iPlotter != differentialPlots[iJetLabel].end(); ++ iPlotter) { - (*iPlotter)->process(ibook); - if (producePs) (*iPlotter)->psPlot(psBaseName); - if (produceEps) (*iPlotter)->epsPlot(epsBaseName); + iPlotter != differentialPlots[iJetLabel].end(); ++ iPlotter) { + (*iPlotter)->process(ibook); + if (producePs) (*iPlotter)->psPlot(psBaseName); + if (produceEps) (*iPlotter)->epsPlot(epsBaseName); } } } diff --git a/DQMOffline/RecoB/python/bTagCommon_cff.py b/DQMOffline/RecoB/python/bTagCommon_cff.py index 164d4bd0f8739..215513e482193 100644 --- a/DQMOffline/RecoB/python/bTagCommon_cff.py +++ b/DQMOffline/RecoB/python/bTagCommon_cff.py @@ -77,12 +77,12 @@ label = cms.InputTag("pfJetBProbabilityBJetTags"), folder = cms.string("JBP") ), - cms.PSet( + cms.PSet( bTagSimpleSVAnalysisBlock, label = cms.InputTag("pfSimpleSecondaryVertexHighEffBJetTags"), folder = cms.string("SSVHE") ), - cms.PSet( + cms.PSet( bTagSimpleSVAnalysisBlock, label = cms.InputTag("pfSimpleInclusiveSecondaryVertexHighEffBJetTags"), folder = cms.string("SISVHE") @@ -90,12 +90,16 @@ cms.PSet( bTagGenericAnalysisBlock, label = cms.InputTag("pfCombinedInclusiveSecondaryVertexV2BJetTags"), - folder = cms.string("CSVv2") + folder = cms.string("CSVv2"), + differentialPlots = cms.bool(True), + discrCut = cms.double(0.5426) ), cms.PSet( bTagSymmetricAnalysisBlock, label = cms.InputTag("pfCombinedMVAV2BJetTags"), - folder = cms.string("combMVAv2") + folder = cms.string("combMVAv2"), + differentialPlots = cms.bool(True), + discrCut = cms.double(-0.5884) ), cms.PSet( bTagSoftLeptonAnalysisBlock, @@ -107,31 +111,35 @@ label = cms.InputTag("softPFElectronBJetTags"), folder = cms.string("SET") ), - cms.PSet( + cms.PSet( cTagCombinedSVAnalysisBlock, listTagInfos = cms.VInputTag( - cms.InputTag("pfImpactParameterTagInfos"), - cms.InputTag("pfInclusiveSecondaryVertexFinderCvsLTagInfos"), - cms.InputTag("softPFMuonsTagInfos"), - cms.InputTag("softPFElectronsTagInfos") + cms.InputTag("pfImpactParameterTagInfos"), + cms.InputTag("pfInclusiveSecondaryVertexFinderCvsLTagInfos"), + cms.InputTag("softPFMuonsTagInfos"), + cms.InputTag("softPFElectronsTagInfos") ), type = cms.string('GenericMVA'), label = cms.InputTag("candidateCombinedSecondaryVertexSoftLeptonCvsLComputer"), folder = cms.string("CtaggerTag") ), - cms.PSet( + cms.PSet( cTagGenericAnalysisBlock, label = cms.InputTag("pfCombinedCvsLJetTags"), folder = cms.string("Ctagger_CvsL"), - doCTagPlots = cms.bool(True) + doCTagPlots = cms.bool(True), + differentialPlots = cms.bool(True), + discrCut = cms.double(-0.48) ), cms.PSet( cTagGenericAnalysisBlock, label = cms.InputTag("pfCombinedCvsBJetTags"), folder = cms.string("Ctagger_CvsB"), - doCTagPlots = cms.bool(True) + doCTagPlots = cms.bool(True), + differentialPlots = cms.bool(True), + discrCut = cms.double(-0.17) ), - cms.PSet( + cms.PSet( cTagCorrelationAnalysisBlock, type = cms.string('TagCorrelation'), label1 = cms.InputTag("pfCombinedCvsLJetTags"), diff --git a/DQMOffline/RecoB/src/JetTagPlotter.cc b/DQMOffline/RecoB/src/JetTagPlotter.cc index 1f2d89387780d..0b2a8ebc6c88c 100644 --- a/DQMOffline/RecoB/src/JetTagPlotter.cc +++ b/DQMOffline/RecoB/src/JetTagPlotter.cc @@ -11,14 +11,17 @@ using namespace RecoBTag; JetTagPlotter::JetTagPlotter (const std::string & tagName, const EtaPtBin & etaPtBin, const edm::ParameterSet& pSet, const unsigned int& mc, - const bool& wf, DQMStore::IBooker & ibook, const bool & doCTagPlots) : + const bool& wf, DQMStore::IBooker & ibook, const bool & doCTagPlots/*=false*/, + bool doDifferentialPlots/*=false*/, double discrCut/*=-999.*/) : BaseBTagPlotter(tagName, etaPtBin), discrBins(400), discrStart_(pSet.getParameter("discriminatorStart")), discrEnd_(pSet.getParameter("discriminatorEnd")), nBinEffPur_(pSet.getParameter("nBinEffPur")), startEffPur_(pSet.getParameter("startEffPur")), - endEffPur_(pSet.getParameter("endEffPur")), - mcPlots_(mc), willFinalize_(wf), doCTagPlots_(doCTagPlots) { + endEffPur_(pSet.getParameter("endEffPur")), + mcPlots_(mc), willFinalize_(wf), doCTagPlots_(doCTagPlots), + doDifferentialPlots_(doDifferentialPlots), + cutValue_(discrCut) { // to have a shorter name ..... const std::string & es = theExtensionString; @@ -65,28 +68,42 @@ JetTagPlotter::JetTagPlotter (const std::string & tagName, const EtaPtBin & etaP // reconstructed jet eta dJetRecPseudoRapidity = new FlavourHistograms - ("jetEta" + es, "jet eta", 100, -3.0, 3.0, + ("jetEta" + es, "jet eta", 20, -etaPtBin.getEtaMax(), etaPtBin.getEtaMax(), false, false, true, "b", jetTagDir, mcPlots_, ibook); // reconstructed jet phi dJetRecPhi = new FlavourHistograms - ("jetPhi" + es, "jet phi", 100, -3.15, 3.15, + ("jetPhi" + es, "jet phi", 20, -M_PI, M_PI, false, false, true, "b", jetTagDir, mcPlots_, ibook); + + if (doDifferentialPlots_) { + // jet Phi larger than requested discrimnator cut + dJetPhiDiscrCut = new FlavourHistograms("jetPhi_diffEff" + es, "Efficiency vs. jet Phi for discriminator above cut", + 20, -M_PI, M_PI, false, false, true, "b", jetTagDir, mcPlots_, ibook); + + // jet Eta larger than requested discrimnator cut + dJetPseudoRapidityDiscrCut = new FlavourHistograms("jetEta_diffEff" + es, "Efficiency vs. jet eta for discriminator above cut", + 20, -etaPtBin.getEtaMax(), etaPtBin.getEtaMax(), false, false, true, "b", jetTagDir, mcPlots_, ibook); + } } JetTagPlotter::~JetTagPlotter () { + delete dDiscriminator; + + if (doDifferentialPlots_) { + delete dJetPhiDiscrCut; + delete dJetPseudoRapidityDiscrCut; + } + if (!willFinalize_) { delete dJetFlav; delete JetMultiplicity; - delete dDiscriminator; delete dJetRecMomentum; delete dJetRecPt; delete dJetRecPseudoRapidity; delete dJetRecPhi; - } - else { - delete dDiscriminator; + } else { delete effPurFromHistos; } } @@ -217,6 +234,12 @@ void JetTagPlotter::analyzeTag(const reco::Jet & jet, dJetRecPt->fill(jetFlavour, jet.pt()*jec ); dJetRecPseudoRapidity->fill(jetFlavour, jet.eta() ); dJetRecPhi->fill(jetFlavour, jet.phi()); + if (doDifferentialPlots_) { + if (edm::isFinite(discriminator) && discriminator > cutValue_) { + dJetPhiDiscrCut->fill(jetFlavour, jet.phi()); + dJetPseudoRapidityDiscrCut->fill(jetFlavour, jet.eta()); + } + } } void JetTagPlotter::analyzeTag(const reco::Jet & jet, @@ -241,6 +264,12 @@ void JetTagPlotter::analyzeTag(const reco::Jet & jet, dJetRecPt->fill(jetFlavour, jet.pt()*jec , w); dJetRecPseudoRapidity->fill(jetFlavour, jet.eta() , w ); dJetRecPhi->fill(jetFlavour, jet.phi() , w ); + if (doDifferentialPlots_) { + if (edm::isFinite(discriminator) && discriminator > cutValue_) { + dJetPhiDiscrCut->fill(jetFlavour, jet.phi()); + dJetPseudoRapidityDiscrCut->fill(jetFlavour, jet.eta()); + } + } } @@ -297,12 +326,24 @@ void JetTagPlotter::finalize(DQMStore::IBooker & ibook_, DQMStore::IGetter & ige // const std::string & es = theExtensionString; const std::string jetTagDir(es.substr(1)); - dDiscriminator = new FlavourHistograms - ("discr" + es, "Discriminator", 102, discrStart_, discrEnd_, "b", jetTagDir, mcPlots_, igetter_); + dDiscriminator = new FlavourHistograms("discr" + es, "Discriminator", 102, discrStart_, discrEnd_, "b", jetTagDir, mcPlots_, igetter_); effPurFromHistos = new EffPurFromHistos ( dDiscriminator,theExtensionString.substr(1), mcPlots_, ibook_, nBinEffPur_, startEffPur_, endEffPur_); effPurFromHistos->doCTagPlots(doCTagPlots_); effPurFromHistos->compute(ibook_); + + // Produce the differentiel efficiency vs. kinematical variables + if (doDifferentialPlots_) { + dJetRecPhi = new FlavourHistograms("jetPhi" + es, "jet phi", 20, -M_PI, M_PI, "b", jetTagDir, mcPlots_, igetter_); + dJetPhiDiscrCut = new FlavourHistograms("jetPhi_diffEff" + es, "Efficiency vs. jet Phi for discriminator above cut", 20, -M_PI, M_PI, "b", jetTagDir, mcPlots_, igetter_); + dJetPhiDiscrCut->divide(*dJetRecPhi); + dJetPhiDiscrCut->setEfficiencyFlag(); + + dJetRecPseudoRapidity = new FlavourHistograms("jetEta" + es, "jet eta", 20, -etaPtBin_.getEtaMax(), etaPtBin_.getEtaMax(), "b", jetTagDir, mcPlots_, igetter_); + dJetPseudoRapidityDiscrCut = new FlavourHistograms("jetEta_diffEff" + es, "Efficiency vs. jet eta for discriminator above cut", 20, -etaPtBin_.getEtaMax(), etaPtBin_.getEtaMax(), "b", jetTagDir, mcPlots_, igetter_); + dJetPseudoRapidityDiscrCut->divide(*dJetRecPseudoRapidity); + dJetPseudoRapidityDiscrCut->setEfficiencyFlag(); + } } diff --git a/Validation/RecoB/plugins/BTagPerformanceAnalyzerMC.cc b/Validation/RecoB/plugins/BTagPerformanceAnalyzerMC.cc index 7286caa7ce6f7..5ca511abf6378 100644 --- a/Validation/RecoB/plugins/BTagPerformanceAnalyzerMC.cc +++ b/Validation/RecoB/plugins/BTagPerformanceAnalyzerMC.cc @@ -48,6 +48,11 @@ BTagPerformanceAnalyzerMC::BTagPerformanceAnalyzerMC(const edm::ParameterSet& pS case 15: tauPlots = true; electronPlots = false; tauPlots = false; break; default: electronPlots = false; muonPlots = false; tauPlots = false; } + + if (etaRanges.size() == 0) + etaRanges = { pSet.getParameter("etaMin"), pSet.getParameter("etaMax") }; + if (ptRanges.size() == 0) + ptRanges = { pSet.getParameter("ptRecJetMin"), pSet.getParameter("ptRecJetMax") }; genToken = mayConsume(edm::InputTag("generator")); genJetsMatchedToken = mayConsume>(pSet.getParameter("genJetsMatched")); @@ -81,16 +86,16 @@ BTagPerformanceAnalyzerMC::BTagPerformanceAnalyzerMC(const edm::ParameterSet& pS binTagInfoPlotters.push_back(vector()) ; std::vector< edm::EDGetTokenT> > tokens; if(dataFormatType == "GenericMVA") { - const std::vector listInfo = iModule->getParameter>("listTagInfos"); + const std::vector listInfo = iModule->getParameter>("listTagInfos"); for(unsigned int ITi=0; ITi >(listInfo[ITi])); - vIP.push_back(listInfo[ITi]); - } + vIP.push_back(listInfo[ITi]); + } } else { - const InputTag& moduleLabel = iModule->getParameter("label"); - tokens.push_back(consumes< View >(moduleLabel)); - vIP.push_back(moduleLabel); + const InputTag& moduleLabel = iModule->getParameter("label"); + tokens.push_back(consumes< View >(moduleLabel)); + vIP.push_back(moduleLabel); } tagInfoToken.push_back(tokens); tagInfoInputTags.push_back(vIP); @@ -125,17 +130,22 @@ void BTagPerformanceAnalyzerMC::bookHistograms(DQMStore::IBooker & ibook, edm::R // eta loop for ( int iEta = iEtaStart ; iEta < iEtaEnd ; iEta++ ) { - // pt loop - for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) { + // pt loop + for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) { - const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); + const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); - // Instantiate the genertic b tag plotter - JetTagPlotter *jetTagPlotter = new JetTagPlotter(folderName, etaPtBin, - iModule->getParameter("parameters"),mcPlots_,false, ibook); - binJetTagPlotters.at(iTag).push_back ( jetTagPlotter ) ; + // Instantiate the genertic b tag plotter + bool doDifferentialPlots = false; + double discrCut = -999.; + if (iModule->exists("differentialPlots") && iModule->getParameter("differentialPlots") == true) { + doDifferentialPlots = true; + discrCut = iModule->getParameter("discrCut"); + } + JetTagPlotter *jetTagPlotter = new JetTagPlotter(folderName, etaPtBin, iModule->getParameter("parameters"), mcPlots_, false, ibook, false, doDifferentialPlots, discrCut); + binJetTagPlotters.at(iTag).push_back ( jetTagPlotter ) ; - } + } } } else if(dataFormatType == "TagCorrelation") { iTagCorr++; @@ -161,18 +171,18 @@ void BTagPerformanceAnalyzerMC::bookHistograms(DQMStore::IBooker & ibook, edm::R const string& folderName = iModule->getParameter("folder"); // eta loop for ( int iEta = iEtaStart ; iEta < iEtaEnd ; iEta++ ) { - // pt loop - for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) { - const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); - - // Instantiate the tagInfo plotter - - BaseTagInfoPlotter *jetTagPlotter = theFactory.buildPlotter(dataFormatType, moduleLabel.label(), - etaPtBin, iModule->getParameter("parameters"), folderName, - mcPlots_,false, ibook); - binTagInfoPlotters.at(iInfoTag).push_back ( jetTagPlotter ) ; - binTagInfoPlottersToModuleConfig.insert(make_pair(jetTagPlotter, iModule - moduleConfig.begin())); - } + // pt loop + for ( int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) { + const EtaPtBin& etaPtBin = getEtaPtBin(iEta, iPt); + + // Instantiate the tagInfo plotter + + BaseTagInfoPlotter *jetTagPlotter = theFactory.buildPlotter(dataFormatType, moduleLabel.label(), + etaPtBin, iModule->getParameter("parameters"), folderName, + mcPlots_,false, ibook); + binTagInfoPlotters.at(iInfoTag).push_back ( jetTagPlotter ) ; + binTagInfoPlottersToModuleConfig.insert(make_pair(jetTagPlotter, iModule - moduleConfig.begin())); + } } } } @@ -186,27 +196,26 @@ EtaPtBin BTagPerformanceAnalyzerMC::getEtaPtBin(const int& iEta, const int& iPt) if ( iEta != -1 ) { etaActive_ = true ; - etaMin_ = etaRanges[iEta] ; - etaMax_ = etaRanges[iEta+1] ; + etaMin_ = etaRanges[iEta]; + etaMax_ = etaRanges[iEta+1]; } else { - etaActive_ = false ; - etaMin_ = etaRanges[0] ; - etaMax_ = etaRanges[etaRanges.size() - 1] ; + etaActive_ = false; + etaMin_ = etaRanges[0]; + etaMax_ = etaRanges[etaRanges.size() - 1]; } if ( iPt != -1 ) { - ptActive_ = true ; - ptMin_ = ptRanges[iPt] ; - ptMax_ = ptRanges[iPt+1] ; + ptActive_ = true; + ptMin_ = ptRanges[iPt]; + ptMax_ = ptRanges[iPt+1]; } else { - ptActive_ = false ; - ptMin_ = ptRanges[0] ; - ptMax_ = ptRanges[ptRanges.size() - 1] ; + ptActive_ = false; + ptMin_ = ptRanges[0]; + ptMax_ = ptRanges[ptRanges.size() - 1]; } - return EtaPtBin(etaActive_ , etaMin_ , etaMax_ , - ptActive_ , ptMin_ , ptMax_ ); + return EtaPtBin(etaActive_, etaMin_, etaMax_, ptActive_, ptMin_, ptMax_); } BTagPerformanceAnalyzerMC::~BTagPerformanceAnalyzerMC() @@ -256,16 +265,15 @@ void BTagPerformanceAnalyzerMC::analyze(const edm::Event& iEvent, const edm::Eve if(!useOldFlavourTool) { edm::Handle jetMC; iEvent.getByToken(jetToken, jetMC); - for (JetFlavourInfoMatchingCollection::const_iterator iter = jetMC->begin(); - iter != jetMC->end(); ++iter) { + for (JetFlavourInfoMatchingCollection::const_iterator iter = jetMC->begin(); iter != jetMC->end(); ++iter) { unsigned int fl = std::abs(iter->second.getPartonFlavour()); flavours.insert(std::make_pair(iter->first, fl)); const GenParticleRefVector &lep = iter->second.getLeptons(); reco::JetFlavour::Leptons lepCount; for (unsigned int i=0; ipdgId())==11) lepCount.electron++; - else if(abs(lep[i]->pdgId())==13) lepCount.muon++; - else if(abs(lep[i]->pdgId())==15) lepCount.tau++; + if(abs(lep[i]->pdgId())==11) lepCount.electron++; + else if(abs(lep[i]->pdgId())==13) lepCount.muon++; + else if(abs(lep[i]->pdgId())==15) lepCount.tau++; } leptons.insert(std::make_pair(iter->first, lepCount)); } @@ -273,8 +281,7 @@ void BTagPerformanceAnalyzerMC::analyze(const edm::Event& iEvent, const edm::Eve else { edm::Handle jetMC; iEvent.getByToken(caloJetToken, jetMC); - for (JetFlavourMatchingCollection::const_iterator iter = jetMC->begin(); - iter != jetMC->end(); ++iter) { + for (JetFlavourMatchingCollection::const_iterator iter = jetMC->begin(); iter != jetMC->end(); ++iter) { unsigned int fl = std::abs(iter->second.getFlavour()); flavours.insert(std::make_pair(iter->first, fl)); const reco::JetFlavour::Leptons &lep = iter->second.getLeptons(); @@ -311,7 +318,7 @@ void BTagPerformanceAnalyzerMC::analyze(const edm::Event& iEvent, const edm::Eve int plotterSize = binJetTagPlotters[iJetLabel].size(); for (JetTagCollection::const_iterator tagI = tagColl.begin(); - tagI != tagColl.end(); ++tagI) { + tagI != tagColl.end(); ++tagI) { // Identify parton associated to jet. /// needed for lepton specific plots @@ -334,11 +341,11 @@ void BTagPerformanceAnalyzerMC::analyze(const edm::Event& iEvent, const edm::Eve continue; for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) { - bool inBin = false; - inBin = binJetTagPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.first, jec); - // Fill histograms if in desired pt/rapidity bin. - if (inBin) - binJetTagPlotters[iJetLabel][iPlotter]->analyzeTag(jetWithFlavour.first, jec, tagI->second, std::abs(jetWithFlavour.second.getPartonFlavour()),weight); + bool inBin = false; + inBin = binJetTagPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.first, jec); + // Fill histograms if in desired pt/rapidity bin. + if (inBin) + binJetTagPlotters[iJetLabel][iPlotter]->analyzeTag(jetWithFlavour.first, jec, tagI->second, std::abs(jetWithFlavour.second.getPartonFlavour()),weight); } } for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) { @@ -381,10 +388,9 @@ void BTagPerformanceAnalyzerMC::analyze(const edm::Event& iEvent, const edm::Eve for(int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) { bool inBin = false; - inBin = binTagCorrelationPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.first, jec); + inBin = binTagCorrelationPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.first, jec); - if(inBin) - { + if(inBin) { double discr2 = tagColl2[tagI->first]; binTagCorrelationPlotters[iJetLabel][iPlotter]->analyzeTags(tagI->second, discr2, std::abs(jetWithFlavour.second.getPartonFlavour()),weight); } @@ -414,9 +420,9 @@ void BTagPerformanceAnalyzerMC::analyze(const edm::Event& iEvent, const edm::Eve for (unsigned int iInputTags = 0; iInputTags < tokens.size(); ++iInputTags) { edm::Handle< View > & tagInfoHandle = tagInfoHandles[iInputTags]; iEvent.getByToken(tokens[iInputTags], tagInfoHandle); - if (tagInfoHandle.isValid() == false){ - edm::LogWarning("BTagPerformanceAnalyzerMC")<<" Collection "<size(); @@ -466,11 +472,11 @@ void BTagPerformanceAnalyzerMC::analyze(const edm::Event& iEvent, const edm::Eve continue; for (int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) { - bool inBin = false; - inBin = binTagInfoPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*jetRef, jec); - // Fill histograms if in desired pt/rapidity bin. - if (inBin) - binTagInfoPlotters[iJetLabel][iPlotter]->analyzeTag(baseTagInfos, jec, std::abs(jetWithFlavour.second.getPartonFlavour()),weight); + bool inBin = false; + inBin = binTagInfoPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*jetRef, jec); + // Fill histograms if in desired pt/rapidity bin. + if (inBin) + binTagInfoPlotters[iJetLabel][iPlotter]->analyzeTag(baseTagInfos, jec, std::abs(jetWithFlavour.second.getPartonFlavour()),weight); } } } @@ -485,9 +491,9 @@ bool BTagPerformanceAnalyzerMC::getJetWithGenJet(edm::RefToBase jetRef, edm } bool BTagPerformanceAnalyzerMC::getJetWithFlavour(const edm::Event& iEvent, - edm::RefToBase jetRef, const FlavourMap& flavours, - JetWithFlavour & jetWithFlavour, const JetCorrector * corrector, - edm::Handle > genJetsMatched) + edm::RefToBase jetRef, const FlavourMap& flavours, + JetWithFlavour & jetWithFlavour, const JetCorrector * corrector, + edm::Handle > genJetsMatched) { edm::ProductID recProdId = jetRef.id(); edm::ProductID refProdId = (flavours.begin() == flavours.end())