Add a draw class for the CORRFW (produces a warning, will be fixed
[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 #
6551594b 15//# Frederick Kramer, Uni Ffm / Frederick.Kramer@cern.ch #
b2a297fa 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>
6551594b 27#include <AliAODEvent.h>
28#include <AliMCEvent.h>
29#include <AliVVertex.h>
30#include <AliESDVertex.h>
b2a297fa 31
32#include <AliVParticle.h>
b2a297fa 33#include <AliESDtrack.h>
34#include <AliAODTrack.h>
35#include <AliKFParticle.h>
36#include <AliMCParticle.h>
37#include <AliAODMCParticle.h>
38#include <AliVTrack.h> // ?
39
6551594b 40#include <AliExternalTrackParam.h>
41#include <AliESDpid.h>
42
b2a297fa 43#include "AliDielectronPair.h"
44
45class AliVEvent;
46
47//________________________________________________________________
48class AliDielectronVarManager : public TNamed {
49
50public:
51
52 // Particle specific variables
53 enum ValueTypes {
54 kPx = 0, // px
55 kPy, // py
56 kPz, // pz
57 kPt, // transverse momentum
58 kP, // momentum
59 kXv, // vertex position in x
60 kYv, // vertex position in y
61 kZv, // vertex position in z
62 kOneOverPt, // 1/pt
63 kPhi, // phi angle
64 kTheta, // theta angle
65 kEta, // pseudo-rapidity
66 kY, // rapidity
67 kE, // energy
68 kM, // mass
69 kCharge, // charge
70 kNclsITS, // number of clusters assigned in the ITS
71 kNclsTPC, // number of clusters assigned in the TPC
72 kNFclsTPC, // number of findable clusters in the TPC
73 kTPCsignalN, // number of points used for dEdx
74 kNclsTRD, // number of clusters assigned in the TRD
75 kTRDntracklets, // number of TRD tracklets used for tracking/PID TODO: correct getter
76 kTRDpidQuality, // number of TRD tracklets used for PID
77 kImpactParXY, // Impact parameter in XY plane
78 kImpactParZ, // Impact parameter in Z
79 kTrackLength, // Track length
80 kPdgCode, // PDG code
81 kPIn, // momentum at inner wall of TPC (if available), used for PID
82 kTPCsignal, // TPC dE/dx signal
6551594b 83 kTPCnSigmaEle, // number of sigmas to the dE/dx electron line in the TPC
b2a297fa 84 kParticleMax, //
85 // TODO: kRNClusters ??
86 // AliDielectronPair specific variables
87 kChi2NDF = kParticleMax, // Chi^2/NDF
88 kDecayLength, // decay length
89 kR, // distance to the origin
90 kOpeningAngle, // opening angle
91 kMerr, // error of mass calculation
92 kDCA, // distance of closest approach TODO: not implemented yet
93 kPairType, // type of the pair, like like sign ++ unlikesign ...
94 kPairMax, //
95 // Event specific variables
6551594b 96 kXvPrim=kPairMax, // prim vertex
97 kYvPrim, // prim vertex
98 kZvPrim, // prim vertex
99 kXRes, // primary vertex x-resolution
100 kYRes, // primary vertex y-resolution
101 kZRes, // primary vertex z-resolution
b2a297fa 102 kNTrk, // number of tracks (or tracklets)
6551594b 103 kTracks, // ESD tracks
104 kNevents, // event counter
b2a297fa 105 kNMaxValues //
106 // TODO: (for A+A) ZDCEnergy, impact parameter, Iflag??
107 };
108
109
110 AliDielectronVarManager();
111 AliDielectronVarManager(const char* name, const char* title);
112 virtual ~AliDielectronVarManager();
113 static void Fill(const TObject* particle, Double_t * const values);
114
6551594b 115 static void InitESDpid(Int_t type=0);
116 static void SetEvent(AliVEvent * const ev) { fgEvent = ev; }
117
b2a297fa 118 static const char* GetValueName(Int_t i) { return (i>=0&&i<kNMaxValues)?fgkParticleNames[i]:""; }
119private:
120
121 static const char* fgkParticleNames[kNMaxValues]; //variable names
122
123 static void FillVarVParticle(const AliVParticle *particle, Double_t * const values);
124 static void FillVarESDtrack(const AliESDtrack *particle, Double_t * const values);
125 static void FillVarAODTrack(const AliAODTrack *particle, Double_t * const values);
6551594b 126 static void FillVarMCParticle(const AliMCParticle *particle, Double_t * const values);
b2a297fa 127 static void FillVarAODMCParticle(const AliAODMCParticle *particle, Double_t * const values);
128 static void FillVarDielectronPair(const AliDielectronPair *pair, Double_t * const values);
6551594b 129 static void FillVarVEvent(const AliVEvent *event, Double_t * const values);
130 static void FillVarESDEvent(const AliESDEvent *event, Double_t * const values);
131 static void FillVarAODEvent(const AliAODEvent *event, Double_t * const values);
132 static void FillVarMCEvent(const AliMCEvent *event, Double_t * const values);
133
134 static AliESDpid* fgESDpid; // ESD pid object
135 static AliVEvent* fgEvent; // current event pointer
b2a297fa 136
137 AliDielectronVarManager(const AliDielectronVarManager &c);
138 AliDielectronVarManager &operator=(const AliDielectronVarManager &c);
139
140 ClassDef(AliDielectronVarManager,1);
141};
142
143
144//Inline functions
6551594b 145inline void AliDielectronVarManager::Fill(const TObject* object, Double_t * const values)
b2a297fa 146{
147 //
148 // Main function to fill all available variables according to the type of particle
149 //
150
6551594b 151 if (object->IsA() == AliESDtrack::Class()) FillVarESDtrack(static_cast<const AliESDtrack*>(object), values);
152 else if (object->IsA() == AliAODTrack::Class()) FillVarAODTrack(static_cast<const AliAODTrack*>(object), values);
153 else if (object->IsA() == AliMCParticle::Class()) FillVarMCParticle(static_cast<const AliMCParticle*>(object), values);
154 else if (object->IsA() == AliAODMCParticle::Class()) FillVarAODMCParticle(static_cast<const AliAODMCParticle*>(object), values);
155 else if (object->IsA() == AliDielectronPair::Class()) FillVarDielectronPair(static_cast<const AliDielectronPair*>(object), values);
156
157 // Main function to fill all available variables according to the type of event
158
159 else if (object->IsA() == AliVEvent::Class()) FillVarVEvent(static_cast<const AliVEvent*>(object), values);
160 else if (object->IsA() == AliESDEvent::Class()) FillVarESDEvent(static_cast<const AliESDEvent*>(object), values);
161 else if (object->IsA() == AliAODEvent::Class()) FillVarAODEvent(static_cast<const AliAODEvent*>(object), values);
162 else if (object->IsA() == AliMCEvent::Class()) FillVarMCEvent(static_cast<const AliMCEvent*>(object), values);
163// else Error("Fill",Form("Type %s is not supported by AliDielectronVarManager!", object->ClassName())); //TODO: implement without object needed
b2a297fa 164}
165
166inline void AliDielectronVarManager::FillVarVParticle(const AliVParticle *particle, Double_t * const values)
167{
168 //
169 // Fill track information available in AliVParticle into an array
170 //
171 values[AliDielectronVarManager::kPx] = particle->Px();
172 values[AliDielectronVarManager::kPy] = particle->Py();
173 values[AliDielectronVarManager::kPz] = particle->Pz();
174 values[AliDielectronVarManager::kPt] = particle->Pt();
175 values[AliDielectronVarManager::kP] = particle->P();
176
177 values[AliDielectronVarManager::kXv] = particle->Xv();
178 values[AliDielectronVarManager::kYv] = particle->Yv();
179 values[AliDielectronVarManager::kZv] = particle->Zv();
180
181 values[AliDielectronVarManager::kOneOverPt] = particle->OneOverPt();
182 values[AliDielectronVarManager::kPhi] = particle->Phi();
183 values[AliDielectronVarManager::kTheta] = particle->Theta();
184 values[AliDielectronVarManager::kEta] = particle->Eta();
185 values[AliDielectronVarManager::kY] = particle->Y();
186
187 values[AliDielectronVarManager::kE] = particle->E();
188 values[AliDielectronVarManager::kM] = particle->M();
189 values[AliDielectronVarManager::kCharge] = particle->Charge();
6551594b 190
191 if ( fgEvent ) AliDielectronVarManager::Fill(fgEvent, values);
b2a297fa 192}
193
194inline void AliDielectronVarManager::FillVarESDtrack(const AliESDtrack *particle, Double_t * const values)
195{
196 //
197 // Fill track information available for histogramming into an array
198 //
199
200 // Fill common AliVParticle interface information
201 FillVarVParticle(particle, values);
202
203 // Fill AliESDtrack interface specific information
204 values[AliDielectronVarManager::kNclsITS] = particle->GetNcls(0); // TODO: get rid of the plain numbers
205 values[AliDielectronVarManager::kNclsTPC] = particle->GetNcls(1); // TODO: get rid of the plain numbers
206 values[AliDielectronVarManager::kNFclsTPC] = particle->GetTPCNclsF();
207 values[AliDielectronVarManager::kTPCsignalN] = particle->GetTPCsignalN();
208 values[AliDielectronVarManager::kNclsTRD] = particle->GetNcls(2); // TODO: get rid of the plain numbers
209 values[AliDielectronVarManager::kTRDntracklets] = particle->GetTRDntracklets(); // TODO: GetTRDtracklets/GetTRDntracklets?
210 values[AliDielectronVarManager::kTRDpidQuality] = particle->GetTRDpidQuality();
211
212 Float_t impactParXY, impactParZ;
213 particle->GetImpactParameters(impactParXY, impactParZ);
214 values[AliDielectronVarManager::kImpactParXY] = impactParXY;
215 values[AliDielectronVarManager::kImpactParZ] = impactParZ;
216
217 values[AliDielectronVarManager::kTrackLength] = particle->GetIntegratedLength();
b2a297fa 218 //dEdx information
219 Double_t mom = particle->GetP();
220 const AliExternalTrackParam *in=particle->GetInnerParam();
221 if (in) mom = in->GetP();
222 values[AliDielectronVarManager::kPIn]=mom;
223 values[AliDielectronVarManager::kTPCsignal]=particle->GetTPCsignal();
6551594b 224 // nsigma to Electron band
225 // TODO: for the moment we set the bethe bloch parameters manually
226 // this should be changed in future!
227 values[AliDielectronVarManager::kTPCnSigmaEle]=fgESDpid->NumberOfSigmasTPC(particle,AliPID::kElectron);
b2a297fa 228}
229
230inline void AliDielectronVarManager::FillVarAODTrack(const AliAODTrack *particle, Double_t * const values)
231{
232 //
233 // Fill track information available for histogramming into an array
234 //
235
236 // Fill common AliVParticle interface information
237 FillVarVParticle(particle, values);
238 // Fill AliAODTrack interface information
239 // ...
240
241}
242
243inline void AliDielectronVarManager::FillVarMCParticle(const AliMCParticle *particle, Double_t * const values)
244{
245 //
246 // Fill track information available for histogramming into an array
247 //
248
249 // Fill common AliVParticle interface information
250 FillVarVParticle(particle, values);
251
252 // Fill AliMCParticle interface specific information
253 values[AliDielectronVarManager::kPdgCode] = particle->PdgCode();
254}
255
256inline void AliDielectronVarManager::FillVarAODMCParticle(const AliAODMCParticle *particle, Double_t * const values)
257{
258 //
259 // Fill track information available for histogramming into an array
260 //
261
262 // Fill common AliVParticle interface information
263 FillVarVParticle(particle, values);
264
265 // Fill AliAODMCParticle interface specific information
266 values[AliDielectronVarManager::kPdgCode] = particle->GetPdgCode();
267}
268
269inline void AliDielectronVarManager::FillVarDielectronPair(const AliDielectronPair *pair, Double_t * const values)
270{
271 //
272 // Fill pair information available for histogramming into an array
273 //
274
275 // Fill common AliVParticle interface information
276 FillVarVParticle(pair, values);
277
278 // Fill AliDielectronPair specific information
279 const AliKFParticle &kfPair = pair->GetKFParticle();
280
281 values[AliDielectronVarManager::kChi2NDF] = kfPair.GetChi2()/kfPair.GetNDF();
282 values[AliDielectronVarManager::kDecayLength] = kfPair.GetDecayLength();
283 values[AliDielectronVarManager::kR] = kfPair.GetR();
284 values[AliDielectronVarManager::kOpeningAngle] = pair->OpeningAngle();
285 values[AliDielectronVarManager::kMerr] = kfPair.GetErrMass()>0?kfPair.GetErrMass()/kfPair.GetMass():1000000;
286 values[AliDielectronVarManager::kPairType] = pair->GetType();
287}
288
6551594b 289
290inline void AliDielectronVarManager::FillVarVEvent(const AliVEvent *event, Double_t * const values)
291{
292 //
293 // Fill event information available for histogramming into an array
294 //
295 const AliVVertex *primVtx = event->GetPrimaryVertex();
296 values[AliDielectronVarManager::kXvPrim] = primVtx->GetX();
297 values[AliDielectronVarManager::kYvPrim] = primVtx->GetY();
298 values[AliDielectronVarManager::kZvPrim] = primVtx->GetZ();
299 values[AliDielectronVarManager::kChi2NDF] = primVtx->GetChi2perNDF();
300
301 values[AliDielectronVarManager::kNTrk] = event->GetNumberOfTracks();
302 values[AliDielectronVarManager::kNevents] = 0; //always fill bin 0;
303}
304
305inline void AliDielectronVarManager::FillVarESDEvent(const AliESDEvent *event, Double_t * const values)
306{
307 //
308 // Fill event information available for histogramming into an array
309 //
310
311 // Fill common AliVEvent interface information
312 FillVarVEvent(event, values);
313
314 // Fill AliESDEvent interface specific information
315 const AliESDVertex *primVtx = event->GetPrimaryVertex();
316 values[AliDielectronVarManager::kXRes] = primVtx->GetXRes();
317 values[AliDielectronVarManager::kYRes] = primVtx->GetYRes();
318 values[AliDielectronVarManager::kZRes] = primVtx->GetZRes();
319}
320
321inline void AliDielectronVarManager::FillVarAODEvent(const AliAODEvent *event, Double_t * const values)
322{
323 //
324 // Fill event information available for histogramming into an array
325 //
326
327 // Fill common AliVEvent interface information
328 FillVarVEvent(event, values);
329
330 // Fill AliAODEvent interface specific information
331}
332
333inline void AliDielectronVarManager::FillVarMCEvent(const AliMCEvent *event, Double_t * const values)
334{
335 //
336 // Fill event information available for histogramming into an array
337 //
338
339 // Fill common AliVEvent interface information
340 FillVarVEvent(event, values);
341
342 // Fill AliMCEvent interface specific information
343}
344
345inline void AliDielectronVarManager::InitESDpid(Int_t type)
346{
347 //
348 // initialize PID parameters
349 // type=0 is simulation
350 // type=1 is data
351
352 Double_t alephParameters[5];
353 // simulation
354 alephParameters[0] = 2.15898e+00/50.;
355 alephParameters[1] = 1.75295e+01;
356 alephParameters[2] = 3.40030e-09;
357 alephParameters[3] = 1.96178e+00;
358 alephParameters[4] = 3.91720e+00;
359
360 // data
361 if (type==1){
362 alephParameters[0] = 0.0283086;
363 alephParameters[1] = 2.63394e+01;
364 alephParameters[2] = 5.04114e-11;
365 alephParameters[3] = 2.12543e+00;
366 alephParameters[4] = 4.88663e+00;
367 }
368
369 fgESDpid->GetTPCResponse().SetBetheBlochParameters(
370 alephParameters[0],alephParameters[1],alephParameters[2],
371 alephParameters[3],alephParameters[4]);
372
373}
374
b2a297fa 375/*
376inline void AliDielectronVarManager::FillValues(const TParticle *particle, Double_t *values)
377{
378 //
379 // Fill track information available for histogramming into an array
380 //
381
382 // Fill TParticle interface information
383 values[AliDielectronVarManager::kPx] = particle->Px();
384 values[AliDielectronVarManager::kPy] = particle->Py();
385 values[AliDielectronVarManager::kPz] = particle->Pz();
386 values[AliDielectronVarManager::kPt] = particle->Pt();
387 values[AliDielectronVarManager::kP] = particle->P();
388
389 values[AliDielectronVarManager::kXv] = particle->Vx();
390 values[AliDielectronVarManager::kYv] = particle->Vy();
391 values[AliDielectronVarManager::kZv] = particle->Vz();
392
393 values[AliDielectronVarManager::kOneOverPt] = 1./particle->Pt();
394 values[AliDielectronVarManager::kPhi] = particle->Phi();
395 values[AliDielectronVarManager::kTheta] =
396 values[AliDielectronVarManager::kEta] = particle->Eta();
397 values[AliDielectronVarManager::kY] =
398
399 values[AliDielectronVarManager::kE] = particle->Energy();
400 values[AliDielectronVarManager::kM] = particle->GetMass();
401
402 values[AliDielectronVarManager::kCharge] = particle->GetPDG()->Charge()/3; // uggly
403
404}*/
405
406#endif