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 **************************************************************************/
16 //_________________________________________________________________________
17 // Base Class for PHOS Reconstructed Points
18 // Why should I put meaningless comments
21 //*-- Author: Gines Martinez (SUBATECH)
23 // --- ROOT system ---
25 #include "TClonesArray.h"
27 // --- Standard library ---
31 // --- AliRoot header files ---
33 #include "AliPHOSGeometry.h"
34 #include "AliPHOSDigit.h"
35 #include "AliPHOSRecPoint.h"
36 #include "AliPHOSGetter.h"
38 ClassImp(AliPHOSRecPoint)
41 //____________________________________________________________________________
42 AliPHOSRecPoint::AliPHOSRecPoint()
52 //____________________________________________________________________________
53 Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
55 // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker
56 // Compute the closest distance of approach from point px,py to this marker.
57 // The distance is computed in pixels units.
59 TVector3 pos(0.,0.,0.) ;
60 GetLocalPosition( pos) ;
63 const Int_t kMaxDiff = 10;
64 Int_t pxm = gPad->XtoAbsPixel(x);
65 Int_t pym = gPad->YtoAbsPixel(y);
66 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
68 if (dist > kMaxDiff) return 9999;
72 //___________________________________________________________________________
73 void AliPHOSRecPoint::Draw(Option_t *option)
75 // Draw this AliPHOSRecPoint with its current attributes
80 //______________________________________________________________________________
81 void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
83 // Execute action corresponding to one event
84 // This member function is called when a AliPHOSRecPoint is clicked with the locator
86 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
87 // and switched off when the mouse button is released.
89 // static Int_t pxold, pyold;
91 static TGraph * digitgraph = 0 ;
92 static TPaveText* clustertext = 0 ;
94 if (!gPad->IsEditable()) return;
100 AliPHOSDigit * digit ;
101 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
102 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
107 const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
108 Float_t * xi = new Float_t [kMulDigit] ;
109 Float_t * zi = new Float_t [kMulDigit] ;
111 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
112 digit = (AliPHOSDigit *) fDigitsList[iDigit];
113 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
114 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
118 digitgraph = new TGraph(fMulDigit,xi,zi);
119 digitgraph-> SetMarkerStyle(5) ;
120 digitgraph-> SetMarkerSize(1.) ;
121 digitgraph-> SetMarkerColor(1) ;
122 digitgraph-> Draw("P") ;
126 TVector3 pos(0.,0.,0.) ;
127 GetLocalPosition(pos) ;
128 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
131 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
132 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
133 clustertext ->AddText(line1) ;
134 clustertext ->AddText(line2) ;
135 clustertext ->Draw("");
159 //____________________________________________________________________________
160 void AliPHOSRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits) {
161 //evaluates (if necessary) all RecPoint data members
163 EvalPrimaries(digits) ;
165 //____________________________________________________________________________
166 void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit)
168 // Returns the PHOS module in which the RecPoint is found
173 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
174 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
176 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
181 //______________________________________________________________________________
182 void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits)
184 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
186 AliPHOSDigit * digit ;
187 Int_t * tempo = new Int_t[fMaxTrack] ;
190 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
191 digit = (AliPHOSDigit *) digits->At( fDigitsList[index] ) ;
192 Int_t nprimaries = digit->GetNprimary() ;
193 Int_t * newprimaryarray = new Int_t[nprimaries] ;
195 for ( ii = 0 ; ii < nprimaries ; ii++)
196 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
199 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
200 if ( fMulTrack > fMaxTrack ) {
202 cout << "AliPHOSRecPoint::GetNprimaries ERROR > increase fMaxTrack " << endl ;
205 Int_t newprimary = newprimaryarray[jndex] ;
207 Bool_t already = kFALSE ;
208 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
209 if ( newprimary == tempo[kndex] ){
214 if ( !already) { // store it
215 tempo[fMulTrack] = newprimary ;
218 } // all primaries in digit
219 delete newprimaryarray ;
223 fTracksList = new Int_t[fMulTrack] ;
224 for(index = 0; index < fMulTrack; index++)
225 fTracksList[index] = tempo[index] ;
230 //____________________________________________________________________________
231 void AliPHOSRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrix & gmat) const
233 // returns the position of the cluster in the global reference system of ALICE
234 // and the uncertainty on this position
237 AliPHOSGetter::GetInstance()->PHOSGeometry()->GetGlobal(this, gpos, gmat) ;
242 //______________________________________________________________________________
243 void AliPHOSRecPoint::Paint(Option_t *)
245 // Paint this ALiRecPoint as a TMarker with its current attributes
247 TVector3 pos(0.,0.,0.) ;
248 GetLocalPosition(pos) ;
249 Coord_t x = pos.X() ;
250 Coord_t y = pos.Z() ;
251 Color_t markercolor = 1 ;
252 Size_t markersize = 1. ;
253 Style_t markerstyle = 5 ;
255 if (!gPad->IsBatch()) {
256 gVirtualX->SetMarkerColor(markercolor) ;
257 gVirtualX->SetMarkerSize (markersize) ;
258 gVirtualX->SetMarkerStyle(markerstyle) ;
260 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
261 gPad->PaintPolyMarker(1,&x,&y,"") ;