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

Last change on this file since 1879 was 1544, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.7 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
42
43ClassImp(MPedestalCam);
44
45// --------------------------------------------------------------------------
46//
47// Default constructor. Creates a MPedestalPix object for each pixel
48//
49MPedestalCam::MPedestalCam(const char *name, const char *title)
50{
51 fName = name ? name : "MPedestalCam";
52 fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
53
54 fArray = new TClonesArray("MPedestalPix", 577);
55
56 for (int i=0; i<577; i++)
57 new ((*fArray)[i]) MPedestalPix;
58}
59
60// --------------------------------------------------------------------------
61//
62// Delete the array conatining the pixel pedest information
63//
64MPedestalCam::~MPedestalCam()
65{
66 delete fArray;
67}
68
69// --------------------------------------------------------------------------
70//
71// Set the size of the camera
72//
73void MPedestalCam::InitSize(const UInt_t i)
74{
75 fArray->ExpandCreate(i);
76}
77
78// --------------------------------------------------------------------------
79//
80// Get the size of the MPedestalCam
81//
82Int_t MPedestalCam::GetSize() const
83{
84 return fArray->GetEntries();
85}
86
87// --------------------------------------------------------------------------
88//
89// Get i-th pixel (pixel number)
90//
91MPedestalPix &MPedestalCam::operator[](Int_t i)
92{
93 return *(MPedestalPix*)fArray->UncheckedAt(i);
94}
95
96// --------------------------------------------------------------------------
97//
98// Get i-th pixel (pixel number)
99//
100MPedestalPix &MPedestalCam::operator[](Int_t i) const
101{
102 return *(MPedestalPix*)fArray->UncheckedAt(i);
103}
104
105// --------------------------------------------------------------------------
106//
107// Check if position i is inside bounds
108//
109Bool_t MPedestalCam::CheckBounds(Int_t i)
110{
111 return i < fArray->GetEntriesFast();
112}
113
114void MPedestalCam::Clear(Option_t *o)
115{
116 fArray->ForEach(TObject, Clear)();
117}
118
119void MPedestalCam::Print(Option_t *o) const
120{
121 *fLog << all << GetDescriptor() << ":" << endl;
122 int id = 0;
123
124 TIter Next(fArray);
125 MPedestalPix *pix;
126 while ((pix=(MPedestalPix*)Next()))
127 {
128 id++;
129
130 if (!pix->IsValid())
131 continue;
132
133 *fLog << id-1 << ": ";
134 *fLog << pix->GetMean() << " " << pix->GetSigma() << " ";
135 *fLog << pix->GetMeanRms() << " " << pix->GetSigmaRms() << endl;
136 }
137}
138
139Float_t MPedestalCam::GetMeanMin(const MGeomCam *geom) const
140{
141 if (fArray->GetEntries() <= 0)
142 return 50.;
143
144 Float_t minval = (*this)[0].GetMean();
145
146 for (Int_t i=1; i<fArray->GetEntries(); i++)
147 {
148 const MPedestalPix &pix = (*this)[i];
149
150 Float_t testval = pix.GetMean();
151
152 if (geom)
153 testval *= geom->GetPixRatio(i);
154
155 if (testval < minval)
156 minval = testval;
157 }
158 return minval;
159}
160
161Float_t MPedestalCam::GetMeanMax(const MGeomCam *geom) const
162{
163 if (fArray->GetEntries() <= 0)
164 return 50.;
165
166 Float_t maxval = (*this)[0].GetMean();
167
168 for (Int_t i=1; i<fArray->GetEntries(); i++)
169 {
170 const MPedestalPix &pix = (*this)[i];
171
172 Float_t testval = pix.GetMean();
173
174 if (geom)
175 testval *= geom->GetPixRatio(i);
176
177 if (testval > maxval)
178 maxval = testval;
179 }
180 return maxval;
181}
Note: See TracBrowser for help on using the repository browser.