StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
anachain.C
1 TChain *mTree = 0;
2 TCanvas *c = 0;
3 
4 void anachain( const Char_t *ddname = "/star/data05/scratch/jwebb/checkin/",
5  const Char_t *pref="R5",
6  const Char_t *ffname = ".root",
7  Int_t nmax=50000
8  )
9 {
10 
11  gROOT->LoadMacro("macros/loadlibs.C");
12  loadlibs();
13 
14  c = new TCanvas("c","A canvas",500,500);
15 
16  mTree = new TChain("mTree","A pi0 tree");
17 
18  TSystemDirectory *dir = new TSystemDirectory("pwd",ddname);
19  TList *files = dir->GetListOfFiles();
20  TIter next( files );
21  TSystemFile *file = 0;
22  Int_t nf = 0;
23 
24  TList *listOfEmpties=new TList();
25 
26  while ( (file = (TSystemFile *)next() ) ) {
27 
28 
29  //-- Get the filename --
30  TString fname = file -> GetName();
31  if ( !fname.Contains(ffname) ) continue;
32  if ( !fname.Contains(pref) ) continue;
33  Bool_t pi0tree = 0;
34 
37  TFile pfile( fname );
38  TTree *mytree = (TTree *)pfile.Get("mTree");
39  if ( mytree ) pi0tree = 1;
40  pfile.Close();
41 
42  //-- If we have the trees, add them
43  if ( pi0tree ) {
44  std::cout << "Adding " << fname
45  << " npi0tree=" << mTree->GetEntries()
46  << std::endl;
47 
48  mTree -> Add(fname+"/mTree");
49  nf++;
50  }
51 
52  if ( nf > nmax ) break;
53  }
54 
55  std::cout << "-- anachain -----------------------------------" << std::endl;
56  std::cout << std::endl;
57  std::cout << "loaded " << nf << " files" << std::endl;
58 }
59 
60 
61 
62