Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "TText.h"
0002 #include "TFile.h"
0003 #include "TH1F.h"
0004 #include "TCanvas.h"
0005 #include "TLegend.h"
0006 #include "TPaveStats.h"
0007 #include "TPaveLabel"
0008 
0009 void DoCompare( ){
0010 
0011  static const int NHisto = 81;
0012 
0013  TText* te = new TText();
0014  te->SetTextSize(0.1);
0015  TPaveStats* st_1, st_2; 
0016  
0017   gROOT->ProcessLine(".x HistoCompare.C");
0018   HistoCompare * myPV = new HistoCompare();
0019 
0020  char*  reffilename  = "${REFFILE}";  //"./DTDigiPlots_ref.root";
0021  char*  curfilename  = "${CURFILE}";  //"./DTDigiPlots.root";
0022 
0023  TFile * reffile = new TFile(reffilename);
0024  TFile * curfile = new TFile(curfilename);
0025 
0026  reffile->cd("DQMData/DTDigiValidationTask");
0027  gDirectory->ls();
0028 
0029  curfile->cd("DQMData/DTDigiValidationTask");
0030  gDirectory->ls();
0031 
0032  //1-Dimension Histogram
0033  char* label[NHisto];
0034  char* label_dir[NHisto];
0035 
0036  label[0] = "DigiTimeBox";            
0037  label[1] = "DigiTimeBox_wheel2m";   
0038  label[2] = "DigiTimeBox_wheel1m";
0039  label[3] = "DigiTimeBox_wheel0";
0040  label[4] = "DigiTimeBox_wheel1p";
0041  label[5] = "DigiTimeBox_wheel2p";  
0042  label[6] = "DigiEfficiencyMu";
0043  label[7] = "DigiEfficiency";
0044  label[8] = "Number_Digi_per_layer";
0045  label[9] = "Number_simhit_vs_digi";
0046  label[10] = "Wire_Number_with_double_Digi";
0047  label[11] = "Simhit_occupancy_MB1";
0048  label[12] = "Digi_occupancy_MB1";             
0049  label[13] = "Simhit_occupancy_MB2";
0050  label[14] = "Digi_occupancy_MB2";
0051  label[15] = "Simhit_occupancy_MB3";
0052  label[16] = "Digi_occupancy_MB3";
0053  label[17] = "Simhit_occupancy_MB4";
0054  label[18] = "Digi_occupancy_MB4"; 
0055  
0056  char stringcham[40]; 
0057  char stringall[80];
0058  
0059  TH1F* htemp1[NHisto];
0060  TH1F* htemp2[NHisto];
0061  for ( int i = 0; i< NHisto ; i++ ) {
0062    char title[50];
0063    TCanvas c1;
0064    if ( i>18 )
0065     {
0066       sprintf(stringcham, "DigiTimeBox_slid_%d", i-19) ;
0067       label[i] = stringcham;
0068     }
0069       sprintf(stringall, "DQMData/DTDigiValidationTask/%s",label[i]);
0070       label_dir[i] = stringall;
0071    
0072    htemp1[i]  = dynamic_cast<TH1F*>(reffile->Get(label_dir[i]));
0073    htemp2[i]  = dynamic_cast<TH1F*>(curfile->Get(label_dir[i]));
0074    if( htemp1[i] == 0 ) std::cout << " reference histo is empty " << endl;
0075    if( htemp2[i] == 0 ) std::cout << " current version histo is empty " << endl;
0076    if( htemp1[i] == 0 || htemp2[i] == 0) continue;
0077    
0078    htemp1[i]->SetLineColor(2);
0079    htemp2[i]->SetLineColor(4);
0080    htemp1[i]->SetLineStyle(3);
0081    htemp2[i]->SetLineStyle(5);
0082    TLegend leg(0.1, 0.15, 0.2, 0.25);
0083    leg.AddEntry(htemp1[i], "Reference", "l");
0084    leg.AddEntry(htemp2[i], "New ", "l");
0085 
0086    htemp2[i]->Draw();
0087    gStyle->SetOptStat(1111);
0088    st_2 = (TPaveStats*)htemp2[i]->GetListOfFunctions()->FindObject("stats");
0089 
0090     htemp1[i]->Draw();
0091     gStyle->SetOptStat(1111);
0092     st_1 = (TPaveStats*)htemp1[i]->GetListOfFunctions()->FindObject("stats");
0093 
0094     TPaveStats* sta_1= (TPaveStats*)st_1->Clone();
0095 
0096     sta_1->SetTextColor(2);
0097     sta_1->SetX1NDC(.80);
0098     sta_1->SetX2NDC(0.95);
0099     sta_1->SetY1NDC(0.70);
0100     sta_1->SetY2NDC(0.85);
0101 
0102     TPaveStats* sta_2= (TPaveStats*)st_2->Clone();
0103     
0104     sta_2->SetTextColor(4);
0105     sta_2->SetX1NDC(.80);
0106     sta_2->SetX2NDC(0.95);
0107     sta_2->SetY1NDC(0.85);
0108     sta_2->SetY2NDC(1.0);
0109 
0110     gStyle->SetOptStat(000000);
0111     htemp2[i]->Draw();
0112     gStyle->SetOptStat(000000);
0113     htemp1[i]->Draw("Same"); 
0114     sta_2->Draw("Same");
0115     sta_1->Draw("Same"); 
0116     leg.Draw();
0117     myPV->PVCompute(htemp1[i],htemp2[i], te);
0118     sprintf(title,"%s%s", label[i],".eps");
0119     c1.Print(title);
0120  }
0121 
0122 
0123 }
0124 
0125