]>
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 | **************************************************************************/ | |
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" | |
7b7c1533 | 36 | #include "AliPHOSGetter.h" |
9f616d61 | 37 | |
d15a28e7 | 38 | ClassImp(AliPHOSRecPoint) |
39 | ||
40 | ||
41 | //____________________________________________________________________________ | |
42 | AliPHOSRecPoint::AliPHOSRecPoint() | |
43 | : AliRecPoint() | |
44 | { | |
b2a60966 | 45 | // ctor |
46 | ||
baef0810 | 47 | fMaxTrack = 200 ; |
d15a28e7 | 48 | fPHOSMod = 0; |
4b45b217 | 49 | |
d15a28e7 | 50 | } |
51 | ||
73a68ccb | 52 | //____________________________________________________________________________ |
53 | AliPHOSRecPoint::AliPHOSRecPoint(const char * opt) : AliRecPoint(opt) | |
54 | { | |
55 | // ctor | |
56 | ||
57 | fMaxTrack = 200 ; | |
58 | fPHOSMod = 0; | |
59 | ||
60 | } | |
61 | ||
9f616d61 | 62 | //____________________________________________________________________________ |
63 | Int_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 | //______________________________________________________________________________ | |
91 | void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) | |
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 ; | |
7b7c1533 | 111 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
7a9d98f9 | 112 | AliPHOSGeometry * phosgeom = const_cast<AliPHOSGeometry*>(gime->PHOSGeometry()); |
7b7c1533 | 113 | |
b2a60966 | 114 | Int_t iDigit; |
115 | Int_t relid[4] ; | |
31aa6d6c | 116 | |
88714635 | 117 | const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ; |
118 | Float_t * xi = new Float_t [kMulDigit] ; | |
119 | Float_t * zi = new Float_t [kMulDigit] ; | |
b2a60966 | 120 | |
88714635 | 121 | for(iDigit = 0; iDigit < kMulDigit; iDigit++) { |
7a9d98f9 | 122 | cout << " AliPHOSRecPoint::ExecuteEvent -> Something wromg with the code" << endl ; |
123 | abort() ; | |
124 | digit = 0 ; //dynamic_cast<AliPHOSDigit *>((fDigitsList)[iDigit]); | |
b2a60966 | 125 | phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; |
126 | phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ; | |
127 | } | |
128 | ||
129 | if (!digitgraph) { | |
130 | digitgraph = new TGraph(fMulDigit,xi,zi); | |
131 | digitgraph-> SetMarkerStyle(5) ; | |
132 | digitgraph-> SetMarkerSize(1.) ; | |
133 | digitgraph-> SetMarkerColor(1) ; | |
134 | digitgraph-> Draw("P") ; | |
135 | } | |
136 | if (!clustertext) { | |
137 | ||
138 | TVector3 pos(0.,0.,0.) ; | |
139 | GetLocalPosition(pos) ; | |
140 | clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ; | |
141 | Text_t line1[40] ; | |
142 | Text_t line2[40] ; | |
143 | sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ; | |
144 | sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ; | |
145 | clustertext ->AddText(line1) ; | |
146 | clustertext ->AddText(line2) ; | |
147 | clustertext ->Draw(""); | |
148 | } | |
149 | gPad->Update() ; | |
150 | Print() ; | |
31aa6d6c | 151 | delete[] xi ; |
152 | delete[] zi ; | |
153 | } | |
b2a60966 | 154 | |
31aa6d6c | 155 | break; |
b2a60966 | 156 | |
157 | case kButton1Up: | |
158 | if (digitgraph) { | |
159 | delete digitgraph ; | |
160 | digitgraph = 0 ; | |
161 | } | |
162 | if (clustertext) { | |
163 | delete clustertext ; | |
164 | clustertext = 0 ; | |
165 | } | |
166 | ||
167 | break; | |
168 | ||
9f616d61 | 169 | } |
9f616d61 | 170 | } |
ad8cfaf4 | 171 | //____________________________________________________________________________ |
2731cd1e | 172 | void AliPHOSRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits) { |
ad8cfaf4 | 173 | //evaluates (if necessary) all RecPoint data members |
9f616d61 | 174 | |
2731cd1e | 175 | EvalPrimaries(digits) ; |
ad8cfaf4 | 176 | } |
d15a28e7 | 177 | //____________________________________________________________________________ |
2731cd1e | 178 | void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit) |
b2a60966 | 179 | { |
180 | // Returns the PHOS module in which the RecPoint is found | |
83974468 | 181 | |
2731cd1e | 182 | if( fPHOSMod == 0){ |
ad8cfaf4 | 183 | Int_t relid[4] ; |
83974468 | 184 | |
7b7c1533 | 185 | AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; |
7a9d98f9 | 186 | AliPHOSGeometry * phosgeom = const_cast<AliPHOSGeometry*>(gime->PHOSGeometry()); |
d15a28e7 | 187 | |
92862013 | 188 | phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; |
d15a28e7 | 189 | fPHOSMod = relid[0]; |
2731cd1e | 190 | } |
d15a28e7 | 191 | } |
6ad0bfa0 | 192 | |
cf239357 | 193 | //______________________________________________________________________________ |
2731cd1e | 194 | void AliPHOSRecPoint::EvalPrimaries(TClonesArray * digits) |
cf239357 | 195 | { |
2731cd1e | 196 | // Constructs the list of primary particles (tracks) which have contributed to this RecPoint |
b2a60966 | 197 | |
cf239357 | 198 | AliPHOSDigit * digit ; |
2731cd1e | 199 | Int_t * tempo = new Int_t[fMaxTrack] ; |
200 | ||
201 | Int_t index ; | |
cf239357 | 202 | for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits |
7a9d98f9 | 203 | digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ; |
cf239357 | 204 | Int_t nprimaries = digit->GetNprimary() ; |
26d4b141 | 205 | Int_t * newprimaryarray = new Int_t[nprimaries] ; |
206 | Int_t ii ; | |
207 | for ( ii = 0 ; ii < nprimaries ; ii++) | |
208 | newprimaryarray[ii] = digit->GetPrimary(ii+1) ; | |
2731cd1e | 209 | |
cf239357 | 210 | Int_t jndex ; |
211 | for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit | |
2731cd1e | 212 | if ( fMulTrack > fMaxTrack ) { |
213 | fMulTrack = - 1 ; | |
214 | cout << "AliPHOSRecPoint::GetNprimaries ERROR > increase fMaxTrack " << endl ; | |
cf239357 | 215 | break ; |
216 | } | |
217 | Int_t newprimary = newprimaryarray[jndex] ; | |
cf239357 | 218 | Int_t kndex ; |
219 | Bool_t already = kFALSE ; | |
2731cd1e | 220 | for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored |
cf239357 | 221 | if ( newprimary == tempo[kndex] ){ |
222 | already = kTRUE ; | |
223 | break ; | |
224 | } | |
225 | } // end of check | |
b2a60966 | 226 | if ( !already) { // store it |
2731cd1e | 227 | tempo[fMulTrack] = newprimary ; |
228 | fMulTrack++ ; | |
cf239357 | 229 | } // store it |
230 | } // all primaries in digit | |
26d4b141 | 231 | delete newprimaryarray ; |
cf239357 | 232 | } // all digits |
233 | ||
2731cd1e | 234 | |
235 | fTracksList = new Int_t[fMulTrack] ; | |
236 | for(index = 0; index < fMulTrack; index++) | |
237 | fTracksList[index] = tempo[index] ; | |
238 | ||
239 | delete tempo ; | |
240 | ||
cf239357 | 241 | } |
4b45b217 | 242 | //____________________________________________________________________________ |
243 | void AliPHOSRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrix & gmat) const | |
244 | { | |
245 | // returns the position of the cluster in the global reference system of ALICE | |
246 | // and the uncertainty on this position | |
247 | ||
248 | ||
249 | AliPHOSGetter::GetInstance()->PHOSGeometry()->GetGlobal(this, gpos, gmat) ; | |
250 | ||
251 | } | |
252 | ||
cf239357 | 253 | |
9f616d61 | 254 | //______________________________________________________________________________ |
255 | void AliPHOSRecPoint::Paint(Option_t *) | |
256 | { | |
b2a60966 | 257 | // Paint this ALiRecPoint as a TMarker with its current attributes |
258 | ||
259 | TVector3 pos(0.,0.,0.) ; | |
260 | GetLocalPosition(pos) ; | |
261 | Coord_t x = pos.X() ; | |
262 | Coord_t y = pos.Z() ; | |
263 | Color_t markercolor = 1 ; | |
264 | Size_t markersize = 1. ; | |
265 | Style_t markerstyle = 5 ; | |
266 | ||
267 | if (!gPad->IsBatch()) { | |
268 | gVirtualX->SetMarkerColor(markercolor) ; | |
269 | gVirtualX->SetMarkerSize (markersize) ; | |
270 | gVirtualX->SetMarkerStyle(markerstyle) ; | |
271 | } | |
272 | gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ; | |
273 | gPad->PaintPolyMarker(1,&x,&y,"") ; | |
9f616d61 | 274 | } |