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