]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESD2Tree.C
Added methods for finding a given module in the DDL map (F. Prino)
[u/mrichter/AliRoot.git] / STEER / AliESD2Tree.C
1 /***************************************************************************
2  *   This macros collects into a common Tree sets of ESD objects 
3  *   saved individually in separate files given by "fnames".
4  *   Example:
5  *        root [0] .L $ALICE_ROOT/STEER/AliESD2Tree.C
6  *        root [1] char * names[] = {"rfio:///castor/cern.ch/user/a/aliprod/AliEn-1.0/data/00001/00205.1077678127","rfio:///castor/cern.ch/user/a/aliprod/AliEn-1.0/data/00001/00467.1077678996"}
7  *        root [2] AliESD2Tree(names,2)
8  *    
9  **************************************************************************/
10
11 #if !defined(__CINT__) || defined(__MAKECINT__)
12   #include <TError.h>
13   #include <Riostream.h>
14   #include <TFile.h>
15   #include <TTree.h>
16   #include <TKey.h>
17
18   #include "AliESD.h"
19 #endif
20
21 static const Char_t *names[]={"AliESDs.root"};
22 static Int_t n=sizeof(names)/sizeof(Char_t *);
23
24 Int_t AliESD2Tree(const Char_t *fnames[]=names, Int_t nf=n) {
25   TFile out("AliESDtree.root","recreate");
26
27   TTree *esdTree=new TTree("esdTree","Tree with ESD objects");
28   AliESD *event=0;
29   esdTree->Branch("ESD","AliESD",&event);  
30
31   for (Int_t i=0; i<nf; i++) {
32       TFile * in = TFile::Open(fnames[i]);
33       if (!in->IsOpen()) {
34          ::Error("AliESD2Tree.C","Can't open file %s",fnames[i]);
35          continue;
36       }
37       TKey *key=0;
38       TIter next(in->GetListOfKeys());
39       while ((key=(TKey*)next())!=0) {
40           event=(AliESD*)key->ReadObj();
41           esdTree->Fill();
42           delete event;
43       }
44       in->Close();
45   }  
46   
47   out.cd();
48   esdTree->Write();
49   delete esdTree;
50
51   return 0;
52 }