Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:29

0001 // Commands executed in a GLOBAL scope, e.g. created hitograms aren't erased...

0002 {
0003   //***************************************************************************

0004 
0005 
0006    TCanvas *myc = new TCanvas("myc","",800,600);
0007       
0008    TFile f3("HF_histo_pre5.root");
0009    TFile f4("HF_histo_pre6.root");
0010 
0011    const int Nhist = 4;
0012    TH1F* f3_hist[Nhist];
0013    TH1F* f4_hist[Nhist];
0014    //   cout << "1" << endl;

0015 
0016    char *label[Nhist];
0017 
0018    label[0] = &"Thits.gif";
0019    label[1] = &"Nhits.gif";
0020    label[2] = &"Long_pe.gif";
0021    label[3] = &"Short_pe.gif";
0022 
0023    f3_hist[0] = (TH1F*)f3.Get("h15") ;
0024    f4_hist[0] = (TH1F*)f4.Get("h15") ;
0025 
0026    f3_hist[1] = (TH1F*)f3.Get("h17") ;
0027    f4_hist[1] = (TH1F*)f4.Get("h17") ;
0028 
0029    f3_hist[2] = (TH1F*)f3.Get("h18") ;
0030    f4_hist[2] = (TH1F*)f4.Get("h18") ;
0031 
0032    f3_hist[3] = (TH1F*)f3.Get("h19") ;
0033    f4_hist[3] = (TH1F*)f4.Get("h19") ;
0034 
0035    //

0036    f3_hist[0]->GetXaxis()->SetTitle("T_{hits} (ns)");
0037    f3_hist[0]->GetYaxis()->SetTitle("N_{ev}/bin");
0038 
0039    f3_hist[1]->GetXaxis()->SetTitle("N_{hits}");
0040    f3_hist[1]->GetYaxis()->SetTitle("N_{ev}/bin");
0041 
0042    f3_hist[2]->GetXaxis()->SetTitle("Long Fibers p.e.");
0043    f3_hist[2]->GetYaxis()->SetTitle("N_{ev}/bin");
0044 
0045    f3_hist[3]->GetXaxis()->SetTitle("Short Fibers p.e. ");
0046    f3_hist[3]->GetYaxis()->SetTitle("N_{ev}/bin");
0047 
0048 
0049    //  f3_hist[0]->SetMaximum(5000.);

0050    // f1_hist[5]->SetMinimum(0.9);

0051    // f1_hist[5]->SetMaximum(1.02.);

0052 
0053    for (int i = 0; i < Nhist; i++){
0054  
0055      f3_hist[i]->SetStats(kTRUE);
0056      f4_hist[i]->SetStats(kTRUE);
0057 
0058      f3_hist[i]->SetTitle("");
0059      f4_hist[i]->SetTitle("");
0060     
0061      f3_hist[i]->SetLineColor(41);
0062      f3_hist[i]->SetLineWidth(2); 
0063      f3_hist[i]->SetLineStyle(1); 
0064      f4_hist[i]->SetLineColor(43);
0065      f4_hist[i]->SetLineWidth(3); 
0066      f4_hist[i]->SetLineStyle(2);
0067      
0068      //...Set axis title - sizes are absolute 

0069      f3_hist[i]->GetXaxis()->SetTickLength(-0.01);
0070      f3_hist[i]->GetYaxis()->SetTickLength(-0.01);
0071      f3_hist[i]->GetXaxis()->SetTitleOffset(1.5);
0072      f3_hist[i]->GetYaxis()->SetTitleOffset(1.5);
0073      f3_hist[i]->GetXaxis()->SetLabelOffset(0.02);
0074      f3_hist[i]->GetYaxis()->SetLabelOffset(0.02);
0075      f3_hist[i]->GetXaxis()->SetLabelSize(0.04);
0076      f3_hist[i]->GetYaxis()->SetLabelSize(0.04);
0077      f3_hist[i]->GetXaxis()->SetTitleSize(0.045);
0078      f3_hist[i]->GetYaxis()->SetTitleSize(0.045);
0079 
0080      // Chi2 test

0081      const float NCHI2MIN = 0.01;
0082      
0083      float pval;
0084      stringstream mystream;
0085      char tempbuff[30];
0086      
0087      pval = f3_hist[i]->Chi2Test(f4_hist[i]);
0088      
0089      sprintf(tempbuff,"Chi2 p-value: %6.3E%c",pval,'\0');
0090      mystream<<tempbuff;
0091      
0092      TPaveText* ptchi2 = new TPaveText(0.25, 0.91, 0.5, 0.99, "NDC");
0093      
0094      if (pval > NCHI2MIN) ptchi2->SetFillColor(kGreen);
0095      else                 ptchi2->SetFillColor(kRed);
0096      
0097      ptchi2->SetTextSize(0.03);
0098      ptchi2->AddText(mystream.str().c_str());
0099      //

0100 
0101 
0102 
0103      //...Legend

0104      TLegend *leg = new TLegend(0.55, 0.91, 0.84, 0.99, "","brNDC");
0105      leg->SetBorderSize(2);
0106      leg->SetFillStyle(1001); //

0107 
0108      leg->AddEntry(f3_hist[i],"CMSSW_300pre5","l");
0109      leg->AddEntry(f4_hist[i],"CMSSW_300pre6","l");
0110 
0111 
0112      if (i >= 0) {
0113        TPaveStats *ptstats = new TPaveStats(0.85,0.86,0.98,0.98,"brNDC");
0114        ptstats->SetTextColor(41);
0115        f3_hist[i]->GetListOfFunctions()->Add(ptstats);
0116        ptstats->SetParent(f3_hist[i]->GetListOfFunctions());
0117        TPaveStats *ptstats = new TPaveStats(0.85,0.74,0.98,0.86,"brNDC");
0118        ptstats->SetTextColor(43);
0119        f4_hist[i]->GetListOfFunctions()->Add(ptstats);
0120        ptstats->SetParent(f4_hist[i]->GetListOfFunctions());
0121        
0122        f3_hist[i]->Draw(""); // "stat"   

0123        f4_hist[i]->Draw("hist sames");   
0124      }
0125      else { 
0126        f3_hist[i]->Draw("hist");   
0127        f4_hist[i]->Draw("hist same");   
0128      }
0129 
0130      ptchi2->Draw();
0131      leg->Draw();   
0132 
0133      
0134      myc->SaveAs(label[i]);
0135    }     
0136 
0137 
0138    // close ROOT files

0139 
0140    f3.Close() ;
0141    f4.Close() ;
0142    
0143    return ;  
0144      
0145 }