]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/QA/tasks/macros/AddTaskPerformance.C
5f03d59e356cc2738c6a32458709991cc558c18d
[u/mrichter/AliRoot.git] / HLT / QA / tasks / macros / AddTaskPerformance.C
1 ///////////////////////////////////////////////////////////////////////////////
2 // Macro to setup AliPerformanceTask for either 
3 // HLT or offline TPC performance QA to run on PWG1 QA train. 
4 //
5 // Input: ESDs, ESDfriends (optional), Kinematics (optional), TrackRefs (optional)
6 // ESD and MC input handlers must be attached to AliAnalysisManager
7 // to run default configuration. 
8 //
9 // By default 7 performance components are added to 
10 // the task: 
11 // 1. AliPerformanceRes (TPC track resolution w.r.t MC at DCA)
12 // 2. AliPerformanceResTPCInner (TPC track resolution w.r.t MC at inner TPC wall)
13 // 3. AliPerformanceResTPCOuter (TPC track resolution w.r.t MC at outer TPC wall)
14 // 4. AliPerformanceEff (TPC track reconstruction efficiency, MC primaries)
15 // 5. AliPerformanceDEdxTPCInner (TPC dEdx response - track parameters at TPC inner wall)
16 // 6. AliPerformanceDCA (TPC impact parameters resolution at DCA)
17 // 7. AliPerformanceTPC (TPC cluster and track and event information)
18 // 8. AliPerformanceMatch (TPC and ITS/TRD matching and TPC eff w.r.t ITS)
19 //
20 // Usage on the analysis train (default configuration):
21 // gSystem->Load("libANALYSIS");
22 // gSystem->Load("libANALYSISalice");
23 // gSystem->Load("libTPCcalib.so");
24 // gSystem->Load("libTENDER.so");
25 // gSystem->Load("libPWG1.so");
26 //
27 // gROOT->LoadMacro("$ALICE_ROOT/HLT/QA/tasks/macros/AddTaskPerformanceTPC.C");
28 // AliPerformanceTask *tpcQA = AddTaskPerformanceTPC("kTRUE","kTRUE", "kTRUE"ΒΈ"triggerClass"); 
29 // 
30 // Output:
31 // HLTTPC.Performance.root file with HLT TPC performance components 
32 // or 
33 // TPC.Performance.root file with TPC performance components 
34 //
35 // Each of the components contains THnSparse generic histograms which 
36 // have to be analysed (post-analysis) by using Analyse() function. 
37 // Each component contains such function.
38 //
39 //01-09.10 -  J.Otwinowski@gsi.de, jochen@thaeder.de, hege.erdal@ift.uib.no
40 ///////////////////////////////////////////////////////////////////////////////
41
42 //__________________________________________________________________________________________________
43 AliPerformanceTask* AddTaskPerformance(Bool_t bUseMCInfo=kTRUE,
44                                        Bool_t bUseESDfriend=kTRUE,
45                                        Bool_t bUseHLT = kFALSE,
46                                        const char *triggerClass=0) {
47   //                                    const char *triggerClass="CINT1B-ABCE-NOPF-ALL") {
48   //
49   // Add AliPerformanceTask with HLT/TPC performance components
50   //
51   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
52   if(!mgr) { 
53     Error("AddTaskPerformance","AliAnalysisManager not set!");
54     return NULL;
55   }
56   
57   TString type = mgr->GetInputEventHandler()->GetDataType();
58   if (!type.Contains("ESD")) {
59     Error("AddTaskPerformance", "ESD input handler needed!");
60     return NULL;
61   }
62   
63   AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
64   if (!mcH && bUseMCInfo) {
65     Error("AddTaskPerformance", "MC input handler needed!");
66     return NULL;
67   }
68
69   //============= Add HLT ESD ================================================================
70   if(bUseHLT){
71     AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
72     esdH->SetReadHLT();
73   }
74   //==========================================================================================
75
76   //
77   // Create task -----------------------------------------------------------------------------------
78   //
79   if(bUseHLT)
80     AliPerformanceTask *task = new AliPerformanceTask("Performance","HLT TPC Performance");
81   else
82     AliPerformanceTask *task = new AliPerformanceTask("Performance","TPC Performance");
83
84   if (!task) {
85     Error("AddTaskPerformance", "Performance task cannot be created!");
86     return NULL;
87   }
88
89   task->SelectCollisionCandidates();
90   task->SetUseMCInfo(bUseMCInfo);
91   task->SetUseESDfriend(bUseESDfriend);
92   task->SetUseHLT(bUseHLT);
93   //
94   // Add task to analysis manager ------------------------------------------------------------------
95   //
96   
97   mgr->AddTask(task);
98
99   //================================================================================================
100   // -- Cuts
101   //================================================================================================
102
103   //
104   // Create TPC-ESD track reconstruction cuts ------------------------------------------------------
105   // MB tracks
106   //
107
108   AliRecInfoCuts *pRecInfoCutsTPC = new AliRecInfoCuts(); 
109   if(pRecInfoCutsTPC) {
110     //    pRecInfoCutsTPC->SetMaxDCAToVertexXY(3.0);
111     //    pRecInfoCutsTPC->SetMaxDCAToVertexZ(30.0);
112     pRecInfoCutsTPC->SetMaxDCAToVertexXY(150.0);
113     pRecInfoCutsTPC->SetMaxDCAToVertexZ(150.0);
114     pRecInfoCutsTPC->SetRequireSigmaToVertex(kFALSE);
115     pRecInfoCutsTPC->SetRequireTPCRefit(kFALSE);
116
117     pRecInfoCutsTPC->SetAcceptKinkDaughters(kTRUE);
118     pRecInfoCutsTPC->SetMinNClustersTPC(50);
119     pRecInfoCutsTPC->SetMaxChi2PerClusterTPC(1000000.);
120     pRecInfoCutsTPC->SetDCAToVertex2D(kFALSE);
121
122     pRecInfoCutsTPC->SetHistogramsOn(kFALSE); 
123   } 
124   else {
125     Error("AddTaskPerformance", "AliRecInfoCutsTPC cannot be created!");
126     return NULL;
127   }
128
129   //
130   // Create TPC-ESD track reconstruction cuts ------------------------------------------------------
131   // standard cuts
132
133   AliRecInfoCuts *pRecInfoCuts = new AliRecInfoCuts(); 
134   if(pRecInfoCuts) {
135     pRecInfoCuts->SetMaxDCAToVertexXY(3.0);
136     pRecInfoCuts->SetMaxDCAToVertexZ(3.0);
137     pRecInfoCuts->SetMinNClustersTPC(50);
138     pRecInfoCuts->SetMinNClustersITS(2);
139     pRecInfoCuts->SetHistogramsOn(kFALSE); 
140     pRecInfoCuts->SetTPCITSMatchingRadius(70); 
141     pRecInfoCuts->SetTPCTRDMatchingRadius(260); 
142   } 
143   else {
144     Error("AddTaskPerformance", "AliRecInfoCuts cannot be created!");
145     return NULL;
146   }
147
148   //
149   // Create TPC-MC track reconstruction cuts -------------------------------------------------------
150   //
151   AliMCInfoCuts  *pMCInfoCuts = new AliMCInfoCuts();
152   if(pMCInfoCuts) {
153     pMCInfoCuts->SetMinTrackLength(70);
154   } 
155   else {
156     Error("AddTaskPerformance", "AliMCInfoCuts cannot be created!");
157     return NULL;
158   }
159
160   //================================================================================================
161   // -- Object
162   //================================================================================================
163
164   //
165   // Create performance objects for TPC and set cuts 
166   //
167   enum { kTPC = 0, kTPCITS, kConstrained, kTPCInner, kTPCOuter, kTPCSec };
168
169   //
170   // Resolution ------------------------------------------------------------------------------------
171   //
172
173   AliPerformanceRes *pCompRes0 = new AliPerformanceRes("AliPerformanceRes",
174                                                        "AliPerformanceRes",kTPC,kFALSE); 
175   if(!pCompRes0) {
176     Error("AddTaskPerformance", "Cannot create AliPerformanceRes");
177   }
178   pCompRes0->SetAliRecInfoCuts(pRecInfoCuts);
179   pCompRes0->SetAliMCInfoCuts(pMCInfoCuts);
180   pCompRes0->SetUseTrackVertex(kTRUE);
181
182   //
183   // Efficiency ------------------------------------------------------------------------------------
184   //
185
186   AliPerformanceEff *pCompEff0 = new AliPerformanceEff("AliPerformanceEff",
187                                                        "AliPerformanceEff",kTPC,kFALSE); 
188   if(!pCompEff0) {
189     Error("AddTaskPerformance", "Cannot create AliPerformanceEff");
190   }
191   pCompEff0->SetAliRecInfoCuts(pRecInfoCuts);
192   pCompEff0->SetAliMCInfoCuts(pMCInfoCuts);
193   pCompEff0->SetUseTrackVertex(kTRUE);
194
195   //
196   // dEdx ------------------------------------------------------------------------------------------
197   //
198
199   AliPerformanceDEdx *pCompDEdx3 = new AliPerformanceDEdx("AliPerformanceDEdxTPCInner",
200                                                           "AliPerformanceDEdxTPCInner",kTPCInner,kFALSE); 
201   if(!pCompDEdx3) {
202     Error("AddTaskPerformance", "Cannot create AliPerformanceDEdxTPCInner");
203   }
204   pCompDEdx3->SetAliRecInfoCuts(pRecInfoCuts);
205   pCompDEdx3->SetAliMCInfoCuts(pMCInfoCuts);
206   pCompDEdx3->SetUseTrackVertex(kTRUE);
207
208   //
209   // DCA -------------------------------------------------------------------------------------------
210   //
211
212   AliPerformanceDCA *pCompDCA0 = new AliPerformanceDCA("AliPerformanceDCA",
213                                                        "AliPerformanceDCA",kTPC,kFALSE); 
214   if(!pCompDCA0) {
215     Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceDCA");
216   }
217   pCompDCA0->SetAliRecInfoCuts(pRecInfoCuts);
218   pCompDCA0->SetAliMCInfoCuts(pMCInfoCuts);
219   pCompDCA0->SetUseTrackVertex(kTRUE);
220
221   //
222   // TPC performance -------------------------------------------------------------------------------
223   //
224
225   AliPerformanceTPC *pCompTPC0 = new AliPerformanceTPC("AliPerformanceTPC",
226                                                        "AliPerformanceTPC",kTPC,kFALSE); 
227   if(!pCompTPC0) {
228     Error("AddTaskPerformance", "Cannot create AliPerformanceTPC");
229   }
230   pCompTPC0->SetAliRecInfoCuts(pRecInfoCutsTPC);
231   pCompTPC0->SetAliMCInfoCuts(pMCInfoCuts);
232   pCompTPC0->SetUseTrackVertex(kTRUE);
233   pCompTPC0->SetUseHLT(bUseHLT);
234
235   //
236   // Add components to the performance task --------------------------------------------------------
237   //
238
239   //01.09.10  At the moment only use pCompTPC0
240
241   //task->AddPerformanceObject( pCompDEdx3 );
242   //task->AddPerformanceObject( pCompDCA0 );
243   task->AddPerformanceObject( pCompTPC0 );
244
245   /*
246     if(bUseMCInfo) { 
247     task->AddPerformanceObject( pCompRes0 );
248     task->AddPerformanceObject( pCompEff0 );
249     }
250     
251     if(!bUseMCInfo &&  triggerClass) {
252     pCompDEdx3->SetTriggerClass(triggerClass);
253     pCompDCA0->SetTriggerClass(triggerClass);
254     pCompTPC0->SetTriggerClass(triggerClass);
255     }
256   */
257   
258   //================================================================================================
259   //              data containers
260   //================================================================================================
261   AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
262   
263   if(bUseHLT){
264     AliAnalysisDataContainer *coutput1 =    
265       mgr->CreateContainer("HLTQA", TList::Class(),
266                            AliAnalysisManager::kOutputContainer, Form("HLTTPC.%s.root", task->GetName()));
267   }
268   else{
269     AliAnalysisDataContainer *coutput1 = 
270       mgr->CreateContainer("TPC", TList::Class(), 
271                            AliAnalysisManager::kOutputContainer, Form("TPC.%s.root", task->GetName()));
272   }
273
274   // -- connect containers
275   mgr->ConnectInput  (task,  0, cinput );
276   mgr->ConnectOutput (task,  1, coutput1);
277
278   return task;  
279 }