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
185 gProof->ClearPackage("STEERBase.par");
186 gProof->ClearPackage("ESD.par");
187 gProof->ClearPackage("AOD.par");
188 gProof->ClearPackage("ANALYSIS.par");
189 gProof->ClearPackage("ANALYSISalice.par");
190 gProof->ClearPackage("PWG2AOD.par");
191 gProof->ClearPackage("CORRFW.par");
193 gProof->ClearPackage("PWG2flowCommon");
194 gProof->ClearPackage("PWG2flowTasks");
197 // Upload the Packages
198 gProof->UploadPackage("STEERBase.par");
199 gProof->UploadPackage("ESD.par");
200 gProof->UploadPackage("AOD.par");
201 gProof->UploadPackage("ANALYSIS.par");
202 gProof->UploadPackage("ANALYSISalice.par");
203 gProof->UploadPackage("PWG2AOD.par");
204 gProof->UploadPackage("CORRFW.par");
205 gProof->UploadPackage("PWG2flowCommon.par");
206 gProof->UploadPackage("PWG2flowTasks.par");
208 // Enable the Packages
209 gProof->EnablePackage("STEERBase");
210 gProof->EnablePackage("ESD");
211 gProof->EnablePackage("AOD");
212 gProof->EnablePackage("ANALYSIS");
213 gProof->EnablePackage("ANALYSISalice");
214 gProof->EnablePackage("PWG2AOD");
215 gProof->EnablePackage("CORRFW");
216 gProof->EnablePackage("PWG2flowCommon");
217 gProof->EnablePackage("PWG2flowTasks");
219 // Show enables Packages
220 gProof->ShowEnabledPackages();
225 void SetupPar(char* pararchivename) {
226 //Load par files, create analysis libraries
227 //For testing, if par file already decompressed and modified
228 //classes then do not decompress.
230 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
231 TString parpar(Form("%s.par", pararchivename)) ;
232 if ( gSystem->AccessPathName(parpar.Data()) ) {
233 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
234 TString processline(Form(".! make %s", parpar.Data())) ;
235 gROOT->ProcessLine(processline.Data()) ;
236 gSystem->ChangeDirectory(cdir) ;
237 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
238 gROOT->ProcessLine(processline.Data()) ;
240 if ( gSystem->AccessPathName(pararchivename) ) {
241 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
242 gROOT->ProcessLine(processline.Data());
245 TString ocwd = gSystem->WorkingDirectory();
246 gSystem->ChangeDirectory(pararchivename);
248 // check for BUILD.sh and execute
249 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
250 printf("*******************************\n");
251 printf("*** Building PAR archive ***\n");
252 cout<<pararchivename<<endl;
253 printf("*******************************\n");
254 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
255 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
259 // check for SETUP.C and execute
260 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
261 printf("*******************************\n");
262 printf("*** Setup PAR archive ***\n");
263 cout<<pararchivename<<endl;
264 printf("*******************************\n");
265 gROOT->Macro("PROOF-INF/SETUP.C");
268 gSystem->ChangeDirectory(ocwd.Data());
269 printf("Current dir: %s\n", ocwd.Data());
273 // Helper macros for creating chains
274 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
276 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
278 // creates chain of files in a given directory or file containing a list.
279 // In case of directory the structure is expected as:
280 // <aDataDir>/<dir0>/AliESDs.root
281 // <aDataDir>/<dir1>/AliESDs.root
287 Long_t id, size, flags, modtime;
288 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
290 printf("%s not found.\n", aDataDir);
294 TChain* chain = new TChain("esdTree");
295 TChain* chaingAlice = 0;
299 TString execDir(gSystem->pwd());
300 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
301 TList* dirList = baseDir->GetListOfFiles();
302 Int_t nDirs = dirList->GetEntries();
303 gSystem->cd(execDir);
307 for (Int_t iDir=0; iDir<nDirs; ++iDir)
309 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
310 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
319 if (count++ == aRuns)
322 TString presentDirName(aDataDir);
323 presentDirName += "/";
324 presentDirName += presentDir->GetName();
325 chain->Add(presentDirName + "/AliESDs.root/esdTree");
326 // cerr<<presentDirName<<endl;
332 // Open the input stream
338 // Read the input list of files and add them to the chain
342 if (!esdfile.Contains("root")) continue; // protection
350 if (count++ == aRuns)
364 // Helper macros for creating chains
365 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
367 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
369 // creates chain of files in a given directory or file containing a list.
370 // In case of directory the structure is expected as:
371 // <aDataDir>/<dir0>/AliAOD.root
372 // <aDataDir>/<dir1>/AliAOD.root
378 Long_t id, size, flags, modtime;
379 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
381 printf("%s not found.\n", aDataDir);
385 TChain* chain = new TChain("aodTree");
386 TChain* chaingAlice = 0;
390 TString execDir(gSystem->pwd());
391 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
392 TList* dirList = baseDir->GetListOfFiles();
393 Int_t nDirs = dirList->GetEntries();
394 gSystem->cd(execDir);
398 for (Int_t iDir=0; iDir<nDirs; ++iDir)
400 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
401 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
410 if (count++ == aRuns)
413 TString presentDirName(aDataDir);
414 presentDirName += "/";
415 presentDirName += presentDir->GetName();
416 chain->Add(presentDirName + "/AliAOD.root/aodTree");
417 // cerr<<presentDirName<<endl;
423 // Open the input stream
429 // Read the input list of files and add them to the chain
433 if (!aodfile.Contains("root")) continue; // protection
441 if (count++ == aRuns)