| 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 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2002
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MSigmabar //
|
|---|
| 28 | // //
|
|---|
| 29 | // This is the storage container to hold information about the mean sigma //
|
|---|
| 30 | // (aka Sigmabar) of all pedestals //
|
|---|
| 31 | // //
|
|---|
| 32 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 33 | #include "MSigmabar.h"
|
|---|
| 34 |
|
|---|
| 35 | #include <TMath.h>
|
|---|
| 36 |
|
|---|
| 37 | #include "MLog.h"
|
|---|
| 38 | #include "MLogManip.h"
|
|---|
| 39 |
|
|---|
| 40 | #include "MGeomCam.h"
|
|---|
| 41 | #include "MPedestalCam.h"
|
|---|
| 42 | #include "MGeomPix.h"
|
|---|
| 43 | #include "MPedestalPix.h"
|
|---|
| 44 |
|
|---|
| 45 | ClassImp(MSigmabar);
|
|---|
| 46 |
|
|---|
| 47 | MSigmabar::MSigmabar(const char *name, const char *title)
|
|---|
| 48 | {
|
|---|
| 49 | fName = name ? name : "MSigmabar";
|
|---|
| 50 | fTitle = title ? title : "Storage container for Sigmabar";
|
|---|
| 51 |
|
|---|
| 52 | fSigmabar = 0.0;
|
|---|
| 53 | fSigmabarInner = 0.0;
|
|---|
| 54 | fSigmabarOuter = 0.0;
|
|---|
| 55 | fRatioA = 0.0;
|
|---|
| 56 |
|
|---|
| 57 | fCalcPixNum=kTRUE;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | MSigmabar::~MSigmabar()
|
|---|
| 61 | {
|
|---|
| 62 | // do nothing special.
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | // --------------------------------------------------------------------------
|
|---|
| 67 | //
|
|---|
| 68 | // Actual calculation of sigmabar. This is done for each of the six sectors
|
|---|
| 69 | // separately due to their possibly different HV behavior. Also inner and
|
|---|
| 70 | // outer pixels are treated separately
|
|---|
| 71 | //
|
|---|
| 72 | // Preliminary! Works for CT1 test, for real MAGIC crosschecks still have
|
|---|
| 73 | // to be done. Also implementation details will be updated, like
|
|---|
| 74 | // determination of sector to which a respective pixel belongs
|
|---|
| 75 | //
|
|---|
| 76 | Bool_t MSigmabar::Calc(const MGeomCam &geom, const MPedestalCam &ped)
|
|---|
| 77 | {
|
|---|
| 78 | const UInt_t npix = ped.GetSize();
|
|---|
| 79 | Float_t innerSquaredSum[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
|---|
| 80 | Float_t outerSquaredSum[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
|---|
| 81 | Int_t innerPixels[6] = {0,0,0,0,0,0};
|
|---|
| 82 | Int_t outerPixels[6] = {0,0,0,0,0,0};
|
|---|
| 83 | Int_t currentSector;
|
|---|
| 84 | Float_t angle;
|
|---|
| 85 |
|
|---|
| 86 | for (UInt_t i=0; i<npix;i++)
|
|---|
| 87 | {
|
|---|
| 88 | const MGeomPix gpix = geom[i];
|
|---|
| 89 | angle=((6*atan2(gpix.GetX(),gpix.GetY())/(2*TMath::Pi()))-0.5);
|
|---|
| 90 | if (angle<0) angle+=6;
|
|---|
| 91 | currentSector=(Int_t)angle;
|
|---|
| 92 | geom.GetPixRatio(i) == 1 ? innerPixels[currentSector]++ : outerPixels[currentSector]++;
|
|---|
| 93 |
|
|---|
| 94 | const MPedestalPix pix = ped[i];
|
|---|
| 95 | geom.GetPixRatio(i) == 1 ? innerSquaredSum[currentSector]+=(pix.GetSigma()*pix.GetSigma()) : outerSquaredSum[currentSector]+=((pix.GetSigma()*pix.GetSigma()) / geom.GetPixRatio(i));
|
|---|
| 96 |
|
|---|
| 97 | // Get once and forever the ratio of areas outer/inner pixels
|
|---|
| 98 | if (fRatioA && (geom.GetPixRatio(i) != 1)) fRatioA=geom.GetPixRatio(i);
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | // Overall Sigma
|
|---|
| 102 | fSigmabarInner=0; fInnerPixels=0;
|
|---|
| 103 | fSigmabarOuter=0; fOuterPixels=0;
|
|---|
| 104 | for (UInt_t i=0; i<6; i++) {
|
|---|
| 105 | fSigmabarInner+=innerSquaredSum[i];
|
|---|
| 106 | fInnerPixels +=innerPixels[i];
|
|---|
| 107 | fSigmabarOuter+=outerSquaredSum[i];
|
|---|
| 108 | fOuterPixels +=outerPixels[i];
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | fSigmabarInner/=fInnerPixels;
|
|---|
| 112 | if (fSigmabarOuter != 0) fSigmabarOuter/=fOuterPixels;
|
|---|
| 113 | fSigmabar=sqrt(fSigmabarInner + fSigmabarOuter/( fOuterPixels==0 ? 1 : fRatioA));
|
|---|
| 114 | fSigmabarInner=sqrt(fSigmabarInner);
|
|---|
| 115 | fSigmabarOuter=sqrt(fSigmabarOuter);
|
|---|
| 116 |
|
|---|
| 117 | for (UInt_t i=0; i<6; i++) {
|
|---|
| 118 | fSigmabarInnerSector[i]=innerSquaredSum[i]/innerPixels[i];
|
|---|
| 119 | fSigmabarOuterSector[i]=outerSquaredSum[i]/( outerSquaredSum[i]==0 ? 1: outerPixels[i] );
|
|---|
| 120 |
|
|---|
| 121 | fSigmabarSector[i]=sqrt(fSigmabarInnerSector[i] + fSigmabarOuterSector[i]*fRatioA);
|
|---|
| 122 | fSigmabarInnerSector[i]=sqrt(fSigmabarInnerSector[i]);
|
|---|
| 123 | fSigmabarOuterSector[i]=sqrt(fSigmabarOuterSector[i]);
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | // Did all our calculations work? fOuterPixels==0 could happen, however.
|
|---|
| 127 | return (fInnerPixels!=0);
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 | void MSigmabar::Print(Option_t *) const
|
|---|
| 132 | {
|
|---|
| 133 | *fLog << all;
|
|---|
| 134 | *fLog << "Sigmabar Overall " << fSigmabar;
|
|---|
| 135 | *fLog << " Sectors: ";
|
|---|
| 136 | for (Int_t i=0;i<6;i++) *fLog << fSigmabarSector[i] << " ";
|
|---|
| 137 | *fLog << endl;
|
|---|
| 138 | *fLog << "Sigmabar Inner " << fSigmabarInner;
|
|---|
| 139 | *fLog << " Sectors: ";
|
|---|
| 140 | for (Int_t i=0;i<6;i++) *fLog << fSigmabarInnerSector[i] << " ";
|
|---|
| 141 | *fLog << endl;
|
|---|
| 142 | *fLog << "Sigmabar Outer " << fSigmabarOuter;
|
|---|
| 143 | *fLog << " Sectors: ";
|
|---|
| 144 | for (Int_t i=0;i<6;i++) *fLog << fSigmabarOuterSector[i] << " ";
|
|---|
| 145 | *fLog << endl;
|
|---|
| 146 | *fLog << "Total number of inner pixels found is " << fInnerPixels << endl;
|
|---|
| 147 | *fLog << "Total number of outer pixels found is " << fOuterPixels << endl;
|
|---|
| 148 | *fLog << "Ratio of areas outer/inner pixels found is " << fRatioA << endl;
|
|---|
| 149 | *fLog << endl;
|
|---|
| 150 | }
|
|---|