Removed unused data members
[u/mrichter/AliRoot.git] / PHOS / AliPHOSIndexToObject.cxx
CommitLineData
83974468 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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/* $Id: */
17
18//_________________________________________________________________________
19// A singleton that retrieves objets from an array stored in a Tree on a disk file
20// 1. AliPHOSDigit from TreeD
21//
22//*-- Author: Yves Schutz (SUBATECH)
23//////////////////////////////////////////////////////////////////////////////
24
25// --- ROOT system ---
26
27// --- Standard library ---
28
29// --- AliRoot header files ---
30
31#include "AliPHOSIndexToObject.h"
32
33ClassImp(AliPHOSIndexToObject)
34
35 AliPHOSIndexToObject * AliPHOSIndexToObject::fObjGetter = 0 ;
36
37//____________________________________________________________________________
38AliPHOSIndexToObject::AliPHOSIndexToObject(AliPHOS * det)
39{
40 // ctor called once to initialize the detector in use
41
42 fDetector = det ;
43}
44
45//____________________________________________________________________________
46AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance()
47{
48 // Returns the pointer of the unique instance already defined
49
50 AliPHOSIndexToObject * rv = 0 ;
51 if ( fObjGetter )
52 rv = fObjGetter ;
53 else
54 cout << "AliPHOSIndexToObject::GetInstance ERROR: not yet initialized" << endl ;
55
56 return rv ;
57}
58
59//____________________________________________________________________________
60AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance(AliPHOS * det)
61{
62 // Creates and returns the pointer of the unique instance
63 // Must be called only when the environment has changed (a new event for exemple)
64
65 if ( fObjGetter ) // delete it if already exists
66 delete fObjGetter ;
67
68 fObjGetter = new AliPHOSIndexToObject(det) ;
69
70 return fObjGetter ;
71
72}
73
74//____________________________________________________________________________
75AliPHOSDigit * AliPHOSIndexToObject::GimeDigit(Int_t index)
76{
77 // returns the object AliPHOSDigit stored at array position index in TreeD
78
79 AliPHOSDigit * rv = 0 ;
80
81 if ( index >= fDetector->Digits()->GetEntries() )
82 cout << "AliPHOSIndexToObject::GimeDigit: index " << index << " larger than available entries "
83 << fDetector->Digits()->GetEntries() << endl ;
84 else if ( index != -1)
85 rv = (AliPHOSDigit *) (fDetector->Digits()->At(index) ) ;
86
87 return rv ;
88
89}
90//____________________________________________________________________________
91TParticle * AliPHOSIndexToObject::GimePrimaryParticle(Int_t index)
92{
93 // returns the object TParticle stored at array position index in TreeK
94
95 TParticle * rv = 0 ;
96
97 if ( index >= gAlice->Particles()->GetEntries() )
98 cout << "AliPHOSIndexToObject::GimePrimaryParticles: index " << index << " larger than available entries "
99 << gAlice->Particles()->GetEntries() << endl ;
100 else
101 rv = (TParticle *) (gAlice->Particles()->At(index) ) ;
102
103 return rv ;
104
105}
106
107//____________________________________________________________________________
108AliPHOSRecParticle * AliPHOSIndexToObject::GimeRecParticle(Int_t index)
109{
110 // returns the object AliPHOSRecParticle stored at array position index in TreeR/PHOSRP
111 // this one takes more work because the detetor object and the objects in TreeR are not saved at the same time
112 // therefore the links are lost
113
114 AliPHOSRecParticle * rv = 0 ;
115
116 RecParticlesList * rplist = fDetector->RecParticles() ;
117
118 Int_t rpentries = 0 ;
119
120 if (rplist)
121 rpentries = rplist->GetEntries() ;
122
123 fReconstruct = gAlice->TreeR() ;
124
125 if (!rpentries) {
126 fReconstruct->SetBranchAddress( "PHOSRP", &rplist ) ;
127 fReconstruct->GetEvent(0) ;
128 rpentries = rplist->GetEntries() ;
129 }
130
131 if ( index >= rpentries ) // ERROR
132 cout << "AliPHOSIndexToObject::GimeRecParticle: index " << index << " larger than available entries "
133 << rpentries << endl ;
134 else
135 rv = (AliPHOSRecParticle *) (fDetector->RecParticles()->At(index) ) ;
136
137 return rv ;
138
139}
140
141//____________________________________________________________________________
142AliRecPoint * AliPHOSIndexToObject::GimeRecPoint(Int_t index, TString type)
143{
144 // returns the object AliPHOSRecPoint stored at array position index in TreeR/PHOSEmcRP or TreeR/PHOSPpsdRP
145 // this one takes more work because the detetor object and the objects in TreeR are not saved at the same time
146 // therefore the links are lost
147
148 AliPHOSRecPoint * rv = 0 ;
149
150 RecPointsList * emclist = fDetector->EmcRecPoints() ;
151 RecPointsList * ppsdlist = fDetector->PpsdRecPoints() ;
152
153 Int_t emcentries = 0 ;
154 Int_t ppsdentries = 0 ;
155
156 if (emclist)
157 emcentries = emclist->GetEntries() ;
158
159 if (ppsdlist)
160 ppsdentries= ppsdlist->GetEntries() ;
161
162 fReconstruct = gAlice->TreeR() ;
163
164 if (!emcentries || !ppsdentries) {
165 fReconstruct->SetBranchAddress("PHOSEmcRP",&emclist);
166 fReconstruct->SetBranchAddress("PHOSPpsdRP",&ppsdlist);
167 fReconstruct->GetEvent(0) ;
168 emcentries = emclist->GetEntries() ;
169 ppsdentries= ppsdlist->GetEntries() ;
170 }
171
172 if ( type == "emc" ) {
173 if ( index >= emcentries )
174 cout << "AliPHOSIndexToObject::GimeRecPoint emc: index " << index << " larger than available entries "
175 << emcentries << endl ;
176 else
177 rv = (AliPHOSEmcRecPoint *) ( emclist->At(index) ) ;
178 }
179 else if ( type == "ppsd" ) {
180 if ( index >= ppsdentries )
181 cout << "AliPHOSIndexToObject::GimeRecPoint ppsd: index " << index << " larger than available entries "
182 << ppsdentries << endl ;
183 else if (index != -1)
184 rv = (AliPHOSPpsdRecPoint *) (ppsdlist->At(index) ) ;
185 } else
186 cout << "AliPHOSIndexToObject::GimeRecPoint: " << type << " is an unknown type " << endl
187 << " valid types are : emc " << endl
188 << " ppsd " << endl ;
189
190 return rv ;
191
192}
193
194//____________________________________________________________________________
195AliPHOSTrackSegment * AliPHOSIndexToObject::GimeTrackSegment(Int_t index)
196{
197 // returns the object AliPHOSTrackSegment stored at array position index in TreeR/PHOSTS
198 // this one takes more work because the detetor object and the objects in TreeR are not saved at the same time
199 // therefore the links are lost
200
201 AliPHOSTrackSegment * rv = 0 ;
202
203 TrackSegmentsList * tslist = fDetector->TrackSegments() ;
204
205 Int_t tsentries = 0 ;
206
207 if (tslist)
208 tsentries = tslist->GetEntries() ;
209
210 fReconstruct = gAlice->TreeR() ;
211
212 if (!tsentries) {
213 fReconstruct->SetBranchAddress( "PHOSTS", &tslist ) ;
214 fReconstruct->GetEvent(0) ;
215 tsentries = tslist->GetEntries() ;
216 }
217
218 if ( index >= tsentries ) // ERROR
219 cout << "AliPHOSIndexToObject::GimeTrackSegment: index " << index << " larger than available entries "
220 << tsentries << endl ;
221 else
f4ab1ca2 222 rv = (AliPHOSTrackSegment *) (tslist->At(index) ) ;
83974468 223
224 return rv ;
225
226}