1 #include "TStopwatch.h"
6 //flow analysis method can be: (set to kTRUE or kFALSE)
10 Bool_t LYZEP = kFALSE;
14 Bool_t MCEP = kFALSE; //does not work yet 24/12/08
19 //integrated selection
20 Double_t ptMaxInt = 10.;
21 Double_t ptMinInt = 0.;
22 Double_t etaMaxInt = 1.;
23 Double_t etaMinInt = -1.;
24 Double_t phiMaxInt = 7.5;
25 Double_t phiMinInt = 0.;
28 //differential selection
29 Double_t ptMaxDiff = 10.;
30 Double_t ptMinDiff = 0.;
31 Double_t etaMaxDiff = 1.;
32 Double_t etaMinDiff = -1.;
33 Double_t phiMaxDiff = 7.5;
34 Double_t phiMinDiff = 0.;
37 int runFlowAnalysis(Int_t aRuns = 100, const char*
38 // dir="/data/alice1/kolk/KineOnly3/")
39 dir="/Users/snelling/alice_data/KineOnly3/")
44 if (LYZ1 && LYZ2) {cout<<"WARNING: you cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1."<<endl; exit(); }
45 if (LYZ2 && LYZEP) {cout<<"WARNING: you cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
46 if (LYZ1 && LYZEP) {cout<<"WARNING: you cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
50 cout<<" ---- BEGIN ANALYSIS ---- "<<endl;
53 // gSystem->AddIncludePath("-I$ALICE_ROOT/include");
54 gSystem->AddIncludePath("-I$ROOTSYS/include");
57 gROOT->LoadMacro("code/AliFlowCommonConstants.cxx+");
58 gROOT->LoadMacro("code/AliFlowLYZConstants.cxx+");
59 gROOT->LoadMacro("code/AliFlowCumuConstants.cxx+");
62 gROOT->LoadMacro("code/AliFlowVector.cxx+");
63 gROOT->LoadMacro("code/AliFlowTrackSimple.cxx+");
64 gROOT->LoadMacro("code/AliFlowEventSimple.cxx+");
67 gROOT->LoadMacro("code/AliFlowTrackSimpleCuts.cxx+");
70 gROOT->LoadMacro("code/AliFlowCommonHist.cxx+");
71 gROOT->LoadMacro("code/AliFlowCommonHistResults.cxx+");
72 gROOT->LoadMacro("code/AliFlowLYZHist1.cxx+");
73 gROOT->LoadMacro("code/AliFlowLYZHist2.cxx+");
75 // functions needed for various methods
76 gROOT->LoadMacro("code/AliCumulantsFunctions.cxx+");
77 gROOT->LoadMacro("code/AliQCumulantsFunctions.cxx+");
78 gROOT->LoadMacro("code/AliFittingFunctionsForQDistribution.cxx+");
79 gROOT->LoadMacro("code/AliFlowLYZEventPlane.cxx+");
81 // Flow Analysis code for various methods
82 gROOT->LoadMacro("code/AliFlowAnalysisWithMCEventPlane.cxx+");
83 gROOT->LoadMacro("code/AliFlowAnalysisWithScalarProduct.cxx+");
84 gROOT->LoadMacro("code/AliFlowAnalysisWithLYZEventPlane.cxx+");
85 gROOT->LoadMacro("code/AliFlowAnalysisWithLeeYangZeros.cxx+");
86 gROOT->LoadMacro("code/AliFlowAnalysisWithCumulants.cxx+");
87 gROOT->LoadMacro("code/AliFlowAnalysisWithQCumulants.cxx+");
88 gROOT->LoadMacro("code/AliFittingQDistribution.cxx+");
90 // Method to fill the FlowEvent
91 gROOT->LoadMacro("code/FlowEventSimpleMaker.cxx+");
93 //load needed libraries
94 gSystem->Load("libTree.so");
96 cout << "finished loading macros!" << endl;
97 // gSystem->Load("libPWG2flow.so");
99 //------------------------------------------------------------------------
101 AliFlowTrackSimpleCuts* cutsInt = new AliFlowTrackSimpleCuts();
102 cutsInt->SetPtMax(ptMaxInt);
103 cutsInt->SetPtMin(ptMinInt);
104 cutsInt->SetEtaMax(etaMaxInt);
105 cutsInt->SetEtaMin(etaMinInt);
106 cutsInt->SetPhiMax(phiMaxInt);
107 cutsInt->SetPhiMin(phiMinInt);
108 cutsInt->SetPID(PIDInt);
110 AliFlowTrackSimpleCuts* cutsDiff = new AliFlowTrackSimpleCuts();
111 cutsDiff->SetPtMax(ptMaxDiff);
112 cutsDiff->SetPtMin(ptMinDiff);
113 cutsDiff->SetEtaMax(etaMaxDiff);
114 cutsDiff->SetEtaMin(etaMinDiff);
115 cutsDiff->SetPhiMax(phiMaxDiff);
116 cutsDiff->SetPhiMin(phiMinDiff);
117 cutsDiff->SetPID(PIDDiff);
119 //------------------------------------------------------------------------
121 FlowEventSimpleMaker* fEventMaker = new FlowEventSimpleMaker();
123 AliFlowAnalysisWithQCumulants *qc = NULL;
124 AliFlowAnalysisWithCumulants *gfc = NULL;
125 AliFittingQDistribution *fqd = NULL;
126 AliFlowAnalysisWithLeeYangZeros *lyz1 = NULL;
127 AliFlowAnalysisWithLeeYangZeros *lyz2 = NULL;
128 AliFlowAnalysisWithLYZEventPlane *lyzep = NULL;
129 AliFlowAnalysisWithScalarProduct *sp = NULL;
130 AliFlowAnalysisWithMCEventPlane *mcep = NULL;
134 //MCEP = monte carlo event plane
136 AliFlowAnalysisWithMCEventPlane *mcep = new AliFlowAnalysisWithMCEventPlane();
142 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
143 qc->CreateOutputObjects();
146 //GFC = Generating Function Cumulants
148 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
149 gfc->CreateOutputObjects();
152 //FQD = Fitting q-distribution
154 AliFittingQDistribution* fqd = new AliFittingQDistribution();
155 fqd->CreateOutputObjects();
157 //LYZ1 = Lee-Yang Zeroes first run
159 AliFlowAnalysisWithLeeYangZeros* lyz1 = new AliFlowAnalysisWithLeeYangZeros();
160 lyz1->SetFirstRun(kTRUE);
161 lyz1->SetUseSum(kTRUE);
165 //LYZ2 = Lee-Yang Zeroes second run
168 AliFlowAnalysisWithLeeYangZeros* lyz2 = new AliFlowAnalysisWithLeeYangZeros();
169 // read the input file from the first run
170 TString inputFileNameLYZ2 = "outputLYZ1analysis.root" ;
171 TFile* inputFileLYZ2 = new TFile(inputFileNameLYZ2.Data(),"READ");
172 if(!inputFileLYZ2 || inputFileLYZ2->IsZombie()) {
173 cerr << " ERROR: NO First Run file... " << endl ;
176 TList* inputListLYZ2 = (TList*)inputFileLYZ2->Get("cobjLYZ1");
177 if (!inputListLYZ2) {cout<<"list is NULL pointer!"<<endl;}
179 cout<<"LYZ2 input file/list read..."<<endl;
180 lyz2->SetFirstRunList(inputListLYZ2);
181 lyz2->SetFirstRun(kFALSE);
182 lyz2->SetUseSum(kTRUE);
188 //LYZEP = Lee-Yang Zeroes event plane
190 AliFlowLYZEventPlane* ep = new AliFlowLYZEventPlane() ;
191 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
192 // read the input file from the second lyz run
193 TString inputFileNameLYZEP = "outputLYZ2analysis.root" ;
194 TFile* inputFileLYZEP = new TFile(inputFileNameLYZEP.Data(),"READ");
195 if(!inputFileLYZEP || inputFileLYZEP->IsZombie()) {
196 cerr << " ERROR: NO Second Run file... " << endl ; }
198 TList* inputListLYZEP = (TList*)inputFileLYZEP->Get("cobjLYZ2");
199 if (!inputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
201 cout<<"LYZEP input file/list read..."<<endl;
202 ep ->SetSecondRunList(inputListLYZEP);
203 lyzep->SetSecondRunList(inputListLYZEP);
210 //SP = Scalar Product
212 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
215 //------------------------------------------------------------------------
219 TString execDir(gSystem->pwd());
220 TString targetDir(dir);
221 TSystemDirectory* baseDir = new TSystemDirectory(".", dir);
222 TList* dirList = baseDir->GetListOfFiles();
224 cout << endl << "No input files in: " << targetDir.Data() << endl;
227 Int_t nDirs = dirList->GetEntries();
229 cout<<"Int_t nDirs = "<<nDirs<<endl;
230 gSystem->cd(execDir);
232 for(Int_t iDir=0;iDir<nDirs;++iDir)
234 TSystemFile* presentDir = (TSystemFile*)dirList->At(iDir);
235 if(!presentDir || !presentDir->IsDirectory() ||
236 strcmp(presentDir->GetName(), ".") == 0 ||
237 strcmp(presentDir->GetName(), "..") == 0)
240 cout << "Directory (" << iDir << "): " << presentDir->GetName() <<
241 " - Skipping ... " << endl;
245 if(offset > 0) { --offset ; continue ; }
246 if((aRuns > 0) && (fCount >= aRuns)) { break ; }
248 TString presentDirName(dir); // aDataDir
249 presentDirName += presentDir->GetName();
250 presentDirName += "/";
251 //cerr<<" presentDirName = "<<presentDirName<<endl;
253 TString fileName = presentDirName;
254 fileName += "galice.root";
255 Long_t *id, *size, *flags, *modtime;
256 if(gSystem->GetPathInfo(fileName.Data(),id,size,flags,modtime))
258 cout << " File : " << fileName << " does NOT exist ! - Skipping ... "
262 // cout << endl ; cout << "Directory (" << iDir << "): " << presentDirName << " ... " << endl;
264 //loop (simulations in the present dir)
265 TSystemDirectory* evtsDir = new TSystemDirectory(".",
266 presentDirName.Data());
267 TList* fileList = evtsDir->GetListOfFiles();
268 Int_t nFiles = fileList->GetEntries();
269 //cout<<" Int_t nFiles = "<<nFiles<<endl;
270 gSystem->cd(execDir);
271 for(Int_t iFiles=0; iFiles<nFiles; ++iFiles)
273 TSystemFile* presentFile = (TSystemFile*) fileList->At(iFiles);
274 TString presentFileName(presentDirName);
275 presentFileName += presentFile->GetName();
277 if(!(presentFileName.Contains("Kinematics") &&
278 presentFileName.Contains("root"))) { continue ; }
280 //cout << " found: " << presentFileName.Data() << endl;
282 TFile* kineFile = new TFile(presentFileName.Data(), "READ");
284 Int_t nEvts = kineFile->GetNkeys() ;
285 //cout << " . found: " << nEvts << " KineTree(s) in " << presentFileName.Data() << endl;
286 TList* kineEventsList = (TList*)kineFile->GetListOfKeys();
288 TIter next(kineEventsList);
291 //loop over the events
292 while( key=(TKey *)next() )
294 TDirectory* tDir = (TDirectory*)key->ReadObj();
297 TString evtDir(tDir->GetName());
298 //cout << " . . found: " << tDir->GetName() << endl;
300 kTree = (TTree *)tDir->Get("TreeK");
303 Int_t nPart = kTree->GetEntries();
304 //cout << " . . . kTree " << fCount << " has " << nPart << " particles " << endl;
306 //-----------------------------------------------------------
307 //fill and save the flow event
309 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(kTree, cutsInt, cutsDiff);
311 //pass the flow event to flow methods for analysis
312 if (MCEP) //mcep->Make(fEvent,fEP); //fix fEP
313 if(QC) qc->Make(fEvent);
314 if(GFC) gfc->Make(fEvent);
315 if(FQD) fqd->Make(fEvent);
316 if(LYZ1) lyz1->Make(fEvent);
317 if(LYZ2) lyz2->Make(fEvent);
318 if(LYZEP) lyzep->Make(fEvent,ep);
319 if(SP) sp->Make(fEvent);
320 //-----------------------------------------------------------
323 cout << "# " << fCount << " events processed" << endl;
332 //--------------------------------------------------------------
333 //calculating and storing the final results of flow analysis
334 if (MCEP) {mcep->Finish(); mcep->WriteHistograms("outputMCEPanalysis.root");}
335 if(QC) {qc->Finish(); qc->WriteHistograms("outputQCanalysis.root");}
336 if(GFC) {gfc->Finish(); gfc->WriteHistograms("outputGFCanalysis.root");}
337 if(FQD) {fqd->Finish(); fqd->WriteHistograms("outputFQDanalysis.root");}
338 if(LYZ1) {lyz1->Finish(); lyz1->WriteHistograms("outputLYZ1analysis.root");}
339 if(LYZ2) {lyz2->Finish(); lyz2->WriteHistograms("outputLYZ2analysis.root");}
340 if(LYZEP) {lyzep->Finish(); lyzep->WriteHistograms("outputLYZEPanalysis.root");}
341 if(SP) {sp->Finish(); sp->WriteHistograms("outputSPanalysis.root");}
342 //--------------------------------------------------------------
345 cout << " Finished ... " << endl;