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"
13 Int_t binfirst = 0; //where do we start numbering bins
14 Int_t binlast = 8; //where do we stop numbering bins
15 const Int_t numberOfCentralityBins = 9;
16 Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile
19 TString commonOutputFileName = "outputCentrality";
21 //void runTaskFluctuationsCentralityTrain(Int_t mode = mPROOF,
22 //Int_t nRuns = 600000,
23 //Bool_t DATA = kTRUE,
24 //const Char_t* dataDir="/alice/data/LHC10h_000137161_p1_4plus#esdTree", Int_t offset=0) {
25 //void runTaskFluctuationsCentralityTrain(Int_t mode = mLocal,
26 // Bool_t DATA = kTRUE) {
27 void runTaskFluctuationsCentralityTrain(const char* runListFileName = "group4.txt",
29 Bool_t DATA = kTRUE) {
34 // Load needed libraries:
37 // Create and configure the AliEn plug-in:
38 if(mode == mGrid || mode == mGridPAR) {
39 gROOT->LoadMacro("CreateAlienHandler.C");
40 AliAnalysisGrid *alienHandler = CreateAlienHandler(runListFileName);
41 if (!alienHandler) return;
42 gROOT->LoadMacro("AliEbyEFluctuationAnalysisTaskTrain.cxx++");
45 if(mode==mLocal || mode == mLocalPAR) {
46 gROOT->LoadMacro("AliEbyEFluctuationAnalysisTaskTrain.cxx++");
47 if (analysisType=="ESD") {
48 TChain* chain = new TChain("esdTree");
49 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set1/AliESDs.root");
50 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set2/AliESDs.root");
51 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set3/AliESDs.root");
52 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set4/AliESDs.root");
53 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set5/AliESDs.root");
54 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set6/AliESDs.root");
55 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set7/AliESDs.root");
56 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set8/AliESDs.root");
57 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set9/AliESDs.root");
58 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/pass1_4plus/Set10/AliESDs.root");
60 else if(analysisType == "MC") {
61 TChain *chain = new TChain("TE");
62 chain->AddFile("galice.root");
65 TChain* chain = CreateAODChain(dataDir, nRuns, offset);
69 gROOT->ProcessLine(Form(".include %s/include", gSystem->ExpandPathName("$ALICE_ROOT")));
70 gProof->Load("AliEbyEFluctuationAnalysisTaskTrain.cxx++");
73 // Create analysis manager:
74 AliAnalysisManager *mgr = new AliAnalysisManager("FluctuationsAnalysisManager");
75 // Connect plug-in to the analysis manager:
76 if(mode == mGrid || mode == mGridPAR) {
77 mgr->SetGridHandler(alienHandler);
80 if(analysisType == "ESD") {
81 AliVEventHandler* esdH = new AliESDInputHandler;
82 mgr->SetInputEventHandler(esdH);
83 } // end of if(analysisType == "ESD")
84 if(analysisType == "AOD") {
85 AliVEventHandler* aodH = new AliAODInputHandler;
86 mgr->SetInputEventHandler(aodH);
87 } // end of if(analysisType == "AOD")
88 if(analysisType == "MC") {
89 AliVEventHandler* esdH = new AliESDInputHandler;
90 mgr->SetInputEventHandler(esdH);
91 AliMCEventHandler *mc = new AliMCEventHandler();
92 mc->SetReadTR(kFALSE);
93 mgr->SetMCtruthEventHandler(mc);
94 } // end of if(analysisType == "MC")
96 // Task to check the offline trigger:
97 //if(mode == mLocal || mode == mGrid || mode == mGridPAR)
98 if(analysisType != "MC") {
99 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
100 AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection(!DATA);
101 if(!DATA){physicsSelTask->GetPhysicsSelection()->SetAnalyzeMC();}
102 // Enable debug printouts:
103 mgr->SetDebugLevel(2);
105 //Add the centrality determination task
106 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
108 //AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
109 //taskCentrality->SelectCollisionCandidates(AliVEvent::kMB);
112 // Load the analysis task:
113 gROOT->LoadMacro("AddTaskFluctuationsCentralityTrain.C");
114 for (Int_t i=binfirst; i<binlast+1; i++) {
115 Float_t lowCentralityBinEdge = centralityArray[i];
116 Float_t highCentralityBinEdge = centralityArray[i+1];
117 Printf("\nWagon for centrality bin %i: %.0f-%.0f",i,lowCentralityBinEdge,highCentralityBinEdge);
118 AddTaskFluctuationsCentralityTrain(analysisType.Data(),
120 lowCentralityBinEdge,
121 highCentralityBinEdge,
122 commonOutputFileName);
123 } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
124 // AliEbyEFluctuationAnalysisTaskTrain* taskFA = AddTaskFluctuations(analysisType.Data(),
125 //analysisMode.Data());
128 if(!mgr->InitAnalysis()){return;}
130 if(mode == mLocal || mode == mLocalPAR)
131 mgr->StartAnalysis("local",chain);
132 else if(mode == mPROOF)
133 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
134 else if(mode == mGrid || mode == mGridPAR)
135 mgr->StartAnalysis("grid");
137 // Print real and CPU time used for analysis:
141 } // end of void runTaskFluctuations(...)
143 //=============================================================//
144 void LoadLibraries(const anaModes mode) {
145 //--------------------------------------
146 // Load the needed libraries most of them already loaded by aliroot
147 //--------------------------------------
148 gSystem->Load("libTree");
149 gSystem->Load("libGeom");
150 gSystem->Load("libVMC");
151 gSystem->Load("libXMLIO");
152 gSystem->Load("libPhysics");
154 //----------------------------------------------------------
155 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
156 //----------------------------------------------------------
157 if (mode==mLocal || mode==mGrid || mode == mGridPAR) {
158 //--------------------------------------------------------
159 // If you want to use already compiled libraries
160 // in the aliroot distribution
161 //--------------------------------------------------------
162 gSystem->Load("libSTEERBase");
163 gSystem->Load("libESD");
164 gSystem->Load("libAOD");
165 gSystem->Load("libANALYSIS");
166 gSystem->Load("libANALYSISalice");
167 // Use AliRoot includes to compile our task
168 gROOT->ProcessLine(".include $ALICE_ROOT/include");
169 if(mode==mLocal || mode==mGrid){
170 gSystem->Load("libEventMixing");
171 gSystem->Load("libPWGCFebye");
174 SetupPar("EventMixing");
175 SetupPar("PWGCFebye");
179 else if (mode == mLocalPAR) {
180 //--------------------------------------------------------
181 //If you want to use root and par files from aliroot
182 //--------------------------------------------------------
183 SetupPar("STEERBase");
186 SetupPar("ANALYSIS");
187 SetupPar("ANALYSISalice");
188 SetupPar("PWGCFebye");
191 //---------------------------------------------------------
192 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
193 //---------------------------------------------------------
194 else if (mode==mPROOF) {
196 printf("*** Connect to PROOF ***\n");
197 gEnv->SetValue("XSec.GSI.DelegProxy","2");
198 // Put appropriate username here
199 TProof::Open("alice-caf.cern.ch");
200 //TProof::Open("skaf.saske.sk");
201 //TProof::Open("prf000-iep-grid.saske.sk");
203 gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-12-AN");
205 // Clear the Packages
206 //gProof->ClearPackage("STEERBase.par");
207 //gProof->ClearPackage("ESD.par");
208 //gProof->ClearPackage("AOD.par");
209 //gProof->ClearPackage("ANALYSIS.par");
210 //gProof->ClearPackage("ANALYSISalice.par");
211 //gProof->ClearPackage("PWGCFebye");
213 // Upload the Packages
214 //gProof->UploadPackage("STEERBase.par");
215 //gProof->UploadPackage("ESD.par");
216 //gProof->UploadPackage("AOD.par");
217 //gProof->UploadPackage("ANALYSIS.par");
218 //gProof->UploadPackage("ANALYSISalice.par");
219 //gProof->UploadPackage("CORRFW.par");
220 //gProof->UploadPackage("PWGCFebye");
222 // Enable the Packages
223 //gProof->EnablePackage("STEERBase");
224 //gProof->EnablePackage("ESD");
225 //gProof->EnablePackage("AOD");
226 //gProof->EnablePackage("ANALYSIS");
227 //gProof->EnablePackage("ANALYSISalice");
228 //gProof->EnablePackage("PWGCFebye");
230 // Show enables Packages
231 //gProof->ShowEnabledPackages();
234 } // end of void LoadLibraries(const anaModes mode)
236 //===============================================================================================
238 void SetupPar(char* pararchivename) {
239 //Load par files, create analysis libraries
240 //For testing, if par file already decompressed and modified
241 //classes then do not decompress.
243 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
244 TString parpar(Form("%s.par", pararchivename)) ;
245 if ( gSystem->AccessPathName(parpar.Data()) ) {
246 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
247 TString processline(Form(".! make %s", parpar.Data())) ;
248 gROOT->ProcessLine(processline.Data()) ;
249 gSystem->ChangeDirectory(cdir) ;
250 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
251 gROOT->ProcessLine(processline.Data()) ;
253 if ( gSystem->AccessPathName(pararchivename) ) {
254 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
255 gROOT->ProcessLine(processline.Data());
258 TString ocwd = gSystem->WorkingDirectory();
259 gSystem->ChangeDirectory(pararchivename);
261 // check for BUILD.sh and execute
262 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
263 printf("*******************************\n");
264 printf("*** Building PAR archive ***\n");
265 cout<<pararchivename<<endl;
266 printf("*******************************\n");
267 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
268 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
272 // check for SETUP.C and execute
273 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
274 printf("*******************************\n");
275 printf("*** Setup PAR archive ***\n");
276 cout<<pararchivename<<endl;
277 printf("*******************************\n");
278 gROOT->Macro("PROOF-INF/SETUP.C");
281 gSystem->ChangeDirectory(ocwd.Data());
282 printf("Current dir: %s\n", ocwd.Data());
284 } // end of void SetupPar(char* pararchivename)
286 //===============================================================================================
288 // Helper macros for creating chains
289 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
291 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
293 // creates chain of files in a given directory or file containing a list.
294 // In case of directory the structure is expected as:
295 // <aDataDir>/<dir0>/AliESDs.root
296 // <aDataDir>/<dir1>/AliESDs.root
302 Long_t id, size, flags, modtime;
303 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
305 printf("%s not found.\n", aDataDir);
309 TChain* chain = new TChain("esdTree");
310 TChain* chaingAlice = 0;
314 TString execDir(gSystem->pwd());
315 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
316 TList* dirList = baseDir->GetListOfFiles();
317 Int_t nDirs = dirList->GetEntries();
318 gSystem->cd(execDir);
322 for (Int_t iDir=0; iDir<nDirs; ++iDir)
324 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
325 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
334 if (count++ == aRuns)
337 TString presentDirName(aDataDir);
338 presentDirName += "/";
339 presentDirName += presentDir->GetName();
340 chain->Add(presentDirName + "/AliESDs.root/esdTree");
341 // cerr<<presentDirName<<endl;
347 // Open the input stream
353 // Read the input list of files and add them to the chain
357 if (!esdfile.Contains("root")) continue; // protection
365 if (count++ == aRuns)
377 } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
379 //===============================================================================================
381 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
383 // creates chain of files in a given directory or file containing a list.
384 // In case of directory the structure is expected as:
385 // <aDataDir>/<dir0>/AliAOD.root
386 // <aDataDir>/<dir1>/AliAOD.root
392 Long_t id, size, flags, modtime;
393 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
395 printf("%s not found.\n", aDataDir);
399 TChain* chain = new TChain("aodTree");
400 TChain* chaingAlice = 0;
404 TString execDir(gSystem->pwd());
405 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
406 TList* dirList = baseDir->GetListOfFiles();
407 Int_t nDirs = dirList->GetEntries();
408 gSystem->cd(execDir);
412 for (Int_t iDir=0; iDir<nDirs; ++iDir)
414 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
415 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
424 if (count++ == aRuns)
427 TString presentDirName(aDataDir);
428 presentDirName += "/";
429 presentDirName += presentDir->GetName();
430 chain->Add(presentDirName + "/AliAOD.root/aodTree");
431 // cerr<<presentDirName<<endl;
437 // Open the input stream
443 // Read the input list of files and add them to the chain
447 if (!aodfile.Contains("root")) continue; // protection
455 if (count++ == aRuns)
467 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)