Removing the separate misalignments at inner and outer SSD barrel + minor improvememn...
[u/mrichter/AliRoot.git] / PWG4 / macros / AnalysisTrainCAF.C
CommitLineData
672f1183 1//______________________________________________________________________________\r
2void AnalysisTrainCAF(Int_t nEvents = 10000, Int_t nOffset = 0, char *ds = "/PWG4/kleinb/LHC08r_jetjet50")\r
3{\r
4// Example of running analysis train in CAF. To run in debug mode:\r
5// - export ROOTSYS=debug on your local client\r
6// - un-comment gProof->ClearPackages()\r
7// - un-comment lines with debugging info\r
8\r
9// WHY AOD is not a exchange container when running from ESD->AOD\r
10\r
11 Bool_t debug = kTRUE;\r
12 Bool_t useMC = kTRUE;\r
13 Bool_t readTR = kFALSE;\r
14 Bool_t bPROOF = kTRUE;\r
15\r
16\r
17 \r
18 Int_t iAODanalysis = 0;\r
19 Int_t iAODhandler = 1;\r
20 Int_t iESDfilter = 1; // Only active if iAODanalysis=0\r
21 Int_t iJETAN = 1;\r
22 Int_t iJETANESD = 0;\r
23 Int_t iJETANMC = 0;\r
24 Int_t iDIJETAN = 0;\r
25 Int_t iPWG4SPECTRUM = 1;\r
26 Int_t iPWG4UE = 0;\r
27\r
28 if (iAODanalysis) {\r
29 useMC = kFALSE;\r
30 readTR = kFALSE;\r
31 iESDfilter = 0;\r
32 iMUONfilter = 0;\r
33 } \r
34 if (iJETAN) iESDfilter=1;\r
35 if (iESDfilter) iAODhandler=1;\r
36\r
37 // Dataset from CAF\r
38 TString dataset(ds);\r
39 // CKB quick hack for local analysis\r
40 // gROOT->LoadMacro("CreateESDChain.C");\r
41 // TChain *chain = CreateESDChain("jetjet15-50.txt",1000);\r
42 TChain *chain = 0;\r
43\r
44 printf("==================================================================\n");\r
45 printf("=========== RUNNING ANALYSIS TRAIN IN CAF MODE =============\n");\r
46 printf("==================================================================\n");\r
47 if (iAODanalysis) printf("= AOD analysis on dataset: %s\n", dataset.Data());\r
48 else printf("= ESD analysis on dataset: %s\n", dataset.Data());\r
49 if (iESDfilter) printf("= ESD filter =\n");\r
50 if (iJETAN) printf("= Jet analysis from AOD =\n");\r
51 if (iJETANESD) printf("= Jet analysis from ESD =\n");\r
52 if (iJETANMC) printf("= Jet analysis from Kinematics =\n");\r
53 if (iDIJETAN) printf("= DiJet analysis =\n");\r
54 if (iPWG4SPECTRUM)printf("= PWG4 Jet spectrum analysis =\n");\r
55 if (iPWG4UE) printf("= PWG4 UE =\n");\r
56 printf("==================================================================\n");\r
57 if (useMC) printf(":: use MC TRUE\n");\r
58 else printf(":: use MC FALSE\n");\r
59 if (readTR) printf(":: read TR TRUE\n");\r
60 else printf(":: read TR FALSE\n");\r
61 if (debug) printf(":: debugging TRUE\n");\r
62 else printf(":: debugging FALSE\n");\r
63 \r
64 // Load common libraries\r
65 gSystem->Load("libTree.so");\r
66 gSystem->Load("libGeom.so");\r
67 gSystem->Load("libVMC.so");\r
68 gSystem->Load("libPhysics.so");\r
69\r
70\r
71 // Reset user processes if CAF if not responding anymore\r
72 // TProof::Reset("alicecaf"); \r
73 // One may enable a different ROOT version on CAF\r
74\r
75 const char* proofNode = "alicecaf";\r
76\r
77\r
78\r
79\r
80 // Connect to proof\r
81 if(bPROOF){\r
82 TProof::Mgr(proofNode)->ShowROOTVersions();\r
83 // TProof::Mgr(proofNode)->SetROOTVersion("v5-21-01-alice_dbg");\r
84 TProof::Open(proofNode); \r
85\r
86 // Clear packages if changing ROOT version on CAF or local\r
87 // gProof->ClearPackages();\r
88 // Enable proof debugging if needed\r
89 // gProof->SetLogLevel(5);\r
90 // To debug the train in PROOF mode, type in a root session:\r
91 // root[0] TProof::Mgr("lxb6064")->GetSessionLogs()->Display("*",0,10000);\r
92 // Common packages\r
93 // --- Enable the STEERBase Package\r
94 gProof->UploadPackage("${ALICE_ROOT}/STEERBase.par");\r
95 gProof->EnablePackage("STEERBase");\r
96 // --- Enable the ESD Package\r
97 gProof->UploadPackage("${ALICE_ROOT}/ESD.par");\r
98 gProof->EnablePackage("ESD");\r
99 // --- Enable the AOD Package\r
100 gProof->UploadPackage("${ALICE_ROOT}/AOD.par");\r
101 gProof->EnablePackage("AOD");\r
102 // --- Enable the ANALYSIS Package\r
103 gProof->UploadPackage("${ALICE_ROOT}/ANALYSIS.par");\r
104 gProof->EnablePackage("ANALYSIS");\r
105 // --- Enable the ANALYSISalice Package\r
106 gProof->UploadPackage("${ALICE_ROOT}/ANALYSISalice.par");\r
107 gProof->EnablePackage("ANALYSISalice");\r
108\r
109\r
110 // --- Enable the JETAN Package\r
111 if (iJETAN||iJETANESD||iJETANMC) {\r
112 gProof->UploadPackage("${ALICE_ROOT}/JETAN.par");\r
113 gProof->EnablePackage("JETAN");\r
114 } \r
115 // --- Enable particle correlation analysis\r
116 if (iPWG4UE||iPWG4SPECTRUM) {\r
117 gProof->UploadPackage("${ALICE_ROOT}/PWG4JetTasks.par");\r
118 gProof->EnablePackage("PWG4JetTasks");\r
119 } \r
120\r
121 }\r
122 else{\r
123 gSystem->Load("libSTEERBase");\r
124 gSystem->Load("libESD");\r
125 gSystem->Load("libAOD");\r
126 gSystem->Load("libANALYSIS");\r
127 gSystem->Load("libANALYSISalice");\r
128\r
129\r
130 // --- Enable the JETAN Package\r
131 if (iJETAN||iJETANESD||iJETANMC) gSystem->Load("libJETAN");\r
132 // --- Enable particle correlation analysis\r
133 if (iPWG4UE||iPWG4SPECTRUM)gSystem->Load("libPWG4JetTasks"); \r
134 }\r
135\r
136\r
137 // Make the analysis manager\r
138 AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train", "A test setup for the analysis train");\r
139 if (iAODanalysis) {\r
140 // AOD input handler\r
141 AliAODInputHandler *aodH = new AliAODInputHandler();\r
142 mgr->SetInputEventHandler(aodH);\r
143 } else { \r
144 // ESD input handler\r
145 AliESDInputHandler *esdHandler = new AliESDInputHandler();\r
146 mgr->SetInputEventHandler(esdHandler);\r
147// esdHandler->SetInactiveBranches("FMD CaloCluster");\r
148 }\r
149 // Monte Carlo handler\r
150 if (useMC && !iAODanalysis) {\r
151 AliMCEventHandler* mcHandler = new AliMCEventHandler();\r
152 mgr->SetMCtruthEventHandler(mcHandler);\r
153 mcHandler->SetReadTR(readTR); \r
154 } \r
155 // Top container for input \r
156 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();\r
157 \r
158 // This container is managed by the AOD handler\r
159 AliAnalysisDataContainer *cout_aod = 0;\r
160 if (iAODhandler) {\r
161 // AOD output handler\r
162 AliAODHandler* aodHandler = new AliAODHandler();\r
163 aodHandler->SetFillAOD(kFALSE);\r
164 mgr->SetOutputEventHandler(aodHandler); \r
165 aodHandler->SetOutputFileName(Form("AliAODs_pwg4_%07d-%07d.root",nOffset,nOffset+nEvents));\r
166 cout_aod = mgr->GetCommonOutputContainer();\r
167 cout_aod->SetSpecialOutput();\r
168 } \r
169\r
170 // Debugging if needed\r
171 if (debug) mgr->SetDebugLevel(0);\r
172// AliLog::EnableDebug(kTRUE);\r
173 AliLog::SetGlobalLogLevel(0);\r
174\r
175\r
176 if (iESDfilter && !iAODanalysis) {\r
177 // Set of cuts plugged into the ESD filter\r
178 // \r
179 // standard\r
180 AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Loose");\r
181 esdTrackCutsL->SetMinNClustersTPC(50); \r
182 esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);\r
183 esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);\r
184 esdTrackCutsL->SetRequireTPCRefit(kTRUE);\r
185 esdTrackCutsL->SetMinNsigmaToVertex(3);\r
186 esdTrackCutsL->SetRequireSigmaToVertex(kTRUE);\r
187 esdTrackCutsL->SetAcceptKingDaughters(kFALSE);\r
188 //\r
189 AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");\r
190 trackFilter->AddCuts(esdTrackCutsL);\r
191 //\r
192 // ESD filter task putting standard info to output AOD (with cuts)\r
193 AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");\r
194 esdfilter->SetTrackFilter(trackFilter);\r
195 esdfilter->SetDebugLevel(10);\r
196 mgr->AddTask(esdfilter);\r
197 // Connect to data containers\r
198 mgr->ConnectInput (esdfilter, 0, cinput );\r
199 mgr->ConnectOutput (esdfilter, 0, cout_aod );\r
200 } \r
201 // Jet analysis from the AOD\r
202 AliAnalysisDataContainer *c_aodjet = 0;\r
203 if (iJETAN) {\r
204 gROOT->LoadMacro("AddTaskJets.C");\r
205 AliAnalysisTaskJets *jetanaAOD = AddTaskJets("AOD","UA1");\r
206 } \r
207 // JETANALYSIS from the ESD\r
208 if (iJETANESD && !iAODanalysis) {\r
209 gROOT->LoadMacro("AddTaskJets.C");\r
210 AliAnalysisTaskJets *jetanaESD = AddTaskJets("ESD","UA1");\r
211 jetanaESD->SetDebugLevel(10);\r
212 jetanaESD->SetNonStdBranch("jetsESD"); \r
213 } \r
214 // Jet analysisMC\r
215 AliAnalysisDataContainer *c_aodjetMC = 0;\r
216 if (iJETANMC && useMC) {\r
217 gROOT->LoadMacro("AddTaskJets.C");\r
218 AliAnalysisTaskJets *jetanaMC = AddTaskJets("MC","UA1");\r
219 jetanaMC->SetDebugLevel(10);\r
220 jetanaMC->SetNonStdBranch("jetsMC");\r
221 } \r
222 // Dijet analysis\r
223 if(iDIJETAN){\r
224 AliAnalysisTaskDiJets *dijetana = new AliAnalysisTaskDiJets("DiJetAnalysis");\r
225 dijetana->SetDebugLevel(2);\r
226 \r
227 mgr->AddTask(dijetana);\r
228\r
229 //\r
230 // Create containers for input/output\r
231 AliAnalysisDataContainer *c_aod_dijet = mgr->CreateContainer("cAODdijet", TTree::Class(),\r
232 AliAnalysisManager::kExchangeContainer);\r
233 mgr->ConnectInput (dijetana, 0, cinput );\r
234 mgr->ConnectOutput (dijetana, 0, c_aod_dijet);\r
235 }\r
236\r
237\r
238 if (iPWG4SPECTRUM) {\r
239 AliAnalysisTaskJetSpectrum* pwg4spec = new AliAnalysisTaskJetSpectrum("Jet Spectrum");\r
240 \r
241 // default parameters use a switch via iPWGSPECTRUM\r
242 // or a config file\r
243 pwg4spec->SetAnalysisType(AliAnalysisTaskJetSpectrum::kAnaMC);\r
244 // if(iAODanalysis)pwg4spec->SetAODInput(kTRUE);\r
245 pwg4spec->SetDebugLevel(11); \r
246 // pwg4spec->SetBranchRec("jetsMC"); \r
247 // pwg4spec->SetBranchGen("jetsMC"); \r
248 mgr->AddTask(pwg4spec);\r
249\r
250 AliAnalysisDataContainer *coutput1_Spec = mgr->CreateContainer("pwg4spec", TList::Class(),AliAnalysisManager::kOutputContainer,Form( "pwg4spec_%07d-%07d.root",nOffset,nOffset+nEvents));\r
251 // coutput1_Spec->SetSpecialOutput();\r
252 // Dummy AOD output container for jet analysis (no client yet)\r
253 c_aodSpec = mgr->CreateContainer("cAODjetSpec", TTree::Class(),\r
254 AliAnalysisManager::kExchangeContainer);\r
255 mgr->ConnectInput (pwg4spec, 0, cinput); \r
256 // mgr->ConnectInput (pwg4spec, 0, c_aodjet); \r
257 mgr->ConnectOutput (pwg4spec, 0, c_aodSpec );\r
258 mgr->ConnectOutput (pwg4spec, 1, coutput1_Spec );\r
259 } \r
260\r
261 \r
262 // Particle correlation analysis\r
263 if (iPWG4UE) {\r
264 AliAnalysisTaskUE* ueana = new AliAnalysisTaskUE("Underlying Event");\r
265 \r
266\r
267 // default parameters use a switch via iPWGUE\r
268 // or a config file\r
269 Int_t anaType =1; \r
270 Int_t regType =1;\r
271 Double_t jetEtaCut=0.2;\r
272 Double_t trackPtCut=0.5; \r
273 Double_t trackEtaCut= 0.9; \r
274 Double_t rad=0.7; \r
275 Double_t deltaPhiCut = 2.616;\r
276\r
277 ueana->SetDebugLevel(10); \r
278 ueana->SetPtRangeInHist(25, 0., 250.);\r
279 ueana->SetAnaTopology(anaType); \r
280 ueana->SetRegionType(regType); \r
281 ueana->SetJet1EtaCut(jetEtaCut); \r
282 ueana->SetTrackPtCut(trackPtCut); \r
283 ueana->SetPtSumOrdering(2);\r
284 ueana->SetConeRadius(rad); \r
285 ueana->SetTrackEtaCut(trackEtaCut);\r
286 ueana->SetJet2DeltaPhiCut(deltaPhiCut);\r
287 mgr->AddTask(ueana);\r
288\r
289\r
290 AliAnalysisDataContainer *coutput1_UE = mgr->CreateContainer("histosUE", TList::Class(),AliAnalysisManager::kOutputContainer, Form("pwg4UE_%07d-%07d.root",nOffset,nOffset+nEvents));\r
291\r
292 mgr->ConnectInput (ueana, 0, cinput); \r
293 // mgr->ConnectInput (ueana, 0, c_aodjet); \r
294 mgr->ConnectOutput (ueana, 0, coutput1_UE );\r
295 } \r
296\r
297 // Run the analysis\r
298 // \r
299 if (mgr->InitAnalysis()) {\r
300 mgr->PrintStatus();\r
301 if(bPROOF)mgr->StartAnalysis("proof",dataset.Data(), nEvents,nOffset);\r
302 else mgr->StartAnalysis("local",chain);\r
303 } \r
304}\r