1 enum anaModes {mLocal,mLocalPAR,mPROOF,mGRID};
2 //mLocal: Analyze locally files in your computer using aliroot
3 //mLocalPAR: Analyze locally files in your computer using root + PAR files
4 //mPROOF: Analyze CAF files with PROOF
8 //Boolean to run on ESD from real data or ESD from MC data
11 // Flow analysis method can be:(set to kTRUE or kFALSE)
12 Bool_t MCEP = kTRUE; // correlation with Monte Carlo reaction plane
13 Bool_t SP = kTRUE; // scalar product method (similar to eventplane method)
14 Bool_t GFC = kTRUE; // cumulants based on generating function
15 Bool_t QC = kTRUE; // cumulants using Q vectors
16 Bool_t FQD = kTRUE; // fit of the distribution of the Q vector (only integrated v)
17 Bool_t LYZ1SUM = kTRUE; // Lee Yang Zeroes using sum generating function (integrated v)
18 Bool_t LYZ1PROD = kTRUE; // Lee Yang Zeroes using product generating function (integrated v)
19 Bool_t LYZ2SUM = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
20 Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
21 Bool_t LYZEP = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
23 Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP};
25 // Analysis type can be ESD, AOD, MC, ESDMC0, ESDMC1
26 const TString type = "ESD";
28 // Boolean to fill/not fill the QA histograms
31 // Boolean to use/not use weights for the Q vector
32 Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
35 //void runFlowTask(Int_t mode=mLocal, Int_t nRuns = -1,
36 //const Char_t* dataDir="/data/alice2/kolk/PP/data/LHC09d/104892/test", Int_t offset = 0)
37 //const Char_t* dataDir="/data/alice2/kolk/PP/LHC09d10/104873", Int_t offset = 0)
38 void runFlowTask(Int_t mode = mPROOF, Int_t nRuns = 2000000,
39 //const Char_t* dataDir="/PWG2/akisiel/Therminator_midcentral_ESD", Int_t offset=0)
40 //const Char_t* dataDir="/COMMON/COMMON/LHC09a4_run8101X", Int_t offset = 0)
41 const Char_t* dataDir="/PWG2/akisiel/LHC10d6_0.9TeV_EPOS_12502X", Int_t offset=0)
49 if (mode==mLocal || mode == mLocalPAR || mode == mGRID) {
50 if (type!="AOD") { TChain* chain = CreateESDChain(dataDir, nRuns, offset);}
51 else { TChain* chain = CreateAODChain(dataDir, nRuns, offset);}
53 //____________________________________________//
54 // Make the analysis manager
55 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
58 AliVEventHandler* esdH = new AliESDInputHandler;
59 mgr->SetInputEventHandler(esdH);
61 AliMCEventHandler *mc = new AliMCEventHandler();
62 mgr->SetMCtruthEventHandler(mc);
67 AliVEventHandler* aodH = new AliAODInputHandler;
68 mgr->SetInputEventHandler(aodH);
70 AliMCEventHandler *mc = new AliMCEventHandler();
71 mgr->SetMCtruthEventHandler(mc);
75 if (type == "MC" || type == "ESDMC0" || type == "ESDMC1"){
76 AliVEventHandler* esdH = new AliESDInputHandler;
77 mgr->SetInputEventHandler(esdH);
79 AliMCEventHandler *mc = new AliMCEventHandler();
80 mgr->SetMCtruthEventHandler(mc);
84 //____________________________________________//
85 // Load the analysis task
86 gROOT->LoadMacro("AddTaskFlow.C");
87 AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
89 //task to check the offline trigger
90 gROOT->LoadMacro("$ALICE_ROOT/PWG1/PilotTrain/AddTaskPhysicsSelection.C");
91 AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection();
92 if (!DATA) {physicsSelTask->GetPhysicsSelection()->SetAnalyzeMC();}
94 //____________________________________________//
96 if (!mgr->InitAnalysis()) return;
99 if (mode==mLocal || mode == mLocalPAR) {
100 mgr->StartAnalysis("local",chain);
102 else if (mode==mPROOF) {
103 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
105 else if (mode==mGRID) {
106 mgr->StartAnalysis("local",chain);
115 void LoadLibraries(const anaModes mode) {
117 //--------------------------------------
118 // Load the needed libraries most of them already loaded by aliroot
119 //--------------------------------------
120 gSystem->Load("libTree");
121 gSystem->Load("libGeom");
122 gSystem->Load("libVMC");
123 gSystem->Load("libXMLIO");
124 gSystem->Load("libPhysics");
126 //----------------------------------------------------------
127 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
128 //----------------------------------------------------------
130 //--------------------------------------------------------
131 // If you want to use already compiled libraries
132 // in the aliroot distribution
133 //--------------------------------------------------------
134 gSystem->Load("libSTEERBase");
135 gSystem->Load("libESD");
136 gSystem->Load("libAOD");
137 gSystem->Load("libANALYSIS");
138 gSystem->Load("libANALYSISalice");
139 gSystem->Load("libCORRFW");
140 cerr<<"libCORRFW loaded..."<<endl;
141 gSystem->Load("libPWG2flowCommon");
142 cerr<<"libPWG2flowCommon loaded..."<<endl;
143 gSystem->Load("libPWG2flowTasks");
144 cerr<<"libPWG2flowTasks loaded..."<<endl;
147 else if (mode == mLocalPAR || mode == mGRID) {
148 //--------------------------------------------------------
149 //If you want to use root and par files from aliroot
150 //--------------------------------------------------------
151 SetupPar("STEERBase");
154 SetupPar("ANALYSIS");
155 SetupPar("ANALYSISalice");
158 SetupPar("PWG2flowCommon");
159 cerr<<"PWG2flowCommon.par loaded..."<<endl;
160 SetupPar("PWG2flowTasks");
161 cerr<<"PWG2flowTasks.par loaded..."<<endl;
164 //---------------------------------------------------------
165 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
166 //---------------------------------------------------------
167 else if (mode==mPROOF) {
169 //gEnv->SetValue("XSec.GSI.DelegProxy","2")
170 // set to debug root versus if needed
171 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg");
172 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a");
173 //TProof::Reset("proof://snelling@alicecaf.cern.ch");
175 printf("*** Connect to PROOF ***\n");
176 // Put appropriate username here
177 //TProof::Open("abilandz@alicecaf.cern.ch");
178 //TProof::Open("nkolk@alicecaf.cern.ch");
179 TProof::Open("snelling@localhost");
180 // list the data available
181 //gProof->ShowDataSets("/*/*");
183 // Clear the Packages
184 gProof->ClearPackage("STEERBase.par");
185 gProof->ClearPackage("ESD.par");
186 gProof->ClearPackage("AOD.par");
187 gProof->ClearPackage("ANALYSIS.par");
188 gProof->ClearPackage("ANALYSISalice.par");
189 gProof->ClearPackage("PWG2AOD.par");
190 gProof->ClearPackage("CORRFW.par");
191 gProof->ClearPackage("PWG2flowCommon");
192 gProof->ClearPackage("PWG2flowTasks");
195 // Upload the Packages
196 gProof->UploadPackage("STEERBase.par");
197 gProof->UploadPackage("ESD.par");
198 gProof->UploadPackage("AOD.par");
199 gProof->UploadPackage("ANALYSIS.par");
200 gProof->UploadPackage("ANALYSISalice.par");
201 gProof->UploadPackage("PWG2AOD.par");
202 gProof->UploadPackage("CORRFW.par");
203 gProof->UploadPackage("PWG2flowCommon.par");
204 gProof->UploadPackage("PWG2flowTasks.par");
206 // Enable the Packages
207 gProof->EnablePackage("STEERBase");
208 gProof->EnablePackage("ESD");
209 gProof->EnablePackage("AOD");
210 gProof->EnablePackage("ANALYSIS");
211 gProof->EnablePackage("ANALYSISalice");
212 gProof->EnablePackage("PWG2AOD");
213 gProof->EnablePackage("CORRFW");
214 gProof->EnablePackage("PWG2flowCommon");
215 gProof->EnablePackage("PWG2flowTasks");
217 // Show enables Packages
218 gProof->ShowEnabledPackages();
223 void SetupPar(char* pararchivename) {
224 //Load par files, create analysis libraries
225 //For testing, if par file already decompressed and modified
226 //classes then do not decompress.
228 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
229 TString parpar(Form("%s.par", pararchivename)) ;
230 if ( gSystem->AccessPathName(parpar.Data()) ) {
231 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
232 TString processline(Form(".! make %s", parpar.Data())) ;
233 gROOT->ProcessLine(processline.Data()) ;
234 gSystem->ChangeDirectory(cdir) ;
235 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
236 gROOT->ProcessLine(processline.Data()) ;
238 if ( gSystem->AccessPathName(pararchivename) ) {
239 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
240 gROOT->ProcessLine(processline.Data());
243 TString ocwd = gSystem->WorkingDirectory();
244 gSystem->ChangeDirectory(pararchivename);
246 // check for BUILD.sh and execute
247 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
248 printf("*******************************\n");
249 printf("*** Building PAR archive ***\n");
250 cout<<pararchivename<<endl;
251 printf("*******************************\n");
252 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
253 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
257 // check for SETUP.C and execute
258 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
259 printf("*******************************\n");
260 printf("*** Setup PAR archive ***\n");
261 cout<<pararchivename<<endl;
262 printf("*******************************\n");
263 gROOT->Macro("PROOF-INF/SETUP.C");
266 gSystem->ChangeDirectory(ocwd.Data());
267 printf("Current dir: %s\n", ocwd.Data());
271 // Helper macros for creating chains
272 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
274 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
276 // creates chain of files in a given directory or file containing a list.
277 // In case of directory the structure is expected as:
278 // <aDataDir>/<dir0>/AliESDs.root
279 // <aDataDir>/<dir1>/AliESDs.root
285 Long_t id, size, flags, modtime;
286 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
288 printf("%s not found.\n", aDataDir);
292 TChain* chain = new TChain("esdTree");
293 TChain* chaingAlice = 0;
297 TString execDir(gSystem->pwd());
298 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
299 TList* dirList = baseDir->GetListOfFiles();
300 Int_t nDirs = dirList->GetEntries();
301 gSystem->cd(execDir);
305 for (Int_t iDir=0; iDir<nDirs; ++iDir)
307 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
308 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
317 if (count++ == aRuns)
320 TString presentDirName(aDataDir);
321 presentDirName += "/";
322 presentDirName += presentDir->GetName();
323 chain->Add(presentDirName + "/AliESDs.root/esdTree");
324 // cerr<<presentDirName<<endl;
330 // Open the input stream
336 // Read the input list of files and add them to the chain
340 if (!esdfile.Contains("root")) continue; // protection
348 if (count++ == aRuns)
362 // Helper macros for creating chains
363 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
365 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
367 // creates chain of files in a given directory or file containing a list.
368 // In case of directory the structure is expected as:
369 // <aDataDir>/<dir0>/AliAOD.root
370 // <aDataDir>/<dir1>/AliAOD.root
376 Long_t id, size, flags, modtime;
377 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
379 printf("%s not found.\n", aDataDir);
383 TChain* chain = new TChain("aodTree");
384 TChain* chaingAlice = 0;
388 TString execDir(gSystem->pwd());
389 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
390 TList* dirList = baseDir->GetListOfFiles();
391 Int_t nDirs = dirList->GetEntries();
392 gSystem->cd(execDir);
396 for (Int_t iDir=0; iDir<nDirs; ++iDir)
398 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
399 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
408 if (count++ == aRuns)
411 TString presentDirName(aDataDir);
412 presentDirName += "/";
413 presentDirName += presentDir->GetName();
414 chain->Add(presentDirName + "/AliAOD.root/aodTree");
415 // cerr<<presentDirName<<endl;
421 // Open the input stream
427 // Read the input list of files and add them to the chain
431 if (!aodfile.Contains("root")) continue; // protection
439 if (count++ == aRuns)