GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RunAncillaryFilter.C
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <fstream>
4 #include <sstream>
5 #include <cstdio>
6 
7 #include "TSystemDirectory.h"
8 #include "TString.h"
9 #include "TList.h"
10 #include "TObject.h"
11 #include "TFile.h"
12 #include "TChain.h"
13 #include "TTree.h"
14 #include "TROOT.h"
15 
16 using namespace std;
17 
18 void RunAncillaryFilter(TString SourceDir, TString TreeName)
19 {
20  TSystemDirectory Dir;
21  Dir.SetDirectory(SourceDir);
22 
23  TChain *MyChain = new TChain(TreeName);
24 
25  TList *ListOfSubFolders = Dir.GetListOfFiles();
26  for(int i = 0 ; i<ListOfSubFolders->GetSize() ; i++)
27  {
28  TObject *obj = ListOfSubFolders->At(i);
29 
30  TString Name = obj->GetName();
31 
32  if(Name.EndsWith(".root"))
33  {
34  TString Path = Form("%s/%s",SourceDir.Data(),Name.Data());
35 
36  TFile *file = new TFile(Path);
37  TTree *t = (TTree*)file->Get(TreeName.Data());
38  if(t && !((TObject*)t)->InheritsFrom("TChain"))
39  {
40  Path = Form("%s/%s/%s",SourceDir.Data(),Name.Data(),TreeName.Data());
41  MyChain->Add(Path.Data());
42  }
43  }
44  }
45 
46  cout<<"TChain build from files:"<<endl;
47 
48  MyChain->GetListOfFiles()->ls();
49 
50  MyChain->Process("AncillaryFilter.C+g");
51 
52  gROOT->ProcessLine(".q");
53 }
void RunAncillaryFilter(TString SourceDir, TString TreeName)
ADF::LogMessage & endl(ADF::LogMessage &log)