#include using namespace std; #include "TFile.h" #include "TGraph.h" #include "TKey.h" #include "TCollection.h" #include "TH2F.h" #include "TCanvas.h" #include "TPad.h" #include "TROOT.h" #include "TDirectory.h" TCanvas *can = new TCanvas("listdraw","TListDraw"); TList *ffitlines = new TList(); void listdraw() { TFile *rf = new TFile("Fit_t344.root"); TH2F *h = (TH2F*)rf->Get("h_t344"); h->DrawCopy("colz"); int i = 0; TIter next(rf->GetListOfKeys()); TKey *key; while(key = (TKey *)next()) { const char *name = key->GetClassName(); const char *titl = key->GetTitle(); if( strcmp("TGraph", name)==0 ) { i += 1; //TGraph *pl = (TGraph*)rf->Get(key->GetName()); TGraph *tpl = (TGraph*)rf->Get(key->GetName()); TGraph *pl = new TGraph(*tpl); pl->SetName(key->GetName()); pl->SetTitle(key->GetTitle()); pl->SetLineStyle(1); pl->SetLineColor(2); pl->SetLineWidth(2); //pl->Draw("l"); if(i==1) ffitlines->Clear(); ffitlines->Add(pl); } else { continue; } } rf->Close(); if( ffitlines->GetSize()>0 && (h!=NULL) ) { ffitlines->ls(); ffitlines->Draw("l"); cout<< endl << "Primitives list of gPad:" << endl; gPad->GetListOfPrimitives()->ls(); can->Update(); } }