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

Last change on this file since 1873 was 1748, checked in by wittek, 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! Wolfgang Wittek 01/2003 <mailto:wittek@mppmu.mpg.de>
20!
21! Copyright: MAGIC Software Development, 2002
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 Int_t currentSector;
94 Float_t angle;
95
96 // sum up sigma**2 for each sector, separately for inner and outer region;
97 // all pixels are renormalized to the area of pixel 0
98 //
99 // consider all pixels with Cherenkov photon information
100 // and require "Used"
101 //
102
103 const UInt_t npix = evt.GetNumPixels();
104
105 for (UInt_t i=0; i<npix; i++)
106 {
107 MCerPhotPix &cerpix = evt.operator[](i);
108 if (!cerpix.IsPixelUsed())
109 continue;
110
111 if ( cerpix.GetNumPhotons() == 0 )
112 {
113 *fLog << "MSigmabar::Calc(); no.of photons is 0 for used pixel"
114 << endl;
115 continue;
116 }
117
118 Int_t j = cerpix.GetPixId();
119 Double_t Area = geom.GetPixRatio(j);
120
121 const MGeomPix &gpix = geom[j];
122 const MPedestalPix &pix = ped[j];
123
124 //angle = 6.0*atan2(gpix.GetX(),gpix.GetY()) / (2.0*TMath::Pi()) - 0.5;
125 //if (angle<0.0) angle+=6.0;
126
127 angle = 6.0*atan2(gpix.GetY(),gpix.GetX()) / (2.0*TMath::Pi());
128 if (angle<0.0) angle+=6.0;
129 currentSector=(Int_t)angle;
130
131 // count only those pixels which have a sigma != 0.0
132 Float_t sigma = pix.GetMeanRms();
133
134 if ( sigma != 0.0 )
135 {
136 if (Area < 1.5)
137 {
138 innerPixels[currentSector]++;
139 innerSquaredSum[currentSector]+= sigma*sigma / Area;
140 }
141 else
142 {
143 outerPixels[currentSector]++;
144 outerSquaredSum[currentSector]+= sigma*sigma / Area;
145 }
146 }
147 }
148
149 fSigmabarInner=0; fInnerPixels=0;
150 fSigmabarOuter=0; fOuterPixels=0;
151 for (UInt_t i=0; i<6; i++) {
152 fSigmabarInner += innerSquaredSum[i];
153 fInnerPixels += innerPixels[i];
154 fSigmabarOuter += outerSquaredSum[i];
155 fOuterPixels += outerPixels[i];
156 }
157
158
159 // this is the sqrt of the average sigma**2;
160 //
161 if ( (fInnerPixels+fOuterPixels) > 0)
162 fSigmabar=sqrt( (fSigmabarInner + fSigmabarOuter)
163 / (fInnerPixels + fOuterPixels) );
164
165 if (fInnerPixels > 0) fSigmabarInner /= fInnerPixels;
166 if (fOuterPixels > 0) fSigmabarOuter /= fOuterPixels;
167
168 // this is the sqrt of the average sigma**2
169 // for the inner and outer pixels respectively
170 //
171 fSigmabarInner = sqrt( fSigmabarInner );
172 fSigmabarOuter = sqrt( fSigmabarOuter );
173
174
175 for (UInt_t i=0; i<6; i++) {
176 fSigmabarSector[i] = 0.0;
177 fSigmabarInnerSector[i] = 0.0;
178 fSigmabarOuterSector[i] = 0.0;
179
180 if ( (innerPixels[i]+outerPixels[i]) > 0)
181 fSigmabarSector[i] = sqrt( (innerSquaredSum[i] + outerSquaredSum[i])
182 / (innerPixels[i] + outerPixels[i] ) );
183 if ( innerPixels[i] > 0)
184 fSigmabarInnerSector[i] = innerSquaredSum[i] / innerPixels[i];
185 if ( outerPixels[i] > 0)
186 fSigmabarOuterSector[i] = outerSquaredSum[i] / outerPixels[i];
187
188
189 fSigmabarInnerSector[i] = sqrt( fSigmabarInnerSector[i] );
190 fSigmabarOuterSector[i] = sqrt( fSigmabarOuterSector[i] );
191 }
192
193 return (fSigmabar);
194}
195
196// --------------------------------------------------------------------------
197//
198void MSigmabar::Print(Option_t *) const
199{
200 *fLog << endl;
201 *fLog << "Total number of inner pixels is " << fInnerPixels << endl;
202 *fLog << "Total number of outer pixels is " << fOuterPixels << endl;
203 *fLog << endl;
204
205 *fLog << "Sigmabar Overall : " << fSigmabar << " ";
206 *fLog << " Sectors: ";
207 for (Int_t i=0;i<6;i++) *fLog << fSigmabarSector[i] << ", ";
208 *fLog << endl;
209
210
211 *fLog << "Sigmabar Inner : " << fSigmabarInner << " ";
212 *fLog << " Sectors: ";
213 for (Int_t i=0;i<6;i++) *fLog << fSigmabarInnerSector[i] << ", ";
214 *fLog << endl;
215
216
217 *fLog << "Sigmabar Outer : " << fSigmabarOuter << " ";
218 *fLog << " Sectors: ";
219 for (Int_t i=0;i<6;i++) *fLog << fSigmabarOuterSector[i] << ", ";
220 *fLog << endl;
221
222}
223// --------------------------------------------------------------------------
224
225
226
227
Note: See TracBrowser for help on using the repository browser.