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

Last change on this file since 3450 was 2239, checked in by moralejo, 21 years ago
*** empty log message ***
File size: 3.9 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
51using namespace std;
52
53// --------------------------------------------------------------------------
54//
55// Default Constructor. It sets name and title of the histogram.
56//
57MHSigmaPixel::MHSigmaPixel(const char *name, const char *title)
58{
59 //
60 // set the name and title of this object
61 //
62 fName = name ? name : "MHSigmaPixel";
63 fTitle = title ? title : "2-D histogram in sigma and pixel";
64
65 fHist.SetDirectory(NULL);
66
67 fHist.SetTitle("Sigma vs pixel #");
68 fHist.SetXTitle("pixel #");
69 fHist.SetYTitle("\\sigma");
70 fHist.SetZTitle("N");
71}
72
73// --------------------------------------------------------------------------
74//
75// Set binnings and prepare filling of the histogram. The binning for the
76// pixel axis is derived automagically from the MPedestalCam container
77// expected to be found in the MParList *plist.
78//
79Bool_t MHSigmaPixel::SetupFill(const MParList *plist)
80{
81 fPedestalCam = (MPedestalCam*)plist->FindObject("MPedestalCam");
82 if (!fPedestalCam)
83 {
84 *fLog << err << "MPedestalCam not found... aborting." << endl;
85 return kFALSE;
86 }
87
88 MBinning* binssigma = (MBinning*)plist->FindObject("BinningSigma");
89 if (!binssigma)
90 {
91 *fLog << err << "BinningSigma [MBinning] not found... aborting." << endl;
92 return kFALSE;
93 }
94
95 const Int_t n = fPedestalCam->GetSize();
96
97 MBinning binspixel;
98 binspixel.SetEdges(n, -0.5, -0.5+n);
99
100 SetBinning(&fHist, &binspixel, binssigma);
101
102 fHist.Sumw2();
103
104 return kTRUE;
105}
106
107// --------------------------------------------------------------------------
108//
109// Fill the histogram
110//
111Bool_t MHSigmaPixel::Fill(const MParContainer *par, const Stat_t w)
112{
113 const MPedestalCam &ped = *(MPedestalCam*)par;
114 for (Int_t i=0;i<(ped.GetSize());i++)
115 {
116 const MPedestalPix pix = ped[i];
117 fHist.Fill(i, pix.GetPedestalRms());
118 }
119 return kTRUE;
120}
121
122// --------------------------------------------------------------------------
123//
124// Draw the histogram
125//
126void MHSigmaPixel::Draw(Option_t *opt)
127{
128 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
129 pad->SetBorderMode(0);
130
131 AppendPad("");
132
133 fHist.Draw(opt);
134
135 gPad->Modified();
136 gPad->Update();
137}
138
Note: See TracBrowser for help on using the repository browser.