source: trunk/MagicSoft/Mars/mmain/MOnlineDump.cc@ 2730

Last change on this file since 2730 was 2617, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 6.0 KB
Line 
1#include "MOnlineDump.h"
2
3#include <TCanvas.h>
4#include <TSystem.h>
5
6#include <TGButton.h>
7
8#include "MLog.h"
9#include "MLogManip.h"
10
11#include "MTime.h"
12#include "MRawRunHeader.h"
13#include "MRawEvtHeader.h"
14
15#include "MOnlineDisplay.h"
16
17#include "MFRealTimePeriod.h"
18#include "MHEvent.h"
19#include "MHCamera.h"
20#include "MHCamEvent.h"
21#include "MParList.h"
22#include "MTaskList.h"
23#include "MFillH.h"
24#include "MEventRate.h"
25
26ClassImp(MOnlineDump);
27
28using namespace std;
29
30void MOnlineDump::SetNoContextMenu(TObject *c)
31{
32 if (fDisplay->HasCanvas((TCanvas*)c))
33 c->ResetBit(kNoContextMenu);
34}
35
36void MOnlineDump::DisplayTriggerRate()
37{
38 Bool_t set = kFALSE;
39
40 if (!*fEvtTime)
41 {
42 fEvtTime->Now();
43 set = kTRUE;
44 }
45
46 const UInt_t evts = fRawEvtHeader->GetDAQEvtNumber() - fEvtNumber;
47 const Double_t sec = *fEvtTime-fTime;
48
49 fEvtNumber = fRawEvtHeader->GetDAQEvtNumber();
50 fTime = *fEvtTime;
51
52 if (evts>0 && sec>0 && fDisplay)
53 fDisplay->SetStatusLine2(Form("%sTrigger Rate: %.1fHz / Event Rate: %.1fHz",
54 (set?"Arb. ":""), evts/sec, fRate->GetRate()));
55
56 if (set)
57 fEvtTime->Reset();
58}
59
60Bool_t MOnlineDump::ProcessMessage(Int_t msg, Int_t submsg, Long_t mp1, Long_t mp2)
61{
62 switch (msg)
63 {
64 case kC_VSLIDER:
65 switch (submsg)
66 {
67 case kSL_POS:
68 if (mp1==MOnlineDisplay::kSlider && GetFilter())
69 {
70 ((MFRealTimePeriod*)GetFilter())->SetTime(mp2*100);
71 *fLog << dbg << "Update Time: " << Form("%.1fs", mp2/10.) << endl;
72 }
73 return kTRUE;
74 }
75 return kFALSE;
76 case kC_COMMAND:
77 switch(submsg)
78 {
79 case kCM_TAB:
80 {
81 //
82 // Set name for 'FADC canvas'. The name is the anchor for MHCamera.
83 // and clear the canvas
84 //
85 if (!fPlist || !fDisplay)
86 return kTRUE;
87
88 TCanvas *c = fDisplay->GetCanvas(mp1);
89 if (!c)
90 return kTRUE;
91
92 MHEvent *o = (MHEvent*)fPlist->FindObject(c->GetName());
93 if (o)
94 ((MOnlineDisplay*)fDisplay)->fCanvas->SetName(Form("%p;%p;PixelContent", o->GetHist(),
95 c->GetPad(1)));
96 }
97 break;
98
99 case kCM_BUTTON:
100 if (mp1==MOnlineDisplay::kFreeze)
101 {
102 TGButton *but = (TGButton*)mp2;
103 if (!but->IsDown())
104 {
105 but->AllowStayDown(kTRUE);
106 fCamEvent->SetFreezed();
107 }
108 else
109 {
110 but->AllowStayDown(kFALSE);
111 fCamEvent->SetFreezed(kFALSE);
112 }
113 but->Toggle();
114 }
115 return kTRUE;
116 }
117 return kFALSE;
118 }
119 return kFALSE;
120}
121
122MOnlineDump::~MOnlineDump()
123{
124 if (fDisplay)
125 ((MOnlineDisplay*)fDisplay)->SetTask(0);
126}
127
128Int_t MOnlineDump::PreProcess(MParList *pList)
129{
130 fPlist = pList;
131
132 if (gROOT->IsBatch())
133 {
134 *fLog << err << "We are in batch mode!" << endl;
135 return kFALSE;
136 }
137 if (!fDisplay)
138 {
139 *fLog << err << "fDisplay not set." << endl;
140 return kFALSE;
141 }
142
143 MTaskList *tasks = (MTaskList*)pList->FindObject("MTaskList");
144 if (!tasks)
145 {
146 *fLog << err << "MTaskList not found... abort." << endl;
147 return kFALSE;
148 }
149
150 fFill1 = (MFillH*)tasks->FindObject("MFillCamEvent");
151 if (!fFill1)
152 {
153 *fLog << err << "MFillCamEvent not found... abort." << endl;
154 return kFALSE;
155 }
156 fFill2 = (MFillH*)tasks->FindObject("MFillEvent");
157 if (!fFill2)
158 {
159 *fLog << err << "MFillEvent not found... abort." << endl;
160 return kFALSE;
161 }
162 fFill3 = (MFillH*)tasks->FindObject("MFillTriggerLvl0");
163 if (!fFill3)
164 {
165 *fLog << err << "MFillTriggerLvl0 not found... abort." << endl;
166 return kFALSE;
167 }
168
169 MHCamEvent *idxhi = (MHCamEvent*)pList->FindObject("MaxIdxHi");
170 MHCamEvent *idxlo = (MHCamEvent*)pList->FindObject("MaxIdxLo");
171 if (!idxhi || !idxlo)
172 {
173 *fLog << err << "MaxIdxHi or MaxIdxLo not found... abort." << endl;
174 return kFALSE;
175 }
176
177 idxhi->GetHistByName("sum")->SetMinimum(0);
178 idxlo->GetHistByName("sum")->SetMinimum(0);
179 idxhi->GetHistByName("sum")->SetMaximum(15);
180 idxlo->GetHistByName("sum")->SetMaximum(15);
181
182
183 fRawEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
184 if (!fRawEvtHeader)
185 {
186 *fLog << err << "MRawEvtHeader not found... abort." << endl;
187 return kFALSE;
188 }
189
190 fRawRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
191 if (!fRawRunHeader)
192 {
193 *fLog << err << "MRawRunHeader not found... abort." << endl;
194 return kFALSE;
195 }
196
197 fEvtTime = (MTime*)pList->FindObject("MTime");
198 if (!fEvtTime)
199 {
200 *fLog << err << "MTime not found... abort." << endl;
201 return kFALSE;
202 }
203
204 fRate = (MEventRate*)pList->FindObject("MEventRate");
205 if (!fRate)
206 {
207 *fLog << err << "MEventRate not found... abort." << endl;
208 return kFALSE;
209 }
210
211 MHEvent *hevent = (MHEvent*)pList->FindObject("MHEvent");
212 if (!hevent)
213 {
214 *fLog << err << "MHEvent not found... abort." << endl;
215 return kFALSE;
216 }
217 fCamEvent = hevent->GetHist();
218
219 fRunNumber = 0xffffffff;
220 fEvtNumber = 0;
221
222 SetNoContextMenu((TObject*)fFill1->GetCanvas());
223 SetNoContextMenu((TObject*)fFill2->GetCanvas());
224 SetNoContextMenu((TObject*)fFill3->GetCanvas());
225
226 return kTRUE;
227}
228
229Int_t MOnlineDump::Process()
230{
231 DisplayTriggerRate();
232
233 if (fDisplay && fRawRunHeader->GetNumEvents())
234 fDisplay->SetProgressBarPosition((Float_t)fEvtNumber/fRawRunHeader->GetNumEvents());
235
236 return kTRUE;
237}
238
239Int_t MOnlineDump::PostProcess()
240{
241 if (fDisplay)
242 {
243 fDisplay->SetProgressBarPosition(1);
244 //fDisplay->Reset();
245 }
246
247 return kTRUE;
248}
Note: See TracBrowser for help on using the repository browser.