| 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): Markus Meyer, 02/2005 <mailto:meyer@astro.uni-wuerzburg.de>
|
|---|
| 19 | ! Author(s): Thomas Bretz, 04/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2005
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MHMuonPar
|
|---|
| 29 | //
|
|---|
| 30 | // This class is a histogram class for displaying muonparameters.
|
|---|
| 31 | // The folowing histgrams will be plotted:
|
|---|
| 32 | // - Radius (TH1F)
|
|---|
| 33 | // - ArcWidth (TH1F)
|
|---|
| 34 | // - ArcWidth/Radius vs Radius (TProfile) (it is the energy dependent
|
|---|
| 35 | // relative broadening of the muon ring)
|
|---|
| 36 | // - Size Vs Radius
|
|---|
| 37 | //
|
|---|
| 38 | // Inputcontainer:
|
|---|
| 39 | // - MGeomCam
|
|---|
| 40 | // - MMuonSearchPar
|
|---|
| 41 | // - MMuonCalibPar
|
|---|
| 42 | //
|
|---|
| 43 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 44 | #include "MHMuonPar.h"
|
|---|
| 45 |
|
|---|
| 46 | #include <TH1.h>
|
|---|
| 47 | #include <TPad.h>
|
|---|
| 48 | #include <TLatex.h>
|
|---|
| 49 | #include <TCanvas.h>
|
|---|
| 50 | #include <TProfile.h>
|
|---|
| 51 |
|
|---|
| 52 | #include "MLog.h"
|
|---|
| 53 | #include "MLogManip.h"
|
|---|
| 54 |
|
|---|
| 55 | #include "MGeomCam.h"
|
|---|
| 56 | #include "MBinning.h"
|
|---|
| 57 | #include "MParList.h"
|
|---|
| 58 |
|
|---|
| 59 | #include "MMuonSearchPar.h"
|
|---|
| 60 | #include "MMuonCalibPar.h"
|
|---|
| 61 |
|
|---|
| 62 | ClassImp(MHMuonPar);
|
|---|
| 63 |
|
|---|
| 64 | using namespace std;
|
|---|
| 65 |
|
|---|
| 66 | // --------------------------------------------------------------------------
|
|---|
| 67 | //
|
|---|
| 68 | // Setup histograms
|
|---|
| 69 | //
|
|---|
| 70 | MHMuonPar::MHMuonPar(const char *name, const char *title) :
|
|---|
| 71 | fMuonSearchPar(NULL), fMuonCalibPar(NULL)
|
|---|
| 72 | {
|
|---|
| 73 | fName = name ? name : "MHMuonPar";
|
|---|
| 74 | fTitle = title ? title : "Histograms of muon parameters";
|
|---|
| 75 |
|
|---|
| 76 | fHistRadius.SetName("Radius");
|
|---|
| 77 | fHistRadius.SetTitle("Distribution of Radius'");
|
|---|
| 78 | fHistRadius.SetXTitle("R [\\circ]");
|
|---|
| 79 | fHistRadius.SetYTitle("Counts");
|
|---|
| 80 | fHistRadius.SetDirectory(NULL);
|
|---|
| 81 | fHistRadius.UseCurrentStyle();
|
|---|
| 82 | fHistRadius.SetFillStyle(4000);
|
|---|
| 83 |
|
|---|
| 84 | fHistArcWidth.SetName("ArcWidth");
|
|---|
| 85 | fHistArcWidth.SetTitle("Distribution of ArcWidth");
|
|---|
| 86 | fHistArcWidth.SetXTitle("W [\\circ]");
|
|---|
| 87 | fHistArcWidth.SetYTitle("Counts");
|
|---|
| 88 | fHistArcWidth.SetDirectory(NULL);
|
|---|
| 89 | fHistArcWidth.UseCurrentStyle();
|
|---|
| 90 | fHistArcWidth.SetFillStyle(4000);
|
|---|
| 91 |
|
|---|
| 92 | fHistBroad.SetName("RingBroadening");
|
|---|
| 93 | fHistBroad.SetTitle("Profile ArcWidth/Radius vs Radius");
|
|---|
| 94 | fHistBroad.SetXTitle("R [\\circ]");
|
|---|
| 95 | fHistBroad.SetYTitle("W/R [1]");
|
|---|
| 96 | fHistBroad.SetDirectory(NULL);
|
|---|
| 97 | fHistBroad.UseCurrentStyle();
|
|---|
| 98 | fHistBroad.SetFillStyle(4000);
|
|---|
| 99 |
|
|---|
| 100 | fHistSize.SetName("SizeVsRadius");
|
|---|
| 101 | fHistSize.SetTitle("Profile MuonSize vs Radius");
|
|---|
| 102 | fHistSize.SetXTitle("R [\\circ]");
|
|---|
| 103 | fHistSize.SetYTitle("S [phe]");
|
|---|
| 104 | fHistSize.SetDirectory(NULL);
|
|---|
| 105 | fHistSize.UseCurrentStyle();
|
|---|
| 106 | fHistSize.SetFillStyle(4000);
|
|---|
| 107 |
|
|---|
| 108 | MBinning bins;
|
|---|
| 109 |
|
|---|
| 110 | bins.SetEdges(20, 0.5, 1.5);
|
|---|
| 111 | bins.Apply(fHistRadius);
|
|---|
| 112 |
|
|---|
| 113 | bins.SetEdges(60, 0., 0.3);
|
|---|
| 114 | bins.Apply(fHistArcWidth);
|
|---|
| 115 |
|
|---|
| 116 | bins.SetEdges(20, 0.5, 1.5);
|
|---|
| 117 | bins.Apply(fHistBroad);
|
|---|
| 118 |
|
|---|
| 119 | bins.SetEdges(20, 0.5, 1.5);
|
|---|
| 120 | bins.Apply(fHistSize);
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | // --------------------------------------------------------------------------
|
|---|
| 124 | //
|
|---|
| 125 | // Setup the Binning for the histograms automatically if the correct
|
|---|
| 126 | // instances of MBinning
|
|---|
| 127 | //
|
|---|
| 128 | Bool_t MHMuonPar::SetupFill(const MParList *plist)
|
|---|
| 129 | {
|
|---|
| 130 | MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
|
|---|
| 131 | if (!geom)
|
|---|
| 132 | {
|
|---|
| 133 | *fLog << warn << "MGeomCam not found... abort." << endl;
|
|---|
| 134 | return kFALSE;
|
|---|
| 135 | }
|
|---|
| 136 | fMm2Deg = geom->GetConvMm2Deg();
|
|---|
| 137 |
|
|---|
| 138 | fMuonSearchPar = (MMuonSearchPar*)plist->FindObject("MMuonSearchPar");
|
|---|
| 139 | if (!fMuonSearchPar)
|
|---|
| 140 | {
|
|---|
| 141 | *fLog << warn << "MMuonSearchPar not found... abort." << endl;
|
|---|
| 142 | return kFALSE;
|
|---|
| 143 | }
|
|---|
| 144 | fMuonCalibPar = (MMuonCalibPar*)plist->FindObject("MMuonCalibPar");
|
|---|
| 145 | if (!fMuonCalibPar)
|
|---|
| 146 | {
|
|---|
| 147 | *fLog << warn << "MMuonCalibPar not found... abort." << endl;
|
|---|
| 148 | return kFALSE;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | ApplyBinning(*plist, "Radius", &fHistRadius);
|
|---|
| 152 | ApplyBinning(*plist, "ArcWidth", &fHistArcWidth);
|
|---|
| 153 | ApplyBinning(*plist, "RingBroadening", &fHistBroad);
|
|---|
| 154 | ApplyBinning(*plist, "SizeVsRadius", &fHistSize);
|
|---|
| 155 |
|
|---|
| 156 | return kTRUE;
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | // --------------------------------------------------------------------------
|
|---|
| 160 | //
|
|---|
| 161 | // Fill the histograms with data from a MMuonCalibPar and
|
|---|
| 162 | // MMuonSearchPar container.
|
|---|
| 163 | //
|
|---|
| 164 | Bool_t MHMuonPar::Fill(const MParContainer *par, const Stat_t w)
|
|---|
| 165 | {
|
|---|
| 166 | fHistRadius.Fill(fMm2Deg*fMuonSearchPar->GetRadius(), w);
|
|---|
| 167 |
|
|---|
| 168 | fHistArcWidth.Fill(fMuonCalibPar->GetArcWidth(), w);
|
|---|
| 169 |
|
|---|
| 170 | fHistBroad.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
|
|---|
| 171 | fMuonCalibPar->GetArcWidth()/(fMm2Deg*fMuonSearchPar->GetRadius()), w);
|
|---|
| 172 |
|
|---|
| 173 | fHistSize.Fill(fMm2Deg*fMuonSearchPar->GetRadius(),
|
|---|
| 174 | fMuonCalibPar->GetMuonSize(), w);
|
|---|
| 175 |
|
|---|
| 176 | return kTRUE;
|
|---|
| 177 | }
|
|---|
| 178 | // --------------------------------------------------------------------------
|
|---|
| 179 | //
|
|---|
| 180 | // Creates a new canvas and draws the two histograms into it.
|
|---|
| 181 | // Be careful: The histograms belongs to this object and won't get deleted
|
|---|
| 182 | // together with the canvas.
|
|---|
| 183 | //
|
|---|
| 184 | void MHMuonPar::Draw(Option_t *)
|
|---|
| 185 | {
|
|---|
| 186 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
|---|
| 187 | pad->SetBorderMode(0);
|
|---|
| 188 |
|
|---|
| 189 | AppendPad("");
|
|---|
| 190 |
|
|---|
| 191 | pad->Divide(2,2);
|
|---|
| 192 |
|
|---|
| 193 | pad->cd(1);
|
|---|
| 194 | gPad->SetBorderMode(0);
|
|---|
| 195 | fHistRadius.Draw();
|
|---|
| 196 |
|
|---|
| 197 | pad->cd(2);
|
|---|
| 198 | gPad->SetBorderMode(0);
|
|---|
| 199 | fHistArcWidth.Draw();
|
|---|
| 200 |
|
|---|
| 201 | pad->cd(3);
|
|---|
| 202 | gPad->SetBorderMode(0);
|
|---|
| 203 | fHistSize.Draw();
|
|---|
| 204 |
|
|---|
| 205 | pad->cd(4);
|
|---|
| 206 | gPad->SetBorderMode(0);
|
|---|
| 207 | fHistBroad.Draw();
|
|---|
| 208 |
|
|---|
| 209 | AppendPad("pad4");
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | void MHMuonPar::Paint(Option_t *opt)
|
|---|
| 213 | {
|
|---|
| 214 | if (TString(opt)!=TString("pad4"))
|
|---|
| 215 | return;
|
|---|
| 216 |
|
|---|
| 217 | const Double_t lolim = 0.7;
|
|---|
| 218 | const Double_t uplim = 1.2;
|
|---|
| 219 |
|
|---|
| 220 | const Int_t bin1 = fHistBroad.GetXaxis()->FindFixBin(lolim);
|
|---|
| 221 | const Int_t bin2 = fHistBroad.GetXaxis()->FindFixBin(uplim);
|
|---|
| 222 |
|
|---|
| 223 | const TString txt = Form("\\Sigma_{%.2f\\circ}^{%.2f\\circ} = %.3f", lolim,
|
|---|
| 224 | uplim, fHistBroad.Integral(bin1, bin2));
|
|---|
| 225 |
|
|---|
| 226 | TLatex text(0.57, 0.93, txt);
|
|---|
| 227 | text.SetBit(TLatex::kTextNDC);
|
|---|
| 228 | text.SetTextSize(0.055);
|
|---|
| 229 | text.Paint();
|
|---|
| 230 | }
|
|---|