Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 void compareGlobalHistos( char *Current, char *Reference=0 ){
0002 
0003  TText* te = new TText();
0004  te->SetTextSize(0.1);
0005  
0006  TFile * curfile = new TFile( TString(Current)+".root" );
0007  TFile * reffile = curfile;
0008  if (Reference) reffile = new TFile(TString(Reference)+".root");
0009 
0010 
0011  char * prefix="DQMData/MixingV/Mixing";
0012  //1-Dimension Histogram
0013  TDirectory * refDir=reffile->GetDirectory(prefix);
0014  TDirectory * curDir=curfile->GetDirectory(prefix);
0015  TList* list = refDir->GetListOfKeys();  
0016  TObject*  object = list->First();
0017  int iHisto = 0; char title[50];
0018  while (object) {
0019    // find histo objects
0020    std::cout << " object :" << object->GetName() << std::endl;
0021    TH1F * h1 = dynamic_cast<TH1F*>( refDir->Get(object->GetName()));
0022    TH1F * h2 = dynamic_cast<TH1F*>( curDir->Get(object->GetName()));
0023    bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TH1F");
0024    std::cout << " isHisto = " << isHisto << std::endl;
0025    if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) {
0026       iHisto++;
0027       char title[50];
0028       // draw and  compare
0029    std::cout << " Start draw and compare" << std::endl;
0030    TCanvas c1;
0031    TH1F htemp2;
0032    h2->Copy(htemp2);// to keep 2 distinct histos
0033 
0034    h1->SetLineColor(2);
0035    htemp2.SetLineColor(3);
0036    h1->SetLineStyle(3);
0037    h1->SetMarkerColor(3);
0038    htemp2.SetLineStyle(5);
0039    htemp2.SetMarkerColor(5);
0040    TLegend leg(0.1, 0.15, 0.2, 0.25);
0041    leg.AddEntry(h1, "Reference", "l");
0042    leg.AddEntry(&htemp2, "New ", "l");
0043 
0044    h1->Draw();
0045    htemp2.Draw("Same"); 
0046    leg.Draw();
0047    sprintf(title,"%s%s", object->GetName(),".gif");
0048    c1.Print(title);
0049    }
0050    
0051    // go to next object
0052    object = list->After(object);
0053    }
0054 }