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