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

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