d27bf03f8527def6b0bfc52ecbda048acf8f4e52
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / Nuclei / B2 / macros / runLocalExample.C
1 void runLocalExample(const TString& dir="./")
2 {
3 //
4 // example for testing the analysis task
5 //
6         TStopwatch timer;
7         timer.Start();
8         
9         // Global configuration flags
10         
11         const TString kPeriod   = "lhc10d";
12         // with period name the next flags can be worked out
13         const Bool_t kSimulation = 0;
14         const Bool_t kHeavyIons  = 0;
15         
16         // Load common libraries
17         
18         gSystem->Load("libTree");
19         gSystem->Load("libGeom");
20         gSystem->Load("libVMC");
21         gSystem->Load("libPhysics");
22         gSystem->Load("libMinuit");
23         
24         gSystem->Load("libSTEERBase");
25         gSystem->Load("libESD");
26         gSystem->Load("libAOD");
27         
28         // Load analysis framework
29         
30         gSystem->Load("libANALYSIS");
31         gSystem->Load("libANALYSISalice.so"); // alice specific, e.g. alien plugin
32         
33         // Load task
34         
35         gSystem->Load("libPWGLFspectra");
36         
37         // Get input data
38         
39         gROOT->LoadMacro("$ALICE_ROOT/PWGUD/macros/CreateESDChain.C");
40         TChain* chain = CreateESDChain(dir,900);
41         
42         // Create the analysis manager
43         
44         AliAnalysisManager* mgr = new AliAnalysisManager("B2");
45         
46         // Input event handler (input container created automatically)
47         AliESDInputHandler* esdH = new AliESDInputHandler();
48         esdH->SetReadFriends(kFALSE);
49         mgr->SetInputEventHandler(esdH);
50         
51         // MonteCarlo handler
52         if(kSimulation)
53         {
54                 AliMCEventHandler* mcHandler = new AliMCEventHandler();
55                 mcHandler->SetReadTR(kFALSE); // read AliTrackReferences?
56                 mgr->SetMCtruthEventHandler(mcHandler);
57         }
58         
59         // Create and add the task(s)
60         
61         // PhysicsSelection
62         gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
63         
64         AliPhysicsSelectionTask* phySelectionTask = AddTaskPhysicsSelection(kSimulation);
65         
66         // Centrality selection
67         if(kHeavyIons)
68         {
69                 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
70                 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
71         }
72         
73         // B2: Proton, Deuteron, Triton, ...
74         gROOT->LoadMacro("$ALICE_ROOT/PWGLF/SPECTRA/Nuclei/B2/macros/AddTaskB2.C");
75         
76         // see TrackCuts.C macro for track selection criteria names
77         AliAnalysisTaskB2* proton = AddTaskB2("Proton","ProtonTest.root", "its_tpc_dca_spd", AliLnID::kBayes, kPeriod, kSimulation, kHeavyIons, 1);
78         
79         AliAnalysisTaskB2* deuteron = AddTaskB2("Deuteron","DeuteronTest.root", "its_tpc_tof_dca", AliLnID::kTPC, kPeriod, kSimulation, kHeavyIons, 0.2);
80         
81         // Run the analysis
82         
83         if (mgr->InitAnalysis())
84         {
85                 mgr->PrintStatus();
86                 mgr->StartAnalysis("local", chain);
87         }
88         
89         timer.Stop();
90         timer.Print();
91 }