| 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 11/2003 <mailto:markus@ifae.es>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2001
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MCalibrationPix //
|
|---|
| 28 | // //
|
|---|
| 29 | // This is the storage container to hold informations about the pedestal //
|
|---|
| 30 | // (offset) value of one Pixel (PMT). //
|
|---|
| 31 | // //
|
|---|
| 32 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 33 | #include "MCalibrationPix.h"
|
|---|
| 34 |
|
|---|
| 35 | #include "MLog.h"
|
|---|
| 36 | #include "MLogManip.h"
|
|---|
| 37 |
|
|---|
| 38 | ClassImp(MCalibrationPix);
|
|---|
| 39 |
|
|---|
| 40 | using namespace std;
|
|---|
| 41 |
|
|---|
| 42 | static const TString gsDefHTitle = "Calibration Histograms Pixel ";
|
|---|
| 43 | // --------------------------------------------------------------------------
|
|---|
| 44 | //
|
|---|
| 45 | // Default Constructor.
|
|---|
| 46 | //
|
|---|
| 47 | MCalibrationPix::MCalibrationPix(Int_t pix, const char *name, const char *title)
|
|---|
| 48 | : fPixId(pix)
|
|---|
| 49 | {
|
|---|
| 50 |
|
|---|
| 51 | fName = name ? name : "MCalibrationPixel";
|
|---|
| 52 | fTitle = title ? title : "Container of the MHCalibrationPixels and the fit results";
|
|---|
| 53 |
|
|---|
| 54 | fHist = new MHCalibrationPixel(fPixId,"MHCalibrationPixel",gsDefHTitle.Data()+fPixId);
|
|---|
| 55 |
|
|---|
| 56 | fQ = fErrQ = 0.;
|
|---|
| 57 | fPed = fPedRms = 0.;
|
|---|
| 58 | fT = fSigmaT = 0.;
|
|---|
| 59 | fRQ = fErrRQ = 0.;
|
|---|
| 60 | fSigmaQ = fErrSigmaQ = 0.;
|
|---|
| 61 | fQProb = 0.;
|
|---|
| 62 |
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | MCalibrationPix::~MCalibrationPix()
|
|---|
| 66 | {
|
|---|
| 67 | delete fHist;
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | // ------------------------------------------------------------------------
|
|---|
| 71 | //
|
|---|
| 72 | // Invalidate values
|
|---|
| 73 | //
|
|---|
| 74 | void MCalibrationPix::Clear(Option_t *o)
|
|---|
| 75 | {
|
|---|
| 76 | fHist->Reset();
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | Bool_t MCalibrationPix::FitQ()
|
|---|
| 80 | {
|
|---|
| 81 |
|
|---|
| 82 | if (fHist->IsFitted())
|
|---|
| 83 | return kTRUE;
|
|---|
| 84 |
|
|---|
| 85 | if(!fHist->FitQ())
|
|---|
| 86 | {
|
|---|
| 87 | *fLog << warn << "Could not fit charges of pixel " << fPixId << endl;
|
|---|
| 88 | fHist->PrintQFitResult();
|
|---|
| 89 | return kFALSE;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | fQ = fHist->GetQMean();
|
|---|
| 93 | fErrQ = fHist->GetQMeanErr();
|
|---|
| 94 | fSigmaQ = fHist->GetQSigma();
|
|---|
| 95 | fErrSigmaQ = fHist->GetQSigmaErr();
|
|---|
| 96 | fQProb = fHist->GetQProb();
|
|---|
| 97 |
|
|---|
| 98 | if (fPed)
|
|---|
| 99 | fRQ = fQ - fPed;
|
|---|
| 100 | if (fPedRms)
|
|---|
| 101 | fErrRQ = TMath::Sqrt(fErrQ*fErrQ + fPedRms*fPedRms);
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 | return kTRUE;
|
|---|
| 105 |
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
|
|---|
| 109 | {
|
|---|
| 110 |
|
|---|
| 111 | fPed = ped;
|
|---|
| 112 | fPedRms = pedrms;
|
|---|
| 113 |
|
|---|
| 114 | if ((!fRQ) && fQ)
|
|---|
| 115 | fRQ = fQ - fPed;
|
|---|
| 116 | if ((!fErrRQ) && fErrQ)
|
|---|
| 117 | fErrRQ = TMath::Sqrt(fErrQ*fErrQ + fPedRms*fPedRms);
|
|---|
| 118 |
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | Bool_t MCalibrationPix::FitT()
|
|---|
| 122 | {
|
|---|
| 123 |
|
|---|
| 124 | if(!fHist->FitT())
|
|---|
| 125 | {
|
|---|
| 126 | *fLog << warn << "Could not fit times of pixel " << fPixId << endl;
|
|---|
| 127 | fHist->PrintTFitResult();
|
|---|
| 128 | return kFALSE;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | fT = fHist->GetTMean();
|
|---|
| 132 | fSigmaT = fHist->GetTSigma();
|
|---|
| 133 | fTProb = fHist->GetTProb();
|
|---|
| 134 |
|
|---|
| 135 | return kTRUE;
|
|---|
| 136 |
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | void MCalibrationPix::Test()
|
|---|
| 140 | {
|
|---|
| 141 | *fLog << "TEST: pixid: " << fPixId << endl;
|
|---|
| 142 | }
|
|---|