]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDDisplay.h
Matching new and delete of arrays
[u/mrichter/AliRoot.git] / FMD / AliFMDDisplay.h
1 #ifndef AliFMDDISPLAY_H
2 #define AliFMDDISPLAY_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
4  * reserved. 
5  *
6  * See cxx source for full Copyright notice                               
7  */
8 /** @file    AliFMDDisplay.h
9     @author  Christian Holm Christensen <cholm@nbi.dk>
10     @date    Mon Mar 27 12:39:09 2006
11     @brief   FMD Event display 
12 */
13 //___________________________________________________________________
14 //
15 // The classes defined here, are utility classes for reading in data
16 // for the FMD.  They are  put in a seperate library to not polute the
17 // normal libraries.  The classes are intended to be used as base
18 // classes for customized class that do some sort of analysis on the
19 // various types of data produced by the FMD. 
20 //
21 #include "AliFMDInput.h"
22 #include <TObjArray.h>
23 #include <TTimer.h>
24 class TCanvas;
25 class TPad;
26 class TButton;
27 class TSlider;
28 class TH1;
29
30 //___________________________________________________________________
31 /** @class AliFMDDisplay 
32     @brief Utility class to visualize FMD data in geometry. 
33     @ingroup FMD_util
34  */
35 class AliFMDDisplay : public AliFMDInput
36 {
37 public:
38   /** Constructor
39       @param onlyFMD Only show the FMD
40       @param gAliceFile galice file*/
41   AliFMDDisplay(Bool_t onlyFMD=kTRUE, const char* gAliceFile="galice.root");
42   /** DTOR */
43   virtual ~AliFMDDisplay();
44   /** Singleton access function
45       @return Singleton object. */
46   static AliFMDDisplay* Instance();
47
48   /** Continue to next event */
49   void  Continue() { fWait = kFALSE; }
50   /** Run throug events as fast as possible */ 
51   void Start() { fContinous = kTRUE; fWait = kFALSE; }
52   /** Pause the processing */ 
53   void Pause() { fContinous = kFALSE; fWait = kTRUE; }
54   /** Zoom mode */
55   void  Zoom() { fZoomMode = kTRUE; }
56   /** Pick mode */
57   void  Pick() { fZoomMode = kFALSE; }
58   /** Redisplay the event */ 
59   virtual void Redisplay(); // *MENU*
60   /** Break */
61   virtual void Break();
62   /** Render in 3D */
63   virtual void Render();
64   
65   /** Change cut */
66   virtual void ChangeCut();
67   /** Change cut */
68   virtual void ChangeFactor();
69   /** Called when a mouse or similar event happens in the display. 
70       @param event Event type
71       @param px    where the event happened in pixels along X
72       @param py    where the event happened in pixels along Y */
73   virtual void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
74   /** Calculate distance from point @f$ (p_x,p_y)@f$ to this object. 
75       @param px Pixel X coordinate 
76       @param py Pixel Y coordinate 
77       @return distance. */
78   virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
79   /** Paint into canvas 
80       @param option Not used */
81   virtual void  Paint(Option_t* option="") { (void)option; }
82
83   /** Initialize
84       @return  @c false on error */
85   virtual Bool_t Init();
86   /** Called at beginning of an event 
87       @param event Event number
88       @return @c false on error  */
89   virtual Bool_t Begin(Int_t event);
90   /** Called at end of an event 
91       @return @c false on error  */
92   virtual Bool_t End();
93   /** Visualize a hit
94       @param hit Hit
95       @param p   Track
96       @return @c false on error  */
97   virtual Bool_t ProcessHit(AliFMDHit* hit, TParticle* p);
98   /** Visualize a digit
99       @param digit Digit to draw
100       @return @c false on error  */
101   virtual Bool_t ProcessDigit(AliFMDDigit* digit);
102   /** Visualize a summable digit
103       @param sdigit Summable digit to draw
104       @return @c false on error  */
105   virtual Bool_t ProcessSDigit(AliFMDSDigit* sdigit);
106   /** Visualize a raw digit
107       @param digit Raw digit.
108       @return @c false on error  */
109   virtual Bool_t ProcessRawDigit(AliFMDDigit* digit);
110   /** Visualize a reconstructed point.
111       @param recpoint Reconstructed point
112       @return @c false on error  */
113   virtual Bool_t ProcessRecPoint(AliFMDRecPoint* recpoint);
114   /** Process ESD data for the FMD.  Users should overload this to
115       deal with ESD data. 
116       @param d    Detector number (1-3)
117       @param r    Ring identifier ('I' or 'O')
118       @param s    Sector number (0-19, or 0-39)
119       @param t    Strip number (0-511, or 0-255)
120       @param eta  Psuedo-rapidity 
121       @param mult Psuedo-multiplicity 
122       @return  @c false on error  */
123   virtual Bool_t ProcessESD(UShort_t d, Char_t r, UShort_t s, UShort_t t, 
124                             Float_t eta, Float_t mult);
125   /** Look up a color index, based on the value @a x and the maximum
126       value of @a x
127       @param x   Value 
128       @param max Maximum (for example 1023 for digits)
129       @return @c false on error  */
130   virtual Int_t  LookupColor(Float_t x, Float_t min, Float_t max)  const;
131
132   /** Set range of displayed values */
133   virtual void SetCut(Float_t l=0., Float_t h=1.); //*MENU*
134 protected:
135   /** Copy constructor 
136       @param o Object to copy from  */
137   AliFMDDisplay(const AliFMDDisplay& o) 
138     : AliFMDInput(o),
139       fWait(kFALSE),
140       fMarkers(0),
141       fHits(0),
142       fCanvas(0),
143       fPad(0),
144       fButtons(0),
145       fSlider(0),
146       fFactor(0),
147       fZoomMode(0),
148       fX0(0),
149       fY0(0),
150       fX1(0),
151       fY1(0),
152       fXPixel(0),
153       fYPixel(0),
154       fOldXPixel(0),
155       fOldYPixel(0),
156       fLineDrawn(0), 
157       fOnlyFMD(kTRUE),
158       fSpec(0), 
159       fSpecCut(0),
160       fAux(0),
161       fReturn(kFALSE),
162       fContinous(kFALSE), 
163       fTimeout()
164   { } 
165   /** Assignment operator 
166       @return Reference to this object */
167   AliFMDDisplay& operator=(const AliFMDDisplay&) { return *this; } 
168   /** Add a marker to the display
169       @param x   X position
170       @param y   Y position
171       @param z   Z position
172       @param o   Object to refer to
173       @param s   Signal 
174       @param max Maximum of signal */
175   virtual void AddMarker(Float_t x, Float_t y, Float_t z, 
176                          TObject* o, Float_t s, Float_t min, Float_t max);
177   /** Add a marker to the display
178       @param det Detector
179       @param rng Ring
180       @param sec Sector 
181       @param str Strip
182       @param o   Object to refer to
183       @param s   Signal 
184       @param max Maximum of signal */
185   virtual void AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str, 
186                          TObject* o, Float_t s, Float_t min, Float_t max);
187   
188   /** Show only the FMD detectors. */
189   void ShowOnlyFMD();
190   /** Make base canvas */ 
191   virtual void MakeCanvas(const char** which);
192   virtual void MakeAux();
193   virtual void DrawAux();
194   virtual void Idle();
195   virtual void AtEnd();
196   virtual Bool_t InsideCut(Float_t v, const Float_t& min, 
197                          const Float_t& max) const;
198   
199   static AliFMDDisplay* fgInstance; // Static instance 
200   Bool_t                fWait;      // Wait until user presses `Continue'
201   TObjArray*            fMarkers;   // Cache of markers
202   TObjArray*            fHits;      // Cache of `hits'
203   TCanvas*              fCanvas;    // Canvas to draw in 
204   TPad*                 fPad;       // View pad. 
205   TObjArray             fButtons;   // Continue button
206   TSlider*              fSlider;    // Cut slider
207   TSlider*              fFactor;    // Factor slider
208   Bool_t                fZoomMode;  // Whether we're in Zoom mode
209   Float_t               fX0;        // X at lower left corner or range 
210   Float_t               fY0;        // Y at lower left corner or range 
211   Float_t               fX1;        // X at upper right corner or range 
212   Float_t               fY1;        // Y at upper right corner or range 
213   Int_t                 fXPixel;    // X pixel of mark
214   Int_t                 fYPixel;    // Y pixel of mark
215   Int_t                 fOldXPixel; // Old x pixel of mark
216   Int_t                 fOldYPixel; // Old y pixel of mark
217   Bool_t                fLineDrawn; // Whether we're drawing a box
218   Bool_t                fOnlyFMD;   // Whether to only do FMD
219   TH1*                  fSpec;      // Spectra
220   TH1*                  fSpecCut;   // Cut spectra
221   TCanvas*              fAux;       // Aux canvas.
222   Bool_t                fReturn;    // Stop 
223   Bool_t                fContinous;
224   TTimer                fTimeout;
225   
226
227   struct Range_t { 
228     UInt_t  fNbins;
229     Float_t fLow;
230     Float_t fHigh;
231   };
232   static const Range_t fgkEdepRange;
233   static const Range_t fgkAdcRange;
234   static const Range_t fgkMultRange;
235
236   ClassDef(AliFMDDisplay,0)  // FMD specialised event display
237 };
238
239 #endif
240 //____________________________________________________________________
241 //
242 // Local Variables:
243 //   mode: C++
244 // End:
245 //
246 // EOF
247 //