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 ---
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()
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 px, Int_t py)
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 AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
114 AliEMCALGeometry * emcalgeom = const_cast<AliEMCALGeometry*>(gime->EMCALGeometry());
119 const Int_t kMulDigit=AliEMCALRecPoint::GetDigitsMultiplicity() ;
120 Float_t * xi = new Float_t [kMulDigit] ;
121 Float_t * zi = new Float_t [kMulDigit] ;
123 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
124 Fatal("AliEMCALRecPoint::ExecuteEvent", " -> Something wrong with the code");
125 digit = 0 ; //dynamic_cast<AliEMCALDigit *>((fDigitsList)[iDigit]);
126 emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
127 emcalgeom->PosInAlice(relid, xi[iDigit], zi[iDigit]) ;
131 digitgraph = new TGraph(fMulDigit,xi,zi);
132 digitgraph-> SetMarkerStyle(5) ;
133 digitgraph-> SetMarkerSize(1.) ;
134 digitgraph-> SetMarkerColor(1) ;
135 digitgraph-> Draw("P") ;
139 TVector3 pos(0.,0.,0.) ;
140 GetLocalPosition(pos) ;
141 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
144 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
145 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
146 clustertext ->AddText(line1) ;
147 clustertext ->AddText(line2) ;
148 clustertext ->Draw("");
172 //____________________________________________________________________________
173 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 AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ;
189 AliEMCALGeometry * emcalgeom = const_cast<AliEMCALGeometry*>(gime->EMCALGeometry());
191 emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
192 fEMCALArm = relid[0];
196 //______________________________________________________________________________
197 void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits)
199 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
201 AliEMCALDigit * digit ;
202 Int_t * tempo = new Int_t[fMaxTrack] ;
205 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
206 digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
207 Int_t nprimaries = digit->GetNprimary() ;
208 Int_t * newprimaryarray = new Int_t[nprimaries] ;
210 for ( ii = 0 ; ii < nprimaries ; ii++)
211 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
214 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
215 if ( fMulTrack > fMaxTrack ) {
217 cout << "AliEMCALRecPoint::GetNprimaries ERROR > increase fMaxTrack " << endl ;
220 Int_t newprimary = newprimaryarray[jndex] ;
222 Bool_t already = kFALSE ;
223 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
224 if ( newprimary == tempo[kndex] ){
229 if ( !already) { // store it
230 tempo[fMulTrack] = newprimary ;
233 } // all primaries in digit
234 delete newprimaryarray ;
238 fTracksList = new Int_t[fMulTrack] ;
239 for(index = 0; index < fMulTrack; index++)
240 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
249 // and the uncertainty on this position
251 AliEMCALGeometry * emcalgeom = AliEMCALGetter::GetInstance()->EMCALGeometry();
253 gpos.SetY(emcalgeom->GetIPDistance() + emcalgeom->GetAirGap()) ;
259 //______________________________________________________________________________
260 void AliEMCALRecPoint::Paint(Option_t *)
262 // Paint this ALiRecPoint as a TMarker with its current attributes
264 TVector3 pos(0.,0.,0.) ;
265 GetLocalPosition(pos) ;
266 Coord_t x = pos.X() ;
267 Coord_t y = pos.Z() ;
268 Color_t markercolor = 1 ;
269 Size_t markersize = 1. ;
270 Style_t markerstyle = 5 ;
272 if (!gPad->IsBatch()) {
273 gVirtualX->SetMarkerColor(markercolor) ;
274 gVirtualX->SetMarkerSize (markersize) ;
275 gVirtualX->SetMarkerStyle(markerstyle) ;
277 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
278 gPad->PaintPolyMarker(1,&x,&y,"") ;