source: branches/removing_cpp11_features/mhflux/MHThetaSq.cc@ 18292

Last change on this file since 18292 was 14906, checked in by tbretz, 12 years ago
Reverting to last revision.
File size: 6.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, 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 // Apply binning
133 binsa.Apply(fHistTime);
134 MH::SetBinning(fHist, binst, binse, binsa);
135
136 // Remark: Binnings might be overwritten in MHAlpha::SetupFill
137 return MHAlpha::SetupFill(pl);
138}
139
140// --------------------------------------------------------------------------
141//
142// Store the pointer to the parameter container storing the plotted value
143// (here ThetaSq) in fParameter.
144//
145// return whether it was found or not.
146//
147Bool_t MHThetaSq::GetParameter(const MParList &pl)
148{
149 fParameter = (MParContainer*)pl.FindObject(fNameParameter, "MParameterD");
150 if (fParameter)
151 return kTRUE;
152
153 *fLog << err << fNameParameter << " [MParameterD] not found... abort." << endl;
154 return kFALSE;
155}
156
157// --------------------------------------------------------------------------
158//
159// Return the value from fParemeter which should be filled into the plots
160//
161Double_t MHThetaSq::GetVal() const
162{
163 return static_cast<const MParameterD*>(fParameter)->GetVal();
164}
165
166// --------------------------------------------------------------------------
167//
168// You can use this function if you want to use a MHMatrix instead of
169// MMcEvt. This function adds all necessary columns to the
170// given matrix. Afterward you should fill the matrix with the corresponding
171// data (eg from a file by using MHMatrix::Fill). If you now loop
172// through the matrix (eg using MMatrixLoop) MHHadronness::Fill
173// will take the values from the matrix instead of the containers.
174//
175// It takes fSkipHist* into account!
176//
177void MHThetaSq::InitMapping(MHMatrix *mat, Int_t type)
178{
179 if (fMatrix)
180 return;
181
182 fMatrix = mat;
183
184 fMap[0] = -1;
185 fMap[1] = -1;
186 fMap[2] = -1;
187 fMap[3] = -1;
188 fMap[4] = -1;
189
190 if (!fSkipHistEnergy)
191 {
192 fMap[1] = type==0 ? fMatrix->AddColumn("MEnergyEst.fVal") : -1;
193 fMap[2] = type==0 ? -1 : fMatrix->AddColumn("MHillas.fSize");
194 }
195
196 if (!fSkipHistTheta)
197 fMap[3] = fMatrix->AddColumn("MPointingPos.fZd");
198
199 // if (!fSkipHistTime)
200 // fMap[4] = fMatrix->AddColumn("MTime.GetAxisTime");
201}
202
203Int_t MHThetaSq::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
204{
205 Int_t rc = MHAlpha::ReadEnv(env, prefix, print);
206 if (rc==kERROR)
207 return kERROR;
208
209 if (IsEnvDefined(env, prefix, "NumBinsSignal", print))
210 {
211 SetNumBinsSignal(GetEnvValue(env, prefix, "NumBinsSignal", (Int_t)fNumBinsSignal));
212 rc = kTRUE;
213 }
214 if (IsEnvDefined(env, prefix, "NumBinsTotal", print))
215 {
216 SetNumBinsTotal(GetEnvValue(env, prefix, "NumBinsTotal", (Int_t)fNumBinsTotal));
217 rc = kTRUE;
218 }
219 return rc;
220}
Note: See TracBrowser for help on using the repository browser.