| 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 2001 <mailto:tbretz@uni-sw.gwdg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2001
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | ///////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MHHillasSrc
|
|---|
| 28 | //
|
|---|
| 29 | // This class contains histograms for every Hillas parameter
|
|---|
| 30 | //
|
|---|
| 31 | ///////////////////////////////////////////////////////////////////////
|
|---|
| 32 | #include "MHHillasSrc.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 "MHillasSrc.h"
|
|---|
| 49 |
|
|---|
| 50 | ClassImp(MHHillasSrc);
|
|---|
| 51 |
|
|---|
| 52 | // --------------------------------------------------------------------------
|
|---|
| 53 | //
|
|---|
| 54 | // Setup four histograms for Alpha, and Dist
|
|---|
| 55 | //
|
|---|
| 56 | MHHillasSrc::MHHillasSrc(const char *name, const char *title)
|
|---|
| 57 | : fUseMmScale(kTRUE)
|
|---|
| 58 | {
|
|---|
| 59 | //
|
|---|
| 60 | // set the name and title of this object
|
|---|
| 61 | //
|
|---|
| 62 | fName = name ? name : "MHHillasSrc";
|
|---|
| 63 | fTitle = title ? title : "Container for Hillas histograms";
|
|---|
| 64 |
|
|---|
| 65 | //
|
|---|
| 66 | // loop over all Pixels and create two histograms
|
|---|
| 67 | // one for the Low and one for the High gain
|
|---|
| 68 | // connect all the histogram with the container fHist
|
|---|
| 69 | //
|
|---|
| 70 | fAlpha = new TH1F("Alpha", "Alpha of Ellipse", 181, -90, 90);
|
|---|
| 71 | fDist = new TH1F("Dist", "Dist of Ellipse", 100, 0, 445);
|
|---|
| 72 | fCosDA = new TH1F("CosDA", "cos(Delta,Alpha) of Ellipse", 101, -1, 1);
|
|---|
| 73 |
|
|---|
| 74 | fAlpha->SetDirectory(NULL);
|
|---|
| 75 | fDist->SetDirectory(NULL);
|
|---|
| 76 | fCosDA->SetDirectory(NULL);
|
|---|
| 77 |
|
|---|
| 78 | fAlpha->SetXTitle("\\alpha [\\circ]");
|
|---|
| 79 | fDist->SetXTitle("Dist [mm]");
|
|---|
| 80 | fCosDA->SetXTitle("cos(\\delta,\\alpha)");
|
|---|
| 81 |
|
|---|
| 82 | fAlpha->SetYTitle("Counts");
|
|---|
| 83 | fDist->SetYTitle("Counts");
|
|---|
| 84 | fCosDA->SetYTitle("Counts");
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | // --------------------------------------------------------------------------
|
|---|
| 88 | //
|
|---|
| 89 | // Delete the four histograms
|
|---|
| 90 | //
|
|---|
| 91 | MHHillasSrc::~MHHillasSrc()
|
|---|
| 92 | {
|
|---|
| 93 | delete fAlpha;
|
|---|
| 94 | delete fDist;
|
|---|
| 95 | delete fCosDA;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | // --------------------------------------------------------------------------
|
|---|
| 99 | //
|
|---|
| 100 | // Setup the Binning for the histograms automatically if the correct
|
|---|
| 101 | // instances of MBinning (with the names 'BinningAlpha' and 'BinningDist')
|
|---|
| 102 | // are found in the parameter list
|
|---|
| 103 | // Use this function if you want to set the conversion factor which
|
|---|
| 104 | // is used to convert the mm-scale in the camera plain into the deg-scale
|
|---|
| 105 | // used for histogram presentations. The conversion factor is part of
|
|---|
| 106 | // the camera geometry. Please create a corresponding MGeomCam container.
|
|---|
| 107 | //
|
|---|
| 108 | Bool_t MHHillasSrc::SetupFill(const MParList *plist)
|
|---|
| 109 | {
|
|---|
| 110 | const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
|
|---|
| 111 | if (!geom)
|
|---|
| 112 | *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
|
|---|
| 113 | else
|
|---|
| 114 | {
|
|---|
| 115 | fMm2Deg = geom->GetConvMm2Deg();
|
|---|
| 116 | SetMmScale(kFALSE);
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | ApplyBinning(*plist, "Alpha", fAlpha);
|
|---|
| 120 | ApplyBinning(*plist, "Dist", fDist);
|
|---|
| 121 |
|
|---|
| 122 | return kTRUE;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | // --------------------------------------------------------------------------
|
|---|
| 126 | //
|
|---|
| 127 | // Fill the four histograms with data from a MHillas-Container.
|
|---|
| 128 | // Be careful: Only call this with an object of type MHillas
|
|---|
| 129 | //
|
|---|
| 130 | Bool_t MHHillasSrc::Fill(const MParContainer *par, const Stat_t w)
|
|---|
| 131 | {
|
|---|
| 132 | const MHillasSrc &h = *(MHillasSrc*)par;
|
|---|
| 133 |
|
|---|
| 134 | fAlpha->Fill(h.GetAlpha(), w);
|
|---|
| 135 | fDist ->Fill(fUseMmScale ? h.GetDist() : fMm2Deg*h.GetDist(), w);
|
|---|
| 136 | fCosDA->Fill(h.GetCosDeltaAlpha(), w);
|
|---|
| 137 |
|
|---|
| 138 | return kTRUE;
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | // --------------------------------------------------------------------------
|
|---|
| 142 | //
|
|---|
| 143 | // Use this function to setup your own conversion factor between degrees
|
|---|
| 144 | // and millimeters. The conversion factor should be the one calculated in
|
|---|
| 145 | // MGeomCam. Use this function with Caution: You could create wrong values
|
|---|
| 146 | // by setting up your own scale factor.
|
|---|
| 147 | //
|
|---|
| 148 | void MHHillasSrc::SetMm2Deg(Float_t mmdeg)
|
|---|
| 149 | {
|
|---|
| 150 | if (mmdeg<=0)
|
|---|
| 151 | {
|
|---|
| 152 | *fLog << warn << dbginf << "Warning - Conversion factor <= 0 - nonsense. Ignored." << endl;
|
|---|
| 153 | return;
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | if (fMm2Deg>0)
|
|---|
| 157 | *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
|
|---|
| 158 |
|
|---|
| 159 | fMm2Deg = mmdeg;
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | // --------------------------------------------------------------------------
|
|---|
| 163 | //
|
|---|
| 164 | // With this function you can convert the histogram ('on the fly') between
|
|---|
| 165 | // degrees and millimeters.
|
|---|
| 166 | //
|
|---|
| 167 | void MHHillasSrc::SetMmScale(Bool_t mmscale)
|
|---|
| 168 | {
|
|---|
| 169 | if (fUseMmScale == mmscale)
|
|---|
| 170 | return;
|
|---|
| 171 |
|
|---|
| 172 | if (fMm2Deg<0)
|
|---|
| 173 | {
|
|---|
| 174 | *fLog << warn << GetDescriptor() << ": Warning - Sorry, no conversion factor for conversion available." << endl;
|
|---|
| 175 | return;
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
|
|---|
| 179 | MH::ScaleAxis(fDist, scale);
|
|---|
| 180 |
|
|---|
| 181 | fDist->SetXTitle(mmscale ? "Dist [mm]" : "Dist [\\circ]");
|
|---|
| 182 |
|
|---|
| 183 | fUseMmScale = mmscale;
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | // --------------------------------------------------------------------------
|
|---|
| 187 | //
|
|---|
| 188 | // Creates a new canvas and draws the two histograms into it.
|
|---|
| 189 | // Be careful: The histograms belongs to this object and won't get deleted
|
|---|
| 190 | // together with the canvas.
|
|---|
| 191 | //
|
|---|
| 192 | void MHHillasSrc::Draw(Option_t *)
|
|---|
| 193 | {
|
|---|
| 194 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
|---|
| 195 | pad->SetBorderMode(0);
|
|---|
| 196 |
|
|---|
| 197 | AppendPad("");
|
|---|
| 198 |
|
|---|
| 199 | // FIXME: Display Source position
|
|---|
| 200 |
|
|---|
| 201 | pad->Divide(2, 2);
|
|---|
| 202 |
|
|---|
| 203 | pad->cd(1);
|
|---|
| 204 | gPad->SetBorderMode(0);
|
|---|
| 205 | fAlpha->Draw();
|
|---|
| 206 |
|
|---|
| 207 | pad->cd(2);
|
|---|
| 208 | gPad->SetBorderMode(0);
|
|---|
| 209 | fDist->Draw();
|
|---|
| 210 |
|
|---|
| 211 | pad->cd(4);
|
|---|
| 212 | gPad->SetBorderMode(0);
|
|---|
| 213 | gPad->SetLogy();
|
|---|
| 214 | fCosDA->Draw();
|
|---|
| 215 |
|
|---|
| 216 | pad->Modified();
|
|---|
| 217 | pad->Update();
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|
| 220 | TH1 *MHHillasSrc::GetHistByName(const TString name)
|
|---|
| 221 | {
|
|---|
| 222 | if (name.Contains("Alpha", TString::kIgnoreCase))
|
|---|
| 223 | return fAlpha;
|
|---|
| 224 | if (name.Contains("Dist", TString::kIgnoreCase))
|
|---|
| 225 | return fDist;
|
|---|
| 226 | if (name.Contains("CosDA", TString::kIgnoreCase))
|
|---|
| 227 | return fCosDA;
|
|---|
| 228 |
|
|---|
| 229 | return NULL;
|
|---|
| 230 | }
|
|---|