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