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 ---
29 // --- Standard library ---
31 // --- AliRoot header files ---
33 #include "AliPHOSIndexToObject.h"
35 ClassImp(AliPHOSIndexToObject)
37 AliPHOSIndexToObject * AliPHOSIndexToObject::fgObjGetter = 0 ;
39 //____________________________________________________________________________
40 AliPHOSIndexToObject::AliPHOSIndexToObject(AliPHOS * det)
42 // ctor called once to initialize the detector in use
47 //____________________________________________________________________________
48 AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance()
50 // Returns the pointer of the unique instance already defined
52 AliPHOSIndexToObject * rv = 0 ;
56 cout << "AliPHOSIndexToObject::GetInstance ERROR: not yet initialized" << endl ;
61 //____________________________________________________________________________
62 AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance(AliPHOS * det)
64 // Creates and returns the pointer of the unique instance
65 // Must be called only when the environment has changed (a new event for exemple)
67 if ( fgObjGetter ) // delete it if already exists
70 fgObjGetter = new AliPHOSIndexToObject(det) ;
76 //____________________________________________________________________________
77 AliPHOSDigit * AliPHOSIndexToObject::GimeDigit(Int_t index)
79 // returns the object AliPHOSDigit stored at array position index in TreeD
81 AliPHOSDigit * rv = 0 ;
83 if ( index >= fDetector->Digits()->GetEntries() )
84 cout << "AliPHOSIndexToObject::GimeDigit: index " << index << " larger than available entries "
85 << fDetector->Digits()->GetEntries() << endl ;
86 else if ( index != -1)
87 rv = (AliPHOSDigit *) (fDetector->Digits()->At(index) ) ;
92 //____________________________________________________________________________
93 TParticle * AliPHOSIndexToObject::GimePrimaryParticle(Int_t index)
95 // returns the object TParticle stored at array position index in TreeK
99 if ( index >= gAlice->Particles()->GetEntries() )
100 cout << "AliPHOSIndexToObject::GimePrimaryParticles: index " << index << " larger than available entries "
101 << gAlice->Particles()->GetEntries() << endl ;
103 rv = (TParticle *) (gAlice->Particles()->At(index) ) ;
109 //____________________________________________________________________________
110 AliPHOSRecParticle * AliPHOSIndexToObject::GimeRecParticle(Int_t index)
112 // returns the object AliPHOSRecParticle stored at array position index in TreeR/PHOSRP
113 // this one takes more work because the detetor object and the objects in TreeR are not saved at the same time
114 // therefore the links are lost
116 AliPHOSRecParticle * rv = 0 ;
118 AliPHOSRecParticle::RecParticlesList * rplist = *(fDetector->RecParticles()) ;
120 Int_t rpentries = 0 ;
123 rpentries = rplist->GetEntries() ;
125 fReconstruct = gAlice->TreeR() ;
128 fReconstruct->SetBranchAddress( "PHOSRP", &rplist ) ;
129 fReconstruct->GetEvent(0) ;
130 rpentries = rplist->GetEntries() ;
133 if ( index >= rpentries ) // ERROR
134 cout << "AliPHOSIndexToObject::GimeRecParticle: index " << index << " larger than available entries "
135 << rpentries << endl ;
137 rv = (AliPHOSRecParticle *) (*(fDetector->RecParticles()) )->At(index) ;
143 //____________________________________________________________________________
144 AliRecPoint * AliPHOSIndexToObject::GimeRecPoint(Int_t index, TString type)
146 // returns the object AliPHOSRecPoint stored at array position index in TreeR/PHOSEmcRP or TreeR/PHOSPpsdRP
147 // this one takes more work because the detetor object and the objects in TreeR are not saved at the same time
148 // therefore the links are lost
150 AliPHOSRecPoint * rv = 0 ;
152 AliPHOSRecPoint::RecPointsList * emclist = *(fDetector->EmcRecPoints() );
153 AliPHOSRecPoint::RecPointsList * ppsdlist = *(fDetector->PpsdRecPoints() );
155 Int_t emcentries = 0 ;
156 Int_t ppsdentries = 0 ;
159 emcentries = emclist->GetEntries() ;
162 ppsdentries= ppsdlist->GetEntries() ;
164 fReconstruct = gAlice->TreeR() ;
166 if (!emcentries && !ppsdentries) {
167 fReconstruct->SetBranchAddress("PHOSEmcRP",&emclist);
168 fReconstruct->SetBranchAddress("PHOSPpsdRP",&ppsdlist);
169 fReconstruct->GetEvent(0) ;
170 emcentries = emclist->GetEntries() ;
171 ppsdentries= ppsdlist->GetEntries() ;
174 if ( type == "emc" ) {
175 if ( index >= emcentries )
176 cout << "AliPHOSIndexToObject::GimeRecPoint emc: index " << index << " larger than available entries "
177 << emcentries << endl ;
179 rv = (AliPHOSEmcRecPoint *) ( emclist->At(index) ) ;
181 else if ( type == "ppsd" ) {
182 if ( index >= ppsdentries )
183 cout << "AliPHOSIndexToObject::GimeRecPoint ppsd: index " << index << " larger than available entries "
184 << ppsdentries << endl ;
185 else if (index != -1)
186 rv = (AliPHOSPpsdRecPoint *) (ppsdlist->At(index) ) ;
188 cout << "AliPHOSIndexToObject::GimeRecPoint: " << type << " is an unknown type " << endl
189 << " valid types are : emc " << endl
190 << " ppsd " << endl ;
196 //____________________________________________________________________________
197 AliPHOSTrackSegment * AliPHOSIndexToObject::GimeTrackSegment(Int_t index)
199 // returns the object AliPHOSTrackSegment stored at array position index in TreeR/PHOSTS
200 // this one takes more work because the detetor object and the objects in TreeR are not saved at the same time
201 // therefore the links are lost
203 AliPHOSTrackSegment * rv = 0 ;
205 AliPHOSTrackSegment::TrackSegmentsList * tslist = *( fDetector->TrackSegments()) ;
207 Int_t tsentries = 0 ;
210 tsentries = tslist->GetEntries() ;
212 fReconstruct = gAlice->TreeR() ;
215 fReconstruct->SetBranchAddress( "PHOSTS", &tslist ) ;
216 fReconstruct->GetEvent(0) ;
217 tsentries = tslist->GetEntries() ;
220 if ( index >= tsentries ) // ERROR
221 cout << "AliPHOSIndexToObject::GimeTrackSegment: index " << index << " larger than available entries "
222 << tsentries << endl ;
224 rv = (AliPHOSTrackSegment *) (tslist->At(index) ) ;