Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:28:07

0001 #include "TText.h"
0002 #include "TFile.h"
0003 #include "TH1F.h"
0004 #include "TCanvas.h"
0005 #include "TLegend.h"
0006 
0007 void DoCompareandDivide( ){
0008 
0009  static const int NHisto = 8;
0010 
0011  TText* te = new TText();
0012  te->SetTextSize(0.1);
0013  
0014  TPaveStats* st_1;
0015  TPaveStats* st_2;
0016 
0017   char*  reffilename  = "${REFFILE}";  // "./DTDigiPlots.root";
0018 
0019  TFile * reffile = new TFile(reffilename);
0020 
0021  reffile->cd("DQMData/DTDigiValidationTask");
0022  gDirectory->ls(); 
0023 
0024  //1-Dimension Histogram
0025  char* label[NHisto];
0026  char* label_dir[NHisto];
0027  char stringall[80];
0028  
0029  label[0] = "Simhit_occupancy_MB1";
0030  label[1] = "Digi_occupancy_MB1";
0031  label[2] = "Simhit_occupancy_MB2";
0032  label[3] = "Digi_occupancy_MB2";
0033  label[4] = "Simhit_occupancy_MB3";
0034  label[5] = "Digi_occupancy_MB3";
0035  label[6] = "Simhit_occupancy_MB4";
0036  label[7] = "Digi_occupancy_MB4";
0037 
0038 
0039 
0040  TH1F* htemp1;
0041  TH1F* htemp2;
0042 
0043  for ( int i = 0; i<4 ; i++ ) {
0044    char title[50];
0045    TCanvas c1;
0046  
0047    sprintf(stringall, "DQMData/DTDigiValidationTask/%s",label[2*i]);
0048    label_dir[2*i] = stringall;
0049    htemp1  = dynamic_cast<TH1F*>(reffile->Get(label_dir[2*i]));
0050 
0051    sprintf(stringall, "DQMData/DTDigiValidationTask/%s",label[2*i+1]);
0052    label_dir[2*i+1] = stringall; 
0053    htemp2  = dynamic_cast<TH1F*>(reffile->Get(label_dir[2*i+1]));
0054   
0055    if( htemp1 == 0 ) std::cout << " SimHits histo is empty " << endl;
0056    if( htemp2 == 0 ) std::cout << " Digis histo is empty " << endl;
0057    if( htemp1 == 0 || htemp2 == 0) continue;
0058    htemp1->SetLineColor(4);
0059    htemp2->SetLineColor(6);
0060    htemp1->SetLineStyle(1);
0061    htemp2->SetLineStyle(1);
0062    htemp1->SetLineWidth(2);
0063    htemp2->SetLineWidth(2);
0064    TLegend leg(0.1, 0.2, 0.2, 0.3);
0065    leg.AddEntry(htemp1, "Muon SimHits", "l");
0066    leg.AddEntry(htemp2, "All Digis ", "l");
0067  
0068    htemp2->Draw();
0069    gStyle->SetOptStat(1111);
0070    st_2 = (TPaveStats*)htemp2->GetListOfFunctions()->FindObject("stats");
0071 
0072    htemp1->Draw();
0073    gStyle->SetOptStat(1111);
0074    st_1 = (TPaveStats*)htemp1->GetListOfFunctions()->FindObject("stats");
0075 
0076    TPaveStats* sta_1= (TPaveStats*)st_1->Clone();
0077 
0078    sta_1->SetTextColor(2);
0079    sta_1->SetX1NDC(.80);
0080    sta_1->SetX2NDC(0.95);
0081    sta_1->SetY1NDC(0.70);
0082    sta_1->SetY2NDC(0.85);
0083 
0084    TPaveStats* sta_2= (TPaveStats*)st_2->Clone();
0085 
0086    sta_2->SetTextColor(4);
0087    sta_2->SetX1NDC(.80);
0088    sta_2->SetX2NDC(0.95);
0089    sta_2->SetY1NDC(0.85);
0090    sta_2->SetY2NDC(1.0);
0091 
0092    gStyle->SetOptStat(000000);
0093    htemp2->Draw();
0094    gStyle->SetOptStat(000000);
0095    htemp1->Draw("Same");
0096    sta_2->Draw("Same");
0097    sta_1->Draw("Same");
0098 
0099    leg.Draw();
0100    sprintf(title,"%s%s", label[2*i],"_and_Digi.eps");   
0101    c1.Print(title);
0102 
0103    TH1F* hout = new TH1F(*htemp1);
0104    hout->Reset();
0105    hout->SetName((std::string(htemp1->GetName()) + std::string("_by_") + std::string(htemp2->GetName())).c_str());
0106    
0107 
0108    hout->Divide(htemp2,htemp1,1.,1.,"B");
0109    hout->Draw();
0110 
0111 
0112 //   myPV->PVCompute(htemp1[i],htemp2[i], te);
0113    sprintf(title,"%s%s", label[2*i+1],"_over_Digi_ratio.eps");
0114   c1.Print(title);
0115  }
0116 
0117 
0118 }
0119 
0120