1 enum anaModes {mLocal,mLocalPAR,mPROOF,mGrid,mGridPAR};
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
5 //mGrid: Analyze files on Grid via AliEn plug-in and using precompiled FLOW libraries
6 // (Remark: When using this mode set also Bool_t bUseParFiles = kFALSE; in CreateAlienHandler.C)
7 //mGridPAR: Analyze files on Grid via AliEn plug-in and using par files for FLOW package
8 // (Remark: when using this mode set also Bool_t bUseParFiles = kTRUE; in CreateAlienHandler.C)
10 // CENTRALITY DEFINITION
11 const Int_t numberOfCentralityBins = 1;
12 Int_t centralityArray[numberOfCentralityBins+1] = {0,10000}; // in terms of reference multiplicity
13 TString commonOutputFileName = "outputCentrality"; // e.g.: result for centrality bin 0 will be in the file "outputCentrality0.root", etc
15 //void runFlowTaskCentralityTrain(Int_t mode=mLocal, Int_t nRuns = 10,
16 //Bool_t DATA = kFALSE, const Char_t* dataDir="/Users/snelling/alice_data/Therminator_midcentral", Int_t offset = 0)
18 //void runFlowTaskCentralityTrain(Int_t mode = mPROOF, Int_t nRuns = 50000000,
19 // Bool_t DATA = kTRUE, const Char_t* dataDir="/alice/data/LHC10e_000130795_p1", Int_t offset=0) //hijing Pb Pb pilot
21 void runFlowTaskCentralityTrain(Int_t mode = mGrid, Bool_t DATA = kTRUE)
26 // Cross-check user settings before starting:
27 // CrossCheckUserSettings(DATA);
28 // Load needed libraries:
30 // Create and configure the AliEn plug-in:
31 if(mode == mGrid || mode == mGridPAR)
33 gROOT->LoadMacro("CreateAlienHandler.C");
34 AliAnalysisGrid *alienHandler = CreateAlienHandler();
35 if(!alienHandler) return;
38 if(mode == mLocal || mode == mLocalPAR) {
39 TChain* chain = CreateESDChain(dataDir, nRuns, offset);
40 //TChain* chain = CreateAODChain(dataDir, nRuns, offset);
43 // Create analysis manager:
44 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
45 // Connect plug-in to the analysis manager:
46 if(mode == mGrid || mode == mGridPAR)
48 mgr->SetGridHandler(alienHandler);
52 AliVEventHandler* esdH = new AliESDInputHandler;
53 mgr->SetInputEventHandler(esdH);
54 AliMCEventHandler *mc = new AliMCEventHandler();
55 mgr->SetMCtruthEventHandler(mc);
57 // Load the analysis task:
58 gROOT->LoadMacro("AddTaskFlowCentrality.C");
60 // Setup analysis per centrality bin:
61 for (Int_t i=0; i<numberOfCentralityBins; i++)
63 Int_t lowCentralityBinEdge = centralityArray[i];
64 Int_t highCentralityBinEdge = centralityArray[i+1];
65 TString filename(commonOutputFileName.Data());
67 //TDirectory* dir = new TDirectory(filename.Data(),"");
69 Printf("\nWagon for centrality bin %i:",i);
70 AddTaskFlowCentrality( lowCentralityBinEdge,
71 highCentralityBinEdge,
74 } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
76 // Task to check the offline trigger:
77 if(mode == mLocal || mode == mGrid || mode == mGridPAR) {
78 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
79 } else if(mode == mPROOF || mode == mLocalPAR) {
80 gROOT->LoadMacro("AddTaskPhysicsSelection.C");
83 AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection();
84 physicsSelTask->GetPhysicsSelection()->AddCollisionTriggerClass("+COSM1-B-NOPF-ALL");
85 physicsSelTask->GetPhysicsSelection()->AddCollisionTriggerClass("+C0VBA-B-NOPF-ALL");
86 physicsSelTask->GetPhysicsSelection()->AddCollisionTriggerClass("+C0VBC-B-NOPF-ALL");
88 if(!DATA){physicsSelTask->GetPhysicsSelection()->SetAnalyzeMC();}
89 // Enable debug printouts:
90 mgr->SetDebugLevel(2);
92 if(!mgr->InitAnalysis()) return;
94 if(mode == mLocal || mode == mLocalPAR) {
95 mgr->StartAnalysis("local",chain);
96 } else if(mode == mPROOF) {
97 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
98 } else if(mode == mGrid || mode == mGridPAR) {
99 mgr->StartAnalysis("grid");
102 // Print real and CPU time used for analysis:
106 } // end of void runFlowTaskCentralityTrain(...)
108 //===============================================================================================
110 void CrossCheckUserSettings(Bool_t bData)
112 // Check in this method if the user settings make sense.
113 if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
114 if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
115 if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
116 if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
117 } // end of void CrossCheckUserSettings()
119 //===============================================================================================
121 void LoadLibraries(const anaModes mode)
123 //--------------------------------------
124 // Load the needed libraries most of them already loaded by aliroot
125 //--------------------------------------
126 //gSystem->Load("libTree");
127 gSystem->Load("libGeom");
128 gSystem->Load("libVMC");
129 gSystem->Load("libXMLIO");
130 gSystem->Load("libPhysics");
132 //----------------------------------------------------------
133 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
134 //----------------------------------------------------------
135 if (mode==mLocal || mode==mGrid || mode == mGridPAR) {
136 //--------------------------------------------------------
137 // If you want to use already compiled libraries
138 // in the aliroot distribution
139 //--------------------------------------------------------
140 gSystem->Load("libSTEERBase");
141 gSystem->Load("libESD");
142 gSystem->Load("libAOD");
143 gSystem->Load("libANALYSIS");
144 gSystem->Load("libANALYSISalice");
145 gSystem->Load("libCORRFW");
146 gSystem->Load("libPWG2forward");
147 if(mode==mLocal || mode==mGrid)
149 gSystem->Load("libPWG2flowCommon");
150 cerr<<"libPWG2flowCommon loaded..."<<endl;
151 gSystem->Load("libPWG2flowTasks");
152 cerr<<"libPWG2flowTasks loaded..."<<endl;
156 SetupPar("PWG2flowCommon");
157 cerr<<"PWG2flowCommon.par loaded..."<<endl;
158 SetupPar("PWG2flowTasks");
159 cerr<<"PWG2flowTasks.par loaded..."<<endl;
163 else if (mode == mLocalPAR) {
164 //--------------------------------------------------------
165 //If you want to use root and par files from aliroot
166 //--------------------------------------------------------
167 SetupPar("STEERBase");
170 SetupPar("ANALYSIS");
171 SetupPar("ANALYSISalice");
173 SetupPar("PWG2flowCommon");
174 cerr<<"PWG2flowCommon.par loaded..."<<endl;
175 SetupPar("PWG2flowTasks");
176 cerr<<"PWG2flowTasks.par loaded..."<<endl;
179 //---------------------------------------------------------
180 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
181 //---------------------------------------------------------
182 else if (mode==mPROOF) {
183 // set to debug root versus if needed
184 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg");
185 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a");
186 //TProof::Reset("proof://snelling@alicecaf.cern.ch");
188 printf("*** Connect to PROOF ***\n");
189 gEnv->SetValue("XSec.GSI.DelegProxy","2");
190 TProof::Open("alice-caf.cern.ch");
191 //TProof::Open("skaf.saske.sk");
192 // list the data available
193 //gProof->ShowDataSets("/*/*");
194 //gProof->ShowDataSets("/alice/sim/"); //for MC Data
195 //gProof->ShowDataSets("/alice/data/"); //for REAL Data
197 // Clear the Packages
199 gProof->ClearPackage("STEERBase.par");
200 gProof->ClearPackage("ESD.par");
201 gProof->ClearPackage("AOD.par");
202 gProof->ClearPackage("ANALYSIS.par");
203 gProof->ClearPackage("ANALYSISalice.par");
204 gProof->ClearPackage("CORRFW.par");
206 gProof->ClearPackage("PWG2flowCommon");
207 gProof->ClearPackage("PWG2flowTasks");
209 // Upload the Packages
210 gProof->UploadPackage("STEERBase.par");
211 gProof->UploadPackage("ESD.par");
212 gProof->UploadPackage("AOD.par");
214 gProof->UploadPackage("ANALYSIS.par");
215 gProof->UploadPackage("ANALYSISalice.par");
216 gProof->UploadPackage("CORRFW.par");
217 gProof->UploadPackage("PWG2flowCommon.par");
218 gProof->UploadPackage("PWG2flowTasks.par");
220 // Enable the Packages
221 // The global package
222 //gProof->EnablePackage("aliroot_v4-19-05-AN",kTRUE);
225 gProof->EnablePackage("STEERBase");
226 gProof->EnablePackage("ESD");
227 gProof->EnablePackage("AOD");
230 gProof->EnablePackage("ANALYSIS");
231 gProof->EnablePackage("ANALYSISalice");
232 gProof->EnablePackage("CORRFW");
233 gProof->EnablePackage("PWG2flowCommon");
234 gProof->EnablePackage("PWG2flowTasks");
236 // Show enables Packages
237 gProof->ShowEnabledPackages();
240 } // end of void LoadLibraries(const anaModes mode)
242 //===============================================================================================
244 void SetupPar(char* pararchivename)
246 //Load par files, create analysis libraries
247 //For testing, if par file already decompressed and modified
248 //classes then do not decompress.
250 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
251 TString parpar(Form("%s.par", pararchivename)) ;
252 if ( gSystem->AccessPathName(parpar.Data()) ) {
253 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
254 TString processline(Form(".! make %s", parpar.Data())) ;
255 gROOT->ProcessLine(processline.Data()) ;
256 gSystem->ChangeDirectory(cdir) ;
257 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
258 gROOT->ProcessLine(processline.Data()) ;
260 if ( gSystem->AccessPathName(pararchivename) ) {
261 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
262 gROOT->ProcessLine(processline.Data());
265 TString ocwd = gSystem->WorkingDirectory();
266 gSystem->ChangeDirectory(pararchivename);
268 // check for BUILD.sh and execute
269 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
270 printf("*******************************\n");
271 printf("*** Building PAR archive ***\n");
272 cout<<pararchivename<<endl;
273 printf("*******************************\n");
274 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
275 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
279 // check for SETUP.C and execute
280 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
281 printf("*******************************\n");
282 printf("*** Setup PAR archive ***\n");
283 cout<<pararchivename<<endl;
284 printf("*******************************\n");
285 gROOT->Macro("PROOF-INF/SETUP.C");
288 gSystem->ChangeDirectory(ocwd.Data());
289 printf("Current dir: %s\n", ocwd.Data());
291 } // end of void SetupPar(char* pararchivename)
293 //===============================================================================================
295 // Helper macros for creating chains
296 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
298 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
300 // creates chain of files in a given directory or file containing a list.
301 // In case of directory the structure is expected as:
302 // <aDataDir>/<dir0>/AliESDs.root
303 // <aDataDir>/<dir1>/AliESDs.root
309 Long_t id, size, flags, modtime;
310 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
312 printf("%s not found.\n", aDataDir);
316 TChain* chain = new TChain("esdTree");
317 TChain* chaingAlice = 0;
321 TString execDir(gSystem->pwd());
322 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
323 TList* dirList = baseDir->GetListOfFiles();
324 Int_t nDirs = dirList->GetEntries();
325 gSystem->cd(execDir);
329 for (Int_t iDir=0; iDir<nDirs; ++iDir)
331 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
332 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
341 if (count++ == aRuns)
344 TString presentDirName(aDataDir);
345 presentDirName += "/";
346 presentDirName += presentDir->GetName();
347 chain->Add(presentDirName + "/AliESDs.root/esdTree");
348 // cerr<<presentDirName<<endl;
354 // Open the input stream
360 // Read the input list of files and add them to the chain
364 if (!esdfile.Contains("root")) continue; // protection
372 if (count++ == aRuns)
384 } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
386 //===============================================================================================
388 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
390 // creates chain of files in a given directory or file containing a list.
391 // In case of directory the structure is expected as:
392 // <aDataDir>/<dir0>/AliAOD.root
393 // <aDataDir>/<dir1>/AliAOD.root
399 Long_t id, size, flags, modtime;
400 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
402 printf("%s not found.\n", aDataDir);
406 TChain* chain = new TChain("aodTree");
407 TChain* chaingAlice = 0;
411 TString execDir(gSystem->pwd());
412 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
413 TList* dirList = baseDir->GetListOfFiles();
414 Int_t nDirs = dirList->GetEntries();
415 gSystem->cd(execDir);
419 for (Int_t iDir=0; iDir<nDirs; ++iDir)
421 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
422 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
431 if (count++ == aRuns)
434 TString presentDirName(aDataDir);
435 presentDirName += "/";
436 presentDirName += presentDir->GetName();
437 chain->Add(presentDirName + "/AliAOD.root/aodTree");
438 // cerr<<presentDirName<<endl;
444 // Open the input stream
450 // Read the input list of files and add them to the chain
454 if (!aodfile.Contains("root")) continue; // protection
462 if (count++ == aRuns)
474 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)