Add dielectron framework to PWG3
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectronVarManager.h
CommitLineData
b2a297fa 1#ifndef ALIDIELECTRONVARMANAGER_H
2#define ALIDIELECTRONVARMANAGER_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 AliDielectronVarManager #
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//# Frederick Kramer, Uni Ffm, / Frederick.Kramer@cern.ch #
16//# Magnus Mager, CERN / Magnus.Mager@cern.ch #
17//# WooJin J. Park, GSI / W.J.Park@gsi.de #
18//# Jens Wiechula, Uni HD / Jens.Wiechula@cern.ch #
19//# #
20//#############################################################
21
22
23#include <TNamed.h>
24
25#include <AliVEvent.h>
26#include <AliESDEvent.h>
27
28#include <AliVParticle.h>
29#include <AliExternalTrackParam.h>
30#include <AliESDtrack.h>
31#include <AliAODTrack.h>
32#include <AliKFParticle.h>
33#include <AliMCParticle.h>
34#include <AliAODMCParticle.h>
35#include <AliVTrack.h> // ?
36
37#include "AliDielectronPair.h"
38
39class AliVEvent;
40
41//________________________________________________________________
42class AliDielectronVarManager : public TNamed {
43
44public:
45
46 // Particle specific variables
47 enum ValueTypes {
48 kPx = 0, // px
49 kPy, // py
50 kPz, // pz
51 kPt, // transverse momentum
52 kP, // momentum
53 kXv, // vertex position in x
54 kYv, // vertex position in y
55 kZv, // vertex position in z
56 kOneOverPt, // 1/pt
57 kPhi, // phi angle
58 kTheta, // theta angle
59 kEta, // pseudo-rapidity
60 kY, // rapidity
61 kE, // energy
62 kM, // mass
63 kCharge, // charge
64 kNclsITS, // number of clusters assigned in the ITS
65 kNclsTPC, // number of clusters assigned in the TPC
66 kNFclsTPC, // number of findable clusters in the TPC
67 kTPCsignalN, // number of points used for dEdx
68 kNclsTRD, // number of clusters assigned in the TRD
69 kTRDntracklets, // number of TRD tracklets used for tracking/PID TODO: correct getter
70 kTRDpidQuality, // number of TRD tracklets used for PID
71 kImpactParXY, // Impact parameter in XY plane
72 kImpactParZ, // Impact parameter in Z
73 kTrackLength, // Track length
74 kPdgCode, // PDG code
75 kPIn, // momentum at inner wall of TPC (if available), used for PID
76 kTPCsignal, // TPC dE/dx signal
77 kParticleMax, //
78 // TODO: kRNClusters ??
79 // AliDielectronPair specific variables
80 kChi2NDF = kParticleMax, // Chi^2/NDF
81 kDecayLength, // decay length
82 kR, // distance to the origin
83 kOpeningAngle, // opening angle
84 kMerr, // error of mass calculation
85 kDCA, // distance of closest approach TODO: not implemented yet
86 kPairType, // type of the pair, like like sign ++ unlikesign ...
87 kPairMax, //
88 // Event specific variables
89 kXvPrim=kPairMax, // TODO: prim vertex
90 kYvPrim, // TODO: prim vertex
91 kZvPrim, // TODO: prim vertex
92 kXRes, // primary vertex x-resolution (AliESDVertex)
93 kYRes, // primary vertex y-resolution (AliESDVertex)
94 kZRes, // primary vertex z-resolution (AliESDVertex)
95 kNTrk, // number of tracks (or tracklets)
96 kTracks, // ESD tracks (AliESDEvent)
97 kNMaxValues //
98 // TODO: (for A+A) ZDCEnergy, impact parameter, Iflag??
99 };
100
101
102 AliDielectronVarManager();
103 AliDielectronVarManager(const char* name, const char* title);
104 virtual ~AliDielectronVarManager();
105 static void Fill(const TObject* particle, Double_t * const values);
106
107 static const char* GetValueName(Int_t i) { return (i>=0&&i<kNMaxValues)?fgkParticleNames[i]:""; }
108private:
109
110 static const char* fgkParticleNames[kNMaxValues]; //variable names
111
112 static void FillVarVParticle(const AliVParticle *particle, Double_t * const values);
113 static void FillVarESDtrack(const AliESDtrack *particle, Double_t * const values);
114 static void FillVarAODTrack(const AliAODTrack *particle, Double_t * const values);
115 static void FillVarMCParticle(const AliMCParticle *particle, Double_t * const values);
116 static void FillVarAODMCParticle(const AliAODMCParticle *particle, Double_t * const values);
117 static void FillVarDielectronPair(const AliDielectronPair *pair, Double_t * const values);
118
119 AliDielectronVarManager(const AliDielectronVarManager &c);
120 AliDielectronVarManager &operator=(const AliDielectronVarManager &c);
121
122 ClassDef(AliDielectronVarManager,1);
123};
124
125
126//Inline functions
127inline void AliDielectronVarManager::Fill(const TObject* particle, Double_t * const values)
128{
129 //
130 // Main function to fill all available variables according to the type of particle
131 //
132
133 if (particle->IsA() == AliESDtrack::Class()) FillVarESDtrack(static_cast<const AliESDtrack*>(particle), values);
134 else if (particle->IsA() == AliAODTrack::Class()) FillVarAODTrack(static_cast<const AliAODTrack*>(particle), values);
135 else if (particle->IsA() == AliMCParticle::Class()) FillVarMCParticle(static_cast<const AliMCParticle*>(particle), values);
136 else if (particle->IsA() == AliAODMCParticle::Class()) FillVarAODMCParticle(static_cast<const AliAODMCParticle*>(particle), values);
137 else if (particle->IsA() == AliDielectronPair::Class()) FillVarDielectronPair(static_cast<const AliDielectronPair*>(particle), values);
138// else Error("Fill",Form("Type %s is not supported by AliDielectronVarManager!", particle->ClassName())); //TODO: implement without object needed
139}
140
141inline void AliDielectronVarManager::FillVarVParticle(const AliVParticle *particle, Double_t * const values)
142{
143 //
144 // Fill track information available in AliVParticle into an array
145 //
146 values[AliDielectronVarManager::kPx] = particle->Px();
147 values[AliDielectronVarManager::kPy] = particle->Py();
148 values[AliDielectronVarManager::kPz] = particle->Pz();
149 values[AliDielectronVarManager::kPt] = particle->Pt();
150 values[AliDielectronVarManager::kP] = particle->P();
151
152 values[AliDielectronVarManager::kXv] = particle->Xv();
153 values[AliDielectronVarManager::kYv] = particle->Yv();
154 values[AliDielectronVarManager::kZv] = particle->Zv();
155
156 values[AliDielectronVarManager::kOneOverPt] = particle->OneOverPt();
157 values[AliDielectronVarManager::kPhi] = particle->Phi();
158 values[AliDielectronVarManager::kTheta] = particle->Theta();
159 values[AliDielectronVarManager::kEta] = particle->Eta();
160 values[AliDielectronVarManager::kY] = particle->Y();
161
162 values[AliDielectronVarManager::kE] = particle->E();
163 values[AliDielectronVarManager::kM] = particle->M();
164 values[AliDielectronVarManager::kCharge] = particle->Charge();
165}
166
167inline void AliDielectronVarManager::FillVarESDtrack(const AliESDtrack *particle, Double_t * const values)
168{
169 //
170 // Fill track information available for histogramming into an array
171 //
172
173 // Fill common AliVParticle interface information
174 FillVarVParticle(particle, values);
175
176 // Fill AliESDtrack interface specific information
177 values[AliDielectronVarManager::kNclsITS] = particle->GetNcls(0); // TODO: get rid of the plain numbers
178 values[AliDielectronVarManager::kNclsTPC] = particle->GetNcls(1); // TODO: get rid of the plain numbers
179 values[AliDielectronVarManager::kNFclsTPC] = particle->GetTPCNclsF();
180 values[AliDielectronVarManager::kTPCsignalN] = particle->GetTPCsignalN();
181 values[AliDielectronVarManager::kNclsTRD] = particle->GetNcls(2); // TODO: get rid of the plain numbers
182 values[AliDielectronVarManager::kTRDntracklets] = particle->GetTRDntracklets(); // TODO: GetTRDtracklets/GetTRDntracklets?
183 values[AliDielectronVarManager::kTRDpidQuality] = particle->GetTRDpidQuality();
184
185 Float_t impactParXY, impactParZ;
186 particle->GetImpactParameters(impactParXY, impactParZ);
187 values[AliDielectronVarManager::kImpactParXY] = impactParXY;
188 values[AliDielectronVarManager::kImpactParZ] = impactParZ;
189
190 values[AliDielectronVarManager::kTrackLength] = particle->GetIntegratedLength();
191
192 //dEdx information
193 Double_t mom = particle->GetP();
194 const AliExternalTrackParam *in=particle->GetInnerParam();
195 if (in) mom = in->GetP();
196 values[AliDielectronVarManager::kPIn]=mom;
197 values[AliDielectronVarManager::kTPCsignal]=particle->GetTPCsignal();
198
199}
200
201inline void AliDielectronVarManager::FillVarAODTrack(const AliAODTrack *particle, Double_t * const values)
202{
203 //
204 // Fill track information available for histogramming into an array
205 //
206
207 // Fill common AliVParticle interface information
208 FillVarVParticle(particle, values);
209 // Fill AliAODTrack interface information
210 // ...
211
212}
213
214inline void AliDielectronVarManager::FillVarMCParticle(const AliMCParticle *particle, Double_t * const values)
215{
216 //
217 // Fill track information available for histogramming into an array
218 //
219
220 // Fill common AliVParticle interface information
221 FillVarVParticle(particle, values);
222
223 // Fill AliMCParticle interface specific information
224 values[AliDielectronVarManager::kPdgCode] = particle->PdgCode();
225}
226
227inline void AliDielectronVarManager::FillVarAODMCParticle(const AliAODMCParticle *particle, Double_t * const values)
228{
229 //
230 // Fill track information available for histogramming into an array
231 //
232
233 // Fill common AliVParticle interface information
234 FillVarVParticle(particle, values);
235
236 // Fill AliAODMCParticle interface specific information
237 values[AliDielectronVarManager::kPdgCode] = particle->GetPdgCode();
238}
239
240inline void AliDielectronVarManager::FillVarDielectronPair(const AliDielectronPair *pair, Double_t * const values)
241{
242 //
243 // Fill pair information available for histogramming into an array
244 //
245
246 // Fill common AliVParticle interface information
247 FillVarVParticle(pair, values);
248
249 // Fill AliDielectronPair specific information
250 const AliKFParticle &kfPair = pair->GetKFParticle();
251
252 values[AliDielectronVarManager::kChi2NDF] = kfPair.GetChi2()/kfPair.GetNDF();
253 values[AliDielectronVarManager::kDecayLength] = kfPair.GetDecayLength();
254 values[AliDielectronVarManager::kR] = kfPair.GetR();
255 values[AliDielectronVarManager::kOpeningAngle] = pair->OpeningAngle();
256 values[AliDielectronVarManager::kMerr] = kfPair.GetErrMass()>0?kfPair.GetErrMass()/kfPair.GetMass():1000000;
257 values[AliDielectronVarManager::kPairType] = pair->GetType();
258}
259
260/*
261inline void AliDielectronVarManager::FillValues(const TParticle *particle, Double_t *values)
262{
263 //
264 // Fill track information available for histogramming into an array
265 //
266
267 // Fill TParticle interface information
268 values[AliDielectronVarManager::kPx] = particle->Px();
269 values[AliDielectronVarManager::kPy] = particle->Py();
270 values[AliDielectronVarManager::kPz] = particle->Pz();
271 values[AliDielectronVarManager::kPt] = particle->Pt();
272 values[AliDielectronVarManager::kP] = particle->P();
273
274 values[AliDielectronVarManager::kXv] = particle->Vx();
275 values[AliDielectronVarManager::kYv] = particle->Vy();
276 values[AliDielectronVarManager::kZv] = particle->Vz();
277
278 values[AliDielectronVarManager::kOneOverPt] = 1./particle->Pt();
279 values[AliDielectronVarManager::kPhi] = particle->Phi();
280 values[AliDielectronVarManager::kTheta] =
281 values[AliDielectronVarManager::kEta] = particle->Eta();
282 values[AliDielectronVarManager::kY] =
283
284 values[AliDielectronVarManager::kE] = particle->Energy();
285 values[AliDielectronVarManager::kM] = particle->GetMass();
286
287 values[AliDielectronVarManager::kCharge] = particle->GetPDG()->Charge()/3; // uggly
288
289}*/
290
291#endif