Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:32:58

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

0002 {
0003 
0004    TCanvas *myc = new TCanvas("myc","",800,600);
0005       
0006    //

0007 
0008    TFile f1("HE_histo_pre5.root");
0009    TFile f2("HE_histo_pre6.root");
0010 
0011    // service variables

0012    //

0013    const int Nhist = 9;
0014    TH1F* f1_hist[Nhist];
0015    TH1F* f2_hist[Nhist];
0016    char *label[Nhist];
0017 
0018    label[0] = &"layer0.gif";
0019    label[1] = &"Lprofile.gif";
0020    label[2] = &"Nhits.gif";
0021    label[3] = &"Thits.gif";
0022    label[4] = &"ThitsEw.gif";
0023    label[5] = &"NxNfract.gif";
0024    label[6] = &"layer7.gif";
0025    label[7] = &"Erec_cone.gif";
0026    label[8] = &"Edep_tot.gif";
0027 
0028    f1_hist[0] = (TH1F*)f1.Get("hl0") ;
0029    f2_hist[0] = (TH1F*)f2.Get("hl0") ;
0030 
0031    f1_hist[1] = (TH1F*)f1.Get("h45") ;
0032    f2_hist[1] = (TH1F*)f2.Get("h45") ;
0033 
0034    f1_hist[2] = (TH1F*)f1.Get("h43") ;
0035    f2_hist[2] = (TH1F*)f2.Get("h43") ;
0036 
0037    f1_hist[3] = (TH1F*)f1.Get("h40") ;
0038    f2_hist[3] = (TH1F*)f2.Get("h40") ;
0039 
0040    f1_hist[4] = (TH1F*)f1.Get("h41") ;
0041    f2_hist[4] = (TH1F*)f2.Get("h41") ;
0042 
0043    f1_hist[5] = (TH1F*)f1.Get("h39") ;
0044    f2_hist[5] = (TH1F*)f2.Get("h39") ;
0045 
0046    f1_hist[6] = (TH1F*)f1.Get("hl6") ;
0047    f2_hist[6] = (TH1F*)f2.Get("hl6") ;
0048 
0049    f1_hist[7] = (TH1F*)f1.Get("h6") ;
0050    f2_hist[7] = (TH1F*)f2.Get("h6") ;
0051 
0052    f1_hist[8] = (TH1F*)f1.Get("h46") ;
0053    f2_hist[8] = (TH1F*)f2.Get("h46") ;
0054 
0055    f1_hist[0]->GetXaxis()->SetTitle("L0 Deposited energy (GeV)");
0056    f1_hist[0]->GetYaxis()->SetTitle("N_{ev}/bin");
0057 
0058    f1_hist[1]->GetXaxis()->SetTitle("N_{layer}");
0059    f1_hist[1]->GetYaxis()->SetTitle("Deposited energy (GeV)");
0060 
0061    f1_hist[2]->GetXaxis()->SetTitle("N_{hits}");
0062    f1_hist[2]->GetYaxis()->SetTitle("N_{ev}");
0063 
0064    f1_hist[3]->GetXaxis()->SetTitle("t_{hits} (ns)");
0065    f1_hist[3]->GetYaxis()->SetTitle("N_{ev}/bin");
0066 
0067    f1_hist[4]->GetXaxis()->SetTitle("t_{hist} (ns)");
0068    f1_hist[4]->GetYaxis()->SetTitle("Energy/bin (MeV)");
0069 
0070    f1_hist[5]->GetXaxis()->SetTitle("NxN square number");
0071    f1_hist[5]->GetYaxis()->SetTitle("Fraction of energy");
0072 
0073    f1_hist[6]->GetXaxis()->SetTitle("L7 Deposited energy (GeV)");
0074    f1_hist[6]->GetYaxis()->SetTitle("N_{ev}/bin");
0075 
0076    f1_hist[7]->GetXaxis()->SetTitle("Pseudo-reconstructed energy (GeV)");
0077    f1_hist[7]->GetYaxis()->SetTitle("N_{ev}/bin");
0078 
0079    f1_hist[8]->GetXaxis()->SetTitle("Deposited energy (GeV)");
0080    f1_hist[8]->GetYaxis()->SetTitle("N_{ev}/bin");
0081 
0082 
0083    f1_hist[2]->GetXaxis()->SetRangeUser(0.,2000.);
0084    f1_hist[7]->GetXaxis()->SetRangeUser(0.,100.);
0085    f1_hist[8]->GetXaxis()->SetRangeUser(0.,1.);
0086   // hist1->GetXaxis()->SetNdivisions(-21);

0087   //  hist1->GetYaxis()->SetNdivisions(-1003);

0088 
0089    for (int i = 0; i < Nhist; i++){
0090 
0091      if(i == 5 ) { 
0092        f1_hist[i]->SetStats(kFALSE);   
0093        f2_hist[i]->SetStats(kFALSE); 
0094      }
0095      else {
0096        f1_hist[i]->SetStats(kTRUE);   
0097        f2_hist[i]->SetStats(kTRUE); 
0098      }
0099  
0100      f1_hist[i]->SetTitle("");
0101      f2_hist[i]->SetTitle("");
0102 
0103      f1_hist[i]->SetLineWidth(2); 
0104      f2_hist[i]->SetLineWidth(3); 
0105 
0106      // diffferent histo colors and styles

0107      f1_hist[i]->SetLineColor(41);
0108      f1_hist[i]->SetLineStyle(1); 
0109 
0110      f2_hist[i]->SetLineColor(43);
0111      f2_hist[i]->SetLineStyle(2);  
0112 
0113      //...Set axis title - sizes are absolute 

0114      f1_hist[i]->GetXaxis()->SetTickLength(-0.01);
0115      f1_hist[i]->GetYaxis()->SetTickLength(-0.01);
0116      f1_hist[i]->GetXaxis()->SetTitleOffset(1.5);
0117      f1_hist[i]->GetYaxis()->SetTitleOffset(1.5);
0118      f1_hist[i]->GetXaxis()->SetLabelOffset(0.02);
0119      f1_hist[i]->GetYaxis()->SetLabelOffset(0.02);
0120      f1_hist[i]->GetXaxis()->SetLabelSize(0.04);
0121      f1_hist[i]->GetYaxis()->SetLabelSize(0.04);
0122      f1_hist[i]->GetXaxis()->SetTitleSize(0.045);
0123      f1_hist[i]->GetYaxis()->SetTitleSize(0.045);
0124 
0125      TLegend *leg = new TLegend(0.55, 0.91, 0.84, 0.99, "","brNDC");
0126 
0127      leg->SetBorderSize(2);
0128      //  leg->SetFillColor(51); // see new color definition above

0129      leg->SetFillStyle(1001); //

0130      leg->AddEntry(f1_hist[i],"CMSSW_300pre5","l");
0131      leg->AddEntry(f2_hist[i],"CMSSW_300pre6","l");
0132      
0133      if (i != 5) {
0134        TPaveStats *ptstats = new TPaveStats(0.85,0.86,0.98,0.98,"brNDC");
0135        ptstats->SetTextColor(41);
0136        f1_hist[i]->GetListOfFunctions()->Add(ptstats);
0137        ptstats->SetParent(f1_hist[i]->GetListOfFunctions());
0138        TPaveStats *ptstats = new TPaveStats(0.85,0.74,0.98,0.86,"brNDC");
0139        ptstats->SetTextColor(43);
0140        f2_hist[i]->GetListOfFunctions()->Add(ptstats);
0141        ptstats->SetParent(f2_hist[i]->GetListOfFunctions());
0142 
0143        f1_hist[i]->Draw(""); // "stat"

0144        f2_hist[i]->Draw("hist sames");
0145      }
0146      else {
0147        f1_hist[i]->Draw("hist");
0148        f2_hist[i]->Draw("hist same");
0149      }
0150 
0151      leg->Draw();   
0152 
0153      // Chi2 test

0154      if(i == 2 || i == 3 || i == 7 || i ==8 ) {
0155        const float NCHI2MIN = 0.01;
0156        
0157        float pval;
0158        stringstream mystream;
0159        char tempbuff[30];
0160        
0161        pval = f1_hist[i]->Chi2Test(f2_hist[i]);
0162        //     cout << "i_hist "  << i << " pval = " << pval << endl;

0163        
0164        sprintf(tempbuff,"Chi2 p-value: %6.3E%c",pval,'\0');
0165        mystream<<tempbuff;
0166        
0167        TPaveText* ptchi2 = new TPaveText(0.25, 0.91, 0.5, 0.99, "NDC");
0168        
0169        if (pval > NCHI2MIN) ptchi2->SetFillColor(kGreen);
0170        else                 ptchi2->SetFillColor(kRed);
0171        
0172        ptchi2->SetTextSize(0.03);
0173        ptchi2->AddText(mystream.str().c_str()); 
0174        ptchi2->Draw();
0175 
0176      }
0177      
0178      myc->SaveAs(label[i]);
0179    }     
0180 
0181    // close ROOT files

0182    //

0183    f1.Close() ;  
0184    f2.Close() ;
0185    
0186    return ;  
0187      
0188 }