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

Last change on this file since 2942 was 2942, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.1 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// This function returns the current size of the TClonesArray
80// independently if the MPedestalPix is filled with values or not.
81//
82// Get the size of the MPedestalCam
83//
84Int_t MPedestalCam::GetSize() const
85{
86 return fArray->GetEntriesFast();
87}
88
89// --------------------------------------------------------------------------
90//
91// Get i-th pixel (pixel number)
92//
93MPedestalPix &MPedestalCam::operator[](Int_t i)
94{
95 return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
96}
97
98// --------------------------------------------------------------------------
99//
100// Get i-th pixel (pixel number)
101//
102MPedestalPix &MPedestalCam::operator[](Int_t i) const
103{
104 return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
105}
106
107void MPedestalCam::Clear(Option_t *o)
108{
109 fArray->ForEach(TObject, Clear)();
110}
111
112void MPedestalCam::Print(Option_t *o) const
113{
114 *fLog << all << GetDescriptor() << ":" << endl;
115 int id = 0;
116
117 TIter Next(fArray);
118 MPedestalPix *pix;
119 while ((pix=(MPedestalPix*)Next()))
120 {
121 id++;
122
123 if (!pix->IsValid())
124 continue;
125
126 *fLog << id-1 << ": ";
127 *fLog << pix->GetPedestal() << " " << pix->GetPedestalRms() << endl;
128 }
129}
130
131Float_t MPedestalCam::GetPedestalMin(const MGeomCam *geom) const
132{
133 if (fArray->GetEntries() <= 0)
134 return 50.;
135
136 Float_t minval = (*this)[0].GetPedestalRms();
137
138 for (Int_t i=1; i<fArray->GetEntries(); i++)
139 {
140 const MPedestalPix &pix = (*this)[i];
141
142 Float_t testval = pix.GetPedestalRms();
143
144 if (geom)
145 testval *= geom->GetPixRatio(i);
146
147 if (testval < minval)
148 minval = testval;
149 }
150 return minval;
151}
152
153Float_t MPedestalCam::GetPedestalMax(const MGeomCam *geom) const
154{
155 if (fArray->GetEntries() <= 0)
156 return 50.;
157
158 Float_t maxval = (*this)[0].GetPedestalRms();
159
160 for (Int_t i=1; i<fArray->GetEntries(); i++)
161 {
162 const MPedestalPix &pix = (*this)[i];
163
164 Float_t testval = pix.GetPedestalRms();
165
166 if (geom)
167 testval *= geom->GetPixRatio(i);
168
169 if (testval > maxval)
170 maxval = testval;
171 }
172 return maxval;
173}
174
175Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
176{
177 switch (type)
178 {
179 case 0:
180 val = (*this)[idx].GetPedestal();
181 break;
182 case 1:
183 val = (*this)[idx].GetPedestalRms();
184 break;
185 default:
186 return kFALSE;
187 }
188 return val>=0;
189}
190
191void MPedestalCam::DrawPixelContent(Int_t num) const
192{
193 *fLog << warn << "MPedestalCam::DrawPixelContent - not available." << endl;
194}
Note: See TracBrowser for help on using the repository browser.