]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSRecPoint.cxx
cleanup
[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"
2731cd1e 25#include "TClonesArray.h"
d15a28e7 26
27// --- Standard library ---
de9ec31b 28#include <iostream.h>
29#include <stdio.h>
d15a28e7 30
31// --- AliRoot header files ---
32
33#include "AliPHOSGeometry.h"
34#include "AliPHOSDigit.h"
35#include "AliPHOSRecPoint.h"
9f616d61 36
d15a28e7 37ClassImp(AliPHOSRecPoint)
38
39
40//____________________________________________________________________________
41AliPHOSRecPoint::AliPHOSRecPoint()
42 : AliRecPoint()
43{
b2a60966 44 // ctor
45
b73f246d 46 fGeom = (AliPHOSGeometry*) AliPHOSGeometry::GetInstance() ;
2731cd1e 47 fMaxTrack = 20 ;
d15a28e7 48 fPHOSMod = 0;
49}
50
9f616d61 51//____________________________________________________________________________
52Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
53{
b2a60966 54 // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker
55 // Compute the closest distance of approach from point px,py to this marker.
56 // The distance is computed in pixels units.
57
58 TVector3 pos(0.,0.,0.) ;
59 GetLocalPosition( pos) ;
60 Float_t x = pos.X() ;
61 Float_t y = pos.Z() ;
62 const Int_t kMaxDiff = 10;
63 Int_t pxm = gPad->XtoAbsPixel(x);
64 Int_t pym = gPad->YtoAbsPixel(y);
65 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
66
67 if (dist > kMaxDiff) return 9999;
68 return dist;
9f616d61 69}
6ad0bfa0 70
9f616d61 71//___________________________________________________________________________
72 void AliPHOSRecPoint::Draw(Option_t *option)
73 {
6ad0bfa0 74 // Draw this AliPHOSRecPoint with its current attributes
75
76 AppendPad(option);
9f616d61 77 }
78
79//______________________________________________________________________________
80void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
81{
6ad0bfa0 82 // Execute action corresponding to one event
83 // This member function is called when a AliPHOSRecPoint is clicked with the locator
84 //
85 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
86 // and switched off when the mouse button is released.
9f616d61 87
88 // static Int_t pxold, pyold;
89
b2a60966 90 static TGraph * digitgraph = 0 ;
91 static TPaveText* clustertext = 0 ;
92
93 if (!gPad->IsEditable()) return;
9f616d61 94
b2a60966 95 switch (event) {
96
97
98 case kButton1Down:{
99 AliPHOSDigit * digit ;
100 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
101 Int_t iDigit;
102 Int_t relid[4] ;
31aa6d6c 103
88714635 104 const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
105 Float_t * xi = new Float_t [kMulDigit] ;
106 Float_t * zi = new Float_t [kMulDigit] ;
b2a60966 107
88714635 108 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
b2a60966 109 digit = (AliPHOSDigit *) fDigitsList[iDigit];
110 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
111 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
112 }
113
114 if (!digitgraph) {
115 digitgraph = new TGraph(fMulDigit,xi,zi);
116 digitgraph-> SetMarkerStyle(5) ;
117 digitgraph-> SetMarkerSize(1.) ;
118 digitgraph-> SetMarkerColor(1) ;
119 digitgraph-> Draw("P") ;
120 }
121 if (!clustertext) {
122
123 TVector3 pos(0.,0.,0.) ;
124 GetLocalPosition(pos) ;
125 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
126 Text_t line1[40] ;
127 Text_t line2[40] ;
128 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
129 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
130 clustertext ->AddText(line1) ;
131 clustertext ->AddText(line2) ;
132 clustertext ->Draw("");
133 }
134 gPad->Update() ;
135 Print() ;
31aa6d6c 136 delete[] xi ;
137 delete[] zi ;
138 }
b2a60966 139
31aa6d6c 140break;
b2a60966 141
142 case kButton1Up:
143 if (digitgraph) {
144 delete digitgraph ;
145 digitgraph = 0 ;
146 }
147 if (clustertext) {
148 delete clustertext ;
149 clustertext = 0 ;
150 }
151
152 break;
153
9f616d61 154 }
9f616d61 155}
ad8cfaf4 156//____________________________________________________________________________
2731cd1e 157void AliPHOSRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits) {
ad8cfaf4 158 //evaluates (if necessary) all RecPoint data members
9f616d61 159
2731cd1e 160 EvalPrimaries(digits) ;
ad8cfaf4 161}
d15a28e7 162//____________________________________________________________________________
2731cd1e 163void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit)
b2a60966 164{
165 // Returns the PHOS module in which the RecPoint is found
83974468 166
2731cd1e 167 if( fPHOSMod == 0){
ad8cfaf4 168 Int_t relid[4] ;
83974468 169
92862013 170 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
d15a28e7 171
92862013 172 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
d15a28e7 173 fPHOSMod = relid[0];
2731cd1e 174 }
d15a28e7 175}
6ad0bfa0 176
cf239357 177//______________________________________________________________________________
2731cd1e 178void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits)
cf239357 179{
2731cd1e 180 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
b2a60966 181
cf239357 182 AliPHOSDigit * digit ;
2731cd1e 183 Int_t * tempo = new Int_t[fMaxTrack] ;
184
185 Int_t index ;
cf239357 186 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
2731cd1e 187 digit = (AliPHOSDigit *) digits->At( fDigitsList[index] ) ;
cf239357 188 Int_t nprimaries = digit->GetNprimary() ;
26d4b141 189 Int_t * newprimaryarray = new Int_t[nprimaries] ;
190 Int_t ii ;
191 for ( ii = 0 ; ii < nprimaries ; ii++)
192 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
2731cd1e 193
cf239357 194 Int_t jndex ;
195 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
2731cd1e 196 if ( fMulTrack > fMaxTrack ) {
197 fMulTrack = - 1 ;
198 cout << "AliPHOSRecPoint::GetNprimaries ERROR > increase fMaxTrack " << endl ;
cf239357 199 break ;
200 }
201 Int_t newprimary = newprimaryarray[jndex] ;
cf239357 202 Int_t kndex ;
203 Bool_t already = kFALSE ;
2731cd1e 204 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
cf239357 205 if ( newprimary == tempo[kndex] ){
206 already = kTRUE ;
207 break ;
208 }
209 } // end of check
b2a60966 210 if ( !already) { // store it
2731cd1e 211 tempo[fMulTrack] = newprimary ;
212 fMulTrack++ ;
cf239357 213 } // store it
214 } // all primaries in digit
26d4b141 215 delete newprimaryarray ;
cf239357 216 } // all digits
217
2731cd1e 218
219 fTracksList = new Int_t[fMulTrack] ;
220 for(index = 0; index < fMulTrack; index++)
221 fTracksList[index] = tempo[index] ;
222
223 delete tempo ;
224
cf239357 225}
226
9f616d61 227//______________________________________________________________________________
228void AliPHOSRecPoint::Paint(Option_t *)
229{
b2a60966 230 // Paint this ALiRecPoint as a TMarker with its current attributes
231
232 TVector3 pos(0.,0.,0.) ;
233 GetLocalPosition(pos) ;
234 Coord_t x = pos.X() ;
235 Coord_t y = pos.Z() ;
236 Color_t markercolor = 1 ;
237 Size_t markersize = 1. ;
238 Style_t markerstyle = 5 ;
239
240 if (!gPad->IsBatch()) {
241 gVirtualX->SetMarkerColor(markercolor) ;
242 gVirtualX->SetMarkerSize (markersize) ;
243 gVirtualX->SetMarkerStyle(markerstyle) ;
244 }
245 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
246 gPad->PaintPolyMarker(1,&x,&y,"") ;
9f616d61 247}