Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:24

0001 void DrawL3Comparison()
0002 {  
0003   PrintMessage();
0004 }
0005 void DrawL3Comparison(char s1[1024])
0006 {  
0007   char filename[1][1024];
0008   sprintf(filename[0],"%s",s1);
0009   MainProgram(1,filename);
0010 }
0011 void DrawL3Comparison(char s1[1024],char s2[1024])
0012 { 
0013   char filename[2][1024];
0014   sprintf(filename[0],"%s",s1);
0015   sprintf(filename[1],"%s",s2);
0016   MainProgram(2,filename);
0017 }
0018 void DrawL3Comparison(char s1[1024],char s2[1024],char s3[1024])
0019 { 
0020   char filename[3][1024];
0021   sprintf(filename[0],"%s",s1);
0022   sprintf(filename[1],"%s",s2);
0023   sprintf(filename[2],"%s",s3);
0024   MainProgram(3,filename);
0025 }
0026 void DrawL3Comparison(char s1[1024],char s2[1024],char s3[1024],char s4[1024])
0027 { 
0028   char filename[4][1024];
0029   sprintf(filename[0],"%s",s1);
0030   sprintf(filename[1],"%s",s2);
0031   sprintf(filename[2],"%s",s3);
0032   sprintf(filename[3],"%s",s4);
0033   MainProgram(4,filename);
0034 }
0035 void DrawL3Comparison(char s1[1024],char s2[1024],char s3[1024],char s4[1024],char s5[1024])
0036 { 
0037   char filename[5][1024];
0038   sprintf(filename[0],"%s",s1);
0039   sprintf(filename[1],"%s",s2);
0040   sprintf(filename[2],"%s",s3);
0041   sprintf(filename[3],"%s",s4);
0042   sprintf(filename[4],"%s",s5);
0043   MainProgram(5,filename);
0044 }
0045 void MainProgram(const int NAlg,char filename[][1024])
0046 {
0047   gROOT->SetStyle("Plain");
0048   gStyle->SetOptStat(0000);
0049   gStyle->SetOptFit(000); 
0050   gStyle->SetPalette(1);
0051  
0052   char name[1024];
0053   int alg,color;
0054   TFile *inf[NAlg];
0055   
0056   TGraphErrors *g_Cor[NAlg],*g_Resp[NAlg];
0057   TF1 *CorFit[NAlg],*RespFit[NAlg];
0058   ///////////////////////////////////////////////////////////////
0059   for(alg=0;alg<NAlg;alg++)
0060     {
0061       inf[alg] = new TFile(filename[alg],"r");
0062       g_Cor[alg] = (TGraphErrors*)inf[alg]->Get("Correction_vs_CaloPt");
0063       sprintf(name,"Correction_%s",filename[alg]);
0064       g_Cor[alg]->SetName(name);
0065       CorFit[alg] = (TF1*)g_Cor[alg]->GetFunction("CorFit");
0066       sprintf(name,"CorFit_%s",filename[alg]); 
0067       CorFit[alg]->SetName(name);
0068       CorFit[alg]->SetRange(5,5000);
0069       g_Resp[alg] = (TGraphErrors*)inf[alg]->Get("Response_vs_RefPt");
0070       sprintf(name,"Response_%s",filename[alg]);
0071       g_Resp[alg]->SetName(name);
0072       RespFit[alg] = (TF1*)g_Resp[alg]->GetFunction("RespFit");
0073       sprintf(name,"RespFit_%s",filename[alg]); 
0074       RespFit[alg]->SetName(name);
0075       RespFit[alg]->SetRange(5,5000);
0076     }
0077   ////////////////////// Correction ///////////////////////////////////////
0078   sprintf(name,"L3CorrectionComparison");
0079   TCanvas *c_Correction = new TCanvas(name,name,900,600);
0080   c_Correction->cd();
0081   gPad->SetLogx(); 
0082   g_Cor[0]->SetTitle("");
0083   g_Cor[0]->GetXaxis()->SetTitle("Uncorrected jet p_{T} (GeV)");
0084   g_Cor[0]->GetYaxis()->SetTitle("Correction Factor");
0085   g_Cor[0]->SetMaximum(3.5);
0086   g_Cor[0]->SetMinimum(0.8);
0087   g_Cor[0]->Draw("AP");
0088   TLegend *leg = new TLegend(0.5,0.6,0.85,0.85);
0089   for(alg=0;alg<NAlg;alg++)
0090     {
0091       color = alg+1;
0092       if (color==5)
0093         color = 7;
0094       g_Cor[alg]->SetMarkerStyle(20+alg);
0095       g_Cor[alg]->SetMarkerColor(color);
0096       g_Cor[alg]->SetLineColor(color);
0097       g_Cor[alg]->SetLineStyle(1);
0098       CorFit[alg]->SetLineColor(color);
0099       CorFit[alg]->SetLineStyle(1);
0100       CorFit[alg]->SetLineWidth(2); 
0101       g_Cor[alg]->Draw("sameP");
0102       leg->AddEntry(g_Cor[alg],filename[alg],"LP");
0103     }
0104   leg->SetFillColor(0);
0105   leg->SetLineColor(0);
0106   leg->Draw();
0107   ////////////////////// Response ///////////////////////////////////////
0108   sprintf(name,"ResponseComparison");
0109   TCanvas *c_Correction = new TCanvas(name,name,900,600);
0110   c_Correction->cd();
0111   gPad->SetLogx(); 
0112   g_Resp[0]->SetTitle("");
0113   g_Resp[0]->GetXaxis()->SetTitle("p_{T}^{gen} (GeV)");
0114   g_Resp[0]->GetYaxis()->SetTitle("Response");
0115   g_Resp[0]->SetMaximum(1);
0116   g_Resp[0]->SetMinimum(0);
0117   g_Resp[0]->Draw("AP");
0118   TLegend *leg = new TLegend(0.5,0.15,0.85,0.4);
0119   for(alg=0;alg<NAlg;alg++)
0120     {
0121       color = alg+1;
0122       if (color==5)
0123         color = 7;
0124       g_Resp[alg]->SetMarkerStyle(20+alg);
0125       g_Resp[alg]->SetMarkerColor(color);
0126       g_Resp[alg]->SetLineColor(color);
0127       g_Resp[alg]->SetLineStyle(1);
0128       RespFit[alg]->SetLineColor(color);
0129       RespFit[alg]->SetLineStyle(1);
0130       RespFit[alg]->SetLineWidth(2); 
0131       g_Resp[alg]->Draw("sameP");
0132       leg->AddEntry(g_Resp[alg],filename[alg],"LP");
0133     }
0134   leg->SetFillColor(0);
0135   leg->SetLineColor(0);
0136   leg->Draw();
0137 }
0138 
0139 void PrintMessage()
0140 {
0141   cout<<"This ROOT macro can compare up to 5 cases."<<endl;
0142   cout<<"Usage: .X DrawL3Comparison.C(\"filename1\",...,\"filename5\")"<<endl;
0143 }
0144