| 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 9/2001 (tbretz@uni-sw.gwdg.de)
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2001
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | #include "MAnalysis.h"
|
|---|
| 26 |
|
|---|
| 27 | #include <stdlib.h> // atof
|
|---|
| 28 | #include <iostream.h>
|
|---|
| 29 |
|
|---|
| 30 | #include <TGLabel.h> // TGlabel
|
|---|
| 31 | #include <TGButton.h> // TGTextButton
|
|---|
| 32 | #include <TGTextEntry.h> // TGNumberEntry
|
|---|
| 33 |
|
|---|
| 34 | ClassImp(MAnalysis)
|
|---|
| 35 |
|
|---|
| 36 | enum {
|
|---|
| 37 | kButHillas
|
|---|
| 38 | };
|
|---|
| 39 |
|
|---|
| 40 | void MAnalysis::AddButtons()
|
|---|
| 41 | {
|
|---|
| 42 | TGTextButton *hillas = new TGTextButton(fTop2, "Calculate Standard Hillas", kButHillas);
|
|---|
| 43 |
|
|---|
| 44 | hillas->Associate(this);
|
|---|
| 45 |
|
|---|
| 46 | fList->Add(hillas);
|
|---|
| 47 |
|
|---|
| 48 | TGLayoutHints *laybut = new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 10, 10, 5, 5);
|
|---|
| 49 | fList->Add(laybut);
|
|---|
| 50 |
|
|---|
| 51 | fTop2->AddFrame(hillas, laybut);
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | void MAnalysis::AddSetupTab()
|
|---|
| 55 | {
|
|---|
| 56 | //
|
|---|
| 57 | // Create Setup Tab
|
|---|
| 58 | //
|
|---|
| 59 | TGCompositeFrame *frame = CreateNewTab("Setup");
|
|---|
| 60 |
|
|---|
| 61 | //
|
|---|
| 62 | // Align the lines:
|
|---|
| 63 | // - top, left
|
|---|
| 64 | // - padding: top=20, bottom=0, left=20, right=0
|
|---|
| 65 | //
|
|---|
| 66 | TGLayoutHints *layline = new TGLayoutHints(kLHintsNormal, 20, 0, 20);
|
|---|
| 67 | fList->Add(layline);
|
|---|
| 68 |
|
|---|
| 69 | //
|
|---|
| 70 | // Create check buttons for the first two lines
|
|---|
| 71 | //
|
|---|
| 72 | fCheckButton1 = new TGCheckButton(frame, "Display Hillas Histograms when finished"); //, M_CHECK_DISPLHIL);
|
|---|
| 73 | fCheckButton2 = new TGCheckButton(frame, "Display Star Map Histogram when finished"); //, M_CHECK_DISPLHIL);
|
|---|
| 74 |
|
|---|
| 75 | /*
|
|---|
| 76 | FIXME...
|
|---|
| 77 |
|
|---|
| 78 | fList->Add(fCheckButton1);
|
|---|
| 79 | fList->Add(fCheckButton2);
|
|---|
| 80 | */
|
|---|
| 81 |
|
|---|
| 82 | //
|
|---|
| 83 | // Create first two lines with the checkbuttons
|
|---|
| 84 | //
|
|---|
| 85 | frame->AddFrame(fCheckButton1, layline);
|
|---|
| 86 | frame->AddFrame(fCheckButton2, layline);
|
|---|
| 87 |
|
|---|
| 88 | //
|
|---|
| 89 | // Create entry fields and labels for line 3 and 4
|
|---|
| 90 | //
|
|---|
| 91 |
|
|---|
| 92 | /*
|
|---|
| 93 | * --> use with root >=3.02 <--
|
|---|
| 94 | *
|
|---|
| 95 |
|
|---|
| 96 | TGNumberEntry *fNumEntry1 = new TGNumberEntry(frame, 3.0, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
|
|---|
| 97 | TGNumberEntry *fNumEntry2 = new TGNumberEntry(frame, 2.5, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
|
|---|
| 98 |
|
|---|
| 99 | */
|
|---|
| 100 |
|
|---|
| 101 | //
|
|---|
| 102 | // Create a frame for line 3 and 4 to be able
|
|---|
| 103 | // to align entry field and label in one line
|
|---|
| 104 | //
|
|---|
| 105 | TGHorizontalFrame *f1 = new TGHorizontalFrame(frame, 0, 0);
|
|---|
| 106 | TGHorizontalFrame *f2 = new TGHorizontalFrame(frame, 0, 0);
|
|---|
| 107 |
|
|---|
| 108 | fNumEntry1 = new TGTextEntry(f1, "****");
|
|---|
| 109 | fNumEntry2 = new TGTextEntry(f2, "****");
|
|---|
| 110 |
|
|---|
| 111 | // --- doesn't work like expected --- fNumEntry1->SetAlignment(kTextRight);
|
|---|
| 112 | // --- doesn't work like expected --- fNumEntry2->SetAlignment(kTextRight);
|
|---|
| 113 |
|
|---|
| 114 | fNumEntry1->SetText("3.0");
|
|---|
| 115 | fNumEntry2->SetText("2.5");
|
|---|
| 116 |
|
|---|
| 117 | fList->Add(fNumEntry1);
|
|---|
| 118 | fList->Add(fNumEntry2);
|
|---|
| 119 |
|
|---|
| 120 | TGLabel *l1 = new TGLabel(f1, "Cleaning Level 1 for standard image cleaning.");
|
|---|
| 121 | TGLabel *l2 = new TGLabel(f2, "Cleaning Level 2 for standard image cleaning.");
|
|---|
| 122 |
|
|---|
| 123 | l1->SetTextJustify(kTextLeft);
|
|---|
| 124 | l2->SetTextJustify(kTextLeft);
|
|---|
| 125 |
|
|---|
| 126 | fList->Add(l1);
|
|---|
| 127 | fList->Add(l2);
|
|---|
| 128 |
|
|---|
| 129 | //
|
|---|
| 130 | // Align the text of the label centered, left in the row
|
|---|
| 131 | // with a left padding of 10
|
|---|
| 132 | //
|
|---|
| 133 | TGLayoutHints *laylabel = new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 10); //, 10); //, 5, 5);
|
|---|
| 134 | fList->Add(laylabel);
|
|---|
| 135 |
|
|---|
| 136 | //
|
|---|
| 137 | // Add one entry field and the corresponding label to each line
|
|---|
| 138 | //
|
|---|
| 139 | f1->AddFrame(fNumEntry1);
|
|---|
| 140 | f2->AddFrame(fNumEntry2);
|
|---|
| 141 |
|
|---|
| 142 | f1->AddFrame(l1, laylabel);
|
|---|
| 143 | f2->AddFrame(l2, laylabel);
|
|---|
| 144 |
|
|---|
| 145 | //
|
|---|
| 146 | // Add line 3 and 4 to tab
|
|---|
| 147 | //
|
|---|
| 148 | frame->AddFrame(f1, layline);
|
|---|
| 149 | frame->AddFrame(f2, layline);
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | MAnalysis::MAnalysis(const TGWindow *main, const TGWindow *p,
|
|---|
| 153 | const UInt_t w, const UInt_t h)
|
|---|
| 154 | : MBrowser(main, p, w, h)
|
|---|
| 155 | {
|
|---|
| 156 | AddButtons();
|
|---|
| 157 | AddSetupTab();
|
|---|
| 158 |
|
|---|
| 159 | MapSubwindows();
|
|---|
| 160 |
|
|---|
| 161 | Layout();
|
|---|
| 162 |
|
|---|
| 163 | SetWindowName("Analysis Window");
|
|---|
| 164 | SetIconName("Analysis");
|
|---|
| 165 |
|
|---|
| 166 | MapWindow();
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | // ======================================================================
|
|---|
| 170 |
|
|---|
| 171 | #include "MParList.h"
|
|---|
| 172 | #include "MTaskList.h"
|
|---|
| 173 | #include "MGeomCamMagic.h"
|
|---|
| 174 | #include "MPedestalCam.h"
|
|---|
| 175 | #include "MHHillas.h"
|
|---|
| 176 | #include "MHStarMap.h"
|
|---|
| 177 | #include "MReadTree.h"
|
|---|
| 178 | #include "MCerPhotCalc.h"
|
|---|
| 179 | #include "MImgCleanStd.h"
|
|---|
| 180 | #include "MHillasCalc.h"
|
|---|
| 181 | #include "MFillH.h"
|
|---|
| 182 | #include "MEvtLoop.h"
|
|---|
| 183 | #include "MHillas.h"
|
|---|
| 184 |
|
|---|
| 185 | void MAnalysis::CalculateHillas()
|
|---|
| 186 | {
|
|---|
| 187 | //
|
|---|
| 188 | // This is a demonstration program which calculates the Hillas
|
|---|
| 189 | // parameter out of a Magic root file.
|
|---|
| 190 |
|
|---|
| 191 | const Bool_t displhillas = fCheckButton1->GetState();
|
|---|
| 192 | const Bool_t displstarmap = fCheckButton2->GetState();
|
|---|
| 193 |
|
|---|
| 194 | Float_t cleanlvl1 = atof(fNumEntry1->GetText());
|
|---|
| 195 | Float_t cleanlvl2 = atof(fNumEntry2->GetText());
|
|---|
| 196 |
|
|---|
| 197 | if (cleanlvl1<0)
|
|---|
| 198 | {
|
|---|
| 199 | cleanlvl1=0;
|
|---|
| 200 | fNumEntry1->SetText("0");
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | if (cleanlvl2<0)
|
|---|
| 204 | {
|
|---|
| 205 | cleanlvl2=0;
|
|---|
| 206 | fNumEntry2->SetText("0");
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | //
|
|---|
| 210 | // Create a empty Parameter List and an empty Task List
|
|---|
| 211 | // The tasklist is identified in the eventloop by its name
|
|---|
| 212 | //
|
|---|
| 213 | MParList plist;
|
|---|
| 214 |
|
|---|
| 215 | MTaskList tlist;
|
|---|
| 216 | plist.AddToList(&tlist);
|
|---|
| 217 |
|
|---|
| 218 | //
|
|---|
| 219 | // The geometry container must be created by yourself to make sure
|
|---|
| 220 | // that you don't choos a wrong geometry by chance
|
|---|
| 221 | //
|
|---|
| 222 | MGeomCamMagic geomcam;
|
|---|
| 223 | plist.AddToList(&geomcam);
|
|---|
| 224 |
|
|---|
| 225 | MPedestalCam pedest;
|
|---|
| 226 | plist.AddToList(&pedest);
|
|---|
| 227 |
|
|---|
| 228 | //
|
|---|
| 229 | // Now setup the tasks and tasklist:
|
|---|
| 230 | //
|
|---|
| 231 | // 1) read in the data from a magic root file MReadTree
|
|---|
| 232 | // 2) calculate number of cerenkov photons MCerPhotCalc
|
|---|
| 233 | // 3) clean the image MImgCleanStd
|
|---|
| 234 | // 4) calculate hillas MHillasCalc
|
|---|
| 235 | // 5) fill the hillas into the histograms MFillH
|
|---|
| 236 | //
|
|---|
| 237 |
|
|---|
| 238 | //
|
|---|
| 239 | // The first argument is the tree you want to read.
|
|---|
| 240 | // Events: Cosmic ray events
|
|---|
| 241 | // PedEvents: Pedestal Events
|
|---|
| 242 | // CalEvents: Calibration Events
|
|---|
| 243 | //
|
|---|
| 244 | MReadTree read("Events", fInputFile);
|
|---|
| 245 |
|
|---|
| 246 | MCerPhotCalc ncalc;
|
|---|
| 247 | MImgCleanStd clean(cleanlvl1, cleanlvl2);
|
|---|
| 248 | MHillasCalc hcalc;
|
|---|
| 249 |
|
|---|
| 250 | tlist.AddToList(&read);
|
|---|
| 251 | tlist.AddToList(&ncalc);
|
|---|
| 252 | tlist.AddToList(&clean);
|
|---|
| 253 | tlist.AddToList(&hcalc);
|
|---|
| 254 |
|
|---|
| 255 | MFillH hfill("MHillas", "MHHillas");
|
|---|
| 256 | MFillH sfill("MHillas", "MHStarMap");
|
|---|
| 257 |
|
|---|
| 258 | if (displhillas)
|
|---|
| 259 | tlist.AddToList(&hfill);
|
|---|
| 260 |
|
|---|
| 261 | if (displstarmap)
|
|---|
| 262 | tlist.AddToList(&sfill);
|
|---|
| 263 |
|
|---|
| 264 | //
|
|---|
| 265 | // Create and setup the eventloop
|
|---|
| 266 | //
|
|---|
| 267 | MEvtLoop evtloop;
|
|---|
| 268 | evtloop.SetParList(&plist);
|
|---|
| 269 |
|
|---|
| 270 | //
|
|---|
| 271 | // Add ProgressBar to window
|
|---|
| 272 | //
|
|---|
| 273 | TGProgressBar *bar = CreateProgressBar(fTop2);
|
|---|
| 274 | read.SetProgressBar(bar);
|
|---|
| 275 | evtloop.SetProgressBar(bar);
|
|---|
| 276 |
|
|---|
| 277 | //
|
|---|
| 278 | // Execute your analysis
|
|---|
| 279 | //
|
|---|
| 280 | Bool_t rc = evtloop.Eventloop();
|
|---|
| 281 |
|
|---|
| 282 | //
|
|---|
| 283 | // Remove progressbar from window
|
|---|
| 284 | //
|
|---|
| 285 | DestroyProgressBar(bar);
|
|---|
| 286 |
|
|---|
| 287 | if (!rc)
|
|---|
| 288 | return;
|
|---|
| 289 | //
|
|---|
| 290 | // After the analysis is finished we can display the histograms
|
|---|
| 291 | //
|
|---|
| 292 | if (displhillas)
|
|---|
| 293 | plist.FindObject("MHHillas")->DrawClone();
|
|---|
| 294 |
|
|---|
| 295 | if (displstarmap)
|
|---|
| 296 | plist.FindObject("MHStarMap")->DrawClone();
|
|---|
| 297 |
|
|---|
| 298 | cout << endl;
|
|---|
| 299 | cout << "Calculation of Hillas Parameters finished without error!" << endl;
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 | // ======================================================================
|
|---|
| 303 |
|
|---|
| 304 | Bool_t MAnalysis::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
|---|
| 305 | {
|
|---|
| 306 | // Process events generated by the buttons in the frame.
|
|---|
| 307 |
|
|---|
| 308 | if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
|
|---|
| 309 | return MBrowser::ProcessMessage(msg, parm1, parm2);
|
|---|
| 310 |
|
|---|
| 311 | switch (parm1)
|
|---|
| 312 | {
|
|---|
| 313 | case kButHillas:
|
|---|
| 314 | if (!InputFileSelected())
|
|---|
| 315 | {
|
|---|
| 316 | DisplError("No Input (root) File selected!");
|
|---|
| 317 | return kTRUE;
|
|---|
| 318 | }
|
|---|
| 319 |
|
|---|
| 320 | switch (parm1)
|
|---|
| 321 | {
|
|---|
| 322 | case kButHillas:
|
|---|
| 323 | CalculateHillas();
|
|---|
| 324 | return kTRUE;
|
|---|
| 325 | }
|
|---|
| 326 | return kTRUE;
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 | return MBrowser::ProcessMessage(msg, parm1, parm2);
|
|---|
| 330 | }
|
|---|