]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONPoints.cxx
DIPO added
[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 <TClonesArray.h>
32 #include <TROOT.h>
33 #include <TPolyMarker3D.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 /// \cond CLASSIMP
47 ClassImp(AliMUONPoints)
48 /// \endcond
49
50 //_____________________________________________________________________________
51 AliMUONPoints::AliMUONPoints()
52   : AliPoints(),
53     fHitIndex(0),
54     fTrackIndex(0),
55     fDigitIndex(0),
56     fMatrix(0)
57
58 {
59   /// Default constructor
60
61   fMarker[0] = fMarker[1] = fMarker[2]=0;
62 }
63
64 //_____________________________________________________________________________
65 AliMUONPoints::AliMUONPoints(Int_t npoints)
66   : AliPoints(npoints),
67     fHitIndex(0),
68     fTrackIndex(0),
69     fDigitIndex(0),
70     fMatrix(0)
71 {
72   /// Standard constructor
73
74   fMarker[0] = fMarker[1] = fMarker[2]=0;
75 }
76
77 //_____________________________________________________________________________
78 AliMUONPoints::~AliMUONPoints()
79 {
80   /// Destructor
81
82   fHitIndex = 0;
83   fTrackIndex = 0;
84   fDigitIndex = 0;
85   for (Int_t i=0;i<3;i++){
86       if (fMarker[i]) delete fMarker[i];
87   }
88   fMatrix = 0;
89 }
90
91 //_____________________________________________________________________________
92 void AliMUONPoints::DumpHit() const
93 {
94   /// Dump hit corresponding to this point
95  
96   AliMUONHit *hit = GetHit();
97   if (hit) hit->Dump();
98 }
99
100 //_____________________________________________________________________________
101 void AliMUONPoints::DumpDigit() const
102 {
103   /// Dump digit corresponding to this point
104
105   AliMUONDigit *digit = GetDigit();
106   if (digit) digit->Dump();
107 }
108
109 //_____________________________________________________________________________
110 void AliMUONPoints::InspectHit()
111 {
112   /// Inspect hit corresponding to this point
113
114   if (fHitIndex < 0 ) return;
115   TVirtualPad *padsav = gPad;
116   AliMUONHit *hit = GetHit();
117   if (hit) hit->Inspect();
118   TVirtualPad *padinspect = (TVirtualPad*)(gROOT->GetListOfCanvases())->FindObject("inspect");
119    padinspect->cd();
120    Float_t xmin = gPad->GetX1();
121    Float_t xmax = gPad->GetX2();
122    Float_t ymin = gPad->GetY1();
123    Float_t ymax = gPad->GetY2();
124    Float_t dy   = ymax-ymin;
125
126       TPaveText *pad = new TPaveText(xmin, ymin+0.1*dy, xmax, ymin+0.15*dy);
127       pad->SetBit(kCanDelete);
128       pad->SetFillColor(42);
129       pad->Draw();
130       char ptitle[100];
131       sprintf(ptitle," %s , fTrack: %d  fTrackIndex: %d ",GetName(),fIndex,fTrackIndex);
132       pad->AddText(ptitle);
133       padinspect->cd();
134       padinspect->Update();
135   if (padsav) padsav->cd();
136
137 }
138
139 //_____________________________________________________________________________
140 void AliMUONPoints::InspectDigit()
141 {
142   /// Inspect digit corresponding to this point
143
144   if (fDigitIndex < 0) return;
145   TVirtualPad *padsav = gPad;
146   AliMUONDigit *digit = GetDigit();
147   if (digit) digit->Inspect();
148   TVirtualPad *padinspect = (TVirtualPad*)(gROOT->GetListOfCanvases())->FindObject("inspect");
149    padinspect->cd();
150    Float_t xmin = gPad->GetX1();
151    Float_t xmax = gPad->GetX2();
152    Float_t ymin = gPad->GetY1();
153    Float_t ymax = gPad->GetY2();
154    Float_t dy   = ymax-ymin;
155
156       TPaveText *pad = new TPaveText(xmin, ymin+0.1*dy, xmax, ymin+0.25*dy);
157       pad->SetBit(kCanDelete);
158       pad->SetFillColor(42);
159       pad->Draw();
160       char ptitle[11][100];
161       //      sprintf(ptitle[11],"Tracks making this digit");
162       //      pad->AddText(ptitle[11]);
163   for (int i=0;i<digit->Ntracks();i++) {
164       if (digit->Track(i) == 0) continue;  
165       sprintf(ptitle[i],"fTrackIndex: %d  Charge: %e",
166               digit->Track(i), digit->TrackCharge(i));
167       pad->AddText(ptitle[i]);
168   }
169       padinspect->cd();
170       padinspect->Update();
171   if (padsav) padsav->cd();
172       
173 }
174
175 //_____________________________________________________________________________
176 Int_t AliMUONPoints::GetTrackIndex() const
177 {
178   /// Dump digit corresponding to this point
179
180   Inspect();
181   /*
182   if (fDigitIndex != 0) {
183     Int_t ncol=this->fMatrix->GetNcols();
184     for (int i=0;i<ncol;i++) {
185         printf(" track charge %f %f \n",(*(this->fMatrix))(0,i),(*(this->fMatrix))(1,i));
186     }
187   }
188   */
189   return fTrackIndex;
190 }
191
192 //_____________________________________________________________________________
193 AliMUONHit *AliMUONPoints::GetHit() const
194 {
195   /// Returns pointer to hit index in AliRun::fParticles
196
197   AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");
198   
199   pMUON->TreeH()->GetEvent(fTrackIndex);
200   TClonesArray *muonHits  = pMUON->Hits();
201   Int_t nhits = muonHits->GetEntriesFast();
202   if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
203   return (AliMUONHit*)muonHits->UncheckedAt(fHitIndex);
204 }
205
206 //_____________________________________________________________________________
207 AliMUONDigit *AliMUONPoints::GetDigit() const
208 {
209   /// Returns pointer to digit index in AliRun::fParticles
210
211   AliMUONDisplay *display=(AliMUONDisplay*)gAlice->Display();
212   Int_t chamber=display->GetChamber();
213    
214   AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");
215   TClonesArray *muonDigits  = pMUON->GetMUONData()->Digits(chamber-1);
216   pMUON->GetMUONData()->GetDigits();
217   //gAlice->TreeD()->GetEvent(cathode);
218   Int_t ndigits = muonDigits->GetEntriesFast();
219   if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
220   return (AliMUONDigit*)muonDigits->UncheckedAt(fDigitIndex);
221 }