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