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

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