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