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()
52 //____________________________________________________________________________
53 AliPHOSRecPoint::AliPHOSRecPoint(const char * opt) : AliRecPoint(opt)
62 //____________________________________________________________________________
63 Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
65 // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker
66 // Compute the closest distance of approach from point px,py to this marker.
67 // The distance is computed in pixels units.
69 TVector3 pos(0.,0.,0.) ;
70 GetLocalPosition( pos) ;
73 const Int_t kMaxDiff = 10;
74 Int_t pxm = gPad->XtoAbsPixel(x);
75 Int_t pym = gPad->YtoAbsPixel(y);
76 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
78 if (dist > kMaxDiff) return 9999;
82 //___________________________________________________________________________
83 void AliPHOSRecPoint::Draw(Option_t *option)
85 // Draw this AliPHOSRecPoint with its current attributes
90 //______________________________________________________________________________
91 void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t)
93 // Execute action corresponding to one event
94 // This member function is called when a AliPHOSRecPoint is clicked with the locator
96 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
97 // and switched off when the mouse button is released.
99 // static Int_t pxold, pyold;
101 static TGraph * digitgraph = 0 ;
102 static TPaveText* clustertext = 0 ;
104 if (!gPad->IsEditable()) return;
110 AliPHOSDigit * digit ;
112 // Accessing geometry this way is equivalent to getting from gAlice
113 // to have Detector in Folder one have to load gAlice anyway
114 // AliPHOSLoader * gime = AliPHOSLoader::GetInstance();
115 // AliPHOSGeometry * phosgeom = const_cast<AliPHOSGeometry*>(gime->PHOSGeometry());
117 AliPHOSGeometry * phosgeom = AliPHOSLoader::GetPHOSGeometry();
122 const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
123 Float_t * xi = new Float_t [kMulDigit] ;
124 Float_t * zi = new Float_t [kMulDigit] ;
126 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
127 Fatal("AliPHOSRecPoint::ExecuteEvent", "-> Something wrong with the code");
128 digit = 0 ; //dynamic_cast<AliPHOSDigit *>((fDigitsList)[iDigit]);
129 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
130 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
134 digitgraph = new TGraph(fMulDigit,xi,zi);
135 digitgraph-> SetMarkerStyle(5) ;
136 digitgraph-> SetMarkerSize(1.) ;
137 digitgraph-> SetMarkerColor(1) ;
138 digitgraph-> Draw("P") ;
142 TVector3 pos(0.,0.,0.) ;
143 GetLocalPosition(pos) ;
144 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
147 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
148 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
149 clustertext ->AddText(line1) ;
150 clustertext ->AddText(line2) ;
151 clustertext ->Draw("");
175 //____________________________________________________________________________
176 void AliPHOSRecPoint::EvalAll(TClonesArray * digits)
178 //evaluates (if necessary) all RecPoint data members
180 EvalPrimaries(digits) ;
183 //____________________________________________________________________________
184 void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit)
186 // Returns the PHOS module in which the RecPoint is found
191 AliPHOSGeometry * phosgeom = (AliPHOSGetter::Instance())->PHOSGeometry();
193 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
198 //______________________________________________________________________________
199 void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits)
201 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
203 AliPHOSDigit * digit ;
204 Int_t * tempo = new Int_t[fMaxTrack] ;
207 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
208 digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ;
209 Int_t nprimaries = digit->GetNprimary() ;
211 Int_t * newprimaryarray = new Int_t[nprimaries] ;
213 for ( ii = 0 ; ii < nprimaries ; ii++)
214 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
217 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
218 if ( fMulTrack > fMaxTrack ) {
220 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack" ) ;
223 Int_t newprimary = newprimaryarray[jndex] ;
225 Bool_t already = kFALSE ;
226 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
227 if ( newprimary == tempo[kndex] ){
232 if ( !already) { // store it
233 tempo[fMulTrack] = newprimary ;
236 } // all primaries in digit
237 delete [] newprimaryarray ;
242 fTracksList = new Int_t[fMulTrack] ;
243 for(index = 0; index < fMulTrack; index++)
244 fTracksList[index] = tempo[index] ;
249 //____________________________________________________________________________
250 void AliPHOSRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrix & gmat) const
252 // returns the position of the cluster in the global reference system of ALICE
253 // and the uncertainty on this position
254 (AliPHOSGetter::Instance())->PHOSGeometry()->GetGlobal(this, gpos, gmat);
258 //______________________________________________________________________________
259 void AliPHOSRecPoint::Paint(Option_t *)
261 // Paint this ALiRecPoint as a TMarker with its current attributes
263 TVector3 pos(0.,0.,0.) ;
264 GetLocalPosition(pos) ;
265 Coord_t x = pos.X() ;
266 Coord_t y = pos.Z() ;
267 Color_t markercolor = 1 ;
268 Size_t markersize = 1. ;
269 Style_t markerstyle = 5 ;
271 if (!gPad->IsBatch()) {
272 gVirtualX->SetMarkerColor(markercolor) ;
273 gVirtualX->SetMarkerSize (markersize) ;
274 gVirtualX->SetMarkerStyle(markerstyle) ;
276 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
277 gPad->PaintPolyMarker(1,&x,&y,"") ;
279 //______________________________________________________________________________