]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHPoints.cxx
Offset Alpha Beta angles added
[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.9  2001/02/27 15:20:56  jbarbosa
19   Transition to SDigits.
20
21   Revision 1.8  2001/01/26 20:00:27  hristov
22   Major upgrade of AliRoot code
23
24   Revision 1.7  2000/11/02 09:10:57  jbarbosa
25   Removed AliRICHRecHit.h from include.
26
27   Revision 1.6  2000/10/03 21:44:09  morsch
28   Use AliSegmentation and AliHit abstract base classes.
29
30   Revision 1.5  2000/10/02 21:28:12  fca
31   Removal of useless dependecies via forward declarations
32
33   Revision 1.4  2000/10/02 15:50:43  jbarbosa
34   Fixed forward declarations.
35
36   Revision 1.3  2000/06/12 15:26:36  jbarbosa
37   Cleaned up version.
38
39   Revision 1.2  2000/05/18 13:43:54  jbarbosa
40   Added the ShowRing function.
41
42   Revision 1.1  2000/04/19 13:16:47  morsch
43   Minor changes on class names.
44
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 ///////////////////////////////////////////////////////////////////////////////
60 #include <TPad.h>
61 #include <TTree.h>
62 #include <TView.h>
63 #include <TMath.h>
64 #include <TPolyMarker3D.h>
65 #include <TMarker3DBox.h>
66
67 #include <AliRICH.h>
68 #include "TParticle.h"
69 #include "AliRICHDisplay.h"
70 #include "AliRICHPoints.h"
71 #include "AliRun.h"
72 #include "AliRICHHit.h"
73 #include "AliRICHCerenkov.h"
74 #include "AliRICHSDigit.h"
75 #include "AliRICHDigit.h"
76 #include "AliRICHRawCluster.h"
77
78 const Int_t kMaxNipx=400, kMaxNipy=800;
79  
80 ClassImp(AliRICHPoints)
81
82 //_____________________________________________________________________________
83 AliRICHPoints::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 //_____________________________________________________________________________
95 AliRICHPoints::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 //_____________________________________________________________________________
108 AliRICHPoints::~AliRICHPoints()
109 {
110   //
111   // Default destructor
112   //
113   fHitIndex = 0;
114   fTrackIndex = 0;
115   fDigitIndex = 0;
116 }
117
118 //_____________________________________________________________________________
119 void AliRICHPoints::DumpHit()
120 {
121   //
122   //   Dump hit corresponding to this point
123   //
124   AliRICHHit *hit = GetHit();
125   if (hit) hit->Dump();
126 }
127
128 //_____________________________________________________________________________
129 void AliRICHPoints::DumpDigit()
130 {
131   //
132   //   Dump digit corresponding to this point
133   //
134   AliRICHDigit *digit = GetDigit();
135   if (digit) digit->Dump();
136 }
137
138 //_____________________________________________________________________________
139 void AliRICHPoints::InspectHit()
140 {
141   //
142   //   Inspect hit corresponding to this point
143   //
144   AliRICHHit *hit = GetHit();
145   if (hit) hit->Inspect();
146 }
147
148 //_____________________________________________________________________________
149 void AliRICHPoints::InspectDigit()
150 {
151   //
152   //   Inspect digit corresponding to this point
153   //
154   AliRICHDigit *digit = GetDigit();
155   if (digit) digit->Inspect();
156 }
157
158 //_____________________________________________________________________________
159 Int_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 }
168 //_____________________________________________________________________________
169 TParticle *AliRICHPoints::GetParticle() const
170 {
171   //
172   //   Returns pointer to particle index in AliRun::fParticles
173   //
174   if (fIndex < 0 || fIndex >= gAlice->GetNtrack()) return 0;
175   return gAlice->Particle(fIndex);
176 }
177
178 //_____________________________________________________________________________
179 AliRICHHit *AliRICHPoints::GetHit() const
180 {
181   //
182   //   Returns pointer to hit index in AliRun::fParticles
183   //
184   AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
185   gAlice->TreeH()->GetEvent(fTrackIndex);
186   TClonesArray *pRICHhits  = pRICH->Hits();
187   Int_t nhits = pRICHhits->GetEntriesFast();
188   if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
189   return (AliRICHHit*)pRICHhits->UncheckedAt(fHitIndex);
190 }
191
192 //_____________________________________________________________________________
193 AliRICHDigit *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    
203   AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
204   TClonesArray *pRICHdigits  = pRICH->DigitsAddress(chamber-1);
205   gAlice->TreeD()->GetEvent(cathode);
206   Int_t ndigits = pRICHdigits->GetEntriesFast();
207   if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
208   return (AliRICHDigit*)pRICHdigits->UncheckedAt(fDigitIndex);
209 }
210 //----------------------------------------------------------------------------
211 void AliRICHPoints::ShowRing(Int_t highlight) {
212
213 //
214 // Highlights all pads generated by the same mother particle
215
216    
217   AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
218   AliRICHChamber*       iChamber;
219   AliSegmentation*      segmentation;
220
221       
222   AliRICHPoints *points = 0;
223   TMarker3DBox  *marker = 0;
224     
225   AliRICHHit *mHit = GetHit();
226
227   printf("Hit %d on chamber: %d\n",fHitIndex, mHit->Chamber());
228
229   TClonesArray *digits  = pRICH->DigitsAddress(mHit->Chamber() - 1);
230   iChamber = &(pRICH->Chamber(mHit->Chamber() - 1));
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;
247     if (fTrackIndex == mdig->Track(0)) {
248
249       printf("Digit %d from particle %d belongs to ring %d \n", digit, fTrackIndex, mdig->Track(0));
250
251       Int_t charge=mdig->Signal();
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);
258       Float_t xpad, ypad, zpad;
259       segmentation->GetPadC(mdig->PadX(), mdig->PadY(),xpad, ypad, zpad);
260       Float_t vectorLoc[3]={xpad,6.276,ypad};
261       Float_t  vectorGlob[3];
262       points->SetParticle(-1);
263       points->SetHitIndex(-1);
264       points->SetTrackIndex(-1);
265       points->SetDigitIndex(digit);
266       iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
267       points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
268       
269       segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
270       Float_t theta = iChamber->GetRotMatrix()->GetTheta();
271       Float_t phi   = iChamber->GetRotMatrix()->GetPhi();          
272       marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
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       }
286       TParticle *p = gAlice->Particle(fIndex);
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 }
295
296 //_____________________________________________________________________________
297 const 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 //_____________________________________________________________________________
308 Text_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