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 EMCAL Reconstructed Points
18 // Why should I put meaningless comments
21 //*-- Author: Yves Schutz (SUBATECH)
23 // --- ROOT system ---
26 #include "TPaveText.h"
27 #include "TClonesArray.h"
29 // --- Standard library ---
31 // --- AliRoot header files ---
33 #include "AliEMCALGeometry.h"
34 #include "AliEMCALDigit.h"
35 #include "AliEMCALRecPoint.h"
36 #include "AliEMCALGetter.h"
38 ClassImp(AliEMCALRecPoint)
41 //____________________________________________________________________________
42 AliEMCALRecPoint::AliEMCALRecPoint()
50 fECASection = kFALSE ;
53 //____________________________________________________________________________
54 AliEMCALRecPoint::AliEMCALRecPoint(const char * opt) : AliRecPoint(opt)
64 //____________________________________________________________________________
65 Int_t AliEMCALRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
67 // Compute distance from point px,py to a AliEMCALRecPoint considered as a Tmarker
68 // Compute the closest distance of approach from point px,py to this marker.
69 // The distance is computed in pixels units.
71 TVector3 pos(0.,0.,0.) ;
72 GetLocalPosition( pos) ;
75 const Int_t kMaxDiff = 10;
76 Int_t pxm = gPad->XtoAbsPixel(x);
77 Int_t pym = gPad->YtoAbsPixel(y);
78 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
80 if (dist > kMaxDiff) return 9999;
84 //___________________________________________________________________________
85 void AliEMCALRecPoint::Draw(Option_t *option)
87 // Draw this AliEMCALRecPoint with its current attributes
92 //______________________________________________________________________________
93 void AliEMCALRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t)
95 // Execute action corresponding to one event
96 // This member function is called when a AliEMCALRecPoint is clicked with the locator
98 // If Left button is clicked on AliEMCALRecPoint, the digits are switched on
99 // and switched off when the mouse button is released.
101 // static Int_t pxold, pyold;
103 static TGraph * digitgraph = 0 ;
104 static TPaveText* clustertext = 0 ;
106 if (!gPad->IsEditable()) return;
112 AliEMCALDigit * digit ;
113 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry() ;
118 const Int_t kMulDigit=AliEMCALRecPoint::GetDigitsMultiplicity() ;
119 Float_t * xi = new Float_t [kMulDigit] ;
120 Float_t * zi = new Float_t [kMulDigit] ;
122 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
123 Fatal("AliEMCALRecPoint::ExecuteEvent", " -> Something wrong with the code");
124 digit = 0 ; //dynamic_cast<AliEMCALDigit *>((fDigitsList)[iDigit]);
125 emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
126 emcalgeom->PosInAlice(relid, xi[iDigit], zi[iDigit]) ;
130 digitgraph = new TGraph(fMulDigit,xi,zi);
131 digitgraph-> SetMarkerStyle(5) ;
132 digitgraph-> SetMarkerSize(1.) ;
133 digitgraph-> SetMarkerColor(1) ;
134 digitgraph-> Draw("P") ;
138 TVector3 pos(0.,0.,0.) ;
139 GetLocalPosition(pos) ;
140 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
143 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
144 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
145 clustertext ->AddText(line1) ;
146 clustertext ->AddText(line2) ;
147 clustertext ->Draw("");
171 //____________________________________________________________________________
172 void AliEMCALRecPoint::EvalAll(Float_t /*logWeight*/,TClonesArray * digits)
174 //evaluates (if necessary) all RecPoint data members
176 EvalPrimaries(digits) ;
179 //____________________________________________________________________________
180 void AliEMCALRecPoint::EvalEMCALArm(AliEMCALDigit * digit)
182 // Returns the EMCAL module in which the RecPoint is found
188 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
190 emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
191 fEMCALArm = relid[0];
195 //______________________________________________________________________________
196 void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits)
198 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
200 AliEMCALDigit * digit ;
201 Int_t * tempo = new Int_t[fMaxTrack] ;
204 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
205 digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
206 Int_t nprimaries = digit->GetNprimary() ;
207 Int_t * newprimaryarray = new Int_t[nprimaries] ;
209 for ( ii = 0 ; ii < nprimaries ; ii++)
210 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
213 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
214 if ( fMulTrack > fMaxTrack ) {
216 Error("GetNprimaries", "increase fMaxTrack ") ;
219 Int_t newprimary = newprimaryarray[jndex] ;
221 Bool_t already = kFALSE ;
222 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
223 if ( newprimary == tempo[kndex] ){
228 if ( !already) { // store it
229 tempo[fMulTrack] = newprimary ;
232 } // all primaries in digit
233 delete newprimaryarray ;
237 fTracksList = new Int_t[fMulTrack] ;
238 for(index = 0; index < fMulTrack; index++)
239 fTracksList[index] = tempo[index] ;
245 //____________________________________________________________________________
246 void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos) const
248 // returns the position of the cluster in the global reference system of ALICE
250 AliEMCALGeometry * emcalgeom = AliEMCALGetter::Instance()->EMCALGeometry();
253 gpos.SetY(emcalgeom->GetIP2ECASection()) ;
255 Fatal("GetGlobalPosition", "Unexpected tower section") ;
259 //____________________________________________________________________________
260 void AliEMCALRecPoint::GetLocalPosition(TVector3 & lpos) const
262 // returns the position of the cluster in the global reference system of ALICE
264 lpos.SetX(fLocPos.X()) ;
265 lpos.SetY(fLocPos.Y()) ;
266 lpos.SetZ(fLocPos.Z()) ;
269 //______________________________________________________________________________
270 void AliEMCALRecPoint::Paint(Option_t *)
272 // Paint this ALiRecPoint as a TMarker with its current attributes
274 TVector3 pos(0.,0.,0.) ;
275 GetLocalPosition(pos) ;
276 Coord_t x = pos.X() ;
277 Coord_t y = pos.Z() ;
278 Color_t markercolor = 1 ;
279 Size_t markersize = 1. ;
280 Style_t markerstyle = 5 ;
282 if (!gPad->IsBatch()) {
283 gVirtualX->SetMarkerColor(markercolor) ;
284 gVirtualX->SetMarkerSize (markersize) ;
285 gVirtualX->SetMarkerStyle(markerstyle) ;
287 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
288 gPad->PaintPolyMarker(1,&x,&y,"") ;