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 // Flow analysis method can be:(set to kTRUE or kFALSE)
10 Bool_t LYZ1SUM = kTRUE;
11 Bool_t LYZ1PROD = kTRUE;
12 Bool_t LYZ2SUM = kFALSE;
13 Bool_t LYZ2PROD = kFALSE;
14 Bool_t LYZEP = kFALSE;
18 Bool_t MCEP = kFALSE; //not for pp
20 Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP};
22 // Analysis type can be ESD, AOD, MC, ESDMC0, ESDMC1
23 const TString type = "ESD";
25 // Boolean to fill/not fill the QA histograms
28 // Boolean to use/not use weights for the Q vector
29 Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
32 //void runFlowTask(Int_t mode=mLocal, Int_t nRuns = 100,
33 //const Char_t* dataDir="/data/alice2/kolk/PP/LHC09a4/81119", Int_t offset = 0)
34 //const Char_t* dataDir="/data/alice2/kolk/Therminator_midcentral", Int_t offset = 0)
35 //const Char_t* dataDir="/Users/snelling/alice_data/Therminator_midcentral", Int_t offset = 0)
36 void runFlowTask(Int_t mode=mPROOF, Int_t nRuns = 1000000,
37 //const Char_t* dataDir="/COMMON/COMMON/LHC09a14_0.9TeV_0.5T", Int_t offset = 0)
38 //const Char_t* dataDir="/COMMON/COMMON/LHC08c11_10TeV_0.5T", Int_t offset = 0)
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)
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 //____________________________________________//
86 gROOT->LoadMacro("AddTaskFlow.C");
87 AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
89 //____________________________________________//
91 if (!mgr->InitAnalysis()) return;
94 if (mode==mLocal || mode == mLocalPAR) {
95 mgr->StartAnalysis("local",chain);
97 else if (mode==mPROOF) {
98 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
100 else if (mode==mGRID) {
101 mgr->StartAnalysis("local",chain);
110 void LoadLibraries(const anaModes mode) {
112 //--------------------------------------
113 // Load the needed libraries most of them already loaded by aliroot
114 //--------------------------------------
115 gSystem->Load("libTree");
116 gSystem->Load("libGeom");
117 gSystem->Load("libVMC");
118 gSystem->Load("libXMLIO");
119 gSystem->Load("libPhysics");
121 //----------------------------------------------------------
122 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
123 //----------------------------------------------------------
125 //--------------------------------------------------------
126 // If you want to use already compiled libraries
127 // in the aliroot distribution
128 //--------------------------------------------------------
129 gSystem->Load("libSTEERBase");
130 gSystem->Load("libESD");
131 gSystem->Load("libAOD");
132 gSystem->Load("libANALYSIS");
133 gSystem->Load("libANALYSISalice");
134 gSystem->Load("libCORRFW");
135 cerr<<"libCORRFW loaded..."<<endl;
136 gSystem->Load("libPWG2flowCommon");
137 cerr<<"libPWG2flowCommon loaded..."<<endl;
138 gSystem->Load("libPWG2flowTasks");
139 cerr<<"libPWG2flowTasks loaded..."<<endl;
142 else if (mode == mLocalPAR || mode == mGRID) {
143 //--------------------------------------------------------
144 //If you want to use root and par files from aliroot
145 //--------------------------------------------------------
146 SetupPar("STEERBase");
149 SetupPar("ANALYSIS");
150 SetupPar("ANALYSISalice");
153 SetupPar("PWG2flowCommon");
154 cerr<<"PWG2flowCommon.par loaded..."<<endl;
155 SetupPar("PWG2flowTasks");
156 cerr<<"PWG2flowTasks.par loaded..."<<endl;
159 //---------------------------------------------------------
160 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
161 //---------------------------------------------------------
162 else if (mode==mPROOF) {
165 // set to debug root versus if needed
166 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg");
167 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a");
169 //TProof::Reset("proof://snelling@alicecaf.cern.ch");
171 printf("*** Connect to PROOF ***\n");
172 // Put appropriate username here
173 //TProof::Open("abilandz@alicecaf.cern.ch");
174 //TProof::Open("nkolk@alicecaf.cern.ch");
175 TProof::Open("snelling@localhost");
176 // list the data available
177 //gProof->ShowDataSets("/*/*");
179 // Clear the Packages
180 gProof->ClearPackage("STEERBase.par");
181 gProof->ClearPackage("ESD.par");
182 gProof->ClearPackage("AOD.par");
183 gProof->ClearPackage("ANALYSIS.par");
184 gProof->ClearPackage("ANALYSISalice.par");
185 gProof->ClearPackage("PWG2AOD.par");
186 gProof->ClearPackage("CORRFW.par");
187 gProof->ClearPackage("PWG2flowCommon");
188 gProof->ClearPackage("PWG2flowTasks");
191 // Upload the Packages
192 gProof->UploadPackage("STEERBase.par");
193 gProof->UploadPackage("ESD.par");
194 gProof->UploadPackage("AOD.par");
195 gProof->UploadPackage("ANALYSIS.par");
196 gProof->UploadPackage("ANALYSISalice.par");
197 gProof->UploadPackage("PWG2AOD.par");
198 gProof->UploadPackage("CORRFW.par");
199 gProof->UploadPackage("PWG2flowCommon.par");
200 gProof->UploadPackage("PWG2flowTasks.par");
202 // Enable the Packages
203 gProof->EnablePackage("STEERBase");
204 gProof->EnablePackage("ESD");
205 gProof->EnablePackage("AOD");
206 gProof->EnablePackage("ANALYSIS");
207 gProof->EnablePackage("ANALYSISalice");
208 gProof->EnablePackage("PWG2AOD");
209 gProof->EnablePackage("CORRFW");
210 gProof->EnablePackage("PWG2flowCommon");
211 gProof->EnablePackage("PWG2flowTasks");
213 // Show enables Packages
214 gProof->ShowEnabledPackages();
219 void SetupPar(char* pararchivename) {
220 //Load par files, create analysis libraries
221 //For testing, if par file already decompressed and modified
222 //classes then do not decompress.
224 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
225 TString parpar(Form("%s.par", pararchivename)) ;
226 if ( gSystem->AccessPathName(parpar.Data()) ) {
227 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
228 TString processline(Form(".! make %s", parpar.Data())) ;
229 gROOT->ProcessLine(processline.Data()) ;
230 gSystem->ChangeDirectory(cdir) ;
231 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
232 gROOT->ProcessLine(processline.Data()) ;
234 if ( gSystem->AccessPathName(pararchivename) ) {
235 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
236 gROOT->ProcessLine(processline.Data());
239 TString ocwd = gSystem->WorkingDirectory();
240 gSystem->ChangeDirectory(pararchivename);
242 // check for BUILD.sh and execute
243 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
244 printf("*******************************\n");
245 printf("*** Building PAR archive ***\n");
246 cout<<pararchivename<<endl;
247 printf("*******************************\n");
248 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
249 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
253 // check for SETUP.C and execute
254 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
255 printf("*******************************\n");
256 printf("*** Setup PAR archive ***\n");
257 cout<<pararchivename<<endl;
258 printf("*******************************\n");
259 gROOT->Macro("PROOF-INF/SETUP.C");
262 gSystem->ChangeDirectory(ocwd.Data());
263 printf("Current dir: %s\n", ocwd.Data());
267 // Helper macros for creating chains
268 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
270 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
272 // creates chain of files in a given directory or file containing a list.
273 // In case of directory the structure is expected as:
274 // <aDataDir>/<dir0>/AliESDs.root
275 // <aDataDir>/<dir1>/AliESDs.root
281 Long_t id, size, flags, modtime;
282 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
284 printf("%s not found.\n", aDataDir);
288 TChain* chain = new TChain("esdTree");
289 TChain* chaingAlice = 0;
293 TString execDir(gSystem->pwd());
294 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
295 TList* dirList = baseDir->GetListOfFiles();
296 Int_t nDirs = dirList->GetEntries();
297 gSystem->cd(execDir);
301 for (Int_t iDir=0; iDir<nDirs; ++iDir)
303 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
304 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
313 if (count++ == aRuns)
316 TString presentDirName(aDataDir);
317 presentDirName += "/";
318 presentDirName += presentDir->GetName();
319 chain->Add(presentDirName + "/AliESDs.root/esdTree");
320 // cerr<<presentDirName<<endl;
326 // Open the input stream
332 // Read the input list of files and add them to the chain
336 if (!esdfile.Contains("root")) continue; // protection
344 if (count++ == aRuns)
358 // Helper macros for creating chains
359 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
361 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
363 // creates chain of files in a given directory or file containing a list.
364 // In case of directory the structure is expected as:
365 // <aDataDir>/<dir0>/AliAOD.root
366 // <aDataDir>/<dir1>/AliAOD.root
372 Long_t id, size, flags, modtime;
373 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
375 printf("%s not found.\n", aDataDir);
379 TChain* chain = new TChain("aodTree");
380 TChain* chaingAlice = 0;
384 TString execDir(gSystem->pwd());
385 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
386 TList* dirList = baseDir->GetListOfFiles();
387 Int_t nDirs = dirList->GetEntries();
388 gSystem->cd(execDir);
392 for (Int_t iDir=0; iDir<nDirs; ++iDir)
394 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
395 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
404 if (count++ == aRuns)
407 TString presentDirName(aDataDir);
408 presentDirName += "/";
409 presentDirName += presentDir->GetName();
410 chain->Add(presentDirName + "/AliAOD.root/aodTree");
411 // cerr<<presentDirName<<endl;
417 // Open the input stream
423 // Read the input list of files and add them to the chain
427 if (!aodfile.Contains("root")) continue; // protection
435 if (count++ == aRuns)