| 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 10/2001 <mailto:tbretz@uni-sw.gwdg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2001
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | #include "MGCamDisplay.h"
|
|---|
| 26 |
|
|---|
| 27 | #include <TList.h> // TList::Add
|
|---|
| 28 | #include <TCanvas.h> // TCanvas::cd
|
|---|
| 29 | #include <TGButton.h> // TGPictureButton
|
|---|
| 30 | #include <TGButtonGroup.h> // TGVButtonGroup
|
|---|
| 31 |
|
|---|
| 32 | #include "MGTask.h" // MGTask::CreateGui
|
|---|
| 33 | #include "MClone.h" // MClone
|
|---|
| 34 | #include "MHillas.h" // MHillas
|
|---|
| 35 | #include "MParList.h" // MParList::AddToList
|
|---|
| 36 | #include "MEvtLoop.h" // MEvtLoop::GetParList
|
|---|
| 37 | #include "MTaskList.h" // MTaskList::AddToList
|
|---|
| 38 | #include "MCamDisplay.h" // MCamDisplay
|
|---|
| 39 | #include "MHillasCalc.h" // MHillasCalc
|
|---|
| 40 | #include "MPedestalCam.h" // MPedestalCam
|
|---|
| 41 | #include "MCerPhotCalc.h" // MCerPhotCalc
|
|---|
| 42 | #include "MMcPedestalCopy.h" // MMcPedestalCopy
|
|---|
| 43 | #include "MMcPedestalNSB.h" // MMcPedestalNSB
|
|---|
| 44 | #include "MImgCleanStd.h" // MImgCleanStd
|
|---|
| 45 | #include "MGeomCamMagic.h" // MGeomMagicCam
|
|---|
| 46 |
|
|---|
| 47 | ClassImp(MGCamDisplay);
|
|---|
| 48 |
|
|---|
| 49 | enum
|
|---|
| 50 | {
|
|---|
| 51 | kRButRawEvt,
|
|---|
| 52 | kRButCleanedEvt,
|
|---|
| 53 | kCButHillas
|
|---|
| 54 | };
|
|---|
| 55 |
|
|---|
| 56 | // --------------------------------------------------------------------------
|
|---|
| 57 | //
|
|---|
| 58 | // Add Setup elements to GUI.
|
|---|
| 59 | //
|
|---|
| 60 | void MGCamDisplay::AddSetupElements()
|
|---|
| 61 | {
|
|---|
| 62 | //
|
|---|
| 63 | // Create gui elements for vertical frame
|
|---|
| 64 | //
|
|---|
| 65 | TGGroupFrame *grp = new TGGroupFrame(fTab1, "Display");
|
|---|
| 66 | TGVButtonGroup *group = new TGVButtonGroup(grp);
|
|---|
| 67 | fList->Add(group);
|
|---|
| 68 |
|
|---|
| 69 | TGRadioButton *but1 = new TGRadioButton(group, "Raw Events", kRButRawEvt);
|
|---|
| 70 | TGRadioButton *but2 = new TGRadioButton(group, "Cleaned Events", kRButCleanedEvt);
|
|---|
| 71 | TGCheckButton *but3 = new TGCheckButton(grp, "Display Ellipse", kCButHillas);
|
|---|
| 72 |
|
|---|
| 73 | but2->SetState(kButtonDown);
|
|---|
| 74 | but3->SetState(kButtonDown);
|
|---|
| 75 |
|
|---|
| 76 | fDisplayRaw = kFALSE;
|
|---|
| 77 | fDisplayHillas = kTRUE;
|
|---|
| 78 |
|
|---|
| 79 | /*
|
|---|
| 80 | WARNING:
|
|---|
| 81 | Bacause of some strage and hidden dependencies the
|
|---|
| 82 | GetMaiFrame call in the destructor of TGButton may fail if some
|
|---|
| 83 | of the other gui elements are deleted first.
|
|---|
| 84 | AddFirst adds the buttons at the beginning of the deletion list,
|
|---|
| 85 | this seems to work.
|
|---|
| 86 | */
|
|---|
| 87 | fList->AddFirst(but1);
|
|---|
| 88 | fList->AddFirst(but2);
|
|---|
| 89 |
|
|---|
| 90 | but1->Associate(this);
|
|---|
| 91 | but2->Associate(this);
|
|---|
| 92 | but3->Associate(this);
|
|---|
| 93 |
|
|---|
| 94 | TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 15, 0);
|
|---|
| 95 | fList->Add(laybut);
|
|---|
| 96 |
|
|---|
| 97 | grp->AddFrame(group);
|
|---|
| 98 | grp->AddFrame(but3, laybut);
|
|---|
| 99 |
|
|---|
| 100 | TGLayoutHints *laygrp1 = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 10, 10, 5, 0);
|
|---|
| 101 | TGLayoutHints *laygrp2 = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 10, 10, 5, 5);
|
|---|
| 102 |
|
|---|
| 103 | fTab1->AddFrame(grp, laygrp1);
|
|---|
| 104 | ((MGTask*)GetTaskList()->FindObject("MImgCleanStd"))->CreateGui(fTab1, laygrp2);
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | // --------------------------------------------------------------------------
|
|---|
| 108 | //
|
|---|
| 109 | // Setup Task and parameter list for hillas calculation,
|
|---|
| 110 | // preprocess tasks and read in first event (process)
|
|---|
| 111 | //
|
|---|
| 112 | MGeomCam *MGCamDisplay::SetupTaskList()
|
|---|
| 113 | {
|
|---|
| 114 | MTaskList *tlist = GetTaskList();
|
|---|
| 115 | MParList *plist = GetParList();
|
|---|
| 116 |
|
|---|
| 117 | MMcPedestalCopy *pcopy = new MMcPedestalCopy;
|
|---|
| 118 | MMcPedestalNSB *pdnsb = new MMcPedestalNSB;
|
|---|
| 119 | MCerPhotCalc *ncalc = new MCerPhotCalc;
|
|---|
| 120 | MClone *clone = new MClone("MCerPhotEvt");
|
|---|
| 121 | MImgCleanStd *clean = new MImgCleanStd;
|
|---|
| 122 | MHillasCalc *hcalc = new MHillasCalc;
|
|---|
| 123 |
|
|---|
| 124 | tlist->AddToList(pcopy);
|
|---|
| 125 | tlist->AddToList(pdnsb);
|
|---|
| 126 | tlist->AddToList(ncalc);
|
|---|
| 127 | tlist->AddToList(clone);
|
|---|
| 128 | tlist->AddToList(clean);
|
|---|
| 129 | tlist->AddToList(hcalc);
|
|---|
| 130 |
|
|---|
| 131 | MGeomCamMagic *geom = new MGeomCamMagic;
|
|---|
| 132 | MPedestalCam *pedest = new MPedestalCam;
|
|---|
| 133 |
|
|---|
| 134 | plist->AddToList(geom);
|
|---|
| 135 | plist->AddToList(pedest);
|
|---|
| 136 |
|
|---|
| 137 | return geom;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | // --------------------------------------------------------------------------
|
|---|
| 141 | //
|
|---|
| 142 | // Constructor.
|
|---|
| 143 | //
|
|---|
| 144 | MGCamDisplay::MGCamDisplay(const char *filename,
|
|---|
| 145 | const TGWindow *p, const TGWindow *main,
|
|---|
| 146 | UInt_t w, UInt_t h)
|
|---|
| 147 | : MGEvtDisplay(filename, "Events", p, main, w, h), fDisplay(NULL)
|
|---|
| 148 | {
|
|---|
| 149 | //
|
|---|
| 150 | // Setup Task list for hillas calculation
|
|---|
| 151 | //
|
|---|
| 152 | MGeomCam *geom = SetupTaskList();
|
|---|
| 153 |
|
|---|
| 154 | //
|
|---|
| 155 | // Add missing setup elements to GUI
|
|---|
| 156 | //
|
|---|
| 157 | AddSetupElements();
|
|---|
| 158 |
|
|---|
| 159 | //
|
|---|
| 160 | // Show camera display for the actual geometry
|
|---|
| 161 | //
|
|---|
| 162 | fDisplay = new MCamDisplay(geom);
|
|---|
| 163 | fDisplay->Draw();
|
|---|
| 164 | fList->Add(fDisplay);
|
|---|
| 165 |
|
|---|
| 166 | ReadFirstEvent();
|
|---|
| 167 |
|
|---|
| 168 | //
|
|---|
| 169 | // Map the window, set up the layout, etc.
|
|---|
| 170 | //
|
|---|
| 171 | MapSubwindows();
|
|---|
| 172 |
|
|---|
| 173 | Layout();
|
|---|
| 174 |
|
|---|
| 175 | SetWindowName("Hillas Event Display");
|
|---|
| 176 | SetIconName("Hillas");
|
|---|
| 177 |
|
|---|
| 178 | MapWindow();
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | // --------------------------------------------------------------------------
|
|---|
| 182 | //
|
|---|
| 183 | // Update event display:
|
|---|
| 184 | // dependent on the setup either the uncleaned or cleand data is shown
|
|---|
| 185 | // together with the hillas ellipse or not.
|
|---|
| 186 | //
|
|---|
| 187 | void MGCamDisplay::UpdateDisplay()
|
|---|
| 188 | {
|
|---|
| 189 | if (!IsInitOk())
|
|---|
| 190 | return;
|
|---|
| 191 |
|
|---|
| 192 | const MParList *plist = fEvtLoop->GetParList();
|
|---|
| 193 |
|
|---|
| 194 | //
|
|---|
| 195 | // Show Hillas ellipse
|
|---|
| 196 | //
|
|---|
| 197 | MHillas *hillas = (MHillas*)plist->FindObject("MHillas");
|
|---|
| 198 |
|
|---|
| 199 | hillas->Print();
|
|---|
| 200 | if (fDisplayHillas)
|
|---|
| 201 | {
|
|---|
| 202 | fCanvas->cd();
|
|---|
| 203 | hillas->Draw();
|
|---|
| 204 | }
|
|---|
| 205 | else
|
|---|
| 206 | hillas->Clear();
|
|---|
| 207 |
|
|---|
| 208 | //
|
|---|
| 209 | // Display the requested event. This does a Canvas update, too.
|
|---|
| 210 | //
|
|---|
| 211 | MCerPhotEvt *evt = NULL;
|
|---|
| 212 | if (fDisplayRaw)
|
|---|
| 213 | {
|
|---|
| 214 | //
|
|---|
| 215 | // Get a clone of MCerPhotEvt which is made before the image cleaning
|
|---|
| 216 | //
|
|---|
| 217 | const MClone *clone = (MClone*)GetTaskList()->FindObject("MClone");
|
|---|
| 218 | evt = (MCerPhotEvt*)clone->GetClone();
|
|---|
| 219 | }
|
|---|
| 220 | else
|
|---|
| 221 | {
|
|---|
| 222 | //
|
|---|
| 223 | // Get MCerPhotEvt which containes the cleaned data
|
|---|
| 224 | //
|
|---|
| 225 | evt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | fDisplay->DrawPhotNum(evt);
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 | // --------------------------------------------------------------------------
|
|---|
| 232 | //
|
|---|
| 233 | // Process the messages from the setup GUI elements.
|
|---|
| 234 | //
|
|---|
| 235 | Bool_t MGCamDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
|---|
| 236 | {
|
|---|
| 237 | switch(GET_MSG(msg))
|
|---|
| 238 | {
|
|---|
| 239 | case kC_COMMAND:
|
|---|
| 240 | switch(GET_SUBMSG(msg))
|
|---|
| 241 | {
|
|---|
| 242 | case kCM_CHECKBUTTON:
|
|---|
| 243 | switch (parm1)
|
|---|
| 244 | {
|
|---|
| 245 | case kCButHillas:
|
|---|
| 246 | fDisplayHillas = !fDisplayHillas;
|
|---|
| 247 | UpdateDisplay();
|
|---|
| 248 | return kTRUE;
|
|---|
| 249 | }
|
|---|
| 250 | break;
|
|---|
| 251 |
|
|---|
| 252 | case kCM_RADIOBUTTON:
|
|---|
| 253 | switch (parm1)
|
|---|
| 254 | {
|
|---|
| 255 | case kRButRawEvt:
|
|---|
| 256 | fDisplayRaw = kTRUE;
|
|---|
| 257 | UpdateDisplay();
|
|---|
| 258 | return kTRUE;
|
|---|
| 259 |
|
|---|
| 260 | case kRButCleanedEvt:
|
|---|
| 261 | fDisplayRaw = kFALSE;
|
|---|
| 262 | UpdateDisplay();
|
|---|
| 263 | return kTRUE;
|
|---|
| 264 | }
|
|---|
| 265 | break;
|
|---|
| 266 | }
|
|---|
| 267 | break;
|
|---|
| 268 | }
|
|---|
| 269 | return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|