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

Last change on this file since 2578 was 2578, 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==0)
41 {
42 fEvtTime->SetTime((ULong_t)gSystem->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("Trigger Rate: %.1fHz / Event Rate: %.1fHz", evts/sec, fRate->GetRate()));
54
55 if (set)
56 fEvtTime->SetTime((ULong_t)0);
57}
58
59Bool_t MOnlineDump::ProcessMessage(Int_t msg, Int_t submsg, Long_t mp1, Long_t mp2)
60{
61 switch (msg)
62 {
63 case kC_VSLIDER:
64 switch (submsg)
65 {
66 case kSL_POS:
67 if (mp1==MOnlineDisplay::kSlider && GetFilter())
68 {
69 ((MFRealTimePeriod*)GetFilter())->SetTime(mp2*100);
70 *fLog << dbg << "Update Time: " << Form("%.1fs", mp2/10.) << endl;
71 }
72 return kTRUE;
73 }
74 return kFALSE;
75 case kC_COMMAND:
76 switch(submsg)
77 {
78 case kCM_TAB:
79 {
80 //
81 // Set name for 'FADC canvas'. The name is the anchor for MHCamera.
82 // and clear the canvas
83 //
84 if (!fPlist || !fDisplay)
85 return kTRUE;
86
87 TCanvas *c = fDisplay->GetCanvas(mp1);
88 if (!c)
89 return kTRUE;
90
91 MHEvent *o = (MHEvent*)fPlist->FindObject(c->GetName());
92 if (o)
93 ((MOnlineDisplay*)fDisplay)->fCanvas->SetName(Form("%p;%p;PixelContent", o->GetHist(),
94 c->GetPad(1)));
95 }
96 break;
97
98 case kCM_BUTTON:
99 if (mp1==MOnlineDisplay::kFreeze)
100 {
101 TGButton *but = (TGButton*)mp2;
102 if (!but->IsDown())
103 {
104 but->AllowStayDown(kTRUE);
105 fCamEvent->SetFreezed();
106 }
107 else
108 {
109 but->AllowStayDown(kFALSE);
110 fCamEvent->SetFreezed(kFALSE);
111 }
112 but->Toggle();
113 }
114 return kTRUE;
115 }
116 return kFALSE;
117 }
118 return kFALSE;
119}
120
121MOnlineDump::~MOnlineDump()
122{
123 if (fDisplay)
124 ((MOnlineDisplay*)fDisplay)->SetTask(0);
125}
126
127Int_t MOnlineDump::PreProcess(MParList *pList)
128{
129 fPlist = pList;
130
131 if (gROOT->IsBatch())
132 {
133 *fLog << err << "We are in batch mode!" << endl;
134 return kFALSE;
135 }
136 if (!fDisplay)
137 {
138 *fLog << err << "fDisplay not set." << endl;
139 return kFALSE;
140 }
141
142 MTaskList *tasks = (MTaskList*)pList->FindObject("MTaskList");
143 if (!tasks)
144 {
145 *fLog << err << "MTaskList not found... abort." << endl;
146 return kFALSE;
147 }
148
149 fFill1 = (MFillH*)tasks->FindObject("MFillCamEvent");
150 if (!fFill1)
151 {
152 *fLog << err << "MFillCamEvent not found... abort." << endl;
153 return kFALSE;
154 }
155 fFill2 = (MFillH*)tasks->FindObject("MFillEvent");
156 if (!fFill2)
157 {
158 *fLog << err << "MFillEvent not found... abort." << endl;
159 return kFALSE;
160 }
161 fFill3 = (MFillH*)tasks->FindObject("MFillTriggerLvl0");
162 if (!fFill3)
163 {
164 *fLog << err << "MFillTriggerLvl0 not found... abort." << endl;
165 return kFALSE;
166 }
167
168 MHCamEvent *idxhi = (MHCamEvent*)pList->FindObject("MaxIdxHi");
169 MHCamEvent *idxlo = (MHCamEvent*)pList->FindObject("MaxIdxLo");
170 if (!idxhi || !idxlo)
171 {
172 *fLog << err << "MaxIdxHi or MaxIdxLo not found... abort." << endl;
173 return kFALSE;
174 }
175
176 idxhi->GetHistByName("sum")->SetMinimum(0);
177 idxlo->GetHistByName("sum")->SetMinimum(0);
178 idxhi->GetHistByName("sum")->SetMaximum(15);
179 idxlo->GetHistByName("sum")->SetMaximum(15);
180
181
182 fRawEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
183 if (!fRawEvtHeader)
184 {
185 *fLog << err << "MRawEvtHeader not found... abort." << endl;
186 return kFALSE;
187 }
188
189 fRawRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
190 if (!fRawRunHeader)
191 {
192 *fLog << err << "MRawRunHeader not found... abort." << endl;
193 return kFALSE;
194 }
195
196 fEvtTime = (MTime*)pList->FindObject("MTime");
197 if (!fEvtTime)
198 {
199 *fLog << err << "MTime not found... abort." << endl;
200 return kFALSE;
201 }
202
203 fRate = (MEventRate*)pList->FindObject("MEventRate");
204 if (!fRate)
205 {
206 *fLog << err << "MEventRate not found... abort." << endl;
207 return kFALSE;
208 }
209
210 MHEvent *hevent = (MHEvent*)pList->FindObject("MHEvent");
211 if (!hevent)
212 {
213 *fLog << err << "MHEvent not found... abort." << endl;
214 return kFALSE;
215 }
216 fCamEvent = hevent->GetHist();
217
218 fRunNumber = 0xffffffff;
219 fEvtNumber = 0;
220
221 SetNoContextMenu((TObject*)fFill1->GetCanvas());
222 SetNoContextMenu((TObject*)fFill2->GetCanvas());
223 SetNoContextMenu((TObject*)fFill3->GetCanvas());
224
225 return kTRUE;
226}
227
228Int_t MOnlineDump::Process()
229{
230 DisplayTriggerRate();
231
232 if (fDisplay && fRawRunHeader->GetNumEvents())
233 fDisplay->SetProgressBarPosition((Float_t)fEvtNumber/fRawRunHeader->GetNumEvents());
234
235 return kTRUE;
236}
237
238Int_t MOnlineDump::PostProcess()
239{
240 if (fDisplay)
241 {
242 fDisplay->SetProgressBarPosition(1);
243 //fDisplay->Reset();
244 }
245
246 return kTRUE;
247}
Note: See TracBrowser for help on using the repository browser.