]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSPpsdRecPoint.cxx
Removal of useless dependencies via forward declarations
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPpsdRecPoint.cxx
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 RecPoint (cluster) in the PPSD 
20 //  A PPSD RecPoint ends up to be a single digit
21 //                
22 //*--  Yves Schutz (SUBATECH)
23
24 // --- ROOT system ---
25
26 #include "TPad.h"
27
28 // --- Standard library ---
29
30 #include <iostream.h>
31
32 // --- AliRoot header files ---
33
34 #include "AliPHOSGeometry.h"
35 #include "AliPHOSPpsdRecPoint.h"
36 #include "AliRun.h"
37 #include "AliPHOSIndexToObject.h"
38
39 ClassImp(AliPHOSPpsdRecPoint)
40
41 //____________________________________________________________________________
42 AliPHOSPpsdRecPoint::AliPHOSPpsdRecPoint(void)
43
44   // ctor
45
46   fMulDigit = 0 ;  
47   AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;  
48   fDelta = geom->GetCrystalSize(0) ; 
49   fLocPos.SetX(1000000.)  ;      //Local position should be evaluated
50 }
51
52 //____________________________________________________________________________
53 void AliPHOSPpsdRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
54 {
55   // adds a digit to the digits list
56   // and accumulates the total amplitude and the multiplicity 
57   
58   
59   if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists 
60     fMaxDigit*=2 ; 
61     int * tempo = new ( int[fMaxDigit] ) ; 
62     Int_t index ; 
63     
64     for ( index = 0 ; index < fMulDigit ; index++ )
65       tempo[index] = fDigitsList[index] ;
66     
67     delete []  fDigitsList ; 
68     fDigitsList =  new ( int[fMaxDigit] ) ;
69    
70     for ( index = 0 ; index < fMulDigit ; index++ )
71       fDigitsList[index] = tempo[index] ;
72  
73     delete [] tempo ;
74   }
75
76   fDigitsList[fMulDigit++]  =  digit.GetIndexInList() ; 
77   fAmp += Energy ; 
78 }
79
80 //____________________________________________________________________________
81 Int_t AliPHOSPpsdRecPoint::Compare(TObject * obj)
82 {
83   // Compares according to the position
84   
85   Int_t rv ; 
86   
87   AliPHOSPpsdRecPoint * clu = (AliPHOSPpsdRecPoint *)obj ; 
88   
89  
90   Float_t x1 , z1 ;
91   Float_t x2 , z2 ;
92   
93   Int_t phosmod1 ;
94   Int_t phosmod2 ;
95   
96   Int_t up1 ;
97   Int_t up2 ; 
98   
99   if(GetUp()) // upper layer
100     up1 = 0 ; 
101   else        // lower layer
102     up1 = 1 ;       
103   
104   if(clu->GetUp()) // upper layer
105     up2 = 0 ; 
106   else            // lower layer
107     up2 = 1 ;       
108
109   TVector3 posloc ;
110   this->GetLocalPosition(posloc) ;
111   x1 = posloc.X() ;
112   z1 = posloc.Z() ; 
113   phosmod1 = this->GetPHOSMod();  
114   clu->GetLocalPosition(posloc) ;
115   x2 = posloc.X() ;
116   z2 = posloc.Z() ; 
117   phosmod2 = clu->GetPHOSMod();
118
119   if(phosmod1 == phosmod2 ) {
120  
121     if(up1 == up2 ){
122       Int_t rowdif = (Int_t)TMath::Ceil(x1/fDelta) - (Int_t) TMath::Ceil(x2/fDelta) ;
123
124       if (rowdif> 0) 
125         rv = -1 ;
126       else if(rowdif < 0) 
127         rv = 1 ;
128       else if(z1>z2) 
129         rv = -1 ;
130       else 
131         rv = 1 ; 
132     }
133
134     else {
135
136       if(up1 < up2 ) // Upper level first (up = True or False, True > False)
137         rv = 1 ;   
138       else 
139         rv = - 1 ;
140     }
141     
142   } // if phosmod1 == phosmod2
143
144   else {
145
146     if(phosmod1 < phosmod2 ) 
147       rv = -1 ;
148     else 
149       rv = 1 ;
150   
151 }
152   
153   return rv ; 
154 }
155
156 //____________________________________________________________________________
157 void AliPHOSPpsdRecPoint::GetLocalPosition(TVector3 &LPos)
158 {
159   // Calculates the local position in the PHOS-PPSD-module corrdinates
160   
161   AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
162
163   if( fLocPos.X() < 1000000.) { //allready evaluated
164    LPos = fLocPos ;
165    return ;
166   }
167
168   Int_t relid[4] ;
169
170   Float_t x = 0. ;
171   Float_t z = 0. ;
172
173   AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
174   
175   AliPHOSDigit * digit ;
176   Int_t iDigit;
177
178   for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
179     digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ); 
180  
181     Float_t xi ;
182     Float_t zi ;
183     phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
184     phosgeom->RelPosInModule(relid, xi, zi);
185     x += xi ;
186     z += zi ;
187   }
188
189   x /= fMulDigit ;
190   z /= fMulDigit ;
191
192   fLocPos.SetX(x)  ;
193   fLocPos.SetY(0.) ;
194   fLocPos.SetZ(z)  ;
195
196   LPos = fLocPos ;
197
198 }
199
200 //____________________________________________________________________________
201 Bool_t AliPHOSPpsdRecPoint::GetUp() 
202 {
203   // Are we in the uper PPSD module ?
204
205   Int_t relid[4] ;
206   
207   AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
208
209   AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
210   
211   
212   AliPHOSDigit *digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[0]) ) ; 
213   
214   phosgeom->AbsToRelNumbering(digit->GetId(),relid);
215   Bool_t up ;
216
217   if((Int_t)TMath::Ceil((Float_t)relid[1]/
218                         (phosgeom->GetNumberOfModulesPhi()*phosgeom->GetNumberOfModulesZ())-0.0001 ) > 1) 
219     up = kFALSE ;
220   else  
221     up = kTRUE ;
222   
223   return up ;
224 }
225 //______________________________________________________________________________
226 void AliPHOSPpsdRecPoint::Paint(Option_t *)
227 {
228   //*-*-*-*-*-*-*-*-*-*-*Paint this ALiRecPoint as a TMarker  with its current attributes*-*-*-*-*-*-*
229   //*-*                  =============================================
230
231   TVector3 pos(0.,0.,0.) ;
232   GetLocalPosition(pos) ;
233   Coord_t x = pos.X() ;
234   Coord_t y = pos.Z() ;
235   Color_t markercolor = 1 ;
236   Size_t  markersize  = 1. ;
237   Style_t markerstyle = 2 ;
238   if (GetUp()) 
239     markerstyle = 3 ;
240   
241   if (!gPad->IsBatch()) {
242     gVirtualX->SetMarkerColor(markercolor);
243     gVirtualX->SetMarkerSize (markersize);
244     gVirtualX->SetMarkerStyle(markerstyle);
245   }
246   gPad->SetAttMarkerPS(markercolor,markerstyle,markersize);
247   gPad->PaintPolyMarker(1,&x,&y,"");
248   
249   
250 }
251
252 //____________________________________________________________________________
253 void AliPHOSPpsdRecPoint::Print(Option_t * option) 
254 {
255   // Print the digits information 
256   
257   cout << "AliPHOSPpsdRecPoint: " << endl ;
258   
259   AliPHOSDigit * digit ; 
260   Int_t iDigit;
261   AliPHOSGeometry * phosgeom =  (AliPHOSGeometry *) fGeom ;
262
263   Float_t xi ;
264   Float_t zi ;
265   Int_t relid[4] ; 
266
267   AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
268   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
269     digit = please->GimeDigit( fDigitsList[iDigit] ) ; 
270     if (digit) {
271       phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
272       phosgeom->RelPosInModule(relid, xi, zi);
273       cout << " Id = " << digit->GetId() ;  
274       cout << "  Phos mod = " << relid[0] ;  
275       cout << "  PPSD mod = " << relid[1] ;  
276       cout << "  x = " << xi ;  
277       cout << "  z = " << zi ;  
278       cout << "   Energy = " << digit->GetAmp() << endl ;
279     }
280   }
281   cout << "       Multiplicity    = " << fMulDigit  << endl ;
282   cout << "       Stored at position " << fIndexInList << endl ; 
283 }
284
285