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