source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/common/eventviewer/include/EFocalSurfacePainter.hh @ 117

Last change on this file since 117 was 117, checked in by moretto, 11 years ago

ESAF version compilable on mac OS

File size: 15.2 KB
Line 
1// $Id: EFocalSurfacePainter.hh 3019 2012-03-26 07:52:42Z mabl $
2// A.Thea created Jun, 28 2004
3
4/*****************************************************************************
5 * ESAF: Euso Simulation and Analysis Framework                              *
6 *                                                                           *
7 *  Id: FocalSurfacePainter                                                  *
8 *  Package: EventViewer                                                     *
9 *  Coordinator: Alessandro.Thea                                             *
10 *                                                                           *
11 *****************************************************************************/
12
13#ifndef __EFOCALSURFACEPAINTER_HH__
14#define __EFOCALSURFACEPAINTER_HH__
15
16#include "EAnimator.hh"
17#include <TSeqCollection.h>
18#include <TPolyLine.h>
19#include <TVector3.h>
20#include <TText.h>
21#include <TPaveText.h>
22#include <TStyle.h>
23#include <TGaxis.h>
24#include <map>
25#include <vector>
26#include "Etypes.hh"
27
28
29//////////////////////////////////////////////////////////////////////////////
30//                                                                          //
31//  EFocalSurfacePainter                                                    //
32//                                                                          //
33//  A painter to show the development of the signal on                      //
34//  the focal surface                                                       //
35//                                                                          //
36//////////////////////////////////////////////////////////////////////////////
37
38class EEvent;
39class EDetector;
40class ERunParameters;
41class EPolygon;
42class TH1F;
43
44enum EMapId { kFeeHits    = 1,
45              kFeeSignals = 2,
46              kCellHits   = 3
47            };
48
49enum EIntegral { kIntNone = 1,
50                 kIntSum  = 2,
51                 kIntMax  = 3
52               };
53
54using std::map;
55using std::vector;
56
57typedef map<Int_t, Int_t> Counts_t;
58typedef map<Int_t, Counts_t> GtuCounts_t;
59
60const Counts_t  operator+( const Counts_t&, const Counts_t& );
61      Counts_t& operator+=( Counts_t&, const Counts_t& );
62
63const Counts_t  operator|( const Counts_t&, const Counts_t& );
64      Counts_t& operator|=( Counts_t&, const Counts_t& );
65
66class EFocalSurfacePainter: public EAnimator {
67public:
68    EFocalSurfacePainter();
69    EFocalSurfacePainter( EEvent*  );
70    EFocalSurfacePainter( EDetector *, ERunParameters*  );
71    virtual ~EFocalSurfacePainter();
72
73    virtual   void Clear( Option_t* ="");
74    virtual   void Draw( Option_t* ="");
75    virtual   void Paint( Option_t* ="");
76    virtual  Int_t DistancetoPrimitive(Int_t px, Int_t py);
77    virtual   void ExecuteEvent(Int_t event, Int_t px, Int_t py);
78    virtual  char* GetObjectInfo(Int_t px, Int_t py) const;
79
80    virtual   void Play( Option_t* =""); // *MENU*
81    virtual   void Animate();
82    virtual   void NextFrame(); // *MENU*
83    virtual inline void Rewind() { fGtu = fFirstGtu; } // *MENU*
84    virtual inline Bool_t IsEnded() { return fGtu >= fLastGtu; } 
85
86    inline ERunParameters* GetRunPars() const { return fRunPars; }
87
88    virtual   void FeeHits() { SetCurrentMapID( kFeeHits ); } // *MENU*
89    virtual   void FeeSignals() { SetCurrentMapID( kFeeSignals ); } // *MENU*
90    virtual   void CellHits() { SetCurrentMapID( kCellHits ); } // *MENU*
91    virtual   void ApplyTriggerThreshold( ETriggerTypeIdentifier ); // *MENU*
92    virtual   void Move() { fMoveView = kTRUE; } // *MENU*
93
94    virtual   void CenterViewOnPmt( Int_t ); // *MENU*
95    virtual   void SetViewCenter( Float_t  x, Float_t y) { fViewCenter.SetXYZ(x,y,0); } //*MENU*
96   
97    virtual   void Modified( Bool_t flag=1) { fModified=flag;} 
98
99    Bool_t IsTriggerEnabled( ETriggerTypeIdentifier );
100
101    void MakeGifSequence(const char* option = "", const char* path="Anim");
102   
103    // getters
104    inline Float_t GetAlpha() const { return fAlpha; }
105    inline Int_t   GetCurrentMapID() const { return fCurrentMapID; }
106    inline Int_t   GetFirstGtu() const { return fFirstGtu; }
107    inline Int_t   GetGtu() const { return fGtu; }
108    inline TH1F*   GetHitsHist() const { return fH1Hits; }
109    inline TStyle* GetHitsHistStyle() const { return fHitsStyle; }
110    inline TH1F*   GetSigProfile() const { return fH1SigProfile; }
111    inline TH1F*   GetSigMaxProfile() const { return fH1SigMaxProfile; }
112    inline TH1F*   GetNoiseMaxProfile() const { return fH1NoiseMaxProfile; }
113    inline TH1F*   GetNoiseMinProfile() const { return fH1NoiseMinProfile; }
114    inline TH1F*   GetNoiseMeanProfile() const { return fH1NoiseMeanProfile; }
115    inline TH1F*   GetHitsMaxProfile() const { return fH1HitsMaxProfile; }
116    inline Int_t   GetLastGtu() const { return fLastGtu; }
117    inline const TVector3& GetSpread() const { return fSpread; }
118    inline const TVector3& GetViewCenter() const { return fViewCenter; } 
119    inline Float_t GetViewRange() const { return fViewRange; }
120    inline Int_t   GetViewThreshold() const { return fViewThreshold; }
121   
122    inline Bool_t  IsApplyThreshold() const { return fApplyThreshold; }
123    inline Bool_t  IsAbsoluteThreshold() const { return fAbsoluteThreshold; }
124    inline Bool_t  IsShowAxis() const { return fShowAxis; }
125    inline Bool_t  IsShowEmptyPixels() const { return fShowEmptyPixels; }
126    inline Bool_t  IsShowOffPixels() const { return fShowOffPixels; }
127    inline Bool_t  IsShowPixelBorder() const { return fShowPixelBorder;}
128    inline Bool_t  IsShowGtuCounter() const { return fShowGtuCounter; }
129    inline Bool_t  IsDrawNightGlow() const { return fDrawNightGlow; }
130    inline Bool_t  IsStdPalette() const { return fStdPalette; }
131    inline Int_t   GetIntegral() const { return fIntegral; }
132    inline Int_t   GetCurrentTrigger() const { return fCurrentTrigger; }
133
134    inline UInt_t  GetNumColors() const { return fNumColors; }
135    inline UInt_t  GetMaxCounts() const { return fMaxCounts; }
136
137    inline Color_t GetPixelColorEmpty() const { return fPixelColorEmpty; }
138    inline Color_t GetPixelColorOff() const { return fPixelColorOff; }
139    inline Color_t GetPmtColorEmpty() const { return fPmtColorEmpty; }
140    inline Color_t GetPmtColorHit() const { return fPmtColorHit; }
141   
142    // setters
143    void SetAlpha( Float_t alpha ) { fAlpha = alpha; if (fAlpha<0) { SetApplyThreshold(kFALSE); fAlpha=0; } PaintHits(); } // *MENU*
144    void SetApplyThreshold( Bool_t apply = kTRUE ) { fApplyThreshold = apply; if (!apply) fAlpha=0; PaintHits(); } // *TOGGLE*
145    void SetAbsoluteThreshold( Bool_t t = kTRUE ) { fAbsoluteThreshold = t; PaintHits(); } // *TOGGLE*
146    inline void    SetCurrentMapID( Int_t id ) { fCurrentMapID = id; }
147    inline void    SetPaletteOffset( Color_t c ) { fPaletteOffset = c; }
148    inline void    SetFirstGtu( Int_t gtu ) { fFirstGtu = gtu; }
149    inline void    SetGtu( Int_t gtu ) { fGtu = gtu; } // *MENU*
150    inline void    SetHitsHistStyle( TStyle* sty ) {  SafeDelete(fHitsStyle); fHitsStyle = sty; }
151    inline void    SetLastGtu( Int_t gtu ) { fLastGtu = gtu; }
152    inline void    SetMaxCounts( UInt_t n ) { fMaxCounts = n; UpdateHist(); }  // *MENU*
153    inline void    SetNumColors( UInt_t n ) { fNumColors = n; }          // *MENU*
154    inline void    SetPixelEmptyColor( Color_t c ) { fPixelColorEmpty = c; }
155    inline void    SetPixelOffColor( Color_t c ) { fPixelColorOff = c; }
156    inline void    SetPmtColorEmpty( Color_t c ) { fPmtColorEmpty = c; }
157    inline void    SetPmtColorHit( Color_t c ) { fPmtColorHit = c; }
158    inline void    SetStdPalette( Bool_t std = kTRUE ) { fStdPalette = std; } // *TOGGLE*
159    inline void    SetShowAxis( Bool_t show = kTRUE ) { fShowAxis = show; } // *TOGGLE*
160    inline void    SetShowGtuCounter( Bool_t show = kTRUE ) { fShowGtuCounter = show; }     // *TOGGLE*
161    inline void    SetShowEmptyPixels( Bool_t show = kTRUE ) { fShowEmptyPixels = show; }     // *TOGGLE*
162    inline void    SetShowOffPixels( Bool_t show = kTRUE ) { fShowOffPixels = show; }         // *TOGGLE*
163    inline void    SetShowPixelBorder( Bool_t show = kFALSE ) { fShowPixelBorder = show; }         // *TOGGLE*
164    inline void    SetDrawNightGlow( Bool_t draw = kTRUE ) { fDrawNightGlow = draw; }
165    inline void    SetIntegral( Int_t id ) { fIntegral = id; }        // *MENU*
166    inline void    SetViewBorder( Float_t b ) {  fViewBorder = b; }                // *MENU*
167    inline void    SetViewRange( Float_t s) { fViewRange = s; }                    // *MENU*
168    inline void    SetViewThreshold( Int_t t ) { fViewThreshold = t; Modified(); } // *MENU*
169
170    void UpdateHist(Bool_t force=kFALSE);
171
172private:
173    enum {
174        kColorPixelEmpty = -1,
175        kColorPixelOff   = -2,
176        kColorPmtEmpty   = -3,
177        kColorPmtHit     = -4
178    };
179
180    // helper functions
181    void Constructor();
182    Bool_t Load();
183    void BuildPolyLines();
184    void ClearPolyLines();
185
186        Int_t CurrentCode() const { return fCurrentMapID+10*fIntegral;}
187         void CacheIntegral() const;
188    EPolygon* FindPmtLine( Int_t ) const;
189         void FindPmtsToPaint( Float_t, Float_t, Float_t, Float_t );
190       Bool_t FindView( Int_t );
191    EPolygon* GetPixelLine( Int_t );
192    EPolygon* GetPmtLine( Int_t );
193    const Counts_t* MapToPaint() const;
194    const GtuCounts_t* GtuCountsToPaint() const;
195        void PaintHits();
196        void PaintNightGlow( Option_t* = "ncnt" );
197       Int_t GetColorPalette( Int_t i ) const;
198       Int_t GetNormColorPalette( Float_t i ) const;
199       Int_t GetPaletteNumColors() const { return fStdPalette ? gStyle->GetNumberOfColors() : fNumColors; }
200
201    void FillChipTriggers(); // create a map with the chip triggers threshold numbers
202
203    // painter settings
204    Int_t   fGtu;                       // current gtu
205
206    Int_t   fCurrentMapID;              // identifier of the data to paint
207    Int_t   fCurrentTrigger;            // identifier of the trigger
208
209    Bool_t  fModified;
210
211    // viewport
212    Int_t   fViewThreshold;            // min counts of hits used to def the VP
213    Float_t fViewRange;                // size of viewport in signal Nspread
214    Float_t fViewBorder;               // border size, from 0 to 0.5
215    Bool_t  fAutoThreshold;            // it true and no count over threshold are found, it is lowered to find the viewport
216
217    // gif display size
218    Int_t fGifCanvasW;                 // width of the gif sequence canvas
219    Int_t fGifCanvasH;                 // hieght of the gif sequence canvas
220
221    // draw options
222    Bool_t  fShowAxis;                 // true to draw axis are shown
223    Bool_t  fShowEmptyPixels;          // true to draw pixels with 0 hits
224    Bool_t  fShowOffPixels;            // true to draw pixels even not in the maps
225    Bool_t  fShowPixelBorder;          // Enclose the pixel in a black polygon
226    Bool_t  fShowGtuCounter;           // true to draw the gtu counter
227    Bool_t  fDrawNightGlow;            // true to draw nightglow rate
228    Int_t   fIntegral;                 // true to draw time integral of the track
229    Bool_t  fAutoRadius;               // true to set the view according the signal
230
231    Bool_t  fMoveView;                 // if true the next leftmouse click moves the view center
232   
233    Float_t fAlpha;                    // 
234    Bool_t  fApplyThreshold;           // if true subtracts mu-fAlpha*sqrt(mu) from each Efee
235                                       // where mu is the mean nightglow rate in the fee
236    Bool_t  fAbsoluteThreshold;        // if true the threshold is absolute: subtract fAlpha
237                                       // from each Efee
238
239    Float_t fX1;                       // X coord of the lower left corner
240    Float_t fX2;                       // X coord of the lower right corner
241    Float_t fY1;                       // Y coord of the lower left corner
242    Float_t fY2;                       // Y coord of the lower right corner
243
244    Float_t fXmin;                     // X coord of the frame lower left corner
245    Float_t fXmax;                     // X coord of the frame lower right corner
246    Float_t fYmin;                     // Y coord of the frame lower left corner
247    Float_t fYmax;                     // Y coord of the frame lower right corner
248
249    // colors
250     Bool_t fStdPalette;               // if true uses the gStyle palette
251      Int_t fPaletteOffset;            // first color in the palette
252      Int_t fNumColors;                // maximum number of colors
253     UInt_t fMaxCounts;                // 
254
255    Color_t fPixelColorOff;            // color code of absent pixels
256    Color_t fPixelColorEmpty;          // color code of empty pixels
257    Color_t fPmtColorEmpty;            // color code of empty pmts
258    Color_t fPmtColorHit;              // color code of hit pmts
259
260    // data
261    EDetector *fDetector;
262    ERunParameters *fRunPars;
263   
264    map<ETriggerTypeIdentifier, Int_t> fTriggers;  // array of the chip tracking triggers
265    Bool_t fHasTriggersFilled;
266   
267    // histo
268    TH1F*   fH1Hits;
269    TStyle* fHitsStyle;
270    TH1F*   fH1SigProfile;
271    TH1F*   fH1SigMaxProfile;     // pixel max signal per GTU
272    TH1F*   fH1NoiseMaxProfile;   // pixel max noise per GTU (only EC with signal)
273    TH1F*   fH1NoiseMinProfile;   // pixel min noise per GTU (only EC with signal)
274    TH1F*   fH1NoiseMeanProfile;  // pixel mean noise per GTU (in EC most hitted)
275    TH1F*   fH1HitsMaxProfile;    // pixel max hits per GTU (only pixels with signal)
276
277    // data maps
278    GtuCounts_t fFrontEndHits;     // map fe hits per gtu
279    GtuCounts_t fFrontEndSignals;  // map fe signals per gtu
280    GtuCounts_t fFrontEndNoises;   // map fe background per gtu
281    GtuCounts_t fMacroCellHits;    // map mc hits
282    GtuCounts_t fSelFrontEndHits;  // map fe hits in pixels with signal
283    GtuCounts_t fECHits;           // map elem. cell hits per gtu
284   
285
286    Int_t    fFirstGtu;                 // first gtu in data
287    Int_t    fLastGtu;                  // last gtu in data
288    TVector3 fViewCenter;               // signal center in Detector coordinates
289    TVector3 fSpread;                   // signal spread
290   
291    TSeqCollection *fLines;             // list of lines used by the destructor
292
293    vector<Int_t> fPmtsToPaint;         // list of the pmt ids in the viewport
294
295    map<Int_t, EPolygon* > fPmtLines;
296    map<Int_t, EPolygon* > fPixelLines;
297
298//    GtuCounts_t fInteglFrontEndHits;
299//    GtuCounts_t fInteglFrontEndSignals;
300//    GtuCounts_t fInteglCellHits;
301
302    // cache
303    mutable Counts_t fCountsSum;
304    mutable GtuCounts_t fCache;
305    mutable Int_t fCacheCode;
306
307    TText fTxtCounter;
308    TText fTxtSum;
309    TGaxis fXaxis;
310    TGaxis fYaxis;
311    TGaxis fHaxis;
312
313    ClassDef(EFocalSurfacePainter,1)
314};
315
316////////////////////////////////////////////////////////////////////////////////
317//                                                                            //
318//  EPolygon                                                                  //
319//                                                                            //
320////////////////////////////////////////////////////////////////////////////////
321
322class EPolygon : public TPolyLine {
323public:
324
325    EPolygon() {};
326    EPolygon( Int_t n, Float_t *x, Float_t *y);
327    EPolygon( Int_t n, Double_t *x, Double_t *y);
328    virtual ~EPolygon();
329
330    virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py); 
331    virtual Int_t DistancetoPrimitive(Int_t px, Int_t py); 
332    virtual void Translate( Double_t dx, Double_t dy );
333    virtual void Rotate( Double_t alpha );
334
335private:
336    ClassDef(EPolygon,1) 
337};
338
339#endif  /* __EFOCALSURFACEPAINTER_HH__ */
340
Note: See TracBrowser for help on using the repository browser.