]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/hfe/AliAnalysisTaskDCA.cxx
Update of the HFE package
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliAnalysisTaskDCA.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  *
14 **************************************************************************/
15 //
16 // The analysis task:
17 // impact parameter resolution and pull study
18 // for tracks which survivied the particle cuts
19 // 
20 // 
21 // Authors:
22 //  Hongyan Yang <hongyan@physi.uni-heidelberg.de>
23 //  Carlo Bombonati <carlo.bombonati@cern.ch>
24 //
25 #include <TChain.h>
26 #include <TFile.h>
27 #include <TH1F.h>
28 #include <TH1I.h>
29 #include <TList.h>
30 #include <TMath.h>
31 #include <TObjArray.h>
32 #include <TParticle.h>
33 #include <TString.h>
34
35 #include <TCanvas.h>
36
37 #include "AliAnalysisManager.h"
38
39 #include "AliCFManager.h"
40
41 #include "AliESDInputHandler.h"
42 #include "AliESDtrack.h"
43 #include "AliVertexerTracks.h"
44 #include "AliESDVertex.h"
45
46 #include "AliMCEventHandler.h"
47 #include "AliMCEvent.h"
48 #include "AliMCParticle.h"
49
50 #include "AliESDpid.h"
51 #include "AliHFEpid.h"
52 #include "AliHFEcuts.h"
53 #include "AliHFEdca.h"
54
55 #include "AliAnalysisTaskDCA.h"
56
57
58 //____________________________________________________________
59 AliAnalysisTaskDCA::AliAnalysisTaskDCA():
60   AliAnalysisTaskSE("Impact Parameter Resolution and Pull Analysis")
61   , fPlugins(0)
62   , fCuts(0x0)
63   , fDefaultPID(0x0)
64   , fHFEpid(0x0)
65   , fPIDdetectors("")
66   , fPIDstrategy(0)
67   , fCFM(0x0)
68   , fDCA(0x0)
69   , fNclustersITS(0x0)
70   , fMinNprimVtxContrbutor(0x0)
71   , fNEvents(0x0)
72   , fResidualList(0x0)
73   , fPullList(0x0)
74   , fDcaList(0x0)
75   , fKfDcaList(0x0)
76   , fMcVertexList(0x0)
77   , fDataDcaList(0x0)
78   , fDataVertexList(0x0)
79   , fDataPullList(0x0)
80   , fMcPidList(0x0) 
81   , fDataPidList(0x0)
82   , fHfeDcaList(0x0)
83   , fHfeDataDcaList(0x0)
84   , fOutput(0x0)
85 {
86   //
87   // Dummy constructor
88   //
89   DefineInput(0, TChain::Class());
90   DefineOutput(1, TH1I::Class());
91   DefineOutput(2, TList::Class());
92
93   fDefaultPID = new AliESDpid;
94   fHFEpid = new AliHFEpid;
95
96 }
97
98 //____________________________________________________________
99 AliAnalysisTaskDCA::AliAnalysisTaskDCA(const char * name):
100   AliAnalysisTaskSE(name)
101   , fPlugins(0)
102   , fCuts(0x0)
103   , fDefaultPID(0x0)
104   , fHFEpid(0x0)
105   , fPIDdetectors("")
106   , fPIDstrategy(0)
107   , fCFM(0x0)
108   , fDCA(0x0)
109   , fNclustersITS(0x0)
110   , fMinNprimVtxContrbutor(0x0)
111   , fNEvents(0x0)
112   , fResidualList(0x0)
113   , fPullList(0x0)
114   , fDcaList(0x0) 
115   , fKfDcaList(0x0)
116   , fMcVertexList(0x0)
117   , fDataDcaList(0x0)
118   , fDataVertexList(0x0)
119   , fDataPullList(0x0)
120   , fMcPidList(0x0)
121   , fDataPidList(0x0)
122   , fHfeDcaList(0x0)
123   , fHfeDataDcaList(0x0)
124   , fOutput(0x0)
125 {
126   //
127   // Default constructor
128   //
129   DefineInput(0, TChain::Class());
130   DefineOutput(1, TH1I::Class());
131   DefineOutput(2, TList::Class());
132   
133   fDefaultPID = new AliESDpid;
134   fHFEpid = new AliHFEpid;
135
136 }
137
138 //____________________________________________________________
139 AliAnalysisTaskDCA::AliAnalysisTaskDCA(const AliAnalysisTaskDCA &ref):
140   AliAnalysisTaskSE(ref)
141   , fPlugins(ref.fPlugins)
142   , fCuts(ref.fCuts)  
143   , fDefaultPID(ref.fDefaultPID)
144   , fHFEpid(ref.fHFEpid)
145   , fPIDdetectors(ref.fPIDdetectors)
146   , fPIDstrategy(ref.fPIDstrategy)
147   , fCFM(ref.fCFM)
148   , fDCA(ref.fDCA)
149   , fNclustersITS(ref.fNclustersITS)
150   , fMinNprimVtxContrbutor(ref.fMinNprimVtxContrbutor)
151   , fNEvents(ref.fNEvents)
152   , fResidualList(ref.fResidualList)
153   , fPullList(ref.fPullList)
154   , fDcaList(ref.fDcaList)
155   , fKfDcaList(ref.fKfDcaList)
156   , fMcVertexList(ref.fMcVertexList)
157   , fDataDcaList(ref.fDataDcaList)
158   , fDataVertexList(ref.fDataVertexList)
159   , fDataPullList(ref.fDataPullList)
160   , fMcPidList(ref.fMcPidList)
161   , fDataPidList(ref.fDataPidList)
162   , fHfeDcaList(ref.fHfeDcaList)
163   , fHfeDataDcaList(ref.fHfeDataDcaList)
164   , fOutput(ref.fOutput)
165 {
166   //
167   // Copy Constructor
168   //
169
170   ref.Copy(*this);
171 }
172
173 //____________________________________________________________
174 AliAnalysisTaskDCA &AliAnalysisTaskDCA::operator=(const AliAnalysisTaskDCA &ref){
175   //
176   // Assignment operator
177   //
178   if(this == &ref) return *this;
179   AliAnalysisTaskSE::operator=(ref);
180   fPlugins = ref.fPlugins;
181   fCuts = ref.fCuts;
182   fDefaultPID = ref.fDefaultPID;
183   fHFEpid = ref.fHFEpid;
184   fPIDdetectors = ref.fPIDdetectors;
185   fPIDstrategy = ref.fPIDstrategy;
186   fCFM = ref.fCFM;
187   fDCA = ref.fDCA;
188   fNclustersITS = ref.fNclustersITS;
189   fMinNprimVtxContrbutor = ref.fMinNprimVtxContrbutor;
190   fNEvents = ref.fNEvents;
191   fResidualList = ref.fResidualList;
192   fPullList = ref.fPullList;
193   fDcaList = ref.fDcaList;
194   fKfDcaList = ref.fKfDcaList;
195   fMcVertexList = ref.fMcVertexList;
196   fDataDcaList = ref.fDataDcaList;
197   fDataVertexList = ref.fDataVertexList;
198   fDataPullList = ref.fDataPullList;
199   fMcPidList = ref.fMcPidList;
200   fDataPidList = ref.fDataPidList;
201   fHfeDcaList = ref.fHfeDcaList;    
202   fHfeDataDcaList = ref.fHfeDataDcaList;
203   fOutput = ref.fOutput;
204
205   return *this;
206 }
207
208 //____________________________________________________________
209 AliAnalysisTaskDCA::~AliAnalysisTaskDCA(){
210   //
211   // Destructor
212   //
213
214   if(fDefaultPID) delete fDefaultPID;
215   if(fHFEpid) delete fHFEpid;
216   if(fCFM) delete fCFM;
217   if(fDCA) delete fDCA;  
218   if(fNEvents) delete fNEvents;
219   if(fResidualList){ 
220     fResidualList->Clear();
221     delete fResidualList;
222   }
223
224   if(fPullList){ 
225     fPullList->Clear();
226     delete fPullList;
227   }
228   
229   if(fDcaList){ 
230     fDcaList->Clear();
231     delete fDcaList;
232   }
233   if(fKfDcaList){ 
234     fKfDcaList->Clear();
235     delete fKfDcaList;
236   }
237
238   if(fMcVertexList){
239     fMcVertexList->Clear();
240     delete   fMcVertexList;
241   }
242
243   if(fDataDcaList){ 
244     fDataDcaList->Clear();
245     delete fDataDcaList;
246   }
247
248   if(fDataVertexList){
249     fDataVertexList->Clear();
250     delete   fDataVertexList;
251   }
252   if(fDataPullList){ 
253     fDataPullList->Clear();
254     delete fDataPullList;
255   }
256
257   if(fMcPidList){
258     fMcPidList -> Clear();
259     delete fMcPidList;
260   }
261   if(fDataPidList){
262     fDataPidList -> Clear();
263     delete fDataPidList;
264   }
265
266   if(fHfeDcaList) {
267     fHfeDcaList->Clear();
268     delete fHfeDcaList;
269   } 
270   
271   if(fHfeDataDcaList) {
272     fHfeDataDcaList->Clear();
273     delete fHfeDataDcaList;
274   } 
275   
276   if(fOutput){ 
277     fOutput->Clear();
278     delete fOutput;
279   }
280   
281 }
282
283 //____________________________________________________________
284 void AliAnalysisTaskDCA::UserCreateOutputObjects(){
285   // create output objects
286   // fNEvents
287   // residual and pull
288   
289   // Automatic determination of the analysis mode
290   AliVEventHandler *inputHandler = dynamic_cast<AliVEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
291     
292   if(!TString(inputHandler->IsA()->GetName()).CompareTo("AliAODInputHandler")){
293     SetAODAnalysis();
294   } else {
295     SetESDAnalysis();
296     if(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())
297       SetHasMCData();
298   }
299   
300
301   fNEvents = new TH1I("nEvents", "Number of Events in the Analysis", 5, -0.5, 4.5); // Number of Events neccessary for the analysis and not a QA histogram
302   if(!fOutput) fOutput = new TList;
303   // Initialize correction Framework and Cuts
304   fCFM = new AliCFManager;
305   MakeParticleContainer();
306   // Temporary fix: Initialize particle cuts with 0x0
307   for(Int_t istep = 0; istep < fCFM->GetParticleContainer()->GetNStep(); istep++)
308     fCFM->SetParticleCutsList(istep, 0x0);
309   if(!fCuts){
310     AliWarning("Cuts not available. Default cuts will be used");
311     fCuts = new AliHFEcuts;
312     fCuts->CreateStandardCuts();
313   }
314   
315   fCuts->Initialize(fCFM);
316   
317   if(!fHFEpid) printf("hallo, fHFEpid is not available\n");
318   
319   if(fHFEpid && GetPlugin(kHFEpid)) {      
320     fHFEpid->SetHasMCData(HasMCData());
321     if(!fPIDdetectors.Length() && ! fPIDstrategy) AddPIDdetector("TPC");
322     if(fPIDstrategy)
323       fHFEpid->InitializePID(Form("Strategy%d", fPIDstrategy));
324     else
325       fHFEpid->InitializePID(fPIDdetectors.Data());     // Only restrictions to TPC allowed 
326   }
327
328   // dca study----------------------------------
329
330   
331   if(!fDCA) fDCA = new AliHFEdca;
332   if(!fResidualList) fResidualList = new TList();
333   if(!fPullList) fPullList = new TList();
334   if(!fDcaList) fDcaList = new TList();
335   if(!fKfDcaList) fKfDcaList = new TList();
336   if(!fMcVertexList) fMcVertexList = new TList();
337   if(!fDataDcaList) fDataDcaList = new TList();
338   if(!fDataVertexList) fDataVertexList = new TList();
339   if(!fDataPullList) fDataPullList = new TList();
340   if(!fMcPidList) fMcPidList = new TList();
341   if(!fDataPidList) fDataPidList = new TList();  
342   
343   if(!fHfeDcaList) fHfeDcaList = new TList();
344   if(!fHfeDataDcaList) fHfeDataDcaList = new TList();
345
346   if(HasMCData()) {    
347     if(GetPlugin(kImpactPar) ) {
348       fDCA->CreateHistogramsResidual(fResidualList);
349       fDCA->CreateHistogramsPull(fPullList);
350       fDCA->CreateHistogramsDca(fDcaList);
351       fOutput->AddAt(fResidualList,0);
352       fOutput->AddAt(fPullList,1);
353       fOutput->AddAt(fDcaList,2);
354     } 
355     if(GetPlugin(kKFdca)){
356       fDCA->CreateHistogramsKfDca(fKfDcaList);
357       fOutput->AddAt(fDcaList,3);
358     }
359     if(GetPlugin(kPrimVtx)){
360       fDCA->CreateHistogramsVertex(fMcVertexList);
361       fOutput->AddAt(fMcVertexList,4);
362     }
363     if(GetPlugin(kCombinedPid)){
364       fDCA->CreateHistogramsPid(fMcPidList);
365       fOutput->AddAt(fMcPidList, 5);
366     }
367     if(GetPlugin(kHFEpid)){
368       fDCA->CreateHistogramsHfeDca(fHfeDcaList);
369       fOutput->AddAt(fHfeDcaList, 6);
370     }
371   } // mc case
372
373   if(!HasMCData())  { 
374     
375     if(GetPlugin(kPrimVtx)){
376       fDCA->CreateHistogramsDataVertex(fDataVertexList);  
377       fOutput->AddAt(fDataVertexList,0);
378     }    
379
380     if(GetPlugin(kCombinedPid)){
381       fDCA->CreateHistogramsDataDca(fDataDcaList);  
382       fDCA->CreateHistogramsDataPull(fDataPullList);  
383       fDCA->CreateHistogramsDataPid(fDataPidList);
384       fOutput->AddAt(fDataDcaList,1);
385       fOutput->AddAt(fDataPullList,2);
386       fOutput->AddAt(fDataPidList, 3);
387     }
388     if(GetPlugin(kHFEpid)){
389       fDCA->CreateHistogramsHfeDataDca(fHfeDataDcaList);
390       fOutput->AddAt(fHfeDataDcaList, 4);
391     }
392     
393
394
395   }  // data case
396   
397 }
398
399 //____________________________________________________________
400 void AliAnalysisTaskDCA::UserExec(Option_t *){
401   //
402   // Run the analysis
403   // 
404
405   AliDebug(3, "Processing ESD events");
406
407   if(!fInputEvent){
408     AliError("Reconstructed Event not available");
409     return;
410   }
411   if(HasMCData()){
412     AliDebug(4, Form("MC Event: %p", fMCEvent));
413     if(!fMCEvent){
414       AliError("No MC Event, but MC Data required");
415       return;
416     }
417   }
418
419   if(!fCuts){
420     AliError("HFE cuts not available");
421     return;
422   }
423  
424
425   // protection
426   if(IsESDanalysis() && HasMCData()){
427     // Protect against missing MC trees
428     AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
429     if(!mcH->InitOk()) return;
430     if(!mcH->TreeK()) return;
431     if(!mcH->TreeTR()) return;
432   }
433
434   if(!IsAODanalysis()) {
435     AliESDInputHandler *inH = dynamic_cast<AliESDInputHandler *>(fInputHandler);
436     AliESDpid *workingPID = inH->GetESDpid();
437     if(workingPID){
438       AliDebug(1, "Using ESD PID from the input handler");
439       fHFEpid->SetESDpid(workingPID);
440     } else {
441       AliDebug(1, "Using default ESD PID");
442       fHFEpid->SetESDpid(fDefaultPID);
443     }
444     ProcessDcaAnalysis();
445   }
446
447   
448   PostData(1, fNEvents);
449   PostData(2, fOutput);
450 }
451 //____________________________________________________________
452 void AliAnalysisTaskDCA::ProcessDcaAnalysis(){
453
454   //
455   // Loop ESD
456   //
457   
458   AliMCEvent *fMC = 0x0;
459   AliESDEvent *fESD = dynamic_cast<AliESDEvent *>(fInputEvent);
460   if(HasMCData())fMC = dynamic_cast<AliMCEvent*>(fMCEvent);
461
462   if(!fESD){
463     AliError("ESD Event required for ESD Analysis")
464       return;
465   }
466
467   fNEvents->Fill(1);  // original event number before cut
468   fDCA->ApplyExtraCuts(fESD,fMinNprimVtxContrbutor);  // cut on primVtx contributors
469   fNEvents->Fill(3);  // events number after cut
470
471   AliESDtrack *track = 0x0;  
472   AliMCParticle *mctrack = 0x0;
473
474   fCFM->SetRecEventInfo(fESD);
475  
476   // event cut level
477   if(!fCFM->CheckEventCuts(AliHFEcuts::kEventStepReconstructed, fESD)) return;
478
479   for(Int_t itrack = 0; itrack < fESD->GetNumberOfTracks(); itrack++){
480     
481     track = fESD->GetTrack(itrack);
482     if(HasMCData())mctrack = dynamic_cast<AliMCParticle *>(fMC->GetTrack(TMath::Abs(track->GetLabel())));
483
484     // RecPrim: primary cuts
485     if(!fCFM->CheckParticleCuts(AliHFEcuts::kStepRecPrim, track)) continue;
486     // RecKine: ITSTPC cuts  
487     if(!fCFM->CheckParticleCuts(AliHFEcuts::kStepRecKineITSTPC, track)) continue;
488     // HFEcuts: ITS layers cuts
489     if(!fCFM->CheckParticleCuts(AliHFEcuts::kStepHFEcutsITS, track)) continue;
490     
491     if(track->GetITSclusters(0)<=fNclustersITS) continue;  // require number of ITS clusters
492     
493     // track accepted, do PID
494     AliHFEpidObject hfetrack;
495     hfetrack.fAnalysisType = AliHFEpidObject::kESDanalysis;
496     hfetrack.fRecTrack = track;
497     if(HasMCData()) hfetrack.fMCtrack = mctrack;
498
499     if(HasMCData()){
500       if(GetPlugin(kPrimVtx))
501         fDCA->FillHistogramsVtx(fESD, fMC);
502       if(GetPlugin(kImpactPar)) 
503         fDCA->FillHistogramsDca(fESD, track, fMC);
504       if(GetPlugin(kKFdca)) 
505         fDCA->FillHistogramsKfDca(fESD, track, fMC);
506       if(GetPlugin(kCombinedPid)) 
507         fDCA->FillHistogramsPid(track, fMC);
508       if(GetPlugin(kHFEpid)) {
509         if(fHFEpid->IsSelected(&hfetrack)) 
510           fDCA->FillHistogramsHfeDca(fESD, track, fMC);
511       } // plugin for hfepid 
512     }  // MC
513
514     if(!HasMCData()){
515       if(GetPlugin(kPrimVtx))
516         fDCA->FillHistogramsDataVtx(fESD);
517       if(GetPlugin(kCombinedPid)) {
518
519         // method from Andrea D 28.05.2010
520         AliVertexerTracks *vertexer = new AliVertexerTracks(fESD->GetMagneticField());
521         vertexer->SetITSMode();
522         vertexer->SetMinClusters(fNclustersITS);
523         Int_t skipped[2];
524         skipped[0] = (Int_t)track->GetID();
525         vertexer->SetSkipTracks(1,skipped);
526         AliESDVertex *vtxESDSkip = (AliESDVertex*)vertexer->FindPrimaryVertex(fESD);
527         delete vertexer; vertexer = NULL;
528         if(vtxESDSkip->GetNContributors()<fMinNprimVtxContrbutor) continue;
529
530         fDCA->FillHistogramsDataDca(fESD, track, vtxESDSkip);
531         fDCA->FillHistogramsDataPid(track);
532       }
533       if(GetPlugin(kHFEpid)) {
534         if(fHFEpid->IsSelected(&hfetrack)) {
535           //      printf("Found an electron in p+p collision! from HFE pid \n");
536           fDCA->FillHistogramsHfeDataDca(fESD, track);    
537         } 
538       } // plugin for hfepid
539     }  // data case
540
541   } // track loop
542
543 }
544
545
546 //____________________________________________________________
547 void AliAnalysisTaskDCA::Terminate(Option_t *){
548   //
549   // Terminate not implemented at the moment
550   //  
551   
552   if(GetPlugin(kPostProcess)){
553     fOutput = dynamic_cast<TList *>(GetOutputData(1));
554     if(!fOutput){
555       AliError("Results not available");
556       return;
557     }
558     PostProcess();
559   }
560   
561 }
562
563
564 //____________________________________________________________
565 void AliAnalysisTaskDCA::Load(TString filename){
566   // no need for postprocessing for the moment
567   TFile *input = TFile::Open(filename.Data());
568   if(!input || input->IsZombie()){
569     AliError("Cannot read file");
570     return;
571   }
572
573   input->Close();
574   delete input;
575   
576   
577 }
578
579 //____________________________________________________________
580 void AliAnalysisTaskDCA::PostProcess(){
581   // do post processing
582   // should do fitting here for dca resolution
583   // moved to an external macro to do the job
584   
585   Load("HFEdca.root");
586   TCanvas *c1 = new TCanvas("c1", "number of analyzed events", 300, 400);
587   fNEvents->Draw();
588   c1->SaveAs("temp.png");
589  
590 }
591
592
593
594
595 //____________________________________________________________
596 void AliAnalysisTaskDCA::PrintStatus() const {
597   
598   //
599   // Print Analysis status
600   //
601   printf("\n\tAnalysis Settings\n\t========================================\n");
602   printf("\t Running on %s\n", !HasMCData()?"p+p collision data":"MC sample");
603   printf("\t Cuts: %s\n", (fCuts != NULL) ? "YES" : "NO");
604   printf("\t Impact parameter analysis is %s\n", GetPlugin(kImpactPar)?"ON":"OFF");
605   printf("\t Using AliKFParticle for analysis? %s\n", GetPlugin(kKFdca)?"ON":"OFF");
606   printf("\t Primary vertex analysis is %s\n", GetPlugin(kPrimVtx)?"ON":"OFF");
607   printf("\t Combined pid analysis is %s\n", GetPlugin(kCombinedPid)?"ON":"OFF");
608   printf("\t HFE pid analysis is %s\n", GetPlugin(kHFEpid)?"ON":"OFF");
609   printf("\t Post process analysis is %s\n", GetPlugin(kPostProcess)?"ON":"OFF");
610   printf("\t ");
611   printf("\n");
612 }
613
614 //__________________________________________                                                  
615 void AliAnalysisTaskDCA::SwitchOnPlugin(Int_t plug){
616   //                                            
617   // Switch on Plugin          
618   // Available:                                  
619   //  - analyze impact parameter
620   //  - Post Processing                                                                      
621   
622   switch(plug){
623   case kPostProcess: 
624     SETBIT(fPlugins, plug); 
625     break;
626   case kImpactPar: 
627     SETBIT(fPlugins, plug); 
628     break;
629   case kPrimVtx: 
630     SETBIT(fPlugins, plug); 
631     break;
632   case kCombinedPid:
633     SETBIT(fPlugins, plug); 
634     break;
635   case kHFEpid:
636     SETBIT(fPlugins, plug); 
637     break;
638   case kKFdca:
639     SETBIT(fPlugins, plug); 
640     break;
641   default: 
642     AliError("Unknown Plugin");
643   };
644 }
645
646
647 //____________________________________________________________
648 void AliAnalysisTaskDCA::MakeParticleContainer(){
649   //
650   // Create the particle container (borrowed from AliAnalysisTaskHFE)
651   //
652   const Int_t kNvar   = 3 ; //number of variables on the grid:pt,eta, phi
653   const Double_t kPtmin = 0.1, kPtmax = 10.;
654   const Double_t kEtamin = -0.9, kEtamax = 0.9;
655   const Double_t kPhimin = 0., kPhimax = 2. * TMath::Pi();
656
657   //arrays for the number of bins in each dimension
658   Int_t iBin[kNvar];
659   iBin[0] = 40; //bins in pt
660   iBin[1] =  8; //bins in eta 
661   iBin[2] = 18; // bins in phi
662
663   //arrays for lower bounds :
664   Double_t* binEdges[kNvar];
665   for(Int_t ivar = 0; ivar < kNvar; ivar++)
666     binEdges[ivar] = new Double_t[iBin[ivar] + 1];
667
668   //values for bin lower bounds
669   for(Int_t i=0; i<=iBin[0]; i++) binEdges[0][i]=(Double_t)TMath::Power(10,TMath::Log10(kPtmin) + (TMath::Log10(kPtmax)-TMath::Log10(kPtmin))/iBin[0]*(Double_t)i);  
670   for(Int_t i=0; i<=iBin[1]; i++) binEdges[1][i]=(Double_t)kEtamin  + (kEtamax-kEtamin)/iBin[1]*(Double_t)i;
671   for(Int_t i=0; i<=iBin[2]; i++) binEdges[2][i]=(Double_t)kPhimin  + (kPhimax-kPhimin)/iBin[2]*(Double_t)i;
672
673   //one "container" for MC
674   AliCFContainer* container = new AliCFContainer("container","container for tracks", (AliHFEcuts::kNcutStepsTrack + 1 + 2*(AliHFEcuts::kNcutStepsESDtrack + 1)), kNvar, iBin);
675
676   //setting the bin limits
677   for(Int_t ivar = 0; ivar < kNvar; ivar++)
678     container -> SetBinLimits(ivar, binEdges[ivar]);
679   fCFM->SetParticleContainer(container);
680
681   //create correlation matrix for unfolding
682   Int_t thnDim[2*kNvar];
683   for (int k=0; k<kNvar; k++) {
684     //first half  : reconstructed 
685     //second half : MC
686     thnDim[k]      = iBin[k];
687     thnDim[k+kNvar] = iBin[k];
688   }
689
690
691 }
692
693 //____________________________________________________________
694 void AliAnalysisTaskDCA::AddPIDdetector(TString detector){
695   
696   //
697   // Adding PID detector to the task
698   //
699   
700   if(!fPIDdetectors.Length()) 
701     fPIDdetectors = detector;
702   else
703     fPIDdetectors += ":" + detector;
704 }
705