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
22 //*-- Author: Yves Schutz (SUBATECH)
23 //////////////////////////////////////////////////////////////////////////////
25 // --- ROOT system ---
27 // --- Standard library ---
29 // --- AliRoot header files ---
31 #include "AliPHOSIndexToObject.h"
33 ClassImp(AliPHOSIndexToObject)
35 AliPHOSIndexToObject * AliPHOSIndexToObject::fgObjGetter = 0 ;
37 //____________________________________________________________________________
38 AliPHOSIndexToObject::AliPHOSIndexToObject(AliPHOS * det)
40 // ctor called once to initialize the detector in use
45 //____________________________________________________________________________
46 AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance()
48 // Returns the pointer of the unique instance already defined
50 AliPHOSIndexToObject * rv = 0 ;
54 cout << "AliPHOSIndexToObject::GetInstance ERROR: not yet initialized" << endl ;
59 //____________________________________________________________________________
60 AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance(AliPHOS * det)
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)
65 if ( fgObjGetter ) // delete it if already exists
68 fgObjGetter = new AliPHOSIndexToObject(det) ;
74 //____________________________________________________________________________
75 AliPHOSDigit * AliPHOSIndexToObject::GimeDigit(Int_t index)
77 // returns the object AliPHOSDigit stored at array position index in TreeD
79 AliPHOSDigit * rv = 0 ;
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) ) ;
90 //____________________________________________________________________________
91 TParticle * AliPHOSIndexToObject::GimePrimaryParticle(Int_t index)
93 // returns the object TParticle stored at array position index in TreeK
97 if ( index >= gAlice->Particles()->GetEntries() )
98 cout << "AliPHOSIndexToObject::GimePrimaryParticles: index " << index << " larger than available entries "
99 << gAlice->Particles()->GetEntries() << endl ;
101 rv = (TParticle *) (gAlice->Particles()->At(index) ) ;
107 //____________________________________________________________________________
108 AliPHOSRecParticle * AliPHOSIndexToObject::GimeRecParticle(Int_t index)
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
114 AliPHOSRecParticle * rv = 0 ;
116 AliPHOSRecParticle::RecParticlesList * rplist = fDetector->RecParticles() ;
118 Int_t rpentries = 0 ;
121 rpentries = rplist->GetEntries() ;
123 fReconstruct = gAlice->TreeR() ;
126 fReconstruct->SetBranchAddress( "PHOSRP", &rplist ) ;
127 fReconstruct->GetEvent(0) ;
128 rpentries = rplist->GetEntries() ;
131 if ( index >= rpentries ) // ERROR
132 cout << "AliPHOSIndexToObject::GimeRecParticle: index " << index << " larger than available entries "
133 << rpentries << endl ;
135 rv = (AliPHOSRecParticle *) (fDetector->RecParticles()->At(index) ) ;
141 //____________________________________________________________________________
142 AliRecPoint * AliPHOSIndexToObject::GimeRecPoint(Int_t index, TString type)
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
148 AliPHOSRecPoint * rv = 0 ;
150 AliPHOSRecPoint::RecPointsList * emclist = fDetector->EmcRecPoints() ;
151 AliPHOSRecPoint::RecPointsList * ppsdlist = fDetector->PpsdRecPoints() ;
153 Int_t emcentries = 0 ;
154 Int_t ppsdentries = 0 ;
157 emcentries = emclist->GetEntries() ;
160 ppsdentries= ppsdlist->GetEntries() ;
162 fReconstruct = gAlice->TreeR() ;
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() ;
172 if ( type == "emc" ) {
173 if ( index >= emcentries )
174 cout << "AliPHOSIndexToObject::GimeRecPoint emc: index " << index << " larger than available entries "
175 << emcentries << endl ;
177 rv = (AliPHOSEmcRecPoint *) ( emclist->At(index) ) ;
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) ) ;
186 cout << "AliPHOSIndexToObject::GimeRecPoint: " << type << " is an unknown type " << endl
187 << " valid types are : emc " << endl
188 << " ppsd " << endl ;
194 //____________________________________________________________________________
195 AliPHOSTrackSegment * AliPHOSIndexToObject::GimeTrackSegment(Int_t index)
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
201 AliPHOSTrackSegment * rv = 0 ;
203 AliPHOSTrackSegment::TrackSegmentsList * tslist = fDetector->TrackSegments() ;
205 Int_t tsentries = 0 ;
208 tsentries = tslist->GetEntries() ;
210 fReconstruct = gAlice->TreeR() ;
213 fReconstruct->SetBranchAddress( "PHOSTS", &tslist ) ;
214 fReconstruct->GetEvent(0) ;
215 tsentries = tslist->GetEntries() ;
218 if ( index >= tsentries ) // ERROR
219 cout << "AliPHOSIndexToObject::GimeTrackSegment: index " << index << " larger than available entries "
220 << tsentries << endl ;
222 rv = (AliPHOSTrackSegment *) (tslist->At(index) ) ;