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