Line data Source code
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 : /* $Id$ */
16 : //_________________________________________________________________________
17 : // Base Class for PHOS Reconstructed Points
18 : // Why should I put meaningless comments
19 : // just to satisfy
20 : // the code checker
21 : //-- Author: Gines Martinez (SUBATECH)
22 :
23 : // --- ROOT system ---
24 : #include "TPad.h"
25 : #include "TGraph.h"
26 : #include "TPaveText.h"
27 : #include "TClonesArray.h"
28 : #include "TGeoMatrix.h"
29 :
30 : // --- Standard library ---
31 :
32 : // --- AliRoot header files ---
33 : #include "AliLog.h"
34 : #include "AliPHOSLoader.h"
35 : #include "AliPHOSGeometry.h"
36 : #include "AliPHOSDigit.h"
37 : #include "AliPHOSRecPoint.h"
38 : #include "AliGeomManager.h"
39 :
40 22 : ClassImp(AliPHOSRecPoint)
41 :
42 :
43 : //____________________________________________________________________________
44 : AliPHOSRecPoint::AliPHOSRecPoint()
45 80 : : AliCluster(),fPHOSMod(0),
46 40 : fMulTrack(0),fMaxDigit(100),fMulDigit(0),fMaxTrack(200),
47 40 : fDigitsList(0),fTracksList(0),fAmp(0),
48 40 : fIndexInList(-1), // to be set when the point is already stored
49 40 : fLocPos(0,0,0)
50 120 : {
51 : // ctor
52 :
53 40 : }
54 :
55 : //____________________________________________________________________________
56 : AliPHOSRecPoint::AliPHOSRecPoint(const char * )
57 20 : : AliCluster(),fPHOSMod(0),
58 10 : fMulTrack(0),fMaxDigit(100),fMulDigit(0),fMaxTrack(200),
59 30 : fDigitsList(new Int_t[fMaxDigit]),fTracksList(new Int_t[fMaxTrack]),fAmp(0),
60 10 : fIndexInList(-1), // to be set when the point is already stored
61 10 : fLocPos(0,0,0)
62 :
63 30 : {
64 : // ctor
65 :
66 10 : }
67 : //_______________________________________________________________________
68 : AliPHOSRecPoint::~AliPHOSRecPoint()
69 88 : {
70 : // dtor
71 :
72 86 : delete [] fDigitsList ;
73 70 : delete [] fTracksList ;
74 :
75 44 : }
76 : //____________________________________________________________________________
77 : AliPHOSRecPoint::AliPHOSRecPoint(const AliPHOSRecPoint &rp) :
78 10 : AliCluster(rp),
79 10 : fPHOSMod(rp.fPHOSMod),fMulTrack(rp.fMulTrack),fMaxDigit(rp.fMaxDigit),
80 10 : fMulDigit(rp.fMulDigit),fMaxTrack(rp.fMaxTrack),fDigitsList(0x0),
81 10 : fTracksList(0x0),fAmp(rp.fAmp),fIndexInList(rp.fIndexInList),
82 10 : fLocPos(rp.fLocPos)
83 30 : {
84 : //copy ctor
85 :
86 30 : if (rp.fMulDigit>0) fDigitsList = new Int_t[rp.fMulDigit];
87 344 : for(Int_t i=0; i<fMulDigit; i++)
88 162 : fDigitsList[i] = rp.fDigitsList[i];
89 :
90 20 : if (rp.fMulTrack>0) fTracksList = new Int_t[rp.fMulTrack];
91 30 : for(Int_t i=0; i<fMulTrack; i++)
92 5 : fTracksList[i] = rp.fTracksList[i];
93 :
94 10 : }
95 : //____________________________________________________________________________
96 : AliPHOSRecPoint& AliPHOSRecPoint::operator= (const AliPHOSRecPoint &rp)
97 : {
98 0 : if(&rp == this) return *this;
99 :
100 0 : fPHOSMod = rp.fPHOSMod;
101 0 : fMulTrack = rp.fMulTrack;
102 0 : fMaxDigit = rp.fMaxDigit;
103 0 : fMulDigit = rp.fMulDigit;
104 0 : fMaxTrack = rp.fMaxTrack;
105 0 : fAmp = rp.fAmp;
106 0 : fIndexInList = rp.fIndexInList;
107 0 : fLocPos = rp.fLocPos;
108 :
109 0 : if (fDigitsList != 0) delete [] fDigitsList;
110 0 : if (fMaxDigit>0) {
111 0 : fDigitsList = new Int_t[fMaxDigit];
112 0 : for(Int_t i=0; i<fMaxDigit; i++)
113 0 : fDigitsList[i] = rp.fDigitsList[i];
114 0 : }
115 :
116 0 : if (fTracksList != 0) delete [] fTracksList;
117 0 : if (fMaxTrack>0) {
118 0 : fTracksList = new Int_t[fMaxTrack];
119 0 : for(Int_t i=0; i<fMaxTrack; i++)
120 0 : fTracksList[i] = rp.fTracksList[i];
121 0 : }
122 :
123 0 : return *this;
124 0 : }
125 : //____________________________________________________________________________
126 : Int_t AliPHOSRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
127 : {
128 : // Compute distance from point px,py to a AliPHOSRecPoint considered as a Tmarker
129 : // Compute the closest distance of approach from point px,py to this marker.
130 : // The distance is computed in pixels units.
131 :
132 0 : TVector3 pos(0.,0.,0.) ;
133 0 : GetLocalPosition( pos) ;
134 0 : Float_t x = pos.X() ;
135 0 : Float_t y = pos.Z() ;
136 : const Int_t kMaxDiff = 10;
137 0 : Int_t pxm = gPad->XtoAbsPixel(x);
138 0 : Int_t pym = gPad->YtoAbsPixel(y);
139 0 : Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
140 :
141 0 : if (dist > kMaxDiff) return 9999;
142 0 : return dist;
143 0 : }
144 :
145 : //___________________________________________________________________________
146 : void AliPHOSRecPoint::Draw(Option_t *option)
147 : {
148 : // Draw this AliPHOSRecPoint with its current attributes
149 :
150 0 : AppendPad(option);
151 0 : }
152 :
153 : //______________________________________________________________________________
154 : void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t)
155 : {
156 : // Execute action corresponding to one event
157 : // This member function is called when a AliPHOSRecPoint is clicked with the locator
158 : //
159 : // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
160 : // and switched off when the mouse button is released.
161 :
162 : // static Int_t pxold, pyold;
163 :
164 : static TGraph * digitgraph = 0 ;
165 : static TPaveText* clustertext = 0 ;
166 :
167 0 : if (!gPad->IsEditable()) return;
168 :
169 0 : switch (event) {
170 :
171 :
172 : case kButton1Down:{
173 : AliPHOSDigit * digit ;
174 :
175 0 : AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
176 :
177 : Int_t iDigit;
178 0 : Int_t relid[4] ;
179 :
180 0 : const Int_t kMulDigit=AliPHOSRecPoint::GetDigitsMultiplicity() ;
181 0 : Float_t * xi = new Float_t [kMulDigit] ;
182 0 : Float_t * zi = new Float_t [kMulDigit] ;
183 :
184 0 : for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
185 0 : Fatal("AliPHOSRecPoint::ExecuteEvent", "-> Something wrong with the code");
186 : digit = 0 ; //dynamic_cast<AliPHOSDigit *>((fDigitsList)[iDigit]);
187 0 : phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
188 0 : phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]) ;
189 : }
190 :
191 0 : if (!digitgraph) {
192 0 : digitgraph = new TGraph(fMulDigit,xi,zi);
193 0 : digitgraph-> SetMarkerStyle(5) ;
194 0 : digitgraph-> SetMarkerSize(1.) ;
195 0 : digitgraph-> SetMarkerColor(1) ;
196 0 : digitgraph-> Draw("P") ;
197 0 : }
198 0 : if (!clustertext) {
199 :
200 0 : TVector3 pos(0.,0.,0.) ;
201 0 : GetLocalPosition(pos) ;
202 0 : clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
203 0 : Text_t line1[40] ;
204 0 : Text_t line2[40] ;
205 0 : snprintf(line1,40,"Energy=%1.2f GeV",GetEnergy()) ;
206 0 : snprintf(line2,40,"%d Digits",GetDigitsMultiplicity()) ;
207 0 : clustertext ->AddText(line1) ;
208 0 : clustertext ->AddText(line2) ;
209 0 : clustertext ->Draw("");
210 0 : }
211 0 : gPad->Update() ;
212 0 : Print("dummy") ;
213 0 : delete[] xi ;
214 0 : delete[] zi ;
215 0 : }
216 :
217 0 : break;
218 :
219 : case kButton1Up:
220 0 : if (digitgraph) {
221 0 : delete digitgraph ;
222 0 : digitgraph = 0 ;
223 0 : }
224 0 : if (clustertext) {
225 0 : delete clustertext ;
226 0 : clustertext = 0 ;
227 0 : }
228 :
229 : break;
230 :
231 : }
232 0 : }
233 : //____________________________________________________________________________
234 : void AliPHOSRecPoint::EvalAll(TClonesArray * /* digits */)
235 : {
236 : //evaluates (if necessary) all RecPoint data members
237 :
238 20 : }
239 :
240 : //____________________________________________________________________________
241 : void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit)
242 : {
243 : // Returns the PHOS module in which the RecPoint is found
244 :
245 352 : if( fPHOSMod == 0){
246 10 : Int_t relid[4] ;
247 :
248 10 : AliPHOSGeometry * phosgeom = (AliPHOSGeometry::GetInstance());
249 :
250 10 : phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
251 10 : fPHOSMod = relid[0];
252 10 : }
253 176 : }
254 :
255 : //____________________________________________________________________________
256 : void AliPHOSRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrixF & gmat) const
257 : {
258 : // returns the position of the cluster in the global reference system of ALICE
259 : // and the uncertainty on this position
260 :
261 0 : AliPHOSGeometry * phosgeom = (AliPHOSGeometry::GetInstance());
262 0 : phosgeom->GetGlobalPHOS(this, gpos, gmat);
263 :
264 0 : }
265 :
266 : //______________________________________________________________________________
267 : void AliPHOSRecPoint::Paint(Option_t *)
268 : {
269 : // Paint this ALiRecPoint as a TMarker with its current attributes
270 :
271 0 : TVector3 pos(0.,0.,0.) ;
272 0 : GetLocalPosition(pos) ;
273 0 : Coord_t x = pos.X() ;
274 0 : Coord_t y = pos.Z() ;
275 : Color_t markercolor = 1 ;
276 : Size_t markersize = 1. ;
277 : Style_t markerstyle = 5 ;
278 :
279 0 : if (!gPad->IsBatch()) {
280 0 : gVirtualX->SetMarkerColor(markercolor) ;
281 0 : gVirtualX->SetMarkerSize (markersize) ;
282 0 : gVirtualX->SetMarkerStyle(markerstyle) ;
283 : }
284 0 : gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
285 0 : gPad->PaintPolyMarker(1,&x,&y,"") ;
286 0 : }
287 : //______________________________________________________________________________
288 : void AliPHOSRecPoint::GetLocalPosition(TVector3 & pos) const
289 : {
290 : // returns the position of the cluster in the local reference system
291 : // of the sub-detector
292 :
293 92 : pos = fLocPos;
294 46 : }
295 :
296 : //____________________________________________________________________________
297 : void AliPHOSRecPoint::EvalLocal2TrackingCSTransform()
298 : {
299 : //Evaluates local to "tracking" c.s. transformation (B.P.).
300 : //All evaluations should be completed before calling for this function.
301 : //See ALICE PPR Chapter 5 p.18 for "tracking" c.s. definition,
302 : //or just ask Jouri Belikov. :)
303 :
304 30 : if(IsEmc()) {
305 20 : SetVolumeId(AliGeomManager::LayerToVolUID(AliGeomManager::kPHOS1,GetPHOSMod()-1));
306 10 : }
307 : else
308 0 : SetVolumeId(AliGeomManager::LayerToVolUID(AliGeomManager::kPHOS2,GetPHOSMod()-1));
309 :
310 10 : Double_t lxyz[3] = {fLocPos.X(),fLocPos.Y(),fLocPos.Z()};
311 10 : Double_t txyz[3] = {0,0,0};
312 : Double_t dy;
313 : Double_t crystalShift;
314 :
315 10 : AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
316 10 : AliPHOSEMCAGeometry* geoEMCA = phosgeom->GetEMCAGeometry();
317 :
318 : //Calculate offset to crystal surface.
319 : //See fCrystalShift code in AliPHOSGeometry::Init()).
320 :
321 10 : const Float_t * inthermo = geoEMCA->GetInnerThermoHalfSize() ;
322 10 : const Float_t * strip = geoEMCA->GetStripHalfSize() ;
323 10 : const Float_t * splate = geoEMCA->GetSupportPlateHalfSize();
324 10 : const Float_t * crystal = geoEMCA->GetCrystalHalfSize() ;
325 10 : const Float_t * pin = geoEMCA->GetAPDHalfSize() ;
326 10 : const Float_t * preamp = geoEMCA->GetPreampHalfSize() ;
327 10 : crystalShift = -inthermo[1]+strip[1]+splate[1]+crystal[1]-geoEMCA->GetAirGapLed()/2.+pin[1]+preamp[1] ;
328 :
329 10 : if(IsEmc()) {
330 : dy = crystalShift;
331 10 : lxyz[2] = -lxyz[2]; //Opposite z directions in EMC matrix and local frame!!!
332 10 : }
333 : else
334 0 : dy = phosgeom->GetCPVBoxSize(1)/2.; //center of CPV module
335 :
336 10 : lxyz[1] = lxyz[1] - dy;
337 :
338 10 : const TGeoHMatrix* tr2loc = GetTracking2LocalMatrix();
339 10 : if(!tr2loc) AliError(Form("No Tracking2LocalMatrix found for VolumeID=%d",GetVolumeId()));
340 :
341 10 : if(tr2loc){
342 10 : tr2loc->MasterToLocal(lxyz,txyz);
343 10 : SetX(txyz[0]); SetY(txyz[1]); SetZ(txyz[2]);
344 :
345 10 : if(AliLog::GetGlobalDebugLevel()>0) {
346 0 : TVector3 gpos; TMatrixF gmat;
347 0 : GetGlobalPosition(gpos,gmat);
348 0 : Float_t gxyz[3];
349 0 : GetGlobalXYZ(gxyz);
350 0 : TString emc;
351 0 : if(IsEmc())
352 0 : emc="EMC";
353 : else
354 0 : emc="CPV";
355 0 : AliInfo(Form("lCS-->(%.3f,%.3f,%.3f), tCS-->(%.3f,%.3f,%.3f), gCS-->(%.3f,%.3f,%.3f), gCScalc-->(%.3f,%.3f,%.3f), module %d %s",
356 : fLocPos.X(),fLocPos.Y(),fLocPos.Z(),
357 : GetX(),GetY(),GetZ(),
358 : gpos.X(),gpos.Y(),gpos.Z(),
359 : gxyz[0],gxyz[1],gxyz[2],GetPHOSMod(),emc.Data()));
360 0 : }
361 : }
362 10 : }
|