source: trunk/MagicSoft/Mars/mhist/MHFadcPix.cc@ 2029

Last change on this file since 2029 was 1652, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.5 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 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
19! Author(s): Harald Kornmayer 1/2001
20!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25
26///////////////////////////////////////////////////////////////////////
27//
28// MHFadcPix
29//
30// This container stores a histogram to display an Fadc Spektrum.
31// The spektrum of all the values measured by the Fadcs.
32//
33///////////////////////////////////////////////////////////////////////
34#include "MHFadcPix.h"
35
36#include <TPad.h>
37
38#include "MH.h"
39#include "MBinning.h"
40
41#include "MRawEvtData.h"
42#include "MRawEvtPixelIter.h"
43
44ClassImp(MHFadcPix);
45
46// --------------------------------------------------------------------------
47//
48// Creates the histograms for lo and hi gain of one pixel
49//
50MHFadcPix::MHFadcPix(UInt_t pixid, Type_t t)
51 : fPixId(pixid), fType(t)
52{
53 fHistHi.SetName(pixid ? Form("HiGain%03d", pixid) : "HiGain");
54 fHistHi.SetTitle(pixid ? Form("Hi Gain Pixel #%d", pixid) : "Hi Gain Samples");
55 fHistHi.SetDirectory(NULL);
56
57 fHistLo.SetName(pixid ? Form("LoGain%03d", pixid) : "LoGain");
58 fHistLo.SetTitle(pixid ? Form("Lo Gain Pixel #%d", pixid) : "Lo Gain Samples");
59 fHistLo.SetDirectory(NULL);
60
61 if (fType==kValue)
62 {
63 fHistHi.SetXTitle("Signal/FADC Units");
64 fHistLo.SetXTitle("Signal/FADC Units");
65 fHistHi.SetYTitle("Count");
66 fHistLo.SetYTitle("Count");
67
68 MBinning bins;
69 bins.SetEdges(255, -.5, 255.5);
70
71 bins.Apply(fHistHi);
72 bins.Apply(fHistLo);
73 }
74 else
75 {
76 fHistHi.SetXTitle("Time/FADC Slices");
77 fHistLo.SetXTitle("Time/FADC Slices");
78 fHistLo.SetYTitle("Sum Signal/FADC Units");
79 fHistHi.SetYTitle("Sum Signal/FADC Units");
80 }
81}
82
83void MHFadcPix::Init(Byte_t nhi, Byte_t nlo)
84{
85 MBinning bins;
86
87 bins.SetEdges(nhi, -.5, -.5+nhi);
88 bins.Apply(fHistHi);
89
90 bins.SetEdges(nlo, -.5, -.5+nlo);
91 bins.Apply(fHistLo);
92}
93
94Bool_t MHFadcPix::Fill(const MRawEvtData &evt)
95{
96 MRawEvtPixelIter pixel((MRawEvtData*)&evt);
97
98 if (!pixel.Jump(fPixId))
99 return kTRUE;
100
101 const Int_t nhisamples = evt.GetNumHiGainSamples();
102
103 if (fType==kValue)
104 for (Int_t i=0; i<nhisamples; i++)
105 fHistHi.Fill(pixel.GetHiGainSamples()[i]);
106 else
107 for (Int_t i=0; i<nhisamples; i++)
108 fHistHi.Fill(i, pixel.GetHiGainSamples()[i]);
109
110 if (!pixel.HasLoGain())
111 return kTRUE;
112
113 const Int_t nlosamples = evt.GetNumLoGainSamples();
114
115 if (fType==kValue)
116 for (Int_t i=0; i<nlosamples; i++)
117 fHistLo.Fill(pixel.GetLoGainSamples()[i]);
118 else
119 for (Int_t i=0; i<nlosamples; i++)
120 fHistLo.Fill(i, pixel.GetLoGainSamples()[i]);
121
122 return kTRUE;
123}
124
125// --------------------------------------------------------------------------
126void MHFadcPix::DrawHi()
127{
128 fHistHi.Draw();
129}
130
131// --------------------------------------------------------------------------
132void MHFadcPix::DrawLo()
133{
134 fHistLo.Draw();
135}
136
137// --------------------------------------------------------------------------
138//
139// We need our own clone function to get rid of the histogram in any
140// directory
141//
142TObject *MHFadcPix::Clone(const char *) const
143{
144 MHFadcPix &pix = *(MHFadcPix*)TObject::Clone();
145
146 pix.fHistHi.SetDirectory(NULL);
147 pix.fHistLo.SetDirectory(NULL);
148
149 return &pix;
150}
151
152// --------------------------------------------------------------------------
153void MHFadcPix::Draw(Option_t *)
154{
155 if (!gPad)
156 {
157 const char *name = StrDup(fPixId ? Form("Pixel #%d", fPixId) : "Pixel");
158 MH::MakeDefCanvas(name, fPixId ? Form("%s FADC Samples", name) : "FADC Samples");
159 delete [] name;
160 }
161
162 gPad->Divide(1, 2);
163
164 gPad->cd(1);
165 fHistHi.Draw();
166
167 gPad->cd(2);
168 fHistLo.Draw();
169}
Note: See TracBrowser for help on using the repository browser.