source: trunk/MagicSoft/Mars/mhist/MHSigmaPixel.cc@ 2043

Last change on this file since 2043 was 2043, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 3.8 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): Robert Wagner 10/2002 <mailto:magicsoft@rwagner.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26// //
27// MHSigmaPixel //
28// //
29// 2D-Histogram pedestal sigma vs pixel number //
30// //
31//////////////////////////////////////////////////////////////////////////////
32
33#include "MHSigmaPixel.h"
34
35#include <TCanvas.h>
36
37#include <math.h>
38
39#include "MPedestalCam.h"
40#include "MPedestalPix.h"
41#include "MSigmabar.h"
42
43#include "MBinning.h"
44#include "MParList.h"
45
46#include "MLog.h"
47#include "MLogManip.h"
48
49ClassImp(MHSigmaPixel);
50
51// --------------------------------------------------------------------------
52//
53// Default Constructor. It sets name and title of the histogram.
54//
55MHSigmaPixel::MHSigmaPixel(const char *name, const char *title)
56{
57 //
58 // set the name and title of this object
59 //
60 fName = name ? name : "MHSigmaPixel";
61 fTitle = title ? title : "2-D histogram in sigma and pixel";
62
63 fHist.SetDirectory(NULL);
64
65 fHist.SetTitle("Sigma vs pixel #");
66 fHist.SetXTitle("pixel #");
67 fHist.SetYTitle("\\sigma");
68 fHist.SetZTitle("N");
69}
70
71// --------------------------------------------------------------------------
72//
73// Set binnings and prepare filling of the histogram. The binning for the
74// pixel axis is derived automagically from the MPedestalCam container
75// expected to be found in the MParList *plist.
76//
77Bool_t MHSigmaPixel::SetupFill(const MParList *plist)
78{
79 fPedestalCam = (MPedestalCam*)plist->FindObject("MPedestalCam");
80 if (!fPedestalCam)
81 {
82 *fLog << err << "MPedestalCam not found... aborting." << endl;
83 return kFALSE;
84 }
85
86 MBinning* binssigma = (MBinning*)plist->FindObject("BinningSigma");
87 if (!binssigma)
88 {
89 *fLog << err << "BinningSigma [MBinning] not found... aborting." << endl;
90 return kFALSE;
91 }
92
93 const Int_t n = fPedestalCam->GetSize();
94
95 MBinning binspixel;
96 binspixel.SetEdges(n, -0.5, -0.5+n);
97
98 SetBinning(&fHist, &binspixel, binssigma);
99
100 fHist.Sumw2();
101
102 return kTRUE;
103}
104
105// --------------------------------------------------------------------------
106//
107// Fill the histogram
108//
109Bool_t MHSigmaPixel::Fill(const MParContainer *par, const Stat_t w)
110{
111 const MPedestalCam &ped = *(MPedestalCam*)par;
112 for (Int_t i=0;i<(ped.GetSize());i++)
113 {
114 const MPedestalPix pix = ped[i];
115 fHist.Fill(i, pix.GetSigma());
116 }
117 return kTRUE;
118}
119
120// --------------------------------------------------------------------------
121//
122// Draw the histogram
123//
124void MHSigmaPixel::Draw(Option_t *opt)
125{
126 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
127 pad->SetBorderMode(0);
128
129 AppendPad("");
130
131 fHist.Draw(opt);
132
133 gPad->Modified();
134 gPad->Update();
135}
136
Note: See TracBrowser for help on using the repository browser.