1 | // $Id: ETriggerPainter.hh 1540 2005-02-18 15:16:46Z pesce $ |
---|
2 | // R.Pesce created Feb, 17 2005 |
---|
3 | |
---|
4 | /***************************************************************************** |
---|
5 | * ESAF: Euso Simulation and Analysis Framework * |
---|
6 | * * |
---|
7 | * Id: TriggerPainter * |
---|
8 | * Package: EventViewer * |
---|
9 | * Coordinator: Alessandro.Thea * |
---|
10 | * * |
---|
11 | *****************************************************************************/ |
---|
12 | |
---|
13 | #ifndef __ETRIGGERPAINTER_HH__ |
---|
14 | #define __ETRIGGERPAINTER_HH__ |
---|
15 | |
---|
16 | #include "EFocalSurfacePainter.hh" |
---|
17 | #include "EAnimator.hh" |
---|
18 | #include "TSeqCollection.h" |
---|
19 | #include "TPolyLine.h" |
---|
20 | #include "TVector3.h" |
---|
21 | #include "TText.h" |
---|
22 | #include "TPaveText.h" |
---|
23 | #include <map> |
---|
24 | #include <vector> |
---|
25 | |
---|
26 | |
---|
27 | ////////////////////////////////////////////////////////////////////////////// |
---|
28 | // // |
---|
29 | // ETriggerPainter // |
---|
30 | // // |
---|
31 | // A painter to show the development of the signal on // |
---|
32 | // the focal surface // |
---|
33 | // // |
---|
34 | ////////////////////////////////////////////////////////////////////////////// |
---|
35 | |
---|
36 | class EDetector; |
---|
37 | class ERunParameters; |
---|
38 | class EChipTrackTrigger; |
---|
39 | class EPolygon; |
---|
40 | |
---|
41 | enum ETrigId { kAllHits = 1, |
---|
42 | kTrgHits = 2, |
---|
43 | kAllSig = 3, |
---|
44 | kTrgSig = 4, |
---|
45 | kCHits = 5 |
---|
46 | }; |
---|
47 | |
---|
48 | using std::map; |
---|
49 | using std::vector; |
---|
50 | |
---|
51 | /*typedef map<Int_t, Int_t> Counts_t; |
---|
52 | typedef map<Int_t, Counts_t> GtuCounts_t; |
---|
53 | |
---|
54 | const Counts_t operator+(const Counts_t&, const Counts_t&); |
---|
55 | Counts_t& operator+=( Counts_t&, const Counts_t&);*/ |
---|
56 | |
---|
57 | class ETriggerPainter: public EAnimator { |
---|
58 | public: |
---|
59 | ETriggerPainter( EDetector *, ERunParameters*, EChipTrackTrigger* ); |
---|
60 | virtual ~ETriggerPainter(); |
---|
61 | |
---|
62 | virtual void Clear( Option_t* =""); |
---|
63 | virtual void Draw( Option_t* =""); |
---|
64 | virtual void Paint( Option_t* =""); |
---|
65 | virtual Int_t DistancetoPrimitive(Int_t px, Int_t py); |
---|
66 | virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py); |
---|
67 | virtual char* GetObjectInfo(Int_t px, Int_t py) const; |
---|
68 | |
---|
69 | virtual void Play( Option_t* =""); // *MENU* |
---|
70 | virtual void Animate(); |
---|
71 | virtual void NextFrame(); |
---|
72 | virtual inline void Rewind() { fGtu = fFirstGtu; } // *MENU* |
---|
73 | virtual inline Bool_t IsEnded() { return fGtu >= fLastGtu; } |
---|
74 | |
---|
75 | void MakeGifSequence(const char* option = "", const char* path="Anim"); |
---|
76 | |
---|
77 | // getters |
---|
78 | inline Int_t GetGtu() const { return fGtu; } |
---|
79 | inline Int_t GetFirstGtu() const { return fFirstGtu; } |
---|
80 | inline Int_t GetLastGtu() const { return fLastGtu; } |
---|
81 | |
---|
82 | inline ETrigId GetMapToPaintID() const { return fMaptoPaintID; } |
---|
83 | |
---|
84 | inline const TVector3& GetCenter() const { return fCenter; } |
---|
85 | inline const TVector3& GetSpread() const { return fSpread; } |
---|
86 | inline const TVector3& GetXaxis() const { return fXaxis; } |
---|
87 | inline const TVector3& GetYaxis() const { return fYaxis; } |
---|
88 | inline const TVector3& GetZaxis() const { return fZaxis; } |
---|
89 | |
---|
90 | inline Int_t GetViewThreshold() const { return fViewThreshold; } |
---|
91 | inline Float_t GetViewNspread() const { return fViewNspread; } |
---|
92 | inline Float_t GetViewBorder() const { return fViewBorder; } |
---|
93 | |
---|
94 | inline Bool_t GetPixelEmpty() const { return fPixelEmpty; } |
---|
95 | inline Bool_t GetPixelOff() const { return fPixelOff; } |
---|
96 | inline Bool_t GetGtuCounter() const { return fGtuCounter; } |
---|
97 | inline Bool_t GetTimeIntegral() const { return fTimeIntegral; } |
---|
98 | inline Bool_t GetStatusBar() const { return fStatusBar; } |
---|
99 | |
---|
100 | inline Int_t GetNumColors() const { return fNumColors; } |
---|
101 | inline Int_t GetMaxCounts() const { return fMaxCounts; } |
---|
102 | |
---|
103 | inline Color_t GetPixelColorEmpty() const { return fPixelColorEmpty; } |
---|
104 | inline Color_t GetPixelColorOff() const { return fPixelColorOff; } |
---|
105 | inline Color_t GetPmtColorEmpty() const { return fPmtColorEmpty; } |
---|
106 | inline Color_t GetPmtColorHit() const { return fPmtColorHit; } |
---|
107 | |
---|
108 | // setters |
---|
109 | inline void SetGtu( Int_t gtu ) { fGtu = gtu; } // *MENU* |
---|
110 | inline void SetFirstGtu( Int_t gtu ) { fFirstGtu = gtu; } |
---|
111 | inline void SetLastGtu( Int_t gtu ) { fLastGtu = gtu; } |
---|
112 | |
---|
113 | inline void SetMapToPaintID( ETrigId id ) { fMaptoPaintID = id; } // *MENU* |
---|
114 | |
---|
115 | virtual void PaintAllHits() { SetMapToPaintID( kAllHits ); } // *MENU* |
---|
116 | virtual void PaintTrigHits() { SetMapToPaintID( kTrgHits ); } // *MENU* |
---|
117 | virtual void PaintAllSignals() { SetMapToPaintID( kAllSig ); } // *MENU* |
---|
118 | virtual void PaintTrigSignals() { SetMapToPaintID( kTrgSig ); } // *MENU* |
---|
119 | virtual void PaintCellHits() { SetMapToPaintID( kCHits ); } // *MENU* |
---|
120 | |
---|
121 | |
---|
122 | inline void SetViewThreshold( Int_t t ) { fViewThreshold = t; } // *MENU* |
---|
123 | inline void SetViewNspread( Float_t s) { fViewNspread = s; } // *MENU* |
---|
124 | inline void SetViewBorder( Float_t b ) { fViewBorder = b; } // *MENU* |
---|
125 | |
---|
126 | inline void SetPixelEmpty( Bool_t b = kTRUE ) { fPixelEmpty = b; } // *TOGGLE* |
---|
127 | inline void SetPixelOff( Bool_t b = kTRUE ) { fPixelOff = b; } // *TOGGLE* |
---|
128 | inline void SetGtuCounter( Bool_t b = kTRUE ) { fGtuCounter = b; } // *TOGGLE* |
---|
129 | inline void SetTimeIntegral( Bool_t b = kTRUE ) { fTimeIntegral = b; } // *TOGGLE* |
---|
130 | inline void SetStatusBar( Bool_t b=kTRUE ) { fStatusBar = b; } // *TOGGLE* |
---|
131 | |
---|
132 | inline void SetNumColors( Int_t n ) { fNumColors = n; } // *MENU* |
---|
133 | inline void SetMaxCounts( Int_t n ) { fMaxCounts = n; } // *MENU* |
---|
134 | |
---|
135 | inline void SetPixelColorEmpty( Color_t c ) { fPixelColorEmpty = c; } |
---|
136 | inline void SetPixelColorOff( Color_t c ) { fPixelColorOff = c; } |
---|
137 | inline void SetPmtColorEmpty( Color_t c ) { fPmtColorEmpty = c; } |
---|
138 | inline void SetPmtColorHit( Color_t c ) { fPmtColorHit = c; } |
---|
139 | |
---|
140 | private: |
---|
141 | |
---|
142 | // helper functions |
---|
143 | void LoadData(); |
---|
144 | void FindView( ETrigId ); |
---|
145 | void BuildPolyLines(); |
---|
146 | |
---|
147 | EPolygon* FindPmtLine( Int_t ) const; |
---|
148 | EPolygon* GetPmtLine( Int_t ); |
---|
149 | EPolygon* GetPixelLine( Int_t ); |
---|
150 | void FindPmtsToPaint( Float_t, Float_t, Float_t, Float_t ); |
---|
151 | |
---|
152 | // painter settings |
---|
153 | Int_t fGtu; // current gtu |
---|
154 | |
---|
155 | ETrigId fMaptoPaintID; // identifier of the data to paint |
---|
156 | |
---|
157 | // viewport |
---|
158 | Int_t fViewThreshold; // min counts of hits used to def the VP |
---|
159 | Float_t fViewNspread; // size of viewport in signal Nspread |
---|
160 | Float_t fViewBorder; // border size, from 0 to 0.5 |
---|
161 | |
---|
162 | // gif display size |
---|
163 | Int_t fGifCanvasW; // width of the gif sequence canvas |
---|
164 | Int_t fGifCanvasH; // hieght of the gif sequence canvas |
---|
165 | |
---|
166 | // draw options |
---|
167 | Bool_t fPixelEmpty; // true to draw pixels with 0 hits |
---|
168 | Bool_t fPixelOff; // true to draw pixels even not in the maps |
---|
169 | Bool_t fGtuCounter; // true to draw the gtu counter |
---|
170 | Bool_t fTimeIntegral; // true to draw time integral of the track |
---|
171 | Bool_t fStatusBar; // true paint the status text |
---|
172 | |
---|
173 | Float_t fX1; // X coord of the lower left corner |
---|
174 | Float_t fX2; // X coord of the lower right corner |
---|
175 | Float_t fY1; // Y coord of the lower left corner |
---|
176 | Float_t fY2; // Y coord of the lower right corner |
---|
177 | |
---|
178 | // colors |
---|
179 | Int_t fNumColors; // maximum number of colors |
---|
180 | Int_t fColorOffset; // first color in the palette |
---|
181 | Int_t fMaxCounts; // |
---|
182 | |
---|
183 | Color_t fPixelColorOff; // color code of absent pixels |
---|
184 | Color_t fPixelColorEmpty; // color code of empty pixels |
---|
185 | Color_t fPmtColorEmpty; // color code of empty pmts |
---|
186 | Color_t fPmtColorHit; // color code of hit pmts |
---|
187 | |
---|
188 | TPaveText fPaveStatusBar; |
---|
189 | |
---|
190 | virtual void SetStatus( Int_t uid, Int_t pmt=-1, Int_t chip=-1, Int_t cell=-1, Int_t counts=-1); |
---|
191 | |
---|
192 | // data |
---|
193 | EDetector *fDetector; |
---|
194 | ERunParameters *fRunPars; |
---|
195 | EChipTrackTrigger *fTrigger; |
---|
196 | |
---|
197 | // data maps |
---|
198 | GtuCounts_t fChips; |
---|
199 | GtuCounts_t fTrgChips; |
---|
200 | GtuCounts_t fTrackHits; |
---|
201 | GtuCounts_t fTrackSignals; |
---|
202 | GtuCounts_t fTrgHits; |
---|
203 | GtuCounts_t fTrgSignals; |
---|
204 | GtuCounts_t fMacroCellHits; |
---|
205 | |
---|
206 | Int_t fFirstGtu; // first gtu in data |
---|
207 | Int_t fLastGtu; // last gtu in data |
---|
208 | TVector3 fCenter; // signal center in Detector coordinates |
---|
209 | TVector3 fSpread; // signal spread |
---|
210 | TVector3 fXaxis; // x axis calculated from signal pixels |
---|
211 | TVector3 fYaxis; // y axis calculated from signal pixels |
---|
212 | TVector3 fZaxis; // normal (z ax) calculated from signal pixels |
---|
213 | |
---|
214 | TSeqCollection *fLines; // list of lines used by the destructor |
---|
215 | |
---|
216 | vector<Int_t> fPmtsToPaint; // list of the pmt ids in the viewport |
---|
217 | |
---|
218 | map<Int_t, EPolygon* > fPmtLines; |
---|
219 | map<Int_t, EPolygon* > fPixelLines; |
---|
220 | |
---|
221 | |
---|
222 | // cache |
---|
223 | mutable GtuCounts_t fCache; |
---|
224 | mutable Int_t fCacheContents; |
---|
225 | |
---|
226 | TText fTxtCounter; |
---|
227 | |
---|
228 | void CacheTimeInt() const; |
---|
229 | Counts_t GetMapToPaint() const; |
---|
230 | const GtuCounts_t* GtuCountsToPaint() const; |
---|
231 | |
---|
232 | ClassDef(ETriggerPainter,1) |
---|
233 | }; |
---|
234 | |
---|
235 | #endif /* __ETRIGGERPAINTER_HH__ */ |
---|
236 | |
---|