Old style include needed on HP
[u/mrichter/AliRoot.git] / RICH / AliRICHPoints.cxx
CommitLineData
0279872e 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
16/*
17 $Log$
6e585aa2 18 Revision 1.9 2001/02/27 15:20:56 jbarbosa
19 Transition to SDigits.
20
b251a2b5 21 Revision 1.8 2001/01/26 20:00:27 hristov
22 Major upgrade of AliRoot code
23
2ab0c725 24 Revision 1.7 2000/11/02 09:10:57 jbarbosa
25 Removed AliRICHRecHit.h from include.
26
b83446fc 27 Revision 1.6 2000/10/03 21:44:09 morsch
28 Use AliSegmentation and AliHit abstract base classes.
29
a2f7eaf6 30 Revision 1.5 2000/10/02 21:28:12 fca
31 Removal of useless dependecies via forward declarations
32
94de3818 33 Revision 1.4 2000/10/02 15:50:43 jbarbosa
34 Fixed forward declarations.
35
488e98ba 36 Revision 1.3 2000/06/12 15:26:36 jbarbosa
37 Cleaned up version.
38
237c933d 39 Revision 1.2 2000/05/18 13:43:54 jbarbosa
40 Added the ShowRing function.
41
7ea4320b 42 Revision 1.1 2000/04/19 13:16:47 morsch
43 Minor changes on class names.
44
0279872e 45*/
46
47
48///////////////////////////////////////////////////////////////////////////////
49// //
50// This class contains the points for the ALICE event display //
51// //
52//Begin_Html
53/*
54<img src="gif/AliRICHPointsClass.gif">
55*/
56//End_Html
57// //
58// //
59///////////////////////////////////////////////////////////////////////////////
237c933d 60#include <TPad.h>
94de3818 61#include <TTree.h>
237c933d 62#include <TView.h>
63#include <TMath.h>
488e98ba 64#include <TPolyMarker3D.h>
65#include <TMarker3DBox.h>
237c933d 66
488e98ba 67#include <AliRICH.h>
94de3818 68#include "TParticle.h"
0279872e 69#include "AliRICHDisplay.h"
70#include "AliRICHPoints.h"
71#include "AliRun.h"
237c933d 72#include "AliRICHHit.h"
73#include "AliRICHCerenkov.h"
b251a2b5 74#include "AliRICHSDigit.h"
237c933d 75#include "AliRICHDigit.h"
76#include "AliRICHRawCluster.h"
237c933d 77
78const Int_t kMaxNipx=400, kMaxNipy=800;
0279872e 79
80ClassImp(AliRICHPoints)
81
82//_____________________________________________________________________________
83AliRICHPoints::AliRICHPoints()
84{
85 //
86 // Default constructor
87 //
88 fHitIndex = 0;
89 fTrackIndex = 0;
90 fDigitIndex = 0;
91 fMarker[0] = fMarker[1] = fMarker[2]=0;
92}
93
94//_____________________________________________________________________________
95AliRICHPoints::AliRICHPoints(Int_t npoints)
96 :AliPoints(npoints)
97{
98 //
99 // Standard constructor
100 //
101 fHitIndex = 0;
102 fTrackIndex = 0;
103 fDigitIndex = 0;
104 fMarker[0] = fMarker[1] = fMarker[2]=0;
105}
106
107//_____________________________________________________________________________
108AliRICHPoints::~AliRICHPoints()
109{
110 //
111 // Default destructor
112 //
113 fHitIndex = 0;
114 fTrackIndex = 0;
115 fDigitIndex = 0;
116}
117
118//_____________________________________________________________________________
119void AliRICHPoints::DumpHit()
120{
121 //
122 // Dump hit corresponding to this point
123 //
124 AliRICHHit *hit = GetHit();
125 if (hit) hit->Dump();
126}
127
128//_____________________________________________________________________________
129void AliRICHPoints::DumpDigit()
130{
131 //
132 // Dump digit corresponding to this point
133 //
134 AliRICHDigit *digit = GetDigit();
135 if (digit) digit->Dump();
136}
137
138//_____________________________________________________________________________
139void AliRICHPoints::InspectHit()
140{
141 //
142 // Inspect hit corresponding to this point
143 //
144 AliRICHHit *hit = GetHit();
145 if (hit) hit->Inspect();
146}
147
148//_____________________________________________________________________________
149void AliRICHPoints::InspectDigit()
150{
151 //
152 // Inspect digit corresponding to this point
153 //
154 AliRICHDigit *digit = GetDigit();
155 if (digit) digit->Inspect();
156}
157
158//_____________________________________________________________________________
159Int_t AliRICHPoints::GetTrackIndex()
160{
161 //
162 // Dump digit corresponding to this point
163 //
164 printf("GetTrackIndex - fTrackIndex %d \n",fTrackIndex);
165 this->Inspect();
166 return fTrackIndex;
167}
7ea4320b 168//_____________________________________________________________________________
169TParticle *AliRICHPoints::GetParticle() const
170{
171 //
172 // Returns pointer to particle index in AliRun::fParticles
173 //
2ab0c725 174 if (fIndex < 0 || fIndex >= gAlice->GetNtrack()) return 0;
175 return gAlice->Particle(fIndex);
7ea4320b 176}
0279872e 177
178//_____________________________________________________________________________
179AliRICHHit *AliRICHPoints::GetHit() const
180{
181 //
182 // Returns pointer to hit index in AliRun::fParticles
183 //
237c933d 184 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
0279872e 185 gAlice->TreeH()->GetEvent(fTrackIndex);
237c933d 186 TClonesArray *pRICHhits = pRICH->Hits();
187 Int_t nhits = pRICHhits->GetEntriesFast();
0279872e 188 if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
237c933d 189 return (AliRICHHit*)pRICHhits->UncheckedAt(fHitIndex);
0279872e 190}
191
192//_____________________________________________________________________________
193AliRICHDigit *AliRICHPoints::GetDigit() const
194{
195 //
196 // Returns pointer to digit index in AliRun::fParticles
197 //
198
199 AliRICHDisplay *display=(AliRICHDisplay*)gAlice->Display();
200 Int_t chamber=display->GetChamber();
201 Int_t cathode=display->GetCathode();
202
237c933d 203 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
204 TClonesArray *pRICHdigits = pRICH->DigitsAddress(chamber-1);
0279872e 205 gAlice->TreeD()->GetEvent(cathode);
237c933d 206 Int_t ndigits = pRICHdigits->GetEntriesFast();
0279872e 207 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
237c933d 208 return (AliRICHDigit*)pRICHdigits->UncheckedAt(fDigitIndex);
0279872e 209}
7ea4320b 210//----------------------------------------------------------------------------
211void AliRICHPoints::ShowRing(Int_t highlight) {
237c933d 212
213//
214// Highlights all pads generated by the same mother particle
215
7ea4320b 216
237c933d 217 AliRICH *pRICH = (AliRICH*)gAlice->GetDetector("RICH");
7ea4320b 218 AliRICHChamber* iChamber;
a2f7eaf6 219 AliSegmentation* segmentation;
7ea4320b 220
221
222 AliRICHPoints *points = 0;
223 TMarker3DBox *marker = 0;
224
225 AliRICHHit *mHit = GetHit();
226
6e585aa2 227 printf("Hit %d on chamber: %d\n",fHitIndex, mHit->Chamber());
7ea4320b 228
6e585aa2 229 TClonesArray *digits = pRICH->DigitsAddress(mHit->Chamber() - 1);
230 iChamber = &(pRICH->Chamber(mHit->Chamber() - 1));
7ea4320b 231 segmentation=iChamber->GetSegmentationModel();
232
233 Float_t dpx = segmentation->Dpx();
234 Float_t dpy = segmentation->Dpy();
235
236 int ndigits=digits->GetEntriesFast();
237
238 printf("Show Ring called with %d digits\n",ndigits);
239
240 for (int digit=0;digit<ndigits;digit++) {
241 AliRICHDigit *mdig = (AliRICHDigit*)digits->UncheckedAt(digit);
242 points = new AliRICHPoints(1);
243
244 //printf("Particle %d belongs to ring %d \n", fTrackIndex, mdig->fTracks[1]);
245
246 if (!points) continue;
6e585aa2 247 if (fTrackIndex == mdig->Track(0)) {
7ea4320b 248
6e585aa2 249 printf("Digit %d from particle %d belongs to ring %d \n", digit, fTrackIndex, mdig->Track(0));
7ea4320b 250
6e585aa2 251 Int_t charge=mdig->Signal();
7ea4320b 252 Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
253 Int_t color=701+index;
254 if (color>722) color=722;
255 points->SetMarkerColor(color);
256 points->SetMarkerStyle(21);
257 points->SetMarkerSize(.5);
a2f7eaf6 258 Float_t xpad, ypad, zpad;
6e585aa2 259 segmentation->GetPadC(mdig->PadX(), mdig->PadY(),xpad, ypad, zpad);
237c933d 260 Float_t vectorLoc[3]={xpad,6.276,ypad};
261 Float_t vectorGlob[3];
7ea4320b 262 points->SetParticle(-1);
263 points->SetHitIndex(-1);
264 points->SetTrackIndex(-1);
265 points->SetDigitIndex(digit);
237c933d 266 iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
267 points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
7ea4320b 268
6e585aa2 269 segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
7ea4320b 270 Float_t theta = iChamber->GetRotMatrix()->GetTheta();
271 Float_t phi = iChamber->GetRotMatrix()->GetPhi();
237c933d 272 marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
7ea4320b 273 dpy/2,0,dpx/2,theta,phi);
274 marker->SetLineColor(highlight);
275 marker->SetFillStyle(1001);
276 marker->SetFillColor(color);
277 marker->SetRefObject((TObject*)points);
278 points->Set3DMarker(0, marker);
279
280 points->Draw("same");
281 for (Int_t im=0;im<3;im++) {
282 TMarker3DBox *marker=points->GetMarker(im);
283 if (marker)
284 marker->Draw();
285 }
2ab0c725 286 TParticle *p = gAlice->Particle(fIndex);
7ea4320b 287 printf("\nTrack index %d\n",fTrackIndex);
288 printf("Particle ID %d\n",p->GetPdgCode());
289 printf("Parent %d\n",p->GetFirstMother());
290 printf("First child %d\n",p->GetFirstDaughter());
291 printf("Px,Py,Pz %f %f %f\n",p->Px(),p->Py(),p->Pz());
292 }
293 }
294}
0279872e 295
296//_____________________________________________________________________________
297const Text_t *AliRICHPoints::GetName() const
298{
299 //
300 // Return name of the Geant3 particle corresponding to this point
301 //
302 TParticle *particle = GetParticle();
303 if (!particle) return "Particle";
304 return particle->GetName();
305}
306
307//_____________________________________________________________________________
308Text_t *AliRICHPoints::GetObjectInfo(Int_t, Int_t)
309{
310 //
311 // Redefines TObject::GetObjectInfo.
312 // Displays the info (particle,etc
313 // corresponding to cursor position px,py
314 //
315 static char info[64];
316 sprintf(info,"%s %d",GetName(),fIndex);
317 return info;
318}
319
320
321