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

Last change on this file since 2037 was 1961, checked in by wittek, 22 years ago
*** empty log message ***
File size: 7.3 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 fSigmabarInner += innerSquaredSum[i];
176 fInnerPixels += innerPixels[i];
177 fSigmabarOuter += outerSquaredSum[i];
178 fOuterPixels += outerPixels[i];
179 }
180
181 //
182 // this is the sqrt of the average sigma^2;
183 //
184 fSigmabar=fInnerPixels+fOuterPixels<=0?0:sqrt((fSigmabarInner+fSigmabarOuter)/(fInnerPixels+fOuterPixels));
185
186 if (fInnerPixels > 0) fSigmabarInner /= fInnerPixels;
187 if (fOuterPixels > 0) fSigmabarOuter /= fOuterPixels;
188
189 //
190 // this is the sqrt of the average sigma^2
191 // for the inner and outer pixels respectively
192 //
193 fSigmabarInner = sqrt( fSigmabarInner );
194 fSigmabarOuter = sqrt( fSigmabarOuter );
195
196 for (UInt_t i=0; i<6; i++) {
197 fSigmabarSector[i] = innerPixels[i]+outerPixels[i]<=0?0:sqrt((innerSquaredSum[i]+outerSquaredSum[i])/(innerPixels[i]+outerPixels[i]));
198
199 const Double_t is = innerPixels[i]<=0?0:innerSquaredSum[i]/innerPixels[i];
200 const Double_t os = outerPixels[i]<=0?0:outerSquaredSum[i]/outerPixels[i];
201
202 fSigmabarInnerSector[i] = sqrt( is );
203 fSigmabarOuterSector[i] = sqrt( os );
204 }
205
206 return fSigmabar;
207}
208
209// --------------------------------------------------------------------------
210//
211void MSigmabar::Print(Option_t *) const
212{
213 *fLog << all << endl;
214 *fLog << "Total number of inner pixels is " << fInnerPixels << endl;
215 *fLog << "Total number of outer pixels is " << fOuterPixels << endl;
216 *fLog << endl;
217
218 *fLog << "Sigmabar Overall : " << fSigmabar << " ";
219 *fLog << " Sectors: ";
220 for (Int_t i=0;i<6;i++)
221 *fLog << fSigmabarSector[i] << ", ";
222 *fLog << endl;
223
224
225 *fLog << "Sigmabar Inner : " << fSigmabarInner << " ";
226 *fLog << " Sectors: ";
227 for (Int_t i=0;i<6;i++)
228 *fLog << fSigmabarInnerSector[i] << ", ";
229 *fLog << endl;
230
231
232 *fLog << "Sigmabar Outer : " << fSigmabarOuter << " ";
233 *fLog << " Sectors: ";
234 for (Int_t i=0;i<6;i++)
235 *fLog << fSigmabarOuterSector[i] << ", ";
236 *fLog << endl;
237
238}
239
240
241
242
243
244
Note: See TracBrowser for help on using the repository browser.