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: Gines Martinez (SUBATECH)
23 // --- ROOT system ---
25 #include "TClonesArray.h"
27 // --- Standard library ---
30 // --- AliRoot header files ---
32 #include "AliEMCALGeometry.h"
33 #include "AliEMCALDigit.h"
34 #include "AliEMCALRecPoint.h"
35 #include "AliEMCALGetter.h"
37 ClassImp(AliEMCALRecPoint)
40 //____________________________________________________________________________
41 AliEMCALRecPoint::AliEMCALRecPoint()
52 //____________________________________________________________________________
53 AliEMCALRecPoint::AliEMCALRecPoint(const char * opt) : AliRecPoint(opt)
63 //____________________________________________________________________________
64 Int_t AliEMCALRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
66 // Compute distance from point px,py to a AliEMCALRecPoint considered as a Tmarker
67 // Compute the closest distance of approach from point px,py to this marker.
68 // The distance is computed in pixels units.
70 TVector3 pos(0.,0.,0.) ;
71 GetLocalPosition( pos) ;
74 const Int_t kMaxDiff = 10;
75 Int_t pxm = gPad->XtoAbsPixel(x);
76 Int_t pym = gPad->YtoAbsPixel(y);
77 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
79 if (dist > kMaxDiff) return 9999;
83 //___________________________________________________________________________
84 void AliEMCALRecPoint::Draw(Option_t *option)
86 // Draw this AliEMCALRecPoint with its current attributes
91 //______________________________________________________________________________
92 void AliEMCALRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
94 // Execute action corresponding to one event
95 // This member function is called when a AliEMCALRecPoint is clicked with the locator
97 // If Left button is clicked on AliEMCALRecPoint, the digits are switched on
98 // and switched off when the mouse button is released.
100 // static Int_t pxold, pyold;
102 static TGraph * digitgraph = 0 ;
103 static TPaveText* clustertext = 0 ;
105 if (!gPad->IsEditable()) return;
111 AliEMCALDigit * digit ;
112 AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
113 AliEMCALGeometry * emcalgeom = const_cast<AliEMCALGeometry*>(gime->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) {
173 //evaluates (if necessary) all RecPoint data members
175 EvalPrimaries(digits) ;
178 //____________________________________________________________________________
179 void AliEMCALRecPoint::EvalEMCALArm(AliEMCALDigit * digit)
181 // Returns the EMCAL module in which the RecPoint is found
187 AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
188 AliEMCALGeometry * emcalgeom = const_cast<AliEMCALGeometry*>(gime->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::GetInstance()->EMCALGeometry();
253 gpos.SetY(emcalgeom->GetIP2Tower()) ;
255 gpos.SetY(emcalgeom->GetIP2PreShower()) ;
260 //______________________________________________________________________________
261 void AliEMCALRecPoint::Paint(Option_t *)
263 // Paint this ALiRecPoint as a TMarker with its current attributes
265 TVector3 pos(0.,0.,0.) ;
266 GetLocalPosition(pos) ;
267 Coord_t x = pos.X() ;
268 Coord_t y = pos.Z() ;
269 Color_t markercolor = 1 ;
270 Size_t markersize = 1. ;
271 Style_t markerstyle = 5 ;
273 if (!gPad->IsBatch()) {
274 gVirtualX->SetMarkerColor(markercolor) ;
275 gVirtualX->SetMarkerSize (markersize) ;
276 gVirtualX->SetMarkerStyle(markerstyle) ;
278 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
279 gPad->PaintPolyMarker(1,&x,&y,"") ;