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