1 // from CreateESDChain.C - instead of #include "CreateESDChain.C"
2 TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20, Int_t offset = 0) ;
3 void LookupWrite(TChain* chain, const char* target) ;
7 void runAliAnalysisTaskLeeYangZeros(Int_t nRuns = 2, Bool_t firstrun = kTRUE, TString type = "ESD", Bool_t usesum = kTRUE, const Char_t* dataDir="/Users/snelling/alice_data/TherminatorFIX", Int_t offset = 0)
12 // include path (to find the .h files when compiling)
13 gSystem->AddIncludePath("-I$ALICE_ROOT/include") ;
14 gSystem->AddIncludePath("-I$ROOTSYS/include") ;
16 // load needed libraries
17 gSystem->Load("libTree.so");
18 gSystem->Load("libESD.so");
19 cerr<<"libESD loaded..."<<endl;
20 gSystem->Load("libANALYSIS.so");
21 cerr<<"libANALYSIS.so loaded..."<<endl;
22 gSystem->Load("libPWG2flow.so");
24 // gROOT->LoadMacro("AliFlowLYZConstants.cxx+");
25 // gROOT->LoadMacro("AliFlowCommonConstants.cxx+");
26 // gROOT->LoadMacro("AliFlowVector.cxx+");
27 // gROOT->LoadMacro("AliFlowTrackSimple.cxx+");
28 // gROOT->LoadMacro("AliFlowEventSimple.cxx+");
29 // gROOT->LoadMacro("AliFlowEventSimpleMaker.cxx+");
30 // gROOT->LoadMacro("AliFlowCommonHist.cxx+");
31 // gROOT->LoadMacro("AliFlowCommonHistResults.cxx+");
32 // gROOT->LoadMacro("AliFlowLYZHist1.cxx+");
33 // gROOT->LoadMacro("AliFlowLYZHist2.cxx+");
34 // gROOT->LoadMacro("AliFlowAnalysisWithLeeYangZeros.cxx+");
35 // gROOT->LoadMacro("AliAnalysisTaskLeeYangZeros.cxx+");
37 // create the TChain. CreateESDChain() is defined in CreateESDChain.C
38 TChain* chain = CreateESDChain(dataDir, nRuns, offset);
39 cout<<"chain ("<<chain<<")"<<endl;
42 // read the input files
43 TString firstRunFileName = "outputFromLeeYangZerosAnalysis" ;
44 firstRunFileName += type;
45 firstRunFileName += "_firstrun.root";
46 TFile* fFirstRunFile = new TFile(firstRunFileName.Data(),"READ");
47 if(!fFirstRunFile || fFirstRunFile->IsZombie()) { cerr << " ERROR: NO First Run file... " << endl ; }
48 cout<<"input files read..."<<endl;
50 //____________________________________________//
51 // Make the analysis manager
52 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
53 AliVEventHandler* esdH = new AliESDInputHandler;
54 mgr->SetInputEventHandler(esdH);
55 AliMCEventHandler *mc = new AliMCEventHandler();
56 mgr->SetMCtruthEventHandler(mc);
57 //____________________________________________//
59 AliAnalysisTaskLeeYangZeros *task1 = new AliAnalysisTaskLeeYangZeros("TaskLeeYangZeros", firstrun);
60 task1->SetAnalysisType(type);
61 task1->SetFirstRunLYZ(firstrun); //set to first or second run
62 task1->SetUseSumLYZ(usesum); //set to sum gen.function or product gen.function
65 // Create containers for input/output
66 AliAnalysisDataContainer *cinput1 =
67 mgr->CreateContainer("cchain1",TChain::Class(),AliAnalysisManager::kInputContainer);
68 if (!firstrun){ AliAnalysisDataContainer *cinput2 =
69 mgr->CreateContainer("cobj2",TList::Class(),AliAnalysisManager::kInputContainer); }
70 AliAnalysisDataContainer *coutput1 =
71 mgr->CreateContainer("cobj1", TList::Class(),AliAnalysisManager::kOutputContainer);
73 //____________________________________________//
74 mgr->ConnectInput(task1,0,cinput1);
75 if (!firstrun) { mgr->ConnectInput(task1,1,cinput2); }
76 mgr->ConnectOutput(task1,0,coutput1);
78 if (!firstrun){ cinput2->SetData(fFirstRunFile);}
80 if (!mgr->InitAnalysis()) return;
82 mgr->StartAnalysis("local",chain);
89 // Helper macros for creating chains
90 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
92 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
94 // creates chain of files in a given directory or file containing a list.
95 // In case of directory the structure is expected as:
96 // <aDataDir>/<dir0>/AliESDs.root
97 // <aDataDir>/<dir1>/AliESDs.root
103 Long_t id, size, flags, modtime;
104 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
106 printf("%s not found.\n", aDataDir);
110 TChain* chain = new TChain("esdTree");
111 TChain* chaingAlice = 0;
115 TString execDir(gSystem->pwd());
116 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
117 TList* dirList = baseDir->GetListOfFiles();
118 Int_t nDirs = dirList->GetEntries();
119 gSystem->cd(execDir);
123 for (Int_t iDir=0; iDir<nDirs; ++iDir)
125 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
126 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
135 if (count++ == aRuns)
138 TString presentDirName(aDataDir);
139 presentDirName += "/";
140 presentDirName += presentDir->GetName();
141 chain->Add(presentDirName + "/AliESDs.root/esdTree");
142 cerr<<presentDirName<<endl;
148 // Open the input stream
154 // Read the input list of files and add them to the chain
158 if (!esdfile.Contains("root")) continue; // protection
166 if (count++ == aRuns)
179 void LookupWrite(TChain* chain, const char* target)
181 // looks up the chain and writes the remaining files to the text file target
185 TObjArray* list = chain->GetListOfFiles();
186 TIterator* iter = list->MakeIterator();
190 outfile.open(target);
192 while ((obj = iter->Next()))
193 outfile << obj->GetTitle() << "#AliESDs.root" << endl;