| 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 | fHeadTail = new TH1F("HeadTail", "HeadTail of Ellipse", 101, -445, 445);
|
|---|
| 73 | fCosDA = new TH1F("CosDA", "cos(Delta,Alpha) of Ellipse", 101, -1, 1);
|
|---|
| 74 |
|
|---|
| 75 | fAlpha->SetDirectory(NULL);
|
|---|
| 76 | fDist->SetDirectory(NULL);
|
|---|
| 77 | fHeadTail->SetDirectory(NULL);
|
|---|
| 78 | fCosDA->SetDirectory(NULL);
|
|---|
| 79 |
|
|---|
| 80 | fAlpha->SetXTitle("\\alpha [\\circ]");
|
|---|
| 81 | fDist->SetXTitle("Dist [mm]");
|
|---|
| 82 | fHeadTail->SetXTitle("Head-Tail [mm]");
|
|---|
| 83 | fCosDA->SetXTitle("cos(\\delta,\\alpha)");
|
|---|
| 84 |
|
|---|
| 85 | fAlpha->SetYTitle("Counts");
|
|---|
| 86 | fDist->SetYTitle("Counts");
|
|---|
| 87 | fHeadTail->SetYTitle("Counts");
|
|---|
| 88 | fCosDA->SetYTitle("Counts");
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | // --------------------------------------------------------------------------
|
|---|
| 92 | //
|
|---|
| 93 | // Delete the four histograms
|
|---|
| 94 | //
|
|---|
| 95 | MHHillasSrc::~MHHillasSrc()
|
|---|
| 96 | {
|
|---|
| 97 | delete fAlpha;
|
|---|
| 98 | delete fDist;
|
|---|
| 99 | delete fHeadTail;
|
|---|
| 100 | delete fCosDA;
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | // --------------------------------------------------------------------------
|
|---|
| 104 | //
|
|---|
| 105 | // Setup the Binning for the histograms automatically if the correct
|
|---|
| 106 | // instances of MBinning (with the names 'BinningAlpha' and 'BinningDist')
|
|---|
| 107 | // are found in the parameter list
|
|---|
| 108 | // Use this function if you want to set the conversion factor which
|
|---|
| 109 | // is used to convert the mm-scale in the camera plain into the deg-scale
|
|---|
| 110 | // used for histogram presentations. The conversion factor is part of
|
|---|
| 111 | // the camera geometry. Please create a corresponding MGeomCam container.
|
|---|
| 112 | //
|
|---|
| 113 | Bool_t MHHillasSrc::SetupFill(const MParList *plist)
|
|---|
| 114 | {
|
|---|
| 115 | const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
|
|---|
| 116 | if (!geom)
|
|---|
| 117 | *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
|
|---|
| 118 | else
|
|---|
| 119 | {
|
|---|
| 120 | fMm2Deg = geom->GetConvMm2Deg();
|
|---|
| 121 | SetMmScale(kFALSE);
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | ApplyBinning(*plist, "Alpha", fAlpha);
|
|---|
| 125 | ApplyBinning(*plist, "Dist", fDist);
|
|---|
| 126 | ApplyBinning(*plist, "HeadTail", fHeadTail);
|
|---|
| 127 |
|
|---|
| 128 | return kTRUE;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | // --------------------------------------------------------------------------
|
|---|
| 132 | //
|
|---|
| 133 | // Fill the four histograms with data from a MHillas-Container.
|
|---|
| 134 | // Be careful: Only call this with an object of type MHillas
|
|---|
| 135 | //
|
|---|
| 136 | Bool_t MHHillasSrc::Fill(const MParContainer *par)
|
|---|
| 137 | {
|
|---|
| 138 | const MHillasSrc &h = *(MHillasSrc*)par;
|
|---|
| 139 |
|
|---|
| 140 | fAlpha ->Fill(h.GetAlpha());
|
|---|
| 141 | fDist ->Fill(fUseMmScale ? h.GetDist() : fMm2Deg*h.GetDist());
|
|---|
| 142 | fHeadTail->Fill(fUseMmScale ? h.GetHeadTail() : fMm2Deg*h.GetHeadTail());
|
|---|
| 143 | fCosDA ->Fill(h.GetCosDeltaAlpha());
|
|---|
| 144 |
|
|---|
| 145 | return kTRUE;
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | // --------------------------------------------------------------------------
|
|---|
| 149 | //
|
|---|
| 150 | // Use this function to setup your own conversion factor between degrees
|
|---|
| 151 | // and millimeters. The conversion factor should be the one calculated in
|
|---|
| 152 | // MGeomCam. Use this function with Caution: You could create wrong values
|
|---|
| 153 | // by setting up your own scale factor.
|
|---|
| 154 | //
|
|---|
| 155 | void MHHillasSrc::SetMm2Deg(Float_t mmdeg)
|
|---|
| 156 | {
|
|---|
| 157 | if (mmdeg<=0)
|
|---|
| 158 | {
|
|---|
| 159 | *fLog << warn << dbginf << "Warning - Conversion factor <= 0 - nonsense. Ignored." << endl;
|
|---|
| 160 | return;
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | if (fMm2Deg>0)
|
|---|
| 164 | *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
|
|---|
| 165 |
|
|---|
| 166 | fMm2Deg = mmdeg;
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | // --------------------------------------------------------------------------
|
|---|
| 170 | //
|
|---|
| 171 | // With this function you can convert the histogram ('on the fly') between
|
|---|
| 172 | // degrees and millimeters.
|
|---|
| 173 | //
|
|---|
| 174 | void MHHillasSrc::SetMmScale(Bool_t mmscale)
|
|---|
| 175 | {
|
|---|
| 176 | if (fUseMmScale == mmscale)
|
|---|
| 177 | return;
|
|---|
| 178 |
|
|---|
| 179 | if (fMm2Deg<0)
|
|---|
| 180 | {
|
|---|
| 181 | *fLog << warn << GetDescriptor() << ": Warning - Sorry, no conversion factor for conversion available." << endl;
|
|---|
| 182 | return;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
|
|---|
| 186 | MH::ScaleAxis(fDist, scale);
|
|---|
| 187 | MH::ScaleAxis(fHeadTail, scale);
|
|---|
| 188 |
|
|---|
| 189 | if (mmscale)
|
|---|
| 190 | {
|
|---|
| 191 | fDist->SetXTitle("Dist [mm]");
|
|---|
| 192 | fHeadTail->SetXTitle("Head-Tail [mm]");
|
|---|
| 193 | }
|
|---|
| 194 | else
|
|---|
| 195 | {
|
|---|
| 196 | fDist->SetXTitle("Dist [\\circ]");
|
|---|
| 197 | fHeadTail->SetXTitle("Head-Tail [\\circ]");
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | fUseMmScale = mmscale;
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | // --------------------------------------------------------------------------
|
|---|
| 204 | //
|
|---|
| 205 | // Draw clones of all two histograms. So that the object can be deleted
|
|---|
| 206 | // and the histograms are still visible in the canvas.
|
|---|
| 207 | // The cloned object are deleted together with the canvas if the canvas is
|
|---|
| 208 | // destroyed. If you want to handle dostroying the canvas you can get a
|
|---|
| 209 | // pointer to it from this function
|
|---|
| 210 | //
|
|---|
| 211 | TObject *MHHillasSrc::DrawClone(Option_t *opt) const
|
|---|
| 212 | {
|
|---|
| 213 | TCanvas *c = MakeDefCanvas(this, 700, 500);
|
|---|
| 214 | c->Divide(2, 2);
|
|---|
| 215 |
|
|---|
| 216 | // FIXME: Display Source position
|
|---|
| 217 |
|
|---|
| 218 | gROOT->SetSelectedPad(NULL);
|
|---|
| 219 |
|
|---|
| 220 | //
|
|---|
| 221 | // This is necessary to get the expected bahviour of DrawClone
|
|---|
| 222 | //
|
|---|
| 223 | c->cd(1);
|
|---|
| 224 | fAlpha->DrawCopy();
|
|---|
| 225 |
|
|---|
| 226 | c->cd(2);
|
|---|
| 227 | fDist->DrawCopy();
|
|---|
| 228 |
|
|---|
| 229 | c->cd(3);
|
|---|
| 230 | fHeadTail->DrawCopy();
|
|---|
| 231 |
|
|---|
| 232 | c->cd(4);
|
|---|
| 233 | gPad->SetLogy();
|
|---|
| 234 | fCosDA->DrawCopy();
|
|---|
| 235 |
|
|---|
| 236 | c->Modified();
|
|---|
| 237 | c->Update();
|
|---|
| 238 |
|
|---|
| 239 | return c;
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | // --------------------------------------------------------------------------
|
|---|
| 243 | //
|
|---|
| 244 | // Creates a new canvas and draws the two histograms into it.
|
|---|
| 245 | // Be careful: The histograms belongs to this object and won't get deleted
|
|---|
| 246 | // together with the canvas.
|
|---|
| 247 | //
|
|---|
| 248 | void MHHillasSrc::Draw(Option_t *)
|
|---|
| 249 | {
|
|---|
| 250 | if (!gPad)
|
|---|
| 251 | MakeDefCanvas(this, 700, 500);
|
|---|
| 252 |
|
|---|
| 253 | // FIXME: Display Source position
|
|---|
| 254 |
|
|---|
| 255 | gPad->Divide(2, 2);
|
|---|
| 256 |
|
|---|
| 257 | gPad->cd(1);
|
|---|
| 258 | fAlpha->Draw();
|
|---|
| 259 |
|
|---|
| 260 | gPad->cd(2);
|
|---|
| 261 | fDist->Draw();
|
|---|
| 262 |
|
|---|
| 263 | gPad->cd(1);
|
|---|
| 264 | fHeadTail->Draw();
|
|---|
| 265 |
|
|---|
| 266 | gPad->cd(2);
|
|---|
| 267 | gPad->SetLogy();
|
|---|
| 268 | fCosDA->Draw();
|
|---|
| 269 |
|
|---|
| 270 | gPad->Modified();
|
|---|
| 271 | gPad->Update();
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 | TH1 *MHHillasSrc::GetHistByName(const TString name)
|
|---|
| 275 | {
|
|---|
| 276 | if (name.Contains("Alpha", TString::kIgnoreCase))
|
|---|
| 277 | return fAlpha;
|
|---|
| 278 | if (name.Contains("Dist", TString::kIgnoreCase))
|
|---|
| 279 | return fDist;
|
|---|
| 280 | if (name.Contains("HeadTail", TString::kIgnoreCase))
|
|---|
| 281 | return fHeadTail;
|
|---|
| 282 | if (name.Contains("CosDA", TString::kIgnoreCase))
|
|---|
| 283 | return fCosDA;
|
|---|
| 284 |
|
|---|
| 285 | return NULL;
|
|---|
| 286 | }
|
|---|