]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGDQ/dielectron/AliDielectronEvent.cxx
o update dielectron package
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / AliDielectronEvent.cxx
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 /*
21 Detailed 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
36 ClassImp(AliDielectronEvent)
37
38 AliDielectronEvent::AliDielectronEvent() :
39   TNamed(),
40   fArrTrackP("AliESDtrack",1000),
41   fArrTrackN("AliESDtrack",1000),
42   fArrPairs("AliKFParticle",0),
43   fNTracksP(0),
44   fNTracksN(0),
45   fIsAOD(kFALSE),
46   fEventData()
47 {
48   //
49   // Default Constructor
50   //
51   
52 }
53
54 //______________________________________________
55 AliDielectronEvent::AliDielectronEvent(const char* name, const char* title) :
56   TNamed(name, title),
57   fArrTrackP("AliESDtrack",1000),
58   fArrTrackN("AliESDtrack",1000),
59   fArrPairs("AliKFParticle",0),
60   fNTracksP(0),
61   fNTracksN(0),
62   fIsAOD(kFALSE),
63   fEventData()
64 {
65   //
66   // Named Constructor
67   //
68 }
69
70 //______________________________________________
71 AliDielectronEvent::~AliDielectronEvent()
72 {
73   //
74   // Default Destructor
75   //
76   fArrTrackP.Delete();
77   fArrTrackN.Delete();
78   fArrPairs.Delete();
79 }
80
81 //______________________________________________
82 void AliDielectronEvent::SetTracks(const TObjArray &arrP, const TObjArray &arrN, const TObjArray &/*arrPairs*/)
83 {
84   //
85   // Setup AliKFParticles
86   // assumes that the objects in arrP and arrN are AliVTracks
87   //
88
89   //Clear out old entries before filling new ones
90   Clear();
91   // we keep the tracks buffered to minimise new / delete operations
92   fNTracksN=0;
93   fNTracksP=0;
94
95   //check size of the arrays
96   if (fArrTrackP.GetSize()<arrP.GetSize()) fArrTrackP.Expand(arrP.GetSize());
97   if (fArrTrackN.GetSize()<arrN.GetSize()) fArrTrackN.Expand(arrN.GetSize());
98
99   // fill particles
100   Int_t tracks=0;
101   for (Int_t itrack=0; itrack<arrP.GetEntriesFast(); ++itrack){
102     if (!fIsAOD){
103       AliESDtrack *track=dynamic_cast<AliESDtrack*>(arrP.At(itrack));
104       if (!track) continue;
105       new (fArrTrackP[tracks]) AliESDtrack(*track);
106       ++tracks;
107     } else {
108       AliAODTrack *track=dynamic_cast<AliAODTrack*>(arrP.At(itrack));
109       if (!track) continue;
110       new (fArrTrackP[tracks]) AliAODTrack(*track);
111       ++tracks;
112     }
113   }
114   fNTracksP=tracks;
115
116   tracks=0;
117   for (Int_t itrack=0; itrack<arrN.GetEntriesFast(); ++itrack){
118     if (!fIsAOD){
119       AliESDtrack *track=dynamic_cast<AliESDtrack*>(arrN.At(itrack));
120       if (!track) continue;
121       new (fArrTrackN[tracks]) AliESDtrack(*track);
122       ++tracks;
123     } else {
124       AliAODTrack *track=dynamic_cast<AliAODTrack*>(arrN.At(itrack));
125       if (!track) continue;
126       new (fArrTrackN[tracks]) AliAODTrack(*track);
127       ++tracks;
128     }
129   }
130   fNTracksN=tracks;
131
132   //TODO: pair arrays
133 }
134
135 //______________________________________________
136 void AliDielectronEvent::Clear(Option_t *opt)
137 {
138   //
139   // clear arrays
140   //
141 //   fArrTrackP.Clear(opt);
142 //   fArrTrackN.Clear(opt);
143
144   for (Int_t i=fArrTrackP.GetEntriesFast()-1; i>=0; --i){
145     delete fArrTrackP.RemoveAt(i);
146   }
147   
148   for (Int_t i=fArrTrackN.GetEntriesFast()-1; i>=0; --i){
149     delete fArrTrackN.RemoveAt(i);
150   }
151   
152   fArrPairs.Clear(opt);
153   
154 }
155
156 //______________________________________________
157 void AliDielectronEvent::SetAOD()
158 {
159   //
160   // use AOD as input
161   //
162   fArrTrackP.SetClass("AliAODTrack");
163   fArrTrackN.SetClass("AliAODTrack");
164   fIsAOD=kTRUE;
165 }
166
167 //______________________________________________
168 void AliDielectronEvent::SetEventData(const Double_t data[AliDielectronVarManager::kNMaxValues])
169 {
170   //
171   // copy only evnet variables
172   //
173   for (Int_t i=AliDielectronVarManager::kPairMax; i<AliDielectronVarManager::kNMaxValues;++i) fEventData[i]=data[i];
174 }