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 ---
30 // --- AliRoot header files ---
32 #include "AliPHOSGeometry.h"
33 #include "AliPHOSDigit.h"
34 #include "AliPHOSRecPoint.h"
35 #include "AliPHOSGetter.h"
37 ClassImp(AliPHOSRecPoint)
40 //____________________________________________________________________________
41 AliPHOSRecPoint::AliPHOSRecPoint()
51 //____________________________________________________________________________
52 AliPHOSRecPoint::AliPHOSRecPoint(const char * opt) : AliRecPoint(opt)
61 //____________________________________________________________________________
62 Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
64 // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker
65 // Compute the closest distance of approach from point px,py to this marker.
66 // The distance is computed in pixels units.
68 TVector3 pos(0.,0.,0.) ;
69 GetLocalPosition( pos) ;
72 const Int_t kMaxDiff = 10;
73 Int_t pxm = gPad->XtoAbsPixel(x);
74 Int_t pym = gPad->YtoAbsPixel(y);
75 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
77 if (dist > kMaxDiff) return 9999;
81 //___________________________________________________________________________
82 void AliPHOSRecPoint::Draw(Option_t *option)
84 // Draw this AliPHOSRecPoint with its current attributes
89 //______________________________________________________________________________
90 void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
92 // Execute action corresponding to one event
93 // This member function is called when a AliPHOSRecPoint is clicked with the locator
95 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
96 // and switched off when the mouse button is released.
98 // static Int_t pxold, pyold;
100 static TGraph * digitgraph = 0 ;
101 static TPaveText* clustertext = 0 ;
103 if (!gPad->IsEditable()) return;
109 AliPHOSDigit * digit ;
110 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
111 AliPHOSGeometry * phosgeom = const_cast<AliPHOSGeometry*>(gime->PHOSGeometry());
116 const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
117 Float_t * xi = new Float_t [kMulDigit] ;
118 Float_t * zi = new Float_t [kMulDigit] ;
120 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
121 Fatal("AliPHOSRecPoint::ExecuteEvent", "-> Something wrong with the code");
122 digit = 0 ; //dynamic_cast<AliPHOSDigit *>((fDigitsList)[iDigit]);
123 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
124 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
128 digitgraph = new TGraph(fMulDigit,xi,zi);
129 digitgraph-> SetMarkerStyle(5) ;
130 digitgraph-> SetMarkerSize(1.) ;
131 digitgraph-> SetMarkerColor(1) ;
132 digitgraph-> Draw("P") ;
136 TVector3 pos(0.,0.,0.) ;
137 GetLocalPosition(pos) ;
138 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
141 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
142 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
143 clustertext ->AddText(line1) ;
144 clustertext ->AddText(line2) ;
145 clustertext ->Draw("");
169 //____________________________________________________________________________
170 void AliPHOSRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits) {
171 //evaluates (if necessary) all RecPoint data members
173 EvalPrimaries(digits) ;
175 //____________________________________________________________________________
176 void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit)
178 // Returns the PHOS module in which the RecPoint is found
183 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
184 AliPHOSGeometry * phosgeom = const_cast<AliPHOSGeometry*>(gime->PHOSGeometry());
186 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
191 //______________________________________________________________________________
192 void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits)
194 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
196 AliPHOSDigit * digit ;
197 Int_t * tempo = new Int_t[fMaxTrack] ;
200 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
201 digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ;
202 Int_t nprimaries = digit->GetNprimary() ;
204 Int_t * newprimaryarray = new Int_t[nprimaries] ;
206 for ( ii = 0 ; ii < nprimaries ; ii++)
207 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
210 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
211 if ( fMulTrack > fMaxTrack ) {
213 cout << "AliPHOSRecPoint::GetNprimaries ERROR > increase fMaxTrack " << endl ;
216 Int_t newprimary = newprimaryarray[jndex] ;
218 Bool_t already = kFALSE ;
219 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
220 if ( newprimary == tempo[kndex] ){
225 if ( !already) { // store it
226 tempo[fMulTrack] = newprimary ;
229 } // all primaries in digit
230 delete [] newprimaryarray ;
235 fTracksList = new Int_t[fMulTrack] ;
236 for(index = 0; index < fMulTrack; index++)
237 fTracksList[index] = tempo[index] ;
242 //____________________________________________________________________________
243 void AliPHOSRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrix & gmat) const
245 // returns the position of the cluster in the global reference system of ALICE
246 // and the uncertainty on this position
249 AliPHOSGetter::GetInstance()->PHOSGeometry()->GetGlobal(this, gpos, gmat) ;
254 //______________________________________________________________________________
255 void AliPHOSRecPoint::Paint(Option_t *)
257 // Paint this ALiRecPoint as a TMarker with its current attributes
259 TVector3 pos(0.,0.,0.) ;
260 GetLocalPosition(pos) ;
261 Coord_t x = pos.X() ;
262 Coord_t y = pos.Z() ;
263 Color_t markercolor = 1 ;
264 Size_t markersize = 1. ;
265 Style_t markerstyle = 5 ;
267 if (!gPad->IsBatch()) {
268 gVirtualX->SetMarkerColor(markercolor) ;
269 gVirtualX->SetMarkerSize (markersize) ;
270 gVirtualX->SetMarkerStyle(markerstyle) ;
272 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
273 gPad->PaintPolyMarker(1,&x,&y,"") ;