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 ---
26 #include "TPaveText.h"
27 #include "TClonesArray.h"
29 // --- 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()
43 : AliCluster(),fPHOSMod(0),
44 fMulTrack(0),fMaxDigit(100),fMulDigit(0),fMaxTrack(0),
45 fDigitsList(0),fTracksList(0),fAmp(0),
46 fIndexInList(-1), // to be set when the point is already stored
47 fLocPos(0,0,0),fLocPosM(0)
53 //____________________________________________________________________________
54 AliPHOSRecPoint::AliPHOSRecPoint(const char * )
55 : AliCluster(),fPHOSMod(0),
56 fMulTrack(0),fMaxDigit(100),fMulDigit(0),fMaxTrack(200),
57 fDigitsList(new int[fMaxDigit]),fTracksList(new int[fMaxTrack]),fAmp(0),
58 fIndexInList(-1), // to be set when the point is already stored
59 fLocPos(0,0,0),fLocPosM(new TMatrixF(3,3))
65 //_______________________________________________________________________
66 AliPHOSRecPoint::~AliPHOSRecPoint()
71 delete [] fDigitsList ;
72 delete [] fTracksList ;
75 //____________________________________________________________________________
76 AliPHOSRecPoint::AliPHOSRecPoint(const AliPHOSRecPoint &rp) :
78 fPHOSMod(rp.fPHOSMod),fMulTrack(rp.fMulTrack),fMaxDigit(rp.fMaxDigit),
79 fMulDigit(rp.fMulDigit),fMaxTrack(rp.fMaxTrack),fDigitsList(new int[rp.fMaxDigit]),
80 fTracksList(new int[rp.fMaxTrack]),fAmp(rp.fAmp),fIndexInList(rp.fIndexInList),
81 fLocPos(rp.fLocPos),fLocPosM(rp.fLocPosM)
85 for(Int_t i=0; i<fMaxDigit; i++)
86 fDigitsList[i] = rp.fDigitsList[i];
88 for(Int_t i=0; i<fMaxTrack; i++)
89 fTracksList[i] = rp.fTracksList[i];
92 //____________________________________________________________________________
93 AliPHOSRecPoint& AliPHOSRecPoint::operator= (const AliPHOSRecPoint &rp)
95 if(&rp == this) return *this;
97 fPHOSMod = rp.fPHOSMod;
98 fMulTrack = rp.fMulTrack;
99 fMaxDigit = rp.fMaxDigit;
100 fMulDigit = rp.fMulDigit;
101 fMaxTrack = rp.fMaxTrack;
103 fIndexInList = rp.fIndexInList;
104 fLocPos = rp.fLocPos;
105 fLocPosM = rp.fLocPosM;
107 for(Int_t i=0; i<fMaxDigit; i++)
108 fDigitsList[i] = rp.fDigitsList[i];
110 for(Int_t i=0; i<fMaxTrack; i++)
111 fTracksList[i] = rp.fTracksList[i];
115 //____________________________________________________________________________
116 Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
118 // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker
119 // Compute the closest distance of approach from point px,py to this marker.
120 // The distance is computed in pixels units.
122 TVector3 pos(0.,0.,0.) ;
123 GetLocalPosition( pos) ;
124 Float_t x = pos.X() ;
125 Float_t y = pos.Z() ;
126 const Int_t kMaxDiff = 10;
127 Int_t pxm = gPad->XtoAbsPixel(x);
128 Int_t pym = gPad->YtoAbsPixel(y);
129 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
131 if (dist > kMaxDiff) return 9999;
135 //___________________________________________________________________________
136 void AliPHOSRecPoint::Draw(Option_t *option)
138 // Draw this AliPHOSRecPoint with its current attributes
143 //______________________________________________________________________________
144 void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t)
146 // Execute action corresponding to one event
147 // This member function is called when a AliPHOSRecPoint is clicked with the locator
149 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
150 // and switched off when the mouse button is released.
152 // static Int_t pxold, pyold;
154 static TGraph * digitgraph = 0 ;
155 static TPaveText* clustertext = 0 ;
157 if (!gPad->IsEditable()) return;
163 AliPHOSDigit * digit ;
165 // Accessing geometry this way is equivalent to getting from gAlice
166 // to have Detector in Folder one have to load gAlice anyway
167 // AliPHOSLoader * gime = AliPHOSLoader::GetInstance();
168 // AliPHOSGeometry * phosgeom = const_cast<AliPHOSGeometry*>(gime->PHOSGeometry());
170 AliPHOSGeometry * phosgeom = AliPHOSLoader::GetPHOSGeometry();
175 const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
176 Float_t * xi = new Float_t [kMulDigit] ;
177 Float_t * zi = new Float_t [kMulDigit] ;
179 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
180 Fatal("AliPHOSRecPoint::ExecuteEvent", "-> Something wrong with the code");
181 digit = 0 ; //dynamic_cast<AliPHOSDigit *>((fDigitsList)[iDigit]);
182 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
183 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
187 digitgraph = new TGraph(fMulDigit,xi,zi);
188 digitgraph-> SetMarkerStyle(5) ;
189 digitgraph-> SetMarkerSize(1.) ;
190 digitgraph-> SetMarkerColor(1) ;
191 digitgraph-> Draw("P") ;
195 TVector3 pos(0.,0.,0.) ;
196 GetLocalPosition(pos) ;
197 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
200 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
201 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
202 clustertext ->AddText(line1) ;
203 clustertext ->AddText(line2) ;
204 clustertext ->Draw("");
228 //____________________________________________________________________________
229 void AliPHOSRecPoint::EvalAll(TClonesArray * digits)
231 //evaluates (if necessary) all RecPoint data members
233 EvalPrimaries(digits) ;
236 //____________________________________________________________________________
237 void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit)
239 // Returns the PHOS module in which the RecPoint is found
244 AliPHOSGeometry * phosgeom = (AliPHOSGetter::Instance())->PHOSGeometry();
246 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
251 //______________________________________________________________________________
252 void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits)
254 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
256 AliPHOSDigit * digit ;
257 Int_t * tempo = new Int_t[fMaxTrack] ;
260 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
261 digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ;
262 Int_t nprimaries = digit->GetNprimary() ;
264 Int_t * newprimaryarray = new Int_t[nprimaries] ;
266 for ( ii = 0 ; ii < nprimaries ; ii++)
267 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
270 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
271 if ( fMulTrack > fMaxTrack ) {
273 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack" ) ;
276 Int_t newprimary = newprimaryarray[jndex] ;
278 Bool_t already = kFALSE ;
279 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
280 if ( newprimary == tempo[kndex] ){
285 if ( !already) { // store it
286 tempo[fMulTrack] = newprimary ;
289 } // all primaries in digit
290 delete [] newprimaryarray ;
295 fTracksList = new Int_t[fMulTrack] ;
296 for(index = 0; index < fMulTrack; index++)
297 fTracksList[index] = tempo[index] ;
302 //____________________________________________________________________________
303 void AliPHOSRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrixF & gmat) const
305 // returns the position of the cluster in the global reference system of ALICE
306 // and the uncertainty on this position
308 (AliPHOSGetter::Instance())->PHOSGeometry()->GetGlobalPHOS(this, gpos, gmat);
311 // GetGlobalXYZ(xyz);
312 // gpos.SetXYZ(xyz[0],xyz[1],xyz[2]);
318 //______________________________________________________________________________
319 void AliPHOSRecPoint::Paint(Option_t *)
321 // Paint this ALiRecPoint as a TMarker with its current attributes
323 TVector3 pos(0.,0.,0.) ;
324 GetLocalPosition(pos) ;
325 Coord_t x = pos.X() ;
326 Coord_t y = pos.Z() ;
327 Color_t markercolor = 1 ;
328 Size_t markersize = 1. ;
329 Style_t markerstyle = 5 ;
331 if (!gPad->IsBatch()) {
332 gVirtualX->SetMarkerColor(markercolor) ;
333 gVirtualX->SetMarkerSize (markersize) ;
334 gVirtualX->SetMarkerStyle(markerstyle) ;
336 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
337 gPad->PaintPolyMarker(1,&x,&y,"") ;
339 //______________________________________________________________________________
340 void AliPHOSRecPoint::GetLocalPosition(TVector3 & pos) const
342 // returns the position of the cluster in the local reference system
343 // of the sub-detector