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