1 //------------------------------------------------------------------------------
2 // Implementation of AliComparisonDCA class. It keeps information from
3 // comparison of reconstructed and MC particle tracks. In addtion,
4 // it keeps selection cuts used during comparison. The comparison
5 // information is stored in the ROOT histograms. Analysis of these
6 // histograms can be done by using Analyse() class function. The result of
7 // the analysis (histograms/graphs) are stored in the folder
8 // which is a data member of AliComparisonDCA.
10 // Author: J.Otwinowski 04/02/2008
11 //------------------------------------------------------------------------------
15 // after running comparison task, read the file, and get component
16 gROOT->LoadMacro("$ALICE_ROOT/PWG1/Macros/LoadMyLibs.C");
18 TFile f("Output.root");
19 //AliComparisonDCA * compObj = (AliComparisonDCA*)f.Get("AliComparisonDCA");
20 AliComparisonDCA * compObj = (AliComparisonDCA*)cOutput->FindObject("AliComparisonDCA");
22 // Analyse comparison data
25 // the output histograms/graphs will be stored in the folder "folderDCA"
26 compObj->GetAnalysisFolder()->ls("*");
28 // user can save whole comparison object (or only folder with anlysed histograms)
29 // in the seperate output file (e.g.)
30 TFile fout("Analysed_DCA.root","recreate");
31 compObj->Write(); // compObj->GetAnalysisFolder()->Write();
43 #include "TProfile2D.h"
48 #include "AliTracker.h"
49 #include "AliESDEvent.h"
51 #include "AliESDfriend.h"
52 #include "AliESDfriendTrack.h"
53 #include "AliRecInfoCuts.h"
54 #include "AliMCInfoCuts.h"
56 #include "AliESDVertex.h"
58 #include "AliMathBase.h"
59 #include "AliTreeDraw.h"
61 #include "AliMCInfo.h"
62 #include "AliESDRecInfo.h"
63 #include "AliComparisonDCA.h"
67 ClassImp(AliComparisonDCA)
69 //_____________________________________________________________________________
70 AliComparisonDCA::AliComparisonDCA():
71 AliComparisonObject("AliComparisonDCA"),
91 //_____________________________________________________________________________
92 AliComparisonDCA::~AliComparisonDCA()
95 if(fD0TanSPtTPCITS) delete fD0TanSPtTPCITS; fD0TanSPtTPCITS=0;
96 if(fD1TanSPtTPCITS) delete fD1TanSPtTPCITS; fD1TanSPtTPCITS=0;
97 if(fD0TanSPt) delete fD0TanSPt; fD0TanSPt=0;
98 if(fD1TanSPt) delete fD1TanSPt; fD1TanSPt=0;
99 if(fD0TanSPtTPC) delete fD0TanSPtTPC; fD0TanSPtTPC=0;
100 if(fD1TanSPtTPC) delete fD1TanSPtTPC; fD1TanSPtTPC=0;
101 if(fAnalysisFolder) delete fAnalysisFolder; fAnalysisFolder=0;
105 //_____________________________________________________________________________
106 void AliComparisonDCA::Init()
109 fD0TanSPtTPCITS = new TH3F("DCAyTanSPtTPCITS","DCAyTanSPt",40,-2,2, 10,0.3,3, 100,-1,1);
110 fD0TanSPtTPCITS->SetXTitle("tan(#theta)");
111 fD0TanSPtTPCITS->SetYTitle("#sqrt{p_{t}(GeV)}");
112 fD0TanSPtTPCITS->SetZTitle("DCA_{xy}");
114 fD1TanSPtTPCITS = new TH3F("DCAzTanSPtTPCITS","DCAzTanSPt",40,-2,2, 10,0.3,3, 100,-1,1);
115 fD1TanSPtTPCITS->SetXTitle("tan(#theta)");
116 fD1TanSPtTPCITS->SetYTitle("#sqrt(p_{t}(GeV))");
117 fD1TanSPtTPCITS->SetZTitle("DCA_{z}");
119 fD0TanSPt = new TH3F("DCAyTanSPt","DCAyTanSPt",40,-2,2, 10,0.3,3, 100,-1,1);
120 fD0TanSPt->SetXTitle("tan(#theta)");
121 fD0TanSPt->SetYTitle("#sqrt{p_{t}(GeV)}");
122 fD0TanSPt->SetZTitle("DCA_{xy}");
124 fD1TanSPt = new TH3F("DCAzTanSPt","DCAzTanSPt",40,-2,2, 10,0.3,3, 100, -1,1);
125 fD1TanSPt->SetXTitle("tan(#theta)");
126 fD1TanSPt->SetYTitle("#sqrt{p_{t}(GeV)}");
127 fD1TanSPt->SetZTitle("DCA_{z}");
129 fD0TanSPtTPC = new TH3F("DCAyTanSPtTPC","DCAyTanSPt",40,-2,2, 10,0.3,3, 100,-1,1);
130 fD0TanSPtTPC->SetXTitle("tan(#theta)");
131 fD0TanSPtTPC->SetYTitle("#sqrt{p_{t}(GeV)}");
132 fD0TanSPtTPC->SetZTitle("DCA_{xy}");
134 fD1TanSPtTPC = new TH3F("DCAzTanSPtTPC","DCAzTanSPt",40,-2,2, 10,0.3,3, 100, -1,1);
135 fD1TanSPtTPC->SetXTitle("tan(#theta)");
136 fD1TanSPtTPC->SetYTitle("#sqrt{p_{t}(GeV)}");
137 fD1TanSPtTPC->SetZTitle("DCA_{z}");
141 AliDebug(AliLog::kError, "ERROR: Cannot find AliMCInfoCuts object");
143 AliDebug(AliLog::kError, "ERROR: Cannot find AliRecInfoCuts object");
146 fAnalysisFolder = CreateFolder("folderDCA","Analysis DCA Folder");
149 //_____________________________________________________________________________
150 void AliComparisonDCA::Process(AliMCInfo* infoMC, AliESDRecInfo *infoRC)
152 // Fill DCA comparison information
153 AliExternalTrackParam *track = 0;
154 Double_t field = AliTracker::GetBz(); // nominal Bz field [kG]
155 Double_t kMaxD = 123456.0; // max distance
157 Int_t clusterITS[200];
158 Double_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
159 Float_t dca1[2], cov1[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
161 Float_t mcpt = infoMC->GetParticle().Pt();
162 Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
163 Float_t spt = TMath::Sqrt(mcpt);
165 // distance to Prim. vertex
166 const Double_t* dv = infoMC->GetVDist();
168 Bool_t isPrim = TMath::Sqrt(dv[0]*dv[0] + dv[1]*dv[1])<fCutsMC->GetMaxR() && TMath::Abs(dv[2])<fCutsMC->GetMaxVz();
170 // Check selection cuts
171 if (fCutsMC->IsPdgParticle(TMath::Abs(infoMC->GetParticle().GetPdgCode())) == kFALSE) return;
173 if (infoRC->GetStatus(1)!=3) return;
174 if (!infoRC->GetESDtrack()) return;
175 if (infoRC->GetESDtrack()->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return;
176 if (!infoRC->GetESDtrack()->GetConstrainedParam()) return;
178 // calculate and set prim. vertex
179 AliESDVertex vertexMC;
180 vertexMC.SetXv( infoMC->GetParticle().Vx() - dv[0] );
181 vertexMC.SetYv( infoMC->GetParticle().Vy() - dv[1] );
182 vertexMC.SetZv( infoMC->GetParticle().Vz() - dv[2] );
184 // calculate track parameters at vertex
185 if (infoRC->GetESDtrack()->GetTPCInnerParam())
187 if ((track = new AliExternalTrackParam(*infoRC->GetESDtrack()->GetTPCInnerParam())) != 0 )
189 Bool_t bDCAStatus = track->PropagateToDCA(&vertexMC,field,kMaxD,dca,cov);
192 fD0TanSPtTPC->Fill(tantheta,spt,dca[0]);
193 fD1TanSPtTPC->Fill(tantheta,spt,dca[1]);
200 infoRC->GetESDtrack()->GetImpactParameters(dca1,cov1);
203 if(infoRC->GetESDtrack()->GetITSclusters(clusterITS)>fCutsRC->GetMinNClustersITS()){
204 fD0TanSPtTPCITS->Fill(tantheta,spt,dca1[0]);
205 fD1TanSPtTPCITS->Fill(tantheta,spt,dca1[1]);
207 fD0TanSPt->Fill(tantheta,spt,dca1[0]);
208 fD1TanSPt->Fill(tantheta,spt,dca1[1]);
211 //_____________________________________________________________________________
212 Long64_t AliComparisonDCA::Merge(TCollection* list)
214 // Merge list of objects (needed by PROOF)
222 TIterator* iter = list->MakeIterator();
225 // collection of generated histograms
227 while((obj = iter->Next()) != 0)
229 AliComparisonDCA* entry = dynamic_cast<AliComparisonDCA*>(obj);
230 if (entry == 0) continue;
233 fD0TanSPtTPCITS->Add(entry->fD0TanSPtTPCITS);
234 fD1TanSPtTPCITS->Add(entry->fD1TanSPtTPCITS);
235 fD0TanSPt->Add(entry->fD0TanSPt);
236 fD1TanSPt->Add(entry->fD1TanSPt);
237 fD0TanSPtTPC->Add(entry->fD0TanSPtTPC);
238 fD1TanSPtTPC->Add(entry->fD1TanSPtTPC);
246 //_____________________________________________________________________________
247 void AliComparisonDCA::Exec(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
248 // Process comparison information
249 Process(infoMC,infoRC);
252 //_____________________________________________________________________________
253 void AliComparisonDCA::Analyse()
256 // Analyse comparison information and store output histograms
257 // in the analysis folder "folderDCA"
260 TH1::AddDirectory(kFALSE);
262 TGraph * gr[8]= { 0,0,0,0,0,0,0,0 };
263 TGraph2D *gr2[8]= { 0,0,0,0,0,0,0,0};
264 AliComparisonDCA * comp=this;
265 TObjArray *aFolderObj = new TObjArray;
267 // write results in the folder
268 // Canvas to draw analysed histograms
269 TCanvas * c = new TCanvas("canDCA","DCA resolution");
275 gr[0] = AliMathBase::MakeStat1D(comp->fD0TanSPtTPC,2,5);
276 gr[0]->GetXaxis()->SetTitle("Tan(#theta)");
277 gr[0]->GetYaxis()->SetTitle("#sigmaDCA_xy (cm)");
278 gr[0]->SetName("DCAXYResolTanTPC");
279 gr[0]->SetTitle("resol. DCA_xy (TPC only)");
282 aFolderObj->Add(gr[0]);
285 gr[1] = AliMathBase::MakeStat1D(comp->fD1TanSPtTPC,2,5);
286 gr[1]->GetXaxis()->SetTitle("Tan(#theta)");
287 gr[1]->GetYaxis()->SetTitle("#sigmaDCA_z (cm)");
288 gr[1]->SetName("DCAZResolTanTPC");
289 gr[1]->SetTitle("resol. DCA_z (TPC only)");
292 aFolderObj->Add(gr[1]);
295 gr[2] = AliMathBase::MakeStat1D(comp->fD0TanSPtTPCITS,2,5);
296 gr[2]->GetXaxis()->SetTitle("Tan(#theta)");
297 gr[2]->GetYaxis()->SetTitle("#sigmaDCA_xy (cm)");
298 gr[2]->SetName("DCAXYResolTanTPCITS");
299 gr[2]->SetTitle("resol. DCA_xy (TPC+ITS)");
302 aFolderObj->Add(gr[2]);
305 gr[3] = AliMathBase::MakeStat1D(comp->fD1TanSPtTPCITS,2,5);
306 gr[3]->GetXaxis()->SetTitle("Tan(#theta)");
307 gr[3]->GetYaxis()->SetTitle("#sigmaDCA_z (cm)");
308 gr[3]->SetName("DCAZResolTanTPCITS");
309 gr[3]->SetTitle("resol. DCA_z (TPC+ITS)");
312 aFolderObj->Add(gr[3]);
318 gr[4] = AliMathBase::MakeStat1D(comp->fD0TanSPtTPC,2,4);
319 gr[4]->GetXaxis()->SetTitle("Tan(#theta)");
320 gr[4]->GetYaxis()->SetTitle("mean DCA_xy (cm)");
321 gr[4]->SetName("DCAXYMeanTanTPC");
322 gr[4]->SetTitle("mean DCA_xy (TPC only)");
325 aFolderObj->Add(gr[4]);
328 gr[5] = AliMathBase::MakeStat1D(comp->fD1TanSPtTPC,2,4);
329 gr[5]->GetXaxis()->SetTitle("Tan(#theta)");
330 gr[5]->GetYaxis()->SetTitle("mean DCA_z (cm)");
331 gr[5]->SetName("DCAZMeanTanTPC");
332 gr[5]->SetTitle("mean DCA_z (TPC only)");
335 aFolderObj->Add(gr[5]);
338 gr[6] = AliMathBase::MakeStat1D(comp->fD0TanSPtTPCITS,2,4);
339 gr[6]->GetXaxis()->SetTitle("Tan(#theta)");
340 gr[6]->GetYaxis()->SetTitle("mean DCA_xy (cm)");
341 gr[6]->SetName("DCAXYMeanTanTPCITS");
342 gr[6]->SetTitle("mean DCA_xy (TPC+ITS)");
345 aFolderObj->Add(gr[6]);
348 gr[7] = AliMathBase::MakeStat1D(comp->fD1TanSPtTPCITS,2,4);
349 gr[7]->GetXaxis()->SetTitle("Tan(#theta)");
350 gr[7]->GetYaxis()->SetTitle("mean DCA_z (cm)");
351 gr[7]->SetName("DCAZMeanTanTPCITS");
352 gr[7]->SetTitle("mean DCA_z (TPC+ITS)");
355 aFolderObj->Add(gr[7]);
358 TCanvas * c1 = new TCanvas("canDCA1","2D DCA resolution");
363 gr2[0] = AliMathBase::MakeStat2D(comp->fD0TanSPtTPC,4,2,5);
364 gr2[0]->GetXaxis()->SetTitle("Tan(#theta)");
365 gr2[0]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
366 gr2[0]->GetZaxis()->SetTitle("#sigmaDCA_xy (cm)");
367 gr2[0]->SetName("DCAXYResolSPTTanTPC");
368 gr2[0]->SetTitle("#sigma DCA_xy (TPC only)");
369 gr2[0]->GetHistogram()->Draw("colz");
371 gr2[0]->GetHistogram()->SetName("DCAXYResolSPTTanTPC");
372 aFolderObj->Add(gr2[0]->GetHistogram());
375 gr2[1] = AliMathBase::MakeStat2D(comp->fD1TanSPtTPC,4,2,5);
376 gr2[1]->GetXaxis()->SetTitle("Tan(#theta)");
377 gr2[1]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
378 gr2[1]->GetZaxis()->SetTitle("#sigmaDCA_z (cm)");
379 gr2[1]->SetName("DCAZResolSPTTanTPC");
380 gr2[1]->SetTitle("#sigma DCA_z (TPC only)");
381 gr2[1]->GetHistogram()->Draw("colz");
383 gr2[1]->GetHistogram()->SetName("DCAZResolSPTTanTPC");
384 aFolderObj->Add(gr2[1]->GetHistogram());
388 gr2[2] = AliMathBase::MakeStat2D(comp->fD0TanSPtTPCITS,4,2,5);
389 gr2[2]->GetXaxis()->SetTitle("Tan(#theta)");
390 gr2[2]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
391 gr2[2]->GetZaxis()->SetTitle("#sigmaDCA_xy (cm)");
392 gr2[2]->SetName("DCAXYResolSPTTanTPCITS");
393 gr2[2]->SetTitle("#sigma DCA_xy (TPC+ITS)");
394 gr2[2]->GetHistogram()->Draw("colz");
396 gr2[2]->GetHistogram()->SetName("DCAXYResolSPTTanTPCITS");
397 aFolderObj->Add(gr2[2]->GetHistogram());
400 gr2[3] = AliMathBase::MakeStat2D(comp->fD1TanSPtTPCITS,4,2,5);
401 gr2[3]->GetXaxis()->SetTitle("Tan(#theta)");
402 gr2[3]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
403 gr2[3]->GetZaxis()->SetTitle("#sigmaDCA_z (cm)");
404 gr2[3]->SetName("DCAZResolSPTTanTPCITS");
405 gr2[3]->SetTitle("#sigma DCA_z (TPC+ITS)");
406 gr2[3]->GetHistogram()->Draw("colz");
408 gr2[3]->GetHistogram()->SetName("DCAZResolSPTTanTPCITS");
409 aFolderObj->Add(gr2[3]->GetHistogram());
413 gr2[4] = AliMathBase::MakeStat2D(comp->fD0TanSPtTPC,4,2,4);
414 gr2[4]->GetXaxis()->SetTitle("Tan(#theta)");
415 gr2[4]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
416 gr2[4]->GetZaxis()->SetTitle("mean DCA_xy (cm)");
417 gr2[4]->SetName("DCAXYMeanSPTTanTPC");
418 gr2[4]->SetTitle("mean DCA_xy (TPC only)");
419 gr2[4]->GetHistogram()->Draw("colz");
421 gr2[4]->GetHistogram()->SetName("DCAXYMeanSPTTanTPC");
422 aFolderObj->Add(gr2[4]->GetHistogram());
425 gr2[5] = AliMathBase::MakeStat2D(comp->fD1TanSPtTPC,4,2,4);
426 gr2[5]->GetXaxis()->SetTitle("Tan(#theta)");
427 gr2[5]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
428 gr2[5]->GetZaxis()->SetTitle("mean DCA_z (cm)");
429 gr2[5]->SetName("DCAZMeanSPTTanTPC");
430 gr2[5]->SetTitle("mean DCA_z (TPC only)");
431 gr2[5]->GetHistogram()->Draw("colz");
433 gr2[5]->GetHistogram()->SetName("DCAZMeanSPTTanTPC");
434 aFolderObj->Add(gr2[5]->GetHistogram());
437 gr2[6] = AliMathBase::MakeStat2D(comp->fD0TanSPtTPCITS,4,2,4);
438 gr2[6]->GetXaxis()->SetTitle("Tan(#theta)");
439 gr2[6]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
440 gr2[6]->GetZaxis()->SetTitle("mean DCA_xy (cm)");
441 gr2[6]->SetName("DCAXYMeanSPTTanTPCITS");
442 gr2[6]->SetTitle("mean DCA_xy (TPC+ITS)");
443 gr2[6]->GetHistogram()->Draw("colz");
445 gr2[6]->GetHistogram()->SetName("DCAXYMeanSPTTanTPCITS");
446 aFolderObj->Add(gr2[6]->GetHistogram());
449 gr2[7] = AliMathBase::MakeStat2D(comp->fD1TanSPtTPCITS,4,2,4);
450 gr2[7]->GetXaxis()->SetTitle("Tan(#theta)");
451 gr2[7]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV)}");
452 gr2[7]->GetZaxis()->SetTitle("mean DCA_z (cm)");
453 gr2[7]->SetName("DCAZMeanSPTTanTPCITS");
454 gr2[7]->SetTitle("mean DCA_z (TPC+ITS)");
455 gr2[7]->GetHistogram()->Draw("colz");
457 gr2[7]->GetHistogram()->SetName("DCAZMeanSPTTanTPCITS");
458 aFolderObj->Add(gr2[7]->GetHistogram());
460 // export objects to analysis folder
461 fAnalysisFolder = ExportToFolder(aFolderObj);
463 // delete only TObjArray
464 if(aFolderObj) delete aFolderObj;
467 //_____________________________________________________________________________
468 TFolder* AliComparisonDCA::ExportToFolder(TObjArray * array)
470 // recreate folder avery time and export objects to new one
472 AliComparisonDCA * comp=this;
473 TFolder *folder = comp->GetAnalysisFolder();
476 TFolder *newFolder = 0;
478 Int_t size = array->GetSize();
481 // get name and title from old folder
482 name = folder->GetName();
483 title = folder->GetTitle();
489 newFolder = CreateFolder(name.Data(),title.Data());
490 newFolder->SetOwner();
492 // add objects to folder
494 newFolder->Add(array->At(i));
503 //_____________________________________________________________________________
504 TFolder* AliComparisonDCA::CreateFolder(TString name,TString title) {
505 // create folder for analysed histograms
507 folder = new TFolder(name.Data(),title.Data());