]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONPoints.cxx
Switches for each station individually for debug and lego.
[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 $Log$
17 Revision 1.5  2000/10/02 21:28:09  fca
18 Removal of useless dependecies via forward declarations
19
20 Revision 1.4  2000/07/03 11:54:57  morsch
21 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
22 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
23
24 Revision 1.3  2000/06/27 10:13:01  morsch
25 Obsolete global variables removed from file.
26
27 Revision 1.2  2000/06/15 07:58:48  morsch
28 Code from MUON-dev joined
29
30 Revision 1.1.2.6  2000/06/09 21:57:40  morsch
31 Most coding rule violations corrected.
32
33 Revision 1.1.2.5  2000/05/05 11:33:56  morsch
34 Log inside comments.
35
36 Revision 1.1.2.4  2000/05/05 10:12:09  morsch
37 Log messages included
38 */
39
40 ///////////////////////////////////////////////////////////////////////////////
41 //                                                                           //
42 //  This class contains the points for the ALICE event display               //
43 //                                                                           //
44 //Begin_Html
45 /*
46 <img src="gif/AliMUONPointsClass.gif">
47 */
48 //End_Html
49 //                                                                           //
50 //                                                                           //
51 ///////////////////////////////////////////////////////////////////////////////
52
53 #include "AliMUONPoints.h"
54 #include "AliMUONDisplay.h"
55 #include "AliRun.h"
56 #include "AliMUON.h"
57 #include "AliMUONChamber.h"
58 #include "AliMUONResponse.h"
59 #include "AliMUONHit.h"
60 #include "AliMUONPadHit.h"
61 #include "AliMUONDigit.h"
62 #include "AliMUONRawCluster.h"
63
64
65 #include <TROOT.h>
66 #include <TTree.h>
67 #include <TPolyMarker3D.h>
68 #include <TMatrix.h>
69 #include <TPad.h>
70 #include <TVirtualPad.h>
71 #include <TPolyLine3D.h>
72 #include <TPaveText.h>
73 #include <TView.h>
74 #include <TMath.h>
75 #include <TMarker3DBox.h>
76  
77 ClassImp(AliMUONPoints)
78
79 //_____________________________________________________________________________
80 AliMUONPoints::AliMUONPoints()
81 {
82   //
83   // Default constructor
84   //
85   fHitIndex = 0;
86   fTrackIndex = 0;
87   fDigitIndex = 0;
88   fMarker[0] = fMarker[1] = fMarker[2]=0;
89   fMatrix = 0;
90 }
91
92 //_____________________________________________________________________________
93 AliMUONPoints::AliMUONPoints(Int_t npoints)
94   :AliPoints(npoints)
95 {
96   //
97   // Standard constructor
98   //
99   fHitIndex = 0;
100   fTrackIndex = 0;
101   fDigitIndex = 0;
102   fMarker[0] = fMarker[1] = fMarker[2]=0;
103   fMatrix = 0;
104 }
105
106 AliMUONPoints::AliMUONPoints(const AliMUONPoints& points)
107 {
108 // Copy constructor
109 }
110          
111 //_____________________________________________________________________________
112 AliMUONPoints::~AliMUONPoints()
113 {
114   //
115   // Default destructor
116   //
117   fHitIndex = 0;
118   fTrackIndex = 0;
119   fDigitIndex = 0;
120   for (Int_t i=0;i<3;i++){
121       if (fMarker[i]) delete fMarker[i];
122   }
123   fMatrix = 0;
124 }
125
126 //_____________________________________________________________________________
127 void AliMUONPoints::DumpHit()
128 {
129   //
130   //   Dump hit corresponding to this point
131   //
132   AliMUONHit *hit = GetHit();
133   if (hit) hit->Dump();
134 }
135
136 //_____________________________________________________________________________
137 void AliMUONPoints::DumpDigit()
138 {
139   //
140   //   Dump digit corresponding to this point
141   //
142   AliMUONDigit *digit = GetDigit();
143   if (digit) digit->Dump();
144 }
145
146 //_____________________________________________________________________________
147 void AliMUONPoints::InspectHit()
148 {
149   //
150   //   Inspect hit corresponding to this point
151   //
152
153   if (fHitIndex < 0 ) return;
154   TVirtualPad *padsav = gPad;
155   AliMUONHit *hit = GetHit();
156   if (hit) hit->Inspect();
157   TVirtualPad *padinspect = (TVirtualPad*)(gROOT->GetListOfCanvases())->FindObject("inspect");
158    padinspect->cd();
159    Float_t xmin = gPad->GetX1();
160    Float_t xmax = gPad->GetX2();
161    Float_t ymin = gPad->GetY1();
162    Float_t ymax = gPad->GetY2();
163    Float_t dy   = ymax-ymin;
164
165       TPaveText *pad = new TPaveText(xmin, ymin+0.1*dy, xmax, ymin+0.15*dy);
166       pad->SetBit(kCanDelete);
167       pad->SetFillColor(42);
168       pad->Draw();
169       char ptitle[100];
170       sprintf(ptitle," %s , fTrack: %d  fTrackIndex: %d ",GetName(),fIndex,fTrackIndex);
171       pad->AddText(ptitle);
172       padinspect->cd();
173       padinspect->Update();
174   if (padsav) padsav->cd();
175
176 }
177
178 //_____________________________________________________________________________
179 void AliMUONPoints::InspectDigit()
180 {
181   //
182   //   Inspect digit corresponding to this point
183   //
184   if (fDigitIndex < 0) return;
185   TVirtualPad *padsav = gPad;
186   AliMUONDigit *digit = GetDigit();
187   if (digit) digit->Inspect();
188   TVirtualPad *padinspect = (TVirtualPad*)(gROOT->GetListOfCanvases())->FindObject("inspect");
189    padinspect->cd();
190    Float_t xmin = gPad->GetX1();
191    Float_t xmax = gPad->GetX2();
192    Float_t ymin = gPad->GetY1();
193    Float_t ymax = gPad->GetY2();
194    Float_t dy   = ymax-ymin;
195
196       TPaveText *pad = new TPaveText(xmin, ymin+0.1*dy, xmax, ymin+0.25*dy);
197       pad->SetBit(kCanDelete);
198       pad->SetFillColor(42);
199       pad->Draw();
200       char ptitle[11][100];
201       //      sprintf(ptitle[11],"Tracks making this digit");
202       //      pad->AddText(ptitle[11]);
203   for (int i=0;i<10;i++) {
204       if (digit->fTracks[i] == 0) continue;  
205       sprintf(ptitle[i],"fTrackIndex: %d  Charge: %d",digit->fTracks[i],digit->fTcharges[i]);
206       pad->AddText(ptitle[i]);
207   }
208       padinspect->cd();
209       padinspect->Update();
210   if (padsav) padsav->cd();
211       
212 }
213
214 //_____________________________________________________________________________
215 Int_t AliMUONPoints::GetTrackIndex()
216 {
217   //
218   //   Dump digit corresponding to this point
219   //
220
221   this->Inspect();
222   /*
223   if (fDigitIndex != 0) {
224     Int_t ncol=this->fMatrix->GetNcols();
225     for (int i=0;i<ncol;i++) {
226         printf(" track charge %f %f \n",(*(this->fMatrix))(0,i),(*(this->fMatrix))(1,i));
227     }
228   }
229   */
230   return fTrackIndex;
231 }
232
233 //_____________________________________________________________________________
234 AliMUONHit *AliMUONPoints::GetHit() const
235 {
236   //
237   //   Returns pointer to hit index in AliRun::fParticles
238   //
239   AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");
240   gAlice->TreeH()->GetEvent(fTrackIndex);
241   TClonesArray *muonHits  = pMUON->Hits();
242   Int_t nhits = muonHits->GetEntriesFast();
243   if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
244   return (AliMUONHit*)muonHits->UncheckedAt(fHitIndex);
245 }
246
247 //_____________________________________________________________________________
248 AliMUONDigit *AliMUONPoints::GetDigit() const
249 {
250   //
251   //   Returns pointer to digit index in AliRun::fParticles
252   //
253
254   AliMUONDisplay *display=(AliMUONDisplay*)gAlice->Display();
255   Int_t chamber=display->GetChamber();
256   Int_t cathode=display->GetCathode();
257    
258   AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");
259   TClonesArray *muonDigits  = pMUON->DigitsAddress(chamber-1);
260   Int_t nent=(Int_t)gAlice->TreeD()->GetEntries();
261   gAlice->TreeD()->GetEvent(nent-2+cathode-1);
262   //gAlice->TreeD()->GetEvent(cathode);
263   Int_t ndigits = muonDigits->GetEntriesFast();
264   if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
265   return (AliMUONDigit*)muonDigits->UncheckedAt(fDigitIndex);
266 }
267 //_____________________________________________________________________________
268
269 AliMUONPoints& AliMUONPoints::operator= (const AliMUONPoints& rhs)
270 {
271     return *this;
272 }