source: trunk/MagicSoft/Mars/manalysis/MSigmabar.cc@ 2173

Last change on this file since 2173 was 2173, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 7.4 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! Author(s): Wolfgang Wittek, 01/2003 <mailto:wittek@mppmu.mpg.de>
20! Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
21!
22! Copyright: MAGIC Software Development, 2003
23!
24!
25\* ======================================================================== */
26
27/////////////////////////////////////////////////////////////////////////////
28// //
29// MSigmabar //
30// //
31// This is the storage container to hold information about //
32// "average" pedestal sigmas //
33// //
34// In calculating averages all sigmas are normalized to the area of pixel 0//
35// //
36/////////////////////////////////////////////////////////////////////////////
37#include "MSigmabar.h"
38
39#include <TMath.h>
40
41#include "MLog.h"
42#include "MLogManip.h"
43
44#include "MParList.h"
45
46#include "MGeomCam.h"
47#include "MGeomPix.h"
48
49#include "MCerPhotEvt.h"
50#include "MCerPhotPix.h"
51
52#include "MPedestalCam.h"
53#include "MPedestalPix.h"
54
55ClassImp(MSigmabar);
56
57using namespace std;
58
59// --------------------------------------------------------------------------
60//
61MSigmabar::MSigmabar(const char *name, const char *title)
62{
63 fName = name ? name : "MSigmabar";
64 fTitle = title ? title : "Storage container for Sigmabar";
65}
66
67// --------------------------------------------------------------------------
68//
69MSigmabar::~MSigmabar()
70{
71 // do nothing special.
72}
73
74void MSigmabar::Reset()
75{
76 fSigmabar = -1;
77 fInnerPixels = -1;
78 fOuterPixels = -1;
79 fSigmabarInner = -1;
80 fSigmabarOuter = -1;
81
82 memset(fSigmabarSector, 0, sizeof(fSigmabarSector));
83 memset(fSigmabarInnerSector, 0, sizeof(fSigmabarInnerSector));
84 memset(fSigmabarOuterSector, 0, sizeof(fSigmabarOuterSector));
85}
86
87// --------------------------------------------------------------------------
88//
89// Actual calculation of sigmabar. This is done for each of the six sectors
90// separately due to their possibly different HV behavior. Also inner and
91// outer pixels are treated separately.
92//
93// Preliminary! Works for CT1 test, for real MAGIC crosschecks still have
94// to be done. Also implementation details will be updated, like
95// determination of sector to which a respective pixel belongs
96//
97Float_t MSigmabar::Calc(const MGeomCam &geom, const MPedestalCam &ped,
98 const MCerPhotEvt &evt)
99{
100 Int_t innerPixels[6];
101 Int_t outerPixels[6];
102 Float_t innerSquaredSum[6];
103 Float_t outerSquaredSum[6];
104
105 memset(innerPixels, 0, sizeof(innerPixels));
106 memset(outerPixels, 0, sizeof(outerPixels));
107 memset(innerSquaredSum, 0, sizeof(innerSquaredSum));
108 memset(outerSquaredSum, 0, sizeof(outerSquaredSum));
109
110 //
111 // sum up sigma^2 for each sector, separately for inner and outer region;
112 // all pixels are renormalized to the area of pixel 0
113 //
114 // consider all pixels with Cherenkov photon information
115 // and require "Used"
116 //
117
118 const UInt_t npix = evt.GetNumPixels();
119
120 //*fLog << "MSigmabar : npix = " << npix << endl;
121
122 for (UInt_t i=0; i<npix; i++)
123 {
124 MCerPhotPix &cerpix = evt.operator[](i);
125 if (!cerpix.IsPixelUsed())
126 continue;
127
128 /*
129 if ( cerpix.GetNumPhotons() == 0 )
130 {
131 *fLog << "MSigmabar::Calc(); no.of photons is 0 for used pixel"
132 << endl;
133 continue;
134 }
135 */
136
137 const Int_t id = cerpix.GetPixId();
138 const Double_t area = geom.GetPixRatio(id);
139
140 if (id == 0)
141 {
142 //*fLog << "MSigmabar : id = 0; pixel '0' is used, ignore it"
143 // << endl;
144 continue;
145 }
146
147 const MGeomPix &gpix = geom[id];
148 const MPedestalPix &pix = ped[id];
149
150 Int_t sector = (Int_t)(atan2(gpix.GetY(),gpix.GetX())*6 / (TMath::Pi()*2));
151 if (sector<0)
152 sector+=6;
153
154 // count only those pixels which have a sigma != 0.0
155 const Float_t sigma = pix.GetMeanRms();
156
157 if ( sigma <= 0 )
158 continue;
159
160 if (area < 1.5)
161 {
162 innerPixels[sector]++;
163 innerSquaredSum[sector]+= sigma*sigma / area;
164 }
165 else
166 {
167 outerPixels[sector]++;
168 outerSquaredSum[sector]+= sigma*sigma / area;
169 }
170 }
171
172 fInnerPixels = 0;
173 fOuterPixels = 0;
174 fSigmabarInner = 0;
175 fSigmabarOuter = 0;
176 for (UInt_t i=0; i<6; i++)
177 {
178 fSigmabarInner += innerSquaredSum[i];
179 fInnerPixels += innerPixels[i];
180 fSigmabarOuter += outerSquaredSum[i];
181 fOuterPixels += outerPixels[i];
182 }
183
184 //
185 // this is the sqrt of the average sigma^2;
186 //
187 fSigmabar=fInnerPixels+fOuterPixels<=0?0:sqrt((fSigmabarInner+fSigmabarOuter)/(fInnerPixels+fOuterPixels));
188
189 if (fInnerPixels > 0) fSigmabarInner /= fInnerPixels;
190 if (fOuterPixels > 0) fSigmabarOuter /= fOuterPixels;
191
192 //
193 // this is the sqrt of the average sigma^2
194 // for the inner and outer pixels respectively
195 //
196 fSigmabarInner = sqrt( fSigmabarInner );
197 fSigmabarOuter = sqrt( fSigmabarOuter );
198
199 for (UInt_t i=0; i<6; i++)
200 {
201 const Double_t ip = innerPixels[i];
202 const Double_t op = outerPixels[i];
203 const Double_t iss = innerSquaredSum[i];
204 const Double_t oss = outerSquaredSum[i];
205
206 const Double_t sum = ip + op;
207
208 fSigmabarSector[i] = sum<=0 ? 0 : sqrt((iss+oss)/sum);
209 fSigmabarInnerSector[i] = ip <=0 ? 0 : sqrt(iss/ip);
210 fSigmabarOuterSector[i] = op <=0 ? 0 : sqrt(oss/op);
211 }
212
213 return fSigmabar;
214}
215
216// --------------------------------------------------------------------------
217//
218void MSigmabar::Print(Option_t *) const
219{
220 *fLog << all << endl;
221 *fLog << "Total number of inner pixels is " << fInnerPixels << endl;
222 *fLog << "Total number of outer pixels is " << fOuterPixels << endl;
223 *fLog << endl;
224
225 *fLog << "Sigmabar Overall : " << fSigmabar << " ";
226 *fLog << " Sectors: ";
227 for (Int_t i=0;i<6;i++)
228 *fLog << fSigmabarSector[i] << ", ";
229 *fLog << endl;
230
231
232 *fLog << "Sigmabar Inner : " << fSigmabarInner << " ";
233 *fLog << " Sectors: ";
234 for (Int_t i=0;i<6;i++)
235 *fLog << fSigmabarInnerSector[i] << ", ";
236 *fLog << endl;
237
238
239 *fLog << "Sigmabar Outer : " << fSigmabarOuter << " ";
240 *fLog << " Sectors: ";
241 for (Int_t i=0;i<6;i++)
242 *fLog << fSigmabarOuterSector[i] << ", ";
243 *fLog << endl;
244
245}
Note: See TracBrowser for help on using the repository browser.