1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
18 //_________________________________________________________________________
19 // A singleton that retrieves objets from an array stored in a Tree on a disk file
20 // 1. AliPHOSDigit from TreeD
21 // Why should I put meaningless comments
25 //*-- Author: Yves Schutz (SUBATECH)
26 //////////////////////////////////////////////////////////////////////////////
30 // --- ROOT system ---
34 // --- Standard library ---
36 // --- AliRoot header files ---
38 #include "AliPHOSIndexToObject.h"
40 ClassImp(AliPHOSIndexToObject)
42 AliPHOSIndexToObject * AliPHOSIndexToObject::fgObjGetter = 0 ;
44 //____________________________________________________________________________
45 AliPHOSIndexToObject::AliPHOSIndexToObject(AliPHOS * det)
47 // ctor called once to initialize the detector in use
52 //____________________________________________________________________________
53 AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance()
55 // Returns the pointer of the unique instance already defined
57 AliPHOSIndexToObject * rv = 0 ;
61 cout << "AliPHOSIndexToObject::GetInstance ERROR: not yet initialized" << endl ;
66 //____________________________________________________________________________
67 AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance(AliPHOS * det)
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)
72 if ( fgObjGetter ) // delete it if already exists
75 fgObjGetter = new AliPHOSIndexToObject(det) ;
81 //____________________________________________________________________________
82 AliPHOSDigit * AliPHOSIndexToObject::GimeDigit(Int_t index)
84 // returns the object AliPHOSDigit stored at array position index in TreeD
86 AliPHOSDigit * rv = 0 ;
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) ) ;
97 //____________________________________________________________________________
98 TParticle * AliPHOSIndexToObject::GimePrimaryParticle(Int_t index)
100 // returns the object TParticle stored at array position index in TreeK
104 if ( index >= gAlice->Particles()->GetEntries() )
105 cout << "AliPHOSIndexToObject::GimePrimaryParticles: index " << index << " larger than available entries "
106 << gAlice->Particles()->GetEntries() << endl ;
108 rv = (TParticle *) (gAlice->Particles()->At(index) ) ;
114 //____________________________________________________________________________
115 AliPHOSRecParticle * AliPHOSIndexToObject::GimeRecParticle(Int_t index)
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
121 AliPHOSRecParticle * rv = 0 ;
123 AliPHOSRecParticle::RecParticlesList * rplist = *(fDetector->RecParticles()) ;
125 Int_t rpentries = 0 ;
128 rpentries = rplist->GetEntries() ;
130 fReconstruct = gAlice->TreeR() ;
133 fReconstruct->SetBranchAddress( "PHOSRP", &rplist ) ;
134 fReconstruct->GetEvent(0) ;
135 rpentries = rplist->GetEntries() ;
138 if ( index >= rpentries ) // ERROR
139 cout << "AliPHOSIndexToObject::GimeRecParticle: index " << index << " larger than available entries "
140 << rpentries << endl ;
142 rv = (AliPHOSRecParticle *) (*(fDetector->RecParticles()) )->At(index) ;
148 //____________________________________________________________________________
149 AliRecPoint * AliPHOSIndexToObject::GimeRecPoint(Int_t index, TString type)
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
155 AliPHOSRecPoint * rv = 0 ;
157 AliPHOSRecPoint::RecPointsList * emclist = *(fDetector->EmcRecPoints() );
158 AliPHOSRecPoint::RecPointsList * ppsdlist = *(fDetector->PpsdRecPoints() );
160 Int_t emcentries = 0 ;
161 Int_t ppsdentries = 0 ;
164 emcentries = emclist->GetEntries() ;
167 ppsdentries= ppsdlist->GetEntries() ;
169 fReconstruct = gAlice->TreeR() ;
171 if (!emcentries && !ppsdentries) {
172 fReconstruct->SetBranchAddress("PHOSEmcRP",&emclist);
173 fReconstruct->SetBranchAddress("PHOSPpsdRP",&ppsdlist);
174 fReconstruct->GetEvent(0) ;
175 emcentries = emclist->GetEntries() ;
176 ppsdentries= ppsdlist->GetEntries() ;
179 if ( type == "emc" ) {
180 if ( index >= emcentries )
181 cout << "AliPHOSIndexToObject::GimeRecPoint emc: index " << index << " larger than available entries "
182 << emcentries << endl ;
184 rv = (AliPHOSEmcRecPoint *) ( emclist->At(index) ) ;
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) ) ;
193 cout << "AliPHOSIndexToObject::GimeRecPoint: " << type << " is an unknown type " << endl
194 << " valid types are : emc " << endl
195 << " ppsd " << endl ;
201 //____________________________________________________________________________
202 AliPHOSTrackSegment * AliPHOSIndexToObject::GimeTrackSegment(Int_t index)
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
208 AliPHOSTrackSegment * rv = 0 ;
210 AliPHOSTrackSegment::TrackSegmentsList * tslist = *( fDetector->TrackSegments()) ;
212 Int_t tsentries = 0 ;
215 tsentries = tslist->GetEntries() ;
217 fReconstruct = gAlice->TreeR() ;
220 fReconstruct->SetBranchAddress( "PHOSTS", &tslist ) ;
221 fReconstruct->GetEvent(0) ;
222 tsentries = tslist->GetEntries() ;
225 if ( index >= tsentries ) // ERROR
226 cout << "AliPHOSIndexToObject::GimeTrackSegment: index " << index << " larger than available entries "
227 << tsentries << endl ;
229 rv = (AliPHOSTrackSegment *) (tslist->At(index) ) ;