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