]>
Commit | Line | Data |
---|---|---|
0aaa8b91 | 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 | **************************************************************************/ | |
f2dec884 | 15 | // |
16 | // static dNdPt helper functions | |
17 | // | |
18 | // basic functionality to select events and tracks | |
19 | // for dNdPt analysis | |
20 | // | |
21 | // Origin: Jan Fiete Grosse-Oetringhaus | |
22 | // Modified and Extended: Jacek Otwinowski 19/11/2009 | |
23 | // | |
24 | // | |
0aaa8b91 | 25 | |
26 | #include <TROOT.h> | |
f2dec884 | 27 | #include <TCanvas.h> |
28 | #include <TF1.h> | |
0aaa8b91 | 29 | #include <TH1.h> |
30 | #include <TH2.h> | |
31 | #include <TH3.h> | |
0aaa8b91 | 32 | |
33 | #include <AliHeader.h> | |
34 | #include <AliStack.h> | |
35 | #include <AliLog.h> | |
0aaa8b91 | 36 | #include <AliESD.h> |
37 | #include <AliESDEvent.h> | |
38 | #include <AliMCEvent.h> | |
39 | #include <AliESDVertex.h> | |
40 | #include <AliVertexerTracks.h> | |
0aaa8b91 | 41 | #include <AliMathBase.h> |
42 | #include <AliESDtrackCuts.h> | |
774986ef | 43 | #include <AliTracker.h> |
0aaa8b91 | 44 | #include "dNdPt/AlidNdPtEventCuts.h" |
45 | #include "dNdPt/AlidNdPtAcceptanceCuts.h" | |
46 | #include "dNdPt/AlidNdPtHelper.h" | |
47 | ||
48 | //____________________________________________________________________ | |
49 | ClassImp(AlidNdPtHelper) | |
50 | ||
0aaa8b91 | 51 | //____________________________________________________________________ |
e9f7cb15 | 52 | const AliESDVertex* AlidNdPtHelper::GetVertex(AliESDEvent* const aEsd, const AlidNdPtEventCuts *const evtCuts, const AlidNdPtAcceptanceCuts *const accCuts, const AliESDtrackCuts *const trackCuts, AnalysisMode analysisMode, Bool_t debug, Bool_t bRedoTPC, Bool_t bUseMeanVertex) |
0aaa8b91 | 53 | { |
54 | // Get the vertex from the ESD and returns it if the vertex is valid | |
55 | // | |
56 | // Second argument decides which vertex is used (this selects | |
57 | // also the quality criteria that are applied) | |
58 | ||
59 | if(!aEsd) | |
60 | { | |
61 | ::Error("AlidNdPtHelper::GetVertex()","esd event is NULL"); | |
62 | return NULL; | |
63 | } | |
64 | ||
65 | if(!evtCuts || !accCuts || !trackCuts) | |
66 | { | |
67 | ::Error("AlidNdPtHelper::GetVertex()","cuts not available"); | |
68 | return NULL; | |
69 | } | |
70 | ||
71 | const AliESDVertex* vertex = 0; | |
72 | AliESDVertex *initVertex = 0; | |
24c88fc4 | 73 | if (analysisMode == kSPD || |
774986ef | 74 | analysisMode == kTPCSPDvtx || analysisMode == kTPCSPDvtxUpdate || analysisMode == kTPCITSHybrid) |
0aaa8b91 | 75 | { |
76 | vertex = aEsd->GetPrimaryVertexSPD(); | |
77 | if (debug) | |
78 | Printf("AlidNdPtHelper::GetVertex: Returning SPD vertex"); | |
24c88fc4 | 79 | } |
80 | else if (analysisMode == kTPCITS || analysisMode == kTPCTrackSPDvtx || analysisMode == kTPCTrackSPDvtxUpdate || | |
695facdf | 81 | analysisMode == kTPCITSHybridTrackSPDvtx || analysisMode == kTPCITSHybridTrackSPDvtxDCArPt || |
82 | analysisMode == kITSStandAloneTrackSPDvtx || analysisMode == kITSStandAloneTPCTrackSPDvtx) | |
791aaf54 | 83 | { |
84 | vertex = aEsd->GetPrimaryVertexTracks(); | |
85 | if(!vertex) return NULL; | |
86 | if(vertex->GetNContributors()<1) { | |
87 | // SPD vertex | |
88 | vertex = aEsd->GetPrimaryVertexSPD(); | |
89 | } | |
90 | } | |
847e74b2 | 91 | else if (analysisMode == kTPC) |
0aaa8b91 | 92 | { |
93 | if(bRedoTPC) { | |
94 | ||
95 | Double_t kBz = aEsd->GetMagneticField(); | |
96 | AliVertexerTracks vertexer(kBz); | |
97 | ||
98 | if(bUseMeanVertex) { | |
99 | Double_t pos[3]={evtCuts->GetMeanXv(),evtCuts->GetMeanYv(),evtCuts->GetMeanZv()}; | |
100 | Double_t err[3]={evtCuts->GetSigmaMeanXv(),evtCuts->GetSigmaMeanYv(),evtCuts->GetSigmaMeanZv()}; | |
0aaa8b91 | 101 | initVertex = new AliESDVertex(pos,err); |
102 | vertexer.SetVtxStart(initVertex); | |
103 | vertexer.SetConstraintOn(); | |
104 | } | |
105 | ||
0aaa8b91 | 106 | Double_t maxDCAr = accCuts->GetMaxDCAr(); |
107 | Double_t maxDCAz = accCuts->GetMaxDCAz(); | |
108 | Int_t minTPCClust = trackCuts->GetMinNClusterTPC(); | |
109 | ||
bad4ba69 | 110 | //vertexer.SetTPCMode(Double_t dcacut=0.1, Double_t dcacutIter0=1.0, Double_t maxd0z0=5.0, Int_t minCls=10, Int_t mintrks=1, Double_t nsigma=3., Double_t mindetfitter=0.1, Double_t maxtgl=1.5, Double_t fidR=3., Double_t fidZ=30., Int_t finderAlgo=1, Int_t finderAlgoIter0=4); |
0aaa8b91 | 111 | vertexer.SetTPCMode(0.1,1.0,5.0,minTPCClust,1,3.,0.1,2.0,maxDCAr,maxDCAz,1,4); |
112 | ||
113 | // TPC track preselection | |
114 | Int_t ntracks = aEsd->GetNumberOfTracks(); | |
115 | TObjArray array(ntracks); | |
116 | UShort_t *id = new UShort_t[ntracks]; | |
117 | ||
118 | Int_t count=0; | |
119 | for (Int_t i=0;i <ntracks; i++) { | |
120 | AliESDtrack *t = aEsd->GetTrack(i); | |
121 | if (!t) continue; | |
122 | if (t->Charge() == 0) continue; | |
123 | if (!t->GetTPCInnerParam()) continue; | |
124 | if (t->GetTPCNcls()<vertexer.GetMinClusters()) continue; | |
125 | AliExternalTrackParam *tpcTrack = new AliExternalTrackParam(*(t->GetTPCInnerParam())); | |
126 | if(tpcTrack) { | |
127 | array.AddLast(tpcTrack); | |
128 | id[count] = (UShort_t)t->GetID(); | |
129 | count++; | |
130 | } | |
131 | } | |
132 | AliESDVertex *vTPC = vertexer.VertexForSelectedTracks(&array,id, kTRUE, kTRUE, bUseMeanVertex); | |
bad4ba69 | 133 | |
134 | // set recreated TPC vertex | |
0aaa8b91 | 135 | aEsd->SetPrimaryVertexTPC(vTPC); |
136 | ||
137 | for (Int_t i=0; i<aEsd->GetNumberOfTracks(); i++) { | |
138 | AliESDtrack *t = aEsd->GetTrack(i); | |
774986ef | 139 | if(!t) continue; |
140 | ||
141 | Double_t x[3]; t->GetXYZ(x); | |
142 | Double_t b[3]; AliTracker::GetBxByBz(x,b); | |
143 | t->RelateToVertexTPCBxByBz(vTPC, b, kVeryBig); | |
0aaa8b91 | 144 | } |
145 | ||
146 | delete vTPC; | |
147 | array.Delete(); | |
148 | delete [] id; id=NULL; | |
149 | ||
150 | } | |
151 | vertex = aEsd->GetPrimaryVertexTPC(); | |
152 | if (debug) | |
774986ef | 153 | Printf("AlidNdPtHelper::GetVertex: Returning vertex from tracks"); |
154 | } | |
155 | else | |
156 | Printf("AlidNdPtHelper::GetVertex: ERROR: Invalid second argument %d", analysisMode); | |
0aaa8b91 | 157 | |
158 | if (!vertex) { | |
159 | if (debug) | |
160 | Printf("AlidNdPtHelper::GetVertex: No vertex found in ESD"); | |
161 | return 0; | |
162 | } | |
163 | ||
164 | if (debug) | |
165 | { | |
166 | Printf("AlidNdPtHelper::GetVertex: Returning valid vertex: %s", vertex->GetTitle()); | |
167 | vertex->Print(); | |
168 | } | |
169 | ||
170 | if(initVertex) delete initVertex; initVertex=NULL; | |
171 | return vertex; | |
172 | } | |
173 | ||
bad4ba69 | 174 | //____________________________________________________________________ |
791aaf54 | 175 | Bool_t AlidNdPtHelper::TestRecVertex(const AliESDVertex* vertex, const AliESDVertex* vertexSPD, AnalysisMode analysisMode, Bool_t debug) |
bad4ba69 | 176 | { |
177 | // Checks if a vertex meets the needed quality criteria | |
178 | if(!vertex) return kFALSE; | |
774986ef | 179 | if(!vertex->GetStatus()) return kFALSE; |
bad4ba69 | 180 | |
181 | Float_t requiredZResolution = -1; | |
774986ef | 182 | if (analysisMode == kSPD || analysisMode == kTPCITS || |
791aaf54 | 183 | analysisMode == kTPCSPDvtx || analysisMode == kTPCSPDvtxUpdate || analysisMode == kTPCITSHybrid || |
184 | analysisMode == kTPCTrackSPDvtx || analysisMode == kTPCTrackSPDvtxUpdate || analysisMode == kTPCITSHybridTrackSPDvtx || analysisMode == kTPCITSHybridTrackSPDvtxDCArPt | |
695facdf | 185 | || analysisMode == kITSStandAloneTrackSPDvtx || analysisMode == kITSStandAloneTPCTrackSPDvtx) |
bad4ba69 | 186 | { |
774986ef | 187 | requiredZResolution = 1000; |
bad4ba69 | 188 | } |
847e74b2 | 189 | else if (analysisMode == kTPC) |
bad4ba69 | 190 | requiredZResolution = 10.; |
191 | ||
774986ef | 192 | // check resolution |
193 | Double_t zRes = vertex->GetZRes(); | |
194 | ||
195 | if (zRes > requiredZResolution) { | |
196 | if (debug) | |
197 | Printf("AlidNdPtHelper::TestVertex: Resolution too poor %f (required: %f", zRes, requiredZResolution); | |
198 | return kFALSE; | |
199 | } | |
791aaf54 | 200 | |
201 | // always check for SPD vertex | |
202 | if(!vertexSPD) return kFALSE; | |
203 | if(!vertexSPD->GetStatus()) return kFALSE; | |
204 | if (vertexSPD->IsFromVertexerZ()) | |
774986ef | 205 | { |
791aaf54 | 206 | if (vertexSPD->GetDispersion() > 0.02) |
774986ef | 207 | { |
208 | if (debug) | |
209 | Printf("AliPWG0Helper::TestVertex: Delta Phi too large in Vertexer Z: %f (required: %f", vertex->GetDispersion(), 0.02); | |
210 | return kFALSE; | |
211 | } | |
212 | } | |
213 | ||
bad4ba69 | 214 | |
215 | return kTRUE; | |
216 | } | |
217 | ||
791aaf54 | 218 | //____________________________________________________________________ |
e9f7cb15 | 219 | Bool_t AlidNdPtHelper::IsGoodImpPar(const AliESDtrack *const track) |
791aaf54 | 220 | { |
221 | // | |
222 | // check whether particle has good DCAr(Pt) impact | |
223 | // parameter. Only for TPC+ITS tracks (7*sigma cut) | |
224 | // Origin: Andrea Dainese | |
225 | // | |
226 | ||
227 | Float_t d0z0[2],covd0z0[3]; | |
228 | track->GetImpactParameters(d0z0,covd0z0); | |
229 | Float_t sigma= 0.0050+0.0060/TMath::Power(track->Pt(),0.9); | |
230 | Float_t d0max = 7.*sigma; | |
231 | if(TMath::Abs(d0z0[0]) < d0max) return kTRUE; | |
232 | ||
233 | return kFALSE; | |
234 | } | |
235 | ||
0aaa8b91 | 236 | //____________________________________________________________________ |
f2dec884 | 237 | Bool_t AlidNdPtHelper::IsPrimaryParticle(AliStack* const stack, Int_t idx, ParticleMode particleMode) |
0aaa8b91 | 238 | { |
774986ef | 239 | // |
0aaa8b91 | 240 | // check primary particles |
847e74b2 | 241 | // depending on the particle mode |
0aaa8b91 | 242 | // |
243 | if(!stack) return kFALSE; | |
244 | ||
245 | TParticle* particle = stack->Particle(idx); | |
246 | if (!particle) return kFALSE; | |
247 | ||
248 | // only charged particles | |
249 | Double_t charge = particle->GetPDG()->Charge()/3.; | |
f2dec884 | 250 | if (TMath::Abs(charge) < 0.001) return kFALSE; |
0aaa8b91 | 251 | |
252 | Int_t pdg = TMath::Abs(particle->GetPdgCode()); | |
253 | ||
254 | // physical primary | |
255 | Bool_t prim = stack->IsPhysicalPrimary(idx); | |
256 | ||
847e74b2 | 257 | if(particleMode==kMCPion) { |
0aaa8b91 | 258 | if(prim && pdg==kPiPlus) return kTRUE; |
259 | else return kFALSE; | |
260 | } | |
261 | ||
847e74b2 | 262 | if (particleMode==kMCKaon) { |
0aaa8b91 | 263 | if(prim && pdg==kKPlus) return kTRUE; |
264 | else return kFALSE; | |
265 | } | |
266 | ||
847e74b2 | 267 | if (particleMode==kMCProton) { |
0aaa8b91 | 268 | if(prim && pdg==kProton) return kTRUE; |
269 | else return kFALSE; | |
270 | } | |
271 | ||
17e8c701 | 272 | if(particleMode==kMCRest) { |
273 | if(prim && pdg!=kPiPlus && pdg!=kKPlus && pdg!=kProton) return kTRUE; | |
274 | else return kFALSE; | |
275 | } | |
276 | ||
0aaa8b91 | 277 | return prim; |
278 | } | |
279 | ||
d269b0e6 | 280 | //____________________________________________________________________ |
f2dec884 | 281 | Bool_t AlidNdPtHelper::IsCosmicTrack(AliESDtrack *const track1, AliESDtrack *const track2) |
d269b0e6 | 282 | { |
283 | // | |
284 | // check cosmic tracks | |
285 | // | |
286 | if(!track1) return kFALSE; | |
287 | if(!track2) return kFALSE; | |
d269b0e6 | 288 | |
774986ef | 289 | // |
290 | // cosmic tracks in TPC | |
291 | // | |
292 | //if( TMath::Abs( track1->Theta() - track2->Theta() ) < 0.004 && | |
293 | // ((TMath::Abs(track1->Phi()-track2->Phi()) - TMath::Pi() )<0.004) && | |
294 | //if( track1->Pt() > 4.0 && (TMath::Abs(track1->Phi()-track2->Phi())-TMath::Pi())<0.1 | |
295 | // && (TMath::Abs(track1->Eta()+track2->Eta())-0.1) < 0.0 && (track1->Charge()+track2->Charge()) == 0) | |
296 | ||
297 | //Float_t scaleF= 6.0; | |
298 | if ( track1->Pt() > 4 && track2->Pt() > 4 && | |
299 | //(TMath::Abs(track1->GetSnp()-track2->GetSnp())-2.) < scaleF * TMath::Sqrt(track1->GetSigmaSnp2()+track2->GetSigmaSnp2()) && | |
300 | //TMath::Abs(track1->GetTgl()-track2->GetTgl()) < scaleF * TMath::Sqrt(track1->GetSigmaTgl2()+track2->GetSigmaTgl2()) && | |
301 | //TMath::Abs(track1->OneOverPt()-track2->OneOverPt()) < scaleF * TMath::Sqrt(track1->GetSigma1Pt2()+track2->GetSigma1Pt2()) && | |
302 | (track1->Charge()+track2->Charge()) == 0 && | |
303 | track1->Eta()*track2->Eta()<0.0 && TMath::Abs(track1->Eta()+track2->Eta())<0.03 && | |
304 | TMath::Abs(TMath::Abs(track1->Phi()-track2->Phi())-TMath::Pi())<0.1 | |
305 | ) | |
d269b0e6 | 306 | { |
774986ef | 307 | printf("COSMIC candidate \n"); |
d269b0e6 | 308 | |
774986ef | 309 | printf("track1->Pt() %f, track1->Theta() %f, track1->Eta() %f, track1->Phi() %f, track1->Charge() %d \n", track1->Pt(), track1->Theta(), track1->Eta(), track1->Phi(), track1->Charge()); |
310 | printf("track2->Pt() %f, track2->Theta() %f, track2->Eta() %f, track2->Phi() %f, track2->Charge() %d \n", track2->Pt(), track2->Theta(), track2->Eta(), track2->Phi(), track2->Charge()); | |
311 | printf("dtheta %f, deta %f, dphi %f, dq %d \n", track1->Theta()-track2->Theta(), track1->Eta()-track2->Eta(), track1->Phi()-track2->Phi(), track1->Charge()+track2->Charge()); | |
312 | printf("dsphi %f, errsphi %f, dtanl %f, errtanl %f \n", TMath::Abs(track1->GetSnp()-track2->GetSnp()), TMath::Sqrt(track1->GetSigmaSnp2()+track2->GetSigmaSnp2()), TMath::Abs(track1->GetTgl()-track2->GetTgl()), TMath::Sqrt(track1->GetSigmaTgl2()+track2->GetSigmaTgl2())); | |
313 | return kTRUE; | |
314 | } | |
847e74b2 | 315 | |
316 | return kFALSE; | |
317 | } | |
318 | ||
0aaa8b91 | 319 | //____________________________________________________________________ |
70fdd197 | 320 | void AlidNdPtHelper::PrintConf(AnalysisMode analysisMode, AliTriggerAnalysis::Trigger trigger) |
0aaa8b91 | 321 | { |
322 | // | |
323 | // Prints the given configuration | |
324 | // | |
325 | ||
326 | TString str(">>>> Running with "); | |
327 | ||
328 | switch (analysisMode) | |
329 | { | |
330 | case kInvalid: str += "invalid setting"; break; | |
331 | case kSPD : str += "SPD-only"; break; | |
332 | case kTPC : str += "TPC-only"; break; | |
333 | case kTPCITS : str += "Global tracking"; break; | |
334 | case kTPCSPDvtx : str += "TPC tracking + SPD event vertex"; break; | |
847e74b2 | 335 | case kTPCSPDvtxUpdate : str += "TPC tracks updated with SPD event vertex point"; break; |
791aaf54 | 336 | case kTPCTrackSPDvtx : str += "TPC tracking + Tracks event vertex or SPD event vertex"; break; |
337 | case kTPCTrackSPDvtxUpdate : str += "TPC tracks updated with Track or SPD event vertex point"; break; | |
774986ef | 338 | case kTPCITSHybrid : str += "TPC tracking + ITS refit + >1 SPD cluster"; break; |
791aaf54 | 339 | case kTPCITSHybridTrackSPDvtx : str += "TPC tracking + ITS refit + >1 SPD cluster + Tracks event vertex or SPD event vertex"; break; |
340 | case kTPCITSHybridTrackSPDvtxDCArPt : str += "TPC tracking + ITS refit + >1 SPD cluster + Tracks event vertex or SPD event vertex + DCAr(pt)"; break; | |
695facdf | 341 | case kITSStandAloneTrackSPDvtx : str += "ITS standalone + Tracks event vertex or SPD event vertex + DCAr(pt)"; break; |
342 | case kITSStandAloneTPCTrackSPDvtx : str += "kITSStandAloneTPCTrackSPDvtx + TPC stand alone track + Tracks event vertex or SPD event vertex + DCAr(pt)"; break; | |
0aaa8b91 | 343 | case kMCRec : str += "TPC tracking + Replace rec. with MC values"; break; |
0aaa8b91 | 344 | } |
345 | str += " and trigger "; | |
346 | ||
70fdd197 | 347 | str += AliTriggerAnalysis::GetTriggerName(trigger); |
0aaa8b91 | 348 | |
349 | str += " <<<<"; | |
350 | ||
351 | Printf("%s", str.Data()); | |
352 | } | |
353 | ||
354 | //____________________________________________________________________ | |
e9f7cb15 | 355 | Int_t AlidNdPtHelper::ConvertPdgToPid(const TParticle *const particle) { |
0aaa8b91 | 356 | // |
357 | // Convert Abs(pdg) to pid | |
358 | // (0 - e, 1 - muons, 2 - pions, 3 - kaons, 4 - protons, 5 -all rest) | |
359 | // | |
360 | Int_t pid=-1; | |
361 | ||
362 | if (TMath::Abs(particle->GetPdgCode()) == kElectron) { pid = 0; } | |
363 | else if (TMath::Abs(particle->GetPdgCode()) == kMuonMinus) { pid = 1; } | |
364 | else if (TMath::Abs(particle->GetPdgCode()) == kPiPlus) { pid = 2; } | |
365 | else if (TMath::Abs(particle->GetPdgCode()) == kKPlus) { pid = 3; } | |
366 | else if (TMath::Abs(particle->GetPdgCode()) == kProton) { pid = 4; } | |
367 | else { pid = 5; } | |
368 | ||
369 | return pid; | |
370 | } | |
371 | ||
372 | //_____________________________________________________________________________ | |
f2dec884 | 373 | TH1F* AlidNdPtHelper::CreateResHisto(TH2F* const hRes2, TH1F **phMean, Int_t integ, Bool_t drawBinFits, Int_t minHistEntries) |
0aaa8b91 | 374 | { |
bad4ba69 | 375 | // |
376 | // Create mean and resolution | |
377 | // histograms | |
378 | // | |
0aaa8b91 | 379 | TVirtualPad* currentPad = gPad; |
380 | TAxis* axis = hRes2->GetXaxis(); | |
381 | Int_t nBins = axis->GetNbins(); | |
382 | Bool_t overflowBinFits = kFALSE; | |
383 | TH1F* hRes, *hMean; | |
384 | if (axis->GetXbins()->GetSize()){ | |
385 | hRes = new TH1F("hRes", "", nBins, axis->GetXbins()->GetArray()); | |
386 | hMean = new TH1F("hMean", "", nBins, axis->GetXbins()->GetArray()); | |
387 | } | |
388 | else{ | |
389 | hRes = new TH1F("hRes", "", nBins, axis->GetXmin(), axis->GetXmax()); | |
390 | hMean = new TH1F("hMean", "", nBins, axis->GetXmin(), axis->GetXmax()); | |
391 | ||
392 | } | |
393 | hRes->SetStats(false); | |
394 | hRes->SetOption("E"); | |
395 | hRes->SetMinimum(0.); | |
396 | // | |
397 | hMean->SetStats(false); | |
398 | hMean->SetOption("E"); | |
399 | ||
400 | // create the fit function | |
401 | TF1 * fitFunc = new TF1("G","[0]*exp(-(x-[1])*(x-[1])/(2.*[2]*[2]))",-3,3); | |
402 | ||
403 | fitFunc->SetLineWidth(2); | |
404 | fitFunc->SetFillStyle(0); | |
405 | // create canvas for fits | |
406 | TCanvas* canBinFits = NULL; | |
407 | Int_t nPads = (overflowBinFits) ? nBins+2 : nBins; | |
408 | Int_t nx = Int_t(sqrt(nPads-1.));// + 1; | |
409 | Int_t ny = (nPads-1) / nx + 1; | |
410 | if (drawBinFits) { | |
411 | canBinFits = (TCanvas*)gROOT->FindObject("canBinFits"); | |
412 | if (canBinFits) delete canBinFits; | |
413 | canBinFits = new TCanvas("canBinFits", "fits of bins", 200, 100, 500, 700); | |
414 | canBinFits->Divide(nx, ny); | |
415 | } | |
416 | ||
417 | // loop over x bins and fit projection | |
418 | Int_t dBin = ((overflowBinFits) ? 1 : 0); | |
419 | for (Int_t bin = 1-dBin; bin <= nBins+dBin; bin++) { | |
420 | if (drawBinFits) canBinFits->cd(bin + dBin); | |
421 | Int_t bin0=TMath::Max(bin-integ,0); | |
422 | Int_t bin1=TMath::Min(bin+integ,nBins); | |
423 | TH1D* hBin = hRes2->ProjectionY("hBin", bin0, bin1); | |
424 | // | |
425 | if (hBin->GetEntries() > minHistEntries) { | |
426 | fitFunc->SetParameters(hBin->GetMaximum(),hBin->GetMean(),hBin->GetRMS()); | |
427 | hBin->Fit(fitFunc,"s"); | |
428 | Double_t sigma = TMath::Abs(fitFunc->GetParameter(2)); | |
429 | ||
430 | if (sigma > 0.){ | |
431 | hRes->SetBinContent(bin, TMath::Abs(fitFunc->GetParameter(2))); | |
432 | hMean->SetBinContent(bin, fitFunc->GetParameter(1)); | |
433 | } | |
434 | else{ | |
435 | hRes->SetBinContent(bin, 0.); | |
436 | hMean->SetBinContent(bin,0); | |
437 | } | |
438 | hRes->SetBinError(bin, fitFunc->GetParError(2)); | |
439 | hMean->SetBinError(bin, fitFunc->GetParError(1)); | |
440 | ||
441 | // | |
442 | // | |
443 | ||
444 | } else { | |
445 | hRes->SetBinContent(bin, 0.); | |
446 | hRes->SetBinError(bin, 0.); | |
447 | hMean->SetBinContent(bin, 0.); | |
448 | hMean->SetBinError(bin, 0.); | |
449 | } | |
450 | ||
451 | ||
452 | if (drawBinFits) { | |
453 | char name[256]; | |
454 | if (bin == 0) { | |
455 | sprintf(name, "%s < %.4g", axis->GetTitle(), axis->GetBinUpEdge(bin)); | |
456 | } else if (bin == nBins+1) { | |
457 | sprintf(name, "%.4g < %s", axis->GetBinLowEdge(bin), axis->GetTitle()); | |
458 | } else { | |
459 | sprintf(name, "%.4g < %s < %.4g", axis->GetBinLowEdge(bin), | |
460 | axis->GetTitle(), axis->GetBinUpEdge(bin)); | |
461 | } | |
462 | canBinFits->cd(bin + dBin); | |
463 | hBin->SetTitle(name); | |
464 | hBin->SetStats(kTRUE); | |
465 | hBin->DrawCopy("E"); | |
466 | canBinFits->Update(); | |
467 | canBinFits->Modified(); | |
468 | canBinFits->Update(); | |
469 | } | |
470 | ||
471 | delete hBin; | |
472 | } | |
473 | ||
474 | delete fitFunc; | |
475 | currentPad->cd(); | |
476 | *phMean = hMean; | |
477 | return hRes; | |
478 | } | |
479 | ||
480 | //_____________________________________________________________________________ | |
481 | TH1F* AlidNdPtHelper::MakeResol(TH2F * his, Int_t integ, Bool_t type, Bool_t drawBins, Int_t minHistEntries){ | |
482 | // Create resolution histograms | |
483 | ||
484 | TH1F *hisr=0, *hism=0; | |
485 | if (!gPad) new TCanvas; | |
0aaa8b91 | 486 | hisr = CreateResHisto(his,&hism,integ,drawBins,minHistEntries); |
487 | if (type) return hism; | |
488 | else return hisr; | |
489 | ||
490 | return hisr; | |
491 | } | |
492 | ||
493 | //_____________________________________________________________________________ | |
bad4ba69 | 494 | TObjArray* AlidNdPtHelper::GetAllChargedTracks(AliESDEvent *esdEvent, AnalysisMode analysisMode) |
0aaa8b91 | 495 | { |
496 | // | |
497 | // all charged TPC particles | |
498 | // | |
499 | TObjArray *allTracks = new TObjArray(); | |
500 | if(!allTracks) return allTracks; | |
501 | ||
502 | AliESDtrack *track=0; | |
503 | for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++) | |
504 | { | |
847e74b2 | 505 | if(analysisMode == AlidNdPtHelper::kTPC) { |
774986ef | 506 | // |
847e74b2 | 507 | // track must be deleted by user |
774986ef | 508 | // esd track parameters are replaced by TPCinner |
509 | // | |
bad4ba69 | 510 | track = AliESDtrackCuts::GetTPCOnlyTrack(esdEvent,iTrack); |
847e74b2 | 511 | if(!track) continue; |
512 | } | |
774986ef | 513 | else if (analysisMode == AlidNdPtHelper::kTPCSPDvtx || analysisMode == AlidNdPtHelper::kTPCSPDvtxUpdate) |
847e74b2 | 514 | { |
774986ef | 515 | // |
847e74b2 | 516 | // track must be deleted by the user |
774986ef | 517 | // esd track parameters are replaced by TPCinner |
518 | // | |
847e74b2 | 519 | track = AlidNdPtHelper::GetTPCOnlyTrackSPDvtx(esdEvent,iTrack,kFALSE); |
520 | if(!track) continue; | |
521 | } | |
791aaf54 | 522 | else if (analysisMode == AlidNdPtHelper::kTPCTrackSPDvtx || analysisMode == AlidNdPtHelper::kTPCTrackSPDvtxUpdate) |
523 | { | |
524 | // | |
525 | // track must be deleted by the user | |
526 | // esd track parameters are replaced by TPCinner | |
527 | // | |
528 | track = AlidNdPtHelper::GetTPCOnlyTrackTrackSPDvtx(esdEvent,iTrack,kFALSE); | |
529 | if(!track) continue; | |
530 | } | |
695facdf | 531 | else if(analysisMode == AlidNdPtHelper::kTPCITSHybrid ) |
774986ef | 532 | { |
533 | track = AlidNdPtHelper::GetTrackSPDvtx(esdEvent,iTrack,kFALSE); | |
534 | } | |
68f10917 | 535 | else if(analysisMode == AlidNdPtHelper::kTPCITSHybridTrackSPDvtx || analysisMode == AlidNdPtHelper::kTPCITSHybridTrackSPDvtxDCArPt || analysisMode == AlidNdPtHelper::kITSStandAloneTrackSPDvtx || analysisMode ==AlidNdPtHelper::kITSStandAloneTPCTrackSPDvtx) |
791aaf54 | 536 | { |
537 | track = AlidNdPtHelper::GetTrackTrackSPDvtx(esdEvent,iTrack,kFALSE); | |
538 | } | |
774986ef | 539 | else |
540 | { | |
541 | track = esdEvent->GetTrack(iTrack); | |
0aaa8b91 | 542 | } |
774986ef | 543 | |
0aaa8b91 | 544 | if(!track) continue; |
545 | ||
546 | if(track->Charge()==0) { | |
791aaf54 | 547 | if(analysisMode == AlidNdPtHelper::kTPC || |
548 | analysisMode == AlidNdPtHelper::kTPCSPDvtx || analysisMode == AlidNdPtHelper::kTPCTrackSPDvtx || | |
549 | analysisMode == AlidNdPtHelper::kTPCSPDvtxUpdate || analysisMode == AlidNdPtHelper::kTPCTrackSPDvtxUpdate) | |
847e74b2 | 550 | { |
0aaa8b91 | 551 | delete track; continue; |
552 | } else { | |
553 | continue; | |
554 | } | |
555 | } | |
556 | ||
557 | allTracks->Add(track); | |
558 | } | |
bad4ba69 | 559 | |
791aaf54 | 560 | if(analysisMode == AlidNdPtHelper::kTPC || |
561 | analysisMode == AlidNdPtHelper::kTPCSPDvtx || analysisMode == AlidNdPtHelper::kTPCTrackSPDvtx || | |
562 | analysisMode == AlidNdPtHelper::kTPCSPDvtxUpdate || analysisMode == AlidNdPtHelper::kTPCTrackSPDvtxUpdate) { | |
bad4ba69 | 563 | |
564 | allTracks->SetOwner(kTRUE); | |
565 | } | |
0aaa8b91 | 566 | |
567 | return allTracks; | |
568 | } | |
569 | ||
847e74b2 | 570 | //_____________________________________________________________________________ |
e9f7cb15 | 571 | AliESDtrack *AlidNdPtHelper::GetTPCOnlyTrackSPDvtx(const AliESDEvent* esdEvent, Int_t iTrack, Bool_t bUpdate) |
847e74b2 | 572 | { |
573 | // | |
574 | // Create ESD tracks from TPCinner parameters. | |
575 | // Propagte to DCA to SPD vertex. | |
576 | // Update using SPD vertex point (parameter) | |
577 | // | |
578 | // It is user responsibility to delete these tracks | |
579 | // | |
580 | ||
581 | if (!esdEvent) return NULL; | |
582 | if (!esdEvent->GetPrimaryVertexSPD() ) { return NULL; } | |
583 | if (!esdEvent->GetPrimaryVertexSPD()->GetStatus() ) { return NULL; } | |
584 | ||
585 | // | |
586 | AliESDtrack* track = esdEvent->GetTrack(iTrack); | |
587 | if (!track) | |
588 | return NULL; | |
589 | ||
774986ef | 590 | Bool_t isOK = kFALSE; |
591 | Double_t x[3]; track->GetXYZ(x); | |
592 | Double_t b[3]; AliTracker::GetBxByBz(x,b); | |
593 | ||
847e74b2 | 594 | // create new ESD track |
595 | AliESDtrack *tpcTrack = new AliESDtrack(); | |
596 | ||
597 | // relate TPC-only tracks (TPCinner) to SPD vertex | |
598 | AliExternalTrackParam cParam; | |
599 | if(bUpdate) { | |
774986ef | 600 | isOK = track->RelateToVertexTPCBxByBz(esdEvent->GetPrimaryVertexSPD(),b,kVeryBig,&cParam); |
847e74b2 | 601 | track->Set(cParam.GetX(),cParam.GetAlpha(),cParam.GetParameter(),cParam.GetCovariance()); |
602 | ||
603 | // reject fake tracks | |
604 | if(track->Pt() > 10000.) { | |
605 | ::Error("Exclude no physical tracks","pt>10000. GeV"); | |
606 | delete tpcTrack; | |
607 | return NULL; | |
608 | } | |
609 | } | |
610 | else { | |
774986ef | 611 | isOK = track->RelateToVertexTPCBxByBz(esdEvent->GetPrimaryVertexSPD(), b, kVeryBig); |
847e74b2 | 612 | } |
613 | ||
614 | // only true if we have a tpc track | |
615 | if (!track->FillTPCOnlyTrack(*tpcTrack)) | |
616 | { | |
617 | delete tpcTrack; | |
618 | return NULL; | |
619 | } | |
774986ef | 620 | |
621 | if(!isOK) return NULL; | |
847e74b2 | 622 | |
623 | return tpcTrack; | |
624 | } | |
625 | ||
791aaf54 | 626 | //_____________________________________________________________________________ |
e9f7cb15 | 627 | AliESDtrack *AlidNdPtHelper::GetTPCOnlyTrackTrackSPDvtx(const AliESDEvent* esdEvent, Int_t iTrack, Bool_t bUpdate) |
791aaf54 | 628 | { |
629 | // | |
630 | // Create ESD tracks from TPCinner parameters. | |
631 | // Propagte to DCA to Track or SPD vertex. | |
632 | // Update using SPD vertex point (parameter) | |
633 | // | |
634 | // It is user responsibility to delete these tracks | |
635 | // | |
636 | if (!esdEvent) return NULL; | |
637 | const AliESDVertex *vertex = esdEvent->GetPrimaryVertexTracks(); | |
638 | if(vertex->GetNContributors()<1) { | |
639 | // SPD vertex | |
640 | vertex = esdEvent->GetPrimaryVertexSPD(); | |
641 | } | |
642 | if(!vertex) return NULL; | |
643 | ||
644 | // | |
645 | AliESDtrack* track = esdEvent->GetTrack(iTrack); | |
646 | if (!track) | |
647 | return NULL; | |
648 | ||
649 | Bool_t isOK = kFALSE; | |
650 | Double_t x[3]; track->GetXYZ(x); | |
651 | Double_t b[3]; AliTracker::GetBxByBz(x,b); | |
652 | ||
653 | // create new ESD track | |
654 | AliESDtrack *tpcTrack = new AliESDtrack(); | |
655 | ||
656 | // relate TPC-only tracks (TPCinner) to SPD vertex | |
657 | AliExternalTrackParam cParam; | |
658 | if(bUpdate) { | |
659 | isOK = track->RelateToVertexTPCBxByBz(vertex,b,kVeryBig,&cParam); | |
660 | track->Set(cParam.GetX(),cParam.GetAlpha(),cParam.GetParameter(),cParam.GetCovariance()); | |
661 | ||
662 | // reject fake tracks | |
663 | if(track->Pt() > 10000.) { | |
664 | ::Error("Exclude no physical tracks","pt>10000. GeV"); | |
665 | delete tpcTrack; | |
666 | return NULL; | |
667 | } | |
668 | } | |
669 | else { | |
670 | isOK = track->RelateToVertexTPCBxByBz(vertex, b, kVeryBig); | |
671 | } | |
672 | ||
673 | // only true if we have a tpc track | |
674 | if (!track->FillTPCOnlyTrack(*tpcTrack)) | |
675 | { | |
676 | delete tpcTrack; | |
677 | return NULL; | |
678 | } | |
679 | ||
680 | if(!isOK) return NULL; | |
681 | ||
682 | return tpcTrack; | |
683 | } | |
684 | ||
774986ef | 685 | //_____________________________________________________________________________ |
e9f7cb15 | 686 | AliESDtrack *AlidNdPtHelper::GetTrackSPDvtx(const AliESDEvent* esdEvent, Int_t iTrack, Bool_t bUpdate) |
774986ef | 687 | { |
688 | // | |
689 | // Propagte track to DCA to SPD vertex. | |
690 | // Update using SPD vertex point (parameter) | |
691 | // | |
692 | if (!esdEvent) return NULL; | |
693 | if (!esdEvent->GetPrimaryVertexSPD() ) { return NULL; } | |
694 | if (!esdEvent->GetPrimaryVertexSPD()->GetStatus() ) { return NULL; } | |
695 | ||
696 | // | |
697 | AliESDtrack* track = esdEvent->GetTrack(iTrack); | |
698 | if (!track) | |
699 | return NULL; | |
700 | ||
701 | Bool_t isOK = kFALSE; | |
702 | Double_t x[3]; track->GetXYZ(x); | |
703 | Double_t b[3]; AliTracker::GetBxByBz(x,b); | |
704 | ||
705 | // relate tracks to SPD vertex | |
706 | AliExternalTrackParam cParam; | |
707 | if(bUpdate) { | |
708 | isOK = track->RelateToVertexBxByBz(esdEvent->GetPrimaryVertexSPD(),b,kVeryBig,&cParam); | |
709 | track->Set(cParam.GetX(),cParam.GetAlpha(),cParam.GetParameter(),cParam.GetCovariance()); | |
710 | ||
711 | // reject fake tracks | |
712 | if(track->Pt() > 10000.) { | |
713 | ::Error("Exclude no physical tracks","pt>10000. GeV"); | |
714 | return NULL; | |
715 | } | |
716 | } | |
717 | else { | |
718 | isOK = track->RelateToVertexBxByBz(esdEvent->GetPrimaryVertexSPD(), b, kVeryBig); | |
719 | } | |
720 | ||
721 | if(!isOK) return NULL; | |
722 | ||
723 | return track; | |
724 | } | |
725 | ||
791aaf54 | 726 | //_____________________________________________________________________________ |
e9f7cb15 | 727 | AliESDtrack *AlidNdPtHelper::GetTrackTrackSPDvtx(const AliESDEvent* esdEvent, Int_t iTrack, Bool_t bUpdate) |
791aaf54 | 728 | { |
729 | // | |
730 | // Propagte track to DCA to Track or SPD vertex. | |
731 | // Update using SPD vertex point (parameter) | |
732 | // | |
733 | if (!esdEvent) return NULL; | |
734 | ||
735 | const AliESDVertex *vertex = esdEvent->GetPrimaryVertexTracks(); | |
736 | if(vertex->GetNContributors()<1) { | |
737 | // SPD vertex | |
738 | vertex = esdEvent->GetPrimaryVertexSPD(); | |
739 | } | |
740 | if(!vertex) return NULL; | |
741 | ||
742 | // | |
743 | AliESDtrack* track = esdEvent->GetTrack(iTrack); | |
744 | if (!track) | |
745 | return NULL; | |
746 | ||
747 | Bool_t isOK = kFALSE; | |
748 | Double_t x[3]; track->GetXYZ(x); | |
749 | Double_t b[3]; AliTracker::GetBxByBz(x,b); | |
750 | ||
751 | // relate tracks to SPD vertex | |
752 | AliExternalTrackParam cParam; | |
753 | if(bUpdate) { | |
754 | isOK = track->RelateToVertexBxByBz(vertex,b,kVeryBig,&cParam); | |
755 | track->Set(cParam.GetX(),cParam.GetAlpha(),cParam.GetParameter(),cParam.GetCovariance()); | |
756 | ||
757 | // reject fake tracks | |
758 | if(track->Pt() > 10000.) { | |
759 | ::Error("Exclude no physical tracks","pt>10000. GeV"); | |
760 | return NULL; | |
761 | } | |
762 | } | |
763 | else { | |
764 | isOK = track->RelateToVertexBxByBz(vertex, b, kVeryBig); | |
765 | } | |
766 | ||
767 | if(!isOK) return NULL; | |
768 | ||
769 | return track; | |
770 | } | |
771 | ||
55468faf | 772 | //_____________________________________________________________________________ |
773 | Bool_t AlidNdPtHelper::SelectEvent(const AliESDEvent* const esdEvent, AliESDtrackCuts* const esdTrackCuts) { | |
774 | // select events with at least | |
775 | // one reconstructed primary track in acceptance | |
776 | // pT>0.5 GeV/c, |eta|<0.8 for cross section studies | |
777 | ||
778 | if(!esdEvent) return kFALSE; | |
779 | if(!esdTrackCuts) return kFALSE; | |
780 | ||
781 | AliESDtrack *track=0; | |
782 | Int_t count = 0; | |
783 | for (Int_t iTrack = 0; iTrack < esdEvent->GetNumberOfTracks(); iTrack++) | |
784 | { | |
785 | track = esdEvent->GetTrack(iTrack); | |
786 | if(!track) continue; | |
787 | if(track->Charge()==0) continue; | |
788 | if(!esdTrackCuts->AcceptTrack(track)) continue; | |
789 | if(track->Pt() < 0.5) continue; | |
790 | if(TMath::Abs(track->Eta()) > 0.8) continue; | |
791 | ||
792 | count++; | |
793 | } | |
794 | ||
795 | if(count > 0) return kTRUE; | |
796 | else return kFALSE; | |
797 | ||
798 | return kFALSE; | |
799 | } | |
800 | ||
801 | //_____________________________________________________________________________ | |
802 | Bool_t AlidNdPtHelper::SelectMCEvent(AliMCEvent* const mcEvent) { | |
803 | // | |
804 | // select events with at least | |
805 | // one prompt (MC primary) track in acceptance | |
806 | // pT>0.5 GeV/c, |eta|<0.8 for cross section studies | |
807 | // | |
808 | ||
809 | if(!mcEvent) return kFALSE; | |
810 | AliStack* stack = mcEvent->Stack(); | |
811 | if(!stack) return kFALSE; | |
812 | ||
813 | Int_t count = 0; | |
814 | for (Int_t iMc = 0; iMc < stack->GetNtrack(); ++iMc) | |
815 | { | |
816 | TParticle* particle = stack->Particle(iMc); | |
817 | if (!particle) continue; | |
818 | ||
819 | // only charged particles | |
820 | if(!particle->GetPDG()) continue; | |
821 | Double_t charge = particle->GetPDG()->Charge()/3.; | |
822 | if(charge == 0) continue; | |
823 | ||
824 | // physical primary | |
825 | Bool_t prim = stack->IsPhysicalPrimary(iMc); | |
826 | if(!prim) continue; | |
827 | ||
828 | if(particle->Pt() < 0.5) continue; | |
829 | if(TMath::Abs(particle->Eta()) > 0.8) continue; | |
830 | ||
831 | count++; | |
832 | } | |
833 | ||
834 | if(count > 0) return kTRUE; | |
835 | else return kFALSE; | |
836 | ||
837 | return kFALSE; | |
838 | } | |
839 | ||
0aaa8b91 | 840 | //_____________________________________________________________________________ |
e9f7cb15 | 841 | Int_t AlidNdPtHelper::GetTPCMBTrackMult(const AliESDEvent *const esdEvent,const AlidNdPtEventCuts *const evtCuts, const AlidNdPtAcceptanceCuts *const accCuts,const AliESDtrackCuts *const trackCuts) |
0aaa8b91 | 842 | { |
843 | // | |
844 | // get MB event track multiplicity | |
845 | // | |
846 | if(!esdEvent) | |
847 | { | |
848 | ::Error("AlidNdPtHelper::GetTPCMBTrackMult()","esd event is NULL"); | |
849 | return 0; | |
850 | } | |
851 | ||
852 | if(!evtCuts || !accCuts || !trackCuts) | |
853 | { | |
854 | ::Error("AlidNdPtHelper::GetTPCMBTrackMult()","cuts not available"); | |
855 | return 0; | |
856 | } | |
857 | ||
858 | // | |
859 | Double_t pos[3]={evtCuts->GetMeanXv(),evtCuts->GetMeanYv(),evtCuts->GetMeanZv()}; | |
860 | Double_t err[3]={evtCuts->GetSigmaMeanXv(),evtCuts->GetSigmaMeanYv(),evtCuts->GetSigmaMeanZv()}; | |
861 | AliESDVertex vtx0(pos,err); | |
862 | ||
863 | // | |
864 | Float_t maxDCAr = accCuts->GetMaxDCAr(); | |
865 | Float_t maxDCAz = accCuts->GetMaxDCAz(); | |
866 | Float_t minTPCClust = trackCuts->GetMinNClusterTPC(); | |
867 | // | |
868 | Int_t ntracks = esdEvent->GetNumberOfTracks(); | |
869 | Double_t dca[2],cov[3]; | |
870 | Int_t mult=0; | |
871 | for (Int_t i=0;i <ntracks; i++){ | |
872 | AliESDtrack *t = esdEvent->GetTrack(i); | |
873 | if (!t) continue; | |
874 | if (t->Charge() == 0) continue; | |
875 | if (!t->GetTPCInnerParam()) continue; | |
876 | if (t->GetTPCNcls()<minTPCClust) continue; | |
877 | // | |
774986ef | 878 | Double_t x[3]; t->GetXYZ(x); |
879 | Double_t b[3]; AliTracker::GetBxByBz(x,b); | |
880 | const Double_t kMaxStep = 1; //max step over the material | |
881 | ||
0aaa8b91 | 882 | AliExternalTrackParam *tpcTrack = new AliExternalTrackParam(*(t->GetTPCInnerParam())); |
774986ef | 883 | if (!tpcTrack->PropagateToDCABxByBz(&vtx0,b,kMaxStep,dca,cov)) |
0aaa8b91 | 884 | { |
885 | if(tpcTrack) delete tpcTrack; | |
886 | continue; | |
887 | } | |
888 | // | |
889 | if (TMath::Abs(dca[0])>maxDCAr || TMath::Abs(dca[1])>maxDCAz) { | |
890 | if(tpcTrack) delete tpcTrack; | |
891 | continue; | |
892 | } | |
893 | ||
894 | mult++; | |
895 | ||
896 | if(tpcTrack) delete tpcTrack; | |
897 | } | |
898 | ||
899 | return mult; | |
900 | } | |
901 | ||
902 | //_____________________________________________________________________________ | |
e9f7cb15 | 903 | Int_t AlidNdPtHelper::GetTPCMBPrimTrackMult(const AliESDEvent *const esdEvent, AliStack *const stack, const AlidNdPtEventCuts *const evtCuts, const AlidNdPtAcceptanceCuts *const accCuts, const AliESDtrackCuts *const trackCuts) |
0aaa8b91 | 904 | { |
905 | // | |
906 | // get MB primary event track multiplicity | |
907 | // | |
908 | if(!esdEvent) | |
909 | { | |
910 | ::Error("AlidNdPtHelper::GetTPCMBPrimTrackMult()","esd event is NULL"); | |
911 | return 0; | |
912 | } | |
913 | ||
914 | if(!stack) | |
915 | { | |
916 | ::Error("AlidNdPtHelper::GetTPCMBPrimTrackMult()","esd event is NULL"); | |
917 | return 0; | |
918 | } | |
919 | ||
920 | if(!evtCuts || !accCuts || !trackCuts) | |
921 | { | |
922 | ::Error("AlidNdPtHelper::GetTPCMBPrimTrackMult()","cuts not available"); | |
923 | return 0; | |
924 | } | |
925 | ||
926 | // | |
927 | Double_t pos[3]={evtCuts->GetMeanXv(),evtCuts->GetMeanYv(),evtCuts->GetMeanZv()}; | |
928 | Double_t err[3]={evtCuts->GetSigmaMeanXv(),evtCuts->GetSigmaMeanYv(),evtCuts->GetSigmaMeanZv()}; | |
929 | AliESDVertex vtx0(pos,err); | |
930 | ||
931 | // | |
932 | Float_t maxDCAr = accCuts->GetMaxDCAr(); | |
933 | Float_t maxDCAz = accCuts->GetMaxDCAz(); | |
934 | Float_t minTPCClust = trackCuts->GetMinNClusterTPC(); | |
935 | ||
936 | // | |
937 | Int_t ntracks = esdEvent->GetNumberOfTracks(); | |
938 | Double_t dca[2],cov[3]; | |
939 | Int_t mult=0; | |
940 | for (Int_t i=0;i <ntracks; i++){ | |
941 | AliESDtrack *t = esdEvent->GetTrack(i); | |
942 | if (!t) continue; | |
943 | if (t->Charge() == 0) continue; | |
944 | if (!t->GetTPCInnerParam()) continue; | |
945 | if (t->GetTPCNcls()<minTPCClust) continue; | |
946 | // | |
774986ef | 947 | Double_t x[3]; t->GetXYZ(x); |
948 | Double_t b[3]; AliTracker::GetBxByBz(x,b); | |
949 | const Double_t kMaxStep = 1; //max step over the material | |
950 | ||
0aaa8b91 | 951 | AliExternalTrackParam *tpcTrack = new AliExternalTrackParam(*(t->GetTPCInnerParam())); |
774986ef | 952 | if (!tpcTrack->PropagateToDCABxByBz(&vtx0,b,kMaxStep,dca,cov)) |
0aaa8b91 | 953 | { |
954 | if(tpcTrack) delete tpcTrack; | |
955 | continue; | |
956 | } | |
957 | // | |
958 | if (TMath::Abs(dca[0])>maxDCAr || TMath::Abs(dca[1])>maxDCAz) { | |
959 | if(tpcTrack) delete tpcTrack; | |
960 | continue; | |
961 | } | |
962 | ||
963 | Int_t label = TMath::Abs(t->GetLabel()); | |
964 | TParticle *part = stack->Particle(label); | |
965 | if(!part) { | |
966 | if(tpcTrack) delete tpcTrack; | |
967 | continue; | |
968 | } | |
969 | if(!stack->IsPhysicalPrimary(label)) | |
970 | { | |
971 | if(tpcTrack) delete tpcTrack; | |
972 | continue; | |
973 | } | |
974 | ||
975 | mult++; | |
976 | ||
977 | if(tpcTrack) delete tpcTrack; | |
978 | } | |
979 | ||
980 | return mult; | |
981 | } | |
982 | ||
983 | ||
791aaf54 | 984 | //_____________________________________________________________________________ |
985 | Double_t AlidNdPtHelper::GetStrangenessCorrFactor(const Double_t pt) | |
986 | { | |
987 | // data driven correction factor for secondaries | |
988 | // underestimated secondaries with strangeness in Pythia (A. Dainese) | |
0aaa8b91 | 989 | |
791aaf54 | 990 | // |
991 | // pt=0.17; fact=1 | |
992 | // pt=0.4; fact=1.07 | |
993 | // pt=0.6; fact=1.25 | |
994 | // pt>=1.2; fact=1.5 | |
995 | // | |
0aaa8b91 | 996 | |
791aaf54 | 997 | if (pt <= 0.17) return 1.0; |
998 | if (pt <= 0.4) return GetLinearInterpolationValue(0.17,1.0,0.4,1.07, pt); | |
999 | if (pt <= 0.6) return GetLinearInterpolationValue(0.4,1.07,0.6,1.25, pt); | |
1000 | if (pt <= 1.2) return GetLinearInterpolationValue(0.6,1.25,1.2,1.5, pt); | |
1001 | return 1.5; | |
1002 | ||
1003 | } | |
1004 | ||
d4640855 | 1005 | //_____________________________________________________________________________ |
1006 | Double_t AlidNdPtHelper::GetStrangenessCorrFactorPbPb(const Double_t pt) | |
1007 | { | |
1008 | // data driven correction factor for secondaries (PbPb) | |
1009 | ||
1010 | if (pt <= 0.25) return 1.0; | |
1011 | if (pt <= 0.5) return GetLinearInterpolationValue(0.25,1.0,0.5,1.4, pt); | |
1012 | if (pt <= 1.0) return GetLinearInterpolationValue(0.5,1.4,1.0,1.47, pt); | |
1013 | if (pt <= 2.0) return GetLinearInterpolationValue(1.0,1.47,2.0,1.56, pt); | |
1014 | if (pt <= 5.0) return GetLinearInterpolationValue(2.0,1.56,5.0,1.67, pt); | |
1015 | return 1.67; | |
1016 | ||
1017 | } | |
1018 | ||
791aaf54 | 1019 | //___________________________________________________________________________ |
e9f7cb15 | 1020 | Double_t AlidNdPtHelper::GetLinearInterpolationValue(const Double_t x1,const Double_t y1,const Double_t x2,const Double_t y2, const Double_t pt) |
791aaf54 | 1021 | { |
1022 | // | |
1023 | // linear interpolation | |
1024 | // | |
1025 | return ((y2-y1)/(x2-x1))*pt+(y2-(((y2-y1)/(x2-x1))*x2)); | |
1026 | } | |
0aaa8b91 | 1027 | |
1028 | //_____________________________________________________________________________ | |
f2dec884 | 1029 | Int_t AlidNdPtHelper::GetMCTrueTrackMult(AliMCEvent *const mcEvent, AlidNdPtEventCuts *const evtCuts, AlidNdPtAcceptanceCuts *const accCuts) |
0aaa8b91 | 1030 | { |
1031 | // | |
1032 | // calculate mc event true track multiplicity | |
1033 | // | |
1034 | if(!mcEvent) return 0; | |
1035 | ||
1036 | AliStack* stack = 0; | |
1037 | Int_t mult = 0; | |
1038 | ||
1039 | // MC particle stack | |
1040 | stack = mcEvent->Stack(); | |
1041 | if (!stack) return 0; | |
1042 | ||
695facdf | 1043 | // |
1044 | //printf("minZv %f, maxZv %f \n", evtCuts->GetMinZv(), evtCuts->GetMaxZv()); | |
1045 | // | |
1046 | ||
0aaa8b91 | 1047 | Bool_t isEventOK = evtCuts->AcceptMCEvent(mcEvent); |
1048 | if(!isEventOK) return 0; | |
1049 | ||
1050 | Int_t nPart = stack->GetNtrack(); | |
1051 | for (Int_t iMc = 0; iMc < nPart; ++iMc) | |
1052 | { | |
1053 | TParticle* particle = stack->Particle(iMc); | |
1054 | if (!particle) | |
1055 | continue; | |
1056 | ||
1057 | // only charged particles | |
09abaebb | 1058 | if(!particle->GetPDG()) continue; |
0aaa8b91 | 1059 | Double_t charge = particle->GetPDG()->Charge()/3.; |
f2dec884 | 1060 | if (TMath::Abs(charge) < 0.001) |
0aaa8b91 | 1061 | continue; |
1062 | ||
1063 | // physical primary | |
1064 | Bool_t prim = stack->IsPhysicalPrimary(iMc); | |
1065 | if(!prim) continue; | |
1066 | ||
774986ef | 1067 | // checked accepted without pt cut |
1068 | //if(accCuts->AcceptTrack(particle)) | |
1069 | if( particle->Eta() > accCuts->GetMinEta() && particle->Eta() < accCuts->GetMaxEta() ) | |
0aaa8b91 | 1070 | { |
1071 | mult++; | |
1072 | } | |
1073 | } | |
1074 | ||
1075 | return mult; | |
1076 | } | |
1077 | ||
1078 | //_______________________________________________________________________ | |
f2dec884 | 1079 | void AlidNdPtHelper::PrintMCInfo(AliStack *const pStack,Int_t label) |
0aaa8b91 | 1080 | { |
1081 | // print information about particles in the stack | |
1082 | ||
1083 | if(!pStack)return; | |
1084 | label = TMath::Abs(label); | |
1085 | TParticle *part = pStack->Particle(label); | |
1086 | Printf("########################"); | |
1087 | Printf("%s:%d %d UniqueID %d PDG %d P %3.3f",(char*)__FILE__,__LINE__,label,part->GetUniqueID(),part->GetPdgCode(),part->P()); | |
1088 | part->Print(); | |
1089 | TParticle* mother = part; | |
1090 | Int_t imo = part->GetFirstMother(); | |
1091 | Int_t nprim = pStack->GetNprimary(); | |
1092 | ||
1093 | while((imo >= nprim)) { | |
1094 | mother = pStack->Particle(imo); | |
1095 | Printf("Mother %s:%d Label %d UniqueID %d PDG %d P %3.3f",(char*)__FILE__,__LINE__,imo,mother->GetUniqueID(),mother->GetPdgCode(),mother->P()); | |
1096 | mother->Print(); | |
1097 | imo = mother->GetFirstMother(); | |
1098 | } | |
1099 | ||
1100 | Printf("########################"); | |
1101 | } | |
1102 | ||
1103 | ||
1104 | //_____________________________________________________________________________ | |
f2dec884 | 1105 | TH1* AlidNdPtHelper::GetContCorrHisto(TH1 *const hist) |
0aaa8b91 | 1106 | { |
1107 | // | |
1108 | // get contamination histogram | |
1109 | // | |
1110 | if(!hist) return 0; | |
1111 | ||
1112 | Int_t nbins = hist->GetNbinsX(); | |
f2dec884 | 1113 | TH1 *hCont = (TH1D *)hist->Clone(); |
0aaa8b91 | 1114 | |
1115 | for(Int_t i=0; i<=nbins+1; i++) { | |
1116 | Double_t binContent = hist->GetBinContent(i); | |
1117 | Double_t binError = hist->GetBinError(i); | |
1118 | ||
f2dec884 | 1119 | hCont->SetBinContent(i,1.-binContent); |
1120 | hCont->SetBinError(i,binError); | |
0aaa8b91 | 1121 | } |
1122 | ||
f2dec884 | 1123 | return hCont; |
0aaa8b91 | 1124 | } |
1125 | ||
1126 | ||
1127 | //_____________________________________________________________________________ | |
f2dec884 | 1128 | TH1* AlidNdPtHelper::ScaleByBinWidth(TH1 *const hist) |
0aaa8b91 | 1129 | { |
1130 | // | |
1131 | // scale by bin width | |
1132 | // | |
1133 | if(!hist) return 0; | |
1134 | ||
f2dec884 | 1135 | TH1 *hScale = (TH1D *)hist->Clone(); |
1136 | hScale->Scale(1.,"width"); | |
0aaa8b91 | 1137 | |
f2dec884 | 1138 | return hScale; |
0aaa8b91 | 1139 | } |
1140 | ||
1141 | //_____________________________________________________________________________ | |
e9f7cb15 | 1142 | TH1* AlidNdPtHelper::CalcRelativeDifference(const TH1 *const hist1, const TH1 *const hist2) |
0aaa8b91 | 1143 | { |
1144 | // | |
1145 | // calculate rel. difference | |
1146 | // | |
1147 | ||
1148 | if(!hist1) return 0; | |
1149 | if(!hist2) return 0; | |
1150 | ||
f2dec884 | 1151 | TH1 *h1Clone = (TH1D *)hist1->Clone(); |
1152 | h1Clone->Sumw2(); | |
0aaa8b91 | 1153 | |
1154 | // (rec-mc)/mc | |
f2dec884 | 1155 | h1Clone->Add(hist2,-1); |
1156 | h1Clone->Divide(hist2); | |
0aaa8b91 | 1157 | |
f2dec884 | 1158 | return h1Clone; |
0aaa8b91 | 1159 | } |
1160 | ||
1161 | //_____________________________________________________________________________ | |
e9f7cb15 | 1162 | TH1* AlidNdPtHelper::CalcRelativeDifferenceFun(const TH1 *const hist1, TF1 *const fun) |
0aaa8b91 | 1163 | { |
1164 | // | |
08a80bfe | 1165 | // calculate rel. difference |
0aaa8b91 | 1166 | // between histogram and function |
1167 | // | |
1168 | if(!hist1) return 0; | |
1169 | if(!fun) return 0; | |
1170 | ||
f2dec884 | 1171 | TH1 *h1Clone = (TH1D *)hist1->Clone(); |
1172 | h1Clone->Sumw2(); | |
0aaa8b91 | 1173 | |
1174 | // | |
f2dec884 | 1175 | h1Clone->Add(fun,-1); |
1176 | h1Clone->Divide(hist1); | |
0aaa8b91 | 1177 | |
f2dec884 | 1178 | return h1Clone; |
0aaa8b91 | 1179 | } |
1180 | ||
1181 | //_____________________________________________________________________________ | |
e9f7cb15 | 1182 | TH1* AlidNdPtHelper::NormalizeToEvent(const TH2 *const hist1, const TH1 *const hist2) |
0aaa8b91 | 1183 | { |
1184 | // normalise to event for a given multiplicity bin | |
1185 | // return pt histogram | |
1186 | ||
1187 | if(!hist1) return 0; | |
1188 | if(!hist2) return 0; | |
1189 | char name[256]; | |
1190 | ||
1191 | Int_t nbinsX = hist1->GetNbinsX(); | |
1192 | //Int_t nbinsY = hist1->GetNbinsY(); | |
1193 | ||
f2dec884 | 1194 | TH1D *histNorm = 0; |
0aaa8b91 | 1195 | for(Int_t i=0; i<=nbinsX+1; i++) { |
1196 | sprintf(name,"mom_%d",i); | |
1197 | TH1D *hist = (TH1D*)hist1->ProjectionY(name,i+1,i+1); | |
1198 | ||
1199 | sprintf(name,"mom_norm"); | |
1200 | if(i==0) { | |
f2dec884 | 1201 | histNorm = (TH1D *)hist->Clone(name); |
1202 | histNorm->Reset(); | |
0aaa8b91 | 1203 | } |
1204 | ||
1205 | Double_t nbEvents = hist2->GetBinContent(i); | |
1206 | if(!nbEvents) { nbEvents = 1.; }; | |
1207 | ||
1208 | hist->Scale(1./nbEvents); | |
f2dec884 | 1209 | histNorm->Add(hist); |
0aaa8b91 | 1210 | } |
1211 | ||
f2dec884 | 1212 | return histNorm; |
0aaa8b91 | 1213 | } |
1214 | ||
1215 | //_____________________________________________________________________________ | |
e9f7cb15 | 1216 | //THnSparse* AlidNdPtHelper::GenerateCorrMatrix(THnSparse *const hist1, const THnSparse *const hist2, char *const name) { |
1217 | THnSparse* AlidNdPtHelper::GenerateCorrMatrix(THnSparse *const hist1, const THnSparse *const hist2, const char *name) { | |
0aaa8b91 | 1218 | // generate correction matrix |
1219 | if(!hist1 || !hist2) return 0; | |
1220 | ||
1221 | THnSparse *h =(THnSparse*)hist1->Clone(name);; | |
1222 | h->Divide(hist1,hist2,1,1,"B"); | |
1223 | ||
1224 | return h; | |
1225 | } | |
1226 | ||
1227 | //_____________________________________________________________________________ | |
a9b12ce1 | 1228 | //TH2* AlidNdPtHelper::GenerateCorrMatrix(TH2 *const hist1, TH2 *const hist2, char *const name) { |
1229 | TH2* AlidNdPtHelper::GenerateCorrMatrix(TH2 *const hist1, TH2 *const hist2, const char *name) { | |
0aaa8b91 | 1230 | // generate correction matrix |
1231 | if(!hist1 || !hist2) return 0; | |
1232 | ||
1233 | TH2D *h =(TH2D*)hist1->Clone(name);; | |
1234 | h->Divide(hist1,hist2,1,1,"B"); | |
1235 | ||
1236 | return h; | |
1237 | } | |
1238 | ||
1239 | //_____________________________________________________________________________ | |
a9b12ce1 | 1240 | //TH1* AlidNdPtHelper::GenerateCorrMatrix(TH1 *const hist1, TH1 *const hist2, char *const name) { |
1241 | TH1* AlidNdPtHelper::GenerateCorrMatrix(TH1 *const hist1, TH1 *const hist2, const char* name) { | |
0aaa8b91 | 1242 | // generate correction matrix |
1243 | if(!hist1 || !hist2) return 0; | |
1244 | ||
1245 | TH1D *h =(TH1D*)hist1->Clone(name);; | |
1246 | h->Divide(hist1,hist2,1,1,"B"); | |
1247 | ||
1248 | return h; | |
1249 | } | |
1250 | ||
1251 | //_____________________________________________________________________________ | |
a9b12ce1 | 1252 | //THnSparse* AlidNdPtHelper::GenerateContCorrMatrix(THnSparse *const hist1, THnSparse *const hist2, char *const name) { |
e9f7cb15 | 1253 | THnSparse* AlidNdPtHelper::GenerateContCorrMatrix(THnSparse *const hist1, const THnSparse *const hist2, const char* name) { |
0aaa8b91 | 1254 | // generate contamination correction matrix |
1255 | if(!hist1 || !hist2) return 0; | |
1256 | ||
1257 | THnSparse *hist = GenerateCorrMatrix(hist1, hist2, name); | |
1258 | if(!hist) return 0; | |
1259 | ||
1260 | // only for non ZERO bins!!!! | |
1261 | ||
1262 | Int_t* coord = new Int_t[hist->GetNdimensions()]; | |
1263 | memset(coord, 0, sizeof(Int_t) * hist->GetNdimensions()); | |
1264 | ||
1265 | for (Long64_t i = 0; i < hist->GetNbins(); ++i) { | |
1266 | Double_t v = hist->GetBinContent(i, coord); | |
1267 | hist->SetBinContent(coord, 1.0-v); | |
1268 | //printf("v %f, hist->GetBinContent(i, coord) %f \n",v,hist->GetBinContent(i, coord)); | |
1269 | Double_t err = hist->GetBinError(coord); | |
1270 | hist->SetBinError(coord, err); | |
1271 | } | |
1272 | ||
1273 | delete [] coord; | |
1274 | ||
1275 | return hist; | |
1276 | } | |
1277 | ||
1278 | //_____________________________________________________________________________ | |
a9b12ce1 | 1279 | //TH2* AlidNdPtHelper::GenerateContCorrMatrix(TH2 *const hist1, TH2 *const hist2, char *const name) { |
1280 | TH2* AlidNdPtHelper::GenerateContCorrMatrix(TH2 *const hist1, TH2 *const hist2, const char* name) { | |
0aaa8b91 | 1281 | // generate contamination correction matrix |
1282 | if(!hist1 || !hist2) return 0; | |
1283 | ||
1284 | TH2 *hist = GenerateCorrMatrix(hist1, hist2, name); | |
1285 | if(!hist) return 0; | |
1286 | ||
1287 | Int_t nBinsX = hist->GetNbinsX(); | |
1288 | Int_t nBinsY = hist->GetNbinsY(); | |
1289 | ||
1290 | for (Int_t i = 0; i < nBinsX+1; i++) { | |
1291 | for (Int_t j = 0; j < nBinsY+1; j++) { | |
1292 | Double_t cont = hist->GetBinContent(i,j); | |
1293 | hist->SetBinContent(i,j,1.-cont); | |
1294 | Double_t err = hist->GetBinError(i,j); | |
1295 | hist->SetBinError(i,j,err); | |
1296 | } | |
1297 | } | |
1298 | ||
1299 | return hist; | |
1300 | } | |
1301 | ||
1302 | //_____________________________________________________________________________ | |
a9b12ce1 | 1303 | //TH1* AlidNdPtHelper::GenerateContCorrMatrix(TH1 *const hist1, TH1 *const hist2, char *const name) { |
1304 | TH1* AlidNdPtHelper::GenerateContCorrMatrix(TH1 *const hist1, TH1 *const hist2, const char* name) { | |
0aaa8b91 | 1305 | // generate contamination correction matrix |
1306 | if(!hist1 || !hist2) return 0; | |
1307 | ||
1308 | TH1 *hist = GenerateCorrMatrix(hist1, hist2, name); | |
1309 | if(!hist) return 0; | |
1310 | ||
1311 | Int_t nBinsX = hist->GetNbinsX(); | |
1312 | ||
1313 | for (Int_t i = 0; i < nBinsX+1; i++) { | |
1314 | Double_t cont = hist->GetBinContent(i); | |
1315 | hist->SetBinContent(i,1.-cont); | |
1316 | Double_t err = hist->GetBinError(i); | |
1317 | hist->SetBinError(i,err); | |
1318 | } | |
1319 | ||
1320 | return hist; | |
1321 | } | |
1322 | ||
1323 | //_____________________________________________________________________________ | |
e9f7cb15 | 1324 | const AliESDVertex* AlidNdPtHelper::GetTPCVertexZ(const AliESDEvent* const esdEvent, const AlidNdPtEventCuts *const evtCuts, const AlidNdPtAcceptanceCuts *const accCuts, const AliESDtrackCuts *const trackCuts, Float_t fraction, Int_t ntracksMin){ |
0aaa8b91 | 1325 | // |
1326 | // TPC Z vertexer | |
1327 | // | |
bad4ba69 | 1328 | if(!esdEvent) |
1329 | { | |
1330 | ::Error("AlidNdPtHelper::GetTPCVertexZ()","cuts not available"); | |
1331 | return NULL; | |
1332 | } | |
1333 | ||
1334 | if(!evtCuts || !accCuts || !trackCuts) | |
1335 | { | |
1336 | ::Error("AlidNdPtHelper::GetTPCVertexZ()","cuts not available"); | |
1337 | return NULL; | |
1338 | } | |
1339 | ||
1340 | Double_t vtxpos[3]={evtCuts->GetMeanXv(),evtCuts->GetMeanYv(),evtCuts->GetMeanZv()}; | |
1341 | Double_t vtxsigma[3]={evtCuts->GetSigmaMeanXv(),evtCuts->GetSigmaMeanYv(),evtCuts->GetSigmaMeanZv()}; | |
0aaa8b91 | 1342 | AliESDVertex vtx0(vtxpos,vtxsigma); |
bad4ba69 | 1343 | |
1344 | Double_t maxDCAr = accCuts->GetMaxDCAr(); | |
1345 | Double_t maxDCAz = accCuts->GetMaxDCAz(); | |
1346 | Int_t minTPCClust = trackCuts->GetMinNClusterTPC(); | |
1347 | ||
0aaa8b91 | 1348 | // |
1349 | Int_t ntracks = esdEvent->GetNumberOfTracks(); | |
1350 | TVectorD ztrack(ntracks); | |
0aaa8b91 | 1351 | Double_t dca[2],cov[3]; |
1352 | Int_t counter=0; | |
1353 | for (Int_t i=0;i <ntracks; i++){ | |
1354 | AliESDtrack *t = esdEvent->GetTrack(i); | |
1355 | if (!t) continue; | |
1356 | if (!t->GetTPCInnerParam()) continue; | |
bad4ba69 | 1357 | if (t->GetTPCNcls()<minTPCClust) continue; |
0aaa8b91 | 1358 | // |
774986ef | 1359 | |
1360 | Double_t x[3]; t->GetXYZ(x); | |
1361 | Double_t b[3]; AliTracker::GetBxByBz(x,b); | |
1362 | const Double_t kMaxStep = 1; //max step over the material | |
1363 | ||
0aaa8b91 | 1364 | AliExternalTrackParam *tpcTrack = new AliExternalTrackParam(*(t->GetTPCInnerParam())); |
774986ef | 1365 | if (!tpcTrack->PropagateToDCABxByBz(&vtx0,b,kMaxStep,dca,cov)) continue; |
0aaa8b91 | 1366 | |
1367 | // | |
bad4ba69 | 1368 | if (TMath::Abs(dca[0])>maxDCAr) continue; |
1369 | //if (TMath::Sqrt(cov[0])>sigmaXYcut) continue; | |
1370 | if (TMath::Abs(tpcTrack->GetZ())>maxDCAz) continue; | |
0aaa8b91 | 1371 | |
0aaa8b91 | 1372 | ztrack[counter]=tpcTrack->GetZ(); |
1373 | counter++; | |
1374 | ||
1375 | if(tpcTrack) delete tpcTrack; | |
1376 | } | |
bad4ba69 | 1377 | |
0aaa8b91 | 1378 | // |
1379 | // Find LTM z position | |
1380 | // | |
1381 | Double_t mean=0, sigma=0; | |
1382 | if (counter<ntracksMin) return 0; | |
1383 | // | |
1384 | Int_t nused = TMath::Nint(counter*fraction); | |
1385 | if (nused==counter) nused=counter-1; | |
1386 | if (nused>1){ | |
1387 | AliMathBase::EvaluateUni(counter, ztrack.GetMatrixArray(), mean,sigma, TMath::Nint(counter*fraction)); | |
1388 | sigma/=TMath::Sqrt(nused); | |
1389 | }else{ | |
1390 | mean = TMath::Mean(counter, ztrack.GetMatrixArray()); | |
1391 | sigma = TMath::RMS(counter, ztrack.GetMatrixArray()); | |
1392 | sigma/=TMath::Sqrt(counter-1); | |
1393 | } | |
1394 | vtxpos[2]=mean; | |
1395 | vtxsigma[2]=sigma; | |
1396 | const AliESDVertex* vertex = new AliESDVertex(vtxpos, vtxsigma); | |
1397 | return vertex; | |
1398 | } | |
1399 | ||
1400 | //_____________________________________________________________________________ | |
e9f7cb15 | 1401 | Int_t AlidNdPtHelper::GetSPDMBTrackMult(const AliESDEvent* const esdEvent, Float_t deltaThetaCut, Float_t deltaPhiCut) |
0aaa8b91 | 1402 | { |
1403 | // | |
1404 | // SPD track multiplicity | |
1405 | // | |
1406 | ||
1407 | // get tracklets | |
1408 | const AliMultiplicity* mult = esdEvent->GetMultiplicity(); | |
1409 | if (!mult) | |
1410 | return 0; | |
1411 | ||
1412 | // get multiplicity from SPD tracklets | |
1413 | Int_t inputCount = 0; | |
1414 | for (Int_t i=0; i<mult->GetNumberOfTracklets(); ++i) | |
1415 | { | |
1416 | //printf("%d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), mult->GetDeltaPhi(i)); | |
1417 | ||
1418 | Float_t phi = mult->GetPhi(i); | |
1419 | if (phi < 0) | |
1420 | phi += TMath::Pi() * 2; | |
1421 | Float_t deltaPhi = mult->GetDeltaPhi(i); | |
1422 | Float_t deltaTheta = mult->GetDeltaTheta(i); | |
1423 | ||
1424 | if (TMath::Abs(deltaPhi) > 1) | |
1425 | printf("WARNING: Very high Delta Phi: %d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), deltaPhi); | |
1426 | ||
1427 | if (deltaThetaCut > 0. && TMath::Abs(deltaTheta) > deltaThetaCut) | |
1428 | continue; | |
1429 | ||
1430 | if (deltaPhiCut > 0. && TMath::Abs(deltaPhi) > deltaPhiCut) | |
1431 | continue; | |
1432 | ||
1433 | ++inputCount; | |
1434 | } | |
1435 | ||
1436 | return inputCount; | |
1437 | } | |
1438 | ||
1439 | //_____________________________________________________________________________ | |
e9f7cb15 | 1440 | Int_t AlidNdPtHelper::GetSPDMBPrimTrackMult(const AliESDEvent* const esdEvent, AliStack* const stack, Float_t deltaThetaCut, Float_t deltaPhiCut) |
0aaa8b91 | 1441 | { |
1442 | // | |
1443 | // SPD track multiplicity | |
1444 | // | |
1445 | ||
1446 | // get tracklets | |
1447 | const AliMultiplicity* mult = esdEvent->GetMultiplicity(); | |
1448 | if (!mult) | |
1449 | return 0; | |
1450 | ||
1451 | // get multiplicity from SPD tracklets | |
1452 | Int_t inputCount = 0; | |
1453 | for (Int_t i=0; i<mult->GetNumberOfTracklets(); ++i) | |
1454 | { | |
1455 | //printf("%d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), mult->GetDeltaPhi(i)); | |
1456 | ||
1457 | Float_t phi = mult->GetPhi(i); | |
1458 | if (phi < 0) | |
1459 | phi += TMath::Pi() * 2; | |
1460 | Float_t deltaPhi = mult->GetDeltaPhi(i); | |
1461 | Float_t deltaTheta = mult->GetDeltaTheta(i); | |
1462 | ||
1463 | if (TMath::Abs(deltaPhi) > 1) | |
1464 | printf("WARNING: Very high Delta Phi: %d %f %f %f\n", i, mult->GetTheta(i), mult->GetPhi(i), deltaPhi); | |
1465 | ||
1466 | if (deltaThetaCut > 0. && TMath::Abs(deltaTheta) > deltaThetaCut) | |
1467 | continue; | |
1468 | ||
1469 | if (deltaPhiCut > 0. && TMath::Abs(deltaPhi) > deltaPhiCut) | |
1470 | continue; | |
1471 | ||
1472 | ||
1473 | if (mult->GetLabel(i, 0) < 0 || mult->GetLabel(i, 0) != mult->GetLabel(i, 1) || | |
1474 | !stack->IsPhysicalPrimary(mult->GetLabel(i, 0))) | |
1475 | continue; | |
1476 | ||
1477 | ||
1478 | ++inputCount; | |
1479 | } | |
1480 | ||
1481 | return inputCount; | |
1482 | } | |
fc98fbb5 | 1483 | //_____________________________________________________________________________ |
1484 | ||
1485 | THnSparse* AlidNdPtHelper::RebinTHnSparse(const THnSparse* hist1, THnSparse* hist2, const Char_t* newname, Option_t* option) | |
1486 | { | |
1487 | THnSparse* htemp = 0; | |
1488 | const THnSparse* hist = 0; | |
1489 | TString opt = option; | |
1490 | opt.ToLower(); | |
1491 | Bool_t calcErrors = kFALSE; | |
1492 | Bool_t useRange = kFALSE; | |
1493 | Bool_t overwrite = kFALSE; | |
1494 | if (opt.Contains("e")) { calcErrors = kTRUE; } // calcluate correct errors (not implemented) | |
1495 | if (opt.Contains("r")) { useRange = kTRUE; } // use the axis range given in hist1 | |
1496 | if (opt.Contains("o")) { overwrite = kTRUE; } // overwrite hist2 instead of creating a new one | |
1497 | Int_t ndim = hist1->GetNdimensions(); | |
1498 | if (ndim != hist2->GetNdimensions()) { | |
1499 | printf("AlidNdPtHelper::RebinTHnSparse: ERROR: Histograms have different dimensions \n"); | |
1500 | return 0; | |
1501 | } | |
1502 | Int_t* dims = new Int_t[ndim]; | |
1503 | for (Int_t i = 0; i < ndim; i++) { dims[i] = i; } | |
1504 | if (useRange) { | |
1505 | htemp = hist1->Projection(ndim,dims,"e"); | |
1506 | hist = htemp; | |
1507 | } else { hist = hist1; } | |
1508 | //THnSparse* hnew = hist2->Projection(ndim,dims,"o"); | |
1509 | //hnew->SetName(newname); | |
1510 | THnSparse* hnew = 0; | |
1511 | if (overwrite) { | |
1512 | hnew = hist2; | |
1513 | } else { | |
1514 | hnew = (THnSparse*) hist2->Clone(newname); | |
1515 | } | |
1516 | for (Int_t i = 0; i < ndim; i++) { hnew->GetAxis(i)->SetRange(); } | |
1517 | hnew->SetTitle(hist1->GetTitle()); | |
1518 | hnew->Reset(); | |
1519 | hnew->Sumw2(); | |
1520 | Double_t content; | |
1521 | Double_t error; | |
1522 | Int_t* c = new Int_t[ndim]; | |
1523 | Double_t* x = new Double_t[ndim]; | |
1524 | Long64_t n = hist->GetNbins(); | |
1525 | for (Long64_t j = 0; j < n; j++) { | |
1526 | content = hist->GetBinContent(j,c); | |
1527 | error = hist->GetBinError(j); | |
1528 | for (Int_t i = 0; i < ndim; i++) { | |
1529 | x[i] = hist->GetAxis(i)->GetBinCenter(c[i]); | |
1530 | } | |
1531 | /* function IsInRange is protected, shit! | |
1532 | if (useRange) { | |
1533 | if (! hist1->IsInRange(c)) continue; | |
1534 | } | |
1535 | */ | |
1536 | if (calcErrors) { | |
1537 | // implementation to be done | |
1538 | } else { | |
1539 | hnew->Fill(x,content); | |
1540 | } | |
1541 | } | |
1542 | delete[] c; c=0; | |
1543 | delete[] x; x=0; | |
1544 | delete[] dims; dims=0; | |
1545 | if (htemp) { delete htemp; htemp = 0;} | |
1546 | return hnew; | |
1547 | } | |
0aaa8b91 | 1548 | |
1549 |