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 //mGridPAR: Analyze files on Grid via AliEn plug-in and using par files for FLOW package
9 const TString analysisType = "ESD"; //"MC", "ESD", "AOD"
10 const TString analysisMode = "TPC"; //"TPC", "Global"
12 //void runTaskFluctuations(Int_t mode = mPROOF, Int_t nRuns = 600000,
13 //Bool_t DATA = kTRUE, const Char_t* dataDir="/alice/data/LHC10h_000137161_p1_4plus#esdTree", Int_t offset=0) {
14 //void runTaskFluctuations(Int_t mode = mLocal, Bool_t DATA = kTRUE) {
15 //void runTaskFluctuations(Int_t mode = mGrid, Bool_t DATA = kTRUE) {
16 //void runTaskFluctuations(Int_t mode = mGridPAR, Bool_t DATA = kTRUE) {
17 void runTaskFluctuations(Int_t mode = mLocalPAR, Bool_t DATA = kTRUE) {
22 // Load needed libraries:
25 // Create and configure the AliEn plug-in:
26 if(mode == mGrid || mode == mGridPAR) {
27 gROOT->LoadMacro("CreateAlienHandler.C");
28 AliAnalysisGrid *alienHandler = CreateAlienHandler();
29 if (!alienHandler) return;
30 //gROOT->LoadMacro("AliEbyEFluctuationAnalysisTask.cxx++");
33 if(mode==mLocal || mode == mLocalPAR) {
34 //gROOT->LoadMacro("AliEbyEFluctuationAnalysisTask.cxx++");
35 if (analysisType!="AOD") {
36 TChain* chain = new TChain("esdTree");
37 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set1/AliESDs.root");
38 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set2/AliESDs.root");
39 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set3/AliESDs.root");
42 TChain* chain = CreateAODChain(dataDir, nRuns, offset);
46 gROOT->ProcessLine(Form(".include %s/include", gSystem->ExpandPathName("$ALICE_ROOT")));
47 //gProof->Load("AliEbyEFluctuationAnalysisTask.cxx++");
50 // Create analysis manager:
51 AliAnalysisManager *mgr = new AliAnalysisManager("FluctuationsAnalysisManager");
52 // Connect plug-in to the analysis manager:
53 if(mode == mGrid || mode == mGridPAR) {
54 mgr->SetGridHandler(alienHandler);
57 if(analysisType == "ESD") {
58 AliVEventHandler* esdH = new AliESDInputHandler;
59 mgr->SetInputEventHandler(esdH);
60 } // end of if(analysisType == "ESD")
61 if(analysisType == "AOD") {
62 AliVEventHandler* aodH = new AliAODInputHandler;
63 mgr->SetInputEventHandler(aodH);
64 } // end of if(analysisType == "AOD")
65 if(analysisType == "MC") {
66 AliVEventHandler* esdH = new AliESDInputHandler;
67 mgr->SetInputEventHandler(esdH);
68 AliMCEventHandler *mc = new AliMCEventHandler();
69 mgr->SetMCtruthEventHandler(mc);
70 } // end of if(analysisType == "MC")
72 // Load the analysis task:
73 gROOT->LoadMacro("AddTaskFluctuations.C");
74 AliEbyEFluctuationAnalysisTask* taskFA = AddTaskFluctuations(analysisType.Data(),
77 // Task to check the offline trigger:
78 //if(mode == mLocal || mode == mGrid || mode == mGridPAR)
79 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
80 AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection();
81 if(!DATA){physicsSelTask->GetPhysicsSelection()->SetAnalyzeMC();}
82 // Enable debug printouts:
83 mgr->SetDebugLevel(2);
85 //Add the centrality determination task
86 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
87 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
88 taskCentrality->SelectCollisionCandidates(AliVEvent::kMB);
91 if(!mgr->InitAnalysis()){return;}
93 if(mode == mLocal || mode == mLocalPAR)
94 //mgr->StartAnalysis("local",chain);
95 else if(mode == mPROOF)
96 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
97 else if(mode == mGrid || mode == mGridPAR)
98 //mgr->StartAnalysis("grid");
100 // Print real and CPU time used for analysis:
104 } // end of void runTaskFluctuations(...)
106 //=============================================================//
107 void LoadLibraries(const anaModes mode) {
108 //--------------------------------------
109 // Load the needed libraries most of them already loaded by aliroot
110 //--------------------------------------
111 gSystem->Load("libTree");
112 gSystem->Load("libGeom");
113 gSystem->Load("libVMC");
114 gSystem->Load("libXMLIO");
115 gSystem->Load("libPhysics");
117 //----------------------------------------------------------
118 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
119 //----------------------------------------------------------
120 if (mode==mLocal || mode==mGrid || mode == mGridPAR) {
121 //--------------------------------------------------------
122 // If you want to use already compiled libraries
123 // in the aliroot distribution
124 //--------------------------------------------------------
125 gSystem->Load("libSTEERBase");
126 gSystem->Load("libESD");
127 gSystem->Load("libAOD");
128 gSystem->Load("libANALYSIS");
129 gSystem->Load("libANALYSISalice");
130 if(mode==mLocal || mode==mGrid)
131 gSystem->Load("libPWG2ebye");
133 SetupPar("PWG2ebye");
136 else if (mode == mLocalPAR) {
137 //--------------------------------------------------------
138 //If you want to use root and par files from aliroot
139 //--------------------------------------------------------
140 gSystem->Load("libSTEERBase");
141 gSystem->Load("libESD");
142 gSystem->Load("libAOD");
143 gSystem->Load("libANALYSIS");
144 gSystem->Load("libANALYSISalice");
145 //SetupPar("STEERBase");
148 //SetupPar("ANALYSIS");
149 //SetupPar("ANALYSISalice");
150 SetupPar("PWG2ebye");
153 //---------------------------------------------------------
154 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
155 //---------------------------------------------------------
156 else if (mode==mPROOF) {
158 printf("*** Connect to PROOF ***\n");
159 gEnv->SetValue("XSec.GSI.DelegProxy","2");
160 // Put appropriate username here
161 TProof::Open("alice-caf.cern.ch");
162 //TProof::Open("skaf.saske.sk");
163 //TProof::Open("prf000-iep-grid.saske.sk");
165 gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-12-AN");
166 gSystem->Load("libSTEERBase");
167 gSystem->Load("libESD");
168 gSystem->Load("libAOD");
169 gSystem->Load("libANALYSIS");
170 gSystem->Load("libANALYSISalice");
172 // Clear the Packages
173 //gProof->ClearPackage("STEERBase.par");
174 //gProof->ClearPackage("ESD.par");
175 //gProof->ClearPackage("AOD.par");
176 //gProof->ClearPackage("ANALYSIS.par");
177 //gProof->ClearPackage("ANALYSISalice.par");
178 //gProof->ClearPackage("PWG2ebye");
180 // Upload the Packages
181 //gProof->UploadPackage("STEERBase.par");
182 //gProof->UploadPackage("ESD.par");
183 //gProof->UploadPackage("AOD.par");
184 //gProof->UploadPackage("ANALYSIS.par");
185 //gProof->UploadPackage("ANALYSISalice.par");
186 //gProof->UploadPackage("CORRFW.par");
187 gProof->UploadPackage("PWG2ebye.par");
189 // Enable the Packages
190 //gProof->EnablePackage("STEERBase");
191 //gProof->EnablePackage("ESD");
192 //gProof->EnablePackage("AOD");
193 //gProof->EnablePackage("ANALYSIS");
194 //gProof->EnablePackage("ANALYSISalice");
195 gProof->EnablePackage("PWG2ebye");
197 // Show enables Packages
198 //gProof->ShowEnabledPackages();
201 } // end of void LoadLibraries(const anaModes mode)
203 //===============================================================================================
205 void SetupPar(char* pararchivename) {
206 //Load par files, create analysis libraries
207 //For testing, if par file already decompressed and modified
208 //classes then do not decompress.
210 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
211 TString parpar(Form("%s.par", pararchivename)) ;
212 if ( gSystem->AccessPathName(parpar.Data()) ) {
213 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
214 TString processline(Form(".! make %s", parpar.Data())) ;
215 gROOT->ProcessLine(processline.Data()) ;
216 gSystem->ChangeDirectory(cdir) ;
217 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
218 gROOT->ProcessLine(processline.Data()) ;
220 if ( gSystem->AccessPathName(pararchivename) ) {
221 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
222 gROOT->ProcessLine(processline.Data());
225 TString ocwd = gSystem->WorkingDirectory();
226 gSystem->ChangeDirectory(pararchivename);
228 // check for BUILD.sh and execute
229 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
230 printf("*******************************\n");
231 printf("*** Building PAR archive ***\n");
232 cout<<pararchivename<<endl;
233 printf("*******************************\n");
234 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
235 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
239 // check for SETUP.C and execute
240 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
241 printf("*******************************\n");
242 printf("*** Setup PAR archive ***\n");
243 cout<<pararchivename<<endl;
244 printf("*******************************\n");
245 gROOT->Macro("PROOF-INF/SETUP.C");
248 gSystem->ChangeDirectory(ocwd.Data());
249 printf("Current dir: %s\n", ocwd.Data());
251 } // end of void SetupPar(char* pararchivename)
253 //===============================================================================================
255 // Helper macros for creating chains
256 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
258 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
260 // creates chain of files in a given directory or file containing a list.
261 // In case of directory the structure is expected as:
262 // <aDataDir>/<dir0>/AliESDs.root
263 // <aDataDir>/<dir1>/AliESDs.root
269 Long_t id, size, flags, modtime;
270 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
272 printf("%s not found.\n", aDataDir);
276 TChain* chain = new TChain("esdTree");
277 TChain* chaingAlice = 0;
281 TString execDir(gSystem->pwd());
282 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
283 TList* dirList = baseDir->GetListOfFiles();
284 Int_t nDirs = dirList->GetEntries();
285 gSystem->cd(execDir);
289 for (Int_t iDir=0; iDir<nDirs; ++iDir)
291 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
292 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
301 if (count++ == aRuns)
304 TString presentDirName(aDataDir);
305 presentDirName += "/";
306 presentDirName += presentDir->GetName();
307 chain->Add(presentDirName + "/AliESDs.root/esdTree");
308 // cerr<<presentDirName<<endl;
314 // Open the input stream
320 // Read the input list of files and add them to the chain
324 if (!esdfile.Contains("root")) continue; // protection
332 if (count++ == aRuns)
344 } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
346 //===============================================================================================
348 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
350 // creates chain of files in a given directory or file containing a list.
351 // In case of directory the structure is expected as:
352 // <aDataDir>/<dir0>/AliAOD.root
353 // <aDataDir>/<dir1>/AliAOD.root
359 Long_t id, size, flags, modtime;
360 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
362 printf("%s not found.\n", aDataDir);
366 TChain* chain = new TChain("aodTree");
367 TChain* chaingAlice = 0;
371 TString execDir(gSystem->pwd());
372 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
373 TList* dirList = baseDir->GetListOfFiles();
374 Int_t nDirs = dirList->GetEntries();
375 gSystem->cd(execDir);
379 for (Int_t iDir=0; iDir<nDirs; ++iDir)
381 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
382 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
391 if (count++ == aRuns)
394 TString presentDirName(aDataDir);
395 presentDirName += "/";
396 presentDirName += presentDir->GetName();
397 chain->Add(presentDirName + "/AliAOD.root/aodTree");
398 // cerr<<presentDirName<<endl;
404 // Open the input stream
410 // Read the input list of files and add them to the chain
414 if (!aodfile.Contains("root")) continue; // protection
422 if (count++ == aRuns)
434 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)