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