end-of-line normalization
[u/mrichter/AliRoot.git] / PWGCF / EBYE / macros / runBalanceFunctionInpp.C
CommitLineData
a65a7e70 1enum analysisModes {mLocal,mLocalPAR,mPROOF,mGrid,mGridPAR};
2enum analysisTypes {mESD,mAOD,mMC,mMCESD};
3
4//
5class AliAnalysisGrid;
6class AliAnalysisTaskBF;
7class AliBalance;
8
9//________________________________________________________________________//
10void runBalanceFunctionInpp(Int_t mode = mLocal,
11 Int_t type = mAOD,
12 Bool_t DATA = kFALSE) {
13 // Time:
14 TStopwatch timer;
15 timer.Start();
16
17 //Check analysis mode
18 if((mode < 0) || (mode > 4)) {
19 Printf("Analysis mode not recognized!");
20 Printf("You can select out of 0: local, 1: local with par files, 2: proof, 3: grid, 4: grid with par files");
21 return;
22 }
23
24 //Check analysis type
25 if((type < 0) || (type > 3)) {
26 Printf("Analysis type not recognized!");
27 Printf("You can select out of 0: ESD, 1: AOD, 2: MC (stack), 3: MC (from the ESD)");
28 return;
29 }
30
31 // Load needed libraries:
32 LoadLibraries(mode);
33
34 // Create and configure the AliEn plug-in:
35 if(mode == mGrid || mode == mGridPAR) {
36 gROOT->LoadMacro("CreateAlienHandler.C");
37 AliAnalysisGrid *alienHandler = CreateAlienHandler(runListFileName);
38 if (!alienHandler) return;
39 }
40 // Chains:
41 if(mode == mLocal || mode == mLocalPAR) {
42 TChain* chain = 0x0;
43 if((type == mESD)||(type == mMCESD))
44 chain = new TChain("esdTree");
45 else if(type == mAOD)
46 chain = new TChain("aodTree");
47 else if(type == mMC)
48 chain = new TChain("TE");
49
50 TString filename;
51 for(Int_t i = 1; i < 20; i++) {
52 filename = "/data/alice2/pchrist/pp/LHC10c/0.9TeV/Data/";
53 filename += "Set"; filename += i;
54 if((type == mESD)||(type == mMCESD))
55 filename += "/AliESDs.root";
56 else if(type == mAOD)
57 filename += "/AliAOD.root";
58 else if(type == mMC)
59 filename += "/galice.root";
60
61 chain->Add(filename.Data());
62 }
63 }
64 //Proof
65 if(mode == mPROOF) {
66 gROOT->ProcessLine(Form(".include %s/include", gSystem->ExpandPathName("$ALICE_ROOT")));
67 }
68
69 // analysis manager
70 AliAnalysisManager* mgr = new AliAnalysisManager("balanceFunctionManager");
71 if(mode == mGrid || mode == mGridPAR)
72 mgr->SetGridHandler(alienHandler);
73
74 // input handler (ESD or AOD)
75 AliVEventHandler* inputH = NULL;
76 if((type == mESD)||(type == mMCESD))
77 inputH = new AliESDInputHandler();
78 else if(type == mAOD)
79 inputH = new AliAODInputHandler();
80 mgr->SetInputEventHandler(inputH);
81
82 // mc event handler
83 if((type == mMC) || (type == mMCESD)) {
84 AliMCEventHandler* mchandler = new AliMCEventHandler();
85 // Not reading track references
86 mchandler->SetReadTR(kFALSE);
87 mgr->SetMCtruthEventHandler(mchandler);
88 }
89
90 if(type != mAOD){
91 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
92 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
93 }
94
95 //Add the BF task (all centralities)
96 gROOT->LoadMacro("AddTaskBalanceFunctionInpp.C");
97 AddTaskBalanceFunctionInpp();
98
99 // enable debug printouts
100 mgr->SetDebugLevel(2);
101 mgr->SetUseProgressBar(1,100);
102 if (!mgr->InitAnalysis()) return;
103 mgr->PrintStatus();
104
105 // start analysis
106 if(mode == mLocal || mode == mLocalPAR)
107 mgr->StartAnalysis("local",chain);
108 else if(mode == mPROOF)
109 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
110 else if(mode == mGrid || mode == mGridPAR)
111 mgr->StartAnalysis("grid");
112
113 // Print real and CPU time used for analysis:
114 timer.Stop();
115 timer.Print();
116}
117
118//=============================================================//
119void LoadLibraries(const analysisModes mode) {
120 //--------------------------------------
121 // Load the needed libraries most of them already loaded by aliroot
122 //--------------------------------------
123 gSystem->Load("libCore.so");
124 gSystem->Load("libGeom.so");
125 gSystem->Load("libVMC.so");
126 gSystem->Load("libPhysics.so");
127 gSystem->Load("libTree.so");
128
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.so");
138 gSystem->Load("libESD.so");
139 gSystem->Load("libAOD.so");
140 gSystem->Load("libANALYSIS.so");
141 gSystem->Load("libANALYSISalice.so");
142 gSystem->Load("libEventMixing.so");
143 gSystem->Load("libPWGCFebye.so");
144 // Use AliRoot includes to compile our task
145 gROOT->ProcessLine(".include $ALICE_ROOT/include");
146 }
147
148 else if (mode == mLocalPAR) {
149 //--------------------------------------------------------
150 //If you want to use root and par files from aliroot
151 //--------------------------------------------------------
152 SetupPar("STEERBase");
153 SetupPar("ESD");
154 SetupPar("AOD");
155 SetupPar("ANALYSIS");
156 SetupPar("ANALYSISalice");
157 SetupPar("PWGCFebye");
158}
159
160 //---------------------------------------------------------
161 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
162 //---------------------------------------------------------
163 else if (mode==mPROOF) {
164 // Connect to proof
165 printf("*** Connect to PROOF ***\n");
166 gEnv->SetValue("XSec.GSI.DelegProxy","2");
167 // Put appropriate username here
168 TProof::Open("alice-caf.cern.ch");
169 //TProof::Open("skaf.saske.sk");
170 //TProof::Open("prf000-iep-grid.saske.sk");
171
172 gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-12-AN");
173 }
174
175} // end of void LoadLibraries(const anaModes mode)
176
177//======================================================================//
178void SetupPar(char* pararchivename) {
179 //Load par files, create analysis libraries
180 //For testing, if par file already decompressed and modified
181 //classes then do not decompress.
182
183 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
184 TString parpar(Form("%s.par", pararchivename)) ;
185 if ( gSystem->AccessPathName(parpar.Data()) ) {
186 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
187 TString processline(Form(".! make %s", parpar.Data())) ;
188 gROOT->ProcessLine(processline.Data()) ;
189 gSystem->ChangeDirectory(cdir) ;
190 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
191 gROOT->ProcessLine(processline.Data()) ;
192 }
193 if ( gSystem->AccessPathName(pararchivename) ) {
194 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
195 gROOT->ProcessLine(processline.Data());
196 }
197
198 TString ocwd = gSystem->WorkingDirectory();
199 gSystem->ChangeDirectory(pararchivename);
200
201 // check for BUILD.sh and execute
202 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
203 printf("*******************************\n");
204 printf("*** Building PAR archive ***\n");
205 cout<<pararchivename<<endl;
206 printf("*******************************\n");
207 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
208 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
209 return -1;
210 }
211 }
212 // check for SETUP.C and execute
213 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
214 printf("*******************************\n");
215 printf("*** Setup PAR archive ***\n");
216 cout<<pararchivename<<endl;
217 printf("*******************************\n");
218 gROOT->Macro("PROOF-INF/SETUP.C");
219 }
220
221 gSystem->ChangeDirectory(ocwd.Data());
222 printf("Current dir: %s\n", ocwd.Data());
223
224} // end of void SetupPar(char* pararchivename)