| 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): Markus Gaug 02/2004 <mailto:markus@ifae.es>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MHPedestalPix
|
|---|
| 28 | //
|
|---|
| 29 | // Histogram class for pedestal analysis.
|
|---|
| 30 | // Stores and fits the pedestals taken from MPedestalPix on an event-by-event
|
|---|
| 31 | // basis. The results are re-normalized to a value per slice with the formulae:
|
|---|
| 32 | //
|
|---|
| 33 | // - Mean Pedestal / slice = Mean Pedestal / Number slices
|
|---|
| 34 | // - Mean Pedestal Error / slice = Mean Pedestal Error / Number slices
|
|---|
| 35 | // - Sigma Pedestal / slice = Sigma Pedestal / Sqrt (Number slices)
|
|---|
| 36 | // - Sigma Pedestal Error / slice = Sigma Pedestal Error / Sqrt (Number slices)
|
|---|
| 37 | //
|
|---|
| 38 | // Derives from MHGausEvents, fits the pedestals to a Gaussian and performs
|
|---|
| 39 | // a Fourier analysis.
|
|---|
| 40 | //
|
|---|
| 41 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 42 | #include "MHPedestalPix.h"
|
|---|
| 43 |
|
|---|
| 44 | #include "MLog.h"
|
|---|
| 45 | #include "MLogManip.h"
|
|---|
| 46 |
|
|---|
| 47 | #include <TH1.h>
|
|---|
| 48 |
|
|---|
| 49 | ClassImp(MHPedestalPix);
|
|---|
| 50 |
|
|---|
| 51 | using namespace std;
|
|---|
| 52 | //
|
|---|
| 53 | const Int_t MHPedestalPix::fgChargeNbins = 500;
|
|---|
| 54 | const Axis_t MHPedestalPix::fgChargeFirst = -49.5;
|
|---|
| 55 | const Axis_t MHPedestalPix::fgChargeLast = 449.5;
|
|---|
| 56 | // --------------------------------------------------------------------------
|
|---|
| 57 | //
|
|---|
| 58 | // Default Constructor.
|
|---|
| 59 | //
|
|---|
| 60 | // Sets:
|
|---|
| 61 | // - the default number for fNbins (fgChargeNbins)
|
|---|
| 62 | // - the default number for fFirst (fgChargeFirst)
|
|---|
| 63 | // - the default number for fLast (fgChargeLast)
|
|---|
| 64 | //
|
|---|
| 65 | // - the default name of the fHGausHist ("HPedestalCharge")
|
|---|
| 66 | // - the default title of the fHGausHist ("Distribution of Summed FADC Pedestal slices Pixel ")
|
|---|
| 67 | // - the default x-axis title for fHGausHist ("Sum FADC Slices")
|
|---|
| 68 | // - the default y-axis title for fHGausHist ("Nr. of events")
|
|---|
| 69 | // - TH1::Sumw2() for fHGausHist
|
|---|
| 70 | //
|
|---|
| 71 | // Initializes:
|
|---|
| 72 | // - fNSlices to 1
|
|---|
| 73 | //
|
|---|
| 74 | MHPedestalPix::MHPedestalPix(const char *name, const char *title)
|
|---|
| 75 | : fNSlices(1)
|
|---|
| 76 | {
|
|---|
| 77 |
|
|---|
| 78 | fName = name ? name : "MHPedestalPix";
|
|---|
| 79 | fTitle = title ? title : "Histogrammed Pedestal events";
|
|---|
| 80 |
|
|---|
| 81 | SetNbins( fgChargeNbins );
|
|---|
| 82 | SetFirst( fgChargeFirst );
|
|---|
| 83 | SetLast( fgChargeLast );
|
|---|
| 84 |
|
|---|
| 85 | // Create a large number of bins, later we will rebin
|
|---|
| 86 | fHGausHist.SetName("HPedestalCharge");
|
|---|
| 87 | fHGausHist.SetTitle("Distribution of Summed FADC Pedestal Slices Pixel ");
|
|---|
| 88 | fHGausHist.SetXTitle("Sum FADC Slices");
|
|---|
| 89 | fHGausHist.SetYTitle("Nr. of events");
|
|---|
| 90 | fHGausHist.Sumw2();
|
|---|
| 91 |
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | // --------------------------------------------------------------------------
|
|---|
| 95 | //
|
|---|
| 96 | // If mean and sigma have not yet been set, returns.
|
|---|
| 97 | //
|
|---|
| 98 | // Renormalizes the pedestal fit results by the following formulae:
|
|---|
| 99 | //
|
|---|
| 100 | // - Mean Pedestal / slice = Mean Pedestal / Number slices
|
|---|
| 101 | // - Mean Pedestal Error / slice = Mean Pedestal Error / Number slices
|
|---|
| 102 | // - Sigma Pedestal / slice = Sigma Pedestal / Sqrt (Number slices)
|
|---|
| 103 | // - Sigma Pedestal Error / slice = Sigma Pedestal Error / Sqrt (Number slices)
|
|---|
| 104 | //
|
|---|
| 105 | void MHPedestalPix::Renorm()
|
|---|
| 106 | {
|
|---|
| 107 |
|
|---|
| 108 | //
|
|---|
| 109 | // One never knows...
|
|---|
| 110 | //
|
|---|
| 111 | if (fNSlices <= 0)
|
|---|
| 112 | return;
|
|---|
| 113 |
|
|---|
| 114 | const Float_t sqslices = TMath::Sqrt(fNSlices);
|
|---|
| 115 |
|
|---|
| 116 | SetMean ( GetMean() / fNSlices );
|
|---|
| 117 | //
|
|---|
| 118 | // Mean error goes with PedestalRMS/Sqrt(entries) -> scale with slices
|
|---|
| 119 | //
|
|---|
| 120 | SetMeanErr ( GetMeanErr() / fNSlices );
|
|---|
| 121 | //
|
|---|
| 122 | // Sigma goes like PedestalRMS -> scale with sqrt(slices)
|
|---|
| 123 | //
|
|---|
| 124 | SetSigma ( GetSigma() / sqslices );
|
|---|
| 125 | //
|
|---|
| 126 | // Sigma error goes like PedestalRMS/2.(entries) -> scale with sqrt(slices)
|
|---|
| 127 | //
|
|---|
| 128 | SetSigmaErr ( GetSigmaErr() / sqslices );
|
|---|
| 129 |
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|