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