Skip to content

Commit

Permalink
Merge pull request #19878 from cms-btv-pog/fixValidationPlots_from-CM…
Browse files Browse the repository at this point in the history
…SSW_9_3_0_pre2

B-tag validation/offline DQM: fix efficiency plots on data & eta ranges
  • Loading branch information
cmsbuild committed Aug 3, 2017
2 parents bde6c50 + b0ca7e2 commit ac18042
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 65 deletions.
8 changes: 4 additions & 4 deletions DQMOffline/RecoB/plugins/BTagPerformanceAnalyzerOnData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ BTagPerformanceAnalyzerOnData::BTagPerformanceAnalyzerOnData(const edm::Paramete
jecMCToken = mayConsume<JetCorrector>(pSet.getParameter<edm::InputTag>( "JECsourceMC" ));
jecDataToken = consumes<JetCorrector>(pSet.getParameter<edm::InputTag>( "JECsourceData" ));

if (etaRanges.size() == 0)
if (etaRanges.size() <= 1)
etaRanges = { pSet.getParameter<double>("etaMin"), pSet.getParameter<double>("etaMax") };
if (ptRanges.size() == 0)
if (ptRanges.size() <= 1)
ptRanges = { pSet.getParameter<double>("ptRecJetMin"), pSet.getParameter<double>("ptRecJetMax") };

for (vector<edm::ParameterSet>::const_iterator iModule = moduleConfig.begin();
Expand Down Expand Up @@ -82,9 +82,9 @@ void BTagPerformanceAnalyzerOnData::bookHistograms(DQMStore::IBooker & ibook, ed

// iterate over ranges:
const int iEtaStart = -1 ; // this will be the inactive one
const int iEtaEnd = etaRanges.size() - 1 ;
const int iEtaEnd = etaRanges.size() > 2 ? etaRanges.size() - 1 : 0; // if there is only one bin defined, leave it as the inactive one
const int iPtStart = -1 ; // this will be the inactive one
const int iPtEnd = ptRanges.size() - 1 ;
const int iPtEnd = ptRanges.size() > 2 ? ptRanges.size() - 1 : 0; // if there is only one bin defined, leave it as the inactive one
setTDRStyle();

TagInfoPlotterFactory theFactory;
Expand Down
9 changes: 7 additions & 2 deletions DQMOffline/RecoB/plugins/BTagPerformanceHarvester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ BTagPerformanceHarvester::BTagPerformanceHarvester(const edm::ParameterSet& pSet
} else
mcPlots_ = 0;

if (etaRanges.size() <= 1)
etaRanges = { pSet.getParameter<double>("etaMin"), pSet.getParameter<double>("etaMax") };
if (ptRanges.size() <= 1)
ptRanges = { pSet.getParameter<double>("ptRecJetMin"), pSet.getParameter<double>("ptRecJetMax") };

for (vector<edm::ParameterSet>::const_iterator iModule = moduleConfig.begin();
iModule != moduleConfig.end(); ++iModule) {
const string& dataFormatType = iModule->exists("type") ?
Expand Down Expand Up @@ -96,9 +101,9 @@ void BTagPerformanceHarvester::dqmEndJob(DQMStore::IBooker & ibook, DQMStore::IG

// iterate over ranges:
const int iEtaStart = -1 ; // this will be the inactive one
const int iEtaEnd = etaRanges.size() - 1;
const int iEtaEnd = etaRanges.size() > 2 ? etaRanges.size() - 1 : 0; // if there is only one bin defined, leave it as the inactive one
const int iPtStart = -1 ; // this will be the inactive one
const int iPtEnd = ptRanges.size() - 1 ;
const int iPtEnd = ptRanges.size() > 2 ? ptRanges.size() - 1 : 0; // if there is only one bin defined, leave it as the inactive one
setTDRStyle();

TagInfoPlotterFactory theFactory;
Expand Down
4 changes: 2 additions & 2 deletions DQMOffline/RecoB/python/bTagCommon_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@
folder = cms.string("Ctagger_CvsL"),
doCTagPlots = cms.bool(True),
differentialPlots = cms.bool(True),
discrCut = cms.double(-0.48)
discrCut = cms.double(-0.1)
),
cms.PSet(
cTagGenericAnalysisBlock,
label = cms.InputTag("pfCombinedCvsBJetTags"),
folder = cms.string("Ctagger_CvsB"),
doCTagPlots = cms.bool(True),
differentialPlots = cms.bool(True),
discrCut = cms.double(-0.17)
discrCut = cms.double(0.08)
),
cms.PSet(
cTagCorrelationAnalysisBlock,
Expand Down
64 changes: 11 additions & 53 deletions DQMOffline/RecoB/src/JetTagPlotter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ JetTagPlotter::JetTagPlotter (const std::string & tagName, const EtaPtBin & etaP
int nFl = 1;
if (mcPlots_) nFl = 8;
nJets_.resize(nFl, 0);

if (mcPlots_) {
// jet flavour
dJetFlav_ = std::make_unique<FlavourHistograms<int>>
Expand Down Expand Up @@ -187,34 +187,6 @@ void JetTagPlotter::analyzeTag(float w)
}
}

/*void JetTagPlotter::analyzeTag(const reco::Jet & jet,
const double & jec,
const float& discriminator,
const int& jetFlavour)
{
if (mcPlots_) {
dJetFlav_->fill(jetFlavour, jetFlavour);
if (abs(jetFlavour) > 0 && abs(jetFlavour) < 6) nJets_[abs(jetFlavour)] += 1; //quarks 1 to 5
else if (abs(jetFlavour)==21) nJets_[6] += 1; //gluons
else if (jetFlavour==20) nJets_[7] += 1; //PU
else nJets_[0] += 1; //NI
} else {
nJets_[0] += 1;
}
if (edm::isNotFinite(discriminator)) dDiscriminator_->fill(jetFlavour, -999.0);
else dDiscriminator_->fill(jetFlavour, discriminator);
dJetRecMomentum_->fill(jetFlavour, jet.p()*jec);
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,
double jec,
float discriminator,
Expand Down Expand Up @@ -245,27 +217,6 @@ void JetTagPlotter::analyzeTag(const reco::Jet & jet,
}


/*void JetTagPlotter::analyzeTag(const reco::JetTag & jetTag,
const double & jec,
const int & jetFlavour)
{
if (mcPlots_) {
dJetFlav_->fill(jetFlavour, jetFlavour);
if (abs(jetFlavour) > 0 && abs(jetFlavour) < 6) nJets_[abs(jetFlavour)] += 1; //quarks 1 to 5
else if(abs(jetFlavour) == 21) nJets_[6] +=1 ; //gluons
else if(jetFlavour == 20) nJets_[7] += 1; //PU
else nJets_[0] += 1; //NI
} else {
nJets_[0] += 1;
}
if (edm::isNotFinite(jetTag.second) ) dDiscriminator_->fill(jetFlavour, -999.0 );
else dDiscriminator_->fill(jetFlavour, jetTag.second);
dJetRecMomentum_->fill(jetFlavour, jetTag.first->p()*jec );
dJetRecPt_->fill(jetFlavour, jetTag.first->pt()*jec );
dJetRecPseudoRapidity_->fill(jetFlavour, jetTag.first->eta() );
dJetRecPhi_->fill(jetFlavour, jetTag.first->phi());
}*/

void JetTagPlotter::analyzeTag(const reco::JetTag & jetTag,
double jec,
int jetFlavour,
Expand All @@ -280,12 +231,19 @@ void JetTagPlotter::analyzeTag(const reco::JetTag & jetTag,
} else {
nJets_[0] += 1;
}
if (edm::isNotFinite(jetTag.second)) dDiscriminator_->fill(jetFlavour, -999.0, w);
else dDiscriminator_->fill(jetFlavour, jetTag.second, w);
const auto& discriminator = jetTag.second;
if (edm::isNotFinite(discriminator)) dDiscriminator_->fill(jetFlavour, -999.0, w);
else dDiscriminator_->fill(jetFlavour, discriminator, w);
dJetRecMomentum_->fill(jetFlavour, jetTag.first->p() * jec, w);
dJetRecPt_->fill(jetFlavour, jetTag.first->pt() * jec, w);
dJetRecPseudoRapidity_->fill(jetFlavour, jetTag.first->eta(), w);
dJetRecPhi_->fill(jetFlavour, jetTag.first->phi(), w);
if (doDifferentialPlots_) {
if (edm::isFinite(discriminator) && discriminator > cutValue_) {
dJetPhiDiscrCut_->fill(jetFlavour, jetTag.first->phi(), w);
dJetPseudoRapidityDiscrCut_->fill(jetFlavour, jetTag.first->eta(), w);
}
}
}

void JetTagPlotter::finalize(DQMStore::IBooker & ibook_, DQMStore::IGetter & igetter_)
Expand All @@ -298,7 +256,7 @@ void JetTagPlotter::finalize(DQMStore::IBooker & ibook_, DQMStore::IGetter & ige
const std::string jetTagDir(es.substr(1));
dDiscriminator_ = std::make_unique<FlavourHistograms<double>>("discr" + es, "Discriminator", 102, discrStart_, discrEnd_, "b", jetTagDir, mcPlots_, igetter_);

effPurFromHistos_ = std::make_unique<EffPurFromHistos>(*dDiscriminator_, theExtensionString.substr(1), mcPlots_, ibook_, nBinEffPur_, startEffPur_, endEffPur_);
effPurFromHistos_ = std::make_unique<EffPurFromHistos>(*dDiscriminator_, jetTagDir, mcPlots_, ibook_, nBinEffPur_, startEffPur_, endEffPur_);
effPurFromHistos_->doCTagPlots(doCTagPlots_);
effPurFromHistos_->compute(ibook_);

Expand Down
9 changes: 5 additions & 4 deletions Validation/RecoB/plugins/BTagPerformanceAnalyzerMC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ BTagPerformanceAnalyzerMC::BTagPerformanceAnalyzerMC(const edm::ParameterSet& pS
default: electronPlots = false; muonPlots = false; tauPlots = false;
}

if (etaRanges.size() == 0)
if (etaRanges.size() <= 1)
etaRanges = { pSet.getParameter<double>("etaMin"), pSet.getParameter<double>("etaMax") };
if (ptRanges.size() == 0)
if (ptRanges.size() <= 1)
ptRanges = { pSet.getParameter<double>("ptRecJetMin"), pSet.getParameter<double>("ptRecJetMax") };

genToken = mayConsume<GenEventInfoProduct>(edm::InputTag("generator"));
Expand Down Expand Up @@ -111,9 +111,10 @@ void BTagPerformanceAnalyzerMC::bookHistograms(DQMStore::IBooker & ibook, edm::R

// iterate over ranges:
const int iEtaStart = -1 ; // this will be the inactive one
const int iEtaEnd = etaRanges.size() - 1 ;
const int iEtaEnd = etaRanges.size() > 2 ? etaRanges.size() - 1 : 0; // if there is only one bin defined, leave it as the inactive one
const int iPtStart = -1 ; // this will be the inactive one
const int iPtEnd = ptRanges.size() - 1 ;
const int iPtEnd = ptRanges.size() > 2 ? ptRanges.size() - 1 : 0; // if there is only one bin defined, leave it as the inactive one

setTDRStyle();

TagInfoPlotterFactory theFactory;
Expand Down

0 comments on commit ac18042

Please sign in to comment.