]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/UNICOR/AliDAnal.cxx
Added seperate methods to write histograms to a file when not using the task framework
[u/mrichter/AliRoot.git] / PWG2 / UNICOR / AliDAnal.cxx
1 // Author: Dariusz Miskowiec <mailto:d.miskowiec@gsi.de> 2007
2
3 //=============================================================================
4 // parent class of all analyzers
5 // keeps the obj array of histograms filled by the daughter
6 // takes care of storing them on file at the end
7 //=============================================================================
8
9 #include <TROOT.h>
10 #include <TFile.h>
11 #include "AliDAnal.h"
12
13 ClassImp(AliDAnal)
14   
15 TDatabasePDG AliDAnal::fgPDG;
16
17 //=============================================================================
18 AliDAnal::AliDAnal(char *nam) : TNamed(nam,nam), fHistos() 
19 {
20   // constructor
21
22   fHistos.SetOwner(1);
23   TDirectory *dir = gROOT->mkdir(GetName());
24   dir->cd();
25
26   printf("%s object named %s created\n",ClassName(),GetName());
27 }
28 //=============================================================================
29 void AliDAnal::Save(const char *outfil, const char *mode) 
30 {
31   // store histograms on file in a directory named after the object
32   // mode should be "update" (default) or "new"
33
34   printf("%s saving  histograms on %s (%s)\n",GetName(),outfil,mode);  
35   TFile * f = TFile::Open(outfil, mode);
36   TDirectory *dest = f->mkdir(GetName());
37   dest->cd();
38   fHistos.Write();
39   gROOT->cd();
40   f->Close();
41 }
42 //=============================================================================