1 enum libModes {mLocal,mLocalSource};
3 void mergeOutput(TString type="", Int_t nRuns=-1, Int_t mode=mLocal)
5 // type: type of analysis can be ESD, AOD, MC, ESDMC0, ESDMC1
6 // (if type="" output files are from MC simulation (default))
7 // nRuns: specify here how many output .root files will be merged
8 // (if nRuns = -1 all of them will be merged)
9 // mode: if mode=mLocal analyze data on your computer using aliroot
10 // if mode=mLocalSource analyze data on your computer using root + source files
12 // load needed libraries:
13 LoadSpreadLibrariesMO(mode);
15 // access the path of current directory:
16 TString pwd(gSystem->pwd());
19 // file mergers for the output file of each method separately:
21 TFileMerger *mcepFileMerger = new TFileMerger();
22 TString mergedFileNameMCEP("mergedMCEPanalysis");
23 (mergedFileNameMCEP+=(type.Data()))+=(".root");
24 TString pwdMCEP=pwd.Data();
25 if(!(gSystem->AccessPathName((pwdMCEP+=mergedFileNameMCEP).Data(),kFileExists)))
27 cout<<"WARNING: You already have a merged output for MCEP !!!!"<<endl;
30 mcepFileMerger->OutputFile(mergedFileNameMCEP);
33 TFileMerger *spFileMerger = new TFileMerger();
34 TString mergedFileNameSP("mergedSPanalysis");
35 (mergedFileNameSP+=(type.Data()))+=(".root");
36 TString pwdSP=pwd.Data();
37 if(!(gSystem->AccessPathName((pwdSP+=mergedFileNameSP).Data(),kFileExists)))
39 cout<<"WARNING: You already have a merged output for SP !!!!"<<endl;
42 spFileMerger->OutputFile(mergedFileNameSP);
45 TFileMerger *gfcFileMerger = new TFileMerger();
46 TString mergedFileNameGFC("mergedGFCanalysis");
47 (mergedFileNameGFC+=(type.Data()))+=(".root");
48 TString pwdGFC=pwd.Data();
49 if(!(gSystem->AccessPathName((pwdGFC+=mergedFileNameGFC).Data(),kFileExists)))
51 cout<<"WARNING: You already have a merged output for GFC !!!!"<<endl;
54 gfcFileMerger->OutputFile(mergedFileNameGFC);
57 TFileMerger *qcFileMerger = new TFileMerger();
58 TString mergedFileNameQC("mergedQCanalysis");
59 (mergedFileNameQC+=(type.Data()))+=(".root");
60 TString pwdQC=pwd.Data();
61 if(!(gSystem->AccessPathName((pwdQC+=mergedFileNameQC).Data(),kFileExists)))
63 cout<<"WARNING: You already have a merged output for QC !!!!"<<endl;
66 qcFileMerger->OutputFile(mergedFileNameQC);
69 TFileMerger *fqdFileMerger = new TFileMerger();
70 TString mergedFileNameFQD("mergedFQDanalysis");
71 (mergedFileNameFQD+=(type.Data()))+=(".root");
72 TString pwdFQD=pwd.Data();
73 if(!(gSystem->AccessPathName((pwdFQD+=mergedFileNameFQD).Data(),kFileExists)))
75 cout<<"WARNING: You already have a merged output for FQD !!!!"<<endl;
78 fqdFileMerger->OutputFile(mergedFileNameFQD);
81 TFileMerger *lyz1FileMerger = new TFileMerger();
82 TString mergedFileNameLYZ1("mergedLYZ1analysis");
83 (mergedFileNameLYZ1+=(type.Data()))+=(".root");
84 TString pwdLYZ1=pwd.Data();
85 if(!(gSystem->AccessPathName((pwdLYZ1+=mergedFileNameLYZ1).Data(),kFileExists)))
87 cout<<"WARNING: You already have a merged output for LYZ1 !!!!"<<endl;
90 lyz1FileMerger->OutputFile(mergedFileNameLYZ1);
93 TFileMerger *lyz2FileMerger = new TFileMerger();
94 TString mergedFileNameLYZ2("mergedLYZ2analysis");
95 (mergedFileNameLYZ2+=(type.Data()))+=(".root");
96 TString pwdLYZ2=pwd.Data();
97 if(!(gSystem->AccessPathName((pwdLYZ2+=mergedFileNameLYZ2).Data(),kFileExists)))
99 cout<<"WARNING: You already have a merged output for LYZ2 !!!!"<<endl;
102 lyz2FileMerger->OutputFile(mergedFileNameLYZ2);
105 TFileMerger *lyzepFileMerger = new TFileMerger();
106 TString mergedFileNameLYZEP("mergedLYZEPanalysis");
107 (mergedFileNameLYZEP+=(type.Data()))+=(".root");
108 TString pwdLYZEP=pwd.Data();
109 if(!(gSystem->AccessPathName((pwdLYZEP+=mergedFileNameLYZEP).Data(),kFileExists)))
111 cout<<"WARNING: You already have a merged output for LYZEP !!!!"<<endl;
114 lyzepFileMerger->OutputFile(mergedFileNameLYZEP);
117 TString execDir(gSystem->pwd());
118 TSystemDirectory* baseDir = new TSystemDirectory(".",execDir.Data());
119 TList* dirList = baseDir->GetListOfFiles();
120 Int_t nDirs = dirList->GetEntries();
121 gSystem->cd(execDir);
125 for(Int_t iDir=0;iDir<nDirs;++iDir)
127 TSystemFile* presentDir = (TSystemFile*)dirList->At(iDir);
128 if(!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 ||
129 strcmp(presentDir->GetName(), "..") == 0) continue;
133 if (counter >= nRuns) break;
136 TString presentDirName(gSystem->pwd());
137 presentDirName += "/";
138 presentDirName += presentDir->GetName();
139 presentDirName += "/";
141 // accessing the output .root files from independent analysis for each method:
143 TString fileNameMCEP = presentDirName;
144 ((fileNameMCEP+="outputMCEPanalysis")+=type.Data())+=".root";
145 if(!(gSystem->AccessPathName(fileNameMCEP.Data(),kFileExists)))
147 mcepFileMerger->AddFile(fileNameMCEP.Data());
150 cout<<"WARNING: Couldn't find a file "<<fileNameMCEP.Data()<<". Merging will continue without this file."<<endl;
154 TString fileNameSP = presentDirName;
155 ((fileNameSP+="outputSPanalysis")+=type.Data())+=".root";
156 if(!(gSystem->AccessPathName(fileNameSP.Data(),kFileExists)))
158 spFileMerger->AddFile(fileNameSP.Data());
161 cout<<"WARNING: Couldn't find a file "<<fileNameSP.Data()<<". Merging will continue without this file."<<endl;
165 TString fileNameGFC = presentDirName;
166 ((fileNameGFC+="outputGFCanalysis")+=type.Data())+=".root";
167 if(!(gSystem->AccessPathName(fileNameGFC.Data(),kFileExists)))
169 gfcFileMerger->AddFile(fileNameGFC.Data());
172 cout<<"WARNING: Couldn't find a file "<<fileNameGFC.Data()<<". Merging will continue without this file."<<endl;
176 TString fileNameQC = presentDirName;
177 ((fileNameQC+="outputQCanalysis")+=type.Data())+=".root";
178 if(!(gSystem->AccessPathName(fileNameQC.Data(),kFileExists)))
180 qcFileMerger->AddFile(fileNameQC.Data());
183 cout<<"WARNING: Couldn't find a file "<<fileNameQC.Data()<<". Merging will continue without this file."<<endl;
187 TString fileNameFQD = presentDirName;
188 ((fileNameFQD+="outputFQDanalysis")+=type.Data())+=".root";
189 if(!(gSystem->AccessPathName(fileNameFQD.Data(),kFileExists)))
191 fqdFileMerger->AddFile(fileNameFQD.Data());
194 cout<<"WARNING: Couldn't find a file "<<fileNameFQD.Data()<<". Merging will continue without this file."<<endl;
198 TString fileNameLYZ1 = presentDirName;
199 ((fileNameLYZ1+="outputLYZ1analysis")+=type.Data())+=".root";
200 if(!(gSystem->AccessPathName(fileNameLYZ1.Data(),kFileExists)))
202 lyz1FileMerger->AddFile(fileNameLYZ1.Data());
205 cout<<"WARNING: Couldn't find a file "<<fileNameLYZ1.Data()<<". Merging will continue without this file."<<endl;
209 TString fileNameLYZ2 = presentDirName;
210 ((fileNameLYZ2+="outputLYZ2analysis")+=type.Data())+=".root";
211 if(!(gSystem->AccessPathName(fileNameLYZ2.Data(),kFileExists)))
213 lyz2FileMerger->AddFile(fileNameLYZ2.Data());
216 cout<<"WARNING: Couldn't find a file "<<fileNameLYZ2.Data()<<". Merging will continue without this file."<<endl;
220 TString fileNameLYZEP = presentDirName;
221 ((fileNameLYZEP+="outputLYZEPanalysis")+=type.Data())+=".root";
222 if(!(gSystem->AccessPathName(fileNameLYZEP.Data(),kFileExists)))
224 lyzepFileMerger->AddFile(fileNameLYZEP.Data());
227 cout<<"WARNING: Couldn't find a file "<<fileNameLYZEP.Data()<<". Merging will continue without this file."<<endl;
232 } // end of for(Int_t iDir=0;iDir<nDirs;++iDir)
238 cout<<" ---- Starting to merge MCEP files ----"<<endl;
239 mcepFileMerger->Merge();
244 cout<<" ---- Starting to merge SP files ----"<<endl;
245 spFileMerger->Merge();
250 cout<<" ---- Starting to merge GFC files ----"<<endl;
251 gfcFileMerger->Merge();
256 cout<<" ---- Starting to merge QC files ----"<<endl;
257 qcFileMerger->Merge();
262 cout<<" ---- Starting to merge FQD files ----"<<endl;
263 fqdFileMerger->Merge();
268 cout<<" ---- Starting to merge LYZ1 files ----"<<endl;
269 lyz1FileMerger->Merge();
274 cout<<" ---- Starting to merge LYZ2 files ----"<<endl;
275 lyz2FileMerger->Merge();
280 cout<<" ---- Starting to merge LYZEP files ----"<<endl;
281 lyzepFileMerger->Merge();
284 } // end of void mergeOutput(TString type="", const Int_t nRuns=-1, Int_t mode=mLocal)
286 void LoadSpreadLibrariesMO(const libModes mode) {
288 //--------------------------------------
289 // Load the needed libraries most of them already loaded by aliroot
290 //--------------------------------------
291 gSystem->Load("libTree.so");
292 gSystem->Load("libGeom.so");
293 gSystem->Load("libVMC.so");
294 gSystem->Load("libXMLIO.so");
295 gSystem->Load("libPhysics.so");
297 //----------------------------------------------------------
298 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
299 //----------------------------------------------------------
301 //--------------------------------------------------------
302 // If you want to use already compiled libraries
303 // in the aliroot distribution
304 //--------------------------------------------------------
306 //==================================================================================
307 //load needed libraries:
308 gSystem->AddIncludePath("-I$ROOTSYS/include");
309 gSystem->Load("libTree.so");
312 gSystem->AddIncludePath("-I$ALICE_ROOT/include");
313 gSystem->Load("libANALYSIS.so");
314 gSystem->Load("libPWG2flowCommon.so");
315 cerr<<"libPWG2flowCommon.so loaded ..."<<endl;
319 else if (mode==mLocalSource) {
321 // In root inline compile
324 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+");
325 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+");
326 gROOT->LoadMacro("AliFlowCommon/AliFlowCumuConstants.cxx+");
329 gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+");
330 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+");
331 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+");
334 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+");
336 // Output histosgrams
337 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+");
338 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+");
339 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+");
340 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+");
342 cout << "finished loading macros!" << endl;
344 } // end of else if (mode==mLocalSource)
346 } // end of void LoadSpreadLibrariesMO(const libModes mode)