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