| 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@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 | #include "MEventDisplay.h"
|
|---|
| 25 |
|
|---|
| 26 | //
|
|---|
| 27 | // C-lib
|
|---|
| 28 | //
|
|---|
| 29 | #include <stdlib.h> // atoi
|
|---|
| 30 |
|
|---|
| 31 | //
|
|---|
| 32 | // root
|
|---|
| 33 | //
|
|---|
| 34 | #include <TList.h> // TList::Add
|
|---|
| 35 | #include <TStyle.h> // gStyle->SetOptStat
|
|---|
| 36 | #include <TCanvas.h> // TCanvas::cd
|
|---|
| 37 |
|
|---|
| 38 | //
|
|---|
| 39 | // root GUI
|
|---|
| 40 | //
|
|---|
| 41 | #include <TGLabel.h> // TGLabel
|
|---|
| 42 | #include <TGButton.h> // TGPictureButton
|
|---|
| 43 | #include <TG3DLine.h> // TGHorizontal3DLine
|
|---|
| 44 | #include <TGTextEntry.h> // TGTextEntry
|
|---|
| 45 | #include <TGButtonGroup.h> // TGVButtonGroup
|
|---|
| 46 | #include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
|
|---|
| 47 |
|
|---|
| 48 | //
|
|---|
| 49 | // General
|
|---|
| 50 | //
|
|---|
| 51 | #include "MGList.h" // MGList
|
|---|
| 52 |
|
|---|
| 53 | #include "MParList.h" // MParList::AddToList
|
|---|
| 54 | #include "MEvtLoop.h" // MEvtLoop::GetParList
|
|---|
| 55 | #include "MTaskList.h" // MTaskList::AddToList
|
|---|
| 56 |
|
|---|
| 57 | //
|
|---|
| 58 | // Tasks
|
|---|
| 59 | //
|
|---|
| 60 | #include "MReadMarsFile.h" // MReadMarsFile
|
|---|
| 61 | #include "MGeomApply.h" // MGeomApply
|
|---|
| 62 | #include "MFDataMember.h" // MFDataMember
|
|---|
| 63 | #include "MMcPedestalCopy.h" // MMcPedestalCopy
|
|---|
| 64 | #include "MMcPedestalNSBAdd.h" // MMcPedestalNSBAdd
|
|---|
| 65 | #include "MCerPhotCalc.h" // MCerPhotCalc
|
|---|
| 66 | #include "MCerPhotAnal2.h" // MCerPhotAnal2
|
|---|
| 67 | #include "MImgCleanStd.h" // MImgCleanStd
|
|---|
| 68 | #include "MHillasCalc.h" // MHillasCalc
|
|---|
| 69 | #include "MHillasSrcCalc.h" // MHillasSrcCalc
|
|---|
| 70 | #include "MBlindPixelCalc.h" // MBlindPixelCalc
|
|---|
| 71 | #include "MFillH.h" // MFillH
|
|---|
| 72 |
|
|---|
| 73 | //
|
|---|
| 74 | // Container
|
|---|
| 75 | //
|
|---|
| 76 | #include "MHEvent.h" // MHEvent
|
|---|
| 77 | #include "MHCamera.h" // MHCamera
|
|---|
| 78 | #include "MRawEvtData.h" // MRawEvtData
|
|---|
| 79 |
|
|---|
| 80 | ClassImp(MEventDisplay);
|
|---|
| 81 |
|
|---|
| 82 | // --------------------------------------------------------------------------
|
|---|
| 83 | //
|
|---|
| 84 | // Constructor.
|
|---|
| 85 | //
|
|---|
| 86 | MEventDisplay::MEventDisplay(const char *filename) : MStatusDisplay()
|
|---|
| 87 | {
|
|---|
| 88 | //
|
|---|
| 89 | // Setup Task list for hillas calculation
|
|---|
| 90 | //
|
|---|
| 91 | SetupTaskList("Events", filename);
|
|---|
| 92 |
|
|---|
| 93 | //
|
|---|
| 94 | // Add MEventDisplay GUI elements to the display
|
|---|
| 95 | //
|
|---|
| 96 | AddUserFrame(filename);
|
|---|
| 97 |
|
|---|
| 98 | //
|
|---|
| 99 | // Show new part of the window, resize to correct aspect ratio
|
|---|
| 100 | //
|
|---|
| 101 | // FIXME: This should be done by MStatusDisplay automatically
|
|---|
| 102 | Resize(GetWidth(), GetHeight() + fUserFrame->GetDefaultHeight());
|
|---|
| 103 | SetWindowName("Event Display");
|
|---|
| 104 | MapSubwindows();
|
|---|
| 105 |
|
|---|
| 106 | //
|
|---|
| 107 | // Readin first event and display it
|
|---|
| 108 | //
|
|---|
| 109 | ReadFirstEvent();
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | // --------------------------------------------------------------------------
|
|---|
| 113 | //
|
|---|
| 114 | // Destructor: PostProcess eventloop, delete eventloop with all containers
|
|---|
| 115 | //
|
|---|
| 116 | MEventDisplay::~MEventDisplay()
|
|---|
| 117 | {
|
|---|
| 118 | fEvtLoop->PostProcess();
|
|---|
| 119 | delete fEvtLoop;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | // --------------------------------------------------------------------------
|
|---|
| 123 | //
|
|---|
| 124 | // Return reading task
|
|---|
| 125 | //
|
|---|
| 126 | MReadTree *MEventDisplay::GetReader() const
|
|---|
| 127 | {
|
|---|
| 128 | MParList *plist = (MParList*)fEvtLoop->GetParList();
|
|---|
| 129 | MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList");
|
|---|
| 130 | MReadTree *reader = (MReadTree*)tlist->FindObject("MRead");
|
|---|
| 131 | return reader;
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | // --------------------------------------------------------------------------
|
|---|
| 135 | //
|
|---|
| 136 | // Setup Task and parameter list for hillas calculation,
|
|---|
| 137 | // preprocess tasks and read in first event (process)
|
|---|
| 138 | //
|
|---|
| 139 | void MEventDisplay::SetupTaskList(const char *tname, const char *fname)
|
|---|
| 140 | {
|
|---|
| 141 | //
|
|---|
| 142 | // Setup an empty job, with a reader task only.
|
|---|
| 143 | // All tasks and parameter containers are deleted automatically
|
|---|
| 144 | // (via SetOwner())
|
|---|
| 145 | //
|
|---|
| 146 | MTaskList *tlist = new MTaskList;
|
|---|
| 147 | tlist->SetOwner();
|
|---|
| 148 |
|
|---|
| 149 | MReadMarsFile *read = new MReadMarsFile(tname, fname);
|
|---|
| 150 | read->DisableAutoScheme();
|
|---|
| 151 | tlist->AddToList(read);
|
|---|
| 152 |
|
|---|
| 153 | MGeomApply *apl = new MGeomApply;
|
|---|
| 154 | tlist->AddToList(apl);
|
|---|
| 155 |
|
|---|
| 156 | MParList *plist = new MParList;
|
|---|
| 157 | plist->SetOwner();
|
|---|
| 158 | plist->AddToList(tlist);
|
|---|
| 159 |
|
|---|
| 160 | fEvtLoop = new MEvtLoop;
|
|---|
| 161 | fEvtLoop->SetOwner();
|
|---|
| 162 | fEvtLoop->SetParList(plist);
|
|---|
| 163 |
|
|---|
| 164 | MHEvent *evt1 = new MHEvent(MHEvent::kEvtSignal);
|
|---|
| 165 | MHEvent *evt2 = new MHEvent(MHEvent::kEvtSignal);
|
|---|
| 166 | MHEvent *evt3 = new MHEvent(MHEvent::kEvtPedestal);
|
|---|
| 167 | MHEvent *evt4 = new MHEvent(MHEvent::kEvtPedestalRMS);
|
|---|
| 168 | MHEvent *evt5 = new MHEvent(MHEvent::kEvtRelativeSignal);
|
|---|
| 169 | MHEvent *evt6 = new MHEvent(MHEvent::kEvtCleaningLevels);
|
|---|
| 170 | evt1->SetName("Signal");
|
|---|
| 171 | evt2->SetName("Cleaned");
|
|---|
| 172 | evt3->SetName("Pedestal");
|
|---|
| 173 | evt4->SetName("PedRMS");
|
|---|
| 174 | evt5->SetName("Signal/PedRMS");
|
|---|
| 175 | evt6->SetName("CleanLevels");
|
|---|
| 176 | plist->AddToList(evt1);
|
|---|
| 177 | plist->AddToList(evt2);
|
|---|
| 178 | plist->AddToList(evt3);
|
|---|
| 179 | plist->AddToList(evt4);
|
|---|
| 180 | plist->AddToList(evt5);
|
|---|
| 181 | plist->AddToList(evt6);
|
|---|
| 182 |
|
|---|
| 183 | MMcPedestalCopy *pcopy = new MMcPedestalCopy;
|
|---|
| 184 | MMcPedestalNSBAdd *pdnsb = new MMcPedestalNSBAdd;
|
|---|
| 185 | MCerPhotCalc *ncalc = new MCerPhotCalc;
|
|---|
| 186 | MCerPhotAnal2 *nanal = new MCerPhotAnal2;
|
|---|
| 187 | MFillH *fill1 = new MFillH(evt1, "MCerPhotEvt", "MFillH1");
|
|---|
| 188 | MImgCleanStd *clean = new MImgCleanStd;
|
|---|
| 189 | MFillH *fill2 = new MFillH(evt2, "MCerPhotEvt", "MFillH2");
|
|---|
| 190 | MFillH *fill3 = new MFillH(evt3, "MPedestalCam", "MFillH3");
|
|---|
| 191 | MFillH *fill4 = new MFillH(evt4, "MPedestalCam", "MFillH4");
|
|---|
| 192 | MFillH *fill5 = new MFillH(evt5, "MCameraData", "MFillH5");
|
|---|
| 193 | MFillH *fill6 = new MFillH(evt6, "MCameraData", "MFillH6");
|
|---|
| 194 | MBlindPixelCalc *blind = new MBlindPixelCalc;
|
|---|
| 195 | MHillasCalc *hcalc = new MHillasCalc;
|
|---|
| 196 | MHillasSrcCalc *scalc = new MHillasSrcCalc;
|
|---|
| 197 |
|
|---|
| 198 | MFilter *f1=new MFDataMember("MRawRunHeader.fRunType", '>', 255.5);
|
|---|
| 199 | MFilter *f2=new MFDataMember("MRawRunHeader.fRunType", '<', 255.5);
|
|---|
| 200 |
|
|---|
| 201 | ncalc->SetFilter(f1);
|
|---|
| 202 | nanal->SetFilter(f2);
|
|---|
| 203 |
|
|---|
| 204 | tlist->AddToList(f1);
|
|---|
| 205 | tlist->AddToList(f2);
|
|---|
| 206 | tlist->AddToList(pcopy);
|
|---|
| 207 | tlist->AddToList(pdnsb);
|
|---|
| 208 | tlist->AddToList(ncalc);
|
|---|
| 209 | tlist->AddToList(nanal);
|
|---|
| 210 | tlist->AddToList(fill1);
|
|---|
| 211 | tlist->AddToList(clean);
|
|---|
| 212 | tlist->AddToList(fill2);
|
|---|
| 213 | tlist->AddToList(fill3);
|
|---|
| 214 | tlist->AddToList(fill4);
|
|---|
| 215 | tlist->AddToList(fill5);
|
|---|
| 216 | tlist->AddToList(fill6);
|
|---|
| 217 | tlist->AddToList(blind);
|
|---|
| 218 | tlist->AddToList(hcalc);
|
|---|
| 219 | tlist->AddToList(scalc);
|
|---|
| 220 |
|
|---|
| 221 | //
|
|---|
| 222 | // Now distribute Display to all tasks
|
|---|
| 223 | //
|
|---|
| 224 | tlist->SetDisplay(this);
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| 227 | // --------------------------------------------------------------------------
|
|---|
| 228 | //
|
|---|
| 229 | // Add the top part of the frame: This is filename and treename display
|
|---|
| 230 | //
|
|---|
| 231 | void MEventDisplay::AddTopFramePart1(TGCompositeFrame *frame,
|
|---|
| 232 | const char *filename,
|
|---|
| 233 | const char *treename)
|
|---|
| 234 | {
|
|---|
| 235 | //
|
|---|
| 236 | // --- the top1 part of the window ---
|
|---|
| 237 | //
|
|---|
| 238 | TGHorizontalFrame *top1 = new TGHorizontalFrame(frame, 1, 1);
|
|---|
| 239 | fList->Add(top1);
|
|---|
| 240 |
|
|---|
| 241 | //
|
|---|
| 242 | // create gui elements
|
|---|
| 243 | //
|
|---|
| 244 | TGLabel *file = new TGLabel(top1, new TGString(Form("%s#%s", filename, treename)));
|
|---|
| 245 | fList->Add(file);
|
|---|
| 246 |
|
|---|
| 247 | //
|
|---|
| 248 | // layout and add gui elements in/to frame
|
|---|
| 249 | //
|
|---|
| 250 | TGLayoutHints *laystd = new TGLayoutHints(kLHintsCenterX, 5, 5);
|
|---|
| 251 | fList->Add(laystd);
|
|---|
| 252 |
|
|---|
| 253 | top1->AddFrame(file, laystd);
|
|---|
| 254 |
|
|---|
| 255 | //
|
|---|
| 256 | // --- the top1 part of the window ---
|
|---|
| 257 | //
|
|---|
| 258 | TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 1, 1);
|
|---|
| 259 | fList->Add(top2);
|
|---|
| 260 |
|
|---|
| 261 | //
|
|---|
| 262 | // layout and add frames
|
|---|
| 263 | //
|
|---|
| 264 | TGLayoutHints *laytop1 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5);
|
|---|
| 265 | fList->Add(laytop1);
|
|---|
| 266 | frame->AddFrame(top1, laytop1);
|
|---|
| 267 | frame->AddFrame(top2, laytop1);
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 | // --------------------------------------------------------------------------
|
|---|
| 271 | //
|
|---|
| 272 | // Add the second part of the top frame: This are the event number controls
|
|---|
| 273 | //
|
|---|
| 274 | void MEventDisplay::AddTopFramePart2(TGCompositeFrame *frame)
|
|---|
| 275 | {
|
|---|
| 276 | //
|
|---|
| 277 | // --- the top2 part of the window ---
|
|---|
| 278 | //
|
|---|
| 279 | TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 1, 1);
|
|---|
| 280 | fList->Add(top2);
|
|---|
| 281 |
|
|---|
| 282 | //
|
|---|
| 283 | // Create the gui elements
|
|---|
| 284 | //
|
|---|
| 285 | TGTextButton *prevevt = new TGTextButton(top2, " << ", kEvtPrev);
|
|---|
| 286 | prevevt->Associate(this);
|
|---|
| 287 |
|
|---|
| 288 | TGLabel *evtnr = new TGLabel(top2, new TGString("Event:"));
|
|---|
| 289 |
|
|---|
| 290 | TGTextEntry *entry=new TGTextEntry(top2, new TGTextBuffer(100), kEvtNumber);
|
|---|
| 291 | entry->Resize(60, entry->GetDefaultHeight());
|
|---|
| 292 | entry->Associate(this);
|
|---|
| 293 |
|
|---|
| 294 | fNumOfEvts = new TGLabel(top2, "of .");
|
|---|
| 295 |
|
|---|
| 296 | TGTextButton *nextevt = new TGTextButton (top2, " >> ", kEvtNext);
|
|---|
| 297 | nextevt->Associate(this);
|
|---|
| 298 |
|
|---|
| 299 | //
|
|---|
| 300 | // Add gui elements to 'atotodel'
|
|---|
| 301 | //
|
|---|
| 302 | fList->Add(prevevt);
|
|---|
| 303 | fList->Add(evtnr);
|
|---|
| 304 | fList->Add(entry);
|
|---|
| 305 | fList->Add(fNumOfEvts);
|
|---|
| 306 | fList->Add(nextevt);
|
|---|
| 307 |
|
|---|
| 308 | //
|
|---|
| 309 | // add the gui elements to the frame
|
|---|
| 310 | //
|
|---|
| 311 | TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 5);
|
|---|
| 312 | fList->Add(laystd);
|
|---|
| 313 |
|
|---|
| 314 | top2->AddFrame(prevevt, laystd);
|
|---|
| 315 | top2->AddFrame(evtnr, laystd);
|
|---|
| 316 | top2->AddFrame(entry, laystd);
|
|---|
| 317 | top2->AddFrame(fNumOfEvts, laystd);
|
|---|
| 318 | top2->AddFrame(nextevt, laystd);
|
|---|
| 319 |
|
|---|
| 320 | TGLayoutHints *laystd2 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5, 5);
|
|---|
| 321 | fList->Add(laystd2);
|
|---|
| 322 | frame->AddFrame(top2, laystd2);
|
|---|
| 323 |
|
|---|
| 324 | //
|
|---|
| 325 | // Add trailing line...
|
|---|
| 326 | //
|
|---|
| 327 | TGHorizontal3DLine *line = new TGHorizontal3DLine(frame);
|
|---|
| 328 | TGLayoutHints *layline = new TGLayoutHints(kLHintsExpandX);
|
|---|
| 329 | fList->Add(line);
|
|---|
| 330 | fList->Add(layline);
|
|---|
| 331 | frame->AddFrame(line, layline);
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | // --------------------------------------------------------------------------
|
|---|
| 335 | //
|
|---|
| 336 | // Add the user frame part of the display
|
|---|
| 337 | //
|
|---|
| 338 | void MEventDisplay::AddUserFrame(const char* filename)
|
|---|
| 339 | {
|
|---|
| 340 | fUserFrame->ChangeOptions(kHorizontalFrame);
|
|---|
| 341 |
|
|---|
| 342 | TGCompositeFrame *vf1 = new TGVerticalFrame(fUserFrame, 1, 1);
|
|---|
| 343 | TGCompositeFrame *vf2 = new TGVerticalFrame(fUserFrame, 1, 1);
|
|---|
| 344 |
|
|---|
| 345 | AddTopFramePart1(vf1, filename, "Events");
|
|---|
| 346 | AddTopFramePart2(vf1);
|
|---|
| 347 |
|
|---|
| 348 | // create root embedded canvas and add it to the tab
|
|---|
| 349 | TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas("Slices", vf2, vf1->GetDefaultHeight()*3/2, vf1->GetDefaultHeight(), 0);
|
|---|
| 350 | vf2->AddFrame(ec);
|
|---|
| 351 | fList->Add(ec);
|
|---|
| 352 |
|
|---|
| 353 | // set background and border mode of the canvas
|
|---|
| 354 | fCanvas = ec->GetCanvas();
|
|---|
| 355 | fCanvas->SetBorderMode(0);
|
|---|
| 356 | gROOT->GetListOfCanvases()->Add(fCanvas);
|
|---|
| 357 | //fCanvas->SetBorderSize(1);
|
|---|
| 358 | //fCanvas->SetBit(kNoContextMenu);
|
|---|
| 359 | //fCanvas->SetFillColor(16);
|
|---|
| 360 |
|
|---|
| 361 | TGLayoutHints *lay = new TGLayoutHints(kLHintsExpandX);
|
|---|
| 362 | fUserFrame->AddFrame(vf1, lay);
|
|---|
| 363 | fUserFrame->AddFrame(vf2);
|
|---|
| 364 | }
|
|---|
| 365 |
|
|---|
| 366 | // --------------------------------------------------------------------------
|
|---|
| 367 | //
|
|---|
| 368 | // Checks if the event number is valid, and if so reads the new event
|
|---|
| 369 | // and updates the display
|
|---|
| 370 | //
|
|---|
| 371 | void MEventDisplay::ReadinEvent(Int_t dir)
|
|---|
| 372 | {
|
|---|
| 373 | MParList *plist = (MParList*)fEvtLoop->GetParList();
|
|---|
| 374 | MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList");
|
|---|
| 375 | MRawEvtData *raw = (MRawEvtData*)plist->FindObject("MRawEvtData");
|
|---|
| 376 | if (!raw)
|
|---|
| 377 | return;
|
|---|
| 378 |
|
|---|
| 379 | //
|
|---|
| 380 | // Read first event.
|
|---|
| 381 | //
|
|---|
| 382 | MReadTree *reader = GetReader();
|
|---|
| 383 |
|
|---|
| 384 | const Int_t num = reader->GetNumEntry();
|
|---|
| 385 |
|
|---|
| 386 | do
|
|---|
| 387 | {
|
|---|
| 388 | if (dir<0 && !reader->DecEventNum())
|
|---|
| 389 | {
|
|---|
| 390 | reader->SetEventNum(num);
|
|---|
| 391 | return;
|
|---|
| 392 | }
|
|---|
| 393 | if (dir>0 && !reader->IncEventNum())
|
|---|
| 394 | {
|
|---|
| 395 | reader->SetEventNum(num);
|
|---|
| 396 | return;
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 | if (!tlist->Process())
|
|---|
| 400 | return;
|
|---|
| 401 |
|
|---|
| 402 | reader->DecEventNum();
|
|---|
| 403 |
|
|---|
| 404 | } while (raw->GetNumPixels()<1 && dir!=0);
|
|---|
| 405 |
|
|---|
| 406 | //
|
|---|
| 407 | // Cleare the 'FADC canvas'
|
|---|
| 408 | //
|
|---|
| 409 | fCanvas->Clear();
|
|---|
| 410 | fCanvas->Modified();
|
|---|
| 411 | fCanvas->Update();
|
|---|
| 412 |
|
|---|
| 413 | //
|
|---|
| 414 | // Print parameters
|
|---|
| 415 | //
|
|---|
| 416 | plist->FindObject("MHillas")->Print();
|
|---|
| 417 | plist->FindObject("MHillasExt")->Print();
|
|---|
| 418 | plist->FindObject("MHillasSrc")->Print();
|
|---|
| 419 | plist->FindObject("MNewImagePar")->Print();
|
|---|
| 420 |
|
|---|
| 421 | //
|
|---|
| 422 | // UpdateDisplay
|
|---|
| 423 | //
|
|---|
| 424 | gStyle->SetOptStat(1101);
|
|---|
| 425 | Update();
|
|---|
| 426 |
|
|---|
| 427 | TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
|
|---|
| 428 | entry->SetText(Form("%d", reader->GetNumEntry()+1));
|
|---|
| 429 | }
|
|---|
| 430 |
|
|---|
| 431 | // --------------------------------------------------------------------------
|
|---|
| 432 | //
|
|---|
| 433 | // Read first event to get display booted
|
|---|
| 434 | //
|
|---|
| 435 | void MEventDisplay::ReadFirstEvent()
|
|---|
| 436 | {
|
|---|
| 437 | if (!fEvtLoop->PreProcess())
|
|---|
| 438 | return;
|
|---|
| 439 |
|
|---|
| 440 | //
|
|---|
| 441 | // Get parlist
|
|---|
| 442 | //
|
|---|
| 443 | MParList *plist = (MParList*)fEvtLoop->GetParList();
|
|---|
| 444 |
|
|---|
| 445 | //
|
|---|
| 446 | // Add Geometry tab
|
|---|
| 447 | //
|
|---|
| 448 | AddGeometryTabs();
|
|---|
| 449 |
|
|---|
| 450 | //
|
|---|
| 451 | // Now read event...
|
|---|
| 452 | //
|
|---|
| 453 | ReadinEvent();
|
|---|
| 454 |
|
|---|
| 455 | TGString *txt = new TGString(Form("of %d", GetReader()->GetEntries()));
|
|---|
| 456 | fNumOfEvts->SetText(txt);
|
|---|
| 457 |
|
|---|
| 458 | //
|
|---|
| 459 | // Draw ellipse on top of all pads
|
|---|
| 460 | //
|
|---|
| 461 | TObject *hillas = plist->FindObject("MHillas");
|
|---|
| 462 | for (int i=1; i<7;i++)
|
|---|
| 463 | {
|
|---|
| 464 | TCanvas *c = GetCanvas(i);
|
|---|
| 465 | c->GetPad(1)->cd(1);
|
|---|
| 466 | hillas->Draw();
|
|---|
| 467 | }
|
|---|
| 468 | }
|
|---|
| 469 |
|
|---|
| 470 | // --------------------------------------------------------------------------
|
|---|
| 471 | //
|
|---|
| 472 | // Adds the geometry tab
|
|---|
| 473 | //
|
|---|
| 474 | void MEventDisplay::AddGeometryTabs()
|
|---|
| 475 | {
|
|---|
| 476 | MGeomCam *geom = (MGeomCam*)fEvtLoop->GetParList()->FindObject("MGeomCam");
|
|---|
| 477 | if (!geom)
|
|---|
| 478 | return;
|
|---|
| 479 |
|
|---|
| 480 | TCanvas &c1=AddTab("Geometry");
|
|---|
| 481 |
|
|---|
| 482 | MHCamera *cam = new MHCamera(*geom);
|
|---|
| 483 | cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
|
|---|
| 484 | cam->Draw("pixelindex");
|
|---|
| 485 | fList->Add(cam);
|
|---|
| 486 |
|
|---|
| 487 | c1.Modified();
|
|---|
| 488 | c1.Update();
|
|---|
| 489 |
|
|---|
| 490 | TCanvas &c2=AddTab("Sectors");
|
|---|
| 491 |
|
|---|
| 492 | cam = new MHCamera(*geom);
|
|---|
| 493 | cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
|
|---|
| 494 | cam->Draw("sectorindex");
|
|---|
| 495 | fList->Add(cam);
|
|---|
| 496 |
|
|---|
| 497 | c2.Modified();
|
|---|
| 498 | c2.Update();
|
|---|
| 499 | }
|
|---|
| 500 |
|
|---|
| 501 | // --------------------------------------------------------------------------
|
|---|
| 502 | //
|
|---|
| 503 | // ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
|---|
| 504 | //
|
|---|
| 505 | // Processes information from all GUI items.
|
|---|
| 506 | // Selecting an item usually generates an event with 4 parameters.
|
|---|
| 507 | // The first two are packed into msg (first and second bytes).
|
|---|
| 508 | // The other two are parm1 and parm2.
|
|---|
| 509 | //
|
|---|
| 510 | Bool_t MEventDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
|
|---|
| 511 | {
|
|---|
| 512 | switch (GET_MSG(msg))
|
|---|
| 513 | {
|
|---|
| 514 | case kC_TEXTENTRY:
|
|---|
| 515 | switch(GET_SUBMSG(msg))
|
|---|
| 516 | {
|
|---|
| 517 | case kTE_ENTER:
|
|---|
| 518 | switch(GET_SUBMSG(msg))
|
|---|
| 519 | {
|
|---|
| 520 | case kTE_ENTER:
|
|---|
| 521 | {
|
|---|
| 522 | TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
|
|---|
| 523 | if (GetReader()->SetEventNum(atoi(entry->GetText())-1))
|
|---|
| 524 | ReadinEvent();
|
|---|
| 525 | }
|
|---|
| 526 | return kTRUE;
|
|---|
| 527 | }
|
|---|
| 528 | return kTRUE;
|
|---|
| 529 | }
|
|---|
| 530 | break;
|
|---|
| 531 |
|
|---|
| 532 | case kC_COMMAND:
|
|---|
| 533 | switch (GET_SUBMSG(msg))
|
|---|
| 534 | {
|
|---|
| 535 | case kCM_TAB:
|
|---|
| 536 | {
|
|---|
| 537 | //
|
|---|
| 538 | // Set name for 'FADC canvas'. The name is the anchor for MHCamera.
|
|---|
| 539 | // and clear the canvas
|
|---|
| 540 | TCanvas *c = GetCanvas(mp1);
|
|---|
| 541 | if (!c)
|
|---|
| 542 | break;
|
|---|
| 543 | MHEvent *o = (MHEvent*)fEvtLoop->GetParList()->FindObject(c->GetName());
|
|---|
| 544 | if (!o)
|
|---|
| 545 | break;
|
|---|
| 546 | fCanvas->SetName(Form("%p;%p;PixelContent", o->GetHist(), c->GetPad(1)));
|
|---|
| 547 | }
|
|---|
| 548 | break;
|
|---|
| 549 |
|
|---|
| 550 | case kCM_BUTTON:
|
|---|
| 551 | switch (mp1)
|
|---|
| 552 | {
|
|---|
| 553 | case kEvtPrev:
|
|---|
| 554 | ReadinEvent(-1);
|
|---|
| 555 | return kTRUE;
|
|---|
| 556 |
|
|---|
| 557 | case kEvtNext:
|
|---|
| 558 | ReadinEvent(+1);
|
|---|
| 559 | return kTRUE;
|
|---|
| 560 | }
|
|---|
| 561 | return kTRUE;
|
|---|
| 562 | }
|
|---|
| 563 | break;
|
|---|
| 564 | }
|
|---|
| 565 |
|
|---|
| 566 | return MStatusDisplay::ProcessMessage(msg, mp1, mp2);
|
|---|
| 567 | }
|
|---|