Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "TText.h"
0002 #include "TFile.h"
0003 #include "TH1F.h"
0004 #include "TCanvas.h"
0005 #include "TLegend.h"
0006 
0007 void DoCompare_DT( ){
0008 
0009  static const int NHisto = 23;
0010 
0011  TText* te = new TText();
0012  te->SetTextSize(0.1);
0013 
0014  TPaveStats* st_1;
0015  TPaveStats* st_2;
0016  
0017   gROOT->ProcessLine(".x HistoCompare.C");
0018   HistoCompare * myPV = new HistoCompare();
0019 
0020  char*  reffilename  = "${REFFILE}";//"./DTSimHitsPlots_ref.root";
0021  char*  curfilename  = "${CURFILE}";//"./DTSimHitsPlots.root";
0022 
0023  TFile * reffile = new TFile(reffilename);
0024  TFile * curfile = new TFile(curfilename);
0025 
0026  curfile->cd("DQMData/MuonDTHitsV/DTHitsValidationTask");
0027  gDirectory->ls();
0028 
0029 
0030  //1-Dimension Histogram
0031  char* label[NHisto];
0032  char* label_dir[NHisto];
0033 
0034  label[0] = "Number_of_all_DT_hits";
0035  label[1] = "Number_of_muon_DT_hits";
0036  label[2] = "Wheel_occupancy";
0037  label[3] = "Station_occupancy";
0038  label[4] = "Sector_occupancy";
0039  label[5] = "SuperLayer_occupancy";
0040  label[6] = "Layer_occupancy";
0041  label[7] = "Wire_occupancy";
0042  label[8] = "DT_energy_loss_keV";
0043  label[9] = "chamber_occupancy";
0044  label[10] = "Momentum_at_MB1";
0045  label[11] = "Momentum_at_MB4";
0046  label[12] = "Loss_of_muon_Momentum_in_Iron";
0047  label[13] = "path_followed_by_muon";
0048  label[14] = "Tof_of_hits";
0049  label[15] = "radius_of_hit";
0050  label[16] = "costheta_of_hit";
0051  label[17] = "global_eta_of_hit";
0052  label[18] = "global_phi_of_hit";
0053  label[19] = "Local_x-coord_vs_local_z-coord_of_muon_hit";
0054  label[20] = "local_x-coord_vs_local_y-coord_of_muon_hit";
0055  label[21] = "Global_x-coord_vs_global_z-coord_of_muon_hit";
0056  label[22] = "Global_x-coord_vs_global_y-coord_of_muon_hit";
0057 
0058  char stringall[90];
0059 
0060  TH1F* htemp1[NHisto];
0061  TH1F* htemp2[NHisto];
0062 
0063  for ( int i = 0; i< NHisto ; i++ ) {
0064    char title[50];
0065    TCanvas c1;
0066 //   cout << "label(i)" << label[i] << endl;
0067 
0068  
0069    sprintf(stringall, "DQMData/MuonDTHitsV/DTHitsValidationTask/%s",label[i]);
0070    label_dir[i] = stringall;
0071 
0072    if ( i<19 ) 
0073    {
0074      htemp1[i]  = dynamic_cast<TH1F*>(reffile->Get(label[i]));
0075      htemp2[i]  = dynamic_cast<TH1F*>(curfile->Get(label_dir[i]));
0076      if( htemp1[i] == 0 ) std::cout << " reference histo is empty " << endl;
0077      if( htemp2[i] == 0 ) std::cout << " current histo is empty " << endl;
0078 
0079      htemp1[i]->SetLineColor(2);
0080      htemp2[i]->SetLineColor(4);
0081      htemp1[i]->SetLineStyle(1);
0082      htemp2[i]->SetLineStyle(2);
0083      htemp1[i]->SetLineWidth(2);
0084      htemp2[i]->SetLineWidth(2);   
0085 
0086      TLegend leg(0.1, 0.15, 0.2, 0.25);
0087      leg.AddEntry(htemp1[i], "Reference", "l");
0088      leg.AddEntry(htemp2[i], "New ", "l");
0089 //   if (i>14 && i<19 || i>29 && i< 34 || i == 13 || i>37 ) c1.SetLogy();
0090 
0091      htemp1[i]->Draw();
0092      gStyle->SetOptStat(1111);  
0093      st_1 = (TPaveStats*)htemp1[i]->GetListOfFunctions()->FindObject("stats");
0094 
0095      htemp2[i]->Draw();
0096      gStyle->SetOptStat(1111);
0097      st_2 = (TPaveStats*)htemp2[i]->GetListOfFunctions()->FindObject("stats");
0098 
0099      TPaveStats* sta_1= (TPaveStats*)st_1->Clone();
0100      
0101       sta_1->SetTextColor(2);
0102       sta_1->SetX1NDC(.80);
0103       sta_1->SetX2NDC(0.95);
0104       sta_1->SetY1NDC(0.70);
0105       sta_1->SetY2NDC(0.85);
0106 
0107       TPaveStats* sta_2= (TPaveStats*)st_2->Clone();
0108 
0109       sta_2->SetTextColor(4);
0110       sta_2->SetX1NDC(.80);
0111       sta_2->SetX2NDC(0.95);
0112       sta_2->SetY1NDC(0.85);
0113       sta_2->SetY2NDC(1.0);
0114 
0115       gStyle->SetOptStat(000000);
0116       htemp2[i]->Draw();
0117       gStyle->SetOptStat(000000);
0118       htemp1[i]->Draw("Same");
0119       sta_2->Draw("Same");
0120       sta_1->Draw("Same");
0121 
0122 
0123      leg.Draw();
0124      myPV->PVCompute(htemp1[i],htemp2[i], te);
0125      sprintf(title,"%s%s", label[i],".eps");
0126      c1.Print(title);
0127    
0128    } else {
0129 
0130      htemp1[i]  = dynamic_cast<TH2F*>(reffile->Get(label[i]));
0131      htemp2[i]  = dynamic_cast<TH2F*>(curfile->Get(label_dir[i]));
0132  
0133      htemp1[i]->SetMarkerStyle(21);
0134      htemp2[i]->SetMarkerStyle(22);
0135      htemp1[i]->SetMarkerColor(2);
0136      htemp2[i]->SetMarkerColor(4);
0137      htemp1[i]->SetMarkerSize(0.3);
0138      htemp2[i]->SetMarkerSize(0.3);
0139  
0140      c1.Divide(1,2);
0141      c1.cd(1);
0142      htemp1[i]->Draw();
0143      leg.Draw();
0144      
0145      c1.cd(2);
0146      htemp2[i]->Draw();
0147      leg.Draw();
0148 
0149      sprintf(title,"%s%s", label[i],".eps");  
0150      c1.Print(title);
0151   } 
0152  }
0153 
0154 
0155 }
0156 
0157