]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/TPC/macros/RunPerformanceTaskResEffMC.C
Merge branch 'master', remote branch 'origin' into TPCdev
[u/mrichter/AliRoot.git] / PWGPP / TPC / macros / RunPerformanceTaskResEffMC.C
1 // Macro to run TPC performance task (locally, proof).
2 //
3 // By default 2 performance components are added to 
4 // AliPerformanceRes - resloution at DCA to prim. vertex
5 // AliPerformanceEff - efficiency for prim. tracks
6 //
7
8 /*
9  
10   //1. Run locally 
11   gSystem->Load("libANALYSIS");
12   gSystem->Load("libANALYSISalice");
13   gSystem->Load("libTENDER");
14   gSystem->Load("libCORRFW");
15   gSystem->Load("libPWGPP");
16
17   gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
18   TChain* chain = CreateESDChain("esds.txt",10, 0);
19   //TChain* chain = CreateESDChain("/u/jacek/alice/dNdPt/input/LHC10a8/esds_104867_MC_LHC10a8.txt",3, 0);
20   chain->Lookup();
21
22   gROOT->LoadMacro("$ALICE_ROOT/PWGPP/TPC/macros/RunPerformanceTaskResEffMC.C");
23   RunPerformanceTaskResEffMC(chain, kTRUE, kFALSE, kFALSE);
24
25   //2. Make final spectra and store them in the
26   // output folder and generate control pictures
27
28   aliroot -b
29   TFile f("TPC.MC.Performance.root");
30
31   AliPerformanceRes * compObjRes = (AliPerformanceRes*)TPCMC->FindObject("AliPerformanceRes");
32   compObjRes->Analyse();
33   compObjRes->GetAnalysisFolder()->ls("*");
34   // create control pictures
35   compObjRes->PrintHisto(kTRUE,"TPC.MC.PerformanceRes.Pict.ps");
36   // store output QA histograms in file
37   TFile fout("TPC.MC.PerformanceRes.Histo.root","recreate");
38   compObjRes->GetAnalysisFolder()->Write();
39   fout.Close();
40
41   //
42   f->cd();
43   AliPerformanceEff * compObjEff = (AliPerformanceEff*)TPCMC->FindObject("AliPerformanceEff");
44   compObjEff->Analyse();
45   compObjEff->GetAnalysisFolder()->ls("*");
46   // create control pictures
47   compObjEff->PrintHisto(kTRUE,"TPC.MC.PerformanceEff.Pict.ps");
48   // store output QA histograms in file
49   TFile fout("TPC.MC.PerformanceEff.Histo.root","recreate");
50   compObjEff->GetAnalysisFolder()->Write();
51   fout.Close();
52
53   f.Close();
54
55 */
56
57 //_____________________________________________________________________________
58 void RunPerformanceTaskResEffMC(TChain *chain, Bool_t bUseMCInfo=kTRUE, Bool_t bUseESDfriend=kTRUE,  Bool_t bProof=kTRUE)
59 {
60   if(!chain) 
61   {
62     AliDebug(AliLog::kError, "ERROR: No input chain available");
63     return;
64   }
65   //
66   // Swtich off all AliInfo (too much output!)
67   //
68   AliLog::SetGlobalLogLevel(AliLog::kError);
69
70   //
71   // Create analysis manager
72   //
73   AliAnalysisManager *mgr = new AliAnalysisManager;
74   if(!mgr) { 
75     Error("runTPCQA","AliAnalysisManager not set!");
76     return;
77   }
78
79   //
80   // Set ESD input handler
81   //
82   AliESDInputHandler* esdH = new AliESDInputHandler;
83   if(!esdH) { 
84     Error("runTPCQA","AliESDInputHandler not created!");
85     return;
86   }
87   if(bUseESDfriend) esdH->SetActiveBranches("ESDfriend");
88   mgr->SetInputEventHandler(esdH);
89
90   //
91   // Set MC input handler
92   //
93   if(bUseMCInfo) {
94     AliMCEventHandler* mcH = new AliMCEventHandler;
95     if(!esdH) { 
96       Error("runTPCQA","AliMCEventHandler not created!");
97       return;
98     }
99     mcH->SetReadTR(kTRUE);
100     mgr->SetMCtruthEventHandler(mcH);
101   }
102
103   //
104   // Create task
105   //
106   AliPerformanceTask *task = new AliPerformanceTask("Performance","TPC Performance");
107   if (!task) {
108     Error("AddTaskPerformanceTPC", "TPC performance task cannot be created!");
109     return NULL;
110   }
111   task->SetUseMCInfo(bUseMCInfo);
112   task->SetUseESDfriend(bUseESDfriend);
113
114   //
115   // Add task to analysis manager
116   //
117   mgr->AddTask(task);
118
119   //
120   // Create TPC-ESD track reconstruction cuts
121   // MB tracks
122   //
123   AliRecInfoCuts *pRecInfoCutsTPC = new AliRecInfoCuts(); 
124   if(pRecInfoCutsTPC) {
125     pRecInfoCutsTPC->SetMaxDCAToVertexXY(3.0);
126     pRecInfoCutsTPC->SetMaxDCAToVertexZ(30.0);
127     //pRecInfoCutsTPC->SetMaxDCAToVertexZ(3.0);
128     pRecInfoCutsTPC->SetRequireSigmaToVertex(kFALSE);
129     pRecInfoCutsTPC->SetRequireTPCRefit(kFALSE);
130     pRecInfoCutsTPC->SetAcceptKinkDaughters(kTRUE);
131     pRecInfoCutsTPC->SetMinNClustersTPC(50);
132     pRecInfoCutsTPC->SetMaxChi2PerClusterTPC(1000000.);
133     pRecInfoCutsTPC->SetDCAToVertex2D(kFALSE);
134
135     pRecInfoCutsTPC->SetHistogramsOn(kFALSE); 
136   } 
137   else {
138     Error("AddTaskPerformanceTPC", "AliRecInfoCutsTPC cannot be created!");
139     return NULL;
140   }
141
142   //
143   // Create TPC-ESD track reconstruction cuts
144   // MATCH tracks
145   //
146   AliRecInfoCuts *pRecInfoCutsMATCH = new AliRecInfoCuts(); 
147   if(pRecInfoCutsMATCH) {
148     pRecInfoCutsMATCH->SetMaxDCAToVertexXY(3.0);
149     pRecInfoCutsMATCH->SetMaxDCAToVertexZ(3.0);
150     pRecInfoCutsMATCH->SetRequireSigmaToVertex(kFALSE);
151     pRecInfoCutsMATCH->SetRequireTPCRefit(kFALSE);
152     pRecInfoCutsMATCH->SetAcceptKinkDaughters(kTRUE);
153     pRecInfoCutsMATCH->SetMinNClustersTPC(50);
154     pRecInfoCutsMATCH->SetMaxChi2PerClusterTPC(1000000.);
155     pRecInfoCutsMATCH->SetDCAToVertex2D(kFALSE);
156     pRecInfoCutsMATCH->SetTPCITSMatchingRadius(70); 
157     pRecInfoCutsMATCH->SetTPCTRDMatchingRadius(260); 
158     pRecInfoCutsMATCH->SetMinNClustersITS(3);
159
160     pRecInfoCutsMATCH->SetHistogramsOn(kFALSE); 
161   } 
162   else {
163     Error("AddTaskPerformanceTPC", "AliRecInfoCutsTPC cannot be created!");
164     return NULL;
165   }
166
167   //
168   // Create TPC-ESD track reconstruction cuts
169   // standard cuts
170   AliRecInfoCuts *pRecInfoCuts = new AliRecInfoCuts(); 
171   if(pRecInfoCuts) {
172     pRecInfoCuts->SetMaxDCAToVertexXY(3.0);
173     pRecInfoCuts->SetMaxDCAToVertexZ(3.0);
174     pRecInfoCuts->SetMinNClustersTPC(50);
175     pRecInfoCuts->SetMinNClustersITS(2);
176     pRecInfoCuts->SetHistogramsOn(kFALSE); 
177     pRecInfoCuts->SetTPCITSMatchingRadius(70); 
178     pRecInfoCuts->SetTPCTRDMatchingRadius(260); 
179   } 
180   else {
181     Error("AddTaskPerformanceTPC", "AliRecInfoCuts cannot be created!");
182     return NULL;
183   }
184   //
185   // Create TPC-MC track reconstruction cuts
186   //
187   AliMCInfoCuts  *pMCInfoCuts = new AliMCInfoCuts();
188   if(pMCInfoCuts) {
189     pMCInfoCuts->SetMinTrackLength(70);
190   } 
191   else {
192     Error("AddTaskPerformanceTPC", "AliMCInfoCuts cannot be created!");
193     return NULL;
194   }
195
196   //
197   // Create performance objects for TPC and set cuts 
198   //
199   enum { kTPC = 0, kTPCITS, kConstrained, kTPCInner, kTPCOuter, kTPCSec };
200
201   //
202   // Resolution
203   //
204   AliPerformanceRes *pCompRes0 = new AliPerformanceRes("AliPerformanceRes","AliPerformanceRes",kTPC,kFALSE); 
205   if(!pCompRes0) {
206     Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceRes");
207   }
208   pCompRes0->SetAliRecInfoCuts(pRecInfoCuts);
209   pCompRes0->SetAliMCInfoCuts(pMCInfoCuts);
210
211   AliPerformanceRes *pCompRes3 = new AliPerformanceRes("AliPerformanceResTPCInner","AliPerformanceResTPCInner",kTPCInner,kFALSE); 
212   if(!pCompRes3) {
213     Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceResTPCInner");
214   }
215   pCompRes3->SetAliRecInfoCuts(pRecInfoCuts);
216   pCompRes3->SetAliMCInfoCuts(pMCInfoCuts);
217
218   AliPerformanceRes *pCompRes4 = new AliPerformanceRes("AliPerformanceResTPCOuter","AliPerformanceResTPCOuter",kTPCOuter,kFALSE); 
219   if(!pCompRes4) {
220     Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceResTPCOuter");
221   }
222   pCompRes4->SetAliRecInfoCuts(pRecInfoCuts);
223   pCompRes4->SetAliMCInfoCuts(pMCInfoCuts);
224   //
225   // Efficiency
226   //
227   AliPerformanceEff *pCompEff0 = new AliPerformanceEff("AliPerformanceEff","AliPerformanceEff",kTPC,kFALSE); 
228   if(!pCompEff0) {
229     Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceEff");
230   }
231   pCompEff0->SetAliRecInfoCuts(pRecInfoCuts);
232   pCompEff0->SetAliMCInfoCuts(pMCInfoCuts);
233   //
234   // dEdx
235   //
236   AliPerformanceDEdx *pCompDEdx3 = new AliPerformanceDEdx("AliPerformanceDEdxTPCInner","AliPerformanceDEdxTPCInner",kTPCInner,kFALSE); 
237   if(!pCompDEdx3) {
238     Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceDEdxTPCInner");
239   }
240   pCompDEdx3->SetAliRecInfoCuts(pRecInfoCuts);
241   pCompDEdx3->SetAliMCInfoCuts(pMCInfoCuts);
242   //
243   // DCA
244   //
245   AliPerformanceDCA *pCompDCA0 = new AliPerformanceDCA("AliPerformanceDCA","AliPerformanceDCA",kTPC,kFALSE); 
246   if(!pCompDCA0) {
247     Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceDCA");
248   }
249   pCompDCA0->SetAliRecInfoCuts(pRecInfoCuts);
250   pCompDCA0->SetAliMCInfoCuts(pMCInfoCuts);
251   //
252   // TPC performance
253   //
254   AliPerformanceTPC *pCompTPC0 = new AliPerformanceTPC("AliPerformanceTPC","AliPerformanceTPC",kTPC,kFALSE); 
255   if(!pCompTPC0) {
256     Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceTPC");
257   }
258   pCompTPC0->SetAliRecInfoCuts(pRecInfoCutsTPC);
259   pCompTPC0->SetAliMCInfoCuts(pMCInfoCuts);
260   //
261   // TPC+ITS matching performance
262   //
263   AliPerformanceMatch *pCompMatch0 = new AliPerformanceMatch("AliPerformanceMatchTPCITS","AliPerformanceMatchTPCITS",0,kFALSE); 
264   if(!pCompMatch0) {
265     Error("AddTaskPerformanceMatch", "Cannot create AliPerformanceMatchTPCITS");
266   }
267   pCompMatch0->SetAliRecInfoCuts(pRecInfoCutsMATCH);
268   pCompMatch0->SetAliMCInfoCuts(pMCInfoCuts);
269   //
270   // TPC+TRD matching performance
271   //
272   AliPerformanceMatch *pCompMatch1 = new AliPerformanceMatch("AliPerformanceMatchTPCTRD","AliPerformanceMatchTPCTRD",1,kFALSE); 
273   if(!pCompMatch1) {
274     Error("AddTaskPerformanceMatch", "Cannot create AliPerformanceMatchTPCTRD");
275   }
276   pCompMatch1->SetAliRecInfoCuts(pRecInfoCutsMATCH);
277   pCompMatch1->SetAliMCInfoCuts(pMCInfoCuts);
278  
279   AliPerformanceMatch *pCompMatch2 = new AliPerformanceMatch("AliPerformanceMatchTPCEFF","AliPerformanceMatchTPCEFF",2,kFALSE); 
280   if(!pCompMatch2) {
281     Error("AddTaskPerformanceMatch", "Cannot create AliPerformanceMatchTPCEFF");
282   }
283   pCompMatch2->SetAliRecInfoCuts(pRecInfoCutsMATCH);
284   pCompMatch2->SetAliMCInfoCuts(pMCInfoCuts);
285
286   //
287   // Add components to the performance task
288   //
289   //task->AddPerformanceObject( pCompDEdx3 );
290   //task->AddPerformanceObject( pCompDCA0 );
291   //task->AddPerformanceObject( pCompTPC0 );
292   //task->AddPerformanceObject( pCompMatch0 );
293   //task->AddPerformanceObject( pCompMatch1 );
294   //task->AddPerformanceObject( pCompMatch2 );
295
296   //
297   if(bUseMCInfo) { 
298      task->AddPerformanceObject( pCompRes0 );
299      //task->AddPerformanceObject( pCompRes3 );
300      //task->AddPerformanceObject( pCompRes4 );
301      task->AddPerformanceObject( pCompEff0 );
302   }
303
304   //
305   if(!bUseMCInfo) {
306     pCompDEdx3->SetTriggerClass(triggerClass);
307     pCompDCA0->SetTriggerClass(triggerClass);
308     pCompTPC0->SetTriggerClass(triggerClass);
309     pCompMatch0->SetTriggerClass(triggerClass);
310     pCompMatch1->SetTriggerClass(triggerClass);
311     pCompMatch2->SetTriggerClass(triggerClass);
312   }
313
314   //
315   // Create containers for input
316   //
317   mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
318
319   //
320   // Create containers for output
321   //
322   AliAnalysisDataContainer *coutput_tpc = mgr->CreateContainer("TPCMC", TList::Class(), AliAnalysisManager::kOutputContainer, Form("TPC.MC.%s.root", task->GetName()));
323   mgr->ConnectOutput(task, 1, coutput_tpc);
324
325   // Enable debug printouts
326   mgr->SetDebugLevel(0);
327
328   if (!mgr->InitAnalysis())
329     return;
330
331   mgr->PrintStatus();
332
333   if(bProof) mgr->StartAnalysis("proof",chain);
334   else mgr->StartAnalysis("local",chain);
335 }
336