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) {
20 // Load needed libraries:
23 // Create and configure the AliEn plug-in:
24 if(mode == mGrid || mode == mGridPAR) {
25 gROOT->LoadMacro("CreateAlienHandler.C");
26 AliAnalysisGrid *alienHandler = CreateAlienHandler();
27 if (!alienHandler) return;
28 //gROOT->LoadMacro("AliEbyEFluctuationAnalysisTask.cxx++");
31 if(mode==mLocal || mode == mLocalPAR) {
32 //gROOT->LoadMacro("AliEbyEFluctuationAnalysisTask.cxx++");
33 if (analysisType!="AOD") {
34 TChain* chain = new TChain("esdTree");
35 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set1/AliESDs.root");
36 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set2/AliESDs.root");
37 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set3/AliESDs.root");
40 TChain* chain = CreateAODChain(dataDir, nRuns, offset);
44 gROOT->ProcessLine(Form(".include %s/include", gSystem->ExpandPathName("$ALICE_ROOT")));
45 //gProof->Load("AliEbyEFluctuationAnalysisTask.cxx++");
48 // Create analysis manager:
49 AliAnalysisManager *mgr = new AliAnalysisManager("FluctuationsAnalysisManager");
50 // Connect plug-in to the analysis manager:
51 if(mode == mGrid || mode == mGridPAR) {
52 mgr->SetGridHandler(alienHandler);
55 if(analysisType == "ESD") {
56 AliVEventHandler* esdH = new AliESDInputHandler;
57 mgr->SetInputEventHandler(esdH);
58 } // end of if(analysisType == "ESD")
59 if(analysisType == "AOD") {
60 AliVEventHandler* aodH = new AliAODInputHandler;
61 mgr->SetInputEventHandler(aodH);
62 } // end of if(analysisType == "AOD")
63 if(analysisType == "MC") {
64 AliVEventHandler* esdH = new AliESDInputHandler;
65 mgr->SetInputEventHandler(esdH);
66 AliMCEventHandler *mc = new AliMCEventHandler();
67 mgr->SetMCtruthEventHandler(mc);
68 } // end of if(analysisType == "MC")
70 // Load the analysis task:
71 gROOT->LoadMacro("AddTaskFluctuations.C");
72 AliEbyEFluctuationAnalysisTask* taskFA = AddTaskFluctuations(analysisType.Data(),
75 // Task to check the offline trigger:
76 //if(mode == mLocal || mode == mGrid || mode == mGridPAR)
77 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
78 AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection();
79 if(!DATA){physicsSelTask->GetPhysicsSelection()->SetAnalyzeMC();}
80 // Enable debug printouts:
81 mgr->SetDebugLevel(2);
83 //Add the centrality determination task
84 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
85 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
86 taskCentrality->SelectCollisionCandidates(AliVEvent::kMB);
89 if(!mgr->InitAnalysis()){return;}
91 if(mode == mLocal || mode == mLocalPAR)
92 mgr->StartAnalysis("local",chain);
93 else if(mode == mPROOF)
94 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
95 else if(mode == mGrid || mode == mGridPAR)
96 mgr->StartAnalysis("grid");
98 // Print real and CPU time used for analysis:
102 } // end of void runTaskFluctuations(...)
104 //=============================================================//
105 void LoadLibraries(const anaModes mode) {
106 //--------------------------------------
107 // Load the needed libraries most of them already loaded by aliroot
108 //--------------------------------------
109 gSystem->Load("libTree");
110 gSystem->Load("libGeom");
111 gSystem->Load("libVMC");
112 gSystem->Load("libXMLIO");
113 gSystem->Load("libPhysics");
115 //----------------------------------------------------------
116 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
117 //----------------------------------------------------------
118 if (mode==mLocal || mode==mGrid || mode == mGridPAR) {
119 //--------------------------------------------------------
120 // If you want to use already compiled libraries
121 // in the aliroot distribution
122 //--------------------------------------------------------
123 gSystem->Load("libSTEERBase");
124 gSystem->Load("libESD");
125 gSystem->Load("libAOD");
126 gSystem->Load("libANALYSIS");
127 gSystem->Load("libANALYSISalice");
128 if(mode==mLocal || mode==mGrid)
129 gSystem->Load("libPWG2ebye");
131 SetupPar("PWG2ebye");
134 else if (mode == mLocalPAR) {
135 //--------------------------------------------------------
136 //If you want to use root and par files from aliroot
137 //--------------------------------------------------------
138 SetupPar("STEERBase");
141 SetupPar("ANALYSIS");
142 SetupPar("ANALYSISalice");
143 SetupPar("PWG2ebye");
146 //---------------------------------------------------------
147 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
148 //---------------------------------------------------------
149 else if (mode==mPROOF) {
151 printf("*** Connect to PROOF ***\n");
152 gEnv->SetValue("XSec.GSI.DelegProxy","2");
153 // Put appropriate username here
154 TProof::Open("alice-caf.cern.ch");
155 //TProof::Open("skaf.saske.sk");
156 //TProof::Open("prf000-iep-grid.saske.sk");
158 gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-12-AN");
160 // Clear the Packages
161 //gProof->ClearPackage("STEERBase.par");
162 //gProof->ClearPackage("ESD.par");
163 //gProof->ClearPackage("AOD.par");
164 //gProof->ClearPackage("ANALYSIS.par");
165 //gProof->ClearPackage("ANALYSISalice.par");
166 //gProof->ClearPackage("PWG2ebye");
168 // Upload the Packages
169 //gProof->UploadPackage("STEERBase.par");
170 //gProof->UploadPackage("ESD.par");
171 //gProof->UploadPackage("AOD.par");
172 //gProof->UploadPackage("ANALYSIS.par");
173 //gProof->UploadPackage("ANALYSISalice.par");
174 //gProof->UploadPackage("CORRFW.par");
175 //gProof->UploadPackage("PWG2ebye");
177 // Enable the Packages
178 //gProof->EnablePackage("STEERBase");
179 //gProof->EnablePackage("ESD");
180 //gProof->EnablePackage("AOD");
181 //gProof->EnablePackage("ANALYSIS");
182 //gProof->EnablePackage("ANALYSISalice");
183 //gProof->EnablePackage("PWG2ebye");
185 // Show enables Packages
186 //gProof->ShowEnabledPackages();
189 } // end of void LoadLibraries(const anaModes mode)
191 //===============================================================================================
193 void SetupPar(char* pararchivename) {
194 //Load par files, create analysis libraries
195 //For testing, if par file already decompressed and modified
196 //classes then do not decompress.
198 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
199 TString parpar(Form("%s.par", pararchivename)) ;
200 if ( gSystem->AccessPathName(parpar.Data()) ) {
201 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
202 TString processline(Form(".! make %s", parpar.Data())) ;
203 gROOT->ProcessLine(processline.Data()) ;
204 gSystem->ChangeDirectory(cdir) ;
205 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
206 gROOT->ProcessLine(processline.Data()) ;
208 if ( gSystem->AccessPathName(pararchivename) ) {
209 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
210 gROOT->ProcessLine(processline.Data());
213 TString ocwd = gSystem->WorkingDirectory();
214 gSystem->ChangeDirectory(pararchivename);
216 // check for BUILD.sh and execute
217 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
218 printf("*******************************\n");
219 printf("*** Building PAR archive ***\n");
220 cout<<pararchivename<<endl;
221 printf("*******************************\n");
222 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
223 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
227 // check for SETUP.C and execute
228 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
229 printf("*******************************\n");
230 printf("*** Setup PAR archive ***\n");
231 cout<<pararchivename<<endl;
232 printf("*******************************\n");
233 gROOT->Macro("PROOF-INF/SETUP.C");
236 gSystem->ChangeDirectory(ocwd.Data());
237 printf("Current dir: %s\n", ocwd.Data());
239 } // end of void SetupPar(char* pararchivename)
241 //===============================================================================================
243 // Helper macros for creating chains
244 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
246 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
248 // creates chain of files in a given directory or file containing a list.
249 // In case of directory the structure is expected as:
250 // <aDataDir>/<dir0>/AliESDs.root
251 // <aDataDir>/<dir1>/AliESDs.root
257 Long_t id, size, flags, modtime;
258 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
260 printf("%s not found.\n", aDataDir);
264 TChain* chain = new TChain("esdTree");
265 TChain* chaingAlice = 0;
269 TString execDir(gSystem->pwd());
270 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
271 TList* dirList = baseDir->GetListOfFiles();
272 Int_t nDirs = dirList->GetEntries();
273 gSystem->cd(execDir);
277 for (Int_t iDir=0; iDir<nDirs; ++iDir)
279 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
280 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
289 if (count++ == aRuns)
292 TString presentDirName(aDataDir);
293 presentDirName += "/";
294 presentDirName += presentDir->GetName();
295 chain->Add(presentDirName + "/AliESDs.root/esdTree");
296 // cerr<<presentDirName<<endl;
302 // Open the input stream
308 // Read the input list of files and add them to the chain
312 if (!esdfile.Contains("root")) continue; // protection
320 if (count++ == aRuns)
332 } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
334 //===============================================================================================
336 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
338 // creates chain of files in a given directory or file containing a list.
339 // In case of directory the structure is expected as:
340 // <aDataDir>/<dir0>/AliAOD.root
341 // <aDataDir>/<dir1>/AliAOD.root
347 Long_t id, size, flags, modtime;
348 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
350 printf("%s not found.\n", aDataDir);
354 TChain* chain = new TChain("aodTree");
355 TChain* chaingAlice = 0;
359 TString execDir(gSystem->pwd());
360 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
361 TList* dirList = baseDir->GetListOfFiles();
362 Int_t nDirs = dirList->GetEntries();
363 gSystem->cd(execDir);
367 for (Int_t iDir=0; iDir<nDirs; ++iDir)
369 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
370 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
379 if (count++ == aRuns)
382 TString presentDirName(aDataDir);
383 presentDirName += "/";
384 presentDirName += presentDir->GetName();
385 chain->Add(presentDirName + "/AliAOD.root/aodTree");
386 // cerr<<presentDirName<<endl;
392 // Open the input stream
398 // Read the input list of files and add them to the chain
402 if (!aodfile.Contains("root")) continue; // protection
410 if (count++ == aRuns)
422 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)