]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGDQ/dielectron/AliDielectronEvent.cxx
including switch to set on/off iso-track core removal, cleaning and bug fix
[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>
4fae8ef9 29#include <TExMap.h>
30#include <TProcessID.h>
5720c765 31
32#include <AliVTrack.h>
33#include <AliESDtrack.h>
34#include <AliAODTrack.h>
35
36#include "AliDielectronEvent.h"
37
38ClassImp(AliDielectronEvent)
39
40AliDielectronEvent::AliDielectronEvent() :
41 TNamed(),
88e9bae6 42 fArrTrackP(),
43 fArrTrackN(),
be6589b2 44 fArrVertex("AliAODVertex",10),
5720c765 45 fArrPairs("AliKFParticle",0),
46 fNTracksP(0),
47 fNTracksN(0),
48 fIsAOD(kFALSE),
4fae8ef9 49 fEventData(),
50 fPID(0x0),
51 fPIDIndex(0)
5720c765 52{
53 //
54 // Default Constructor
55 //
56
57}
58
59//______________________________________________
60AliDielectronEvent::AliDielectronEvent(const char* name, const char* title) :
61 TNamed(name, title),
88e9bae6 62 fArrTrackP(),
63 fArrTrackN(),
a94c2e7e 64 fArrVertex("AliAODVertex",10),
5720c765 65 fArrPairs("AliKFParticle",0),
66 fNTracksP(0),
67 fNTracksN(0),
68 fIsAOD(kFALSE),
4fae8ef9 69 fEventData(),
70 fPID(0x0),
71 fPIDIndex(0)
5720c765 72{
73 //
74 // Named Constructor
75 //
76}
77
78//______________________________________________
79AliDielectronEvent::~AliDielectronEvent()
80{
81 //
82 // Default Destructor
83 //
84 fArrTrackP.Delete();
85 fArrTrackN.Delete();
0c09cae4 86 fArrVertex.Delete();
5720c765 87 fArrPairs.Delete();
88}
89
90//______________________________________________
91void AliDielectronEvent::SetTracks(const TObjArray &arrP, const TObjArray &arrN, const TObjArray &/*arrPairs*/)
92{
93 //
94 // Setup AliKFParticles
95 // assumes that the objects in arrP and arrN are AliVTracks
96 //
97
98 //Clear out old entries before filling new ones
99 Clear();
100 // we keep the tracks buffered to minimise new / delete operations
101 fNTracksN=0;
102 fNTracksP=0;
103
104 //check size of the arrays
67fd1119 105 if (fArrTrackP.GetSize()<arrP.GetSize()) {
106 fArrTrackP.Expand(arrP.GetSize());
67fd1119 107 }
108 if (fArrTrackN.GetSize()<arrN.GetSize()) {
109 fArrTrackN.Expand(arrN.GetSize());
67fd1119 110 }
5720c765 111
4fae8ef9 112 TExMap mapStoredVertices;
113 fPIDIndex=TProcessID::GetPIDs()->IndexOf(fPID);
5720c765 114 // fill particles
115 Int_t tracks=0;
116 for (Int_t itrack=0; itrack<arrP.GetEntriesFast(); ++itrack){
117 if (!fIsAOD){
118 AliESDtrack *track=dynamic_cast<AliESDtrack*>(arrP.At(itrack));
119 if (!track) continue;
120 new (fArrTrackP[tracks]) AliESDtrack(*track);
121 ++tracks;
122 } else {
123 AliAODTrack *track=dynamic_cast<AliAODTrack*>(arrP.At(itrack));
124 if (!track) continue;
67fd1119 125
0c09cae4 126 // buffer track
127 AliAODTrack *ctrack = new (fArrTrackP[tracks]) AliAODTrack(*track);
128
129 // buffer vertex, don't duplicate
130 // most particles will be assiciated to the primary vertex ...
131 AliAODVertex *vtx=track->GetProdVertex();
132 AliAODVertex *cvertex = 0x0;
4fae8ef9 133 if (vtx){
134 cvertex = reinterpret_cast<AliAODVertex*>(mapStoredVertices.GetValue(reinterpret_cast<ULong64_t>(vtx)));
135 if (!cvertex) {
136 if (mapStoredVertices.Capacity()<=mapStoredVertices.GetSize()) mapStoredVertices.Expand(2*mapStoredVertices.GetSize());
137 if (fArrVertex.GetSize()<=fArrVertex.GetEntriesFast()) fArrVertex.Expand(2*fArrVertex.GetSize());
0c09cae4 138 cvertex = new (fArrVertex[fArrVertex.GetEntriesFast()]) AliAODVertex(*vtx);
4fae8ef9 139 AssignID(cvertex);
140 mapStoredVertices.Add(reinterpret_cast<ULong64_t>(vtx),reinterpret_cast<ULong64_t>(cvertex));
0c09cae4 141 }
142 }
143 ctrack->SetProdVertex(cvertex);
5720c765 144 ++tracks;
145 }
146 }
147 fNTracksP=tracks;
148
149 tracks=0;
150 for (Int_t itrack=0; itrack<arrN.GetEntriesFast(); ++itrack){
151 if (!fIsAOD){
152 AliESDtrack *track=dynamic_cast<AliESDtrack*>(arrN.At(itrack));
153 if (!track) continue;
154 new (fArrTrackN[tracks]) AliESDtrack(*track);
155 ++tracks;
156 } else {
157 AliAODTrack *track=dynamic_cast<AliAODTrack*>(arrN.At(itrack));
158 if (!track) continue;
0c09cae4 159
160 //buffer track
161 AliAODTrack *ctrack = new (fArrTrackN[tracks]) AliAODTrack(*track);
67fd1119 162
0c09cae4 163 // buffer vertex, don't duplicate
164 // most particles will be assiciated to the primary vertex ...
165 AliAODVertex *vtx=track->GetProdVertex();
166 AliAODVertex *cvertex = 0x0;
4fae8ef9 167 if (vtx){
168 cvertex = reinterpret_cast<AliAODVertex*>(mapStoredVertices.GetValue(reinterpret_cast<ULong64_t>(vtx)));
169 if (!cvertex) {
170 if (mapStoredVertices.Capacity()<=mapStoredVertices.GetSize()) mapStoredVertices.Expand(2*mapStoredVertices.GetSize());
171 if (fArrVertex.GetSize()<=fArrVertex.GetEntriesFast()) fArrVertex.Expand(2*fArrVertex.GetSize());
0c09cae4 172 cvertex = new (fArrVertex[fArrVertex.GetEntriesFast()]) AliAODVertex(*vtx);
4fae8ef9 173 AssignID(cvertex);
174 mapStoredVertices.Add(reinterpret_cast<ULong64_t>(vtx),reinterpret_cast<ULong64_t>(cvertex));
0c09cae4 175 }
176 }
177 ctrack->SetProdVertex(cvertex);
5720c765 178 ++tracks;
179 }
180 }
181 fNTracksN=tracks;
182
183 //TODO: pair arrays
184}
185
186//______________________________________________
187void AliDielectronEvent::Clear(Option_t *opt)
188{
189 //
190 // clear arrays
191 //
192// fArrTrackP.Clear(opt);
193// fArrTrackN.Clear(opt);
194
195 for (Int_t i=fArrTrackP.GetEntriesFast()-1; i>=0; --i){
196 delete fArrTrackP.RemoveAt(i);
197 }
198
199 for (Int_t i=fArrTrackN.GetEntriesFast()-1; i>=0; --i){
200 delete fArrTrackN.RemoveAt(i);
0c09cae4 201 }
202
203 for (Int_t i=0; i<fArrVertex.GetEntriesFast(); ++i){
204 delete fArrVertex.RemoveAt(i);
5720c765 205 }
206
2d1c503f 207 fArrTrackP.ExpandCreateFast(1);
208 fArrTrackN.ExpandCreateFast(1);
209 fArrVertex.ExpandCreateFast(1);
6a9f06f1 210
5720c765 211 fArrPairs.Clear(opt);
5720c765 212}
213
214//______________________________________________
a94c2e7e 215void AliDielectronEvent::SetAOD(Int_t size)
5720c765 216{
217 //
218 // use AOD as input
219 //
a94c2e7e 220 fArrTrackP.SetClass("AliAODTrack",size);
221 fArrTrackN.SetClass("AliAODTrack",size);
5720c765 222 fIsAOD=kTRUE;
223}
224
88e9bae6 225//______________________________________________
226void AliDielectronEvent::SetESD()
227{
228 //
229 // use ESD as input
230 //
231 fArrTrackP.SetClass("AliESDtrack",1000);
232 fArrTrackN.SetClass("AliESDtrack",1000);
233 fIsAOD=kFALSE;
234}
235
5720c765 236//______________________________________________
237void AliDielectronEvent::SetEventData(const Double_t data[AliDielectronVarManager::kNMaxValues])
238{
239 //
240 // copy only evnet variables
241 //
242 for (Int_t i=AliDielectronVarManager::kPairMax; i<AliDielectronVarManager::kNMaxValues;++i) fEventData[i]=data[i];
67fd1119 243}
4fae8ef9 244
245//______________________________________________
246void AliDielectronEvent::AssignID(TObject *obj)
247{
248 //
249 // Custom function to assign a uid to an object with an own process id
250 // to avoid problems buffering the vertices
251 //
252 UInt_t uid=1;
253 if (fPID->GetObjects()) uid=fPID->GetObjects()->GetEntriesFast();
254 uid+=(fPIDIndex<<24);
255 obj->SetBit(kIsReferenced);
256 obj->SetUniqueID(uid);
257 fPID->PutObjectWithID(obj);
258}