| 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 1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | ! Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2002
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | // //
|
|---|
| 28 | // MHAlphaEnergyTime //
|
|---|
| 29 | // //
|
|---|
| 30 | // 3D-histogram in alpha, E-est and time //
|
|---|
| 31 | // //
|
|---|
| 32 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 33 |
|
|---|
| 34 | #include "MHAlphaEnergyTime.h"
|
|---|
| 35 |
|
|---|
| 36 | #include <TCanvas.h>
|
|---|
| 37 |
|
|---|
| 38 | #include <math.h>
|
|---|
| 39 |
|
|---|
| 40 | #include "MHillasSrc.h"
|
|---|
| 41 | #include "MEnergyEst.h"
|
|---|
| 42 | #include "MTime.h"
|
|---|
| 43 |
|
|---|
| 44 | #include "MBinning.h"
|
|---|
| 45 | #include "MParList.h"
|
|---|
| 46 |
|
|---|
| 47 | #include "MLog.h"
|
|---|
| 48 | #include "MLogManip.h"
|
|---|
| 49 |
|
|---|
| 50 | ClassImp(MHAlphaEnergyTime);
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | // --------------------------------------------------------------------------
|
|---|
| 54 | //
|
|---|
| 55 | // Default Constructor. It sets name and title of the histogram.
|
|---|
| 56 | //
|
|---|
| 57 | MHAlphaEnergyTime::MHAlphaEnergyTime(const char *name, const char *title)
|
|---|
| 58 | : fHist()
|
|---|
| 59 | {
|
|---|
| 60 | //
|
|---|
| 61 | // set the name and title of this object
|
|---|
| 62 | //
|
|---|
| 63 | fName = name ? name : "MHAlphaEnergyTime";
|
|---|
| 64 | fTitle = title ? title : "3-D histogram in alpha, energy and time";
|
|---|
| 65 |
|
|---|
| 66 | fHist.SetDirectory(NULL);
|
|---|
| 67 |
|
|---|
| 68 | fHist.SetTitle("3D-plot of alpha, E-est, time");
|
|---|
| 69 | fHist.SetXTitle("\\alpha [\\circ]");
|
|---|
| 70 | fHist.SetYTitle("E-est [GeV] ");
|
|---|
| 71 | fHist.SetZTitle("time [s]");
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | // --------------------------------------------------------------------------
|
|---|
| 75 | //
|
|---|
| 76 | // Set binnings and prepare filling of the histogram
|
|---|
| 77 | //
|
|---|
| 78 | Bool_t MHAlphaEnergyTime::SetupFill(const MParList *plist)
|
|---|
| 79 | {
|
|---|
| 80 | fEnergy = (MEnergyEst*)plist->FindObject("MEnergyEst");
|
|---|
| 81 | if (!fEnergy)
|
|---|
| 82 | {
|
|---|
| 83 | *fLog << err << dbginf << "MHAlphaEnergyTime : MEnergyEst not found... aborting." << endl;
|
|---|
| 84 | return kFALSE;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | fTime = (MTime*)plist->FindObject("MTime");
|
|---|
| 88 | if (!fTime)
|
|---|
| 89 | {
|
|---|
| 90 | *fLog << err << dbginf << "MHAlphaEnergyTime : MTime not found... aborting." << endl;
|
|---|
| 91 | return kFALSE;
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
|
|---|
| 95 | MBinning* binsalphaflux = (MBinning*)plist->FindObject("BinningAlphaFlux");
|
|---|
| 96 | MBinning* binstime = (MBinning*)plist->FindObject("BinningTime");
|
|---|
| 97 | if (!binsenergy || !binsalphaflux || !binstime)
|
|---|
| 98 | {
|
|---|
| 99 | *fLog << err << dbginf << "MHAlphaEnergyTime : At least one MBinning not found... aborting." << endl;
|
|---|
| 100 | return kFALSE;
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | SetBinning(&fHist, binsalphaflux, binsenergy, binstime);
|
|---|
| 104 |
|
|---|
| 105 | fHist.Sumw2();
|
|---|
| 106 |
|
|---|
| 107 | return kTRUE;
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | // --------------------------------------------------------------------------
|
|---|
| 111 | //
|
|---|
| 112 | // Fill the histogram
|
|---|
| 113 | //
|
|---|
| 114 | Bool_t MHAlphaEnergyTime::Fill(const MParContainer *par, const Stat_t w)
|
|---|
| 115 | {
|
|---|
| 116 | MHillasSrc &hil = *(MHillasSrc*)par;
|
|---|
| 117 |
|
|---|
| 118 | fHist.Fill(fabs(hil.GetAlpha()), fEnergy->GetEnergy(), 0.0001*fTime->GetTimeLo(), w);
|
|---|
| 119 | return kTRUE;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | // --------------------------------------------------------------------------
|
|---|
| 123 | //
|
|---|
| 124 | // Draw the histogram
|
|---|
| 125 | //
|
|---|
| 126 | void MHAlphaEnergyTime::Draw(Option_t *opt)
|
|---|
| 127 | {
|
|---|
| 128 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
|---|
| 129 | pad->SetBorderMode(0);
|
|---|
| 130 |
|
|---|
| 131 | pad->Divide(2,2);
|
|---|
| 132 |
|
|---|
| 133 | TH1 *h;
|
|---|
| 134 |
|
|---|
| 135 | pad->cd(1);
|
|---|
| 136 | gPad->SetBorderMode(0);
|
|---|
| 137 | h = fHist.Project3D("ex");
|
|---|
| 138 | h->SetTitle("Distribution of \\alpha [\\circ]");
|
|---|
| 139 | h->SetXTitle("\\alpha [\\circ]");
|
|---|
| 140 | h->SetYTitle("Counts");
|
|---|
| 141 | h->Draw(opt);
|
|---|
| 142 | h->SetBit(kCanDelete);
|
|---|
| 143 |
|
|---|
| 144 | pad->cd(2);
|
|---|
| 145 | gPad->SetBorderMode(0);
|
|---|
| 146 | gPad->SetLogx();
|
|---|
| 147 | h = fHist.Project3D("ey");
|
|---|
| 148 | h->SetTitle("Distribution of E-est [GeV]");
|
|---|
| 149 | h->SetXTitle("E-est [GeV] ");
|
|---|
| 150 | h->SetYTitle("Counts");
|
|---|
| 151 | h->Draw(opt);
|
|---|
| 152 | h->SetBit(kCanDelete);
|
|---|
| 153 |
|
|---|
| 154 | pad->cd(3);
|
|---|
| 155 | gPad->SetBorderMode(0);
|
|---|
| 156 | h = fHist.Project3D("ez");
|
|---|
| 157 | h->SetTitle("Distribution of time [s]");
|
|---|
| 158 | h->SetXTitle("time [s]");
|
|---|
| 159 | h->SetYTitle("Counts");
|
|---|
| 160 | h->Draw(opt);
|
|---|
| 161 | h->SetBit(kCanDelete);
|
|---|
| 162 |
|
|---|
| 163 | pad->cd(4);
|
|---|
| 164 | gPad->SetBorderMode(0);
|
|---|
| 165 | fHist.Draw(opt);
|
|---|
| 166 |
|
|---|
| 167 | pad->Modified();
|
|---|
| 168 | pad->Update();
|
|---|
| 169 |
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | // --------------------------------------------------------------------------
|
|---|
| 173 | //
|
|---|
| 174 | // Integrate fHist (Alpha,E-est,Time) over the Time to get
|
|---|
| 175 | // fAlphaEest(Alpha,E-est)
|
|---|
| 176 | //
|
|---|
| 177 | TH2D *MHAlphaEnergyTime::IntegrateTime(const char *title, Bool_t draw)
|
|---|
| 178 | {
|
|---|
| 179 | Int_t nzbins = fHist.GetNbinsZ();
|
|---|
| 180 | TAxis &axez = *fHist.GetZaxis();
|
|---|
| 181 | axez.SetRange(1,nzbins);
|
|---|
| 182 |
|
|---|
| 183 | TH2D &fAlphaEest = *(TH2D *)fHist.Project3D("exy");
|
|---|
| 184 |
|
|---|
| 185 | fAlphaEest.SetTitle(title);
|
|---|
| 186 | fAlphaEest.SetXTitle("E-est [GeV] ");
|
|---|
| 187 | fAlphaEest.SetYTitle("\\alpha [ \\circ]");
|
|---|
| 188 |
|
|---|
| 189 | if (draw == kTRUE)
|
|---|
| 190 | {
|
|---|
| 191 | TCanvas &c = *MakeDefCanvas(title, title);
|
|---|
| 192 |
|
|---|
| 193 | gROOT->SetSelectedPad(NULL);
|
|---|
| 194 |
|
|---|
| 195 | fAlphaEest.DrawCopy();
|
|---|
| 196 | gPad->SetLogx();
|
|---|
| 197 |
|
|---|
| 198 | c.Modified();
|
|---|
| 199 | c.Update();
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | return &fAlphaEest;
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | // --------------------------------------------------------------------------
|
|---|
| 206 | //
|
|---|
| 207 | // Integrate fHist (Alpha,E-est,Time) over E-est to get
|
|---|
| 208 | // fAlphaTime(Alpha,Time)
|
|---|
| 209 | //
|
|---|
| 210 | TH2D *MHAlphaEnergyTime::IntegrateEest(const char *title, Bool_t draw)
|
|---|
| 211 | {
|
|---|
| 212 | Int_t nybins = fHist.GetNbinsY();
|
|---|
| 213 | TAxis &axey = *fHist.GetYaxis();
|
|---|
| 214 | axey.SetRange(1,nybins);
|
|---|
| 215 |
|
|---|
| 216 | TH2D &fAlphaTime = *(TH2D *)fHist.Project3D("exz");
|
|---|
| 217 |
|
|---|
| 218 | fAlphaTime.SetTitle(title);
|
|---|
| 219 | fAlphaTime.SetXTitle("Time [s]");
|
|---|
| 220 | fAlphaTime.SetYTitle("\\alpha [ \\circ]");
|
|---|
| 221 |
|
|---|
| 222 | if (draw == kTRUE)
|
|---|
| 223 | {
|
|---|
| 224 | TCanvas &c = *MakeDefCanvas(title, title);
|
|---|
| 225 |
|
|---|
| 226 | gROOT->SetSelectedPad(NULL);
|
|---|
| 227 |
|
|---|
| 228 | fAlphaTime.DrawCopy();
|
|---|
| 229 |
|
|---|
| 230 | c.Modified();
|
|---|
| 231 | c.Update();
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 | return &fAlphaTime;
|
|---|
| 235 | }
|
|---|
| 236 |
|
|---|
| 237 | // --------------------------------------------------------------------------
|
|---|
| 238 | //
|
|---|
| 239 | // Integrate fHist (Alpha,E-est,Time) over Eest and Time to get
|
|---|
| 240 | // fAlpha(Alpha)
|
|---|
| 241 | //
|
|---|
| 242 | TH1D *MHAlphaEnergyTime::IntegrateEestTime(const char *title, Bool_t draw)
|
|---|
| 243 | {
|
|---|
| 244 | Int_t nybins = fHist.GetNbinsY();
|
|---|
| 245 | TAxis &axey = *fHist.GetYaxis();
|
|---|
| 246 | axey.SetRange(1,nybins);
|
|---|
| 247 |
|
|---|
| 248 | Int_t nzbins = fHist.GetNbinsZ();
|
|---|
| 249 | TAxis &axez = *fHist.GetZaxis();
|
|---|
| 250 | axez.SetRange(1,nzbins);
|
|---|
| 251 |
|
|---|
| 252 | TH1D &fAlpha = *(TH1D *)fHist.Project3D("ex");
|
|---|
| 253 |
|
|---|
| 254 | fAlpha.SetTitle(title);
|
|---|
| 255 | fAlpha.SetXTitle("\\alpha [ \\circ]");
|
|---|
| 256 | fAlpha.SetYTitle("Counts");
|
|---|
| 257 |
|
|---|
| 258 | if (draw == kTRUE)
|
|---|
| 259 | {
|
|---|
| 260 | TCanvas &c = *MakeDefCanvas(title, title);
|
|---|
| 261 |
|
|---|
| 262 | gROOT->SetSelectedPad(NULL);
|
|---|
| 263 |
|
|---|
| 264 | fAlpha.DrawCopy();
|
|---|
| 265 |
|
|---|
| 266 | c.Modified();
|
|---|
| 267 | c.Update();
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 | return &fAlpha;
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|