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