Add fast merging option (Diego)
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectronVarContainer.h
CommitLineData
ba15fdfb 1#ifndef ALIDIELECTRONVARCONTAINER_H
2#define ALIDIELECTRONVARCONTAINER_H
3/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6//#############################################################
7//# #
8//# Class AliDielectronVarContainer #
9//# Class for management of available variables #
10//# #
11//# Authors: #
12//# Anton Andronic, GSI / A.Andronic@gsi.de #
13//# Ionut C. Arsene, GSI / I.C.Arsene@gsi.de #
14//# Julian Book, Uni Ffm / Julian.Book@cern.ch #
15//# Markus Köhler, GSI / M.Koehler@gsi.de #
16//# Frederick Kramer, Uni Ffm / Frederick.Kramer@cern.ch #
17//# Magnus Mager, CERN / Magnus.Mager@cern.ch #
18//# WooJin J. Park, GSI / W.J.Park@gsi.de #
19//# Jens Wiechula, Uni HD / Jens.Wiechula@cern.ch #
20//# #
21//#############################################################
22
23
24#include <TNamed.h>
25#include <TDatabasePDG.h>
26
27#include <AliVEvent.h>
28#include <AliESDEvent.h>
29#include <AliAODEvent.h>
30#include <AliMCEvent.h>
31#include <AliESDVertex.h>
32#include <AliAODVertex.h>
33
34#include <AliVParticle.h>
35#include <AliESDtrack.h>
36#include <AliAODTrack.h>
37#include <AliAODPid.h>
38#include <AliKFParticle.h>
39#include <AliKFVertex.h>
40#include <AliMCParticle.h>
41#include <AliAODMCParticle.h>
42#include <AliVTrack.h> // ?
43
44#include <AliExternalTrackParam.h>
45#include <AliESDpid.h>
46#include <AliCentrality.h>
47#include <AliAODpidUtil.h>
48#include <AliPID.h>
49#include <AliPIDResponse.h>
50
51#include "AliDielectronPair.h"
52#include "AliDielectronMC.h"
53#include "AliDielectronPID.h"
54#include "AliDielectronHelper.h"
55
56class AliVEvent;
57
58//________________________________________________________________
59class AliDielectronVarContainer : public TNamed {
60
61public:
62
63 enum ValueTypes {
64 // Leg specific variables
65 kPx = 0, // px
66 kPy, // py
67 kPz, // pz
68 kPt, // transverse momentum
69 kP, // momentum
70 kXv, // vertex position in x
71 kYv, // vertex position in y
72 kZv, // vertex position in z
73 kOneOverPt, // 1/pt
74 kPhi, // phi angle
75 kTheta, // theta angle
76 kEta, // pseudo-rapidity
77 kY, // rapidity
78 kE, // energy
79 kM, // mass
80 kCharge, // charge
81 kNclsITS, // number of clusters assigned in the ITS
82 kNclsTPC, // number of clusters assigned in the TPC
83 kNclsTPCiter1, // number of clusters assigned in the TPC after first iteration
84 kNFclsTPC, // number of findable clusters in the TPC
85 kNFclsTPCr, // number of findable clusters in the TPC with more robust definition
86 kNFclsTPCrFrac, // number of found/findable clusters in the TPC with more robust definition
87 kTPCsignalN, // number of points used for dEdx
88 kTPCsignalNfrac, // fraction of points used for dEdx / cluster used for tracking
89 kTPCchi2Cl, // chi2/cl in TPC
90 kTrackStatus, // track status bits
91 kNclsTRD, // number of clusters assigned in the TRD
92 kTRDntracklets, // number of TRD tracklets used for tracking/PID TODO: correct getter
93 kTRDpidQuality, // number of TRD tracklets used for PID
94 kTRDprobEle, // TRD electron pid probability
95 kTRDprobPio, // TRD electron pid probability
96 kImpactParXY, // Impact parameter in XY plane
97 kImpactParZ, // Impact parameter in Z
98 kTrackLength, // Track length
99 kITSsignal, // ITS dE/dx signal
100 kITSsignalSSD1, // SSD1 dE/dx signal
101 kITSsignalSSD2, // SSD2 dE/dx signal
102 kITSsignalSDD1, // SDD1 dE/dx signal
103 kITSsignalSDD2, // SDD2 dE/dx signal
104 kITSclusterMap, // ITS cluster map
105 kITSnSigmaEle, // number of sigmas to the dE/dx electron line in the ITS
106 kITSnSigmaPio, // number of sigmas to the dE/dx pion line in the ITS
107 kITSnSigmaMuo, // number of sigmas to the dE/dx muon line in the ITS
108 kITSnSigmaKao, // number of sigmas to the dE/dx kaon line in the ITS
109 kITSnSigmaPro, // number of sigmas to the dE/dx proton line in the ITS
110 kPIn, // momentum at inner wall of TPC (if available), used for PID
111 kTPCsignal, // TPC dE/dx signal
112 kTOFsignal, // TOF signal
113 kTOFbeta, // TOF beta
114 kTPCnSigmaEle, // number of sigmas to the dE/dx electron line in the TPC
115 kTPCnSigmaPio, // number of sigmas to the dE/dx pion line in the TPC
116 kTPCnSigmaMuo, // number of sigmas to the dE/dx muon line in the TPC
117 kTPCnSigmaKao, // number of sigmas to the dE/dx kaon line in the TPC
118 kTPCnSigmaPro, // number of sigmas to the dE/dx proton line in the TPC
119 kTOFnSigmaEle, // number of sigmas to the pion line in the TOF
120 kTOFnSigmaPio, // number of sigmas to the pion line in the TOF
121 kTOFnSigmaMuo, // number of sigmas to the muon line in the TOF
122 kTOFnSigmaKao, // number of sigmas to the kaon line in the TOF
123 kTOFnSigmaPro, // number of sigmas to the proton line in the TOF
124 kKinkIndex0, // kink index 0
125 kParticleMax, // TODO: kRNClusters ??
126
127 // Pair specific variables
128 kChi2NDF = kParticleMax, // Chi^2/NDF
129 kDecayLength, // decay length
130 kR, // distance to the origin
131 kOpeningAngle, // opening angle
132 // Helicity picture: Z-axis is considered the direction of the mother's 3-momentum vector
133 kThetaHE, // theta in mother's rest frame in the helicity picture
134 kPhiHE, // phi in mother's rest frame in the helicity picture
135 // Collins-Soper picture: Z-axis is considered the direction of the vectorial difference between
136 // the 3-mom vectors of target and projectile beams
137 kThetaCS, // theta in mother's rest frame in Collins-Soper picture
138 kPhiCS, // phi in mother's rest frame in Collins-Soper picture
139 kLegDist, // distance of the legs
140 kLegDistXY, // distance of the legs in XY
141 kDeltaEta, // Absolute value of Delta Eta for the legs
142 kDeltaPhi, // Absolute value of Delta Phi for the legs
143 kMerr, // error of mass calculation
144 kDCA, // distance of closest approach TODO: not implemented yet
145 kPairType, // type of the pair, like like sign ++ unlikesign ...
146 kPseudoProperTime, // pseudo proper time
147 kPairMax, //
148
149 // Event specific variables
150 kXvPrim = kPairMax, // prim vertex x
151 kYvPrim, // prim vertex y
152 kZvPrim, // prim vertex z
153 kXRes, // primary vertex x-resolution
154 kYRes, // primary vertex y-resolution
155 kZRes, // primary vertex z-resolution
156 kNContrib, // Number of vertex contributors
157 kBzkG, // z componenent of field in kG
158 kNTrk, // number of tracks
159 kNacc, // Number of accepted tracks
160 kNaccTrcklts, // Number of accepted tracklets (MUON definition)
161 kCentrality, // event centrality fraction
162 kNevents, // event counter
163 kNMaxValues // TODO: (for A+A) ZDCEnergy, impact parameter, Iflag??
164 };
165
166
167 enum ValueTypesMC {
168 // Leg specific variables
44f2f99f 169 kPxMC = 0, // px
170 kPyMC, // py
171 kPzMC, // pz
172 kPtMC, // transverse momentum
173 kPMC, // momentum
174 kXvMC, // vertex position in x
175 kYvMC, // vertex position in y
176 kZvMC, // vertex position in z
177 kOneOverPtMC, // 1/pt
178 kPhiMC, // phi angle
179 kThetaMC, // theta angle
180 kEtaMC, // pseudo-rapidity
181 kYMC, // rapidity
182 kEMC, // energy
183 kMMC, // mass
184 kChargeMC, // charge
185 kImpactParXYMC, // Impact parameter in XY plane
186 kImpactParZMC, // Impact parameter in Z
ba15fdfb 187 kPdgCode, // PDG code
188 kPdgCodeMother, // PDG code of the mother
189 kPdgCodeGrandMother, // PDG code of the grand mother
190 kNumberOfDaughters, // number of daughters
191 kHaveSameMother, // check that particles have the same mother (MC)
192 kIsJpsiPrimary, // check if the particle is primary (MC)
44f2f99f 193 kParticleMaxMC, //
ba15fdfb 194
195// Pair specific variables
44f2f99f 196 kDecayLengthvMC = kParticleMaxMC, // decay length
197 kRMC, // distance to the origin
198 kOpeningAngleMC, // opening angle
ba15fdfb 199 // Helicity picture: Z-axis is considered the direction of the mother's 3-momentum vector
44f2f99f 200 kThetaHEMC, // theta in mother's rest frame in the helicity picture
201 kPhiHEMC, // phi in mother's rest frame in the helicity picture
ba15fdfb 202 // Collins-Soper picture: Z-axis is considered the direction of the vectorial difference between
203 // the 3-mom vectors of target and projectile beams
44f2f99f 204 kThetaCSMC, // theta in mother's rest frame in Collins-Soper picture
205 kPhiCSMC, // phi in mother's rest frame in Collins-Soper picture
206 kLegDistMC, // distance of the legs
207 kLegDistXYMC, // distance of the legs in XY
208 kDeltaEtaMC, // Absolute value of Delta Eta for the legs
209 kDeltaPhiMC, // Absolute value of Delta Phi for the legs
210 kDCAMC, // distance of closest approach TODO: not implemented yet
211 kPairTypeMC, // type of the pair, like like sign ++ unlikesign ...
212 kPseudoProperTimeMC, // pseudo proper time
213 kPairMaxMC, //
ba15fdfb 214
215// Event specific variables
44f2f99f 216 kXvPrimMC = kPairMaxMC, // prim vertex x
217 kYvPrimMC, // prim vertex y
218 kZvPrimMC, // prim vertex z
ba15fdfb 219 kNch, // Number of charged MC tracks
44f2f99f 220 kCentralityMC, // event centrality fraction
221 kNeventsMC, // event counter
222 kNMaxValuesMC // TODO: (for A+A) ZDCEnergy, impact parameter, Iflag??
ba15fdfb 223 };
224
225
226
227 AliDielectronVarContainer();
228 AliDielectronVarContainer(const char* name, const char* title);
229 virtual ~AliDielectronVarContainer();
230
231 static void Fill(const TObject* object);
232 static void InitESDpid(Int_t type=0);
233 static void InitAODpidUtil(Int_t type=0);
234
235 static void SetESDpid(AliESDpid * const pid) { fgPIDResponse=pid; }
236 static void SetPIDResponse(AliPIDResponse *pidResponse) { fgPIDResponse=pidResponse; }
237 static void SetEvent(AliVEvent * const event); // TODO: needed?
238
239 static AliESDpid* GetESDpid() { return (AliESDpid*)fgPIDResponse; }
240 static AliAODpidUtil* GetAODpidUtil() { return (AliAODpidUtil*)fgPIDResponse; }
241 static const AliKFVertex* GetKFVertex() { return fgKFVertex; }
242 static const char* GetValueName(Int_t i) { return (i>=0&&i<kNMaxValues)?fgkParticleNames[i]:""; }
243 static const Double_t* GetData() { return fgData; }
244 static const Double_t* GetDataMC() { return fgDataMC; }
245 static Double_t GetValue(ValueTypes val) { return fgData[val]; }
246 static Double_t GetValueMC(ValueTypesMC val) { return fgDataMC[val]; }
247 static Bool_t GetDCA(const AliAODTrack *track, Double_t d0z0[2]);
248
249private:
250
251 static Double_t fgData[kNMaxValues]; //! data
44f2f99f 252 static Double_t fgDataMC[kNMaxValuesMC]; //! MC data
ba15fdfb 253 static const char* fgkParticleNames[kNMaxValues]; // variable names
44f2f99f 254 static const char* fgkParticleNamesMC[kNMaxValuesMC]; // MC variable names
ba15fdfb 255
256 static void FillVarVParticle(const AliVParticle *particle);
257 static void FillVarVParticleMC(const AliVParticle *particle);
258 static void FillVarESDtrack(const AliESDtrack *particle);
259 static void FillVarAODTrack(const AliAODTrack *particle);
260 static void FillVarMCParticle(const AliMCParticle *particle);
261 static void FillVarAODMCParticle(const AliAODMCParticle *particle);
262 static void FillVarDielectronPair(const AliDielectronPair *pair);
263 static void FillVarKFParticle(const AliKFParticle *pair);
264
265 static void FillVarVEvent(const AliVEvent *event);
266 static void FillVarESDEvent(const AliESDEvent *event);
267 static void FillVarAODEvent(const AliAODEvent *event);
268 static void FillVarMCEvent(const AliMCEvent *event);
269 static void ResetArrayData(Int_t to);
270 static void ResetArrayDataMC(Int_t to);
271
272 static Double_t GetPseudoProperTime(const AliDielectronPair *pair);
273
274 static AliPIDResponse *fgPIDResponse; // PID response object
275 static AliKFVertex *fgKFVertex; // KF vertex
276 static AliAODVertex *fgAODVertex; // AOD vertex
277
278
279 AliDielectronVarContainer(const AliDielectronVarContainer &c);
280 AliDielectronVarContainer &operator=(const AliDielectronVarContainer &c);
281
282 ClassDef(AliDielectronVarContainer,1);
283};
284
285
286//Inline functions
287inline void AliDielectronVarContainer::Fill(const TObject* object)
288{
289 //
290 // Main function to fill all available variables according to the type of particle
291 //
292
293 // Protect
294 if (!object) return;
295
296 if (object->IsA() == AliESDtrack::Class()) FillVarESDtrack(static_cast<const AliESDtrack*>(object));
297 else if (object->IsA() == AliAODTrack::Class()) FillVarAODTrack(static_cast<const AliAODTrack*>(object));
298 else if (object->IsA() == AliMCParticle::Class()) FillVarMCParticle(static_cast<const AliMCParticle*>(object));
299 else if (object->IsA() == AliAODMCParticle::Class()) FillVarAODMCParticle(static_cast<const AliAODMCParticle*>(object));
300 else if (object->IsA() == AliDielectronPair::Class()) FillVarDielectronPair(static_cast<const AliDielectronPair*>(object));
301 else if (object->IsA() == AliKFParticle::Class()) FillVarKFParticle(static_cast<const AliKFParticle*>(object));
302 //else if (object->IsA() == TParticle::Class()) FillVarTParticle(static_cast<const TParticle*>(object));
303
304 // Main function to fill all available variables according to the type of event
305 else if (object->IsA() == AliVEvent::Class()) FillVarVEvent(static_cast<const AliVEvent*>(object));
306 else if (object->IsA() == AliESDEvent::Class()) FillVarESDEvent(static_cast<const AliESDEvent*>(object));
307 else if (object->IsA() == AliAODEvent::Class()) FillVarAODEvent(static_cast<const AliAODEvent*>(object));
308 else if (object->IsA() == AliMCEvent::Class()) FillVarMCEvent(static_cast<const AliMCEvent*>(object));
309// else printf(Form("AliDielectronVarContainer::Fill: Type %s is not supported by AliDielectronVarContainer!", object->ClassName())); //TODO: implement without object needed
310}
311
312
313
314inline void AliDielectronVarContainer::ResetArrayData(Int_t to)
315{
316 // Protect
317 if (to >= AliDielectronVarContainer::kNMaxValues) return;
318 // Reset
319 for (Int_t i=0; i<to; ++i) fgData[i] = 0.;
320
321 fgData[AliDielectronVarContainer::kTPCchi2Cl] = -1;
322}
323
324
325inline void AliDielectronVarContainer::ResetArrayDataMC(Int_t to)
326{
327 // Protect
44f2f99f 328 if (to >= AliDielectronVarContainer::kNMaxValuesMC) return;
ba15fdfb 329 // Reset
330 //for (Int_t i=0; i<to; ++i) fgDataMC[i] = 0.;
331
332 //fgDataMC[AliDielectronVarContainer::kPdgCode] = -1.;
333 //fgDataMC[AliDielectronVarContainer::kPdgCodeMother] = -1.;
334 //fgDataMC[AliDielectronVarContainer::kPdgCodeGrandMother] = -1.;
335 //fgDataMC[AliDielectronVarContainer::kNumberOfDaughters] = -999.;
336}
337
338
339inline void AliDielectronVarContainer::FillVarVParticle(const AliVParticle *particle)
340{
341 //
342 // Fill track information available in AliVParticle into array
343 //
344
345 // Protect
346 if (!particle) return;
347
348 // Reset
349 ResetArrayData(AliDielectronVarContainer::kPairMax);
350
351 // Set
352 fgData[AliDielectronVarContainer::kPx] = particle->Px();
353 fgData[AliDielectronVarContainer::kPy] = particle->Py();
354 fgData[AliDielectronVarContainer::kPz] = particle->Pz();
355 fgData[AliDielectronVarContainer::kPt] = particle->Pt();
356 fgData[AliDielectronVarContainer::kP] = particle->P();
357 fgData[AliDielectronVarContainer::kXv] = particle->Xv();
358 fgData[AliDielectronVarContainer::kYv] = particle->Yv();
359 fgData[AliDielectronVarContainer::kZv] = particle->Zv();
360 fgData[AliDielectronVarContainer::kOneOverPt] = particle->OneOverPt();
361 fgData[AliDielectronVarContainer::kPhi] = particle->Phi();
362 fgData[AliDielectronVarContainer::kTheta] = particle->Theta();
363 fgData[AliDielectronVarContainer::kEta] = particle->Eta();
364 fgData[AliDielectronVarContainer::kY] = particle->Y();
365 fgData[AliDielectronVarContainer::kE] = particle->E();
366 fgData[AliDielectronVarContainer::kM] = particle->M();
367 fgData[AliDielectronVarContainer::kCharge] = particle->Charge();
368 fgData[AliDielectronVarContainer::kPdgCode] = particle->PdgCode();
369}
370
371
372inline void AliDielectronVarContainer::FillVarVParticleMC(const AliVParticle *particle)
373{
374 //
375 // Fill MC track information available in AliVParticle into array
376 //
377
378 // Protect
379 if (!particle) return;
380
381 // Get the MC interface if available
382 AliDielectronMC *mc = AliDielectronMC::Instance();
383 if (!mc->HasMC()) return;
384
385 // Reset
44f2f99f 386 ResetArrayDataMC(AliDielectronVarContainer::kPairMaxMC);
ba15fdfb 387
388 // If called for a reco track, get the MC track first
389 if (particle->IsA() == AliESDtrack::Class()) particle = mc->GetMCTrack((AliESDtrack*)particle);
390 if (particle->IsA() == AliAODTrack::Class()) particle = mc->GetMCTrack((AliAODTrack*)particle);
391 if (!particle) return;
392
393 // Set the AliDielectronMC specific info
394 if (particle->IsA() == AliMCParticle::Class()) {
395 AliMCParticle* mcParticle = (AliMCParticle*)particle;
396 if (mc->GetMCTrackMother(mcParticle)) {
397 fgDataMC[AliDielectronVarContainer::kPdgCodeMother] = mc->GetMCTrackMother(mcParticle)->PdgCode();
398 if (mc->GetMCTrackMother(mc->GetMCTrackMother(mcParticle)))
399 fgDataMC[AliDielectronVarContainer::kPdgCodeGrandMother] = mc->GetMCTrackMother(mc->GetMCTrackMother(mcParticle))->PdgCode();;
400 }
401 fgDataMC[AliDielectronVarContainer::kNumberOfDaughters] = mc->NumberOfDaughters(mcParticle);
402 } else if (particle->IsA() == AliAODMCParticle::Class()) {
403 AliAODMCParticle* mcParticle = (AliAODMCParticle*)particle;
404 if (mc->GetMCTrackMother(mcParticle)) {
405 fgDataMC[AliDielectronVarContainer::kPdgCodeMother] = mc->GetMCTrackMother(mcParticle)->PdgCode();
406 if (mc->GetMCTrackMother(mc->GetMCTrackMother(mcParticle)))
407 fgDataMC[AliDielectronVarContainer::kPdgCodeGrandMother] = mc->GetMCTrackMother(mc->GetMCTrackMother(mcParticle))->PdgCode();;
408 }
409 fgDataMC[AliDielectronVarContainer::kNumberOfDaughters] = mc->NumberOfDaughters(mcParticle);
410 }
411
412
413 // Set the common info
414 fgData[AliDielectronVarContainer::kIsJpsiPrimary] = mc->IsJpsiPrimary(particle);
415 fgDataMC[AliDielectronVarContainer::kPdgCode] = particle->PdgCode();
44f2f99f 416 fgDataMC[AliDielectronVarContainer::kPxMC] = particle->Px();
417 fgDataMC[AliDielectronVarContainer::kPyMC] = particle->Py();
418 fgDataMC[AliDielectronVarContainer::kPzMC] = particle->Pz();
419 fgDataMC[AliDielectronVarContainer::kPtMC] = particle->Pt();
420 fgDataMC[AliDielectronVarContainer::kPMC] = particle->P();
421 fgDataMC[AliDielectronVarContainer::kXvMC] = particle->Xv();
422 fgDataMC[AliDielectronVarContainer::kYvMC] = particle->Yv();
423 fgDataMC[AliDielectronVarContainer::kZvMC] = particle->Zv();
424 fgDataMC[AliDielectronVarContainer::kOneOverPtMC] = particle->OneOverPt();
425 fgDataMC[AliDielectronVarContainer::kPhiMC] = particle->Phi();
426 fgDataMC[AliDielectronVarContainer::kThetaMC] = particle->Theta();
427 fgDataMC[AliDielectronVarContainer::kEtaMC] = particle->Eta();
428 fgDataMC[AliDielectronVarContainer::kYMC] = particle->Y();
429 fgDataMC[AliDielectronVarContainer::kEMC] = particle->E();
430 fgDataMC[AliDielectronVarContainer::kMMC] = particle->M();
431 fgDataMC[AliDielectronVarContainer::kChargeMC] = particle->Charge();
ba15fdfb 432}
433
434
435inline void AliDielectronVarContainer::FillVarESDtrack(const AliESDtrack *particle)
436{
437 //
438 // Fill AliESDtrack interface specific information
439 //
440
441 // Fill common AliVParticle interface information
442 FillVarVParticle(particle);
443 // Fill common MC information if available
444 FillVarVParticleMC(particle);
445
446 Double_t tpcNcls=particle->GetTPCNcls();
447 Double_t tpcSignalN=particle->GetTPCsignalN();
448 fgData[AliDielectronVarContainer::kNclsITS] = particle->GetNcls(0); // TODO: get rid of the plain numbers
449 fgData[AliDielectronVarContainer::kNclsTPC] = tpcNcls; // TODO: get rid of the plain numbers
450 fgData[AliDielectronVarContainer::kNclsTPCiter1] = particle->GetTPCNclsIter1(); // TODO: get rid of the plain numbers
451 fgData[AliDielectronVarContainer::kNFclsTPC] = particle->GetTPCNclsF();
452 fgData[AliDielectronVarContainer::kNFclsTPCr] = particle->GetTPCClusterInfo(2,1);
453 fgData[AliDielectronVarContainer::kNFclsTPCrFrac] = particle->GetTPCClusterInfo(2);
454 fgData[AliDielectronVarContainer::kTPCsignalN] = tpcSignalN;
455 fgData[AliDielectronVarContainer::kTPCsignalNfrac]= tpcNcls>0?tpcSignalN/tpcNcls:0;
456 fgData[AliDielectronVarContainer::kNclsTRD] = particle->GetNcls(2); // TODO: get rid of the plain numbers
457 fgData[AliDielectronVarContainer::kTRDntracklets] = particle->GetTRDntracklets(); // TODO: GetTRDtracklets/GetTRDntracklets?
458 fgData[AliDielectronVarContainer::kTRDpidQuality] = particle->GetTRDpidQuality();
459 fgData[AliDielectronVarContainer::kTrackStatus] = (Double_t)particle->GetStatus();
460 if (tpcNcls>0) fgData[AliDielectronVarContainer::kTPCchi2Cl] = particle->GetTPCchi2() / tpcNcls;
461
462 //TRD pidProbs
463 Double_t pidProbs[AliPID::kSPECIES];
464 particle->GetTRDpid(pidProbs);
465 fgData[AliDielectronVarContainer::kTRDprobEle] = pidProbs[AliPID::kElectron];
466 fgData[AliDielectronVarContainer::kTRDprobPio] = pidProbs[AliPID::kPion];
467
468 fgData[AliDielectronVarContainer::kKinkIndex0] = particle->GetKinkIndex(0);
469
470 Float_t impactParXY, impactParZ;
471 particle->GetImpactParameters(impactParXY, impactParZ);
472 fgData[AliDielectronVarContainer::kImpactParXY] = impactParXY;
473 fgData[AliDielectronVarContainer::kImpactParZ] = impactParZ;
474
475 fgData[AliDielectronVarContainer::kITSsignal] = particle->GetITSsignal();
476
477 Double_t itsdEdx[4];
478 particle->GetITSdEdxSamples(itsdEdx);
479
480 fgData[AliDielectronVarContainer::kITSsignalSSD1] = itsdEdx[0];
481 fgData[AliDielectronVarContainer::kITSsignalSSD2] = itsdEdx[1];
482 fgData[AliDielectronVarContainer::kITSsignalSDD1] = itsdEdx[2];
483 fgData[AliDielectronVarContainer::kITSsignalSDD2] = itsdEdx[3];
484 fgData[AliDielectronVarContainer::kITSclusterMap] = particle->GetITSClusterMap();
485
486 fgData[AliDielectronVarContainer::kTrackLength] = particle->GetIntegratedLength();
487
488 //dEdx information
489 Double_t mom = particle->GetP();
490 const AliExternalTrackParam *in=particle->GetInnerParam();
491 if (in) mom = in->GetP();
492 fgData[AliDielectronVarContainer::kPIn]=mom;
493 fgData[AliDielectronVarContainer::kTPCsignal] = particle->GetTPCsignal();
494 fgData[AliDielectronVarContainer::kTOFsignal] = particle->GetTOFsignal();
495
496 Double_t l = particle->GetIntegratedLength(); // cm
497 Double_t t = particle->GetTOFsignal();
498 Double_t t0 = fgPIDResponse->GetTOFResponse().GetTimeZero(); // ps
499
500 if( (l < 360. || l > 800.) || (t <= 0.) || (t0 >999990.0) ) {
501 fgData[AliDielectronVarContainer::kTOFbeta]=0.0;
502 } else {
503 t -= t0; // subtract the T0
504 l *= 0.01; // cm ->m
505 t *= 1e-12; //ps -> s
506
507 Double_t v = l / t;
508 Float_t beta = v / TMath::C();
509 fgData[AliDielectronVarContainer::kTOFbeta] = beta;
510 }
511
512 // nsigma to Electron band
513 // TODO: for the moment we set the bethe bloch parameters manually
514 // this should be changed in future!
515
516 fgData[AliDielectronVarContainer::kTPCnSigmaEle]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kElectron)-AliDielectronPID::GetCorrVal();
517 fgData[AliDielectronVarContainer::kTPCnSigmaPio]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kPion);
518 fgData[AliDielectronVarContainer::kTPCnSigmaMuo]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kMuon);
519 fgData[AliDielectronVarContainer::kTPCnSigmaKao]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kKaon);
520 fgData[AliDielectronVarContainer::kTPCnSigmaPro]=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kProton);
521
522 fgData[AliDielectronVarContainer::kITSnSigmaEle]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kElectron);
523 fgData[AliDielectronVarContainer::kITSnSigmaPio]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kPion);
524 fgData[AliDielectronVarContainer::kITSnSigmaMuo]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kMuon);
525 fgData[AliDielectronVarContainer::kITSnSigmaKao]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kKaon);
526 fgData[AliDielectronVarContainer::kITSnSigmaPro]=fgPIDResponse->NumberOfSigmasITS(particle,AliPID::kProton);
527
528 fgData[AliDielectronVarContainer::kTOFnSigmaEle]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kElectron);
529 fgData[AliDielectronVarContainer::kTOFnSigmaPio]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kPion);
530 fgData[AliDielectronVarContainer::kTOFnSigmaMuo]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kMuon);
531 fgData[AliDielectronVarContainer::kTOFnSigmaKao]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kKaon);
532 fgData[AliDielectronVarContainer::kTOFnSigmaPro]=fgPIDResponse->NumberOfSigmasTOF(particle,AliPID::kProton);
533}
534
535inline void AliDielectronVarContainer::FillVarAODTrack(const AliAODTrack *particle)
536{
537 //
538 // Fill track information available for histogramming into an array
539 //
540
541 // Fill common AliVParticle interface information
542 FillVarVParticle(particle);
543 // Fill common MC information if available
544 FillVarVParticleMC(particle);
545
546 Double_t tpcNcls=particle->GetTPCNcls();
547 // Reset AliESDtrack interface specific information
548 fgData[AliDielectronVarContainer::kNclsTPC] = tpcNcls;
549 fgData[AliDielectronVarContainer::kNclsTPCiter1] = tpcNcls; // not really available in AOD
550 fgData[AliDielectronVarContainer::kTrackStatus] = (Double_t)particle->GetStatus();
551
552 //TODO: set TRD pidProbs correctly
553
554 // Fill AliAODTrack interface information
555 //
556 Double_t d0z0[2];
557 GetDCA(particle, d0z0);
558 fgData[AliDielectronVarContainer::kImpactParXY] = d0z0[0];
559 fgData[AliDielectronVarContainer::kImpactParZ] = d0z0[1];
560 fgData[AliDielectronVarContainer::kITSclusterMap] = particle->GetITSClusterMap();
561
562 AliAODPid *pid=particle->GetDetPid();
563 if (pid){
564 Double_t mom =pid->GetTPCmomentum();
565 Double_t tpcSignalN=pid->GetTPCsignalN();
566 fgData[AliDielectronVarContainer::kTPCsignalN] = tpcSignalN;
567 fgData[AliDielectronVarContainer::kTPCsignalN] = tpcNcls>0?tpcSignalN/tpcNcls:0;
568 Double_t tpcNsigmaEle=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kElectron);
569 Double_t tpcNsigmaPio=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kPion);
570 Double_t tpcNsigmaMuo=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kMuon);
571 Double_t tpcNsigmaKao=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kKaon);
572 Double_t tpcNsigmaPro=fgPIDResponse->NumberOfSigmasTPC(particle,AliPID::kProton);
573
574 fgData[AliDielectronVarContainer::kPIn]=mom;
575 fgData[AliDielectronVarContainer::kTPCsignal]=pid->GetTPCsignal();
576
577 fgData[AliDielectronVarContainer::kTPCnSigmaEle]=tpcNsigmaEle;
578 fgData[AliDielectronVarContainer::kTPCnSigmaPio]=tpcNsigmaPio;
579 fgData[AliDielectronVarContainer::kTPCnSigmaMuo]=tpcNsigmaMuo;
580 fgData[AliDielectronVarContainer::kTPCnSigmaKao]=tpcNsigmaKao;
581 fgData[AliDielectronVarContainer::kTPCnSigmaPro]=tpcNsigmaPro;
582 }
583}
584
585
586inline void AliDielectronVarContainer::FillVarMCParticle(const AliMCParticle *particle)
587{
588 //
589 // Fill track information available for histogramming into an array
590 //
591
592 // Fill common AliVParticle interface information
593 FillVarVParticle(particle);
594 // Fill common MC information if available
595 FillVarVParticleMC(particle);
596
597
598 // Fill AliMCParticle interface specific information
599
600}
601
602inline void AliDielectronVarContainer::FillVarAODMCParticle(const AliAODMCParticle *particle)
603{
604 //
605 // Fill track information available for histogramming into an array
606 //
607
608 // Fill common AliVParticle interface information
609 FillVarVParticle(particle);
610 // Fill common MC information if available
611 FillVarVParticleMC(particle);
612
613
614 // Fill AliAODMCParticle interface specific information
615
616}
617
618inline void AliDielectronVarContainer::FillVarDielectronPair(const AliDielectronPair *pair)
619{
620 //
621 // Fill pair information available for histogramming into an array
622 //
623
624 // Fill common AliVParticle interface information
625 FillVarVParticle(pair);
626 // Reset MC array
44f2f99f 627 ResetArrayDataMC(AliDielectronVarContainer::kPairMaxMC);
ba15fdfb 628
629 // Fill AliDielectronPair specific information
630 const AliKFParticle &kfPair = pair->GetKFParticle();
631
632 Double_t thetaHE=0;
633 Double_t phiHE=0;
634 Double_t thetaCS=0;
635 Double_t phiCS=0;
636
637 pair->GetThetaPhiCM(thetaHE,phiHE,thetaCS,phiCS);
638
639 fgData[AliDielectronVarContainer::kChi2NDF] = kfPair.GetChi2()/kfPair.GetNDF();
640 fgData[AliDielectronVarContainer::kDecayLength] = kfPair.GetDecayLength();
641 fgData[AliDielectronVarContainer::kR] = kfPair.GetR();
642 fgData[AliDielectronVarContainer::kOpeningAngle] = pair->OpeningAngle();
643 fgData[AliDielectronVarContainer::kThetaHE] = thetaHE;
644 fgData[AliDielectronVarContainer::kPhiHE] = phiHE;
645 fgData[AliDielectronVarContainer::kThetaCS] = thetaCS;
646 fgData[AliDielectronVarContainer::kPhiCS] = phiCS;
647 fgData[AliDielectronVarContainer::kLegDist] = pair->DistanceDaughters();
648 fgData[AliDielectronVarContainer::kLegDistXY] = pair->DistanceDaughtersXY();
649 fgData[AliDielectronVarContainer::kDeltaEta] = pair->DeltaEta();
650 fgData[AliDielectronVarContainer::kDeltaPhi] = pair->DeltaPhi();
651 fgData[AliDielectronVarContainer::kMerr] = kfPair.GetErrMass()>1e-30&&kfPair.GetMass()>1e-30?kfPair.GetErrMass()/kfPair.GetMass():1000000;
652 fgData[AliDielectronVarContainer::kPairType] = pair->GetType();
653 fgData[AliDielectronVarContainer::kPseudoProperTime] = GetPseudoProperTime(pair);
654
655
656 AliDielectronMC *mc=AliDielectronMC::Instance();
657 if (mc->HasMC()){
658 Bool_t samemother = mc->HaveSameMother(pair);
659 fgDataMC[AliDielectronVarContainer::kIsJpsiPrimary] = mc->IsJpsiPrimary(pair);
660 fgDataMC[AliDielectronVarContainer::kHaveSameMother] = samemother ;
661 }
662
663}
664
665
666inline void AliDielectronVarContainer::FillVarKFParticle(const AliKFParticle *particle)
667{
668 //
669 // Fill track information available in AliKFParticle into an array
670 //
671
672 // Reset data array
673 ResetArrayData(AliDielectronVarContainer::kPairMax);
674 // Reset MC array
44f2f99f 675 ResetArrayDataMC(AliDielectronVarContainer::kPairMaxMC);
ba15fdfb 676
677
678 fgData[AliDielectronVarContainer::kPx] = particle->GetPx();
679 fgData[AliDielectronVarContainer::kPy] = particle->GetPy();
680 fgData[AliDielectronVarContainer::kPz] = particle->GetPz();
681 fgData[AliDielectronVarContainer::kPt] = particle->GetPt();
682 fgData[AliDielectronVarContainer::kP] = particle->GetP();
683 fgData[AliDielectronVarContainer::kXv] = particle->GetX();
684 fgData[AliDielectronVarContainer::kYv] = particle->GetY();
685 fgData[AliDielectronVarContainer::kZv] = particle->GetZ();
686 fgData[AliDielectronVarContainer::kPhi] = particle->GetPhi();
687 fgData[AliDielectronVarContainer::kEta] = particle->GetEta();
688 fgData[AliDielectronVarContainer::kY] = ((particle->GetE()*particle->GetE()-particle->GetPx()*particle->GetPx()-particle->GetPy()*particle->GetPy()-particle->GetPz()*particle->GetPz())>0.) ? TLorentzVector(particle->GetPx(),particle->GetPy(),particle->GetPz(),particle->GetE()).Rapidity() : -1111.;
689 fgData[AliDielectronVarContainer::kE] = particle->GetE();
690 fgData[AliDielectronVarContainer::kM] = particle->GetMass();
691 fgData[AliDielectronVarContainer::kCharge] = particle->GetQ();
692}
693
694
695inline void AliDielectronVarContainer::FillVarVEvent(const AliVEvent *event)
696{
697 //
698 // Fill event information available for histogramming into an array
699 //
700
701 // Reset data array
702 ResetArrayData(AliDielectronVarContainer::kNMaxValues);
703 // Reset MC array
44f2f99f 704 ResetArrayDataMC(AliDielectronVarContainer::kNMaxValuesMC);
ba15fdfb 705
706 // set the KF vertex
707 if (fgKFVertex) delete fgKFVertex;
708 fgKFVertex = 0x0;
709 if (!event->GetPrimaryVertex()) return;
710 fgKFVertex = new AliKFVertex(*event->GetPrimaryVertex());
711
712
713 fgData[AliDielectronVarContainer::kXvPrim] = event->GetPrimaryVertex()->GetX();
714 fgData[AliDielectronVarContainer::kYvPrim] = event->GetPrimaryVertex()->GetY();
715 fgData[AliDielectronVarContainer::kZvPrim] = event->GetPrimaryVertex()->GetZ();
716 fgData[AliDielectronVarContainer::kNContrib] = event->GetPrimaryVertex()->GetNContributors();
717 //fgData[AliDielectronVarContainer::kChi2NDF] = event->GetPrimaryVertex()->GetChi2perNDF(); // This is the pair value!
718 fgData[AliDielectronVarContainer::kNTrk] = event->GetNumberOfTracks();
719 fgData[AliDielectronVarContainer::kBzkG] = event->GetMagneticField();
720 fgData[AliDielectronVarContainer::kNacc] = AliDielectronHelper::GetNacc(event);
721 fgData[AliDielectronVarContainer::kNaccTrcklts] = AliDielectronHelper::GetNaccTrcklts(event);
722}
723
724
725inline void AliDielectronVarContainer::FillVarESDEvent(const AliESDEvent *event)
726{
727 //
728 // Fill event information available for histogramming into an array
729 //
730
731 // Fill common AliVEvent interface information
732 FillVarVEvent(event);
733
734 Double_t centralityF=-1;
735 AliCentrality *esdCentrality = const_cast<AliESDEvent*>(event)->GetCentrality();
736 if (esdCentrality) centralityF = esdCentrality->GetCentralityPercentile("V0M");
737
738 // Fill AliESDEvent interface specific information
739 const AliESDVertex *esdVtx = event->GetPrimaryVertex();
740 fgData[AliDielectronVarContainer::kXRes] = esdVtx->GetXRes();
741 fgData[AliDielectronVarContainer::kYRes] = esdVtx->GetYRes();
742 fgData[AliDielectronVarContainer::kZRes] = esdVtx->GetZRes();
743 fgData[AliDielectronVarContainer::kCentrality] = centralityF;
744}
745
746
747inline void AliDielectronVarContainer::FillVarAODEvent(const AliAODEvent *event)
748{
749 //
750 // Fill event information available for histogramming into an array
751 //
752
753 // Fill common AliVEvent interface information
754 FillVarVEvent(event);
755
756 // Fill AliAODEvent interface specific information
757 // set the AOD vertex
758 if (fgAODVertex) delete fgAODVertex;
759 fgAODVertex = 0x0;
760 if (!event->GetPrimaryVertex()) return;
761 fgAODVertex = new AliAODVertex(*event->GetPrimaryVertex());
762
763}
764
765
766inline void AliDielectronVarContainer::FillVarMCEvent(const AliMCEvent *event)
767{
768 //
769 // Fill event information available for histogramming into an array
770 //
771
772 // Fill common AliVEvent interface information
773 FillVarVEvent(event);
774
775 // Fill AliMCEvent interface specific information
776 fgDataMC[AliDielectronVarContainer::kNch] = AliDielectronHelper::GetNch(event, 1.6);
777}
778
779
780inline Double_t AliDielectronVarContainer::GetPseudoProperTime(const AliDielectronPair *pair)
781{
782 //
783 // Calculate the pseudo proper time
784 //
785
786 if(!pair) return 0.;
787
788 Double_t pt = pair->Pt();
789 Double_t dx = pair->Xv() - fgData[AliDielectronVarContainer::kXvPrim];
790 Double_t dy = pair->Yv() - fgData[AliDielectronVarContainer::kYvPrim];
791 Double_t lxy = ((dx * pair->Px()) + (dy * pair->Py()))/pt;
792 Double_t ppt = lxy * (TDatabasePDG::Instance()->GetParticle(443)->Mass())/pt;
793
794 return ppt;
795}
796
797
798inline void AliDielectronVarContainer::SetEvent(AliVEvent * const event)
799{
800 //
801 // Set the event
802 //
803
804 FillVarVEvent(event);
805}
806
807
808inline void AliDielectronVarContainer::InitESDpid(Int_t type)
809{
810 //
811 // initialize PID parameters
812 // type=0 is simulation
813 // type=1 is data
814
815 if (!fgPIDResponse) fgPIDResponse=new AliESDpid((Bool_t)(type==0));
816 Double_t alephParameters[5];
817 // simulation
818 alephParameters[0] = 2.15898e+00/50.;
819 alephParameters[1] = 1.75295e+01;
820 alephParameters[2] = 3.40030e-09;
821 alephParameters[3] = 1.96178e+00;
822 alephParameters[4] = 3.91720e+00;
823 fgPIDResponse->GetTOFResponse().SetTimeResolution(80.);
824
825 // data
826 if (type==1){
827 alephParameters[0] = 0.0283086/0.97;
828 alephParameters[1] = 2.63394e+01;
829 alephParameters[2] = 5.04114e-11;
830 alephParameters[3] = 2.12543e+00;
831 alephParameters[4] = 4.88663e+00;
832 fgPIDResponse->GetTOFResponse().SetTimeResolution(130.);
833 fgPIDResponse->GetTPCResponse().SetMip(50.);
834 }
835
836 fgPIDResponse->GetTPCResponse().SetBetheBlochParameters(
837 alephParameters[0],alephParameters[1],alephParameters[2],
838 alephParameters[3],alephParameters[4]);
839
840 fgPIDResponse->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04);
841}
842
843inline void AliDielectronVarContainer::InitAODpidUtil(Int_t type)
844{
845 if (!fgPIDResponse) fgPIDResponse=new AliAODpidUtil;
846 Double_t alephParameters[5];
847 // simulation
848 alephParameters[0] = 2.15898e+00/50.;
849 alephParameters[1] = 1.75295e+01;
850 alephParameters[2] = 3.40030e-09;
851 alephParameters[3] = 1.96178e+00;
852 alephParameters[4] = 3.91720e+00;
853 fgPIDResponse->GetTOFResponse().SetTimeResolution(80.);
854
855 // data
856 if (type==1){
857 alephParameters[0] = 0.0283086/0.97;
858 alephParameters[1] = 2.63394e+01;
859 alephParameters[2] = 5.04114e-11;
860 alephParameters[3] = 2.12543e+00;
861 alephParameters[4] = 4.88663e+00;
862 fgPIDResponse->GetTOFResponse().SetTimeResolution(130.);
863 fgPIDResponse->GetTPCResponse().SetMip(50.);
864 }
865
866 fgPIDResponse->GetTPCResponse().SetBetheBlochParameters(
867 alephParameters[0],alephParameters[1],alephParameters[2],
868 alephParameters[3],alephParameters[4]);
869
870 fgPIDResponse->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04);
871}
872
873
874inline Bool_t AliDielectronVarContainer::GetDCA(const AliAODTrack *track, Double_t d0z0[2])
875{
876 if(track->TestBit(AliAODTrack::kIsDCA)){
877 d0z0[0]=track->DCA();
878 d0z0[1]=track->ZAtDCA();
879 return kTRUE;
880 }
881
882 Double_t covd0z0[3];
883 AliAODTrack copy(*track);
884 AliAODVertex *vtx =(AliAODVertex*)fgAODVertex;
885 Bool_t ok = copy.PropagateToDCA(vtx,fgData[AliDielectronVarContainer::kBzkG],kVeryBig,d0z0,covd0z0);
886 if(!ok){
887 d0z0[0]=-999.;
888 d0z0[1]=-999.;
889 }
890 return ok;
891}
892
893/*
894inline void AliDielectronVarContainer::FillVarTParticle(const TParticle *particle)
895{
896 //
897 // Fill TParticle interface information
898 //
899
900 fgData[AliDielectronVarContainer::kPx] = particle->Px();
901 fgData[AliDielectronVarContainer::kPy] = particle->Py();
902 fgData[AliDielectronVarContainer::kPz] = particle->Pz();
903 fgData[AliDielectronVarContainer::kPt] = particle->Pt();
904 fgData[AliDielectronVarContainer::kP] = particle->P();
905 fgData[AliDielectronVarContainer::kXv] = particle->Vx();
906 fgData[AliDielectronVarContainer::kYv] = particle->Vy();
907 fgData[AliDielectronVarContainer::kZv] = particle->Vz();
908 fgData[AliDielectronVarContainer::kOneOverPt] = 1./particle->Pt();
909 fgData[AliDielectronVarContainer::kPhi] = particle->Phi();
910 fgData[AliDielectronVarContainer::kTheta] = particle->Theta();
911 fgData[AliDielectronVarContainer::kEta] = particle->Eta();
912 fgData[AliDielectronVarContainer::kY] = particle->Y();
913 fgData[AliDielectronVarContainer::kE] = particle->Energy();
914 fgData[AliDielectronVarContainer::kM] = particle->GetMass();
915 fgData[AliDielectronVarContainer::kCharge] = particle->GetPDG()->Charge()/3;
916}
917*/
918
919
920
921
922#endif
923