source: trunk/Mars/mhflux/MHThetaSq.cc@ 14905

Last change on this file since 14905 was 14896, checked in by tbretz, 13 years ago
Added MCalibrateFact and MCalibrateDrsTimes
File size: 6.5 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, 5/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2005
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MHThetaSq
28//
29// This is a MHAlpha using "ThetaSquared [MParameterD]" as 'alpha'
30//
31// The default binning is determined from the integration range set in
32// MAlphaFitter.
33//
34// For more detailes see MHAlpha.
35//
36// Version 2:
37// ---------
38// + UInt_t fNumBinsSignal;
39// + UInt_t fNumBinsTotal;
40//
41//////////////////////////////////////////////////////////////////////////////
42#include "MHThetaSq.h"
43
44#include "MParameters.h"
45#include "MHMatrix.h"
46
47#include "MBinning.h"
48#include "MParList.h"
49#include "MTaskList.h"
50#include "MParameters.h"
51
52#include "MLog.h"
53#include "MLogManip.h"
54
55ClassImp(MHThetaSq);
56
57using namespace std;
58
59// --------------------------------------------------------------------------
60//
61// Default Constructor
62//
63MHThetaSq::MHThetaSq(const char *name, const char *title)
64 : MHAlpha(name, title), fNumBinsSignal(3), fNumBinsTotal(75)
65{
66 //
67 // set the name and title of this object
68 //
69 fName = name ? name : "MHThetaSq";
70 fTitle = title ? title : "Theta Squared plot";
71
72 fNameParameter = "ThetaSquared";
73
74 fHist.SetName("Theta");
75 fHist.SetTitle("Theta");
76 fHist.SetZTitle("\\vartheta^{2} [deg^{2}]");
77 fHist.SetDirectory(NULL);
78
79 // Main histogram
80 fHistTime.SetName("Theta");
81 fHistTime.SetXTitle("\\vartheta^{2} [deg^{2}]");
82 fHistTime.SetDirectory(NULL);
83
84 //fHistTime.SetYTitle("\\theta^{2] [deg^{2}]");
85 /*
86 TArrayD arr(50);
87 for (int i=1; i<50; i++)
88 arr[i] = sqrt((arr[i-1]+1)*(arr[i-1]+1) + 1.1)-1;
89 */
90 MBinning binsa, binse, binst;
91 binsa.SetEdges(75, 0, 1.5);
92 //binsa.SetEdges(arr);
93 binse.SetEdgesLog(15, 10, 100000);
94 binst.SetEdgesASin(67, -0.005, 0.665);
95 binsa.Apply(fHistTime);
96
97 MH::SetBinning(fHist, binst, binse, binsa);
98}
99
100// --------------------------------------------------------------------------
101//
102// Overwrites the binning in Alpha (ThetaSq) with a binning for which
103// the upper edge of the 5th bin (bin=5) fit the signal integration window.
104// In total 75 bins are setup.
105//
106// In case of fOffData!=NULL the binnings are taken later from fOffData anyhow.
107//
108Bool_t MHThetaSq::SetupFill(const MParList *pl)
109{
110 // Default is from default fitter
111 // if a user defined fitter is in the parlist: use this range
112 MAlphaFitter *fit = (MAlphaFitter*)pl->FindObject("MAlphaFitter");
113 if (!fit)
114 fit = &fFit;
115
116 MParameterD *cut = (MParameterD*)pl->FindObject("ThetaSquaredCut", "MParameterD");
117 if (cut)
118 fit->SetSignalIntegralMax(cut->GetVal());
119
120 // Get Histogram binnings
121 MBinning binst, binse;
122 binst.SetEdges(fHist, 'x');
123 binse.SetEdges(fHist, 'y');
124
125 // Calculate bining which fits alpha-cut
126 const Double_t intmax = fit->GetSignalIntegralMax();
127 const UInt_t nbins = fNumBinsTotal;
128 const UInt_t nsig = fNumBinsSignal;
129
130 MBinning binsa(nbins, 0, nbins*intmax/nsig);
131
132 gLog << inf << "Theta-cut set to " << intmax << "deg" << endl;
133
134 // Apply binning
135 binsa.Apply(fHistTime);
136 MH::SetBinning(fHist, binst, binse, binsa);
137
138 // Remark: Binnings might be overwritten in MHAlpha::SetupFill
139 return MHAlpha::SetupFill(pl);
140}
141
142// --------------------------------------------------------------------------
143//
144// Store the pointer to the parameter container storing the plotted value
145// (here ThetaSq) in fParameter.
146//
147// return whether it was found or not.
148//
149Bool_t MHThetaSq::GetParameter(const MParList &pl)
150{
151 fParameter = (MParContainer*)pl.FindObject(fNameParameter, "MParameterD");
152 if (fParameter)
153 return kTRUE;
154
155 *fLog << err << fNameParameter << " [MParameterD] not found... abort." << endl;
156 return kFALSE;
157}
158
159// --------------------------------------------------------------------------
160//
161// Return the value from fParemeter which should be filled into the plots
162//
163Double_t MHThetaSq::GetVal() const
164{
165 return static_cast<const MParameterD*>(fParameter)->GetVal();
166}
167
168// --------------------------------------------------------------------------
169//
170// You can use this function if you want to use a MHMatrix instead of
171// MMcEvt. This function adds all necessary columns to the
172// given matrix. Afterward you should fill the matrix with the corresponding
173// data (eg from a file by using MHMatrix::Fill). If you now loop
174// through the matrix (eg using MMatrixLoop) MHHadronness::Fill
175// will take the values from the matrix instead of the containers.
176//
177// It takes fSkipHist* into account!
178//
179void MHThetaSq::InitMapping(MHMatrix *mat, Int_t type)
180{
181 return MHAlpha::InitMapping(mat, type);
182
183 if (fMatrix)
184 return;
185
186 fMatrix = mat;
187
188 fMap[0] = -1;
189 fMap[1] = -1;
190 fMap[2] = -1;
191 fMap[3] = -1;
192 fMap[4] = -1;
193
194 if (!fSkipHistEnergy)
195 {
196 fMap[1] = type==0 ? fMatrix->AddColumn("MEnergyEst.fVal") : -1;
197 fMap[2] = type==0 ? -1 : fMatrix->AddColumn("MHillas.fSize");
198 }
199
200 if (!fSkipHistTheta)
201 fMap[3] = fMatrix->AddColumn("MPointingPos.fZd");
202
203 // if (!fSkipHistTime)
204 // fMap[4] = fMatrix->AddColumn("MTime.GetAxisTime");
205}
206
207Int_t MHThetaSq::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
208{
209 Int_t rc = MHAlpha::ReadEnv(env, prefix, print);
210 if (rc==kERROR)
211 return kERROR;
212
213 if (IsEnvDefined(env, prefix, "NumBinsSignal", print))
214 {
215 SetNumBinsSignal(GetEnvValue(env, prefix, "NumBinsSignal", (Int_t)fNumBinsSignal));
216 rc = kTRUE;
217 }
218 if (IsEnvDefined(env, prefix, "NumBinsTotal", print))
219 {
220 SetNumBinsTotal(GetEnvValue(env, prefix, "NumBinsTotal", (Int_t)fNumBinsTotal));
221 rc = kTRUE;
222 }
223 return rc;
224}
Note: See TracBrowser for help on using the repository browser.