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

Last change on this file since 1958 was 1951, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 7.1 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(outerSquaredSum, 0, sizeof(outerSquaredSum));
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 for (UInt_t i=0; i<npix; i++)
119 {
120 MCerPhotPix &cerpix = evt.operator[](i);
121 if (!cerpix.IsPixelUsed())
122 continue;
123 /*
124 if ( cerpix.GetNumPhotons() == 0 )
125 {
126 *fLog << "MSigmabar::Calc(); no.of photons is 0 for used pixel"
127 << endl;
128 continue;
129 }
130 */
131 const Int_t id = cerpix.GetPixId();
132 const Double_t area = geom.GetPixRatio(id);
133
134 const MGeomPix &gpix = geom[id];
135 const MPedestalPix &pix = ped[id];
136
137 Int_t sector = (Int_t)(atan2(gpix.GetY(),gpix.GetX())*6 / (TMath::Pi()*2));
138 if (sector<0)
139 sector+=6;
140
141 // count only those pixels which have a sigma != 0.0
142 const Float_t sigma = pix.GetMeanRms();
143
144 if ( sigma <= 0 )
145 continue;
146
147 if (area < 1.5)
148 {
149 innerPixels[sector]++;
150 innerSquaredSum[sector]+= sigma*sigma / area;
151 }
152 else
153 {
154 outerPixels[sector]++;
155 outerSquaredSum[sector]+= sigma*sigma / area;
156 }
157 }
158
159 fInnerPixels = 0;
160 fOuterPixels = 0;
161 fSigmabarInner = 0;
162 fSigmabarOuter = 0;
163 for (UInt_t i=0; i<6; i++) {
164 fSigmabarInner += innerSquaredSum[i];
165 fInnerPixels += innerPixels[i];
166 fSigmabarOuter += outerSquaredSum[i];
167 fOuterPixels += outerPixels[i];
168 }
169
170 //
171 // this is the sqrt of the average sigma^2;
172 //
173 fSigmabar=fInnerPixels+fOuterPixels<=0?0:sqrt((fSigmabarInner+fSigmabarOuter)/(fInnerPixels+fOuterPixels));
174
175 if (fInnerPixels > 0) fSigmabarInner /= fInnerPixels;
176 if (fOuterPixels > 0) fSigmabarOuter /= fOuterPixels;
177
178 //
179 // this is the sqrt of the average sigma^2
180 // for the inner and outer pixels respectively
181 //
182 fSigmabarInner = sqrt( fSigmabarInner );
183 fSigmabarOuter = sqrt( fSigmabarOuter );
184
185 for (UInt_t i=0; i<6; i++) {
186 fSigmabarSector[i] = innerPixels[i]+outerPixels[i]<=0?0:sqrt((innerSquaredSum[i]+outerSquaredSum[i])/(innerPixels[i]+outerPixels[i]));
187
188 const Double_t is = innerPixels[i]<=0?0:innerSquaredSum[i]/innerPixels[i];
189 const Double_t os = outerPixels[i]<=0?0:outerSquaredSum[i]/outerPixels[i];
190
191 fSigmabarInnerSector[i] = sqrt( is );
192 fSigmabarOuterSector[i] = sqrt( os );
193 }
194
195 return fSigmabar;
196}
197
198// --------------------------------------------------------------------------
199//
200void MSigmabar::Print(Option_t *) const
201{
202 *fLog << all << endl;
203 *fLog << "Total number of inner pixels is " << fInnerPixels << endl;
204 *fLog << "Total number of outer pixels is " << fOuterPixels << endl;
205 *fLog << endl;
206
207 *fLog << "Sigmabar Overall : " << fSigmabar << " ";
208 *fLog << " Sectors: ";
209 for (Int_t i=0;i<6;i++)
210 *fLog << fSigmabarSector[i] << ", ";
211 *fLog << endl;
212
213
214 *fLog << "Sigmabar Inner : " << fSigmabarInner << " ";
215 *fLog << " Sectors: ";
216 for (Int_t i=0;i<6;i++)
217 *fLog << fSigmabarInnerSector[i] << ", ";
218 *fLog << endl;
219
220
221 *fLog << "Sigmabar Outer : " << fSigmabarOuter << " ";
222 *fLog << " Sectors: ";
223 for (Int_t i=0;i<6;i++)
224 *fLog << fSigmabarOuterSector[i] << ", ";
225 *fLog << endl;
226
227}
Note: See TracBrowser for help on using the repository browser.