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

Last change on this file since 1895 was 1885, checked in by wittek, 22 years ago
*** empty log message ***
File size: 7.0 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! Wolfgang Wittek 01/2003 <mailto:wittek@mppmu.mpg.de>
20!
21! Copyright: MAGIC Software Development, 2003
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27// //
28// MSigmabar //
29// //
30// This is the storage container to hold information about //
31// "average" pedestal sigmas //
32// //
33// In calculating averages all sigmas are normalized to the area of pixel 0//
34// //
35/////////////////////////////////////////////////////////////////////////////
36#include "MSigmabar.h"
37
38#include <TMath.h>
39
40#include "MLog.h"
41#include "MLogManip.h"
42#include "MParList.h"
43#include "MGeomCam.h"
44#include "MPedestalCam.h"
45#include "MPedestalPix.h"
46#include "MGeomPix.h"
47#include "MCerPhotEvt.h"
48#include "MCerPhotPix.h"
49
50ClassImp(MSigmabar);
51
52// --------------------------------------------------------------------------
53//
54MSigmabar::MSigmabar(const char *name, const char *title)
55{
56 fName = name ? name : "MSigmabar";
57 fTitle = title ? title : "Storage container for Sigmabar";
58
59
60 fCalcPixNum=kTRUE;
61}
62
63// --------------------------------------------------------------------------
64//
65MSigmabar::~MSigmabar()
66{
67 // do nothing special.
68}
69
70// --------------------------------------------------------------------------
71//
72// Actual calculation of sigmabar. This is done for each of the six sectors
73// separately due to their possibly different HV behavior. Also inner and
74// outer pixels are treated separately.
75//
76// Preliminary! Works for CT1 test, for real MAGIC crosschecks still have
77// to be done. Also implementation details will be updated, like
78// determination of sector to which a respective pixel belongs
79//
80Float_t MSigmabar::Calc(const MGeomCam &geom, const MPedestalCam &ped,
81 const MCerPhotEvt &evt)
82{
83 fSigmabar = 0.0;
84 fSigmabarInner = 0.0;
85 fSigmabarOuter = 0.0;
86
87
88 Float_t innerSquaredSum[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
89 Float_t outerSquaredSum[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
90 Int_t innerPixels[6] = {0,0,0,0,0,0};
91 Int_t outerPixels[6] = {0,0,0,0,0,0};
92
93 // sum up sigma**2 for each sector, separately for inner and outer region;
94 // all pixels are renormalized to the area of pixel 0
95 //
96 // consider all pixels with Cherenkov photon information
97 // and require "Used"
98 //
99
100 const UInt_t npix = evt.GetNumPixels();
101
102 for (UInt_t i=0; i<npix; i++)
103 {
104 MCerPhotPix &cerpix = evt.operator[](i);
105 if (!cerpix.IsPixelUsed())
106 continue;
107
108 if ( cerpix.GetNumPhotons() == 0 )
109 {
110 *fLog << "MSigmabar::Calc(); no.of photons is 0 for used pixel"
111 << endl;
112 continue;
113 }
114
115 Int_t j = cerpix.GetPixId();
116 Double_t area = geom.GetPixRatio(j);
117
118 const MGeomPix &gpix = geom[j];
119 const MPedestalPix &pix = ped[j];
120
121 //angle = 6.0*atan2(gpix.GetX(),gpix.GetY()) / (2.0*TMath::Pi()) - 0.5;
122 //if (angle<0.0) angle+=6.0;
123
124 Float_t angle = atan2(gpix.GetY(),gpix.GetX())*6 / (TMath::Pi()*2);
125 if (angle<0) angle+=6;
126
127 Int_t currentSector=(Int_t)angle;
128
129 // count only those pixels which have a sigma != 0.0
130 Float_t sigma = pix.GetMeanRms();
131
132 if ( sigma != 0.0 )
133 {
134 if (area < 1.5)
135 {
136 innerPixels[currentSector]++;
137 innerSquaredSum[currentSector]+= sigma*sigma / area;
138 }
139 else
140 {
141 outerPixels[currentSector]++;
142 outerSquaredSum[currentSector]+= sigma*sigma / area;
143 }
144 }
145 }
146
147 fSigmabarInner=0; fInnerPixels=0;
148 fSigmabarOuter=0; fOuterPixels=0;
149 for (UInt_t i=0; i<6; i++) {
150 fSigmabarInner += innerSquaredSum[i];
151 fInnerPixels += innerPixels[i];
152 fSigmabarOuter += outerSquaredSum[i];
153 fOuterPixels += outerPixels[i];
154 }
155
156
157 // this is the sqrt of the average sigma**2;
158 //
159 if ( (fInnerPixels+fOuterPixels) > 0)
160 fSigmabar=sqrt( (fSigmabarInner + fSigmabarOuter)
161 / (fInnerPixels + fOuterPixels) );
162
163 if (fInnerPixels > 0) fSigmabarInner /= fInnerPixels;
164 if (fOuterPixels > 0) fSigmabarOuter /= fOuterPixels;
165
166 // this is the sqrt of the average sigma**2
167 // for the inner and outer pixels respectively
168 //
169 fSigmabarInner = sqrt( fSigmabarInner );
170 fSigmabarOuter = sqrt( fSigmabarOuter );
171
172
173 for (UInt_t i=0; i<6; i++) {
174 fSigmabarSector[i] = 0.0;
175 fSigmabarInnerSector[i] = 0.0;
176 fSigmabarOuterSector[i] = 0.0;
177
178 if ( (innerPixels[i]+outerPixels[i]) > 0)
179 fSigmabarSector[i] = sqrt( (innerSquaredSum[i] + outerSquaredSum[i])
180 / (innerPixels[i] + outerPixels[i] ) );
181 if ( innerPixels[i] > 0)
182 fSigmabarInnerSector[i] = innerSquaredSum[i] / innerPixels[i];
183 if ( outerPixels[i] > 0)
184 fSigmabarOuterSector[i] = outerSquaredSum[i] / outerPixels[i];
185
186
187 fSigmabarInnerSector[i] = sqrt( fSigmabarInnerSector[i] );
188 fSigmabarOuterSector[i] = sqrt( fSigmabarOuterSector[i] );
189 }
190
191 return fSigmabar;
192}
193
194// --------------------------------------------------------------------------
195//
196void MSigmabar::Print(Option_t *) const
197{
198 *fLog << endl;
199 *fLog << "Total number of inner pixels is " << fInnerPixels << endl;
200 *fLog << "Total number of outer pixels is " << fOuterPixels << endl;
201 *fLog << endl;
202
203 *fLog << "Sigmabar Overall : " << fSigmabar << " ";
204 *fLog << " Sectors: ";
205 for (Int_t i=0;i<6;i++) *fLog << fSigmabarSector[i] << ", ";
206 *fLog << endl;
207
208
209 *fLog << "Sigmabar Inner : " << fSigmabarInner << " ";
210 *fLog << " Sectors: ";
211 for (Int_t i=0;i<6;i++) *fLog << fSigmabarInnerSector[i] << ", ";
212 *fLog << endl;
213
214
215 *fLog << "Sigmabar Outer : " << fSigmabarOuter << " ";
216 *fLog << " Sectors: ";
217 for (Int_t i=0;i<6;i++) *fLog << fSigmabarOuterSector[i] << ", ";
218 *fLog << endl;
219
220}
221// --------------------------------------------------------------------------
222
223
224
225
Note: See TracBrowser for help on using the repository browser.