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

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