FairRoot/PandaRoot
plothistos.C
Go to the documentation of this file.
1 plothistos(TString filename = "histos.root")
2 {
3  gROOT->LoadMacro("$VMCWORKDIR/macro/mvd/Tools.C");
5  TFile* file = new TFile(filename.Data());
6  if (!file) {cout<<"File not there..."<<endl;return;}
7  TCanvas* can = new TCanvas();
8  TString picname = filename;
9  picname.ReplaceAll(".root",".ps");
10  TString pic = picname + "["; // open empty ps
11  cout << "opening: " << pic.Data()<<endl;
12  can->Print(pic);
13  pic=picname;
14 
15  TList* list = file->GetListOfKeys();
16  if (!list) {cout<<"List not there..."<<endl;return;}
17  int divx=2, divy=2;
18  int padcount = 1;
19  TString keyclass="";
20  can->Divide(divx, divy);
21  for(int i=0;i<list->GetEntries();i++)
22  {
23  if(padcount > divx+divy)
24  {
25  can->Print(pic.Data());
26  can->Clear();
27  can->Divide(divx, divy);
28  padcount=1;
29  }
30  can->cd(padcount);
31  TKey* key = (TKey*)list->At(i);
32  keyclass = key->GetClassName();
33  //cout<<keyclass.Data()<<endl;
34  if(keyclass.Contains("TH1"))
35  {
36  //cout<<"try plotting a TH1"<<endl;
37  TH1* his = (TH1*)key->ReadObj();
38  his->Draw();
39  }else if(keyclass.Contains("TH2"))
40  {
41  //cout<<"try plotting a TH2"<<endl;
42  TH2* his2 = (TH2*)key->ReadObj();
43  DrawNice2DHisto(his2);
44  }else if(keyclass.Contains("TProfile"))
45  {
46  //cout<<"try plotting a TH2"<<endl;
47  TProfile* hpro = (TProfile*)key->ReadObj();
48  hpro->Draw();
49  } else continue;
50 
51  padcount++;
52  }
53 
54  can->Print(pic.Data());
55  pic = picname + "]"; // close ps
56  can->Print(pic.Data());
57  cout << "closed: " << pic.Data()<<endl;
58  return;
59 }
Int_t i
Definition: run_full.C:25
TFile * file
DrawNice2DHisto(hisxy)
plothistos(TString filename="histos.root")
Definition: plothistos.C:1
LoadPandaStyle()
const string filename