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