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");
21 // Analyse comparison data
24 // the output histograms/graphs will be stored in the folder "folderDCA"
25 compObj->GetAnalysisFolder()->ls("*");
27 // user can save whole comparison object (or only folder with anlysed histograms)
28 // in the seperate output file (e.g.)
29 TFile fout("Analysed_DCA.root","recreate");
30 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 // TNamed("AliComparisonDCA","AliComparisonDCA"),
72 AliComparisonObject("AliComparisonDCA"),
93 //_____________________________________________________________________________
94 AliComparisonDCA::~AliComparisonDCA()
97 if(fD0TanSPtB1) delete fD0TanSPtB1; fD0TanSPtB1=0;
98 if(fD1TanSPtB1) delete fD1TanSPtB1; fD1TanSPtB1=0;
99 if(fD0TanSPtL1) delete fD0TanSPtL1; fD0TanSPtL1=0;
100 if(fD1TanSPtL1) delete fD1TanSPtL1; fD1TanSPtL1=0;
101 if(fD0TanSPtInTPC) delete fD0TanSPtInTPC; fD0TanSPtInTPC=0;
102 if(fD1TanSPtInTPC) delete fD1TanSPtInTPC; fD1TanSPtInTPC=0;
103 if(fVertex) delete fVertex; fVertex=0;
104 if(fAnalysisFolder) delete fAnalysisFolder; fAnalysisFolder=0;
108 //_____________________________________________________________________________
109 void AliComparisonDCA::Init()
112 fD0TanSPtB1 = new TH3F("DCAyTanSPtB1","DCAyTanSPt",40,-2,2, 10,0.3,3, 100,-1,1);
113 fD0TanSPtB1->SetXTitle("tan(#theta)");
114 fD0TanSPtB1->SetYTitle("#sqrt{p_{t}(GeV/c)}");
115 fD0TanSPtB1->SetZTitle("DCA_{xy}");
117 fD1TanSPtB1 = new TH3F("DCAzTanSPtB1","DCAzTanSPt",40,-2,2, 10,0.3,3, 100,-1,1);
118 fD1TanSPtB1->SetXTitle("tan(#theta)");
119 fD1TanSPtB1->SetYTitle("#sqrt(p_{t}(GeV/c))");
120 fD1TanSPtB1->SetZTitle("DCA_{z}");
122 fD0TanSPtL1 = new TH3F("DCAyTanSPtL1","DCAyTanSPt",40,-2,2, 10,0.3,3, 100,-1,1);
123 fD0TanSPtL1->SetXTitle("tan(#theta)");
124 fD0TanSPtL1->SetYTitle("#sqrt{p_{t}(GeV/c)}");
125 fD0TanSPtL1->SetZTitle("DCA_{xy}");
127 fD1TanSPtL1 = new TH3F("DCAzTanSPtL1","DCAzTanSPt",40,-2,2, 10,0.3,3, 100, -1,1);
128 fD1TanSPtL1->SetXTitle("tan(#theta)");
129 fD1TanSPtL1->SetYTitle("#sqrt{p_{t}(GeV/c)}");
130 fD1TanSPtL1->SetZTitle("DCA_{z}");
132 fD0TanSPtInTPC = new TH3F("DCAyTanSPtInTPC","DCAyTanSPt",40,-2,2, 10,0.3,3, 100,-1,1);
133 fD0TanSPtInTPC->SetXTitle("tan(#theta)");
134 fD0TanSPtInTPC->SetYTitle("#sqrt{p_{t}(GeV/c)}");
135 fD0TanSPtInTPC->SetZTitle("DCA_{xy}");
137 fD1TanSPtInTPC = new TH3F("DCAzTanSPtInTPC","DCAzTanSPt",40,-2,2, 10,0.3,3, 100, -1,1);
138 fD1TanSPtInTPC->SetXTitle("tan(#theta)");
139 fD1TanSPtInTPC->SetYTitle("#sqrt{p_{t}(GeV/c)}");
140 fD1TanSPtInTPC->SetZTitle("DCA_{z}");
144 AliDebug(AliLog::kError, "ERROR: Cannot find AliMCInfoCuts object");
146 AliDebug(AliLog::kError, "ERROR: Cannot find AliRecInfoCuts object");
149 fAnalysisFolder = CreateFolder("folderDCA","Analysis DCA Folder");
152 fVertex = new AliESDVertex();
158 //_____________________________________________________________________________
159 void AliComparisonDCA::Process(AliMCInfo* infoMC, AliESDRecInfo *infoRC)
161 // Fill DCA comparison information
162 AliExternalTrackParam *track = 0;
163 Double_t field = AliTracker::GetBz(); // nominal Bz field [kG]
164 Double_t kMaxD = 123456.0; // max distance
166 Int_t clusterITS[200];
167 Double_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
168 Float_t dca1[2], cov1[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z
170 Float_t mcpt = infoMC->GetParticle().Pt();
171 Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
172 Float_t spt = TMath::Sqrt(mcpt);
174 // distance to Prim. vertex
175 const Double_t* dv = infoMC->GetVDist();
177 Bool_t isPrim = TMath::Sqrt(dv[0]*dv[0] + dv[1]*dv[1])<fCutsMC->GetMaxR() && TMath::Abs(dv[2])<fCutsMC->GetMaxVz();
179 // Check selection cuts
180 if (fCutsMC->IsPdgParticle(TMath::Abs(infoMC->GetParticle().GetPdgCode())) == kFALSE) return;
182 if (infoRC->GetStatus(1)!=3) return;
183 if (!infoRC->GetESDtrack()) return;
184 if (infoRC->GetESDtrack()->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return;
185 if (!infoRC->GetESDtrack()->GetConstrainedParam()) return;
187 // calculate and set prim. vertex
188 fVertex->SetXv( infoMC->GetParticle().Vx() - dv[0] );
189 fVertex->SetYv( infoMC->GetParticle().Vy() - dv[1] );
190 fVertex->SetZv( infoMC->GetParticle().Vz() - dv[2] );
192 // calculate track parameters at vertex
193 if (infoRC->GetESDtrack()->GetTPCInnerParam())
195 if ((track = new AliExternalTrackParam(*infoRC->GetESDtrack()->GetTPCInnerParam())) != 0 )
197 Bool_t bDCAStatus = track->PropagateToDCA(fVertex,field,kMaxD,dca,cov);
200 fD0TanSPtInTPC->Fill(tantheta,spt,dca[0]);
201 fD1TanSPtInTPC->Fill(tantheta,spt,dca[1]);
209 infoRC->GetESDtrack()->GetImpactParameters(dca1,cov1);
211 if(infoRC->GetESDtrack()->GetITSclusters(clusterITS)==0){
212 fD0TanSPtB1->Fill(tantheta,spt,dca1[0]);
213 fD1TanSPtB1->Fill(tantheta,spt,dca1[1]);
215 fD0TanSPtL1->Fill(tantheta,spt,dca1[0]);
216 fD1TanSPtL1->Fill(tantheta,spt,dca1[1]);
219 //_____________________________________________________________________________
220 Long64_t AliComparisonDCA::Merge(TCollection* list)
222 // Merge list of objects (needed by PROOF)
230 TIterator* iter = list->MakeIterator();
233 // collection of generated histograms
235 while((obj = iter->Next()) != 0)
237 AliComparisonDCA* entry = dynamic_cast<AliComparisonDCA*>(obj);
238 if (entry == 0) continue;
241 fD0TanSPtB1->Add(entry->fD0TanSPtB1);
242 fD1TanSPtB1->Add(entry->fD1TanSPtB1);
243 fD0TanSPtL1->Add(entry->fD0TanSPtL1);
244 fD1TanSPtL1->Add(entry->fD1TanSPtL1);
245 fD0TanSPtInTPC->Add(entry->fD0TanSPtInTPC);
246 fD1TanSPtInTPC->Add(entry->fD1TanSPtInTPC);
254 //_____________________________________________________________________________
255 void AliComparisonDCA::Exec(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
256 // Process comparison information
257 Process(infoMC,infoRC);
260 //_____________________________________________________________________________
261 void AliComparisonDCA::Analyse()
264 // Analyse comparison information and store output histograms
265 // in the analysis folder "folderDCA"
268 TH1::AddDirectory(kFALSE);
270 TGraph * gr[4]= { 0,0,0,0 };
271 TGraph2D *gr2[4]= { 0,0,0,0};
272 AliComparisonDCA * comp=this;
273 TObjArray *aFolderObj = new TObjArray;
275 // write results in the folder
276 // Canvas to draw analysed histograms
277 TCanvas * c = new TCanvas("canDCA","DCA resolution");
283 gr[0] = AliMathBase::MakeStat1D(comp->fD0TanSPtB1,2,5);
284 gr[0]->GetXaxis()->SetTitle("Tan(#theta)");
285 gr[0]->GetYaxis()->SetTitle("#sigmaDCA_xy (cm)");
286 gr[0]->SetName("DCAXYResolTan");
289 aFolderObj->Add(gr[0]);
292 gr[1] = AliMathBase::MakeStat1D(comp->fD1TanSPtB1,2,5);
293 gr[1]->GetXaxis()->SetTitle("Tan(#theta)");
294 gr[1]->GetYaxis()->SetTitle("#sigmaDCA_z (cm)");
295 gr[1]->SetName("DCAZResolTan");
298 aFolderObj->Add(gr[1]);
304 gr[2] = AliMathBase::MakeStat1D(comp->fD0TanSPtB1,2,4);
305 gr[2]->GetXaxis()->SetTitle("Tan(#theta)");
306 gr[2]->GetYaxis()->SetTitle("mean DCA_xy (cm)");
307 gr[2]->SetName("DCAXYMeanTan");
310 aFolderObj->Add(gr[2]);
313 gr[3] = AliMathBase::MakeStat1D(comp->fD1TanSPtB1,2,4);
314 gr[3]->GetXaxis()->SetTitle("Tan(#theta)");
315 gr[3]->GetYaxis()->SetTitle("mean DCA_z (cm)");
316 gr[3]->SetName("DCAZMeanTan");
319 aFolderObj->Add(gr[3]);
323 gr2[0] = AliMathBase::MakeStat2D(comp->fD0TanSPtB1,4,2,5);
324 gr2[0]->GetXaxis()->SetTitle("Tan(#theta)");
325 gr2[0]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV/c)}");
326 gr2[0]->GetZaxis()->SetTitle("#sigmaDCA_xy (cm)");
327 gr2[0]->SetName("DCAXYResolSPTTan");
328 gr2[0]->GetHistogram()->Draw("colz");
330 gr2[0]->GetHistogram()->SetName("DCAXYResolSPTTan");
331 aFolderObj->Add(gr2[0]->GetHistogram());
334 gr2[1] = AliMathBase::MakeStat2D(comp->fD1TanSPtB1,4,2,5);
335 gr2[1]->GetXaxis()->SetTitle("Tan(#theta)");
336 gr2[1]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV/c)}");
337 gr2[1]->GetZaxis()->SetTitle("#sigmaDCA_z (cm)");
338 gr2[1]->SetName("DCAZResolSPTTan");
339 gr2[1]->GetHistogram()->Draw("colz");
341 gr2[1]->GetHistogram()->SetName("DCAZResolSPTTan");
342 aFolderObj->Add(gr2[1]->GetHistogram());
346 gr2[2] = AliMathBase::MakeStat2D(comp->fD0TanSPtB1,4,2,4);
347 gr2[2]->GetXaxis()->SetTitle("Tan(#theta)");
348 gr2[2]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV/c)}");
349 gr2[2]->GetZaxis()->SetTitle("mean DCA_xy (cm)");
350 gr2[2]->SetName("DCAXYMeanSPTTan");
351 gr2[2]->GetHistogram()->Draw("colz");
353 gr2[2]->GetHistogram()->SetName("DCAXYMeanSPTTan");
354 aFolderObj->Add(gr2[2]->GetHistogram());
357 gr2[3] = AliMathBase::MakeStat2D(comp->fD1TanSPtB1,4,2,4);
358 gr2[3]->GetXaxis()->SetTitle("Tan(#theta)");
359 gr2[3]->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV/c)}");
360 gr2[3]->GetZaxis()->SetTitle("mean DCA_z (cm)");
361 gr2[3]->SetName("DCAZMeanSPTTan");
362 gr2[3]->GetHistogram()->Draw("colz");
364 gr2[3]->GetHistogram()->SetName("DCAZMeanSPTTan");
365 aFolderObj->Add(gr2[3]->GetHistogram());
367 // export objects to analysis folder
368 fAnalysisFolder = ExportToFolder(aFolderObj);
370 // delete only TObjArray
371 if(aFolderObj) delete aFolderObj;
374 //_____________________________________________________________________________
375 TFolder* AliComparisonDCA::ExportToFolder(TObjArray * array)
377 // recreate folder avery time and export objects to new one
379 AliComparisonDCA * comp=this;
380 TFolder *folder = comp->GetAnalysisFolder();
383 TFolder *newFolder = 0;
385 Int_t size = array->GetSize();
388 // get name and title from old folder
389 name = folder->GetName();
390 title = folder->GetTitle();
396 newFolder = CreateFolder(name.Data(),title.Data());
397 newFolder->SetOwner();
399 // add objects to folder
401 newFolder->Add(array->At(i));
410 //_____________________________________________________________________________
411 TFolder* AliComparisonDCA::CreateFolder(TString name,TString title) {
412 // create folder for analysed histograms
414 folder = new TFolder(name.Data(),title.Data());