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
169 Float_t mcpt = infoMC->GetParticle().Pt();
170 Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
171 Float_t spt = TMath::Sqrt(mcpt);
173 // distance to Prim. vertex
174 const Double_t* dv = infoMC->GetVDist();
176 Bool_t isPrim = TMath::Sqrt(dv[0]*dv[0] + dv[1]*dv[1])<fCutsMC->GetMaxR() && TMath::Abs(dv[2])<fCutsMC->GetMaxVz();
178 // Check selection cuts
179 if (fCutsMC->IsPdgParticle(TMath::Abs(infoMC->GetParticle().GetPdgCode())) == kFALSE) return;
181 if (infoRC->GetStatus(1)!=3) return;
182 if (!infoRC->GetESDtrack()) return;
183 if (infoRC->GetESDtrack()->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return;
184 if (!infoRC->GetESDtrack()->GetConstrainedParam()) return;
186 // calculate and set prim. vertex
187 fVertex->SetXv( infoMC->GetParticle().Vx() - dv[0] );
188 fVertex->SetYv( infoMC->GetParticle().Vy() - dv[1] );
189 fVertex->SetZv( infoMC->GetParticle().Vz() - dv[2] );
191 // calculate track parameters at vertex
192 if (infoRC->GetESDtrack()->GetTPCInnerParam())
194 if ((track = new AliExternalTrackParam(*infoRC->GetESDtrack()->GetTPCInnerParam())) != 0 )
196 Bool_t bDCAStatus = track->PropagateToDCA(fVertex,field,kMaxD,dca,cov);
199 fD0TanSPtInTPC->Fill(tantheta,spt,dca[0]);
200 fD1TanSPtInTPC->Fill(tantheta,spt,dca[1]);
207 if(infoRC->GetESDtrack()->GetITSclusters(clusterITS)==0){
208 fD0TanSPtB1->Fill(tantheta,spt,dca[0]);
209 fD1TanSPtB1->Fill(tantheta,spt,dca[1]);
211 fD0TanSPtL1->Fill(tantheta,spt,dca[0]);
212 fD1TanSPtL1->Fill(tantheta,spt,dca[1]);
215 //_____________________________________________________________________________
216 Long64_t AliComparisonDCA::Merge(TCollection* list)
218 // Merge list of objects (needed by PROOF)
226 TIterator* iter = list->MakeIterator();
229 // collection of generated histograms
231 while((obj = iter->Next()) != 0)
233 AliComparisonDCA* entry = dynamic_cast<AliComparisonDCA*>(obj);
234 if (entry == 0) continue;
237 fD0TanSPtB1->Add(entry->fD0TanSPtB1);
238 fD1TanSPtB1->Add(entry->fD1TanSPtB1);
239 fD0TanSPtL1->Add(entry->fD0TanSPtL1);
240 fD1TanSPtL1->Add(entry->fD1TanSPtL1);
241 fD0TanSPtInTPC->Add(entry->fD0TanSPtInTPC);
242 fD1TanSPtInTPC->Add(entry->fD1TanSPtInTPC);
250 //_____________________________________________________________________________
251 void AliComparisonDCA::Exec(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
252 // Process comparison information
253 Process(infoMC,infoRC);
256 //_____________________________________________________________________________
257 void AliComparisonDCA::Analyse()
260 // Analyse comparison information and store output histograms
261 // in the analysis folder "folderDCA"
264 TH1::AddDirectory(kFALSE);
268 AliComparisonDCA * comp=this;
269 TObjArray *aFolderObj = new TObjArray;
271 // write results in the folder
272 // Canvas to draw analysed histograms
273 TCanvas * c = new TCanvas("canDCA","DCA resolution");
279 gr0 = AliMathBase::MakeStat1D(comp->fD0TanSPtB1,2,5);
280 gr0->GetXaxis()->SetTitle("Tan(#theta)");
281 gr0->GetYaxis()->SetTitle("#sigmaDCA (cm)");
282 gr0->SetName("DCAResolTan");
285 //if(folder) folder->Add(gr0->GetHistogram());
286 aFolderObj->Add(gr0);
289 gr = AliMathBase::MakeStat2D(comp->fD0TanSPtB1,4,2,5);
290 gr->GetXaxis()->SetTitle("Tan(#theta)");
291 gr->GetYaxis()->SetTitle("#sqrt{p_{t}(GeV/c)}");
292 gr->GetYaxis()->SetTitle("#sigmaDCA (cm)");
293 gr->SetName("DCAResolSPTTan");
294 gr->GetHistogram()->Draw("colz");
296 aFolderObj->Add(gr->GetHistogram());
298 // export objects to analysis folder
299 fAnalysisFolder = ExportToFolder(aFolderObj);
301 // delete only TObjArray
302 if(aFolderObj) delete aFolderObj;
305 //_____________________________________________________________________________
306 TFolder* AliComparisonDCA::ExportToFolder(TObjArray * array)
308 // recreate folder avery time and export objects to new one
310 AliComparisonDCA * comp=this;
311 TFolder *folder = comp->GetAnalysisFolder();
314 TFolder *newFolder = 0;
316 Int_t size = array->GetSize();
319 // get name and title from old folder
320 name = folder->GetName();
321 title = folder->GetTitle();
327 newFolder = CreateFolder(name.Data(),title.Data());
328 newFolder->SetOwner();
330 // add objects to folder
332 newFolder->Add(array->At(i));
341 //_____________________________________________________________________________
342 TFolder* AliComparisonDCA::CreateFolder(TString name,TString title) {
343 // create folder for analysed histograms
345 folder = new TFolder(name.Data(),title.Data());