Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:34:36

0001 void SiTrackerHitsCompareToF()
0002 {
0003 
0004  gROOT ->Reset();
0005  gStyle->SetNdivisions(504,"XYZ");
0006  gStyle->SetStatH(0.18);
0007  gStyle->SetStatW(0.35);
0008  
0009  char*  cfilename = "TrackerHitHisto.root"; //current
0010  char*  rfilename = "../TrackerHitHisto.root";  //reference
0011 
0012  delete gROOT->GetListOfFiles()->FindObject(rfilename);
0013  delete gROOT->GetListOfFiles()->FindObject(cfilename); 
0014 
0015  TText* te = new TText();
0016  TFile * rfile = new TFile(rfilename);
0017  TDirectory * rdir=gDirectory; 
0018  TFile * cfile = new TFile(cfilename);
0019  TDirectory * cdir=gDirectory; 
0020 
0021  if(rfile->cd("DQMData/Run 1/TrackerHitsV"))rfile->cd("DQMData/Run 1/TrackerHitsV/Run summary/TrackerHit");
0022  else rfile->cd("DQMData/TrackerHitsV/TrackerHit");
0023  rdir=gDirectory;
0024 
0025  if(cfile->cd("DQMData/Run 1/TrackerHitsV"))cfile->cd("DQMData/Run 1/TrackerHitsV/Run summary/TrackerHit");
0026  else cfile->cd("DQMData/TrackerHitsV/TrackerHit");
0027  cdir=gDirectory; 
0028  
0029   TLegend leg(0.3, 0.83, 0.55, 0.90);
0030  //Get list of Keys from the Reference file.
0031   TList* ref_list = rfile->GetListOfKeys() ;
0032   if (!ref_list) {
0033       std::cout<<"=========>> AutoComaprison:: There is no Keys available in the Reference file."<<std::endl;
0034       exit(1) ;
0035    }
0036 
0037   //Get list of Keys from the New file.
0038   TList* new_list = cfile->GetListOfKeys() ;
0039   if (!new_list) {
0040       std::cout<<"=========>> AutoComaprison:: There is no Keys available in New file."<<std::endl;
0041       exit(1) ;
0042    }
0043 
0044 
0045   //Iterate on the List of Keys of the  Reference file.
0046   TIter     refkey_iter( ref_list) ;
0047   TKey*     ref_key ;
0048   TObject*  ref_obj ;
0049 
0050   char rver[50];
0051   char cver[50];
0052   while ( ref_key = (TKey*) refkey_iter() ) {
0053       ref_obj = ref_key->ReadObj() ;
0054       if (strcmp(ref_obj->IsA()->GetName(),"TObjString")==0) {
0055 
0056          TObjString * rversion = dynamic_cast< TObjString*> (ref_obj);
0057          sprintf(rver, "%s", rversion->GetName());
0058          std::cout<<" Ref. version =" << rver<<std::endl;
0059          break;
0060       }
0061   }
0062 
0063   //Iterate on the List of Keys of the  Reference file.
0064   TIter     newkey_iter( new_list) ;
0065   TKey*     new_key ;
0066   TObject*  new_obj ;
0067   while ( new_key = (TKey*) newkey_iter() ) {
0068       new_obj = new_key->ReadObj() ;
0069       if (strcmp(new_obj->IsA()->GetName(),"TObjString")==0) {
0070 
0071          TObjString * cversion = dynamic_cast< TObjString*> (new_obj);
0072          sprintf(cver, "%s", cversion->GetName());
0073          std::cout<<" Cur version =" << cver<<std::endl;
0074          break;
0075 
0076       }
0077   }
0078 
0079 
0080  ofstream outfile("LowKS_energy_list.dat");
0081 
0082  string statp = "KS prob";
0083  Double_t ks1e[12],ks2e[12],ks3e[12],ks4e[12],ks5e[12],ks6e[12];
0084  
0085  gROOT->ProcessLine(".x HistoCompare.C");
0086  HistoCompare * PV = new HistoCompare();
0087  
0088  Char_t histo[200];
0089  Char_t profileo[200];
0090  Char_t profilen[200];
0091  std::strstream buf;
0092  std::string value;
0093  
0094    TCanvas * ToF = new TCanvas("ToF","ToF",600,800);
0095    ToF->Divide(2,2);
0096 
0097    TProfile * ch1e[4];
0098    TProfile * rh1e[4];
0099    cout<<cdir->GetPath()<<endl;
0100    cout<<rdir->GetPath()<<endl;
0101      sprintf(histo,"tof_eta");
0102      sprintf(profileo,"tof_eta_old");
0103      sprintf(profilen,"tof_eta_new");
0104      rh1e[0] = ((TH2F*)rdir->Get(histo))->ProfileX(profileo);
0105      ch1e[0] = ((TH2F*)cdir->Get(histo))->ProfileX(profilen);
0106      sprintf(histo,"tof_phi");
0107      sprintf(profileo,"tof_phi_old");
0108      sprintf(profilen,"tof_phi_new");
0109      rh1e[1] = ((TH2F*)rdir->Get(histo))->ProfileX(profileo);
0110      ch1e[1] = ((TH2F*)cdir->Get(histo))->ProfileX(profilen);
0111      sprintf(histo,"tof_r");
0112      sprintf(profileo,"tof_r_old");
0113      sprintf(profilen,"tof_r_new");
0114      rh1e[2] = ((TH2F*)rdir->Get(histo))->ProfileX(profileo);
0115      ch1e[2] = ((TH2F*)cdir->Get(histo))->ProfileX(profilen);
0116      sprintf(histo,"tof_z");
0117      sprintf(profileo,"tof_z_old");
0118      sprintf(profilen,"tof_z_new");
0119      rh1e[3] = ((TH2F*)rdir->Get(histo))->ProfileX(profileo);
0120      ch1e[3] = ((TH2F*)cdir->Get(histo))->ProfileX(profilen);
0121      
0122      for (Int_t i=0; i<4; i++) {      
0123        ToF->cd(i+1);
0124        if (PV->KSok(rh1e[i] , ch1e[i])) {
0125        ks1e[i] = PV->KSCompute(rh1e[i] , ch1e[i] , te );
0126        PV->KSdraw(rh1e[i] , ch1e[i]);
0127        rh1e[i]->Draw("h");      
0128        ch1e[i]->Draw("h same");             
0129        buf<<"KS="<<ks1e[i]<<std::endl;
0130        buf>>value;
0131        te->DrawTextNDC(0.5,0.7, value.c_str());
0132        leg.Clear();
0133        leg.AddEntry(rh1e[i],rver , "l");
0134        leg.AddEntry(ch1e[i],cver , "l");
0135        leg.Draw();
0136 
0137 
0138      }
0139 //     std::cout << " i =" << i << " KS = " << ks1e[i] << std::endl; 
0140      if (ks1e[i] < 0.1) outfile << ch1e[i]->GetName() <<" KS probability = "<< ks1e[i] <<" "<<endl;
0141    }
0142 
0143  
0144  ToF->Print("Tof.eps");
0145  ToF->Print("Tof.gif");
0146 
0147 }