source: trunk/Mars/mmain/MDataCheck.cc@ 19344

Last change on this file since 19344 was 2377, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.4 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
19! Author(s): Harald Kornmayer 1/2001
20!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25#include "MDataCheck.h"
26
27#include <TGButton.h> // TGTextButton
28
29#include "MGList.h"
30#include "MFillH.h"
31#include "MParList.h"
32#include "MEvtLoop.h"
33#include "MHFadcCam.h"
34#include "MTaskList.h"
35#include "MReadTree.h"
36#include "MGeomApply.h"
37#include "MGDisplayAdc.h"
38
39#include "MLog.h"
40#include "MLogManip.h"
41
42ClassImp(MDataCheck);
43
44using namespace std;
45
46// ---
47
48enum {
49 kButPedAdc = 0x100,
50 kButEvtAdc = 0x101,
51 kButPedTdc = 0x102,
52 kButEvtTdc = 0x103
53};
54
55// --------------------------------------------------------------------------
56//
57// Create the 'Data Check' GUI Controls (Window) on the screen. To use it
58// from within the interpreter you can call a Standard Version with
59// 'new MDataCheck()'
60//
61MDataCheck::MDataCheck(/*const TGWindow *main,*/ const TGWindow *p,
62 const UInt_t w, const UInt_t h)
63: MBrowser(/*main,*/ p, w, h)
64{
65 //TGTextButton *pedadc = new TGTextButton(fTop1, "ADC Spectra of Pedestals", kButPedAdc);
66 TGTextButton *cradc = new TGTextButton(fTop1, "ADC Spectra of Cosmics", kButEvtAdc);
67 TGTextButton *evttdc = new TGTextButton(fTop1, "Time Spectra of Cosmics", kButEvtTdc);
68 //TGTextButton *crtdc = new TGTextButton(fTop3, "Run Spectra of Cosmics", kButEvtTdc);
69
70 //pedadc->Associate(this);
71 cradc ->Associate(this);
72 evttdc->Associate(this);
73 //crtdc ->Associate(this);
74
75 //fList->Add(pedadc);
76 fList->Add(cradc);
77 fList->Add(evttdc);
78 //fList->Add(crtdc);
79
80 TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsLeft, 10, 10, 5, 5);
81 fList->Add(laybut);
82
83 //fTop1->AddFrame(pedadc, laybut);
84 fTop1->AddFrame(cradc, laybut);
85 fTop1->AddFrame(evttdc, laybut);
86 //fTop3->AddFrame(pedtdc, laybut);
87 //fTop3->AddFrame(crtdc, laybut);
88
89 MapSubwindows();
90
91 Layout();
92
93 SetWindowName("DataCheck Window");
94 SetIconName("DataCheck");
95
96 MapWindow();
97}
98
99// --------------------------------------------------------------------------
100//
101// Create the 'View Adc' GUI Controls (Window) on the screen.
102// Therefor we have to process all data in a file and fill the corresponding
103// histograms.
104//
105void MDataCheck::View(const char *inputfile, const char *treeName, MHFadcPix::Type_t t)
106{
107 //
108 // create a (empty) list of parameters which can be used by the tasks
109 // and an (empty) list of tasks which should be executed
110 // connect them in the required way.
111 //
112
113 //
114 // create the data containers for the raw data
115 //
116 MParList plist;
117
118 //
119 // set up the tasks for this job
120 //
121 MTaskList tasks;
122 plist.AddToList(&tasks);
123
124 MReadTree read(treeName, inputfile);
125 read.DisableAutoScheme();
126
127 MGeomApply geomapl;
128
129 MHFadcCam hist(t);
130 plist.AddToList(&hist);
131
132 MFillH fill(&hist, "MRawEvtData");
133
134 tasks.AddToList(&read);
135 tasks.AddToList(&geomapl);
136 tasks.AddToList(&fill);
137
138 //
139 // set up the loop for the processing
140 //
141 MEvtLoop magic;
142 magic.SetParList(&plist);
143
144 //
145 // Add ProgressBar to window
146 //
147 TGProgressBar *bar = CreateProgressBar(fTop1);
148 magic.SetProgressBar(bar);
149
150 //
151 // Execute your analysis
152 //
153 Bool_t rc = magic.Eventloop();
154
155 //
156 // Remove progressbar from window
157 //
158 DestroyProgressBar(bar);
159
160 if (!rc)
161 return;
162
163 new MGDisplayAdc(&hist);
164}
165
166// --------------------------------------------------------------------------
167//
168// Process the GUI control events (here: mainly button clicks)
169//
170Bool_t MDataCheck::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
171{
172 // Process events generated by the buttons in the frame.
173
174 if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
175 return MBrowser::ProcessMessage(msg, parm1, parm2);
176
177 switch (parm1)
178 {
179 case kButPedAdc:
180 case kButEvtAdc:
181 case kButPedTdc:
182 case kButEvtTdc:
183 if (!InputFileSelected())
184 {
185 DisplError("No Input (root) File selected!");
186 return kTRUE;
187 }
188
189 switch (parm1)
190 {
191 case kButPedAdc:
192 View(fInputFile, "PedEvents", MHFadcPix::kValue);
193 return kTRUE;
194
195 case kButEvtAdc:
196 View(fInputFile, "Events", MHFadcPix::kValue);
197 return kTRUE;
198
199 case kButPedTdc:
200 View(fInputFile, "PedEvents", MHFadcPix::kSlices);
201 return kTRUE;
202
203 case kButEvtTdc:
204 View(fInputFile, "Events", MHFadcPix::kSlices);
205 return kTRUE;
206 }
207 return kTRUE;
208 }
209
210 return MBrowser::ProcessMessage(msg, parm1, parm2);
211}
Note: See TracBrowser for help on using the repository browser.