Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:26

0001 #include <vector>
0002 #include <string>
0003 using namespace std;
0004 
0005 TGraphErrors * computeGraph(TH1F * effdiscrb, TH1F* effdiscruds);
0006 
0007 int colorList[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; 
0008 int markerStyleList[] = {21,21,23,23,22,22,23,23,24,24,24,24,25,25,25,25,26,26,26,26};  
0009 
0010 TObject * getHistogram(TFile * f, string algo,string histoName, string range, string suffix)
0011 {
0012 string prefix = "DQMData/Run 1/Btag/Run summary/JetTag";
0013 string d = prefix+"_"+algo+"_"+range;
0014  cout <<" STR: "<<d<<endl; 
0015  cout <<" DIR: "<<  f->Get(d.c_str())<<endl;
0016  cout <<" HIS: "<<  (histoName+"_"+algo+"_"+range+suffix).c_str()<<endl;
0017 
0018  TDirectory * dir  =(TDirectory *) f->Get(d.c_str());
0019  return dir->Get((histoName+"_"+algo+"_"+range+suffix).c_str());
0020 }
0021 
0022 TObject * getHistogram2(TFile * f, string algo,string histoName, string range, string suffix)
0023 {
0024 string prefix = "JetTag";
0025 string d = prefix+"_"+algo+"_"+range;
0026  cout <<" STR: "<<d<<endl; 
0027  cout <<" DIR: "<<  f->Get(d.c_str())<<endl;
0028  cout <<" HIS: "<<  (histoName+"_"+algo+"_"+range+suffix).c_str()<<endl;
0029 
0030  TDirectory * dir  =(TDirectory *) f->Get(d.c_str());
0031  return dir->Get((histoName+"_"+algo+"_"+range+suffix).c_str());
0032 }
0033 
0034 
0035 
0036 
0037 TObject * getHistogram2(TFile * f, string algo,string histoName, string range = "GLOBAL")
0038 {
0039 string prefix = "JetTag";
0040 string d = prefix+"_"+algo+"_"+range;
0041 TDirectory * dir  =(TDirectory *) f->Get(d.c_str());
0042 return dir->Get((histoName+"_"+algo+"_"+range).c_str());
0043 }
0044 
0045 void setStyle(int i, TGraph *obj)
0046 {
0047 obj->SetMarkerColor(colorList[i]);
0048 obj->SetLineColor(colorList[i]);
0049 obj->SetMarkerStyle(markerStyleList[i]);
0050 obj->SetMarkerSize(.8);
0051 }
0052 
0053 
0054 
0055 TGraphErrors *  drawAll()
0056 {
0057   TFile *_file1 = TFile::Open("here.root");
0058 
0059   // use also an old style file??
0060 
0061   bool old = false;
0062   TFile *_file2;
0063   if (old == true){
0064   _file2= TFile::Open("jetTagAnalysis.root");
0065   }
0066   vector<TFile *> files;
0067   vector<string> algos;
0068   algos.push_back("trackCountingHighPurBJetTags");
0069   /*  algos.push_back("trackCountingHighEffBJetTags");
0070   algos.push_back("jetProbabilityBJetTags");
0071   algos.push_back("jetBProbabilityBJetTags");
0072   algos.push_back("simpleSecondaryVertexBJetTags");
0073   algos.push_back("combinedSecondaryVertexBJetTags");
0074   algos.push_back("softMuonBJetTags");
0075   algos.push_back("softMuonByIP3dBJetTags");
0076   algos.push_back("softMuonByPtBJetTags");
0077   algos.push_back("softElectronBJetTags"); */
0078 
0079   TLegend * leg = new TLegend(0.2,0.65,0.4,0.9);
0080   TCanvas * c1 = new TCanvas();
0081   c1->SetLogy();  
0082   c1->SetGridy();  
0083   c1->SetGridx();  
0084   for(int i = 0 ; i < algos.size() ; i++)
0085    {
0086       cout << algos[i] << endl;
0087       // get the eff vs dicriminant
0088 
0089       TH1F* effdiscrb =  (TH1F *) getHistogram(_file1,algos[i],"effVsDiscrCut_discr","GLOBAL", "B");
0090       TH1F* effdiscruds = (TH1F *) getHistogram(_file1,algos[i],"effVsDiscrCut_discr","GLOBAL", "DUS");
0091       
0092       cout <<" HISTOS "<<effdiscrb <<" " <<effdiscruds<<endl;
0093 
0094       TGraphErrors * h = computeGraph(effdiscrb,effdiscruds);
0095       //      h->SetMaximum(1.);
0096             h->SetMinimum(1e-5);
0097       //      h->GetXaxis()->SetLimits(0,.2);
0098       //      h->GetYaxis()->SetLimits(1e-4,1);
0099      cout << h << endl;
0100      //     return h;
0101      setStyle(i,h);
0102      if(i==0) h->Draw("ALP"); else h->Draw("lpsame"); 
0103      leg->AddEntry(h,algos[i].c_str(),"p");
0104    }
0105 
0106   if (old == true){
0107     
0108     for(int i = 0 ; i < algos.size() ; i++)
0109       {
0110     cout << algos[i] << endl;
0111     // get the eff vs dicriminant
0112     
0113     TH1F* effdiscrb =  (TH1F *) getHistogram2(_file2,algos[i],"effVsDiscrCut_discr","GLOBAL", "B");
0114     TH1F* effdiscruds = (TH1F *) getHistogram2(_file2,algos[i],"effVsDiscrCut_discr","GLOBAL", "DUS");
0115       
0116     cout <<" HISTOS "<<effdiscrb <<" " <<effdiscruds<<endl;
0117     
0118     TGraphErrors * h = computeGraph(effdiscrb,effdiscruds);
0119     //      h->SetMaximum(1.);
0120     h->SetMinimum(1e-5);
0121     //      h->GetXaxis()->SetLimits(0,.2);
0122     //      h->GetYaxis()->SetLimits(1e-4,1);
0123     cout << h << endl;
0124     //     return h;
0125      setStyle(i+10,h);
0126      //     if(i==0) h->Draw("ALP"); else 
0127      h->Draw("lpsame"); 
0128      leg->AddEntry(h,algos[i].c_str(),"p");
0129       }
0130     
0131   }
0132 
0133 
0134 
0135   leg->Draw("same");
0136 
0137   return 0;
0138 }
0139 
0140 
0141 TGraphErrors * computeGraph(TH1F * effdiscrb, TH1F* effdiscruds){
0142   double be[1000],ber[1000], udse[1000], udser[1000];
0143   int nbins = effdiscrb->GetNbinsX();
0144   cout <<" BINS = "<<nbins<<endl;
0145   for (int i=0; i<nbins; i++)    {
0146     be[i] = effdiscrb->GetBinContent(i+1);
0147     ber[i] = effdiscrb->GetBinError(i+1);
0148     udse[i] = effdiscruds->GetBinContent(i+1);
0149     udser[i] = effdiscruds->GetBinError(i+1);
0150     cout <<" GOT "<< i<<" " << be[i]<<" " <<ber[i]<<" " <<udse[i]<<" " <<udser[i]<<endl;
0151   }
0152   TGraphErrors * result = new TGraphErrors(nbins, be, udse, ber, udser);
0153   //  result->Draw();
0154   return result;
0155 }
0156 
0157