some more updates
[u/mrichter/AliRoot.git] / PWGPP / macros / AddTaskPerformanceTPCPtCalib.C
1 ///////////////////////////////////////////////////////////////////////////////
2 // Macro to setup AliPerformanceTask for 
3 // TPC performance QA to run on PWGPP QA train. 
4 //
5 // By default 1 performance component is added to 
6 // the task: 
7 // 1. AliPerformancePtCalib
8 // or AliPerformancePtCalibMC if bUseMCinfo = kTRUE (use MC info)
9
10 // Usage on the analysis train (default configuration):
11 // gSystem->Load("libANALYSIS");
12 // gSystem->Load("libANALYSISalice");
13 // gSystem->Load("libTPCcalib.so");
14 // gSystem->Load("libPWGPP.so");
15 //
16 // gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTaskPerformanceTPCPtCalib.C");
17 // AliPerformanceTask *tpcQA = AddTaskPerformanceTPCPtCalib("kTRUE","kTRUE","CINT1B-ABCE-NOPF-ALL"); 
18 // 
19 // Output:
20 // TPCPtCalib.Performance.root file with TPC performance components is created.
21 //
22 // Each of the components contains THnSparse generic histograms which 
23 // have to be analysed (post-analysis) by using Analyse() function. 
24 // Each component contains such function.
25 //
26 // June 2010 -  Simone Schuchmann sschuchm@ikf.uni-frankfurt.de
27 ///////////////////////////////////////////////////////////////////////////////
28
29 //____________________________________________
30 AliPerformanceTask* AddTaskPerformanceTPCPtCalib(Bool_t bUseMCInfo=kFALSE, Bool_t bUseESDfriend=kFALSE, const char *triggerClass=0)
31 {
32
33 //
34   // Create physics trigger selection class
35   //
36     AliPhysicsSelection *physTrigSel =  new AliPhysicsSelection();
37   
38   //
39   // Add AliPerformanceTask with TPC performance components
40   //
41   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
42   if(!mgr) { 
43      Error("AddTaskPerformanceTPCPtCalib","AliAnalysisManager not set!");
44     return NULL;
45   }
46   
47   TString type = mgr->GetInputEventHandler()->GetDataType();
48   if (!type.Contains("ESD")) {
49      Error("AddTaskPerformanceTPCPtCalib", "ESD input handler needed!");
50     return NULL;
51   }
52   
53   AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
54   if (!mcH && bUseMCInfo) {
55     Error("AddTaskPerformanceTPCPtCalib", "MC input handler needed!");
56     return NULL;
57   }
58
59   //
60   // Create task
61   //
62   AliPerformanceTask *task = new AliPerformanceTask("TPCPerformanceInvPt","TPC Performance PtCalib");
63   if (!task) {
64     Error("AddTaskPerformanceTPCPtCalib", "TPC performance task cannot be created!");
65     return NULL;
66   }
67   task->SetUseMCInfo(bUseMCInfo);
68   task->SetUseESDfriend(kFALSE);
69   task->SelectCollisionCandidates();
70
71   //
72   // Add physics selection task to analysis manager
73   //
74   //    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
75   //    AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
76   //    mgr->AddTask(physSelTask);
77
78   mgr->AddTask(task);
79
80   //
81   // Create TPC-ESD track reconstruction cuts
82   //
83   AliRecInfoCuts *pRecInfoCuts = new AliRecInfoCuts(); 
84   if(pRecInfoCuts) {
85     pRecInfoCuts->SetMaxDCAToVertexXY(3.0);
86     pRecInfoCuts->SetMaxDCAToVertexZ(3.0);
87     pRecInfoCuts->SetMinNClustersTPC(50);
88     pRecInfoCuts->SetMinNClustersITS(2);
89     pRecInfoCuts->SetHistogramsOn(kFALSE); 
90   } 
91   else {
92     Error("AddTaskPerformanceTPCPtCalib", "AliRecInfoCuts cannot be created!");
93     return NULL;
94   }
95   //
96   // Create TPC-MC track reconstruction cuts
97   //
98   AliMCInfoCuts  *pMCInfoCuts = new AliMCInfoCuts();
99   if(pMCInfoCuts) {
100     pMCInfoCuts->SetMinTrackLength(70);
101   } 
102   else {
103     Error("AddTaskPerformanceTPCPtCalib", "AliMCInfoCuts cannot be created!");
104     return NULL;
105   }
106
107   //
108   // Create performance objects for TPC and set cuts 
109   //
110   enum { kTPC = 0, kTPCITS, kConstrained, kTPCInner, kTPCOuter, kTPCSec };
111
112
113
114   AliPerformancePtCalib *ptCalib =  NULL;
115   AliPerformancePtCalibMC *ptCalibMC = NULL;
116
117   if(bUseMCInfo){
118      ptCalibMC = new AliPerformancePtCalibMC("AliPerformancePtCalibMC","AliPerformancePtCalibMC");
119      if(!ptCalibMC) {
120         Error("AddTaskPerformanceTPCPtCalib", "Cannot create AliPerformancePtCalibMC");
121      }
122      // physTrigSel->SetAnalyzeMC();
123      // ptCalibMC->SetPhysicsTriggerSelection(physTrigSel); 
124      ptCalibMC->SetAliRecInfoCuts(pRecInfoCuts);
125      ptCalibMC->SetReadTPCTracks(kTRUE);  
126      AliESDtrackCuts* esdtrackCuts = new AliESDtrackCuts("AliESDtrackCutsPtMC");
127      esdtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(kTRUE);
128      ptCalibMC->SetAliESDtrackCuts(esdtrackCuts);
129      //ptCalibMC->SetEtaRange(0.9);
130   }
131   else{
132
133      ptCalib =  new AliPerformancePtCalib("AliPerformancePtCalib","AliPerformancePtCalib");
134      if(!ptCalib) {
135         Error("AddTaskPerformanceTPCPtCalib", "Cannot create AliPerformancePtCalib");
136      }
137      ptCalib->SetAliRecInfoCuts(pRecInfoCuts);
138      ptCalib->SetReadTPCTracks(kTRUE);  
139      ptCalib->SetEtaRange(0.8);
140      // ptCalib->SetAliMCInfoCuts(pMCInfoCut);
141
142      //if(triggerClass) ptCalib->SetTriggerClass(triggerClass);
143      //ptCalib->SetPhysicsTriggerSelection(physTrigSel);
144      //ptCalib->SetTrigger(AliTriggerAnalysis::kMB1);
145      AliESDtrackCuts* esdtrackCuts = new AliESDtrackCuts("AliESDtrackCutsPt");
146      esdtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(kTRUE);
147      ptCalib->SetAliESDtrackCuts(esdtrackCuts);
148       
149   }
150   
151   // add components to the performance task
152   
153   if(bUseMCInfo) task->AddPerformanceObject(ptCalibMC);
154   else task->AddPerformanceObject(ptCalib);
155   
156   // Create containers for input
157   //
158   mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
159   
160   //
161   // Create containers for output
162   //
163   AliAnalysisDataContainer *coutput_tpcptcalib = mgr->CreateContainer("TPCPtCalib", TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s.Performance.root", task->GetName()));
164   mgr->ConnectOutput(task, 1, coutput_tpcptcalib);
165
166 return task;  
167 }