]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHPoints.cxx
1eba522cbfa5c18e2b0dc441a1a034747970eca5
[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.10.4.1  2002/05/31 09:37:59  hristov
19   First set of changes done by Piotr
20
21   Revision 1.10  2001/10/23 13:03:35  hristov
22   The access to several data members was changed from public to protected. The digitisation was adapted to the multi-event case (J.Chudoba)
23
24   Revision 1.9  2001/02/27 15:20:56  jbarbosa
25   Transition to SDigits.
26
27   Revision 1.8  2001/01/26 20:00:27  hristov
28   Major upgrade of AliRoot code
29
30   Revision 1.7  2000/11/02 09:10:57  jbarbosa
31   Removed AliRICHRecHit.h from include.
32
33   Revision 1.6  2000/10/03 21:44:09  morsch
34   Use AliSegmentation and AliHit abstract base classes.
35
36   Revision 1.5  2000/10/02 21:28:12  fca
37   Removal of useless dependecies via forward declarations
38
39   Revision 1.4  2000/10/02 15:50:43  jbarbosa
40   Fixed forward declarations.
41
42   Revision 1.3  2000/06/12 15:26:36  jbarbosa
43   Cleaned up version.
44
45   Revision 1.2  2000/05/18 13:43:54  jbarbosa
46   Added the ShowRing function.
47
48   Revision 1.1  2000/04/19 13:16:47  morsch
49   Minor changes on class names.
50
51 */
52
53
54 ///////////////////////////////////////////////////////////////////////////////
55 //                                                                           //
56 //  This class contains the points for the ALICE event display               //
57 //                                                                           //
58 //Begin_Html
59 /*
60 <img src="gif/AliRICHPointsClass.gif">
61 */
62 //End_Html
63 //                                                                           //
64 //                                                                           //
65 ///////////////////////////////////////////////////////////////////////////////
66 #include <TPad.h>
67 #include <TTree.h>
68 #include <TView.h>
69 #include <TMath.h>
70 #include <TPolyMarker3D.h>
71 #include <TMarker3DBox.h>
72
73 #include <AliRICH.h>
74 #include "TParticle.h"
75 #include "AliRICHDisplay.h"
76 #include "AliRICHPoints.h"
77 #include "AliRun.h"
78 #include "AliRICHHit.h"
79 #include "AliRICHCerenkov.h"
80 #include "AliRICHSDigit.h"
81 #include "AliRICHDigit.h"
82 #include "AliRICHRawCluster.h"
83
84 const Int_t kMaxNipx=400, kMaxNipy=800;
85  
86 ClassImp(AliRICHPoints)
87
88 //_____________________________________________________________________________
89 AliRICHPoints::AliRICHPoints()
90 {
91   //
92   // Default constructor
93   //
94   fHitIndex = 0;
95   fTrackIndex = 0;
96   fDigitIndex = 0;
97   fMarker[0] = fMarker[1] = fMarker[2]=0;
98 }
99
100 //_____________________________________________________________________________
101 AliRICHPoints::AliRICHPoints(Int_t npoints)
102   :AliPoints(npoints)
103 {
104   //
105   // Standard constructor
106   //
107   fHitIndex = 0;
108   fTrackIndex = 0;
109   fDigitIndex = 0;
110   fMarker[0] = fMarker[1] = fMarker[2]=0;
111 }
112          
113 //_____________________________________________________________________________
114 AliRICHPoints::~AliRICHPoints()
115 {
116   //
117   // Default destructor
118   //
119   fHitIndex = 0;
120   fTrackIndex = 0;
121   fDigitIndex = 0;
122 }
123
124 //_____________________________________________________________________________
125 void AliRICHPoints::DumpHit()
126 {
127   //
128   //   Dump hit corresponding to this point
129   //
130   AliRICHHit *hit = GetHit();
131   if (hit) hit->Dump();
132 }
133
134 //_____________________________________________________________________________
135 void AliRICHPoints::DumpDigit()
136 {
137   //
138   //   Dump digit corresponding to this point
139   //
140   AliRICHDigit *digit = GetDigit();
141   if (digit) digit->Dump();
142 }
143
144 //_____________________________________________________________________________
145 void AliRICHPoints::InspectHit()
146 {
147   //
148   //   Inspect hit corresponding to this point
149   //
150   AliRICHHit *hit = GetHit();
151   if (hit) hit->Inspect();
152 }
153
154 //_____________________________________________________________________________
155 void AliRICHPoints::InspectDigit()
156 {
157   //
158   //   Inspect digit corresponding to this point
159   //
160   AliRICHDigit *digit = GetDigit();
161   if (digit) digit->Inspect();
162 }
163
164 //_____________________________________________________________________________
165 Int_t AliRICHPoints::GetTrackIndex()
166 {
167   //
168   //   Dump digit corresponding to this point
169   //
170   printf("GetTrackIndex - fTrackIndex %d \n",fTrackIndex);
171   this->Inspect();
172   return fTrackIndex;
173 }
174 //_____________________________________________________________________________
175 TParticle *AliRICHPoints::GetParticle() const
176 {
177   //
178   //   Returns pointer to particle index in AliRun::fParticles
179   //
180   if (fIndex < 0 || fIndex >= gAlice->GetNtrack()) return 0;
181   return gAlice->Particle(fIndex);
182 }
183
184 //_____________________________________________________________________________
185 AliRICHHit *AliRICHPoints::GetHit() const
186 {
187   //
188   //   Returns pointer to hit index in AliRun::fParticles
189   //
190   AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
191   pRICH->TreeH()->GetEvent(fTrackIndex);
192   TClonesArray *pRICHhits  = pRICH->Hits();
193   Int_t nhits = pRICHhits->GetEntriesFast();
194   if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
195   return (AliRICHHit*)pRICHhits->UncheckedAt(fHitIndex);
196 }
197
198 //_____________________________________________________________________________
199 AliRICHDigit *AliRICHPoints::GetDigit() const
200 {
201   //
202   //   Returns pointer to digit index in AliRun::fParticles
203   //
204
205   AliRICHDisplay *display=(AliRICHDisplay*)gAlice->Display();
206   Int_t chamber=display->GetChamber();
207   Int_t cathode=display->GetCathode();
208    
209   AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
210   TClonesArray *pRICHdigits  = pRICH->DigitsAddress(chamber-1);
211   gAlice->TreeD()->GetEvent(cathode);
212   Int_t ndigits = pRICHdigits->GetEntriesFast();
213   if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
214   return (AliRICHDigit*)pRICHdigits->UncheckedAt(fDigitIndex);
215 }
216 //----------------------------------------------------------------------------
217 void AliRICHPoints::ShowRing(Int_t highlight) {
218
219 //
220 // Highlights all pads generated by the same mother particle
221
222    
223   AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
224   AliRICHChamber*       iChamber;
225   AliSegmentation*      segmentation;
226
227       
228   AliRICHPoints *points = 0;
229   TMarker3DBox  *marker = 0;
230     
231   AliRICHHit *mHit = GetHit();
232
233   printf("Hit %d on chamber: %d\n",fHitIndex, mHit->Chamber());
234
235   TClonesArray *digits  = pRICH->DigitsAddress(mHit->Chamber() - 1);
236   iChamber = &(pRICH->Chamber(mHit->Chamber() - 1));
237   segmentation=iChamber->GetSegmentationModel();
238
239   Float_t dpx  = segmentation->Dpx();
240   Float_t dpy  = segmentation->Dpy();
241
242   int ndigits=digits->GetEntriesFast();
243   
244   printf("Show Ring called with %d digits\n",ndigits);
245   
246   for (int digit=0;digit<ndigits;digit++) {
247     AliRICHDigit *mdig = (AliRICHDigit*)digits->UncheckedAt(digit);
248     points = new AliRICHPoints(1);
249     
250      //printf("Particle %d belongs to ring %d \n", fTrackIndex, mdig->fTracks[1]);
251
252     if (!points) continue;
253     if (fTrackIndex == mdig->Track(0)) {
254
255       printf("Digit %d from particle %d belongs to ring %d \n", digit, fTrackIndex, mdig->Track(0));
256
257       Int_t charge=mdig->Signal();
258       Int_t index=Int_t(TMath::Log(charge)/(TMath::Log(adc_satm)/22));
259       Int_t color=701+index;
260       if (color>722) color=722;
261       points->SetMarkerColor(color);
262       points->SetMarkerStyle(21);
263       points->SetMarkerSize(.5);
264       Float_t xpad, ypad, zpad;
265       segmentation->GetPadC(mdig->PadX(), mdig->PadY(),xpad, ypad, zpad);
266       Float_t vectorLoc[3]={xpad,6.276,ypad};
267       Float_t  vectorGlob[3];
268       points->SetParticle(-1);
269       points->SetHitIndex(-1);
270       points->SetTrackIndex(-1);
271       points->SetDigitIndex(digit);
272       iChamber->LocaltoGlobal(vectorLoc,vectorGlob);
273       points->SetPoint(0,vectorGlob[0],vectorGlob[1],vectorGlob[2]);
274       
275       segmentation->GetPadC(mdig->PadX(), mdig->PadY(), xpad, ypad, zpad);
276       Float_t theta = iChamber->GetRotMatrix()->GetTheta();
277       Float_t phi   = iChamber->GetRotMatrix()->GetPhi();          
278       marker=new TMarker3DBox(vectorGlob[0],vectorGlob[1],vectorGlob[2],
279                               dpy/2,0,dpx/2,theta,phi);
280       marker->SetLineColor(highlight);
281       marker->SetFillStyle(1001);
282       marker->SetFillColor(color);
283       marker->SetRefObject((TObject*)points);
284       points->Set3DMarker(0, marker);
285       
286       points->Draw("same");
287       for (Int_t im=0;im<3;im++) {
288         TMarker3DBox *marker=points->GetMarker(im);
289         if (marker)
290           marker->Draw();
291       }
292       TParticle *p = gAlice->Particle(fIndex);
293       printf("\nTrack index %d\n",fTrackIndex);
294       printf("Particle ID %d\n",p->GetPdgCode());
295       printf("Parent %d\n",p->GetFirstMother());
296       printf("First child %d\n",p->GetFirstDaughter());
297       printf("Px,Py,Pz %f %f %f\n",p->Px(),p->Py(),p->Pz());
298     }
299   }
300 }
301
302 //_____________________________________________________________________________
303 const Text_t *AliRICHPoints::GetName() const
304 {
305   //
306   // Return name of the Geant3 particle corresponding to this point
307   //
308   TParticle *particle = GetParticle();
309   if (!particle) return "Particle";
310   return particle->GetName();
311 }
312
313 //_____________________________________________________________________________
314 Text_t *AliRICHPoints::GetObjectInfo(Int_t, Int_t)
315 {
316   //
317   //   Redefines TObject::GetObjectInfo.
318   //   Displays the info (particle,etc
319   //   corresponding to cursor position px,py
320   //
321   static char info[64];
322   sprintf(info,"%s %d",GetName(),fIndex);
323   return info;
324 }
325
326
327