File indexing completed on 2024-04-06 12:32:09
0001
0002 void compareHistos( char *Current, char *Reference=0 ){
0003
0004 TText* te = new TText();
0005 te->SetTextSize(0.1);
0006
0007 TFile * curfile = new TFile( TString(Current)+".root" );
0008 TFile * reffile = curfile;
0009 if (Reference) reffile = new TFile(TString(Reference)+".root");
0010
0011
0012
0013 TList* list = reffile->GetListOfKeys();
0014 TObject* object = list->First();
0015 int iHisto = 0; char title[50];
0016 while (object) {
0017
0018 std::cout << " object :" << object->GetName() << std::endl;
0019 TH1I * h1 = dynamic_cast<TH1I*>( reffile->Get(object->GetName()));
0020 TH1I * h2 = dynamic_cast<TH1I*>( curfile->Get(object->GetName()));
0021 bool isHisto = (reffile->Get(object->GetName()))->InheritsFrom("TH1I");
0022 std::cout << " isHisto = " << isHisto << std::endl;
0023 if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) {
0024 iHisto++;
0025 char title[50];
0026
0027 std::cout << " Start draw and compare" << std::endl;
0028 TCanvas c1;
0029 TH1I htemp2;
0030 h2->Copy(htemp2);
0031
0032 h1->SetLineColor(2);
0033 htemp2.SetLineColor(3);
0034 h1->SetLineStyle(3);
0035 h1->SetMarkerColor(3);
0036 h1->GetXaxis()->SetTitle(object->GetName());
0037 htemp2.SetLineStyle(5);
0038 htemp2.SetMarkerColor(5);
0039 htemp2.GetXaxis()->SetTitle(object->GetName());
0040 TLegend leg(0.6,0.7,0.8,0.9);
0041 leg.AddEntry(h1, "with TPG.txt", "l");
0042 leg.AddEntry(&htemp2, "with db", "l");
0043
0044 h1->Draw();
0045 htemp2.Draw("Same");
0046 leg.Draw();
0047 c1.SetLogy();
0048 sprintf(title,"%s%s", object->GetName(),".gif");
0049 c1.Print(title);
0050 }
0051
0052
0053 object = list->After(object);
0054 }
0055 }
0056