Hi Casey,
This is a message of public interest, so I post it to roottalk.
In the attachment you will find a file work.C that fills the missing pieces
in your code. I have added this example to the tutorials.
Suzanne, could you find a place in the Users Guide to add this example?
Rene Brun
corey a stambaugh wrote:
>
> Hello,
> My name is Casey Stambaugh and I am using Root at Ohio State
> Univ. for the CDF group.
>
> I apologize for using this email address, I could not figure out
> how to use the roottalk digest.
>
> I am trying to do a simple root program to run through a .hbk file
> and print out all the graphs.
>
> This is my current code
>
> void work(int x, int y, int page){
>
> int page_cnt, hist_per_page, i;
> TFile *f1 = new TFile("xftRoot_out.hbk");
> TCanvas *c1 = new TCanvas("c1");
> TPostScript *ps = new TPostScript("file.ps",112);
> c1->Divide(x,y);
> hist_per_page = x*y;
>
> while (page_cnt < page)
> {
> ps->NewPage();
> i=1;
> while (hist_per_page >= i)
> {
> c1->cd(i);
> ??????->Draw();
> i++;
> }
> c1->Update();
> page_cnt++;
> }
> ps->Close();
> fgSystem->Exec("lpr -Psmith2079 file.ps");
> gSystem->Exec("gv file.ps");
>
> }
>
> I was wondering if it was possible to somehow extract individual
> histograms to the ????? with a simple call or somehow run through
> histograms in this manner.
>
> If this is not possible, that will suffice but I have spent many days
> reading the root page finding nothing to support or contradict my plans.
>
> Thank you for your time and I apologize again for using this email
>
> Casey Stambaugh
> stambaug@cis.ohio-state.edu
void work(int x, int y, int page){
//example of script to plot all histograms in a Root file
//on a Postcript file (x times y per page)
//The following logic can be used to loop on all the keys of a file:
// TFile f("myfile.root");
// TIter next(f1->GetListOfKeys());
// TKey *key;
// while ((key = (TKey*)next())) {
// //key->GetClassName() returns the name of the object class
// TObject *obj = key->ReadObj(); //read object from file
// //obj->ClassName() should be equal to key->GetClassName()
// //obj->InheritsFrom("someclass") test if obj inherits from someclass
// }
int page_cnt, hist_per_page, i;
TFile *f1 = new TFile("hsimple.root");
TCanvas *c1 = new TCanvas("c1");
TPostScript *ps = new TPostScript("file.ps",112);
c1->Divide(x,y);
hist_per_page = x*y;
TIter next(f1->GetListOfKeys()); //make an iterator on list of keys
TKey *key;
while (page_cnt < page) {
ps->NewPage();
i=1;
while (hist_per_page >= i) {
c1->cd(i);
key = (TKey*)next(); //get next key on the file
if (!key) break; //if no more keys, key=0
TObject *obj = key->ReadObj(); //read object associated to key
if (obj->InheritsFrom("TH1")) { //interested by histograms only
obj->Draw(); //draw histogram with default option
i++;
}
}
c1->Update();
if (!key) break;
page_cnt++;
}
ps->Close();
//gSystem->Exec("lpr -Psmith2079 file.ps");
//gSystem->Exec("gv file.ps");
}
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:37 MET