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 #include "TPaveText.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()
52 //____________________________________________________________________________
53 AliPHOSRecPoint::AliPHOSRecPoint(const char * opt) : AliRecPoint(opt)
62 //____________________________________________________________________________
63 AliPHOSRecPoint::AliPHOSRecPoint(const AliPHOSRecPoint & rp ) : AliRecPoint(rp)
67 fMaxTrack = rp.fMaxTrack;
68 fPHOSMod = rp.fPHOSMod;
72 //____________________________________________________________________________
73 Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
75 // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker
76 // Compute the closest distance of approach from point px,py to this marker.
77 // The distance is computed in pixels units.
79 TVector3 pos(0.,0.,0.) ;
80 GetLocalPosition( pos) ;
83 const Int_t kMaxDiff = 10;
84 Int_t pxm = gPad->XtoAbsPixel(x);
85 Int_t pym = gPad->YtoAbsPixel(y);
86 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
88 if (dist > kMaxDiff) return 9999;
92 //___________________________________________________________________________
93 void AliPHOSRecPoint::Draw(Option_t *option)
95 // Draw this AliPHOSRecPoint with its current attributes
100 //______________________________________________________________________________
101 void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const
103 // Execute action corresponding to one event
104 // This member function is called when a AliPHOSRecPoint is clicked with the locator
106 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
107 // and switched off when the mouse button is released.
109 // static Int_t pxold, pyold;
111 static TGraph * digitgraph = 0 ;
112 static TPaveText* clustertext = 0 ;
114 if (!gPad->IsEditable()) return;
120 AliPHOSDigit * digit ;
121 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
122 AliPHOSGeometry * phosgeom = const_cast<AliPHOSGeometry*>(gime->PHOSGeometry());
127 const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
128 Float_t * xi = new Float_t [kMulDigit] ;
129 Float_t * zi = new Float_t [kMulDigit] ;
131 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
132 Fatal("AliPHOSRecPoint::ExecuteEvent", "-> Something wrong with the code");
133 digit = 0 ; //dynamic_cast<AliPHOSDigit *>((fDigitsList)[iDigit]);
134 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
135 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
139 digitgraph = new TGraph(fMulDigit,xi,zi);
140 digitgraph-> SetMarkerStyle(5) ;
141 digitgraph-> SetMarkerSize(1.) ;
142 digitgraph-> SetMarkerColor(1) ;
143 digitgraph-> Draw("P") ;
147 TVector3 pos(0.,0.,0.) ;
148 GetLocalPosition(pos) ;
149 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
152 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
153 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
154 clustertext ->AddText(line1) ;
155 clustertext ->AddText(line2) ;
156 clustertext ->Draw("");
180 //____________________________________________________________________________
181 void AliPHOSRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits) {
182 //evaluates (if necessary) all RecPoint data members
184 EvalPrimaries(digits) ;
186 //____________________________________________________________________________
187 void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit)
189 // Returns the PHOS module in which the RecPoint is found
194 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
195 AliPHOSGeometry * phosgeom = const_cast<AliPHOSGeometry*>(gime->PHOSGeometry());
197 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
202 //______________________________________________________________________________
203 void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits)
205 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
206 // First in the list - primary, made strongest contribution to the center
209 AliPHOSDigit * digit ;
210 Int_t * tempo = new Int_t[fMaxTrack] ;
212 //Find digit in center
213 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance("IHEP","") ;
215 Error("EvalPrimaries","Can not instantiate PHOS geometry") ;
220 GetGlobalPosition(pos,mat) ;
224 geom->ImpactOnEmc(pos.Theta(),pos.Phi(),module,z,x);
226 geom->RelPosToAbsId(module,x,z,absId) ;
229 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
230 digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ;
231 if(digit->GetId() == absId){
232 fMulTrack = digit->GetNprimary() ;
233 for(Int_t ii = 0 ; ii < fMulTrack ; ii++)
234 tempo[ii] = digit->GetPrimary(ii+1) ;
238 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
239 digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ;
240 if(digit->GetId()!=absId){ //already done
241 Int_t nprimaries = digit->GetNprimary() ;
243 Int_t * newprimaryarray = new Int_t[nprimaries] ;
245 for ( ii = 0 ; ii < nprimaries ; ii++)
246 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
249 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
250 if ( fMulTrack > fMaxTrack ) {
252 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack" ) ;
255 Int_t newprimary = newprimaryarray[jndex] ;
257 Bool_t already = kFALSE ;
258 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
259 if ( newprimary == tempo[kndex] ){
264 if ( !already) { // store it
265 tempo[fMulTrack] = newprimary ;
268 } // all primaries in digit
269 delete [] newprimaryarray ;
275 fTracksList = new Int_t[fMulTrack] ;
276 for(index = 0; index < fMulTrack; index++)
277 fTracksList[index] = tempo[index] ;
282 //____________________________________________________________________________
283 void AliPHOSRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrix & gmat) const
285 // returns the position of the cluster in the global reference system of ALICE
286 // and the uncertainty on this position
289 AliPHOSGetter::GetInstance()->PHOSGeometry()->GetGlobal(this, gpos, gmat) ;
294 //______________________________________________________________________________
295 void AliPHOSRecPoint::Paint(Option_t *)
297 // Paint this ALiRecPoint as a TMarker with its current attributes
299 TVector3 pos(0.,0.,0.) ;
300 GetLocalPosition(pos) ;
301 Coord_t x = pos.X() ;
302 Coord_t y = pos.Z() ;
303 Color_t markercolor = 1 ;
304 Size_t markersize = 1. ;
305 Style_t markerstyle = 5 ;
307 if (!gPad->IsBatch()) {
308 gVirtualX->SetMarkerColor(markercolor) ;
309 gVirtualX->SetMarkerSize (markersize) ;
310 gVirtualX->SetMarkerStyle(markerstyle) ;
312 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
313 gPad->PaintPolyMarker(1,&x,&y,"") ;