]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONPoints.cxx
Basic implementation of AliMUONVNDStore containers, using AliMpExMap
[u/mrichter/AliRoot.git] / MUON / AliMUONPoints.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/AliMUONPointsClass.gif">
25 */
26 //End_Html
27 //                                                                           //
28 //                                                                           //
29 ///////////////////////////////////////////////////////////////////////////////
30
31 #include <TROOT.h>
32 #include <TPolyMarker3D.h>
33 #include <TMatrixF.h>
34 #include <TVirtualPad.h>
35 #include <TPaveText.h>
36 #include <TMarker3DBox.h>
37  
38 #include "AliMUONPoints.h"
39 #include "AliMUONDisplay.h"
40 #include "AliRun.h"
41 #include "AliMUON.h"
42 #include "AliMUONHit.h"
43 #include "AliMUONDigit.h"
44 #include "AliLog.h"
45
46 ClassImp(AliMUONPoints)
47
48 //_____________________________________________________________________________
49 AliMUONPoints::AliMUONPoints()
50   : AliPoints()
51 {
52   //
53   // Default constructor
54   //
55   fHitIndex = 0;
56   fTrackIndex = 0;
57   fDigitIndex = 0;
58   fMarker[0] = fMarker[1] = fMarker[2]=0;
59   fMatrix = 0;
60 }
61
62 //_____________________________________________________________________________
63 AliMUONPoints::AliMUONPoints(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   fMatrix = 0;
74 }
75
76 //_____________________________________________________________________________
77 AliMUONPoints::AliMUONPoints(const AliMUONPoints& points)
78   : AliPoints(points)
79 {
80 // Protected copy constructor
81
82   AliFatal("Not implemented.");
83 }
84          
85 //_____________________________________________________________________________
86 AliMUONPoints::~AliMUONPoints()
87 {
88   //
89   // Default destructor
90   //
91   fHitIndex = 0;
92   fTrackIndex = 0;
93   fDigitIndex = 0;
94   for (Int_t i=0;i<3;i++){
95       if (fMarker[i]) delete fMarker[i];
96   }
97   fMatrix = 0;
98 }
99
100 //_____________________________________________________________________________
101 void AliMUONPoints::DumpHit() const
102 {
103   //
104   //   Dump hit corresponding to this point
105   //
106   AliMUONHit *hit = GetHit();
107   if (hit) hit->Dump();
108 }
109
110 //_____________________________________________________________________________
111 void AliMUONPoints::DumpDigit() const
112 {
113   //
114   //   Dump digit corresponding to this point
115   //
116   AliMUONDigit *digit = GetDigit();
117   if (digit) digit->Dump();
118 }
119
120 //_____________________________________________________________________________
121 void AliMUONPoints::InspectHit()
122 {
123   //
124   //   Inspect hit corresponding to this point
125   //
126
127   if (fHitIndex < 0 ) return;
128   TVirtualPad *padsav = gPad;
129   AliMUONHit *hit = GetHit();
130   if (hit) hit->Inspect();
131   TVirtualPad *padinspect = (TVirtualPad*)(gROOT->GetListOfCanvases())->FindObject("inspect");
132    padinspect->cd();
133    Float_t xmin = gPad->GetX1();
134    Float_t xmax = gPad->GetX2();
135    Float_t ymin = gPad->GetY1();
136    Float_t ymax = gPad->GetY2();
137    Float_t dy   = ymax-ymin;
138
139       TPaveText *pad = new TPaveText(xmin, ymin+0.1*dy, xmax, ymin+0.15*dy);
140       pad->SetBit(kCanDelete);
141       pad->SetFillColor(42);
142       pad->Draw();
143       char ptitle[100];
144       sprintf(ptitle," %s , fTrack: %d  fTrackIndex: %d ",GetName(),fIndex,fTrackIndex);
145       pad->AddText(ptitle);
146       padinspect->cd();
147       padinspect->Update();
148   if (padsav) padsav->cd();
149
150 }
151
152 //_____________________________________________________________________________
153 void AliMUONPoints::InspectDigit()
154 {
155   //
156   //   Inspect digit corresponding to this point
157   //
158   if (fDigitIndex < 0) return;
159   TVirtualPad *padsav = gPad;
160   AliMUONDigit *digit = GetDigit();
161   if (digit) digit->Inspect();
162   TVirtualPad *padinspect = (TVirtualPad*)(gROOT->GetListOfCanvases())->FindObject("inspect");
163    padinspect->cd();
164    Float_t xmin = gPad->GetX1();
165    Float_t xmax = gPad->GetX2();
166    Float_t ymin = gPad->GetY1();
167    Float_t ymax = gPad->GetY2();
168    Float_t dy   = ymax-ymin;
169
170       TPaveText *pad = new TPaveText(xmin, ymin+0.1*dy, xmax, ymin+0.25*dy);
171       pad->SetBit(kCanDelete);
172       pad->SetFillColor(42);
173       pad->Draw();
174       char ptitle[11][100];
175       //      sprintf(ptitle[11],"Tracks making this digit");
176       //      pad->AddText(ptitle[11]);
177   for (int i=0;i<10;i++) {
178       if (digit->Track(i) == 0) continue;  
179       sprintf(ptitle[i],"fTrackIndex: %d  Charge: %d",
180               digit->Track(i), digit->TrackCharge(i));
181       pad->AddText(ptitle[i]);
182   }
183       padinspect->cd();
184       padinspect->Update();
185   if (padsav) padsav->cd();
186       
187 }
188
189 //_____________________________________________________________________________
190 Int_t AliMUONPoints::GetTrackIndex() const
191 {
192   //
193   //   Dump digit corresponding to this point
194   //
195
196   Inspect();
197   /*
198   if (fDigitIndex != 0) {
199     Int_t ncol=this->fMatrix->GetNcols();
200     for (int i=0;i<ncol;i++) {
201         printf(" track charge %f %f \n",(*(this->fMatrix))(0,i),(*(this->fMatrix))(1,i));
202     }
203   }
204   */
205   return fTrackIndex;
206 }
207
208 //_____________________________________________________________________________
209 AliMUONHit *AliMUONPoints::GetHit() const
210 {
211   //
212   //   Returns pointer to hit index in AliRun::fParticles
213   //
214   AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");
215   
216   pMUON->TreeH()->GetEvent(fTrackIndex);
217   TClonesArray *muonHits  = pMUON->Hits();
218   Int_t nhits = muonHits->GetEntriesFast();
219   if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
220   return (AliMUONHit*)muonHits->UncheckedAt(fHitIndex);
221 }
222
223 //_____________________________________________________________________________
224 AliMUONDigit *AliMUONPoints::GetDigit() const
225 {
226   //
227   //   Returns pointer to digit index in AliRun::fParticles
228   //
229
230   AliMUONDisplay *display=(AliMUONDisplay*)gAlice->Display();
231   Int_t chamber=display->GetChamber();
232    
233   AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");
234   TClonesArray *muonDigits  = pMUON->GetMUONData()->Digits(chamber-1);
235   pMUON->GetMUONData()->GetDigits();
236   //gAlice->TreeD()->GetEvent(cathode);
237   Int_t ndigits = muonDigits->GetEntriesFast();
238   if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
239   return (AliMUONDigit*)muonDigits->UncheckedAt(fDigitIndex);
240 }
241 //_____________________________________________________________________________
242
243 AliMUONPoints& AliMUONPoints::operator= (const AliMUONPoints& rhs)
244 {
245 // Protected assignement operator
246
247   if (this == &rhs) return *this;
248
249   AliFatal("Not implemented.");
250     
251   return *this;  
252 }