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