]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDDisplay.h
Updates for better DQM.
[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   /** 
39    * Constructor
40    *
41    * @param onlyFMD Only show the FMD
42    * @param gAliceFile galice file
43    */
44   AliFMDDisplay(Bool_t onlyFMD=kTRUE, const char* gAliceFile="galice.root");
45   /** 
46    * DTOR 
47    */
48   virtual ~AliFMDDisplay();
49   /** 
50    * Singleton access function
51    *
52    * @return Singleton object. 
53    */
54   static AliFMDDisplay* Instance();
55
56   /** 
57    * Continue to next event 
58    */
59   void  Continue() { fWait = kFALSE; }
60   /** 
61    * Run throug events as fast as possible 
62    */ 
63   void Start() { fContinous = kTRUE; fWait = kFALSE; }
64   /** 
65    * Pause the processing 
66    */ 
67   void Pause() { fContinous = kFALSE; fWait = kTRUE; }
68   /** 
69    * Zoom mode 
70    */
71   void  Zoom() { fZoomMode = kTRUE; }
72   /** 
73    * Pick mode 
74    */
75   void  Pick() { fZoomMode = kFALSE; }
76   /** 
77    * Redisplay the event 
78    */ 
79   virtual void Redisplay(); // *MENU*
80   /** 
81    * Break 
82    */
83   virtual void Break();
84   /** 
85    * Render in 3D 
86    */
87   virtual void Render();
88   
89   /** 
90    * Change cut 
91    */
92   virtual void ChangeCut();
93   /** 
94    * Change cut 
95    */
96   virtual void ChangeFactor();
97   /** 
98    * Called when a mouse or similar event happens in the display. 
99    *
100    * @param event Event type
101    * @param px    where the event happened in pixels along X
102    * @param py    where the event happened in pixels along Y 
103    */
104   virtual void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
105   /** 
106    * Paint into canvas 
107    *
108    * @param option Not used 
109    */
110   virtual void  Paint(Option_t* option="") { (void)option; }
111
112   /** 
113    * Initialize
114    *
115    * @return  @c false on error 
116    */
117   virtual Bool_t Init();
118   /** 
119    * Called at beginning of an event 
120    * 
121    * @param event Event number
122    * @return @c false on error  
123    */
124   virtual Bool_t Begin(Int_t event);
125   /** 
126    * Called at end of an event 
127    *
128    * @return @c false on error  
129    */
130   virtual Bool_t End();
131   /** 
132    * Visualize a hit
133    *
134    * @param hit Hit
135    * @param p   Track
136    * @return @c false on error  
137    */
138   virtual Bool_t ProcessHit(AliFMDHit* hit, TParticle* p);
139   /** 
140    * Visualize a digit
141    *
142    * @param digit Digit to draw
143    * @return @c false on error  
144    */
145   virtual Bool_t ProcessDigit(AliFMDDigit* digit);
146   /** 
147    * Visualize a summable digit
148    *
149    * @param sdigit Summable digit to draw
150    * @return @c false on error  
151    */
152   virtual Bool_t ProcessSDigit(AliFMDSDigit* sdigit);
153   /** 
154    * Visualize a raw digit
155    *
156    * @param digit Raw digit.
157    * @return @c false on error  
158    */
159   virtual Bool_t ProcessRawDigit(AliFMDDigit* digit);
160   /** 
161    * Visualize a raw digit
162    * 
163    * @param digit Raw digit.
164    * @return @c false on error  
165    */
166   virtual Bool_t ProcessRawCalibDigit(AliFMDDigit* digit);
167   /** 
168    * Visualize a reconstructed point.
169    *
170    * @param recpoint Reconstructed point
171    * @return @c false on error  
172    */
173   virtual Bool_t ProcessRecPoint(AliFMDRecPoint* recpoint);
174   /** 
175    * Process ESD data for the FMD.  Users should overload this to
176    * deal with ESD data. 
177    *
178    * @param d    Detector number (1-3)
179    * @param r    Ring identifier ('I' or 'O')
180    * @param s    Sector number (0-19, or 0-39)
181    * @param t    Strip number (0-511, or 0-255)
182    * @param eta  Psuedo-rapidity 
183    * @param mult Psuedo-multiplicity 
184    * 
185    * @return  @c false on error  
186    */
187   virtual Bool_t ProcessESD(UShort_t d, Char_t r, UShort_t s, UShort_t t, 
188                             Float_t eta, Float_t mult);
189   /** 
190    * Look up a color index, based on the value @a x and the maximum
191    * value of @a x
192    *
193    * @param x   Value 
194    * @param max Maximum (for example 1023 for digits)
195    * @return @c false on error  
196    */
197   virtual Int_t  LookupColor(Float_t x, Float_t min, Float_t max)  const;
198
199   /** 
200    * Set range of displayed values 
201    */
202   virtual void SetCut(Float_t l=0., Float_t h=1.); //*MENU*
203   /** 
204    * Set the noise factor
205    * 
206    * @param f  Noise factor 
207    */
208   virtual void SetFactor(Float_t f=1);
209 protected:
210   /** 
211    * Copy constructor 
212    *
213    * @param o Object to copy from  
214    */
215   AliFMDDisplay(const AliFMDDisplay& o) 
216     : AliFMDInput(o),
217       fWait(kFALSE),
218       fMarkers(0),
219       fHits(0),
220       fCanvas(0),
221       fPad(0),
222       fButtons(0),
223       fSlider(0),
224       fFactor(0),
225       fZoomMode(0),
226       fX0(0),
227       fY0(0),
228       fX1(0),
229       fY1(0),
230       fXPixel(0),
231       fYPixel(0),
232       fOldXPixel(0),
233       fOldYPixel(0),
234       fLineDrawn(0), 
235       fOnlyFMD(kTRUE),
236       fSpec(0), 
237       fSpecCut(0),
238       fAux(0),
239       fReturn(kFALSE),
240       fContinous(kFALSE), 
241       fTimeout(), 
242       fInitialMin(0), 
243       fInitialMax(1), 
244       fInitialFactor(3./10)
245   { } 
246   /** 
247    * Assignment operator 
248    *
249    * @return Reference to this object 
250    */
251   AliFMDDisplay& operator=(const AliFMDDisplay&) { return *this; } 
252   /** 
253    * Add a marker to the display
254    *
255    * @param x   X position
256    * @param y   Y position
257    * @param z   Z position
258    * @param o   Object to refer to
259    * @param s   Signal 
260    * @param max Maximum of signal 
261    */
262   virtual void AddMarker(Float_t x, Float_t y, Float_t z, 
263                          TObject* o, Float_t s, Float_t min, Float_t max);
264   /** 
265    * Add a marker to the display
266    *
267    * @param det Detector
268    * @param rng Ring
269    * @param sec Sector 
270    * @param str Strip
271    * @param o   Object to refer to
272    * @param s   Signal 
273    * @param max Maximum of signal 
274    */
275   virtual void AddMarker(UShort_t det, Char_t rng, UShort_t sec, UShort_t str, 
276                          TObject* o, Float_t s, Float_t min, Float_t max);
277   
278   /** 
279    * Show only the FMD detectors. 
280    */
281   void ShowOnlyFMD();
282   /** 
283    * Make base canvas 
284    */ 
285   virtual void MakeCanvas(const char** which);
286   /** 
287    * Make AUX canvas 
288    * 
289    */
290   virtual void MakeAux();
291   /** 
292    * Draw AUX canvas 
293    * 
294    */
295   virtual void DrawAux();
296   /** 
297    * Set the ROOT event loop to idle 
298    * 
299    */
300   virtual void Idle();
301   /** 
302    * Called at end of event loop
303    * 
304    */
305   virtual void AtEnd();
306   /** 
307    * Whether a point is inside 
308    * 
309    * @param v   Point
310    * @param min Minimum
311    * @param max Maximum
312    * 
313    * @return true if @a v is inside cut 
314    */
315   virtual Bool_t InsideCut(Float_t v, const Float_t& min, 
316                          const Float_t& max) const;
317   /** 
318    * Get the ADC threshold
319    * 
320    * @param d Detector
321    * @param r Ring 
322    * @param s Sector 
323    * @param t Strip 
324    * 
325    * @return The threshold 
326    */
327   virtual Double_t GetADCThreshold(UShort_t d, Char_t r, 
328                                    UShort_t s, UShort_t t) const;
329   
330   static AliFMDDisplay* fgInstance; // Static instance 
331   Bool_t                fWait;      // Wait until user presses `Continue'
332   TObjArray*            fMarkers;   // Cache of markers
333   TObjArray*            fHits;      // Cache of `hits'
334   TCanvas*              fCanvas;    // Canvas to draw in 
335   TPad*                 fPad;       // View pad. 
336   TObjArray             fButtons;   // Continue button
337   TSlider*              fSlider;    // Cut slider
338   TSlider*              fFactor;    // Factor slider
339   Bool_t                fZoomMode;  // Whether we're in Zoom mode
340   Float_t               fX0;        // X at lower left corner or range 
341   Float_t               fY0;        // Y at lower left corner or range 
342   Float_t               fX1;        // X at upper right corner or range 
343   Float_t               fY1;        // Y at upper right corner or range 
344   Int_t                 fXPixel;    // X pixel of mark
345   Int_t                 fYPixel;    // Y pixel of mark
346   Int_t                 fOldXPixel; // Old x pixel of mark
347   Int_t                 fOldYPixel; // Old y pixel of mark
348   Bool_t                fLineDrawn; // Whether we're drawing a box
349   Bool_t                fOnlyFMD;   // Whether to only do FMD
350   TH1*                  fSpec;      // Spectra
351   TH1*                  fSpecCut;   // Cut spectra
352   TCanvas*              fAux;       // Aux canvas.
353   Bool_t                fReturn;    // Stop 
354   Bool_t                fContinous; // Run continuous - do not stop
355   TTimer                fTimeout;   // Timeout 
356   Float_t               fInitialMin;// Initial minimum
357   Float_t               fInitialMax;// Initial maximum
358   Float_t               fInitialFactor;//Initial factor 
359
360   struct Range_t { 
361     UInt_t  fNbins;  // Number of bins
362     Float_t fLow;    // Low cut
363     Float_t fHigh;   // High cut
364   };
365   static const Range_t fgkEdepRange; // Energy loss range
366   static const Range_t fgkAdcRange;  // ADC counts range 
367   static const Range_t fgkMultRange; // Multiplicity range 
368
369   ClassDef(AliFMDDisplay,0)  // FMD specialised event display
370 };
371
372 #endif
373 //____________________________________________________________________
374 //
375 // Local Variables:
376 //   mode: C++
377 // End:
378 //
379 // EOF
380 //