source: trunk/Mars/manalysis/MMakePadHistograms.cc@ 9875

Last change on this file since 9875 was 5722, checked in by moralejo, 20 years ago
*** empty log message ***
File size: 9.1 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): Wolfgang Wittek, 09/2004 <mailto:wittek@mppmu.mpg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MMakePadHistograms
28//
29// reads calibrated data of a particular type (ON, OFF or MC)
30// and produces the histograms for the padding
31//
32// these histograms are further treated in MPad
33//
34/////////////////////////////////////////////////////////////////////////////
35#include "MMakePadHistograms.h"
36
37#include <math.h>
38#include <stdio.h>
39
40#include <TH2.h>
41#include <TH3.h>
42#include <TCanvas.h>
43#include <TFile.h>
44
45#include "MBadPixelsCalc.h"
46#include "MBadPixelsTreat.h"
47#include "MContinue.h"
48#include "MEvtLoop.h"
49#include "MFillH.h"
50#include "MFSelBasic.h"
51#include "MGeomApply.h"
52#include "MHBadPixels.h"
53#include "MHSigmaTheta.h"
54#include "MLog.h"
55#include "MLogManip.h"
56#include "MParList.h"
57#include "MProgressBar.h"
58#include "MReadMarsFile.h"
59#include "MReadReports.h"
60#include "MTaskList.h"
61//#include "MExtrapolatePointingPos.h"
62#include "MPointingPosCalc.h"
63
64ClassImp(MMakePadHistograms);
65
66using namespace std;
67
68// --------------------------------------------------------------------------
69//
70// Default constructor.
71//
72MMakePadHistograms::MMakePadHistograms(const char *name, const char *title)
73{
74 fName = name ? name : "MMakePadHistograms";
75 fTitle = title ? title : "Class to make Pad histograms";
76
77 fHSigmaTheta = NULL;
78 fHSigmaThetaOuter = NULL;
79 fHDiffPixTheta = NULL;
80 fHSigmaPixTheta = NULL;
81
82 fHBadIdTheta = NULL;
83 fHBadNTheta = NULL;
84
85 // default values
86 fType = "";
87 fMaxEvents = -1;
88 fNamePedPhotCam = "MPedPhotCamFromData";
89 fNameInputFile = "";
90 fNameOutputFile = "";
91 fPedestalLevel = 3.0;
92 fUseInterpolation = kTRUE;
93 fProcessPedestal = kTRUE;
94 fProcessTime = kFALSE;
95}
96
97
98// --------------------------------------------------------------------------
99//
100// SetDataType.
101//
102// the type may be ON, OFF or MC
103//
104void MMakePadHistograms::SetDataType(const char *type)
105{
106 fType = type;
107}
108
109// --------------------------------------------------------------------------
110//
111// SetMaxEvents.
112//
113// set the maximum number of events to be read
114//
115void MMakePadHistograms::SetMaxEvents(Int_t maxev)
116{
117 fMaxEvents = maxev;
118}
119
120// --------------------------------------------------------------------------
121//
122// SetNameInputFile.
123//
124// the input file contains the calibrated data
125//
126void MMakePadHistograms::SetNameInputFile(const char *input)
127{
128 fNameInputFile = input;
129}
130
131// --------------------------------------------------------------------------
132//
133// SetNameOutputFile.
134//
135// the output file contains the histgrams for the padding
136//
137void MMakePadHistograms::SetNameOutputFile(const char *output)
138{
139 fNameOutputFile = output;
140}
141
142// --------------------------------------------------------------------------
143//
144// SetNamePedPhotCam.
145//
146// set the name of the MPedPhotCam container;
147// it is used in : MBadPixelsCalc, MBadPixelsTreat, MHSigmaTheta
148//
149void MMakePadHistograms::SetNamePedPhotCam(const char *name)
150{
151 fNamePedPhotCam = name;
152}
153
154// --------------------------------------------------------------------------
155//
156// SetPedestalLevel.
157//
158// set the pedestal level;
159// it is used in : MBadPixelsCalc
160//
161void MMakePadHistograms::SetPedestalLevel(Float_t pedlevel)
162{
163 fPedestalLevel = pedlevel;
164}
165
166// --------------------------------------------------------------------------
167//
168// SetUseInterpolation.
169//
170// set the option "UseInterpolation";
171// it is used in : MBadPixelsTreat
172//
173void MMakePadHistograms::SetUseInterpolation(Bool_t useinter)
174{
175 fUseInterpolation = useinter;
176}
177
178// --------------------------------------------------------------------------
179//
180// SetProcessPedestal.
181//
182// set the option "ProcessPedestal";
183// it is used in : MBadPixelsTreat
184//
185void MMakePadHistograms::SetProcessPedestal(Bool_t procped)
186{
187 fProcessPedestal = procped;
188}
189
190// --------------------------------------------------------------------------
191//
192// SetProcessTime.
193//
194// set the option "ProcessTime";
195// it is used in : MBadPixelsTreat
196//
197void MMakePadHistograms::SetProcessTime(Bool_t proctim)
198{
199 fProcessTime = proctim;
200}
201
202// --------------------------------------------------------------------------
203//
204//
205Bool_t MMakePadHistograms::MakeHistograms()
206{
207 if (fType == "")
208 {
209 *fLog << err << "MMakePadHistograms::MakeHistograms; type of input data is not defined"
210 << endl;
211 return kFALSE;
212 }
213
214 if (fNameInputFile == "")
215 {
216 *fLog << err << "MMakePadHistograms::MakeHistograms; name of input file is not defined"
217 << endl;
218 return kFALSE;
219 }
220
221 if (fNameOutputFile == "")
222 {
223 *fLog << err << "MMakePadHistograms::MakeHistograms; name of output file is not defined"
224 << endl;
225 return kFALSE;
226 }
227
228 *fLog << "------------" << endl;
229 *fLog << fType << " events :" << endl;
230 *fLog << "------------" << endl;
231 *fLog << "MMakePadHistograms : calibrated " << fType
232 << " data are read from file " << fNameInputFile << endl;
233
234
235 MTaskList tlist;
236 MParList plist;
237
238 MReadReports read;
239 read.AddTree("Drive");
240 read.AddTree("Events","MTime.",kTRUE);
241 static_cast<MRead&>(read).AddFile(fNameInputFile);
242
243 read.AddToBranchList("MReportDrive.*");
244 read.AddToBranchList("MRawEvtHeader.*");
245
246// MReadMarsFile read("Events", fNameInputFile);
247// read.DisableAutoScheme();
248
249
250 MGeomApply apply;
251
252// MExtrapolatePointingPos extraPointing(fNameInputFile);
253 MPointingPosCalc pointposcalc;
254
255 MBadPixelsCalc badcalc;
256 badcalc.SetNamePedPhotCam(fNamePedPhotCam);
257 badcalc.SetPedestalLevel(fPedestalLevel);
258
259 MBadPixelsTreat badtreat;
260 badtreat.SetNamePedPhotCam(fNamePedPhotCam);
261 badtreat.SetUseInterpolation(fUseInterpolation);
262 badtreat.SetProcessPedestal(fProcessPedestal);
263 badtreat.SetProcessTimes(fProcessTime);
264
265 MFSelBasic selbasic;
266 MContinue contbasic(&selbasic);
267 contbasic.SetName("SelBasic");
268
269 MHBadPixels bad("BadPixels");
270 bad.SetNamePedPhotCam(fNamePedPhotCam);
271 MFillH fillbad("BadPixels[MHBadPixels]", "MBadPixelsCam");
272 fillbad.SetName("FillBad");
273
274 MHSigmaTheta sigth("SigmaTheta");
275 sigth.SetNamePedPhotCam(fNamePedPhotCam);
276 MFillH fillsigtheta ("SigmaTheta[MHSigmaTheta]", "");
277 fillsigtheta.SetName("FillSigTheta");
278
279 //*****************************
280 // entries in MParList
281
282 plist.AddToList(&tlist);
283 plist.AddToList(&bad);
284 plist.AddToList(&sigth);
285
286 //*****************************
287 // entries in MTaskList
288
289 tlist.AddToList(&read);
290 tlist.AddToList(&apply);
291 tlist.AddToList(&pointposcalc, "Events");
292
293// tlist.AddToList(&badcalc); done in callisto
294// tlist.AddToList(&badtreat); done in callisto
295
296 tlist.AddToList(&contbasic, "Events");
297 tlist.AddToList(&fillbad, "Events");
298 tlist.AddToList(&fillsigtheta, "Events");
299 //*****************************
300
301 MProgressBar bar;
302 MEvtLoop evtloop;
303 evtloop.SetParList(&plist);
304 evtloop.SetProgressBar(&bar);
305
306 // if ( !evtloop.Eventloop(fMaxEvents) )
307 // return kFALSE;
308 evtloop.Eventloop(fMaxEvents);
309
310 tlist.PrintStatistics(0, kTRUE);
311
312 bad.DrawClone();
313 sigth.DrawClone();
314
315 // save the histograms for the padding
316 fHSigmaTheta = (TH2D*)sigth.GetSigmaTheta();
317 fHSigmaThetaOuter= (TH2D*)sigth.GetSigmaThetaOuter();
318 fHSigmaPixTheta = (TH3D*)sigth.GetSigmaPixTheta();
319 fHDiffPixTheta = (TH3D*)sigth.GetDiffPixTheta();
320
321 fHBadIdTheta = (TH2D*)bad.GetBadId();
322 fHBadNTheta = (TH2D*)bad.GetBadN();
323
324 TFile filewrite(fNameOutputFile, "RECREATE", "");
325 fHSigmaTheta->Write();
326 fHSigmaThetaOuter->Write();
327 //fHSigmaPixTheta->Write();
328 fHDiffPixTheta->Write();
329 //fHBadIdTheta->Write();
330 //fHBadNTheta->Write();
331 filewrite.Close();
332
333 *fLog << "" << endl;
334 *fLog << "MMakePadHistograms : padding plots for " << fType
335 << " data written onto file " << fNameOutputFile << endl;
336
337 return kTRUE;
338}
339
340// --------------------------------------------------------------------------
341
342
343
344
345
346
347
348
349
350
Note: See TracBrowser for help on using the repository browser.