source: trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc@ 2937

Last change on this file since 2937 was 2937, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.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): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MPedestalCam //
28// //
29// Hold the Pedestal information for all pixels in the camera //
30// //
31/////////////////////////////////////////////////////////////////////////////
32#include "MPedestalCam.h"
33#include "MPedestalPix.h"
34
35#include <TClonesArray.h>
36
37#include "MLog.h"
38#include "MLogManip.h"
39
40#include "MGeomCam.h"
41
42ClassImp(MPedestalCam);
43
44using namespace std;
45
46// --------------------------------------------------------------------------
47//
48// Default constructor. Creates a MPedestalPix object for each pixel
49//
50MPedestalCam::MPedestalCam(const char *name, const char *title)
51{
52 fName = name ? name : "MPedestalCam";
53 fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
54
55 fArray = new TClonesArray("MPedestalPix", 1);
56
57}
58
59// --------------------------------------------------------------------------
60//
61// Delete the array conatining the pixel pedest information
62//
63MPedestalCam::~MPedestalCam()
64{
65 delete fArray;
66}
67
68// --------------------------------------------------------------------------
69//
70// Set the size of the camera
71//
72void MPedestalCam::InitSize(const UInt_t i)
73{
74 fArray->ExpandCreate(i);
75}
76
77// --------------------------------------------------------------------------
78//
79// Check if position i is inside bounds
80//
81Bool_t MPedestalCam::CheckBounds(Int_t i) const
82{
83 return i < GetSize();
84}
85
86// --------------------------------------------------------------------------
87//
88// This function returns the current size of the TClonesArray
89// independently if the MPedestalPix is filled with values or not.
90//
91// Get the size of the MPedestalCam
92//
93Int_t MPedestalCam::GetSize() const
94{
95 return fArray->GetEntriesFast();
96}
97
98// --------------------------------------------------------------------------
99//
100// Get i-th pixel (pixel number)
101//
102MPedestalPix &MPedestalCam::operator[](Int_t i)
103{
104 return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
105}
106
107// --------------------------------------------------------------------------
108//
109// Get i-th pixel (pixel number)
110//
111MPedestalPix &MPedestalCam::operator[](Int_t i) const
112{
113 return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
114}
115
116void MPedestalCam::Clear(Option_t *o)
117{
118 fArray->ForEach(TObject, Clear)();
119}
120
121void MPedestalCam::Print(Option_t *o) const
122{
123 *fLog << all << GetDescriptor() << ":" << endl;
124 int id = 0;
125
126 TIter Next(fArray);
127 MPedestalPix *pix;
128 while ((pix=(MPedestalPix*)Next()))
129 {
130 id++;
131
132 if (!pix->IsValid())
133 continue;
134
135 *fLog << id-1 << ": ";
136 *fLog << pix->GetPedestal() << " " << pix->GetPedestalRms() << endl;
137 }
138}
139
140Float_t MPedestalCam::GetPedestalMin(const MGeomCam *geom) const
141{
142 if (fArray->GetEntries() <= 0)
143 return 50.;
144
145 Float_t minval = (*this)[0].GetPedestalRms();
146
147 for (Int_t i=1; i<fArray->GetEntries(); i++)
148 {
149 const MPedestalPix &pix = (*this)[i];
150
151 Float_t testval = pix.GetPedestalRms();
152
153 if (geom)
154 testval *= geom->GetPixRatio(i);
155
156 if (testval < minval)
157 minval = testval;
158 }
159 return minval;
160}
161
162Float_t MPedestalCam::GetPedestalMax(const MGeomCam *geom) const
163{
164 if (fArray->GetEntries() <= 0)
165 return 50.;
166
167 Float_t maxval = (*this)[0].GetPedestalRms();
168
169 for (Int_t i=1; i<fArray->GetEntries(); i++)
170 {
171 const MPedestalPix &pix = (*this)[i];
172
173 Float_t testval = pix.GetPedestalRms();
174
175 if (geom)
176 testval *= geom->GetPixRatio(i);
177
178 if (testval > maxval)
179 maxval = testval;
180 }
181 return maxval;
182}
183
184Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
185{
186 switch (type)
187 {
188 case 0:
189 val = (*this)[idx].GetPedestal();
190 break;
191 case 1:
192 val = (*this)[idx].GetPedestalRms();
193 break;
194 default:
195 return kFALSE;
196 }
197 return val>=0;
198}
199
200void MPedestalCam::DrawPixelContent(Int_t num) const
201{
202 *fLog << warn << "MPedestalCam::DrawPixelContent - not available." << endl;
203}
Note: See TracBrowser for help on using the repository browser.