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