]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSPpsdRecPoint.cxx
New classes: AliPHOSRecParticle, AliPHOSParticleGuesser, AliPHOSAnalyze
[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 //_________________________________________________________________________
17 // RecPoint in the PHOS PPSD: a list of AliPHOSDigit's
18 //*-- Author : Yves Schutz  SUBATECH 
19 //////////////////////////////////////////////////////////////////////////////
20
21 // --- ROOT system ---
22 #include "TPad.h"
23 // --- Standard library ---
24
25 #include <iostream>
26 #include <cassert>
27
28 // --- AliRoot header files ---
29
30 #include "AliPHOSGeometry.h"
31 #include "AliPHOSPpsdRecPoint.h"
32 #include "AliRun.h"
33
34 ClassImp(AliPHOSPpsdRecPoint)
35
36 //____________________________________________________________________________
37 AliPHOSPpsdRecPoint::AliPHOSPpsdRecPoint(void)
38
39   fMulDigit = 0 ;  
40   AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;  
41   fDelta = geom->GetCrystalSize(0) ; 
42   fLocPos.SetX(1000000.)  ;      //Local position should be evaluated
43 }
44
45 //____________________________________________________________________________
46 AliPHOSPpsdRecPoint::~AliPHOSPpsdRecPoint(void) // dtor
47
48   //dtor  
49 }
50
51 //____________________________________________________________________________
52 void AliPHOSPpsdRecPoint::AddDigit(AliDigitNew & digit, Float_t Energy)
53 {
54   // adds a digit to the digits list
55   // and accumulates the total amplitude and the multiplicity 
56   
57   
58   if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists 
59     fMaxDigit*=2 ; 
60     int * tempo = new ( int[fMaxDigit] ) ; 
61     Int_t index ; 
62     
63     for ( index = 0 ; index < fMulDigit ; index++ )
64       tempo[index] = fDigitsList[index] ;
65     
66     delete []  fDigitsList ; 
67     fDigitsList =  new ( int[fMaxDigit] ) ;
68    
69     for ( index = 0 ; index < fMulDigit ; index++ )
70       fDigitsList[index] = tempo[index] ;
71  
72     delete [] tempo ;
73   }
74
75   fDigitsList[fMulDigit++]  =  (int) &digit  ; 
76   fAmp += Energy ; 
77 }
78
79
80
81
82 //____________________________________________________________________________
83 Int_t AliPHOSPpsdRecPoint::Compare(TObject * obj)
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   if( fLocPos.X() < 1000000.) { //allready evaluated
160    LPos = fLocPos ;
161    return ;
162   }
163
164   Int_t relid[4] ;
165
166   Float_t x = 0. ;
167   Float_t z = 0. ;
168
169   AliPHOSGeometry * PHOSGeom = (AliPHOSGeometry *) fGeom ;
170   
171   AliPHOSDigit * digit ;
172   Int_t iDigit;
173
174   for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
175     digit = (AliPHOSDigit *) fDigitsList[iDigit]; 
176  
177     Float_t xi ;
178     Float_t zi ;
179     PHOSGeom->AbsToRelNumbering(digit->GetId(), relid) ;
180     PHOSGeom->RelPosInModule(relid, xi, zi);
181     x += xi ;
182     z += zi ;
183   }
184
185   x /= fMulDigit ;
186   z /= fMulDigit ;
187
188   fLocPos.SetX(x)  ;
189   fLocPos.SetY(0.) ;
190   fLocPos.SetZ(z)  ;
191
192   LPos = fLocPos ;
193
194 }
195
196 //____________________________________________________________________________
197 Bool_t AliPHOSPpsdRecPoint::GetUp() 
198 {
199   Int_t relid[4] ;
200   
201   AliPHOSGeometry * PHOSGeom = (AliPHOSGeometry *) fGeom ;
202   
203   AliPHOSDigit *digit = (AliPHOSDigit *)fDigitsList[0] ; 
204   
205   PHOSGeom->AbsToRelNumbering(digit->GetId(),relid);
206   Bool_t up ;
207
208   if((Int_t)TMath::Ceil((Float_t)relid[1]/
209                         (PHOSGeom->GetNumberOfModulesPhi()*PHOSGeom->GetNumberOfModulesZ())-0.0001 ) > 1) 
210     up = kFALSE ;
211   else  
212     up = kTRUE ;
213   
214   return up ;
215 }
216 //______________________________________________________________________________
217 void AliPHOSPpsdRecPoint::Paint(Option_t *)
218 {
219 //*-*-*-*-*-*-*-*-*-*-*Paint this ALiRecPoint as a TMarker  with its current attributes*-*-*-*-*-*-*
220 //*-*                  =============================================
221    TVector3 pos(0.,0.,0.) ;
222    GetLocalPosition(pos) ;
223    Coord_t x = pos.X() ;
224    Coord_t y = pos.Z() ;
225    Color_t MarkerColor = 1 ;
226    Size_t  MarkerSize = 1. ;
227    Style_t MarkerStyle = 2 ;
228    if (GetUp()) 
229      MarkerStyle = 3 ;
230
231    if (!gPad->IsBatch()) {
232      gVirtualX->SetMarkerColor(MarkerColor);
233      gVirtualX->SetMarkerSize (MarkerSize);
234      gVirtualX->SetMarkerStyle(MarkerStyle);
235    }
236    gPad->SetAttMarkerPS(MarkerColor,MarkerStyle,MarkerSize);
237    gPad->PaintPolyMarker(1,&x,&y,"");
238
239
240 }
241
242 //____________________________________________________________________________
243 void AliPHOSPpsdRecPoint::Print(Option_t * option) 
244 {
245   cout << "AliPHOSPpsdRecPoint: " << endl ;
246   
247   AliPHOSDigit * digit ; 
248   Int_t iDigit;
249   AliPHOSGeometry * PHOSGeom =  (AliPHOSGeometry *) fGeom ;
250
251   Float_t xi ;
252   Float_t zi ;
253   Int_t relid[4] ; 
254
255   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
256     digit = (AliPHOSDigit *) fDigitsList[iDigit];
257     PHOSGeom->AbsToRelNumbering(digit->GetId(), relid) ;
258     PHOSGeom->RelPosInModule(relid, xi, zi);
259     cout << " Id = " << digit->GetId() ;  
260     cout << "  Phos mod = " << relid[0] ;  
261     cout << "  PPSD mod = " << relid[1] ;  
262     cout << "  x = " << xi ;  
263     cout << "  z = " << zi ;  
264     cout << "   Energy = " << digit->GetAmp() << endl ;
265   }
266   cout << "       Multiplicity    = " << fMulDigit  << endl ;
267 }
268
269
270 // //____________________________________________________________________________
271 // AliPHOSPpsdRecPoint& AliPHOSPpsdRecPoint::operator = (AliPHOSPpsdRecPoint Clu)
272 // {
273 //  int* DL = Clu.GetDigitsList() ; 
274   
275 //   if(fDigitsList) 
276 //     delete fDigitsList ;
277
278 //   AliPHOSDigit * digit ;
279  
280 //   Int_t iDigit;
281
282 //   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
283 //     digit = (AliPHOSDigit *) DL[iDigit];
284 //     AddDigit(*digit) ;
285 //   }
286
287 //   fDelta = Clu.GetDelta() ; 
288 //   delete DL ; 
289
290 //   fAmp       = Clu.GetEnergy() ;
291 //   fGeom      = Clu.GetGeom() ;
292 //   TVector3 LocPos;
293 //   Clu.GetLocalPosition(LocPos) ;
294 //   fLocPos    = LocPos;
295 //   fMulDigit  = Clu.GetMultiplicity() ;
296 //   fMaxDigit  = Clu.GetMaximumMultiplicity() ;
297 //   fPHOSMod   = Clu.GetPHOSMod() ;
298   
299
300 //   return *this ;
301 // }