| 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 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | ! Author(s): Harald Kornmayer 1/2001
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2002
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MHThreshold
|
|---|
| 29 | //
|
|---|
| 30 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 31 | #include "MHThreshold.h"
|
|---|
| 32 |
|
|---|
| 33 | #include <TF1.h>
|
|---|
| 34 | #include <TLatex.h>
|
|---|
| 35 | #include <TCanvas.h>
|
|---|
| 36 | #include <TPaveStats.h>
|
|---|
| 37 |
|
|---|
| 38 | #include "MLog.h"
|
|---|
| 39 | #include "MLogManip.h"
|
|---|
| 40 |
|
|---|
| 41 | #include "MBinning.h"
|
|---|
| 42 |
|
|---|
| 43 | #include "MMcEvt.hxx"
|
|---|
| 44 |
|
|---|
| 45 | #include "MParList.h"
|
|---|
| 46 |
|
|---|
| 47 | ClassImp(MHThreshold);
|
|---|
| 48 |
|
|---|
| 49 | using namespace std;
|
|---|
| 50 |
|
|---|
| 51 | // --------------------------------------------------------------------------
|
|---|
| 52 | //
|
|---|
| 53 | // Creates the three necessary histograms:
|
|---|
| 54 | // - selected showers (input)
|
|---|
| 55 | // - all showers (input)
|
|---|
| 56 | // - collection area (result)
|
|---|
| 57 | //
|
|---|
| 58 | MHThreshold::MHThreshold(const char *name, const char *title)
|
|---|
| 59 | {
|
|---|
| 60 | // initialize the histogram for the distribution r vs E
|
|---|
| 61 | //
|
|---|
| 62 | // we set the energy range from 2 Gev to 20000 GeV (in log 4 orders
|
|---|
| 63 | // of magnitude) and for each order we take 25 subdivision --> 100 xbins
|
|---|
| 64 | //
|
|---|
| 65 | // we set the radius range from 0 m to 500 m with 10 m bin --> 50 ybins
|
|---|
| 66 | //
|
|---|
| 67 | fName = name ? name : "MHThreshold";
|
|---|
| 68 | fTitle = title ? title : "Collection Area vs. Energy/Theta";
|
|---|
| 69 |
|
|---|
| 70 | fHEnergy.SetName("Threshold");
|
|---|
| 71 | fHEnergy.SetTitle("Energy Thrshold");
|
|---|
| 72 | fHEnergy.SetXTitle("E [GeV]");
|
|---|
| 73 | fHEnergy.SetYTitle("dN/dE [GeV^{-1}]");
|
|---|
| 74 | fHEnergy.SetDirectory(NULL);
|
|---|
| 75 | fHEnergy.UseCurrentStyle();
|
|---|
| 76 |
|
|---|
| 77 | MBinning binse(80, 10, 1000000, "", "log");
|
|---|
| 78 | binse.Apply(fHEnergy);
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | Bool_t MHThreshold::SetupFill(const MParList *pl)
|
|---|
| 82 | {
|
|---|
| 83 | fMcEvt = (MMcEvt*)pl->FindObject("MMcEvt");
|
|---|
| 84 | if (!fMcEvt)
|
|---|
| 85 | {
|
|---|
| 86 | *fLog << err << "MMcEvt not found... abort." << endl;
|
|---|
| 87 | return kFALSE;
|
|---|
| 88 | }
|
|---|
| 89 | /*
|
|---|
| 90 | MBinning binse;
|
|---|
| 91 | binse.SetEdges(fHEnergy, 'x');
|
|---|
| 92 |
|
|---|
| 93 | MBinning *bins = (MBinning*)pl->FindObject("BinningEnergyEst", "MBinning");
|
|---|
| 94 | if (bins)
|
|---|
| 95 | binse.SetEdges(*bins);
|
|---|
| 96 |
|
|---|
| 97 | binse.Apply(fHEnergy);
|
|---|
| 98 | */
|
|---|
| 99 | return kTRUE;
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | void MHThreshold::Paint(Option_t *option)
|
|---|
| 103 | {
|
|---|
| 104 | const TAxis &axe = *fHEnergy.GetXaxis();
|
|---|
| 105 |
|
|---|
| 106 | const Int_t bin = fHEnergy.GetMaximumBin();
|
|---|
| 107 |
|
|---|
| 108 | // Assume that the energy binning is logarithmic
|
|---|
| 109 | const Axis_t maxe = TMath::Sqrt(axe.GetBinLowEdge(bin)*axe.GetBinUpEdge(bin));
|
|---|
| 110 |
|
|---|
| 111 | TLatex text(0.30, 0.95, Form("E_{max}=%dGeV", TMath::Nint(maxe)));
|
|---|
| 112 | text.SetBit(TLatex::kTextNDC);
|
|---|
| 113 | text.SetTextSize(0.04);
|
|---|
| 114 | text.Paint();
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | void MHThreshold::Draw(Option_t *option)
|
|---|
| 118 | {
|
|---|
| 119 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
|---|
| 120 |
|
|---|
| 121 | // Do the projection before painting the histograms into
|
|---|
| 122 | // the individual pads
|
|---|
| 123 | pad->SetBorderMode(0);
|
|---|
| 124 |
|
|---|
| 125 | gPad->SetLogx();
|
|---|
| 126 | gPad->SetLogy();
|
|---|
| 127 |
|
|---|
| 128 | fHEnergy.Draw();
|
|---|
| 129 |
|
|---|
| 130 | AppendPad();
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 | Bool_t MHThreshold::Fill(const MParContainer *par, const Stat_t weight)
|
|---|
| 134 | {
|
|---|
| 135 | const Double_t energy = fMcEvt->GetEnergy();
|
|---|
| 136 |
|
|---|
| 137 | fHEnergy.Fill(energy, weight/energy);
|
|---|
| 138 |
|
|---|
| 139 | return kTRUE;
|
|---|
| 140 | }
|
|---|