| 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@uni-sw.gwdg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2002
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | #include "MHEnergyTheta.h"
|
|---|
| 26 |
|
|---|
| 27 | #include <TCanvas.h>
|
|---|
| 28 |
|
|---|
| 29 | #include "MH.h"
|
|---|
| 30 | #include "MBinning.h"
|
|---|
| 31 |
|
|---|
| 32 | #include "MLog.h"
|
|---|
| 33 | #include "MLogManip.h"
|
|---|
| 34 |
|
|---|
| 35 | #include "MMcEvt.hxx"
|
|---|
| 36 |
|
|---|
| 37 | #include "MParList.h"
|
|---|
| 38 |
|
|---|
| 39 | ClassImp(MHEnergyTheta);
|
|---|
| 40 |
|
|---|
| 41 | // --------------------------------------------------------------------------
|
|---|
| 42 | //
|
|---|
| 43 | // Creates the three necessary histograms:
|
|---|
| 44 | // - selected showers (input)
|
|---|
| 45 | // - all showers (input)
|
|---|
| 46 | // - collection area (result)
|
|---|
| 47 | //
|
|---|
| 48 | MHEnergyTheta::MHEnergyTheta(const char *name, const char *title)
|
|---|
| 49 | {
|
|---|
| 50 | // initialize the histogram for the distribution r vs E
|
|---|
| 51 | //
|
|---|
| 52 | // we set the energy range from 1 Gev to 10000 GeV (in log 5 orders
|
|---|
| 53 | // of magnitude) and for each order we take 10 subdivision --> 50 xbins
|
|---|
| 54 | //
|
|---|
| 55 | // we set the radius range from 0 m to 500 m with 10 m bin --> 50 ybins
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 | fName = name ? name : "MHEnergyTheta";
|
|---|
| 59 | fTitle = title ? title : "Data to Calculate Collection Area";
|
|---|
| 60 |
|
|---|
| 61 | fHist.SetDirectory(NULL);
|
|---|
| 62 |
|
|---|
| 63 | fHist.SetXTitle("E [GeV]");
|
|---|
| 64 | fHist.SetYTitle("\\Theta [\\circ]");
|
|---|
| 65 | fHist.SetZTitle("N");
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | Bool_t MHEnergyTheta::SetupFill(const MParList *plist)
|
|---|
| 69 | {
|
|---|
| 70 | MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
|
|---|
| 71 | MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta");
|
|---|
| 72 | if (!binsenergy || !binstheta)
|
|---|
| 73 | {
|
|---|
| 74 | *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
|
|---|
| 75 | return kFALSE;
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | SetBinning(&fHist, binsenergy, binstheta);
|
|---|
| 79 |
|
|---|
| 80 | return kTRUE;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | // --------------------------------------------------------------------------
|
|---|
| 84 | //
|
|---|
| 85 | // Delete the three histograms
|
|---|
| 86 | //
|
|---|
| 87 | MHEnergyTheta::~MHEnergyTheta()
|
|---|
| 88 | {
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | // --------------------------------------------------------------------------
|
|---|
| 92 | //
|
|---|
| 93 | // Fill data into the histogram which contains all showers
|
|---|
| 94 | //
|
|---|
| 95 | Bool_t MHEnergyTheta::Fill(const MParContainer *par)
|
|---|
| 96 | {
|
|---|
| 97 | const MMcEvt &mcevt = *(MMcEvt*)par;
|
|---|
| 98 |
|
|---|
| 99 | fHist.Fill(mcevt.GetEnergy(), mcevt.GetTheta());
|
|---|
| 100 |
|
|---|
| 101 | return kTRUE;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | // --------------------------------------------------------------------------
|
|---|
| 105 | //
|
|---|
| 106 | // Draw the histogram with all showers
|
|---|
| 107 | //
|
|---|
| 108 | void MHEnergyTheta::Draw(Option_t* option)
|
|---|
| 109 | {
|
|---|
| 110 | if (!gPad)
|
|---|
| 111 | MakeDefCanvas(&fHist);
|
|---|
| 112 |
|
|---|
| 113 | fHist.DrawCopy(option);
|
|---|
| 114 | gPad->SetLogy();
|
|---|
| 115 |
|
|---|
| 116 | gPad->Modified();
|
|---|
| 117 | gPad->Update();
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | // --------------------------------------------------------------------------
|
|---|
| 121 | //
|
|---|
| 122 | // Creates a new canvas and draws the histogram into it.
|
|---|
| 123 | // Be careful: The histogram belongs to this object and won't get deleted
|
|---|
| 124 | // together with the canvas.
|
|---|
| 125 | //
|
|---|
| 126 | TObject *MHEnergyTheta::DrawClone(Option_t* option) const
|
|---|
| 127 | {
|
|---|
| 128 | TCanvas *c = MakeDefCanvas(&fHist);
|
|---|
| 129 |
|
|---|
| 130 | //
|
|---|
| 131 | // This is necessary to get the expected bahviour of DrawClone
|
|---|
| 132 | //
|
|---|
| 133 | gROOT->SetSelectedPad(NULL);
|
|---|
| 134 |
|
|---|
| 135 | ((TH2D*)&fHist)->DrawCopy(option);
|
|---|
| 136 | gPad->SetLogy();
|
|---|
| 137 |
|
|---|
| 138 | c->Modified();
|
|---|
| 139 | c->Update();
|
|---|
| 140 |
|
|---|
| 141 | return c;
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | // --------------------------------------------------------------------------
|
|---|
| 145 | //
|
|---|
| 146 | // Calculate the Efficiency (collection area) and set the 'ReadyToSave'
|
|---|
| 147 | // flag
|
|---|
| 148 | //
|
|---|
| 149 | void MHEnergyTheta::Divide(const TH2D *h1, const TH2D *h2)
|
|---|
| 150 | {
|
|---|
| 151 | // Description!
|
|---|
| 152 |
|
|---|
| 153 | fHist.Sumw2();
|
|---|
| 154 | fHist.Divide((TH2D*)h1, (TH2D*)h2);
|
|---|
| 155 |
|
|---|
| 156 | SetReadyToSave();
|
|---|
| 157 | }
|
|---|