]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGDQ/dielectron/AliDielectronEvent.cxx
New macros for the kaon train
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / AliDielectronEvent.cxx
CommitLineData
5720c765 1/*************************************************************************
2* Copyright(c) 1998-2009, 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**************************************************************************/
15
16///////////////////////////////////////////////////////////////////////////
17// Dielectron Event //
18// //
19// //
20/*
21Detailed description
22
23
24*/
25// //
26///////////////////////////////////////////////////////////////////////////
27
28#include <TObjArray.h>
29
30#include <AliVTrack.h>
31#include <AliESDtrack.h>
32#include <AliAODTrack.h>
33
34#include "AliDielectronEvent.h"
35
36ClassImp(AliDielectronEvent)
37
38AliDielectronEvent::AliDielectronEvent() :
39 TNamed(),
88e9bae6 40 fArrTrackP(),
41 fArrTrackN(),
67fd1119 42 fArrVertexP("AliAODVertex",1000),
43 fArrVertexN("AliAODVertex",1000),
5720c765 44 fArrPairs("AliKFParticle",0),
45 fNTracksP(0),
46 fNTracksN(0),
47 fIsAOD(kFALSE),
48 fEventData()
49{
50 //
51 // Default Constructor
52 //
53
54}
55
56//______________________________________________
57AliDielectronEvent::AliDielectronEvent(const char* name, const char* title) :
58 TNamed(name, title),
88e9bae6 59 fArrTrackP(),
60 fArrTrackN(),
67fd1119 61 fArrVertexP("AliAODVertex",1000),
62 fArrVertexN("AliAODVertex",1000),
5720c765 63 fArrPairs("AliKFParticle",0),
64 fNTracksP(0),
65 fNTracksN(0),
66 fIsAOD(kFALSE),
67 fEventData()
68{
69 //
70 // Named Constructor
71 //
72}
73
74//______________________________________________
75AliDielectronEvent::~AliDielectronEvent()
76{
77 //
78 // Default Destructor
79 //
80 fArrTrackP.Delete();
81 fArrTrackN.Delete();
67fd1119 82 fArrVertexP.Delete();
83 fArrVertexN.Delete();
5720c765 84 fArrPairs.Delete();
85}
86
87//______________________________________________
88void AliDielectronEvent::SetTracks(const TObjArray &arrP, const TObjArray &arrN, const TObjArray &/*arrPairs*/)
89{
90 //
91 // Setup AliKFParticles
92 // assumes that the objects in arrP and arrN are AliVTracks
93 //
94
95 //Clear out old entries before filling new ones
96 Clear();
97 // we keep the tracks buffered to minimise new / delete operations
98 fNTracksN=0;
99 fNTracksP=0;
100
101 //check size of the arrays
67fd1119 102 if (fArrTrackP.GetSize()<arrP.GetSize()) {
103 fArrTrackP.Expand(arrP.GetSize());
104 fArrVertexP.Expand(arrP.GetSize());
105 }
106 if (fArrTrackN.GetSize()<arrN.GetSize()) {
107 fArrTrackN.Expand(arrN.GetSize());
108 fArrVertexN.Expand(arrN.GetSize());
109 }
5720c765 110
111 // fill particles
112 Int_t tracks=0;
113 for (Int_t itrack=0; itrack<arrP.GetEntriesFast(); ++itrack){
114 if (!fIsAOD){
115 AliESDtrack *track=dynamic_cast<AliESDtrack*>(arrP.At(itrack));
116 if (!track) continue;
117 new (fArrTrackP[tracks]) AliESDtrack(*track);
118 ++tracks;
119 } else {
120 AliAODTrack *track=dynamic_cast<AliAODTrack*>(arrP.At(itrack));
121 if (!track) continue;
67fd1119 122
5720c765 123 new (fArrTrackP[tracks]) AliAODTrack(*track);
67fd1119 124 new (fArrVertexP[tracks]) AliAODVertex(*(track->GetProdVertex()));
5720c765 125 ++tracks;
126 }
127 }
128 fNTracksP=tracks;
129
130 tracks=0;
131 for (Int_t itrack=0; itrack<arrN.GetEntriesFast(); ++itrack){
132 if (!fIsAOD){
133 AliESDtrack *track=dynamic_cast<AliESDtrack*>(arrN.At(itrack));
134 if (!track) continue;
135 new (fArrTrackN[tracks]) AliESDtrack(*track);
136 ++tracks;
137 } else {
138 AliAODTrack *track=dynamic_cast<AliAODTrack*>(arrN.At(itrack));
139 if (!track) continue;
67fd1119 140
5720c765 141 new (fArrTrackN[tracks]) AliAODTrack(*track);
67fd1119 142 new (fArrVertexN[tracks]) AliAODVertex(*(track->GetProdVertex()));
5720c765 143 ++tracks;
144 }
145 }
146 fNTracksN=tracks;
147
148 //TODO: pair arrays
149}
150
151//______________________________________________
152void AliDielectronEvent::Clear(Option_t *opt)
153{
154 //
155 // clear arrays
156 //
157// fArrTrackP.Clear(opt);
158// fArrTrackN.Clear(opt);
159
160 for (Int_t i=fArrTrackP.GetEntriesFast()-1; i>=0; --i){
161 delete fArrTrackP.RemoveAt(i);
67fd1119 162 delete fArrVertexP.RemoveAt(i);
5720c765 163 }
164
165 for (Int_t i=fArrTrackN.GetEntriesFast()-1; i>=0; --i){
166 delete fArrTrackN.RemoveAt(i);
67fd1119 167 delete fArrVertexN.RemoveAt(i);
5720c765 168 }
169
170 fArrPairs.Clear(opt);
171
172}
173
174//______________________________________________
175void AliDielectronEvent::SetAOD()
176{
177 //
178 // use AOD as input
179 //
88e9bae6 180 fArrTrackP.SetClass("AliAODTrack",1000);
181 fArrTrackN.SetClass("AliAODTrack",1000);
5720c765 182 fIsAOD=kTRUE;
183}
184
88e9bae6 185//______________________________________________
186void AliDielectronEvent::SetESD()
187{
188 //
189 // use ESD as input
190 //
191 fArrTrackP.SetClass("AliESDtrack",1000);
192 fArrTrackN.SetClass("AliESDtrack",1000);
193 fIsAOD=kFALSE;
194}
195
5720c765 196//______________________________________________
197void AliDielectronEvent::SetEventData(const Double_t data[AliDielectronVarManager::kNMaxValues])
198{
199 //
200 // copy only evnet variables
201 //
202 for (Int_t i=AliDielectronVarManager::kPairMax; i<AliDielectronVarManager::kNMaxValues;++i) fEventData[i]=data[i];
67fd1119 203}