| 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): Wolfgang Wittek 03/2003 <mailto:wittek@mppmu.mpg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2003
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | ///////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MHNewImagePar
|
|---|
| 28 | //
|
|---|
| 29 | // This class contains histograms for every Hillas parameter
|
|---|
| 30 | //
|
|---|
| 31 | ///////////////////////////////////////////////////////////////////////
|
|---|
| 32 | #include "MHNewImagePar.h"
|
|---|
| 33 |
|
|---|
| 34 | #include <math.h>
|
|---|
| 35 |
|
|---|
| 36 | #include <TH1.h>
|
|---|
| 37 | #include <TPad.h>
|
|---|
| 38 | #include <TCanvas.h>
|
|---|
| 39 |
|
|---|
| 40 | #include "MLog.h"
|
|---|
| 41 | #include "MLogManip.h"
|
|---|
| 42 |
|
|---|
| 43 | #include "MGeomCam.h"
|
|---|
| 44 |
|
|---|
| 45 | #include "MParList.h"
|
|---|
| 46 |
|
|---|
| 47 | #include "MHillas.h"
|
|---|
| 48 | #include "MNewImagePar.h"
|
|---|
| 49 |
|
|---|
| 50 | ClassImp(MHNewImagePar);
|
|---|
| 51 |
|
|---|
| 52 | // --------------------------------------------------------------------------
|
|---|
| 53 | //
|
|---|
| 54 | // Setup histograms
|
|---|
| 55 | //
|
|---|
| 56 | MHNewImagePar::MHNewImagePar(const char *name, const char *title)
|
|---|
| 57 | : fUseMmScale(kTRUE)
|
|---|
| 58 | {
|
|---|
| 59 | fName = name ? name : "MHNewImagePar";
|
|---|
| 60 | fTitle = title ? title : "Container for histograms of new image parameters";
|
|---|
| 61 |
|
|---|
| 62 | fLeakage1 = new TH1F("Leakage1", "Leakage1", 100, 0.0, 1.0);
|
|---|
| 63 | fLeakage1->SetDirectory(NULL);
|
|---|
| 64 | fLeakage1->SetXTitle("Leakage1");
|
|---|
| 65 | fLeakage1->SetYTitle("Counts");
|
|---|
| 66 |
|
|---|
| 67 | fLeakage2 = new TH1F("Leakage2", "Leakage2", 100, 0.0, 1.0);
|
|---|
| 68 | fLeakage2->SetDirectory(NULL);
|
|---|
| 69 | fLeakage2->SetXTitle("Leakage2");
|
|---|
| 70 | fLeakage2->SetYTitle("Counts");
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | // --------------------------------------------------------------------------
|
|---|
| 74 | //
|
|---|
| 75 | // Delete the four histograms
|
|---|
| 76 | //
|
|---|
| 77 | MHNewImagePar::~MHNewImagePar()
|
|---|
| 78 | {
|
|---|
| 79 | delete fLeakage1;
|
|---|
| 80 | delete fLeakage2;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | // --------------------------------------------------------------------------
|
|---|
| 84 | //
|
|---|
| 85 | // Setup the Binning for the histograms automatically if the correct
|
|---|
| 86 | // instances of MBinning (with the names 'BinningAlpha' and 'BinningDist')
|
|---|
| 87 | // are found in the parameter list
|
|---|
| 88 | // Use this function if you want to set the conversion factor which
|
|---|
| 89 | // is used to convert the mm-scale in the camera plain into the deg-scale
|
|---|
| 90 | // used for histogram presentations. The conversion factor is part of
|
|---|
| 91 | // the camera geometry. Please create a corresponding MGeomCam container.
|
|---|
| 92 | //
|
|---|
| 93 | Bool_t MHNewImagePar::SetupFill(const MParList *plist)
|
|---|
| 94 | {
|
|---|
| 95 | const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
|
|---|
| 96 | if (!geom)
|
|---|
| 97 | *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
|
|---|
| 98 | else
|
|---|
| 99 | {
|
|---|
| 100 | fMm2Deg = geom->GetConvMm2Deg();
|
|---|
| 101 | SetMmScale(kFALSE);
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | //ApplyBinning(*plist, "Alpha", fAlpha);
|
|---|
| 105 | //ApplyBinning(*plist, "Dist", fDist);
|
|---|
| 106 | //ApplyBinning(*plist, "HeadTail", fHeadTail);
|
|---|
| 107 |
|
|---|
| 108 | return kTRUE;
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | // --------------------------------------------------------------------------
|
|---|
| 112 | //
|
|---|
| 113 | // Fill the histograms with data from a MNewImagePar container.
|
|---|
| 114 | //
|
|---|
| 115 | Bool_t MHNewImagePar::Fill(const MParContainer *par)
|
|---|
| 116 | {
|
|---|
| 117 | const MNewImagePar &h = *(MNewImagePar*)par;
|
|---|
| 118 |
|
|---|
| 119 | fLeakage1->Fill(h.GetLeakage1());
|
|---|
| 120 | fLeakage2->Fill(h.GetLeakage2());
|
|---|
| 121 |
|
|---|
| 122 | return kTRUE;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | // --------------------------------------------------------------------------
|
|---|
| 126 | //
|
|---|
| 127 | // Use this function to setup your own conversion factor between degrees
|
|---|
| 128 | // and millimeters. The conversion factor should be the one calculated in
|
|---|
| 129 | // MGeomCam. Use this function with Caution: You could create wrong values
|
|---|
| 130 | // by setting up your own scale factor.
|
|---|
| 131 | //
|
|---|
| 132 | void MHNewImagePar::SetMm2Deg(Float_t mmdeg)
|
|---|
| 133 | {
|
|---|
| 134 | if (mmdeg<=0)
|
|---|
| 135 | {
|
|---|
| 136 | *fLog << warn << dbginf << "Warning - Conversion factor <= 0 - nonsense. Ignored." << endl;
|
|---|
| 137 | return;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | if (fMm2Deg>0)
|
|---|
| 141 | *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
|
|---|
| 142 |
|
|---|
| 143 | fMm2Deg = mmdeg;
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | // --------------------------------------------------------------------------
|
|---|
| 147 | //
|
|---|
| 148 | // With this function you can convert the histogram ('on the fly') between
|
|---|
| 149 | // degrees and millimeters.
|
|---|
| 150 | //
|
|---|
| 151 | void MHNewImagePar::SetMmScale(Bool_t mmscale)
|
|---|
| 152 | {
|
|---|
| 153 | if (fUseMmScale == mmscale)
|
|---|
| 154 | return;
|
|---|
| 155 |
|
|---|
| 156 | if (fMm2Deg<0)
|
|---|
| 157 | {
|
|---|
| 158 | *fLog << warn << GetDescriptor() << ": Warning - Sorry, no conversion factor for conversion available." << endl;
|
|---|
| 159 | return;
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | //const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
|
|---|
| 163 | //MH::ScaleAxis(fDist, scale);
|
|---|
| 164 | //MH::ScaleAxis(fHeadTail, scale);
|
|---|
| 165 |
|
|---|
| 166 | if (mmscale)
|
|---|
| 167 | {
|
|---|
| 168 | // fDist->SetXTitle("Dist [mm]");
|
|---|
| 169 | // fHeadTail->SetXTitle("Head-Tail [mm]");
|
|---|
| 170 | }
|
|---|
| 171 | else
|
|---|
| 172 | {
|
|---|
| 173 | // fDist->SetXTitle("Dist [\\circ]");
|
|---|
| 174 | // fHeadTail->SetXTitle("Head-Tail [\\circ]");
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | fUseMmScale = mmscale;
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | // --------------------------------------------------------------------------
|
|---|
| 181 | //
|
|---|
| 182 | // Draw clones of all two histograms. So that the object can be deleted
|
|---|
| 183 | // and the histograms are still visible in the canvas.
|
|---|
| 184 | // The cloned object are deleted together with the canvas if the canvas is
|
|---|
| 185 | // destroyed. If you want to handle dostroying the canvas you can get a
|
|---|
| 186 | // pointer to it from this function
|
|---|
| 187 | //
|
|---|
| 188 | TObject *MHNewImagePar::DrawClone(Option_t *opt) const
|
|---|
| 189 | {
|
|---|
| 190 | TCanvas *c = MakeDefCanvas(this, 300, 600);
|
|---|
| 191 | c->Divide(1, 2);
|
|---|
| 192 |
|
|---|
| 193 | gROOT->SetSelectedPad(NULL);
|
|---|
| 194 |
|
|---|
| 195 | c->cd(1);
|
|---|
| 196 | fLeakage1->DrawCopy();
|
|---|
| 197 |
|
|---|
| 198 | c->cd(2);
|
|---|
| 199 | fLeakage2->DrawCopy();
|
|---|
| 200 |
|
|---|
| 201 | c->Modified();
|
|---|
| 202 | c->Update();
|
|---|
| 203 |
|
|---|
| 204 | return c;
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | // --------------------------------------------------------------------------
|
|---|
| 208 | //
|
|---|
| 209 | // Creates a new canvas and draws the two histograms into it.
|
|---|
| 210 | // Be careful: The histograms belongs to this object and won't get deleted
|
|---|
| 211 | // together with the canvas.
|
|---|
| 212 | //
|
|---|
| 213 | void MHNewImagePar::Draw(Option_t *)
|
|---|
| 214 | {
|
|---|
| 215 | if (!gPad)
|
|---|
| 216 | MakeDefCanvas(this, 300, 600);
|
|---|
| 217 |
|
|---|
| 218 | gPad->Divide(2, 2);
|
|---|
| 219 |
|
|---|
| 220 | gPad->cd(1);
|
|---|
| 221 | fLeakage1->Draw();
|
|---|
| 222 |
|
|---|
| 223 | gPad->cd(2);
|
|---|
| 224 | fLeakage2->Draw();
|
|---|
| 225 |
|
|---|
| 226 | gPad->Modified();
|
|---|
| 227 | gPad->Update();
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | TH1 *MHNewImagePar::GetHistByName(const TString name)
|
|---|
| 231 | {
|
|---|
| 232 | if (name.Contains("Leakage1", TString::kIgnoreCase))
|
|---|
| 233 | return fLeakage1;
|
|---|
| 234 |
|
|---|
| 235 | if (name.Contains("Leakage2", TString::kIgnoreCase))
|
|---|
| 236 | return fLeakage2;
|
|---|
| 237 |
|
|---|
| 238 | return NULL;
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
|
|---|