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

Last change on this file since 2494 was 2255, checked in by wittek, 21 years ago
*** empty log message ***
File size: 7.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): 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 idx = cerpix.GetPixId();
138 if (idx == 0)
139 {
140 //*fLog << "MSigmabar : id = 0; pixel '0' is used, ignore it"
141 // << endl;
142 continue;
143 }
144
145 // ratio is the area of pixel 0
146 // divided by the area of the current pixel
147 const Double_t ratio = geom.GetPixRatio(idx);
148
149 const MGeomPix &gpix = geom[idx];
150
151 Int_t sector = (Int_t)(atan2(gpix.GetY(),gpix.GetX())*6 / (TMath::Pi()*2));
152 if (sector<0)
153 sector+=6;
154
155 // count only those pixels which have a sigma != 0.0
156 const Float_t sigma = ped[idx].GetPedestalRms();
157
158 if ( sigma <= 0 )
159 continue;
160
161 //if (area < 1.5)
162 if (ratio > 0.5)
163 {
164 innerPixels[sector]++;
165 innerSquaredSum[sector]+= sigma*sigma * ratio;
166 }
167 else
168 {
169 outerPixels[sector]++;
170 outerSquaredSum[sector]+= sigma*sigma * ratio;
171 }
172 }
173
174 fInnerPixels = 0;
175 fOuterPixels = 0;
176 fSigmabarInner = 0;
177 fSigmabarOuter = 0;
178 for (UInt_t i=0; i<6; i++)
179 {
180 fSigmabarInner += innerSquaredSum[i];
181 fInnerPixels += innerPixels[i];
182 fSigmabarOuter += outerSquaredSum[i];
183 fOuterPixels += outerPixels[i];
184 }
185
186 //
187 // this is the sqrt of the average sigma^2;
188 //
189 fSigmabar=fInnerPixels+fOuterPixels<=0?0:sqrt((fSigmabarInner+fSigmabarOuter)/(fInnerPixels+fOuterPixels));
190
191 if (fInnerPixels > 0) fSigmabarInner /= fInnerPixels;
192 if (fOuterPixels > 0) fSigmabarOuter /= fOuterPixels;
193
194 //
195 // this is the sqrt of the average sigma^2
196 // for the inner and outer pixels respectively
197 //
198 fSigmabarInner = sqrt( fSigmabarInner );
199 fSigmabarOuter = sqrt( fSigmabarOuter );
200
201 for (UInt_t i=0; i<6; i++)
202 {
203 const Double_t ip = innerPixels[i];
204 const Double_t op = outerPixels[i];
205 const Double_t iss = innerSquaredSum[i];
206 const Double_t oss = outerSquaredSum[i];
207
208 const Double_t sum = ip + op;
209
210 fSigmabarSector[i] = sum<=0 ? 0 : sqrt((iss+oss)/sum);
211 fSigmabarInnerSector[i] = ip <=0 ? 0 : sqrt(iss/ip);
212 fSigmabarOuterSector[i] = op <=0 ? 0 : sqrt(oss/op);
213 }
214
215 return fSigmabar;
216}
217
218// --------------------------------------------------------------------------
219//
220void MSigmabar::Print(Option_t *) const
221{
222 *fLog << all << endl;
223 *fLog << "Total number of inner pixels is " << fInnerPixels << endl;
224 *fLog << "Total number of outer pixels is " << fOuterPixels << endl;
225 *fLog << endl;
226
227 *fLog << "Sigmabar Overall : " << fSigmabar << " ";
228 *fLog << " Sectors: ";
229 for (Int_t i=0;i<6;i++)
230 *fLog << fSigmabarSector[i] << ", ";
231 *fLog << endl;
232
233
234 *fLog << "Sigmabar Inner : " << fSigmabarInner << " ";
235 *fLog << " Sectors: ";
236 for (Int_t i=0;i<6;i++)
237 *fLog << fSigmabarInnerSector[i] << ", ";
238 *fLog << endl;
239
240
241 *fLog << "Sigmabar Outer : " << fSigmabarOuter << " ";
242 *fLog << " Sectors: ";
243 for (Int_t i=0;i<6;i++)
244 *fLog << fSigmabarOuterSector[i] << ", ";
245 *fLog << endl;
246
247}
248
249
250
251
252
253
254
255
256
Note: See TracBrowser for help on using the repository browser.