Skip to content

Commit

Permalink
Merge pull request #20549 from natalia-korneeva/hlt-btag-std-string
Browse files Browse the repository at this point in the history
Switching from TString to std::string
  • Loading branch information
cmsbuild committed Sep 19, 2017
2 parents 8cf418d + 4f83ba6 commit d73a7d3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 54 deletions.
56 changes: 28 additions & 28 deletions HLTriggerOffline/Btag/src/HLTBTagHarvestingAnalyzer.cc
Expand Up @@ -33,48 +33,48 @@ HLTBTagHarvestingAnalyzer::dqmEndJob(DQMStore::IBooker & ibooker, DQMStore::IGet
std::string effDir = Form("HLT/BTag/Discriminator/%s/efficiency",hltPathNames_[ind].c_str());
std::string relationsDir = Form("HLT/BTag/Discriminator/%s/HEP17_HEM17",hltPathNames_[ind].c_str());
ibooker.setCurrentFolder(effDir);
TH1 *den =NULL;
TH1 *num =NULL;
std::map<TString,TH1F> effics;
std::map<TString,bool> efficsOK;
TH1 *den =nullptr;
TH1 *num =nullptr;
std::map<std::string,TH1F> effics;
std::map<std::string,bool> efficsOK;
std::map<std::string,std::map<HCALSpecials,TH1F> > efficsmod;
std::map<std::string,std::map<HCALSpecials,bool> > efficsmodOK;
for (unsigned int i = 0; i < m_mcLabels.size(); ++i)
{
bool isOK=false;
TString label= m_histoName.at(ind) + std::string("__"); //"JetTag__";
TString flavour= m_mcLabels[i].c_str();
std::string label= m_histoName.at(ind) + "__"; //"JetTag__";
std::string flavour= m_mcLabels[i];
label+=flavour;
isOK=GetNumDenumerators(ibooker,igetter,(TString(dqmFolder_hist)+"/"+label).Data(),(TString(dqmFolder_hist)+"/"+label).Data(),num,den,0);
isOK=GetNumDenumerators(ibooker,igetter,dqmFolder_hist+"/"+label,dqmFolder_hist+"/"+label,num,den,0);
if (isOK){

//do the 'b-tag efficiency vs discr' plot
effics[flavour]=calculateEfficiency1D(ibooker,igetter,*num,*den,(label+"_efficiency_vs_disc").Data());
effics[flavour]=calculateEfficiency1D(ibooker,igetter,*num,*den,label+"_efficiency_vs_disc");
efficsOK[flavour]=isOK;
}
//for modules (HEP17 etc.)
for (auto j: HCALSpecialsNames){
ibooker.setCurrentFolder(dqmFolder_hist+"/"+j.second+"/efficiency");
isOK=GetNumDenumerators(ibooker,igetter,(TString(dqmFolder_hist)+"/"+j.second+"/"+label).Data(),(TString(dqmFolder_hist)+"/"+j.second+"/"+label).Data(),num,den,0);
isOK=GetNumDenumerators(ibooker,igetter,dqmFolder_hist+"/"+j.second+"/"+label,dqmFolder_hist+"/"+j.second+"/"+label,num,den,0);
if (isOK){

//do the 'b-tag efficiency vs discr' plot
efficsmod[flavour.Data()][j.first]=calculateEfficiency1D(ibooker,igetter,*num,*den,(label+"_efficiency_vs_disc").Data());
efficsmodOK[flavour.Data()][j.first]=isOK;
efficsmod[flavour][j.first]=calculateEfficiency1D(ibooker,igetter,*num,*den,label+"_efficiency_vs_disc");
efficsmodOK[flavour][j.first]=isOK;
}
}
ibooker.setCurrentFolder(effDir);
label= m_histoName.at(ind)+std::string("___");
std::string labelEta = label.Data();
std::string labelPhi = label.Data();
label+=flavour+TString("_disc_pT");
labelEta+=std::string(static_cast<const char *>(flavour))+"_disc_eta";
labelPhi+=std::string(static_cast<const char *>(flavour))+"_disc_phi";
isOK=GetNumDenumerators (ibooker,igetter,(TString(dqmFolder_hist)+"/"+label).Data(),(TString(dqmFolder_hist)+"/"+label).Data(),num,den,1);
label= m_histoName.at(ind)+"___";
std::string labelEta = label;
std::string labelPhi = label;
label+=flavour+"_disc_pT";
labelEta+=flavour+"_disc_eta";
labelPhi+=flavour+"_disc_phi";
isOK=GetNumDenumerators (ibooker,igetter,dqmFolder_hist+"/"+label,dqmFolder_hist+"/"+label,num,den,1);
if (isOK) {

//do the 'b-tag efficiency vs pT' plot
TH1F eff=calculateEfficiency1D(ibooker,igetter,*num,*den,(label+"_efficiency_vs_pT").Data());
TH1F eff=calculateEfficiency1D(ibooker,igetter,*num,*den,label+"_efficiency_vs_pT");
}
isOK=GetNumDenumerators (ibooker,igetter,dqmFolder_hist+"/"+labelEta,dqmFolder_hist+"/"+labelEta,num,den,2);
if (isOK) {
Expand All @@ -91,8 +91,8 @@ HLTBTagHarvestingAnalyzer::dqmEndJob(DQMStore::IBooker & ibooker, DQMStore::IGet

///save efficiency_vs_disc_HEP17 / efficiency_vs_disc_HEM17 plots
ibooker.setCurrentFolder(relationsDir);
if (efficsmodOK[flavour.Data()][HEP17] && efficsmodOK[flavour.Data()][HEM17])
modulesrate(ibooker,igetter,&efficsmod[flavour.Data()][HEP17], &efficsmod[flavour.Data()][HEM17], m_histoName.at(ind)+"_"+flavour.Data()+"_HEP17_HEM17_effs_vs_disc_rate" );
if (efficsmodOK[flavour][HEP17] && efficsmodOK[flavour][HEM17])
modulesrate(ibooker,igetter,&efficsmod[flavour][HEP17], &efficsmod[flavour][HEM17], m_histoName.at(ind)+"_"+flavour+"_HEP17_HEM17_effs_vs_disc_rate" );
ibooker.setCurrentFolder(effDir);

} /// for mc labels
Expand Down Expand Up @@ -132,17 +132,17 @@ bool HLTBTagHarvestingAnalyzer::GetNumDenumerators(DQMStore::IBooker& ibooker, D
type =2 for eff_vs_eta or eff_vs_phi
type =3 for HEP17 / HEM17 mistagrate relation
*/
MonitorElement *denME = NULL;
MonitorElement *numME = NULL;
MonitorElement *denME = nullptr;
MonitorElement *numME = nullptr;
denME = igetter.get(den);
numME = igetter.get(num);
Exception excp(errors::LogicError);

if ( denME == NULL || numME == NULL )
if ( denME == nullptr || numME == nullptr )
{
excp << "Plots not found:\n";
if(denME == NULL) excp << den << "\n";
if(numME == NULL) excp << num << "\n";
if(denME == nullptr) excp << den << "\n";
if(numME == nullptr) excp << num << "\n";
excp.raise();
}

Expand Down Expand Up @@ -245,7 +245,7 @@ void HLTBTagHarvestingAnalyzer::mistagrate(DQMStore::IBooker& ibooker, DQMStore:
eff->SetBinError(binX,miseffErr);
}
MonitorElement *me;
me = ibooker.book1D(effName.c_str(),eff);
me = ibooker.book1D(effName,eff);
me->setEfficiencyFlag();

delete eff;
Expand All @@ -270,7 +270,7 @@ void HLTBTagHarvestingAnalyzer::modulesrate(DQMStore::IBooker& ibooker, DQMStore
eff->SetStats(kFALSE);

MonitorElement *me;
me = ibooker.book1D(effName.c_str(),eff);
me = ibooker.book1D(effName,eff);
me->setEfficiencyFlag();

delete eff;
Expand Down
52 changes: 26 additions & 26 deletions HLTriggerOffline/Btag/src/HLTBTagPerformanceAnalyzer.cc
Expand Up @@ -158,26 +158,26 @@ void HLTBTagPerformanceAnalyzer::analyze(const edm::Event& iEvent, const edm::Ev
int m = closestJet(BtagJT.first, *h_mcPartons, m_mcRadius);
unsigned int flavour = (m != -1) ? abs((*h_mcPartons)[m].second.getFlavour()) : 0;
for (unsigned int i = 0; i < m_mcLabels.size(); ++i) {
TString flavour_str= m_mcLabels[i].c_str();
std::string flavour_str= m_mcLabels[i];
flavours_t flav_collection= m_mcFlavours[i];
auto it = std::find(flav_collection.begin(), flav_collection.end(), flavour);
if (it== flav_collection.end()) continue;
TString label=JetTagCollection_Label[ind] + "__";
std::string label=JetTagCollection_Label[ind] + "__";
label+=flavour_str;
H1_.at(ind)[label.Data()]->Fill(std::fmax(0.0,BtagJT.second)); //fill 1D btag plot for 'b,c,uds'
H1_.at(ind)[label]->Fill(std::fmax(0.0,BtagJT.second)); //fill 1D btag plot for 'b,c,uds'
for (auto j: HCALSpecialsNames){
if (inmodule[j.first])
H1mod_.at(ind)[label.Data()][j.first]->Fill(std::fmax(0.0,BtagJT.second)); //fill 1D btag plot for 'b,c,uds' in modules (HEP17 etc.)
H1mod_.at(ind)[label][j.first]->Fill(std::fmax(0.0,BtagJT.second)); //fill 1D btag plot for 'b,c,uds' in modules (HEP17 etc.)
}
label=JetTagCollection_Label[ind] + "___";
label+=flavour_str;
std::string labelEta = label.Data();
std::string labelPhi = label.Data();
label+=TString("_disc_pT");
H2_.at(ind)[label.Data()]->Fill(std::fmax(0.0,BtagJT.second),BtagJT.first->pt()); //fill 2D btag, jetPt plot for 'b,c,uds'
std::string labelEta = label;
std::string labelPhi = label;
label+="_disc_pT";
H2_.at(ind)[label]->Fill(std::fmax(0.0,BtagJT.second),BtagJT.first->pt()); //fill 2D btag, jetPt plot for 'b,c,uds'
for (auto j: HCALSpecialsNames){
if (inmodule[j.first])
H2mod_.at(ind)[label.Data()][j.first]->Fill(std::fmax(0.0,BtagJT.second),BtagJT.first->pt());
H2mod_.at(ind)[label][j.first]->Fill(std::fmax(0.0,BtagJT.second),BtagJT.first->pt());
}
labelEta+="_disc_eta";
H2Eta_.at(ind)[labelEta]->Fill(std::fmax(0.0,BtagJT.second),BtagJT.first->eta()); //fill 2D btag, jetEta plot for 'b,c,uds'
Expand Down Expand Up @@ -214,11 +214,11 @@ void HLTBTagPerformanceAnalyzer::bookHistograms(DQMStore::IBooker & ibooker, edm

//book 1D btag plot for 'all'
if ( JetTagCollection_Label[ind] != "" && JetTagCollection_Label[ind] != "NULL" ) {
H1_.back()[JetTagCollection_Label[ind]] = ibooker.book1D(JetTagCollection_Label[ind] + "_all", (JetTagCollection_Label[ind]+ "_all").c_str(), btagBins, btagL, btagU );
H1_.back()[JetTagCollection_Label[ind]] = ibooker.book1D(JetTagCollection_Label[ind] + "_all", JetTagCollection_Label[ind]+ "_all", btagBins, btagL, btagU );
H1_.back()[JetTagCollection_Label[ind]] -> setAxisTitle(JetTagCollection_Label[ind] +"discriminant",1);
for (auto i: HCALSpecialsNames){
ibooker.setCurrentFolder(dqmFolder+"/"+i.second);
H1mod_.back()[JetTagCollection_Label[ind]][i.first] = ibooker.book1D(JetTagCollection_Label[ind] + "_all", (JetTagCollection_Label[ind]+ "_all").c_str(), btagBins, btagL, btagU );
H1mod_.back()[JetTagCollection_Label[ind]][i.first] = ibooker.book1D(JetTagCollection_Label[ind] + "_all", JetTagCollection_Label[ind]+ "_all", btagBins, btagL, btagU );
H1mod_.back()[JetTagCollection_Label[ind]][i.first] -> setAxisTitle(JetTagCollection_Label[ind] +"discriminant",1);
}
ibooker.setCurrentFolder(dqmFolder);
Expand All @@ -235,39 +235,39 @@ void HLTBTagPerformanceAnalyzer::bookHistograms(DQMStore::IBooker & ibooker, edm

for (unsigned int i = 0; i < m_mcLabels.size(); ++i)
{
TString flavour= m_mcLabels[i].c_str();
TString label;
std::string flavour= m_mcLabels[i];
std::string label;
std::string labelEta;
std::string labelPhi;
if ( JetTagCollection_Label[ind] != "" && JetTagCollection_Label[ind] != "NULL" ) {
label=JetTagCollection_Label[ind]+"__";
label+=flavour;

//book 1D btag plot for 'b,c,light,g'
H1_.back()[label.Data()] = ibooker.book1D(label.Data(), Form("%s %s",JetTagCollection_Label[ind].c_str(),flavour.Data()), btagBins, btagL, btagU );
H1_.back()[label.Data()]->setAxisTitle("disc",1);
H1_.back()[label] = ibooker.book1D(label, Form("%s %s",JetTagCollection_Label[ind].c_str(),flavour.c_str()), btagBins, btagL, btagU );
H1_.back()[label]->setAxisTitle("disc",1);
for (auto j: HCALSpecialsNames){
ibooker.setCurrentFolder(dqmFolder+"/"+j.second);
H1mod_.back()[label.Data()][j.first] = ibooker.book1D(label.Data(), Form("%s %s",JetTagCollection_Label[ind].c_str(),flavour.Data()), btagBins, btagL, btagU );
H1mod_.back()[label.Data()][j.first]->setAxisTitle("disc",1);
H1mod_.back()[label][j.first] = ibooker.book1D(label, Form("%s %s",JetTagCollection_Label[ind].c_str(),flavour.c_str()), btagBins, btagL, btagU );
H1mod_.back()[label][j.first]->setAxisTitle("disc",1);
}
ibooker.setCurrentFolder(dqmFolder);
label=JetTagCollection_Label[ind]+"___";
labelEta=label;
labelPhi=label;
label+=flavour+TString("_disc_pT");
labelEta+=std::string(static_cast<const char *>(flavour))+"_disc_eta";
labelPhi+=std::string(static_cast<const char *>(flavour))+"_disc_phi";
label+=flavour+"_disc_pT";
labelEta+=flavour+"_disc_eta";
labelPhi+=flavour+"_disc_phi";

//book 2D btag plot for 'b,c,light,g'
H2_.back()[label.Data()] = ibooker.book2D( label.Data(), label.Data(), btagBins, btagL, btagU, nBinsPt, pTmin, pTMax );
H2_.back()[label.Data()]->setAxisTitle("pT",2);
H2_.back()[label.Data()]->setAxisTitle("disc",1);
H2_.back()[label] = ibooker.book2D( label, label, btagBins, btagL, btagU, nBinsPt, pTmin, pTMax );
H2_.back()[label]->setAxisTitle("pT",2);
H2_.back()[label]->setAxisTitle("disc",1);
for (auto j: HCALSpecialsNames){
ibooker.setCurrentFolder(dqmFolder+"/"+j.second);
H2mod_.back()[label.Data()][j.first] = ibooker.book2D( label.Data(), label.Data(), btagBins, btagL, btagU, nBinsPt, pTmin, pTMax );
H2mod_.back()[label.Data()][j.first]->setAxisTitle("pT",2);
H2mod_.back()[label.Data()][j.first]->setAxisTitle("disc",1);
H2mod_.back()[label][j.first] = ibooker.book2D( label, label, btagBins, btagL, btagU, nBinsPt, pTmin, pTMax );
H2mod_.back()[label][j.first]->setAxisTitle("pT",2);
H2mod_.back()[label][j.first]->setAxisTitle("disc",1);
}
ibooker.setCurrentFolder(dqmFolder);
H2Eta_.back()[labelEta] = ibooker.book2D( labelEta, labelEta, btagBins, btagL, btagU, nBinsEta, etamin, etaMax );
Expand Down

0 comments on commit d73a7d3

Please sign in to comment.