1 /*************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
17 // Dielectron Event //
26 ///////////////////////////////////////////////////////////////////////////
28 #include <TObjArray.h>
30 #include <TProcessID.h>
32 #include <AliVTrack.h>
33 #include <AliESDtrack.h>
34 #include <AliAODTrack.h>
36 #include "AliDielectronEvent.h"
38 ClassImp(AliDielectronEvent)
40 AliDielectronEvent::AliDielectronEvent() :
44 fArrVertex("AliAODVertex",10),
45 fArrPairs("AliKFParticle",0),
54 // Default Constructor
59 //______________________________________________
60 AliDielectronEvent::AliDielectronEvent(const char* name, const char* title) :
64 fArrVertex("AliAODVertex",10),
65 fArrPairs("AliKFParticle",0),
78 //______________________________________________
79 AliDielectronEvent::~AliDielectronEvent()
90 //______________________________________________
91 void AliDielectronEvent::SetTracks(const TObjArray &arrP, const TObjArray &arrN, const TObjArray &/*arrPairs*/)
94 // Setup AliKFParticles
95 // assumes that the objects in arrP and arrN are AliVTracks
98 //Clear out old entries before filling new ones
100 // we keep the tracks buffered to minimise new / delete operations
104 //check size of the arrays
105 if (fArrTrackP.GetSize()<arrP.GetSize()) {
106 fArrTrackP.Expand(arrP.GetSize());
108 if (fArrTrackN.GetSize()<arrN.GetSize()) {
109 fArrTrackN.Expand(arrN.GetSize());
112 TExMap mapStoredVertices;
113 fPIDIndex=TProcessID::GetPIDs()->IndexOf(fPID);
116 for (Int_t itrack=0; itrack<arrP.GetEntriesFast(); ++itrack){
118 AliESDtrack *track=dynamic_cast<AliESDtrack*>(arrP.At(itrack));
119 if (!track) continue;
120 new (fArrTrackP[tracks]) AliESDtrack(*track);
123 AliAODTrack *track=dynamic_cast<AliAODTrack*>(arrP.At(itrack));
124 if (!track) continue;
127 AliAODTrack *ctrack = new (fArrTrackP[tracks]) AliAODTrack(*track);
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;
134 cvertex = reinterpret_cast<AliAODVertex*>(mapStoredVertices.GetValue(reinterpret_cast<ULong64_t>(vtx)));
136 if (mapStoredVertices.Capacity()<=mapStoredVertices.GetSize()) mapStoredVertices.Expand(2*mapStoredVertices.GetSize());
137 if (fArrVertex.GetSize()<=fArrVertex.GetEntriesFast()) fArrVertex.Expand(2*fArrVertex.GetSize());
138 cvertex = new (fArrVertex[fArrVertex.GetEntriesFast()]) AliAODVertex(*vtx);
140 mapStoredVertices.Add(reinterpret_cast<ULong64_t>(vtx),reinterpret_cast<ULong64_t>(cvertex));
143 ctrack->SetProdVertex(cvertex);
150 for (Int_t itrack=0; itrack<arrN.GetEntriesFast(); ++itrack){
152 AliESDtrack *track=dynamic_cast<AliESDtrack*>(arrN.At(itrack));
153 if (!track) continue;
154 new (fArrTrackN[tracks]) AliESDtrack(*track);
157 AliAODTrack *track=dynamic_cast<AliAODTrack*>(arrN.At(itrack));
158 if (!track) continue;
161 AliAODTrack *ctrack = new (fArrTrackN[tracks]) AliAODTrack(*track);
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;
168 cvertex = reinterpret_cast<AliAODVertex*>(mapStoredVertices.GetValue(reinterpret_cast<ULong64_t>(vtx)));
170 if (mapStoredVertices.Capacity()<=mapStoredVertices.GetSize()) mapStoredVertices.Expand(2*mapStoredVertices.GetSize());
171 if (fArrVertex.GetSize()<=fArrVertex.GetEntriesFast()) fArrVertex.Expand(2*fArrVertex.GetSize());
172 cvertex = new (fArrVertex[fArrVertex.GetEntriesFast()]) AliAODVertex(*vtx);
174 mapStoredVertices.Add(reinterpret_cast<ULong64_t>(vtx),reinterpret_cast<ULong64_t>(cvertex));
177 ctrack->SetProdVertex(cvertex);
186 //______________________________________________
187 void AliDielectronEvent::Clear(Option_t *opt)
192 // fArrTrackP.Clear(opt);
193 // fArrTrackN.Clear(opt);
195 for (Int_t i=fArrTrackP.GetEntriesFast()-1; i>=0; --i){
196 delete fArrTrackP.RemoveAt(i);
199 for (Int_t i=fArrTrackN.GetEntriesFast()-1; i>=0; --i){
200 delete fArrTrackN.RemoveAt(i);
203 for (Int_t i=0; i<fArrVertex.GetEntriesFast(); ++i){
204 delete fArrVertex.RemoveAt(i);
207 fArrPairs.Clear(opt);
210 //______________________________________________
211 void AliDielectronEvent::SetAOD(Int_t size)
216 fArrTrackP.SetClass("AliAODTrack",size);
217 fArrTrackN.SetClass("AliAODTrack",size);
221 //______________________________________________
222 void AliDielectronEvent::SetESD()
227 fArrTrackP.SetClass("AliESDtrack",1000);
228 fArrTrackN.SetClass("AliESDtrack",1000);
232 //______________________________________________
233 void AliDielectronEvent::SetEventData(const Double_t data[AliDielectronVarManager::kNMaxValues])
236 // copy only evnet variables
238 for (Int_t i=AliDielectronVarManager::kPairMax; i<AliDielectronVarManager::kNMaxValues;++i) fEventData[i]=data[i];
241 //______________________________________________
242 void AliDielectronEvent::AssignID(TObject *obj)
245 // Custom function to assign a uid to an object with an own process id
246 // to avoid problems buffering the vertices
249 if (fPID->GetObjects()) uid=fPID->GetObjects()->GetEntriesFast();
250 uid+=(fPIDIndex<<24);
251 obj->SetBit(kIsReferenced);
252 obj->SetUniqueID(uid);
253 fPID->PutObjectWithID(obj);