]>
Commit | Line | Data |
---|---|---|
7cc34f08 | 1 | //------------------------------------------------------------------------------ |
2 | // Implementation of AliPerformanceDCA 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 AliPerformanceDCA. | |
9 | // | |
10 | // Author: J.Otwinowski 04/02/2008 | |
11 | //------------------------------------------------------------------------------ | |
12 | ||
13 | /* | |
14 | ||
15 | // after running comparison task, read the file, and get component | |
16 | gROOT->LoadMacro("$ALICE_ROOT/PWG1/Macros/LoadMyLibs.C"); | |
17 | LoadMyLibs(); | |
18 | TFile f("Output.root"); | |
19 | AliPerformanceDCA * compObj = (AliPerformanceDCA*)coutput->FindObject("AliPerformanceDCA"); | |
20 | ||
21 | // Analyse comparison data | |
22 | compObj->Analyse(); | |
23 | ||
24 | // the output histograms/graphs will be stored in the folder "folderDCA" | |
25 | compObj->GetAnalysisFolder()->ls("*"); | |
26 | ||
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(); | |
31 | fout.Close(); | |
32 | ||
33 | */ | |
34 | ||
35 | #include <TAxis.h> | |
36 | #include <TCanvas.h> | |
37 | #include <TGraph.h> | |
38 | #include <TGraph2D.h> | |
39 | #include <TH1.h> | |
40 | #include <TH2.h> | |
41 | #include <TH3.h> | |
4bb5f8a9 | 42 | #include <TF1.h> |
7cc34f08 | 43 | |
44 | #include "AliPerformanceDCA.h" | |
45 | #include "AliESDEvent.h" | |
46 | #include "AliESDVertex.h" | |
47 | #include "AliLog.h" | |
48 | #include "AliMathBase.h" | |
49 | #include "AliRecInfoCuts.h" | |
50 | #include "AliMCInfoCuts.h" | |
51 | #include "AliStack.h" | |
52 | #include "AliMCEvent.h" | |
53 | #include "AliTracker.h" | |
54 | #include "AliHeader.h" | |
55 | #include "AliGenEventHeader.h" | |
56 | ||
57 | using namespace std; | |
58 | ||
59 | ClassImp(AliPerformanceDCA) | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | AliPerformanceDCA::AliPerformanceDCA(): | |
63 | AliPerformanceObject("AliPerformanceDCA"), | |
64 | ||
65 | // DCA histograms | |
66 | fDCAHisto(0), | |
67 | ||
68 | // Cuts | |
69 | fCutsRC(0), | |
70 | fCutsMC(0), | |
71 | ||
72 | // histogram folder | |
73 | fAnalysisFolder(0) | |
74 | { | |
75 | // default constructor | |
76 | Init(); | |
77 | } | |
78 | ||
79 | //_____________________________________________________________________________ | |
80 | AliPerformanceDCA::AliPerformanceDCA(Char_t* name="AliPerformanceDCA", Char_t* title="AliPerformanceDCA",Int_t analysisMode=0, Bool_t hptGenerator=kFALSE): | |
81 | AliPerformanceObject(name,title), | |
82 | ||
83 | // DCA histograms | |
84 | fDCAHisto(0), | |
85 | ||
86 | // Cuts | |
87 | fCutsRC(0), | |
88 | fCutsMC(0), | |
89 | ||
90 | // histogram folder | |
91 | fAnalysisFolder(0) | |
92 | { | |
93 | // named constructor | |
94 | ||
95 | SetAnalysisMode(analysisMode); | |
96 | SetHptGenerator(hptGenerator); | |
97 | Init(); | |
98 | } | |
99 | ||
100 | //_____________________________________________________________________________ | |
101 | AliPerformanceDCA::~AliPerformanceDCA() | |
102 | { | |
103 | // destructor | |
104 | if(fDCAHisto) delete fDCAHisto; fDCAHisto=0; | |
105 | if(fAnalysisFolder) delete fAnalysisFolder; fAnalysisFolder=0; | |
106 | } | |
107 | ||
108 | //_____________________________________________________________________________ | |
109 | void AliPerformanceDCA::Init() | |
110 | { | |
111 | // DCA histograms | |
112 | Int_t nPtBins = 50; | |
113 | Double_t ptMin = 1.e-2, ptMax = 10.; | |
114 | ||
115 | Double_t *binsPt = 0; | |
116 | if (IsHptGenerator()) { | |
117 | nPtBins = 100; ptMax = 100.; | |
118 | binsPt = CreateLogAxis(nPtBins,ptMin,ptMax); | |
119 | } else { | |
120 | binsPt = CreateLogAxis(nPtBins,ptMin,ptMax); | |
121 | } | |
122 | ||
123 | /* | |
124 | Int_t nPtBins = 31; | |
125 | Double_t binsPt[32] = {0.,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.7,0.8,0.9,1.0,1.2,1.4,1.6,1.8,2.0,2.25,2.5,2.75,3.,3.5,4.,5.,6.,8.,10.}; | |
126 | Double_t ptMin = 0., ptMax = 10.; | |
127 | ||
128 | if(IsHptGenerator() == kTRUE) { | |
129 | nPtBins = 100; | |
130 | ptMin = 0.; ptMax = 100.; | |
131 | } | |
132 | */ | |
133 | ||
134 | //dca_r, dca_z, eta, pt | |
e6a60a90 | 135 | Int_t binsQA[5] = {100,100,30,nPtBins,144}; |
886bf4d3 | 136 | Double_t xminQA[5] = {-10.,-10.,-1.5,ptMin,0.}; |
137 | Double_t xmaxQA[5] = {10.,10.,1.5,ptMax,2*TMath::Pi()}; | |
7cc34f08 | 138 | |
886bf4d3 | 139 | fDCAHisto = new THnSparseF("fDCAHisto","dca_r:dca_z:eta:pt:phi",5,binsQA,xminQA,xmaxQA); |
7cc34f08 | 140 | fDCAHisto->SetBinEdges(3,binsPt); |
141 | ||
142 | fDCAHisto->GetAxis(0)->SetTitle("dca_r (cm)"); | |
143 | fDCAHisto->GetAxis(1)->SetTitle("dca_z (cm)"); | |
144 | fDCAHisto->GetAxis(2)->SetTitle("#eta"); | |
145 | fDCAHisto->GetAxis(3)->SetTitle("p_{T} (GeV/c)"); | |
886bf4d3 | 146 | fDCAHisto->GetAxis(4)->SetTitle("phi (rad)"); |
7cc34f08 | 147 | fDCAHisto->Sumw2(); |
148 | ||
149 | // init cuts | |
150 | if(!fCutsMC) | |
151 | AliDebug(AliLog::kError, "ERROR: Cannot find AliMCInfoCuts object"); | |
152 | if(!fCutsRC) | |
153 | AliDebug(AliLog::kError, "ERROR: Cannot find AliRecInfoCuts object"); | |
154 | ||
155 | // init folder | |
156 | fAnalysisFolder = CreateFolder("folderDCA","Analysis DCA Folder"); | |
157 | } | |
158 | ||
159 | //_____________________________________________________________________________ | |
758320f7 | 160 | void AliPerformanceDCA::ProcessTPC(AliStack* const stack, AliESDtrack *const esdTrack, AliESDEvent* const esdEvent) |
7cc34f08 | 161 | { |
162 | // Fill DCA comparison information | |
758320f7 | 163 | if(!esdEvent) return; |
7cc34f08 | 164 | if(!esdTrack) return; |
165 | ||
758320f7 | 166 | if( IsUseTrackVertex() ) |
167 | { | |
168 | // Relate TPC inner params to prim. vertex | |
169 | const AliESDVertex *vtxESD = esdEvent->GetPrimaryVertexTracks(); | |
170 | Double_t x[3]; esdTrack->GetXYZ(x); | |
171 | Double_t b[3]; AliTracker::GetBxByBz(x,b); | |
172 | Bool_t isOK = esdTrack->RelateToVertexTPCBxByBz(vtxESD, b, kVeryBig); | |
173 | if(!isOK) return; | |
174 | ||
175 | /* | |
176 | // JMT -- recaluclate DCA for HLT if not present | |
177 | if ( dca[0] == 0. && dca[1] == 0. ) { | |
178 | track->GetDZ( vtxESD->GetX(), vtxESD->GetY(), vtxESD->GetZ(), esdEvent->GetMagneticField(), dca ); | |
179 | } | |
180 | */ | |
181 | } | |
182 | ||
183 | // get TPC inner params at DCA to prim. vertex | |
7cc34f08 | 184 | const AliExternalTrackParam *track = esdTrack->GetTPCInnerParam(); |
185 | if(!track) return; | |
186 | ||
758320f7 | 187 | // read from ESD track |
7cc34f08 | 188 | Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z |
189 | esdTrack->GetImpactParametersTPC(dca,cov); | |
190 | ||
191 | if (esdTrack->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return; // min. nb. TPC clusters | |
192 | ||
886bf4d3 | 193 | Double_t vDCAHisto[5]={dca[0],dca[1],track->Eta(),track->Pt(),track->Phi()}; |
7cc34f08 | 194 | fDCAHisto->Fill(vDCAHisto); |
195 | ||
196 | // | |
197 | // Fill rec vs MC information | |
198 | // | |
199 | if(!stack) return; | |
200 | ||
758320f7 | 201 | } |
7cc34f08 | 202 | |
203 | //_____________________________________________________________________________ | |
758320f7 | 204 | void AliPerformanceDCA::ProcessTPCITS(AliStack* const stack, AliESDtrack *const esdTrack, AliESDEvent* const esdEvent) |
7cc34f08 | 205 | { |
206 | // Fill DCA comparison information | |
207 | if(!esdTrack) return; | |
758320f7 | 208 | if(!esdEvent) return; |
209 | ||
210 | if( IsUseTrackVertex() ) | |
211 | { | |
212 | // Relate TPC inner params to prim. vertex | |
213 | const AliESDVertex *vtxESD = esdEvent->GetPrimaryVertexTracks(); | |
214 | Double_t x[3]; esdTrack->GetXYZ(x); | |
215 | Double_t b[3]; AliTracker::GetBxByBz(x,b); | |
216 | Bool_t isOK = esdTrack->RelateToVertexBxByBz(vtxESD, b, kVeryBig); | |
217 | if(!isOK) return; | |
218 | ||
219 | /* | |
220 | // JMT -- recaluclate DCA for HLT if not present | |
221 | if ( dca[0] == 0. && dca[1] == 0. ) { | |
222 | track->GetDZ( vtxESD->GetX(), vtxESD->GetY(), vtxESD->GetZ(), esdEvent->GetMagneticField(), dca ); | |
223 | } | |
224 | */ | |
225 | } | |
7cc34f08 | 226 | |
227 | Float_t dca[2], cov[3]; // dca_xy, dca_z, sigma_xy, sigma_xy_z, sigma_z | |
228 | esdTrack->GetImpactParameters(dca,cov); | |
229 | ||
230 | if ((esdTrack->GetStatus()&AliESDtrack::kTPCrefit)==0) return; // TPC refit | |
231 | if (esdTrack->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return; // min. nb. TPC clusters | |
232 | Int_t clusterITS[200]; | |
233 | if(esdTrack->GetITSclusters(clusterITS)<fCutsRC->GetMinNClustersITS()) return; // min. nb. ITS clusters | |
234 | ||
886bf4d3 | 235 | Double_t vDCAHisto[5]={dca[0],dca[1],esdTrack->Eta(),esdTrack->Pt(), esdTrack->Phi()}; |
7cc34f08 | 236 | fDCAHisto->Fill(vDCAHisto); |
237 | ||
238 | // | |
239 | // Fill rec vs MC information | |
240 | // | |
241 | if(!stack) return; | |
242 | ||
243 | } | |
244 | ||
245 | void AliPerformanceDCA::ProcessConstrained(AliStack* const /*stack*/, AliESDtrack *const /*esdTrack*/) | |
246 | { | |
247 | // Fill DCA comparison information | |
248 | ||
249 | AliDebug(AliLog::kWarning, "Warning: Not implemented"); | |
250 | } | |
251 | ||
252 | //_____________________________________________________________________________ | |
253 | Long64_t AliPerformanceDCA::Merge(TCollection* const list) | |
254 | { | |
255 | // Merge list of objects (needed by PROOF) | |
256 | ||
257 | if (!list) | |
258 | return 0; | |
259 | ||
260 | if (list->IsEmpty()) | |
261 | return 1; | |
262 | ||
263 | TIterator* iter = list->MakeIterator(); | |
264 | TObject* obj = 0; | |
265 | ||
266 | // collection of generated histograms | |
267 | Int_t count=0; | |
268 | while((obj = iter->Next()) != 0) | |
269 | { | |
270 | AliPerformanceDCA* entry = dynamic_cast<AliPerformanceDCA*>(obj); | |
271 | if (entry == 0) continue; | |
272 | ||
273 | fDCAHisto->Add(entry->fDCAHisto); | |
274 | count++; | |
275 | } | |
276 | ||
277 | return count; | |
278 | } | |
279 | ||
280 | //_____________________________________________________________________________ | |
281 | void AliPerformanceDCA::Exec(AliMCEvent* const mcEvent, AliESDEvent *const esdEvent, AliESDfriend *const esdFriend, const Bool_t bUseMC, const Bool_t bUseESDfriend) | |
282 | { | |
283 | // Process comparison information | |
284 | // | |
285 | if(!esdEvent) | |
286 | { | |
287 | Error("Exec","esdEvent not available"); | |
288 | return; | |
289 | } | |
290 | AliHeader* header = 0; | |
291 | AliGenEventHeader* genHeader = 0; | |
292 | AliStack* stack = 0; | |
293 | TArrayF vtxMC(3); | |
294 | ||
295 | if(bUseMC) | |
296 | { | |
297 | if(!mcEvent) { | |
298 | Error("Exec","mcEvent not available"); | |
299 | return; | |
300 | } | |
301 | // get MC event header | |
302 | header = mcEvent->Header(); | |
303 | if (!header) { | |
304 | Error("Exec","Header not available"); | |
305 | return; | |
306 | } | |
307 | // MC particle stack | |
308 | stack = mcEvent->Stack(); | |
309 | if (!stack) { | |
310 | Error("Exec","Stack not available"); | |
311 | return; | |
312 | } | |
313 | // get MC vertex | |
314 | genHeader = header->GenEventHeader(); | |
315 | if (!genHeader) { | |
316 | Error("Exec","Could not retrieve genHeader from Header"); | |
317 | return; | |
318 | } | |
319 | genHeader->PrimaryVertex(vtxMC); | |
320 | } | |
321 | ||
322 | // use ESD friends | |
323 | if(bUseESDfriend) { | |
324 | if(!esdFriend) { | |
325 | Error("Exec","esdFriend not available"); | |
326 | return; | |
327 | } | |
328 | } | |
329 | ||
e6a60a90 | 330 | // trigger |
046b4280 | 331 | if(!bUseMC &&GetTriggerClass()) { |
4bb5f8a9 | 332 | Bool_t isEventTriggered = esdEvent->IsTriggerClassFired(GetTriggerClass()); |
333 | if(!isEventTriggered) return; | |
334 | } | |
e6a60a90 | 335 | |
758320f7 | 336 | // get event vertex |
337 | const AliESDVertex *vtxESD = NULL; | |
338 | if( IsUseTrackVertex() ) | |
339 | { | |
340 | // track vertex | |
341 | vtxESD = esdEvent->GetPrimaryVertexTracks(); | |
342 | } | |
343 | else { | |
344 | // TPC track vertex | |
345 | vtxESD = esdEvent->GetPrimaryVertexTPC(); | |
346 | } | |
e6a60a90 | 347 | if(vtxESD && (vtxESD->GetStatus()<=0)) return; |
348 | ||
7cc34f08 | 349 | // Process events |
350 | for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++) | |
351 | { | |
352 | AliESDtrack *track = esdEvent->GetTrack(iTrack); | |
353 | if(!track) continue; | |
354 | ||
758320f7 | 355 | if(GetAnalysisMode() == 0) ProcessTPC(stack,track,esdEvent); |
356 | else if(GetAnalysisMode() == 1) ProcessTPCITS(stack,track,esdEvent); | |
7cc34f08 | 357 | else if(GetAnalysisMode() == 2) ProcessConstrained(stack,track); |
358 | else { | |
359 | printf("ERROR: AnalysisMode %d \n",fAnalysisMode); | |
360 | return; | |
361 | } | |
362 | } | |
363 | } | |
364 | ||
365 | //_____________________________________________________________________________ | |
366 | void AliPerformanceDCA::Analyse() | |
367 | { | |
368 | // | |
369 | // Analyse comparison information and store output histograms | |
370 | // in the analysis folder "folderDCA" | |
371 | // | |
372 | ||
373 | TH1::AddDirectory(kFALSE); | |
4bb5f8a9 | 374 | TH1F *h1D=0; |
375 | TH2F *h2D=0; | |
7cc34f08 | 376 | TObjArray *aFolderObj = new TObjArray; |
377 | char title[256]; | |
4bb5f8a9 | 378 | TObjArray *arr[6] = {0}; |
379 | TF1 *f1[6] = {0}; | |
7cc34f08 | 380 | |
381 | // set pt measurable range | |
a13f4653 | 382 | //fDCAHisto->GetAxis(3)->SetRangeUser(0.10,10.); |
7cc34f08 | 383 | |
384 | // | |
4bb5f8a9 | 385 | h2D = (TH2F*)fDCAHisto->Projection(0,1); // inverse projection convention |
7cc34f08 | 386 | h2D->SetName("dca_r_vs_dca_z"); |
387 | h2D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(1)->GetTitle()); | |
388 | h2D->GetYaxis()->SetTitle(fDCAHisto->GetAxis(0)->GetTitle()); | |
389 | sprintf(title,"%s vs %s",fDCAHisto->GetAxis(0)->GetTitle(),fDCAHisto->GetAxis(1)->GetTitle()); | |
390 | h2D->SetTitle(title); | |
391 | aFolderObj->Add(h2D); | |
392 | ||
393 | // | |
4bb5f8a9 | 394 | h2D = (TH2F*)fDCAHisto->Projection(0,2); |
7cc34f08 | 395 | h2D->SetName("dca_r_vs_eta"); |
396 | h2D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(2)->GetTitle()); | |
397 | h2D->GetYaxis()->SetTitle(fDCAHisto->GetAxis(0)->GetTitle()); | |
398 | sprintf(title,"%s vs %s",fDCAHisto->GetAxis(2)->GetTitle(),fDCAHisto->GetAxis(0)->GetTitle()); | |
399 | h2D->SetTitle(title); | |
400 | aFolderObj->Add(h2D); | |
401 | ||
4bb5f8a9 | 402 | // |
403 | // mean and rms | |
404 | // | |
7cc34f08 | 405 | h1D = MakeStat1D(h2D,0,0); |
406 | h1D->SetName("mean_dca_r_vs_eta"); | |
407 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(2)->GetTitle()); | |
408 | h1D->GetYaxis()->SetTitle("mean_dca_r (cm)"); | |
409 | sprintf(title," mean_dca_r (cm) vs %s",fDCAHisto->GetAxis(2)->GetTitle()); | |
410 | h1D->SetTitle(title); | |
411 | aFolderObj->Add(h1D); | |
412 | ||
413 | h1D = MakeStat1D(h2D,0,1); | |
414 | h1D->SetName("rms_dca_r_vs_eta"); | |
415 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(2)->GetTitle()); | |
416 | h1D->GetYaxis()->SetTitle("rms_dca_r (cm)"); | |
417 | sprintf(title," rms_dca_r (cm) vs %s",fDCAHisto->GetAxis(2)->GetTitle()); | |
418 | h1D->SetTitle(title); | |
419 | aFolderObj->Add(h1D); | |
420 | ||
421 | // | |
4bb5f8a9 | 422 | // fit mean and sigma |
423 | // | |
424 | ||
425 | arr[0] = new TObjArray(); | |
426 | f1[0] = new TF1("gaus","gaus"); | |
427 | h2D->FitSlicesY(f1[0],0,-1,0,"QNR",arr[0]); | |
428 | ||
429 | h1D = (TH1F*)arr[0]->At(1); | |
430 | h1D->SetName("fit_mean_dca_r_vs_eta"); | |
431 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(2)->GetTitle()); | |
432 | h1D->GetYaxis()->SetTitle("fit_mean_dca_r (cm)"); | |
433 | sprintf(title," fit_mean_dca_r (cm) vs %s",fDCAHisto->GetAxis(2)->GetTitle()); | |
434 | h1D->SetTitle(title); | |
435 | aFolderObj->Add(h1D); | |
436 | ||
437 | h1D = (TH1F*)arr[0]->At(2); | |
438 | h1D->SetName("res_dca_r_vs_eta"); | |
439 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(2)->GetTitle()); | |
440 | h1D->GetYaxis()->SetTitle("res_dca_r (cm)"); | |
441 | sprintf(title," res_dca_r (cm) vs %s",fDCAHisto->GetAxis(2)->GetTitle()); | |
442 | h1D->SetTitle(title); | |
443 | aFolderObj->Add(h1D); | |
444 | ||
445 | // | |
446 | // | |
447 | // | |
448 | h2D = (TH2F*)fDCAHisto->Projection(0,3); | |
7cc34f08 | 449 | h2D->SetName("dca_r_vs_pt"); |
450 | h2D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(3)->GetTitle()); | |
451 | h2D->GetYaxis()->SetTitle(fDCAHisto->GetAxis(0)->GetTitle()); | |
452 | sprintf(title,"%s vs %s",fDCAHisto->GetAxis(0)->GetTitle(),fDCAHisto->GetAxis(3)->GetTitle()); | |
453 | h2D->SetTitle(title); | |
454 | h2D->SetBit(TH1::kLogX); | |
455 | aFolderObj->Add(h2D); | |
456 | ||
457 | h1D = MakeStat1D(h2D,0,0); | |
458 | h1D->SetName("mean_dca_r_vs_pt"); | |
459 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(3)->GetTitle()); | |
460 | h1D->GetYaxis()->SetTitle("mean_dca_r (cm)"); | |
461 | sprintf(title,"mean_dca_r (cm) vs %s",fDCAHisto->GetAxis(3)->GetTitle()); | |
462 | h1D->SetTitle(title); | |
463 | h1D->SetBit(TH1::kLogX); | |
464 | aFolderObj->Add(h1D); | |
465 | ||
466 | h1D = MakeStat1D(h2D,0,1); | |
467 | h1D->SetName("rms_dca_r_vs_pt"); | |
468 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(3)->GetTitle()); | |
469 | h1D->GetYaxis()->SetTitle("rms_dca_r (cm)"); | |
470 | sprintf(title,"rms_dca_r (cm) vs %s",fDCAHisto->GetAxis(3)->GetTitle()); | |
471 | h1D->SetTitle(title); | |
472 | h1D->SetBit(TH1::kLogX); | |
473 | aFolderObj->Add(h1D); | |
474 | ||
4bb5f8a9 | 475 | // |
476 | // fit mean and sigma | |
477 | // | |
478 | ||
479 | arr[1] = new TObjArray(); | |
480 | f1[1] = new TF1("gaus","gaus"); | |
481 | h2D->FitSlicesY(f1[1],0,-1,0,"QNR",arr[1]); | |
482 | ||
483 | h1D = (TH1F*)arr[1]->At(1); | |
484 | h1D->SetName("fit_mean_dca_r_vs_pt"); | |
485 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(3)->GetTitle()); | |
486 | h1D->GetYaxis()->SetTitle("fit_mean_dca_r (cm)"); | |
487 | sprintf(title,"fit_mean_dca_r (cm) vs %s",fDCAHisto->GetAxis(3)->GetTitle()); | |
488 | h1D->SetTitle(title); | |
489 | h1D->SetBit(TH1::kLogX); | |
490 | aFolderObj->Add(h1D); | |
491 | ||
492 | h1D = (TH1F*)arr[1]->At(2); | |
493 | h1D->SetName("res_dca_r_vs_pt"); | |
494 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(3)->GetTitle()); | |
495 | h1D->GetYaxis()->SetTitle("res_dca_r (cm)"); | |
496 | sprintf(title,"res_dca_r (cm) vs %s",fDCAHisto->GetAxis(3)->GetTitle()); | |
497 | h1D->SetTitle(title); | |
498 | h1D->SetBit(TH1::kLogX); | |
499 | aFolderObj->Add(h1D); | |
500 | ||
7cc34f08 | 501 | // |
4bb5f8a9 | 502 | h2D = (TH2F*)fDCAHisto->Projection(1,2); |
7cc34f08 | 503 | h2D->SetName("dca_z_vs_eta"); |
504 | h2D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(2)->GetTitle()); | |
505 | h2D->GetYaxis()->SetTitle(fDCAHisto->GetAxis(1)->GetTitle()); | |
506 | sprintf(title,"%s vs %s",fDCAHisto->GetAxis(1)->GetTitle(),fDCAHisto->GetAxis(2)->GetTitle()); | |
507 | h2D->SetTitle(title); | |
508 | aFolderObj->Add(h2D); | |
509 | ||
510 | h1D = MakeStat1D(h2D,0,0); | |
511 | h1D->SetName("mean_dca_z_vs_eta"); | |
512 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(2)->GetTitle()); | |
513 | h1D->GetYaxis()->SetTitle("mean_dca_z (cm)"); | |
514 | sprintf(title,"mean_dca_z (cm) vs %s",fDCAHisto->GetAxis(2)->GetTitle()); | |
515 | h1D->SetTitle(title); | |
516 | aFolderObj->Add(h1D); | |
517 | ||
518 | h1D = MakeStat1D(h2D,0,1); | |
519 | h1D->SetName("rms_dca_z_vs_eta"); | |
520 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(2)->GetTitle()); | |
521 | h1D->GetYaxis()->SetTitle("rms_dca_z (cm)"); | |
522 | sprintf(title,"rms_dca_z (cm) vs %s",fDCAHisto->GetAxis(2)->GetTitle()); | |
523 | h1D->SetTitle(title); | |
524 | aFolderObj->Add(h1D); | |
525 | ||
526 | // | |
4bb5f8a9 | 527 | // fit mean and sigma |
528 | // | |
529 | arr[2] = new TObjArray(); | |
530 | f1[2] = new TF1("gaus","gaus"); | |
531 | h2D->FitSlicesY(f1[2],0,-1,0,"QNR",arr[2]); | |
532 | ||
533 | h1D = (TH1F*)arr[2]->At(1); | |
534 | h1D->SetName("fit_mean_dca_z_vs_eta"); | |
535 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(2)->GetTitle()); | |
536 | h1D->GetYaxis()->SetTitle("fit_mean_dca_z (cm)"); | |
537 | sprintf(title,"fit_mean_dca_z (cm) vs %s",fDCAHisto->GetAxis(2)->GetTitle()); | |
538 | h1D->SetTitle(title); | |
539 | aFolderObj->Add(h1D); | |
540 | ||
541 | h1D = (TH1F*)arr[2]->At(2); | |
542 | h1D->SetName("res_dca_z_vs_eta"); | |
543 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(2)->GetTitle()); | |
544 | h1D->GetYaxis()->SetTitle("res_dca_z (cm)"); | |
545 | sprintf(title,"res_dca_z (cm) vs %s",fDCAHisto->GetAxis(2)->GetTitle()); | |
546 | h1D->SetTitle(title); | |
547 | aFolderObj->Add(h1D); | |
548 | ||
549 | // | |
550 | h2D = (TH2F*)fDCAHisto->Projection(1,3); | |
7cc34f08 | 551 | h2D->SetName("dca_z_vs_pt"); |
552 | h2D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(3)->GetTitle()); | |
553 | h2D->GetYaxis()->SetTitle(fDCAHisto->GetAxis(1)->GetTitle()); | |
554 | sprintf(title,"%s vs %s",fDCAHisto->GetAxis(1)->GetTitle(),fDCAHisto->GetAxis(3)->GetTitle()); | |
555 | h2D->SetTitle(title); | |
556 | h2D->SetBit(TH1::kLogX); | |
557 | aFolderObj->Add(h2D); | |
558 | ||
559 | h1D = MakeStat1D(h2D,0,0); | |
560 | h1D->SetName("mean_dca_z_vs_pt"); | |
561 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(3)->GetTitle()); | |
562 | h1D->GetYaxis()->SetTitle("mean_dca_z (cm)"); | |
563 | sprintf(title,"mean_dca_z (cm) vs %s",fDCAHisto->GetAxis(3)->GetTitle()); | |
564 | h1D->SetTitle(title); | |
565 | h1D->SetBit(TH1::kLogX); | |
566 | aFolderObj->Add(h1D); | |
567 | ||
568 | h1D = MakeStat1D(h2D,0,1); | |
569 | h1D->SetName("rms_dca_z_vs_pt"); | |
570 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(3)->GetTitle()); | |
571 | h1D->GetYaxis()->SetTitle("rms_dca_z (cm)"); | |
572 | sprintf(title,"rms_dca_z (cm) vs %s",fDCAHisto->GetAxis(3)->GetTitle()); | |
573 | h1D->SetTitle(title); | |
574 | h1D->SetBit(TH1::kLogX); | |
575 | aFolderObj->Add(h1D); | |
576 | ||
4bb5f8a9 | 577 | // |
578 | // fit mean and sigma | |
579 | // | |
580 | ||
581 | arr[3] = new TObjArray(); | |
582 | f1[3] = new TF1("gaus","gaus"); | |
583 | h2D->FitSlicesY(f1[3],0,-1,0,"QNR",arr[3]); | |
584 | ||
585 | h1D = (TH1F*)arr[3]->At(1); | |
586 | h1D->SetName("fit_mean_dca_z_vs_pt"); | |
587 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(3)->GetTitle()); | |
588 | h1D->GetYaxis()->SetTitle("fit_mean_dca_z (cm)"); | |
589 | sprintf(title,"fit_mean_dca_z (cm) vs %s",fDCAHisto->GetAxis(3)->GetTitle()); | |
590 | h1D->SetTitle(title); | |
591 | h1D->SetBit(TH1::kLogX); | |
592 | aFolderObj->Add(h1D); | |
593 | ||
594 | h1D = (TH1F*)arr[3]->At(2); | |
595 | h1D->SetName("res_dca_z_vs_pt"); | |
596 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(3)->GetTitle()); | |
597 | h1D->GetYaxis()->SetTitle("res_dca_z (cm)"); | |
598 | sprintf(title,"res_dca_z (cm) vs %s",fDCAHisto->GetAxis(3)->GetTitle()); | |
599 | h1D->SetTitle(title); | |
600 | h1D->SetBit(TH1::kLogX); | |
601 | aFolderObj->Add(h1D); | |
602 | ||
886bf4d3 | 603 | // A - side |
604 | fDCAHisto->GetAxis(2)->SetRangeUser(-1.5,0.0); | |
7cc34f08 | 605 | |
4bb5f8a9 | 606 | h2D = (TH2F*)fDCAHisto->Projection(1,4); |
607 | h2D->SetName("dca_z_vs_phi_Aside"); | |
886bf4d3 | 608 | h2D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(4)->GetTitle()); |
609 | h2D->GetYaxis()->SetTitle(fDCAHisto->GetAxis(1)->GetTitle()); | |
610 | sprintf(title,"%s vs %s (A-side)",fDCAHisto->GetAxis(1)->GetTitle(),fDCAHisto->GetAxis(4)->GetTitle()); | |
7cc34f08 | 611 | h2D->SetTitle(title); |
612 | aFolderObj->Add(h2D); | |
613 | ||
886bf4d3 | 614 | h1D = MakeStat1D(h2D,0,0); |
4bb5f8a9 | 615 | h1D->SetName("mean_dca_z_vs_phi_Aside"); |
886bf4d3 | 616 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(4)->GetTitle()); |
617 | h1D->GetYaxis()->SetTitle("mean_dca_z (cm)"); | |
618 | sprintf(title,"mean_dca_z (cm) vs %s (A-side)",fDCAHisto->GetAxis(4)->GetTitle()); | |
619 | h1D->SetTitle(title); | |
620 | aFolderObj->Add(h1D); | |
7cc34f08 | 621 | |
886bf4d3 | 622 | h1D = MakeStat1D(h2D,0,1); |
4bb5f8a9 | 623 | h1D->SetName("rms_dca_z_vs_phi_Aside"); |
886bf4d3 | 624 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(4)->GetTitle()); |
625 | h1D->GetYaxis()->SetTitle("rms_dca_z (cm)"); | |
626 | sprintf(title,"rms_dca_z (cm) vs %s (A-side)",fDCAHisto->GetAxis(4)->GetTitle()); | |
627 | h1D->SetTitle(title); | |
628 | aFolderObj->Add(h1D); | |
629 | ||
4bb5f8a9 | 630 | // |
631 | // fit mean and sigma | |
632 | // | |
633 | arr[4] = new TObjArray(); | |
634 | f1[4] = new TF1("gaus","gaus"); | |
635 | h2D->FitSlicesY(f1[4],0,-1,0,"QNR",arr[4]); | |
636 | ||
637 | h1D = (TH1F*)arr[4]->At(1); | |
638 | h1D->SetName("fit_mean_dca_z_vs_phi_Aside"); | |
639 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(4)->GetTitle()); | |
640 | h1D->GetYaxis()->SetTitle("fit_mean_dca_z (cm)"); | |
641 | sprintf(title,"fit_mean_dca_z (cm) vs %s (A-side)",fDCAHisto->GetAxis(4)->GetTitle()); | |
642 | h1D->SetTitle(title); | |
643 | aFolderObj->Add(h1D); | |
644 | ||
645 | h1D = (TH1F*)arr[4]->At(2); | |
646 | h1D->SetName("res_dca_z_vs_phi_Aside"); | |
647 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(4)->GetTitle()); | |
648 | h1D->GetYaxis()->SetTitle("res_dca_z (cm)"); | |
649 | sprintf(title,"res_dca_z (cm) vs %s (A-side)",fDCAHisto->GetAxis(4)->GetTitle()); | |
650 | h1D->SetTitle(title); | |
651 | aFolderObj->Add(h1D); | |
652 | ||
653 | ||
886bf4d3 | 654 | // C - side |
655 | fDCAHisto->GetAxis(2)->SetRangeUser(0.0,1.5); | |
7cc34f08 | 656 | |
4bb5f8a9 | 657 | h2D = (TH2F*)fDCAHisto->Projection(1,4); |
658 | h2D->SetName("dca_z_vs_phi_Cside"); | |
886bf4d3 | 659 | h2D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(4)->GetTitle()); |
660 | h2D->GetYaxis()->SetTitle(fDCAHisto->GetAxis(1)->GetTitle()); | |
661 | sprintf(title,"%s vs %s (C-side)",fDCAHisto->GetAxis(1)->GetTitle(),fDCAHisto->GetAxis(4)->GetTitle()); | |
7cc34f08 | 662 | h2D->SetTitle(title); |
663 | aFolderObj->Add(h2D); | |
664 | ||
886bf4d3 | 665 | h1D = MakeStat1D(h2D,0,0); |
4bb5f8a9 | 666 | h1D->SetName("mean_dca_z_vs_phi_Cside"); |
886bf4d3 | 667 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(4)->GetTitle()); |
668 | h1D->GetYaxis()->SetTitle("mean_dca_z (cm)"); | |
669 | sprintf(title,"mean_dca_z (cm) vs %s (C-side)",fDCAHisto->GetAxis(4)->GetTitle()); | |
670 | h1D->SetTitle(title); | |
671 | aFolderObj->Add(h1D); | |
672 | ||
673 | h1D = MakeStat1D(h2D,0,1); | |
4bb5f8a9 | 674 | h1D->SetName("rms_dca_z_vs_phi_Cside"); |
886bf4d3 | 675 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(4)->GetTitle()); |
676 | h1D->GetYaxis()->SetTitle("rms_dca_z (cm)"); | |
677 | sprintf(title,"rms_dca_z (cm) vs %s (C-side)",fDCAHisto->GetAxis(4)->GetTitle()); | |
678 | h1D->SetTitle(title); | |
679 | aFolderObj->Add(h1D); | |
886bf4d3 | 680 | |
4bb5f8a9 | 681 | // |
682 | // fit mean and sigma | |
683 | // | |
684 | arr[5] = new TObjArray(); | |
685 | f1[5] = new TF1("gaus","gaus"); | |
686 | h2D->FitSlicesY(f1[5],0,-1,0,"QNR",arr[5]); | |
687 | ||
688 | h1D = (TH1F*)arr[5]->At(1); | |
689 | h1D->SetName("fit_mean_dca_z_vs_phi_Cside"); | |
690 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(4)->GetTitle()); | |
691 | h1D->GetYaxis()->SetTitle("fit_mean_dca_z (cm)"); | |
692 | sprintf(title,"fit_mean_dca_z (cm) vs %s (C-side)",fDCAHisto->GetAxis(4)->GetTitle()); | |
693 | h1D->SetTitle(title); | |
694 | aFolderObj->Add(h1D); | |
7cc34f08 | 695 | |
4bb5f8a9 | 696 | h1D = (TH1F*)arr[5]->At(2); |
697 | h1D->SetName("res_dca_z_vs_phi_Cside"); | |
698 | h1D->GetXaxis()->SetTitle(fDCAHisto->GetAxis(4)->GetTitle()); | |
699 | h1D->GetYaxis()->SetTitle("res_dca_z (cm)"); | |
700 | sprintf(title,"res_dca_z (cm) vs %s (C-side)",fDCAHisto->GetAxis(4)->GetTitle()); | |
701 | h1D->SetTitle(title); | |
702 | aFolderObj->Add(h1D); | |
703 | ||
7cc34f08 | 704 | // export objects to analysis folder |
705 | fAnalysisFolder = ExportToFolder(aFolderObj); | |
706 | ||
707 | // delete only TObjArray | |
708 | if(aFolderObj) delete aFolderObj; | |
709 | } | |
710 | ||
711 | //_____________________________________________________________________________ | |
712 | TH1F* AliPerformanceDCA::MakeStat1D(TH2 *hist, Int_t delta0, Int_t type) | |
713 | { | |
714 | // Return TH1F histogram | |
715 | // delta - number of bins to integrate | |
716 | // with mean (type == 0) or RMS (type==1) | |
717 | ||
718 | char hname[256]; | |
719 | const char* suffix = "_stat1d"; | |
720 | sprintf(hname,"%s%s",hist->GetName(),suffix); | |
721 | TAxis* xaxis = hist->GetXaxis(); | |
722 | Int_t nbinx = xaxis->GetNbins(); | |
723 | ||
724 | TH1F *hnew = (TH1F*)hist->ProjectionX()->Clone(); | |
725 | hnew->SetName(hname); | |
726 | ||
727 | char name[256]; | |
728 | for (Int_t ix=0; ix<=nbinx;ix++) { | |
729 | sprintf(name,"%s_%d",hist->GetName(),ix); | |
730 | TH1 *projection = hist->ProjectionY(name,ix-delta0,ix+delta0); | |
731 | ||
732 | Float_t stat= 0., stat_err =0.; | |
733 | if (type==0) { stat = projection->GetMean(); stat_err = projection->GetMeanError(); } | |
734 | if (type==1) { stat = projection->GetRMS(); stat_err = projection->GetRMSError(); } | |
735 | ||
736 | hnew->SetBinContent(ix, stat); | |
737 | hnew->SetBinError(ix, stat_err); | |
738 | } | |
739 | ||
740 | return hnew; | |
741 | } | |
742 | ||
743 | //_____________________________________________________________________________ | |
744 | TH2F* AliPerformanceDCA::MakeStat2D(TH3 *hist, Int_t delta0, Int_t delta1, Int_t type) | |
745 | { | |
746 | // Return TH1F histogram | |
747 | // delta0 - number of bins to integrate in x | |
748 | // delta1 - number of bins to integrate in y | |
749 | // with mean (type==0) or RMS (type==1) | |
750 | ||
751 | char hname[256]; | |
752 | const char* suffix = "_stat2d"; | |
753 | sprintf(hname,"%s%s",hist->GetName(),suffix); | |
754 | ||
755 | TAxis* xaxis = hist->GetXaxis(); | |
756 | Int_t nbinx = xaxis->GetNbins(); | |
757 | ||
758 | TH2F *hnew = (TH2F*)hist->Project3D("yx")->Clone(); | |
759 | hnew->SetName(hname); | |
760 | ||
761 | TAxis* yaxis = hist->GetYaxis(); | |
762 | Int_t nbiny = yaxis->GetNbins(); | |
763 | ||
764 | char name[256]; | |
765 | for (Int_t ix=0; ix<=nbinx;ix++) { | |
766 | for (Int_t iy=0; iy<=nbiny;iy++) { | |
767 | sprintf(name,"%s_%d_%d",hist->GetName(),ix,iy); | |
768 | TH1 *projection = hist->ProjectionZ(name,ix-delta0,ix+delta0,iy-delta1,iy+delta1); | |
769 | ||
770 | Float_t stat= 0., stat_err =0.; | |
771 | if (type==0) { stat = projection->GetMean(); stat_err = projection->GetMeanError(); } | |
772 | if (type==1) { stat = projection->GetRMS(); stat_err = projection->GetRMSError(); } | |
773 | ||
774 | hnew->SetBinContent(ix,iy,stat); | |
775 | hnew->SetBinError(ix,iy,stat_err); | |
776 | } | |
777 | } | |
778 | ||
779 | return hnew; | |
780 | } | |
781 | ||
782 | //_____________________________________________________________________________ | |
783 | TFolder* AliPerformanceDCA::ExportToFolder(TObjArray * array) | |
784 | { | |
785 | // recreate folder avery time and export objects to new one | |
786 | // | |
787 | AliPerformanceDCA * comp=this; | |
788 | TFolder *folder = comp->GetAnalysisFolder(); | |
789 | ||
790 | TString name, title; | |
791 | TFolder *newFolder = 0; | |
792 | Int_t i = 0; | |
793 | Int_t size = array->GetSize(); | |
794 | ||
795 | if(folder) { | |
796 | // get name and title from old folder | |
797 | name = folder->GetName(); | |
798 | title = folder->GetTitle(); | |
799 | ||
800 | // delete old one | |
801 | delete folder; | |
802 | ||
803 | // create new one | |
804 | newFolder = CreateFolder(name.Data(),title.Data()); | |
805 | newFolder->SetOwner(); | |
806 | ||
807 | // add objects to folder | |
808 | while(i < size) { | |
809 | newFolder->Add(array->At(i)); | |
810 | i++; | |
811 | } | |
812 | } | |
813 | ||
814 | return newFolder; | |
815 | } | |
816 | ||
817 | //_____________________________________________________________________________ | |
818 | TFolder* AliPerformanceDCA::CreateFolder(TString name,TString title) { | |
819 | // create folder for analysed histograms | |
820 | TFolder *folder = 0; | |
821 | folder = new TFolder(name.Data(),title.Data()); | |
822 | ||
823 | return folder; | |
824 | } |