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 // Base Class for PHOS Reconstructed Points
21 //*-- Author: Gines Martinez (SUBATECH)
23 // --- ROOT system ---
26 // --- Standard library ---
30 // --- AliRoot header files ---
32 #include "AliPHOSGeometry.h"
33 #include "AliPHOSDigit.h"
34 #include "AliPHOSRecPoint.h"
35 #include "AliPHOSIndexToObject.h"
37 ClassImp(AliPHOSRecPoint)
40 //____________________________________________________________________________
41 AliPHOSRecPoint::AliPHOSRecPoint()
46 fGeom = AliPHOSGeometry::GetInstance() ;
50 //____________________________________________________________________________
51 Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
53 // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker
54 // Compute the closest distance of approach from point px,py to this marker.
55 // The distance is computed in pixels units.
57 TVector3 pos(0.,0.,0.) ;
58 GetLocalPosition( pos) ;
61 const Int_t kMaxDiff = 10;
62 Int_t pxm = gPad->XtoAbsPixel(x);
63 Int_t pym = gPad->YtoAbsPixel(y);
64 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
66 if (dist > kMaxDiff) return 9999;
70 //___________________________________________________________________________
71 void AliPHOSRecPoint::Draw(Option_t *option)
73 // Draw this AliPHOSRecPoint with its current attributes
78 //______________________________________________________________________________
79 void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
81 // Execute action corresponding to one event
82 // This member function is called when a AliPHOSRecPoint is clicked with the locator
84 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
85 // and switched off when the mouse button is released.
87 // static Int_t pxold, pyold;
89 static TGraph * digitgraph = 0 ;
90 static TPaveText* clustertext = 0 ;
92 if (!gPad->IsEditable()) return;
98 AliPHOSDigit * digit ;
99 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
103 const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
104 Float_t * xi = new Float_t [kMulDigit] ;
105 Float_t * zi = new Float_t [kMulDigit] ;
107 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
108 digit = (AliPHOSDigit *) fDigitsList[iDigit];
109 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
110 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
114 digitgraph = new TGraph(fMulDigit,xi,zi);
115 digitgraph-> SetMarkerStyle(5) ;
116 digitgraph-> SetMarkerSize(1.) ;
117 digitgraph-> SetMarkerColor(1) ;
118 digitgraph-> Draw("P") ;
122 TVector3 pos(0.,0.,0.) ;
123 GetLocalPosition(pos) ;
124 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
127 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
128 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
129 clustertext ->AddText(line1) ;
130 clustertext ->AddText(line2) ;
131 clustertext ->Draw("");
156 //____________________________________________________________________________
157 Int_t AliPHOSRecPoint::GetPHOSMod()
159 // Returns the PHOS module in which the RecPoint is found
164 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
169 AliPHOSDigit * digit ;
170 digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[0]) ) ;
171 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
173 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
175 if (fPHOSMod<0 || fPHOSMod>phosgeom->GetNModules() ) {
176 cout << "Wrong PHOS module number is found: " << fPHOSMod << endl;
182 //______________________________________________________________________________
183 Int_t * AliPHOSRecPoint::GetPrimaries(Int_t & number)
185 // Constructs the list of primary particles which have contributed to this RecPoint
187 AliPHOSDigit * digit ;
189 Int_t maxcounter = 10 ;
191 Int_t * tempo = new Int_t[maxcounter] ;
192 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
194 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
195 digit = please->GimeDigit( fDigitsList[index] ) ;
196 Int_t nprimaries = digit->GetNprimary() ;
197 Int_t * newprimaryarray = new Int_t[nprimaries] ;
199 for ( ii = 0 ; ii < nprimaries ; ii++)
200 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
202 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
203 if ( counter > maxcounter ) {
205 cout << "AliPHOSRecPoint::GetNprimaries ERROR > increase maxcounter " << endl ;
208 Int_t newprimary = newprimaryarray[jndex] ;
210 Bool_t already = kFALSE ;
211 for ( kndex = 0 ; kndex < counter ; kndex++ ) { //check if not already stored
212 if ( newprimary == tempo[kndex] ){
217 if ( !already) { // store it
218 tempo[counter] = newprimary ;
221 } // all primaries in digit
222 delete newprimaryarray ;
229 //______________________________________________________________________________
230 void AliPHOSRecPoint::Paint(Option_t *)
232 // Paint this ALiRecPoint as a TMarker with its current attributes
234 TVector3 pos(0.,0.,0.) ;
235 GetLocalPosition(pos) ;
236 Coord_t x = pos.X() ;
237 Coord_t y = pos.Z() ;
238 Color_t markercolor = 1 ;
239 Size_t markersize = 1. ;
240 Style_t markerstyle = 5 ;
242 if (!gPad->IsBatch()) {
243 gVirtualX->SetMarkerColor(markercolor) ;
244 gVirtualX->SetMarkerSize (markersize) ;
245 gVirtualX->SetMarkerStyle(markerstyle) ;
247 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
248 gPad->PaintPolyMarker(1,&x,&y,"") ;