source: trunk/MagicSoft/Mars/mhist/MHEffOnTimeTime.cc@ 1285

Last change on this file since 1285 was 1265, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.4 KB
Line 
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// MHEffOnTimeTime //
29// //
30// //
31//////////////////////////////////////////////////////////////////////////////
32
33#include "MHEffOnTimeTime.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
47ClassImp(MHEffOnTimeTime);
48
49
50// --------------------------------------------------------------------------
51//
52// Default Constructor. It sets name and title only. Typically you won't
53// need to change this.
54//
55MHEffOnTimeTime::MHEffOnTimeTime(const char *name, const char *title)
56 : fHist()
57{
58 //
59 // set the name and title of this object
60 //
61 fName = name ? name : "MHEffOnTimeTime";
62 fTitle = title ? title : "1-D histogram of Eff On Time";
63
64 fHist.SetName("EffOn");
65 fHist.SetTitle("Effective On Time Vs. Time");
66
67
68 fHist.SetDirectory(NULL);
69
70 fHist.SetXTitle("t_{eff} [s]");
71 fHist.SetYTitle("t [s]");
72}
73
74TObject *MHEffOnTimeTime::DrawClone(Option_t *opt) const
75{
76 TCanvas *c = MakeDefCanvas("EffOnTimeTime", "t_eff vs. t");
77
78 gROOT->SetSelectedPad(NULL);
79
80 ((TH2&)fHist).DrawCopy(opt);
81
82 c->Modified();
83 c->Update();
84
85 return c;
86}
87
88void MHEffOnTimeTime::Draw(Option_t *opt)
89{
90 if (!gPad)
91 MakeDefCanvas("EffOnTimeTime", "t_eff vs. t");
92
93 fHist.Draw(opt);
94
95 gPad->Modified();
96 gPad->Update();
97}
98
99
100void MHEffOnTimeTime::Calc(TH2D *hist)
101{
102 const Int_t nbins = hist->GetNbinsY();
103
104 for (int i=1; i<nbins; i++)
105 {
106 //char txt[100];
107 //sprintf(txt, "Name%d", 100*i);
108 //new TCanvas(txt, "Title");
109
110 TH1D &h = *hist->ProjectionX("dTime-Distribution for fixed Theta", i, i);
111
112 //hist->Draw();
113 //gPad->SetLogy();
114
115 Double_t Nmdel = h.Integral("width");
116 Double_t mean = h.GetMean();
117
118 TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)",
119 mean, hist->GetXaxis()->GetXmax());
120
121 func.SetParameter(0, 100); // [Hz]
122 func.SetParameter(1, Nmdel);
123
124 func.SetParLimits(0, 0, 1000); // [Hz]
125 func.SetParLimits(1, 0, 2*Nmdel);
126
127 func.SetParName(0, "lambda");
128 func.SetParName(1, "Nmdel");
129
130 h.Fit("Poisson", "RN");
131
132 //func.SetRange(0, 0.1); // Range of Drawing
133 //func.DrawCopy("same");
134
135 //cout << func.GetParameter(0) << " " << func.GetParameter(1) << endl;
136
137 Double_t lambda = func.GetParameter(0);
138 //Double_t a = func.GetParameter(1);
139
140 //cout << "t_eff = " << h->Integral()/lambda << " T(last)=" << time.GetTimeLo()*0.0001 << endl;
141
142 fHist.SetBinContent(i, h.Integral()/lambda);
143
144 delete &h;
145 }
146}
147
148Bool_t MHEffOnTimeTime::SetupFill(const MParList *plist)
149{
150 const MBinning* binstime = (MBinning*)plist->FindObject("BinningTime");
151 if (!binstime)
152 {
153 *fLog << err << dbginf << "BinningTime [MBinning] not found... aborting." << endl;
154 return kFALSE;
155 }
156
157 SetBinning(&fHist, binstime);
158
159 return kTRUE;
160}
161
162Bool_t MHEffOnTimeTime::Fill(const MParContainer *par)
163{
164 return kTRUE;
165}
166
Note: See TracBrowser for help on using the repository browser.