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 ---
29 // --- AliRoot header files ---
31 #include "AliPHOSGeometry.h"
32 #include "AliPHOSDigit.h"
33 #include "AliPHOSRecPoint.h"
34 #include "AliPHOSGetter.h"
36 ClassImp(AliPHOSRecPoint)
39 //____________________________________________________________________________
40 AliPHOSRecPoint::AliPHOSRecPoint()
50 //____________________________________________________________________________
51 AliPHOSRecPoint::AliPHOSRecPoint(const char * opt) : AliRecPoint(opt)
60 //____________________________________________________________________________
61 Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
63 // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker
64 // Compute the closest distance of approach from point px,py to this marker.
65 // The distance is computed in pixels units.
67 TVector3 pos(0.,0.,0.) ;
68 GetLocalPosition( pos) ;
71 const Int_t kMaxDiff = 10;
72 Int_t pxm = gPad->XtoAbsPixel(x);
73 Int_t pym = gPad->YtoAbsPixel(y);
74 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
76 if (dist > kMaxDiff) return 9999;
80 //___________________________________________________________________________
81 void AliPHOSRecPoint::Draw(Option_t *option)
83 // Draw this AliPHOSRecPoint with its current attributes
88 //______________________________________________________________________________
89 void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
91 // Execute action corresponding to one event
92 // This member function is called when a AliPHOSRecPoint is clicked with the locator
94 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
95 // and switched off when the mouse button is released.
97 // static Int_t pxold, pyold;
99 static TGraph * digitgraph = 0 ;
100 static TPaveText* clustertext = 0 ;
102 if (!gPad->IsEditable()) return;
108 AliPHOSDigit * digit ;
110 // Accessing geometry this way is equivalent to getting from gAlice
111 // to have Detector in Folder one have to load gAlice anyway
112 // AliPHOSLoader * gime = AliPHOSLoader::GetInstance();
113 // AliPHOSGeometry * phosgeom = const_cast<AliPHOSGeometry*>(gime->PHOSGeometry());
115 AliPHOSGeometry * phosgeom = AliPHOSLoader::GetPHOSGeometry();
120 const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
121 Float_t * xi = new Float_t [kMulDigit] ;
122 Float_t * zi = new Float_t [kMulDigit] ;
124 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
125 Fatal("AliPHOSRecPoint::ExecuteEvent", "-> Something wrong with the code");
126 digit = 0 ; //dynamic_cast<AliPHOSDigit *>((fDigitsList)[iDigit]);
127 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
128 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
132 digitgraph = new TGraph(fMulDigit,xi,zi);
133 digitgraph-> SetMarkerStyle(5) ;
134 digitgraph-> SetMarkerSize(1.) ;
135 digitgraph-> SetMarkerColor(1) ;
136 digitgraph-> Draw("P") ;
140 TVector3 pos(0.,0.,0.) ;
141 GetLocalPosition(pos) ;
142 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
145 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
146 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
147 clustertext ->AddText(line1) ;
148 clustertext ->AddText(line2) ;
149 clustertext ->Draw("");
173 //____________________________________________________________________________
174 void AliPHOSRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits)
176 //evaluates (if necessary) all RecPoint data members
178 EvalPrimaries(digits) ;
181 //____________________________________________________________________________
182 void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit)
184 // Returns the PHOS module in which the RecPoint is found
189 AliPHOSGeometry * phosgeom = (AliPHOSGetter::Instance())->PHOSGeometry();
191 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
196 //______________________________________________________________________________
197 void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits)
199 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
201 AliPHOSDigit * digit ;
202 Int_t * tempo = new Int_t[fMaxTrack] ;
205 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
206 digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ;
207 Int_t nprimaries = digit->GetNprimary() ;
209 Int_t * newprimaryarray = new Int_t[nprimaries] ;
211 for ( ii = 0 ; ii < nprimaries ; ii++)
212 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
215 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
216 if ( fMulTrack > fMaxTrack ) {
218 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack" ) ;
221 Int_t newprimary = newprimaryarray[jndex] ;
223 Bool_t already = kFALSE ;
224 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
225 if ( newprimary == tempo[kndex] ){
230 if ( !already) { // store it
231 tempo[fMulTrack] = newprimary ;
234 } // all primaries in digit
235 delete [] newprimaryarray ;
240 fTracksList = new Int_t[fMulTrack] ;
241 for(index = 0; index < fMulTrack; index++)
242 fTracksList[index] = tempo[index] ;
247 //____________________________________________________________________________
248 void AliPHOSRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrix & gmat) const
250 // returns the position of the cluster in the global reference system of ALICE
251 // and the uncertainty on this position
252 (AliPHOSGetter::Instance())->PHOSGeometry()->GetGlobal(this, gpos, gmat);
256 //______________________________________________________________________________
257 void AliPHOSRecPoint::Paint(Option_t *)
259 // Paint this ALiRecPoint as a TMarker with its current attributes
261 TVector3 pos(0.,0.,0.) ;
262 GetLocalPosition(pos) ;
263 Coord_t x = pos.X() ;
264 Coord_t y = pos.Z() ;
265 Color_t markercolor = 1 ;
266 Size_t markersize = 1. ;
267 Style_t markerstyle = 5 ;
269 if (!gPad->IsBatch()) {
270 gVirtualX->SetMarkerColor(markercolor) ;
271 gVirtualX->SetMarkerSize (markersize) ;
272 gVirtualX->SetMarkerStyle(markerstyle) ;
274 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
275 gPad->PaintPolyMarker(1,&x,&y,"") ;
277 //______________________________________________________________________________