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