| 1 | /* ======================================================================== *\
|
|---|
| 2 | ! $Name: not supported by cvs2svn $:$Id: MEventDisplay.cc,v 1.59 2007-03-04 13:49:05 tbretz Exp $
|
|---|
| 3 | ! --------------------------------------------------------------------------
|
|---|
| 4 | !
|
|---|
| 5 | ! *
|
|---|
| 6 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 7 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 8 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 9 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 10 | ! *
|
|---|
| 11 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 12 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 13 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 14 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 15 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 16 | ! * or implied warranty.
|
|---|
| 17 | ! *
|
|---|
| 18 | !
|
|---|
| 19 | !
|
|---|
| 20 | ! Author(s): Thomas Bretz, 10/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 21 | !
|
|---|
| 22 | ! Copyright: MAGIC Software Development, 2000-2006
|
|---|
| 23 | !
|
|---|
| 24 | !
|
|---|
| 25 | \* ======================================================================== */
|
|---|
| 26 | #include "MEventDisplay.h"
|
|---|
| 27 |
|
|---|
| 28 | //
|
|---|
| 29 | // C-lib
|
|---|
| 30 | //
|
|---|
| 31 | #include <stdlib.h> // atoi
|
|---|
| 32 |
|
|---|
| 33 | //
|
|---|
| 34 | // root
|
|---|
| 35 | //
|
|---|
| 36 | #include <TFile.h> // TFile
|
|---|
| 37 | #include <TTree.h> // TTree
|
|---|
| 38 | #include <TList.h> // TList::Add
|
|---|
| 39 | #include <TStyle.h> // gStyle->SetOptStat
|
|---|
| 40 | #include <TCanvas.h> // TCanvas::cd
|
|---|
| 41 | #include <TSystem.h> // TSystem::BaseName
|
|---|
| 42 |
|
|---|
| 43 | //
|
|---|
| 44 | // root GUI
|
|---|
| 45 | //
|
|---|
| 46 | #include <TGLabel.h> // TGLabel
|
|---|
| 47 | #include <TGButton.h> // TGPictureButton
|
|---|
| 48 | #include <TG3DLine.h> // TGHorizontal3DLine
|
|---|
| 49 | #include <TGTextEntry.h> // TGTextEntry
|
|---|
| 50 | #include <TGButtonGroup.h> // TGVButtonGroup
|
|---|
| 51 | #include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
|
|---|
| 52 |
|
|---|
| 53 | //
|
|---|
| 54 | // General
|
|---|
| 55 | //
|
|---|
| 56 | #include "MGList.h" // MGList
|
|---|
| 57 |
|
|---|
| 58 | #include "MLog.h"
|
|---|
| 59 | #include "MLogManip.h"
|
|---|
| 60 |
|
|---|
| 61 | #include "MParList.h" // MParList::AddToList
|
|---|
| 62 | #include "MEvtLoop.h" // MEvtLoop::GetParList
|
|---|
| 63 | #include "MTaskList.h" // MTaskList::AddToList
|
|---|
| 64 |
|
|---|
| 65 | //
|
|---|
| 66 | // Tasks
|
|---|
| 67 | //
|
|---|
| 68 | #include "MReadMarsFile.h" // MReadMarsFile
|
|---|
| 69 | #include "MGeomApply.h" // MGeomApply
|
|---|
| 70 | #include "MPedestalSubtract.h" // MPedestalSubtract
|
|---|
| 71 | #include "MFDataMember.h" // MFDataMember
|
|---|
| 72 | #include "MMcPedestalCopy.h" // MMcPedestalCopy
|
|---|
| 73 | #include "MMcPedestalNSBAdd.h" // MMcPedestalNSBAdd
|
|---|
| 74 |
|
|---|
| 75 | #include "MSignalCalc.h" // MPedestalCalc
|
|---|
| 76 | #include "MTaskEnv.h" // MTaskEnv
|
|---|
| 77 | #include "MExtractTimeAndChargeDigitalFilter.h"
|
|---|
| 78 | #include "MImgCleanStd.h" // MImgCleanStd
|
|---|
| 79 | #include "MHillasCalc.h" // MHillasCalc
|
|---|
| 80 | #include "MCalibrationRelTimeCalc.h" // MCalibrationRelTimeCalc
|
|---|
| 81 | #include "MCalibrationPatternDecode.h" // MCalibrationPatternDecode
|
|---|
| 82 | #include "MPrint.h"
|
|---|
| 83 | #include "MBadPixelsCalc.h" // MBadPixelsCalc
|
|---|
| 84 | #include "MBadPixelsTreat.h" // MBadPixelsTreat
|
|---|
| 85 | #include "MFillH.h" // MFillH
|
|---|
| 86 | #include "MMcCalibrationUpdate.h" // MMcCalibrationUpdate
|
|---|
| 87 | #include "MCalibrateData.h" // MCalibrateData
|
|---|
| 88 | #include "MMuonSearchParCalc.h" // MMuonSearchParCalc
|
|---|
| 89 | #include "MMuonCalibParCalc.h" // MMuonCalibParCalc
|
|---|
| 90 | #include "MContinue.h" // MContinue
|
|---|
| 91 | //#include "MMcTriggerLvl2Calc.h" // MMcTriggerLvl2Calc
|
|---|
| 92 |
|
|---|
| 93 | //
|
|---|
| 94 | // Container
|
|---|
| 95 | //
|
|---|
| 96 | #include "MHillas.h" // MHillas::Print(const MGeomCam&)
|
|---|
| 97 | #include "MHillasExt.h" // MHillasExt::Print(const MGeomCam&)
|
|---|
| 98 | #include "MHillasSrc.h" // MHillasSrc::Print(const MGeomCam&)
|
|---|
| 99 | #include "MImagePar.h" // MImagePar::Print(const MGeomCam&)
|
|---|
| 100 | #include "MNewImagePar.h" // MNewImagePar::Print(const MGeomCam&)
|
|---|
| 101 | #include "MHEvent.h" // MHEvent
|
|---|
| 102 | #include "MHCamera.h" // MHCamera
|
|---|
| 103 | #include "MRawEvtData.h" // MRawEvtData
|
|---|
| 104 | #include "MArrivalTimeCam.h" // MArrivalTimeCam
|
|---|
| 105 | #include "MBadPixelsCam.h" // MBadPixelsCam
|
|---|
| 106 | #include "MPedPhotCam.h" // MPedPhotCam
|
|---|
| 107 | #include "MCalibrationChargeCam.h" // MCalibrationChargeCam
|
|---|
| 108 | #include "MMuonSearchPar.h" // MMuonCalibPar
|
|---|
| 109 | //#include "MMcTriggerLvl2.h" // MMcTriggerLvl2
|
|---|
| 110 |
|
|---|
| 111 | using namespace std;
|
|---|
| 112 |
|
|---|
| 113 | ClassImp(MEventDisplay);
|
|---|
| 114 |
|
|---|
| 115 | // --------------------------------------------------------------------------
|
|---|
| 116 | //
|
|---|
| 117 | // Constructor.
|
|---|
| 118 | //
|
|---|
| 119 | MEventDisplay::MEventDisplay(const char *fname) : MStatusDisplay(), fEvtLoop(0)
|
|---|
| 120 | {
|
|---|
| 121 | //
|
|---|
| 122 | // Setup Task list for hillas calculation
|
|---|
| 123 | //
|
|---|
| 124 | SetupTaskList("Events", fname);
|
|---|
| 125 |
|
|---|
| 126 | //
|
|---|
| 127 | // Add MEventDisplay GUI elements to the display
|
|---|
| 128 | //
|
|---|
| 129 | AddUserFrame(fname);
|
|---|
| 130 |
|
|---|
| 131 | //
|
|---|
| 132 | // Show new part of the window, resize to correct aspect ratio
|
|---|
| 133 | //
|
|---|
| 134 | // FIXME: This should be done by MStatusDisplay automatically
|
|---|
| 135 | Resize(768, 576 + fUserFrame->GetDefaultHeight());//TMath::Nint(GetWidth()*1.2), TMath::Nint(GetHeight()*1.2 + fUserFrame->GetDefaultHeight()));
|
|---|
| 136 | SetWindowName("Event Display");
|
|---|
| 137 | MapSubwindows();
|
|---|
| 138 |
|
|---|
| 139 | //
|
|---|
| 140 | // Readin first event and display it
|
|---|
| 141 | //
|
|---|
| 142 | if (fEvtLoop)
|
|---|
| 143 | ReadFirstEvent();
|
|---|
| 144 |
|
|---|
| 145 | SetNoContextMenu(kFALSE);
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | // --------------------------------------------------------------------------
|
|---|
| 149 | //
|
|---|
| 150 | // Destructor: PostProcess eventloop, delete eventloop with all containers
|
|---|
| 151 | //
|
|---|
| 152 | MEventDisplay::~MEventDisplay()
|
|---|
| 153 | {
|
|---|
| 154 | if (fEvtLoop)
|
|---|
| 155 | {
|
|---|
| 156 | fEvtLoop->PostProcess();
|
|---|
| 157 | delete fEvtLoop;
|
|---|
| 158 | }
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | Int_t MEventDisplay::GetFileType(const char *tree, const char *fname) const
|
|---|
| 162 | {
|
|---|
| 163 | TFile f(fname, "READ");
|
|---|
| 164 | TTree *t = (TTree*)f.Get(tree);
|
|---|
| 165 | if (!t)
|
|---|
| 166 | return -1;
|
|---|
| 167 |
|
|---|
| 168 | if (t->FindBranch("MSignalCam."))
|
|---|
| 169 | return 1;
|
|---|
| 170 |
|
|---|
| 171 | if (t->FindBranch("MRawEvtData."))
|
|---|
| 172 | return 2;
|
|---|
| 173 |
|
|---|
| 174 | return -2;
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | // --------------------------------------------------------------------------
|
|---|
| 178 | //
|
|---|
| 179 | // Setup Task and parameter list for hillas calculation,
|
|---|
| 180 | // preprocess tasks and read in first event (process)
|
|---|
| 181 | //
|
|---|
| 182 | void MEventDisplay::SetupTaskList(const char *tname, const char *fname)
|
|---|
| 183 | {
|
|---|
| 184 | // MCalibrationChargeCam *ccam=0;
|
|---|
| 185 | // MPedPhotCam *pcam=0;
|
|---|
| 186 |
|
|---|
| 187 | MBadPixelsCam *badpix = new MBadPixelsCam;
|
|---|
| 188 |
|
|---|
| 189 | const Int_t type = GetFileType(tname, fname);
|
|---|
| 190 | switch (type)
|
|---|
| 191 | {
|
|---|
| 192 | case 1: gLog << all << "Calibrated Data File detected..." << endl; break;
|
|---|
| 193 | case 2: gLog << all << "Raw Data File detected..." << endl; break;
|
|---|
| 194 | case -2: gLog << err << "File type unknown... abort." << endl; return;
|
|---|
| 195 | case -1: gLog << err << "Tree " << tname << " not found... abort." << endl; return;
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | //
|
|---|
| 199 | // Setup an empty job, with a reader task only.
|
|---|
| 200 | // All tasks and parameter containers are deleted automatically
|
|---|
| 201 | // (via SetOwner())
|
|---|
| 202 | //
|
|---|
| 203 | MTaskList *tlist = new MTaskList;
|
|---|
| 204 | tlist->SetOwner();
|
|---|
| 205 |
|
|---|
| 206 | MReadMarsFile *read = new MReadMarsFile(tname, fname);
|
|---|
| 207 | read->DisableAutoScheme();
|
|---|
| 208 | tlist->AddToList(read);
|
|---|
| 209 |
|
|---|
| 210 | MGeomApply *apl = new MGeomApply;
|
|---|
| 211 | tlist->AddToList(apl);
|
|---|
| 212 |
|
|---|
| 213 | MParList *plist = new MParList;
|
|---|
| 214 | plist->SetOwner();
|
|---|
| 215 | plist->AddToList(tlist);
|
|---|
| 216 | plist->AddToList(badpix);
|
|---|
| 217 |
|
|---|
| 218 | //MArrivalTime *atime = new MArrivalTime;
|
|---|
| 219 | //plist->AddToList(atime);
|
|---|
| 220 |
|
|---|
| 221 | MHEvent *evt01 = new MHEvent(MHEvent::kEvtSignalDensity);
|
|---|
| 222 | MHEvent *evt02 = new MHEvent(MHEvent::kEvtSignalDensity);
|
|---|
| 223 | MHEvent *evt03 = new MHEvent(type==1?MHEvent::kEvtPedPhot:MHEvent::kEvtPedestal);
|
|---|
| 224 | MHEvent *evt04 = new MHEvent(type==1?MHEvent::kEvtPedPhotRMS:MHEvent::kEvtPedestalRMS);
|
|---|
| 225 | MHEvent *evt06a= new MHEvent(MHEvent::kEvtCleaningData);
|
|---|
| 226 | MHEvent *evt06b= new MHEvent(MHEvent::kEvtCleaningLevels);
|
|---|
| 227 | //MHEvent *evt07 = new MHEvent(MHEvent::kEvtIdxMax);
|
|---|
| 228 | MHEvent *evt08 = new MHEvent(MHEvent::kEvtArrTime);
|
|---|
| 229 | MHEvent *evt09 = new MHEvent(MHEvent::kEvtArrTimeCleaned);
|
|---|
| 230 | //MHEvent *evt09 = new MHEvent(MHEvent::kEvtTrigPix);
|
|---|
| 231 | MHEvent *evt10 = new MHEvent(MHEvent::kEvtIslandIndex);
|
|---|
| 232 |
|
|---|
| 233 | evt01->SetName("Signal");
|
|---|
| 234 | evt02->SetName("Cleaned");
|
|---|
| 235 | evt03->SetName("Ped");
|
|---|
| 236 | evt04->SetName("PedRMS");
|
|---|
| 237 | evt06a->SetName("CleanData");
|
|---|
| 238 | evt06b->SetName("Levels");
|
|---|
| 239 | //evt07->SetName("MaxSliceIdx");
|
|---|
| 240 | evt08->SetName("ArrTime");
|
|---|
| 241 | evt09->SetName("Time");
|
|---|
| 242 | evt10->SetName("Islands");
|
|---|
| 243 |
|
|---|
| 244 | evt01->SetMinimum(0);
|
|---|
| 245 | evt03->SetMinimum(0);
|
|---|
| 246 | evt04->SetMinimum(0);
|
|---|
| 247 | evt06a->SetMinimum(0);
|
|---|
| 248 |
|
|---|
| 249 | // This makes sure, that the containers are deleted...
|
|---|
| 250 | plist->AddToList(evt01);
|
|---|
| 251 | plist->AddToList(evt02);
|
|---|
| 252 | plist->AddToList(evt03);
|
|---|
| 253 | plist->AddToList(evt04);
|
|---|
| 254 | plist->AddToList(evt06a);
|
|---|
| 255 | plist->AddToList(evt06b);
|
|---|
| 256 | //plist->AddToList(evt07);
|
|---|
| 257 | plist->AddToList(evt08);
|
|---|
| 258 | plist->AddToList(evt09);
|
|---|
| 259 | plist->AddToList(evt10);
|
|---|
| 260 |
|
|---|
| 261 | MExtractTimeAndChargeDigitalFilter *digf = new MExtractTimeAndChargeDigitalFilter;
|
|---|
| 262 | digf->SetNameWeightsFile("msignal/cosmics_weights46.dat");
|
|---|
| 263 |
|
|---|
| 264 | MTaskEnv *taskenv1=new MTaskEnv("ExtractSignal");
|
|---|
| 265 | taskenv1->SetDefault(digf);
|
|---|
| 266 | taskenv1->SetOwner();
|
|---|
| 267 |
|
|---|
| 268 | MSignalCalc *nanal = new MSignalCalc;
|
|---|
| 269 | MFillH *fill01 = new MFillH(evt01, "MSignalCam", "MFillH01");
|
|---|
| 270 | MImgCleanStd *clean = new MImgCleanStd;
|
|---|
| 271 | MFillH *fill02 = new MFillH(evt02, "MSignalCam", "MFillH02");
|
|---|
| 272 | MFillH *fill03 = new MFillH(evt03, type==1?"MPedPhotFundamental":"MPedestalCam", "MFillH03");
|
|---|
| 273 | MFillH *fill04 = new MFillH(evt04, type==1?"MPedPhotFromExtractorRndm":"MPedestalCam", "MFillH04");
|
|---|
| 274 | MFillH *fill06a = new MFillH(evt06a, "MCameraData", "MFillH06a");
|
|---|
| 275 | MFillH *fill06b = new MFillH(evt06b, "MCameraData", "MFillH06b");
|
|---|
| 276 | MHillasCalc *hcalc = new MHillasCalc;
|
|---|
| 277 | //MMcTriggerLvl2Calc *trcal = new MMcTriggerLvl2Calc;
|
|---|
| 278 | //MFillH *fill09 = new MFillH(evt09, "MMcTriggerLvl2", "MFillH09");
|
|---|
| 279 | MFillH *fill10 = new MFillH(evt10, "MSignalCam", "MFillH10");
|
|---|
| 280 |
|
|---|
| 281 | MBadPixelsCalc *bcalc = new MBadPixelsCalc;
|
|---|
| 282 | MBadPixelsTreat *btreat = new MBadPixelsTreat;
|
|---|
| 283 | btreat->SetProcessTimes(kFALSE);
|
|---|
| 284 | if (type==1)
|
|---|
| 285 | {
|
|---|
| 286 | bcalc->SetNamePedPhotCam("MPedPhotFromExtractor");
|
|---|
| 287 | btreat->AddNamePedPhotCam("MPedPhotFromExtractorRndm");
|
|---|
| 288 | clean->SetNamePedPhotCam("MPedPhotFromExtractorRndm");
|
|---|
| 289 | }
|
|---|
| 290 |
|
|---|
| 291 | // If no pedestal or no calibration file is availble
|
|---|
| 292 | if (type==2)
|
|---|
| 293 | {
|
|---|
| 294 | MFilter *f1=new MFDataMember("MRawRunHeader.fRunType", '>', 255.5);
|
|---|
| 295 | f1->SetName("MFMonteCarlo");
|
|---|
| 296 |
|
|---|
| 297 | MMcPedestalCopy *pcopy = new MMcPedestalCopy;
|
|---|
| 298 | MMcPedestalNSBAdd *pdnsb = new MMcPedestalNSBAdd;
|
|---|
| 299 |
|
|---|
| 300 | MCalibrationPatternDecode *decode = new MCalibrationPatternDecode;
|
|---|
| 301 |
|
|---|
| 302 | MPedestalSubtract *pedsub1 = new MPedestalSubtract;
|
|---|
| 303 | MPedestalSubtract *pedsub2 = new MPedestalSubtract;
|
|---|
| 304 | pedsub2->SetNamePedestalCam();
|
|---|
| 305 |
|
|---|
| 306 | MMcCalibrationUpdate* mcupd = new MMcCalibrationUpdate;
|
|---|
| 307 | mcupd->SetOuterPixelsGainScaling(kFALSE);
|
|---|
| 308 |
|
|---|
| 309 | MCalibrateData* calib = new MCalibrateData;
|
|---|
| 310 | calib->SetCalibrationMode(MCalibrateData::kFlatCharge);
|
|---|
| 311 | calib->SetPedestalFlag(MCalibrateData::kEvent);
|
|---|
| 312 |
|
|---|
| 313 | // MPedestalCam is extracted using the simple MSignalCalc!
|
|---|
| 314 |
|
|---|
| 315 | // MC
|
|---|
| 316 | mcupd->SetFilter(f1);
|
|---|
| 317 | //trcal->SetFilter(f1);
|
|---|
| 318 |
|
|---|
| 319 | // TaskList
|
|---|
| 320 | tlist->AddToList(f1);
|
|---|
| 321 | tlist->AddToList(pcopy);
|
|---|
| 322 | tlist->AddToList(pdnsb);
|
|---|
| 323 |
|
|---|
| 324 | tlist->AddToList(decode);
|
|---|
| 325 |
|
|---|
| 326 | tlist->AddToList(pedsub1); // Produce arrays
|
|---|
| 327 | tlist->AddToList(nanal); // Estimate pedestal!
|
|---|
| 328 | tlist->AddToList(pedsub2); // subtract pedestal
|
|---|
| 329 |
|
|---|
| 330 | tlist->AddToList(taskenv1); // Calculates MExtractedSignalCam, MArrivalTimeCam
|
|---|
| 331 | tlist->AddToList(mcupd);
|
|---|
| 332 | tlist->AddToList(calib); // MExtractedSignalCam --> MSignalCam
|
|---|
| 333 |
|
|---|
| 334 | //tlist->AddToList(bcalc); // Produce MBadPixelsCam
|
|---|
| 335 | //tlist->AddToList(btreat); // Treat MBadPixelsCam
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | tlist->AddToList(fill01);
|
|---|
| 339 | tlist->AddToList(clean);
|
|---|
| 340 | tlist->AddToList(fill02);
|
|---|
| 341 | if (type==2)
|
|---|
| 342 | tlist->AddToList(fill03);
|
|---|
| 343 | tlist->AddToList(fill04);
|
|---|
| 344 | tlist->AddToList(fill06a);
|
|---|
| 345 | tlist->AddToList(fill06b);
|
|---|
| 346 | tlist->AddToList(fill10);
|
|---|
| 347 | if (type==2)
|
|---|
| 348 | {
|
|---|
| 349 | //MFillH *fill07 = new MFillH(evt07, "MRawEvtData", "MFillH7");
|
|---|
| 350 | MFillH *fill08 = new MFillH(evt08, "MArrivalTimeCam", "MFillH8");
|
|---|
| 351 | //tlist->AddToList(fill07);
|
|---|
| 352 | tlist->AddToList(fill08);
|
|---|
| 353 |
|
|---|
| 354 | //tlist->AddToList(trcal);
|
|---|
| 355 | //tlist->AddToList(fill09);
|
|---|
| 356 | }
|
|---|
| 357 | if (type==1)
|
|---|
| 358 | {
|
|---|
| 359 | MFillH *fill08 = new MFillH(evt08, "MSignalCam", "MFillH8");
|
|---|
| 360 | MFillH *fill09 = new MFillH(evt09, "MSignalCam", "MFillH9");
|
|---|
| 361 | tlist->AddToList(fill08);
|
|---|
| 362 | tlist->AddToList(fill09);
|
|---|
| 363 | }
|
|---|
| 364 | tlist->AddToList(hcalc);
|
|---|
| 365 |
|
|---|
| 366 | // --------------------------------------------------
|
|---|
| 367 | // Muon Analysis
|
|---|
| 368 | MMuonSearchParCalc *muscalc = new MMuonSearchParCalc;
|
|---|
| 369 | MMuonCalibParCalc *mcalc = new MMuonCalibParCalc;
|
|---|
| 370 | MFillH *fillmuon = new MFillH("MHSingleMuon", "", "FillMuon");
|
|---|
| 371 | fillmuon->SetNameTab("Muon");
|
|---|
| 372 | tlist->AddToList(muscalc);
|
|---|
| 373 | tlist->AddToList(fillmuon);
|
|---|
| 374 | tlist->AddToList(mcalc);
|
|---|
| 375 |
|
|---|
| 376 | // --------------------------------------------------
|
|---|
| 377 | // Cut to steer the display
|
|---|
| 378 | MContinue *cont0=new MContinue("", "Cut");
|
|---|
| 379 | cont0->SetAllowEmpty();
|
|---|
| 380 | tlist->AddToList(cont0);
|
|---|
| 381 |
|
|---|
| 382 | //
|
|---|
| 383 | // Now distribute Display to all tasks
|
|---|
| 384 | //
|
|---|
| 385 | fEvtLoop = new MEvtLoop(gSystem->BaseName(fname));
|
|---|
| 386 | fEvtLoop->SetOwner();
|
|---|
| 387 | fEvtLoop->SetParList(plist);
|
|---|
| 388 | fEvtLoop->SetDisplay(this);
|
|---|
| 389 | fEvtLoop->ReadEnv("mars.rc");
|
|---|
| 390 |
|
|---|
| 391 | }
|
|---|
| 392 |
|
|---|
| 393 | // --------------------------------------------------------------------------
|
|---|
| 394 | //
|
|---|
| 395 | // Add the top part of the frame: This is filename and treename display
|
|---|
| 396 | //
|
|---|
| 397 | void MEventDisplay::AddTopFramePart1(TGCompositeFrame *frame,
|
|---|
| 398 | const char *filename,
|
|---|
| 399 | const char *treename)
|
|---|
| 400 | {
|
|---|
| 401 | //
|
|---|
| 402 | // --- the top1 part of the window ---
|
|---|
| 403 | //
|
|---|
| 404 | TGHorizontalFrame *top1 = new TGHorizontalFrame(frame, 1, 1);
|
|---|
| 405 | fList->Add(top1);
|
|---|
| 406 |
|
|---|
| 407 | //
|
|---|
| 408 | // create gui elements
|
|---|
| 409 | //
|
|---|
| 410 | TGLabel *file = new TGLabel(top1, new TGString(Form("%s#%s", filename, treename)));
|
|---|
| 411 | fList->Add(file);
|
|---|
| 412 |
|
|---|
| 413 | //
|
|---|
| 414 | // layout and add gui elements in/to frame
|
|---|
| 415 | //
|
|---|
| 416 | TGLayoutHints *laystd = new TGLayoutHints(kLHintsCenterX, 5, 5);
|
|---|
| 417 | fList->Add(laystd);
|
|---|
| 418 |
|
|---|
| 419 | top1->AddFrame(file, laystd);
|
|---|
| 420 |
|
|---|
| 421 | //
|
|---|
| 422 | // --- the top1 part of the window ---
|
|---|
| 423 | //
|
|---|
| 424 | TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 1, 1);
|
|---|
| 425 | fList->Add(top2);
|
|---|
| 426 |
|
|---|
| 427 | //
|
|---|
| 428 | // layout and add frames
|
|---|
| 429 | //
|
|---|
| 430 | TGLayoutHints *laytop1 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5);
|
|---|
| 431 | fList->Add(laytop1);
|
|---|
| 432 | frame->AddFrame(top1, laytop1);
|
|---|
| 433 | frame->AddFrame(top2, laytop1);
|
|---|
| 434 | }
|
|---|
| 435 |
|
|---|
| 436 | // --------------------------------------------------------------------------
|
|---|
| 437 | //
|
|---|
| 438 | // Add the second part of the top frame: This are the event number controls
|
|---|
| 439 | //
|
|---|
| 440 | void MEventDisplay::AddTopFramePart2(TGCompositeFrame *frame)
|
|---|
| 441 | {
|
|---|
| 442 | //
|
|---|
| 443 | // --- the top2 part of the window ---
|
|---|
| 444 | //
|
|---|
| 445 | TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 1, 1);
|
|---|
| 446 | fList->Add(top2);
|
|---|
| 447 |
|
|---|
| 448 | //
|
|---|
| 449 | // Create the gui elements
|
|---|
| 450 | //
|
|---|
| 451 | TGTextButton *prevevt = new TGTextButton(top2, " << ", kEvtPrev);
|
|---|
| 452 | prevevt->Associate(this);
|
|---|
| 453 |
|
|---|
| 454 | TGLabel *evtnr = new TGLabel(top2, new TGString("Event:"));
|
|---|
| 455 |
|
|---|
| 456 | TGTextEntry *entry=new TGTextEntry(top2, new TGTextBuffer(100), kEvtNumber);
|
|---|
| 457 | entry->Resize(60, entry->GetDefaultHeight());
|
|---|
| 458 | entry->Associate(this);
|
|---|
| 459 |
|
|---|
| 460 | fNumOfEvts = new TGLabel(top2, "of .");
|
|---|
| 461 |
|
|---|
| 462 | TGTextButton *nextevt = new TGTextButton (top2, " >> ", kEvtNext);
|
|---|
| 463 | nextevt->Associate(this);
|
|---|
| 464 |
|
|---|
| 465 | //
|
|---|
| 466 | // Add gui elements to 'atotodel'
|
|---|
| 467 | //
|
|---|
| 468 | fList->Add(prevevt);
|
|---|
| 469 | fList->Add(evtnr);
|
|---|
| 470 | fList->Add(entry);
|
|---|
| 471 | fList->Add(fNumOfEvts);
|
|---|
| 472 | fList->Add(nextevt);
|
|---|
| 473 |
|
|---|
| 474 | //
|
|---|
| 475 | // add the gui elements to the frame
|
|---|
| 476 | //
|
|---|
| 477 | TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 5);
|
|---|
| 478 | fList->Add(laystd);
|
|---|
| 479 |
|
|---|
| 480 | top2->AddFrame(prevevt, laystd);
|
|---|
| 481 | top2->AddFrame(evtnr, laystd);
|
|---|
| 482 | top2->AddFrame(entry, laystd);
|
|---|
| 483 | top2->AddFrame(fNumOfEvts, laystd);
|
|---|
| 484 | top2->AddFrame(nextevt, laystd);
|
|---|
| 485 |
|
|---|
| 486 | TGLayoutHints *laystd2 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5, 5);
|
|---|
| 487 | fList->Add(laystd2);
|
|---|
| 488 | frame->AddFrame(top2, laystd2);
|
|---|
| 489 |
|
|---|
| 490 | //
|
|---|
| 491 | // Add trailing line...
|
|---|
| 492 | //
|
|---|
| 493 | TGHorizontal3DLine *line = new TGHorizontal3DLine(frame);
|
|---|
| 494 | TGLayoutHints *layline = new TGLayoutHints(kLHintsExpandX);
|
|---|
| 495 | fList->Add(line);
|
|---|
| 496 | fList->Add(layline);
|
|---|
| 497 | frame->AddFrame(line, layline);
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 | // --------------------------------------------------------------------------
|
|---|
| 501 | //
|
|---|
| 502 | // Add the user frame part of the display
|
|---|
| 503 | //
|
|---|
| 504 | void MEventDisplay::AddUserFrame(const char* filename)
|
|---|
| 505 | {
|
|---|
| 506 | fUserFrame->ChangeOptions(kHorizontalFrame);
|
|---|
| 507 |
|
|---|
| 508 | TGCompositeFrame *vf1 = new TGVerticalFrame(fUserFrame, 1, 1);
|
|---|
| 509 | TGCompositeFrame *vf2 = new TGVerticalFrame(fUserFrame, 1, 1);
|
|---|
| 510 |
|
|---|
| 511 | AddTopFramePart1(vf1, filename, "Events");
|
|---|
| 512 | AddTopFramePart2(vf1);
|
|---|
| 513 |
|
|---|
| 514 | // create root embedded canvas and add it to the tab
|
|---|
| 515 | TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas("Slices", vf2, vf1->GetDefaultHeight()*3/2, vf1->GetDefaultHeight(), 0);
|
|---|
| 516 | vf2->AddFrame(ec);
|
|---|
| 517 | fList->Add(ec);
|
|---|
| 518 |
|
|---|
| 519 | // set background and border mode of the canvas
|
|---|
| 520 | fCanvas = ec->GetCanvas();
|
|---|
| 521 | fCanvas->SetBorderMode(0);
|
|---|
| 522 | gROOT->GetListOfCanvases()->Add(fCanvas);
|
|---|
| 523 | //fCanvas->SetBorderSize(1);
|
|---|
| 524 | //fCanvas->SetBit(kNoContextMenu);
|
|---|
| 525 | //fCanvas->SetFillColor(16);
|
|---|
| 526 |
|
|---|
| 527 | TGLayoutHints *lay = new TGLayoutHints(kLHintsExpandX);
|
|---|
| 528 | fUserFrame->AddFrame(vf1, lay);
|
|---|
| 529 | fUserFrame->AddFrame(vf2);
|
|---|
| 530 | }
|
|---|
| 531 |
|
|---|
| 532 | // --------------------------------------------------------------------------
|
|---|
| 533 | //
|
|---|
| 534 | // Checks if the event number is valid, and if so reads the new event
|
|---|
| 535 | // and updates the display
|
|---|
| 536 | //
|
|---|
| 537 | void MEventDisplay::ReadinEvent(Int_t dir)
|
|---|
| 538 | {
|
|---|
| 539 | MParList *plist = (MParList*) fEvtLoop->GetParList();
|
|---|
| 540 | MTaskList *tlist = (MTaskList*) fEvtLoop->GetTaskList();
|
|---|
| 541 | MGeomCam *geom = (MGeomCam*) plist->FindObject("MGeomCam");
|
|---|
| 542 | MRawEvtData *raw = (MRawEvtData*)plist->FindObject("MRawEvtData");
|
|---|
| 543 |
|
|---|
| 544 | //
|
|---|
| 545 | // Read first event.
|
|---|
| 546 | //
|
|---|
| 547 | MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
|
|---|
| 548 |
|
|---|
| 549 | const Int_t num = reader->GetNumEntry();
|
|---|
| 550 |
|
|---|
| 551 | Int_t rc;
|
|---|
| 552 | do
|
|---|
| 553 | {
|
|---|
| 554 | if (dir<0 && !reader->DecEventNum())
|
|---|
| 555 | {
|
|---|
| 556 | reader->SetEventNum(num);
|
|---|
| 557 | return;
|
|---|
| 558 | }
|
|---|
| 559 | if (dir>0 && !reader->IncEventNum())
|
|---|
| 560 | {
|
|---|
| 561 | reader->SetEventNum(num);
|
|---|
| 562 | return;
|
|---|
| 563 | }
|
|---|
| 564 |
|
|---|
| 565 | rc = tlist->Process();
|
|---|
| 566 | if (rc==kFALSE || rc==kERROR)
|
|---|
| 567 | return;
|
|---|
| 568 |
|
|---|
| 569 | reader->DecEventNum();
|
|---|
| 570 |
|
|---|
| 571 | // Define other continue conditions
|
|---|
| 572 | if (raw && raw->GetNumPixels()<1)
|
|---|
| 573 | rc = kCONTINUE;
|
|---|
| 574 |
|
|---|
| 575 | } while (rc==kCONTINUE && dir!=0);
|
|---|
| 576 |
|
|---|
| 577 | //
|
|---|
| 578 | // Cleare the 'FADC canvas'
|
|---|
| 579 | //
|
|---|
| 580 | fCanvas->Clear();
|
|---|
| 581 | fCanvas->Modified();
|
|---|
| 582 | fCanvas->Update();
|
|---|
| 583 |
|
|---|
| 584 | //
|
|---|
| 585 | // Print parameters
|
|---|
| 586 | //
|
|---|
| 587 | *fLog << all;
|
|---|
| 588 | fLog->Separator(Form("Entry %d", reader->GetNumEntry()+1));
|
|---|
| 589 | ((MHillas*) plist->FindObject("MHillas"))->Print(*geom);
|
|---|
| 590 | ((MHillasExt*) plist->FindObject("MHillasExt"))->Print(*geom);
|
|---|
| 591 | ((MHillasSrc*) plist->FindObject("MHillasSrc"))->Print(*geom);
|
|---|
| 592 | plist->FindObject("MImagePar")->Print();
|
|---|
| 593 | ((MNewImagePar*)plist->FindObject("MNewImagePar"))->Print(*geom);
|
|---|
| 594 | plist->FindObject("MMuonCalibPar")->Print();
|
|---|
| 595 | ((MMuonSearchPar*)plist->FindObject("MMuonSearchPar"))->Print(*geom);
|
|---|
| 596 |
|
|---|
| 597 | //
|
|---|
| 598 | // UpdateDisplay
|
|---|
| 599 | //
|
|---|
| 600 | gStyle->SetOptStat(1101);
|
|---|
| 601 | Update();
|
|---|
| 602 |
|
|---|
| 603 | TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
|
|---|
| 604 | entry->SetText(Form("%d", reader->GetNumEntry()+1));
|
|---|
| 605 | }
|
|---|
| 606 |
|
|---|
| 607 | // --------------------------------------------------------------------------
|
|---|
| 608 | //
|
|---|
| 609 | // Read first event to get display booted
|
|---|
| 610 | //
|
|---|
| 611 | void MEventDisplay::ReadFirstEvent()
|
|---|
| 612 | {
|
|---|
| 613 | const Int_t rc = fEvtLoop->PreProcess();
|
|---|
| 614 | if (rc==kFALSE || rc==kERROR)
|
|---|
| 615 | return;
|
|---|
| 616 |
|
|---|
| 617 | UnLock();
|
|---|
| 618 |
|
|---|
| 619 | //
|
|---|
| 620 | // Get parlist
|
|---|
| 621 | //
|
|---|
| 622 | MParList *plist = (MParList*)fEvtLoop->GetParList();
|
|---|
| 623 |
|
|---|
| 624 | //
|
|---|
| 625 | // Add Geometry tab
|
|---|
| 626 | //
|
|---|
| 627 | AddGeometryTabs();
|
|---|
| 628 |
|
|---|
| 629 | //
|
|---|
| 630 | // Now read event...
|
|---|
| 631 | //
|
|---|
| 632 | // FIXME: Can we safly replace ReadinEvent() by RedinEvent(1)?
|
|---|
| 633 | ReadinEvent();
|
|---|
| 634 |
|
|---|
| 635 |
|
|---|
| 636 | MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
|
|---|
| 637 | TGString *txt = new TGString(Form("of %d", reader->GetEntries()));
|
|---|
| 638 | fNumOfEvts->SetText(txt);
|
|---|
| 639 |
|
|---|
| 640 | //
|
|---|
| 641 | // Draw ellipse on top of all pads
|
|---|
| 642 | //
|
|---|
| 643 | TObject *hillas1 = plist->FindObject("MHillas");
|
|---|
| 644 | TObject *hillas2 = plist->FindObject("MHillasSrc");
|
|---|
| 645 | TObject *hillas3 = plist->FindObject("MHillasExt");
|
|---|
| 646 | TObject *hmuon = plist->FindObject("MMuonSearchPar");
|
|---|
| 647 | for (int i=1; i<7;i++)
|
|---|
| 648 | {
|
|---|
| 649 | TCanvas *c = GetCanvas(i);
|
|---|
| 650 | c->GetPad(1)->cd(1);
|
|---|
| 651 | hmuon->Draw();
|
|---|
| 652 | hillas1->Draw();
|
|---|
| 653 | hillas2->Draw();
|
|---|
| 654 | hillas3->Draw();
|
|---|
| 655 | }
|
|---|
| 656 | }
|
|---|
| 657 |
|
|---|
| 658 | // --------------------------------------------------------------------------
|
|---|
| 659 | //
|
|---|
| 660 | // Adds the geometry tab
|
|---|
| 661 | //
|
|---|
| 662 | void MEventDisplay::AddGeometryTabs()
|
|---|
| 663 | {
|
|---|
| 664 | MGeomCam *geom = (MGeomCam*)fEvtLoop->GetParList()->FindObject("MGeomCam");
|
|---|
| 665 | if (!geom)
|
|---|
| 666 | return;
|
|---|
| 667 |
|
|---|
| 668 | TCanvas &c1=AddTab("Geometry");
|
|---|
| 669 |
|
|---|
| 670 | MHCamera *cam = new MHCamera(*geom);
|
|---|
| 671 | cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
|
|---|
| 672 | cam->Draw("pixelindex");
|
|---|
| 673 |
|
|---|
| 674 | c1.Modified();
|
|---|
| 675 | c1.Update();
|
|---|
| 676 |
|
|---|
| 677 | TCanvas &c2=AddTab("Sectors");
|
|---|
| 678 |
|
|---|
| 679 | cam = new MHCamera(*geom);
|
|---|
| 680 | cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
|
|---|
| 681 | cam->Draw("sectorindex");
|
|---|
| 682 |
|
|---|
| 683 | c2.Modified();
|
|---|
| 684 | c2.Update();
|
|---|
| 685 | }
|
|---|
| 686 |
|
|---|
| 687 | // --------------------------------------------------------------------------
|
|---|
| 688 | //
|
|---|
| 689 | // ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
|---|
| 690 | //
|
|---|
| 691 | // Processes information from all GUI items.
|
|---|
| 692 | // Selecting an item usually generates an event with 4 parameters.
|
|---|
| 693 | // The first two are packed into msg (first and second bytes).
|
|---|
| 694 | // The other two are parm1 and parm2.
|
|---|
| 695 | //
|
|---|
| 696 | Bool_t MEventDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
|
|---|
| 697 | {
|
|---|
| 698 | switch (GET_MSG(msg))
|
|---|
| 699 | {
|
|---|
| 700 | case kC_TEXTENTRY:
|
|---|
| 701 | switch(GET_SUBMSG(msg))
|
|---|
| 702 | {
|
|---|
| 703 | case kTE_ENTER:
|
|---|
| 704 | switch(GET_SUBMSG(msg))
|
|---|
| 705 | {
|
|---|
| 706 | case kTE_ENTER:
|
|---|
| 707 | {
|
|---|
| 708 | TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
|
|---|
| 709 | MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
|
|---|
| 710 | if (reader->SetEventNum(atoi(entry->GetText())-1))
|
|---|
| 711 | ReadinEvent();
|
|---|
| 712 | }
|
|---|
| 713 | return kTRUE;
|
|---|
| 714 | }
|
|---|
| 715 | return kTRUE;
|
|---|
| 716 | }
|
|---|
| 717 | break;
|
|---|
| 718 |
|
|---|
| 719 | case kC_COMMAND:
|
|---|
| 720 | switch (GET_SUBMSG(msg))
|
|---|
| 721 | {
|
|---|
| 722 | case kCM_TAB:
|
|---|
| 723 | {
|
|---|
| 724 | //
|
|---|
| 725 | // Set name for 'FADC canvas'. The name is the anchor for MHCamera.
|
|---|
| 726 | // and clear the canvas
|
|---|
| 727 | TCanvas *c = GetCanvas(mp1);
|
|---|
| 728 | if (!c)
|
|---|
| 729 | break;
|
|---|
| 730 | MHEvent *o = (MHEvent*)fEvtLoop->GetParList()->FindObject(c->GetName());
|
|---|
| 731 | if (!o)
|
|---|
| 732 | break;
|
|---|
| 733 | fCanvas->SetName(Form("%p;%p;PixelContent", o->GetHist(), c->GetPad(1)->GetPad(1)));
|
|---|
| 734 | }
|
|---|
| 735 | break;
|
|---|
| 736 |
|
|---|
| 737 | case kCM_BUTTON:
|
|---|
| 738 | switch (mp1)
|
|---|
| 739 | {
|
|---|
| 740 | case kEvtPrev:
|
|---|
| 741 | ReadinEvent(-1);
|
|---|
| 742 | return kTRUE;
|
|---|
| 743 |
|
|---|
| 744 | case kEvtNext:
|
|---|
| 745 | ReadinEvent(+1);
|
|---|
| 746 | return kTRUE;
|
|---|
| 747 | }
|
|---|
| 748 | return kTRUE;
|
|---|
| 749 | }
|
|---|
| 750 | break;
|
|---|
| 751 | }
|
|---|
| 752 |
|
|---|
| 753 | return MStatusDisplay::ProcessMessage(msg, mp1, mp2);
|
|---|
| 754 | }
|
|---|