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