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