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=="ESD") {
34 TChain* chain = new TChain("esdTree");
35 chain->Add("/data/alice2/pchrist/HeavyIons/Data/Pass1_4Plus/Set1/AliESDs.root");
36 chain->Add("/data/alice2/pchrist/HeavyIons/Data/Pass1_4Plus/Set2/AliESDs.root");
37 chain->Add("/data/alice2/pchrist/HeavyIons/Data/Pass1_4Plus/Set3/AliESDs.root");
38 chain->Add("/data/alice2/pchrist/HeavyIons/Data/Pass1_4Plus/Set4/AliESDs.root");
39 chain->Add("/data/alice2/pchrist/HeavyIons/Data/Pass1_4Plus/Set5/AliESDs.root");
40 chain->Add("/data/alice2/pchrist/HeavyIons/Data/Pass1_4Plus/Set6/AliESDs.root");
41 chain->Add("/data/alice2/pchrist/HeavyIons/Data/Pass1_4Plus/Set7/AliESDs.root");
42 chain->Add("/data/alice2/pchrist/HeavyIons/Data/Pass1_4Plus/Set8/AliESDs.root");
43 chain->Add("/data/alice2/pchrist/HeavyIons/Data/Pass1_4Plus/Set9/AliESDs.root");
44 chain->Add("/data/alice2/pchrist/HeavyIons/Data/Pass1_4Plus/Set10/AliESDs.root");
46 else if(analysisType == "MC") {
47 TChain *chain = new TChain("TE");
48 chain->AddFile("galice.root");
51 TChain* chain = CreateAODChain(dataDir, nRuns, offset);
55 gROOT->ProcessLine(Form(".include %s/include", gSystem->ExpandPathName("$ALICE_ROOT")));
56 gProof->Load("AliEbyEFluctuationAnalysisTask.cxx++");
59 // Create analysis manager:
60 AliAnalysisManager *mgr = new AliAnalysisManager("FluctuationsAnalysisManager");
61 // Connect plug-in to the analysis manager:
62 if(mode == mGrid || mode == mGridPAR) {
63 mgr->SetGridHandler(alienHandler);
66 if(analysisType == "ESD") {
67 AliVEventHandler* esdH = new AliESDInputHandler;
68 mgr->SetInputEventHandler(esdH);
69 } // end of if(analysisType == "ESD")
70 if(analysisType == "AOD") {
71 AliVEventHandler* aodH = new AliAODInputHandler;
72 mgr->SetInputEventHandler(aodH);
73 } // end of if(analysisType == "AOD")
74 if(analysisType == "MC") {
75 AliVEventHandler* esdH = new AliESDInputHandler;
76 mgr->SetInputEventHandler(esdH);
77 AliMCEventHandler *mc = new AliMCEventHandler();
78 mc->SetReadTR(kFALSE);
79 mgr->SetMCtruthEventHandler(mc);
80 } // end of if(analysisType == "MC")
82 // Task to check the offline trigger:
83 //if(mode == mLocal || mode == mGrid || mode == mGridPAR)
84 if(analysisType != "MC") {
85 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
86 AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection(!DATA);
87 if(!DATA){physicsSelTask->GetPhysicsSelection()->SetAnalyzeMC();}
88 // Enable debug printouts:
89 mgr->SetDebugLevel(2);
91 //Add the centrality determination task
92 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
93 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
94 //taskCentrality->SelectCollisionCandidates(AliVEvent::kMB);
97 // Load the analysis task:
98 gROOT->LoadMacro("AddTaskFluctuations.C");
99 AliEbyEFluctuationAnalysisTask* taskFA = AddTaskFluctuations(analysisType.Data(),
100 analysisMode.Data());
103 if(!mgr->InitAnalysis()){return;}
105 if(mode == mLocal || mode == mLocalPAR)
106 mgr->StartAnalysis("local",chain);
107 else if(mode == mPROOF)
108 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
109 else if(mode == mGrid || mode == mGridPAR)
110 mgr->StartAnalysis("grid");
112 // Print real and CPU time used for analysis:
116 } // end of void runTaskFluctuations(...)
118 //=============================================================//
119 void LoadLibraries(const anaModes mode) {
120 //--------------------------------------
121 // Load the needed libraries most of them already loaded by aliroot
122 //--------------------------------------
123 gSystem->Load("libTree");
124 gSystem->Load("libGeom");
125 gSystem->Load("libVMC");
126 gSystem->Load("libXMLIO");
127 gSystem->Load("libPhysics");
129 //----------------------------------------------------------
130 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
131 //----------------------------------------------------------
132 if (mode==mLocal || mode==mGrid || mode == mGridPAR) {
133 //--------------------------------------------------------
134 // If you want to use already compiled libraries
135 // in the aliroot distribution
136 //--------------------------------------------------------
137 gSystem->Load("libSTEERBase");
138 gSystem->Load("libESD");
139 gSystem->Load("libAOD");
140 gSystem->Load("libANALYSIS");
141 gSystem->Load("libANALYSISalice");
142 // Use AliRoot includes to compile our task
143 gROOT->ProcessLine(".include $ALICE_ROOT/include");
144 if(mode==mLocal || mode==mGrid)
145 gSystem->Load("libPWGCFebye");
147 SetupPar("PWGCFebye");
150 else if (mode == mLocalPAR) {
151 //--------------------------------------------------------
152 //If you want to use root and par files from aliroot
153 //--------------------------------------------------------
154 SetupPar("STEERBase");
157 SetupPar("ANALYSIS");
158 SetupPar("ANALYSISalice");
159 SetupPar("PWGCFebye");
162 //---------------------------------------------------------
163 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
164 //---------------------------------------------------------
165 else if (mode==mPROOF) {
167 printf("*** Connect to PROOF ***\n");
168 gEnv->SetValue("XSec.GSI.DelegProxy","2");
169 // Put appropriate username here
170 TProof::Open("alice-caf.cern.ch");
171 //TProof::Open("skaf.saske.sk");
172 //TProof::Open("prf000-iep-grid.saske.sk");
174 gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-12-AN");
176 // Clear the Packages
177 //gProof->ClearPackage("STEERBase.par");
178 //gProof->ClearPackage("ESD.par");
179 //gProof->ClearPackage("AOD.par");
180 //gProof->ClearPackage("ANALYSIS.par");
181 //gProof->ClearPackage("ANALYSISalice.par");
182 //gProof->ClearPackage("PWGCFebye");
184 // Upload the Packages
185 //gProof->UploadPackage("STEERBase.par");
186 //gProof->UploadPackage("ESD.par");
187 //gProof->UploadPackage("AOD.par");
188 //gProof->UploadPackage("ANALYSIS.par");
189 //gProof->UploadPackage("ANALYSISalice.par");
190 //gProof->UploadPackage("CORRFW.par");
191 //gProof->UploadPackage("PWGCFebye");
193 // Enable the Packages
194 //gProof->EnablePackage("STEERBase");
195 //gProof->EnablePackage("ESD");
196 //gProof->EnablePackage("AOD");
197 //gProof->EnablePackage("ANALYSIS");
198 //gProof->EnablePackage("ANALYSISalice");
199 //gProof->EnablePackage("PWGCFebye");
201 // Show enables Packages
202 //gProof->ShowEnabledPackages();
205 } // end of void LoadLibraries(const anaModes mode)
207 //===============================================================================================
209 void SetupPar(char* pararchivename) {
210 //Load par files, create analysis libraries
211 //For testing, if par file already decompressed and modified
212 //classes then do not decompress.
214 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
215 TString parpar(Form("%s.par", pararchivename)) ;
216 if ( gSystem->AccessPathName(parpar.Data()) ) {
217 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
218 TString processline(Form(".! make %s", parpar.Data())) ;
219 gROOT->ProcessLine(processline.Data()) ;
220 gSystem->ChangeDirectory(cdir) ;
221 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
222 gROOT->ProcessLine(processline.Data()) ;
224 if ( gSystem->AccessPathName(pararchivename) ) {
225 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
226 gROOT->ProcessLine(processline.Data());
229 TString ocwd = gSystem->WorkingDirectory();
230 gSystem->ChangeDirectory(pararchivename);
232 // check for BUILD.sh and execute
233 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
234 printf("*******************************\n");
235 printf("*** Building PAR archive ***\n");
236 cout<<pararchivename<<endl;
237 printf("*******************************\n");
238 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
239 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
243 // check for SETUP.C and execute
244 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
245 printf("*******************************\n");
246 printf("*** Setup PAR archive ***\n");
247 cout<<pararchivename<<endl;
248 printf("*******************************\n");
249 gROOT->Macro("PROOF-INF/SETUP.C");
252 gSystem->ChangeDirectory(ocwd.Data());
253 printf("Current dir: %s\n", ocwd.Data());
255 } // end of void SetupPar(char* pararchivename)
257 //===============================================================================================
259 // Helper macros for creating chains
260 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
262 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
264 // creates chain of files in a given directory or file containing a list.
265 // In case of directory the structure is expected as:
266 // <aDataDir>/<dir0>/AliESDs.root
267 // <aDataDir>/<dir1>/AliESDs.root
273 Long_t id, size, flags, modtime;
274 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
276 printf("%s not found.\n", aDataDir);
280 TChain* chain = new TChain("esdTree");
281 TChain* chaingAlice = 0;
285 TString execDir(gSystem->pwd());
286 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
287 TList* dirList = baseDir->GetListOfFiles();
288 Int_t nDirs = dirList->GetEntries();
289 gSystem->cd(execDir);
293 for (Int_t iDir=0; iDir<nDirs; ++iDir)
295 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
296 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
305 if (count++ == aRuns)
308 TString presentDirName(aDataDir);
309 presentDirName += "/";
310 presentDirName += presentDir->GetName();
311 chain->Add(presentDirName + "/AliESDs.root/esdTree");
312 // cerr<<presentDirName<<endl;
318 // Open the input stream
324 // Read the input list of files and add them to the chain
328 if (!esdfile.Contains("root")) continue; // protection
336 if (count++ == aRuns)
348 } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
350 //===============================================================================================
352 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
354 // creates chain of files in a given directory or file containing a list.
355 // In case of directory the structure is expected as:
356 // <aDataDir>/<dir0>/AliAOD.root
357 // <aDataDir>/<dir1>/AliAOD.root
363 Long_t id, size, flags, modtime;
364 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
366 printf("%s not found.\n", aDataDir);
370 TChain* chain = new TChain("aodTree");
371 TChain* chaingAlice = 0;
375 TString execDir(gSystem->pwd());
376 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
377 TList* dirList = baseDir->GetListOfFiles();
378 Int_t nDirs = dirList->GetEntries();
379 gSystem->cd(execDir);
383 for (Int_t iDir=0; iDir<nDirs; ++iDir)
385 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
386 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
395 if (count++ == aRuns)
398 TString presentDirName(aDataDir);
399 presentDirName += "/";
400 presentDirName += presentDir->GetName();
401 chain->Add(presentDirName + "/AliAOD.root/aodTree");
402 // cerr<<presentDirName<<endl;
408 // Open the input stream
414 // Read the input list of files and add them to the chain
418 if (!aodfile.Contains("root")) continue; // protection
426 if (count++ == aRuns)
438 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)