| 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 | ! Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2002
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | // //
|
|---|
| 28 | // MHEffOnTimeTheta //
|
|---|
| 29 | // //
|
|---|
| 30 | // //
|
|---|
| 31 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 32 |
|
|---|
| 33 | #include "MHEffOnTimeTheta.h"
|
|---|
| 34 |
|
|---|
| 35 | #include <TF1.h>
|
|---|
| 36 | #include <TH2.h>
|
|---|
| 37 | #include <TCanvas.h>
|
|---|
| 38 |
|
|---|
| 39 | #include "MTime.h"
|
|---|
| 40 |
|
|---|
| 41 | #include "MBinning.h"
|
|---|
| 42 | #include "MParList.h"
|
|---|
| 43 |
|
|---|
| 44 | #include "MLog.h"
|
|---|
| 45 | #include "MLogManip.h"
|
|---|
| 46 |
|
|---|
| 47 | ClassImp(MHEffOnTimeTheta);
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 | // --------------------------------------------------------------------------
|
|---|
| 51 | //
|
|---|
| 52 | // Default Constructor. It sets name and title only. Typically you won't
|
|---|
| 53 | // need to change this.
|
|---|
| 54 | //
|
|---|
| 55 | MHEffOnTimeTheta::MHEffOnTimeTheta(const char *name, const char *title)
|
|---|
| 56 | : fHist()
|
|---|
| 57 | {
|
|---|
| 58 | //
|
|---|
| 59 | // set the name and title of this object
|
|---|
| 60 | //
|
|---|
| 61 | fName = name ? name : "MHEffOnTimeTheta";
|
|---|
| 62 | fTitle = title ? title : "1-D histogram of Eff On Time";
|
|---|
| 63 |
|
|---|
| 64 | fHist.SetName("EffOn");
|
|---|
| 65 | fHist.SetTitle("Effective On Time Vs. Theta");
|
|---|
| 66 |
|
|---|
| 67 | fHist.SetDirectory(NULL);
|
|---|
| 68 |
|
|---|
| 69 | fHist.SetXTitle("t_{eff} [s]");
|
|---|
| 70 | fHist.SetYTitle("\\Theta [\\circ]");
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | void MHEffOnTimeTheta::Calc(TH2D *hist)
|
|---|
| 74 | {
|
|---|
| 75 | const Int_t nbins = hist->GetNbinsY();
|
|---|
| 76 |
|
|---|
| 77 | for (int i=1; i<nbins; i++)
|
|---|
| 78 | {
|
|---|
| 79 | //char txt[100];
|
|---|
| 80 | //sprintf(txt, "Name%d", 100*i);
|
|---|
| 81 | //new TCanvas(txt, "Title");
|
|---|
| 82 |
|
|---|
| 83 | TH1D &h = *hist->ProjectionX("dTime-Distribution for fixed Time", i, i);
|
|---|
| 84 |
|
|---|
| 85 | //hist->Draw();
|
|---|
| 86 | //gPad->SetLogy();
|
|---|
| 87 |
|
|---|
| 88 | Double_t Nmdel = h.Integral("width");
|
|---|
| 89 | Double_t mean = h.GetMean();
|
|---|
| 90 |
|
|---|
| 91 | TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)",
|
|---|
| 92 | mean, hist->GetXaxis()->GetXmax());
|
|---|
| 93 |
|
|---|
| 94 | func.SetParameter(0, 100); // [Hz]
|
|---|
| 95 | func.SetParameter(1, Nmdel);
|
|---|
| 96 |
|
|---|
| 97 | func.SetParLimits(0, 0, 1000); // [Hz]
|
|---|
| 98 | func.SetParLimits(1, 0, 2*Nmdel);
|
|---|
| 99 |
|
|---|
| 100 | func.SetParName(0, "lambda");
|
|---|
| 101 | func.SetParName(1, "Nmdel");
|
|---|
| 102 |
|
|---|
| 103 | h.Fit("Poisson", "RN");
|
|---|
| 104 |
|
|---|
| 105 | //func.SetRange(0, 0.1); // Range of Drawing
|
|---|
| 106 | //func.DrawCopy("same");
|
|---|
| 107 |
|
|---|
| 108 | //cout << func.GetParameter(0) << " " << func.GetParameter(1) << endl;
|
|---|
| 109 |
|
|---|
| 110 | Double_t lambda = func.GetParameter(0);
|
|---|
| 111 | //Double_t a = func.GetParameter(1);
|
|---|
| 112 |
|
|---|
| 113 | //cout << "t_eff = " << h->Integral()/lambda << " T(last)=" << time.GetTimeLo()*0.0001 << endl;
|
|---|
| 114 |
|
|---|
| 115 | fHist.SetBinContent(i, h.Integral()/lambda);
|
|---|
| 116 |
|
|---|
| 117 | delete &h;
|
|---|
| 118 | }
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | Bool_t MHEffOnTimeTheta::SetupFill(const MParList *plist)
|
|---|
| 122 | {
|
|---|
| 123 | const MBinning* bins = (MBinning*)plist->FindObject("BinningTheta");
|
|---|
| 124 | if (!bins)
|
|---|
| 125 | {
|
|---|
| 126 | *fLog << err << dbginf << "BinningTheta [MBinning] not found... aborting." << endl;
|
|---|
| 127 | return kFALSE;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | SetBinning(&fHist, bins);
|
|---|
| 131 |
|
|---|
| 132 | return kTRUE;
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | TObject *MHEffOnTimeTheta::DrawClone(Option_t *opt) const
|
|---|
| 136 | {
|
|---|
| 137 | TCanvas *c = MakeDefCanvas("EffOnTimeTheta", "t_eff vs. Theta");
|
|---|
| 138 |
|
|---|
| 139 | gROOT->SetSelectedPad(NULL);
|
|---|
| 140 |
|
|---|
| 141 | ((TH2&)fHist).DrawCopy(opt);
|
|---|
| 142 |
|
|---|
| 143 | c->Modified();
|
|---|
| 144 | c->Update();
|
|---|
| 145 |
|
|---|
| 146 | return c;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | void MHEffOnTimeTheta::Draw(Option_t *opt)
|
|---|
| 150 | {
|
|---|
| 151 | if (!gPad)
|
|---|
| 152 | MakeDefCanvas("EffOnTimeTheta", "t_eff vs. Theta");
|
|---|
| 153 |
|
|---|
| 154 | fHist.Draw(opt);
|
|---|
| 155 |
|
|---|
| 156 | gPad->Modified();
|
|---|
| 157 | gPad->Update();
|
|---|
| 158 | }
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 | Bool_t MHEffOnTimeTheta::Fill(const MParContainer *par)
|
|---|
| 162 | {
|
|---|
| 163 | return kTRUE;
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|