]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSRecPoint.cxx
Removing warnings (icc), adding more detailed description
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRecPoint.cxx
CommitLineData
d15a28e7 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
b2a60966 15/* $Id$ */
d15a28e7 16//_________________________________________________________________________
b2a60966 17// Base Class for PHOS Reconstructed Points
2f04ed65 18// Why should I put meaningless comments
19// just to satisfy
20// the code checker
b2a60966 21//*-- Author: Gines Martinez (SUBATECH)
d15a28e7 22
23// --- ROOT system ---
9f616d61 24#include "TPad.h"
e957fea8 25#include "TGraph.h"
26#include "TPaveText.h"
2731cd1e 27#include "TClonesArray.h"
d15a28e7 28
29// --- Standard library ---
30
31// --- AliRoot header files ---
32
33#include "AliPHOSGeometry.h"
34#include "AliPHOSDigit.h"
35#include "AliPHOSRecPoint.h"
7b7c1533 36#include "AliPHOSGetter.h"
9f616d61 37
d15a28e7 38ClassImp(AliPHOSRecPoint)
39
40
41//____________________________________________________________________________
42AliPHOSRecPoint::AliPHOSRecPoint()
43 : AliRecPoint()
44{
b2a60966 45 // ctor
46
88cb7938 47 fMaxTrack = 0 ;
48 fPHOSMod = 0 ;
4b45b217 49
d15a28e7 50}
51
73a68ccb 52//____________________________________________________________________________
53AliPHOSRecPoint::AliPHOSRecPoint(const char * opt) : AliRecPoint(opt)
54{
55 // ctor
56
57 fMaxTrack = 200 ;
88cb7938 58 fPHOSMod = 0;
55fe9d13 59
60}
61
9f616d61 62//____________________________________________________________________________
63Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
64{
b2a60966 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.
68
69 TVector3 pos(0.,0.,0.) ;
70 GetLocalPosition( pos) ;
71 Float_t x = pos.X() ;
72 Float_t y = pos.Z() ;
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);
77
78 if (dist > kMaxDiff) return 9999;
79 return dist;
9f616d61 80}
6ad0bfa0 81
9f616d61 82//___________________________________________________________________________
83 void AliPHOSRecPoint::Draw(Option_t *option)
84 {
6ad0bfa0 85 // Draw this AliPHOSRecPoint with its current attributes
86
87 AppendPad(option);
9f616d61 88 }
89
90//______________________________________________________________________________
8f2a3661 91void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t)
9f616d61 92{
6ad0bfa0 93 // Execute action corresponding to one event
94 // This member function is called when a AliPHOSRecPoint is clicked with the locator
95 //
96 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
97 // and switched off when the mouse button is released.
9f616d61 98
99 // static Int_t pxold, pyold;
100
b2a60966 101 static TGraph * digitgraph = 0 ;
102 static TPaveText* clustertext = 0 ;
103
104 if (!gPad->IsEditable()) return;
9f616d61 105
b2a60966 106 switch (event) {
107
108
109 case kButton1Down:{
110 AliPHOSDigit * digit ;
88cb7938 111
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());
116
117 AliPHOSGeometry * phosgeom = AliPHOSLoader::GetPHOSGeometry();
7b7c1533 118
b2a60966 119 Int_t iDigit;
120 Int_t relid[4] ;
31aa6d6c 121
88714635 122 const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
123 Float_t * xi = new Float_t [kMulDigit] ;
124 Float_t * zi = new Float_t [kMulDigit] ;
b2a60966 125
88714635 126 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
4696e514 127 Fatal("AliPHOSRecPoint::ExecuteEvent", "-> Something wrong with the code");
7a9d98f9 128 digit = 0 ; //dynamic_cast<AliPHOSDigit *>((fDigitsList)[iDigit]);
b2a60966 129 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
130 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
131 }
132
133 if (!digitgraph) {
134 digitgraph = new TGraph(fMulDigit,xi,zi);
135 digitgraph-> SetMarkerStyle(5) ;
136 digitgraph-> SetMarkerSize(1.) ;
137 digitgraph-> SetMarkerColor(1) ;
138 digitgraph-> Draw("P") ;
139 }
140 if (!clustertext) {
141
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,"") ;
145 Text_t line1[40] ;
146 Text_t line2[40] ;
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("");
152 }
153 gPad->Update() ;
a8c47ab6 154 Print("dummy") ;
31aa6d6c 155 delete[] xi ;
156 delete[] zi ;
157 }
b2a60966 158
31aa6d6c 159break;
b2a60966 160
161 case kButton1Up:
162 if (digitgraph) {
163 delete digitgraph ;
164 digitgraph = 0 ;
165 }
166 if (clustertext) {
167 delete clustertext ;
168 clustertext = 0 ;
169 }
170
171 break;
172
9f616d61 173 }
9f616d61 174}
ad8cfaf4 175//____________________________________________________________________________
e957fea8 176void AliPHOSRecPoint::EvalAll(TClonesArray * digits)
88cb7938 177{
ad8cfaf4 178 //evaluates (if necessary) all RecPoint data members
9f616d61 179
2731cd1e 180 EvalPrimaries(digits) ;
ad8cfaf4 181}
88cb7938 182
d15a28e7 183//____________________________________________________________________________
2731cd1e 184void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit)
b2a60966 185{
186 // Returns the PHOS module in which the RecPoint is found
83974468 187
2731cd1e 188 if( fPHOSMod == 0){
ad8cfaf4 189 Int_t relid[4] ;
88cb7938 190
191 AliPHOSGeometry * phosgeom = (AliPHOSGetter::Instance())->PHOSGeometry();
d15a28e7 192
92862013 193 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
d15a28e7 194 fPHOSMod = relid[0];
2731cd1e 195 }
d15a28e7 196}
6ad0bfa0 197
cf239357 198//______________________________________________________________________________
2731cd1e 199void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits)
cf239357 200{
2731cd1e 201 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
b2a60966 202
cf239357 203 AliPHOSDigit * digit ;
2731cd1e 204 Int_t * tempo = new Int_t[fMaxTrack] ;
205
206 Int_t index ;
cf239357 207 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
7a9d98f9 208 digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ;
88cb7938 209 Int_t nprimaries = digit->GetNprimary() ;
210 if(nprimaries){
211 Int_t * newprimaryarray = new Int_t[nprimaries] ;
212 Int_t ii ;
213 for ( ii = 0 ; ii < nprimaries ; ii++)
214 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
215
216 Int_t jndex ;
217 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
218 if ( fMulTrack > fMaxTrack ) {
219 fMulTrack = - 1 ;
220 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack" ) ;
221 break ;
222 }
223 Int_t newprimary = newprimaryarray[jndex] ;
224 Int_t kndex ;
225 Bool_t already = kFALSE ;
226 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
227 if ( newprimary == tempo[kndex] ){
228 already = kTRUE ;
884e9693 229 break ;
230 }
88cb7938 231 } // end of check
232 if ( !already) { // store it
233 tempo[fMulTrack] = newprimary ;
234 fMulTrack++ ;
235 } // store it
236 } // all primaries in digit
237 delete [] newprimaryarray ;
884e9693 238 }
cf239357 239 } // all digits
240
884e9693 241 if(fMulTrack)
242 fTracksList = new Int_t[fMulTrack] ;
2731cd1e 243 for(index = 0; index < fMulTrack; index++)
884e9693 244 fTracksList[index] = tempo[index] ;
245
780a31c1 246 delete [] tempo ;
884e9693 247
cf239357 248}
4b45b217 249//____________________________________________________________________________
250void AliPHOSRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrix & gmat) const
251{
252 // returns the position of the cluster in the global reference system of ALICE
253 // and the uncertainty on this position
88cb7938 254 (AliPHOSGetter::Instance())->PHOSGeometry()->GetGlobal(this, gpos, gmat);
4b45b217 255}
256
cf239357 257
9f616d61 258//______________________________________________________________________________
259void AliPHOSRecPoint::Paint(Option_t *)
260{
b2a60966 261 // Paint this ALiRecPoint as a TMarker with its current attributes
262
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 ;
270
271 if (!gPad->IsBatch()) {
272 gVirtualX->SetMarkerColor(markercolor) ;
273 gVirtualX->SetMarkerSize (markersize) ;
274 gVirtualX->SetMarkerStyle(markerstyle) ;
275 }
276 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
277 gPad->PaintPolyMarker(1,&x,&y,"") ;
9f616d61 278}
88cb7938 279//______________________________________________________________________________
280