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("libEventMixing");
146 gSystem->Load("libPWGCFebye");
149 SetupPar("EventMixing");
150 SetupPar("PWGCFebye");
154 else if (mode == mLocalPAR) {
155 //--------------------------------------------------------
156 //If you want to use root and par files from aliroot
157 //--------------------------------------------------------
158 SetupPar("STEERBase");
161 SetupPar("ANALYSIS");
162 SetupPar("ANALYSISalice");
163 SetupPar("PWGCFebye");
166 //---------------------------------------------------------
167 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
168 //---------------------------------------------------------
169 else if (mode==mPROOF) {
171 printf("*** Connect to PROOF ***\n");
172 gEnv->SetValue("XSec.GSI.DelegProxy","2");
173 // Put appropriate username here
174 TProof::Open("alice-caf.cern.ch");
175 //TProof::Open("skaf.saske.sk");
176 //TProof::Open("prf000-iep-grid.saske.sk");
178 gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-12-AN");
180 // Clear the Packages
181 //gProof->ClearPackage("STEERBase.par");
182 //gProof->ClearPackage("ESD.par");
183 //gProof->ClearPackage("AOD.par");
184 //gProof->ClearPackage("ANALYSIS.par");
185 //gProof->ClearPackage("ANALYSISalice.par");
186 //gProof->ClearPackage("PWGCFebye");
188 // Upload the Packages
189 //gProof->UploadPackage("STEERBase.par");
190 //gProof->UploadPackage("ESD.par");
191 //gProof->UploadPackage("AOD.par");
192 //gProof->UploadPackage("ANALYSIS.par");
193 //gProof->UploadPackage("ANALYSISalice.par");
194 //gProof->UploadPackage("CORRFW.par");
195 //gProof->UploadPackage("PWGCFebye");
197 // Enable the Packages
198 //gProof->EnablePackage("STEERBase");
199 //gProof->EnablePackage("ESD");
200 //gProof->EnablePackage("AOD");
201 //gProof->EnablePackage("ANALYSIS");
202 //gProof->EnablePackage("ANALYSISalice");
203 //gProof->EnablePackage("PWGCFebye");
205 // Show enables Packages
206 //gProof->ShowEnabledPackages();
209 } // end of void LoadLibraries(const anaModes mode)
211 //===============================================================================================
213 void SetupPar(char* pararchivename) {
214 //Load par files, create analysis libraries
215 //For testing, if par file already decompressed and modified
216 //classes then do not decompress.
218 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
219 TString parpar(Form("%s.par", pararchivename)) ;
220 if ( gSystem->AccessPathName(parpar.Data()) ) {
221 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
222 TString processline(Form(".! make %s", parpar.Data())) ;
223 gROOT->ProcessLine(processline.Data()) ;
224 gSystem->ChangeDirectory(cdir) ;
225 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
226 gROOT->ProcessLine(processline.Data()) ;
228 if ( gSystem->AccessPathName(pararchivename) ) {
229 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
230 gROOT->ProcessLine(processline.Data());
233 TString ocwd = gSystem->WorkingDirectory();
234 gSystem->ChangeDirectory(pararchivename);
236 // check for BUILD.sh and execute
237 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
238 printf("*******************************\n");
239 printf("*** Building PAR archive ***\n");
240 cout<<pararchivename<<endl;
241 printf("*******************************\n");
242 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
243 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
247 // check for SETUP.C and execute
248 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
249 printf("*******************************\n");
250 printf("*** Setup PAR archive ***\n");
251 cout<<pararchivename<<endl;
252 printf("*******************************\n");
253 gROOT->Macro("PROOF-INF/SETUP.C");
256 gSystem->ChangeDirectory(ocwd.Data());
257 printf("Current dir: %s\n", ocwd.Data());
259 } // end of void SetupPar(char* pararchivename)
261 //===============================================================================================
263 // Helper macros for creating chains
264 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
266 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
268 // creates chain of files in a given directory or file containing a list.
269 // In case of directory the structure is expected as:
270 // <aDataDir>/<dir0>/AliESDs.root
271 // <aDataDir>/<dir1>/AliESDs.root
277 Long_t id, size, flags, modtime;
278 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
280 printf("%s not found.\n", aDataDir);
284 TChain* chain = new TChain("esdTree");
285 TChain* chaingAlice = 0;
289 TString execDir(gSystem->pwd());
290 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
291 TList* dirList = baseDir->GetListOfFiles();
292 Int_t nDirs = dirList->GetEntries();
293 gSystem->cd(execDir);
297 for (Int_t iDir=0; iDir<nDirs; ++iDir)
299 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
300 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
309 if (count++ == aRuns)
312 TString presentDirName(aDataDir);
313 presentDirName += "/";
314 presentDirName += presentDir->GetName();
315 chain->Add(presentDirName + "/AliESDs.root/esdTree");
316 // cerr<<presentDirName<<endl;
322 // Open the input stream
328 // Read the input list of files and add them to the chain
332 if (!esdfile.Contains("root")) continue; // protection
340 if (count++ == aRuns)
352 } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
354 //===============================================================================================
356 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
358 // creates chain of files in a given directory or file containing a list.
359 // In case of directory the structure is expected as:
360 // <aDataDir>/<dir0>/AliAOD.root
361 // <aDataDir>/<dir1>/AliAOD.root
367 Long_t id, size, flags, modtime;
368 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
370 printf("%s not found.\n", aDataDir);
374 TChain* chain = new TChain("aodTree");
375 TChain* chaingAlice = 0;
379 TString execDir(gSystem->pwd());
380 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
381 TList* dirList = baseDir->GetListOfFiles();
382 Int_t nDirs = dirList->GetEntries();
383 gSystem->cd(execDir);
387 for (Int_t iDir=0; iDir<nDirs; ++iDir)
389 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
390 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
399 if (count++ == aRuns)
402 TString presentDirName(aDataDir);
403 presentDirName += "/";
404 presentDirName += presentDir->GetName();
405 chain->Add(presentDirName + "/AliAOD.root/aodTree");
406 // cerr<<presentDirName<<endl;
412 // Open the input stream
418 // Read the input list of files and add them to the chain
422 if (!aodfile.Contains("root")) continue; // protection
430 if (count++ == aRuns)
442 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)