| 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 | // --------------------------------------------------------------------------
|
|---|
| 43 | //
|
|---|
| 44 | // Default Constructor.
|
|---|
| 45 | //
|
|---|
| 46 | MCalibrationPix::MCalibrationPix(const char *name, const char *title)
|
|---|
| 47 | : fPixId(-1),
|
|---|
| 48 | fCharge(-1.),
|
|---|
| 49 | fErrCharge(-1.),
|
|---|
| 50 | fSigmaCharge(-1.),
|
|---|
| 51 | fErrSigmaCharge(-1.),
|
|---|
| 52 | fRSigma(-1.),
|
|---|
| 53 | fChargeProb(-1.),
|
|---|
| 54 | fPed(-1.),
|
|---|
| 55 | fPedRms(-1.),
|
|---|
| 56 | fTime(-1.),
|
|---|
| 57 | fSigmaTime(-1.),
|
|---|
| 58 | fTimeProb(-1.),
|
|---|
| 59 | fFactor(1.3),
|
|---|
| 60 | fPheFFactorMethod(-1.),
|
|---|
| 61 | fConversionFFactorMethod(-1.),
|
|---|
| 62 | fHiGainSaturation(kFALSE),
|
|---|
| 63 | fLoGainPedRms(4.)
|
|---|
| 64 | {
|
|---|
| 65 |
|
|---|
| 66 | fName = name ? name : "MCalibrationPixel";
|
|---|
| 67 | fTitle = title ? title : "Container of the MHCalibrationPixels and the fit results";
|
|---|
| 68 |
|
|---|
| 69 | fHist = new MHCalibrationPixel("MHCalibrationPixel","Calibration Histograms Pixel ");
|
|---|
| 70 |
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | MCalibrationPix::~MCalibrationPix()
|
|---|
| 74 | {
|
|---|
| 75 | delete fHist;
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 | void MCalibrationPix::DefinePixId(Int_t i)
|
|---|
| 80 | {
|
|---|
| 81 |
|
|---|
| 82 | fPixId = i;
|
|---|
| 83 | fHist->ChangeHistId(i);
|
|---|
| 84 |
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 | // ------------------------------------------------------------------------
|
|---|
| 89 | //
|
|---|
| 90 | // Invalidate values
|
|---|
| 91 | //
|
|---|
| 92 | void MCalibrationPix::Clear(Option_t *o)
|
|---|
| 93 | {
|
|---|
| 94 | fHist->Reset();
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | Bool_t MCalibrationPix::FitCharge()
|
|---|
| 98 | {
|
|---|
| 99 |
|
|---|
| 100 | if (fHist->IsFitOK())
|
|---|
| 101 | return kTRUE;
|
|---|
| 102 |
|
|---|
| 103 | if (fPed && fPedRms)
|
|---|
| 104 | fHist->SetLowerFitRange(1.5*fPedRms);
|
|---|
| 105 |
|
|---|
| 106 | else
|
|---|
| 107 | *fLog << warn << "Cannot set lower fit range to suppress cosmics: Pedestals not available" << endl;
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 | if (fHist->UseLoGain())
|
|---|
| 111 | {
|
|---|
| 112 | SetHiGainSaturation();
|
|---|
| 113 |
|
|---|
| 114 | if(!fHist->FitChargeLoGain())
|
|---|
| 115 | {
|
|---|
| 116 | *fLog << warn << "Could not fit Lo Gain charges of pixel " << fPixId << endl;
|
|---|
| 117 | fHist->PrintChargeFitResult();
|
|---|
| 118 | // return kFALSE;
|
|---|
| 119 | }
|
|---|
| 120 | }
|
|---|
| 121 | else
|
|---|
| 122 | {
|
|---|
| 123 | if(!fHist->FitChargeHiGain())
|
|---|
| 124 | {
|
|---|
| 125 | *fLog << warn << "Could not fit Hi Gain charges of pixel " << fPixId << endl;
|
|---|
| 126 | fHist->PrintChargeFitResult();
|
|---|
| 127 | // return kFALSE;
|
|---|
| 128 | }
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 | fCharge = fHist->GetChargeMean();
|
|---|
| 133 | fErrCharge = fHist->GetChargeMeanErr();
|
|---|
| 134 | fSigmaCharge = fHist->GetChargeSigma();
|
|---|
| 135 | fErrSigmaCharge = fHist->GetChargeSigmaErr();
|
|---|
| 136 | fChargeProb = fHist->GetChargeProb();
|
|---|
| 137 |
|
|---|
| 138 | if ((fPed > 0.) && (fPedRms > 0.))
|
|---|
| 139 | {
|
|---|
| 140 |
|
|---|
| 141 | if (fHiGainSaturation)
|
|---|
| 142 | fRSigma = (fSigmaCharge*fSigmaCharge) - (fLoGainPedRms*fLoGainPedRms);
|
|---|
| 143 | else
|
|---|
| 144 | fRSigma = (fSigmaCharge*fSigmaCharge) - (fPedRms*fPedRms);
|
|---|
| 145 |
|
|---|
| 146 | if (fRSigma > 0. )
|
|---|
| 147 | {
|
|---|
| 148 | fPheFFactorMethod = fFactor * fCharge*fCharge / fRSigma;
|
|---|
| 149 | fConversionFFactorMethod = fPheFFactorMethod / fCharge ;
|
|---|
| 150 | }
|
|---|
| 151 | else
|
|---|
| 152 | {
|
|---|
| 153 | *fLog << warn << "Cannot apply F-Factor method: Reduced Sigmas are smaller than 0 in pixel: "
|
|---|
| 154 | << fPixId << endl;
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | return kTRUE;
|
|---|
| 160 |
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 | void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)
|
|---|
| 165 | {
|
|---|
| 166 |
|
|---|
| 167 | fPed = ped;
|
|---|
| 168 | fPedRms = pedrms;
|
|---|
| 169 |
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | Bool_t MCalibrationPix::FitTime()
|
|---|
| 173 | {
|
|---|
| 174 |
|
|---|
| 175 | if (fHiGainSaturation)
|
|---|
| 176 | {
|
|---|
| 177 | if(!fHist->FitTimeLoGain())
|
|---|
| 178 | {
|
|---|
| 179 | *fLog << warn << "Could not fit Lo Gain times of pixel " << fPixId << endl;
|
|---|
| 180 | fHist->PrintTimeFitResult();
|
|---|
| 181 | return kFALSE;
|
|---|
| 182 | }
|
|---|
| 183 | }
|
|---|
| 184 | else
|
|---|
| 185 | {
|
|---|
| 186 | if(!fHist->FitTimeHiGain())
|
|---|
| 187 | {
|
|---|
| 188 | *fLog << warn << "Could not fit Hi Gain times of pixel " << fPixId << endl;
|
|---|
| 189 | fHist->PrintTimeFitResult();
|
|---|
| 190 | return kFALSE;
|
|---|
| 191 | }
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | fTime = fHist->GetTimeMean();
|
|---|
| 195 | fSigmaTime = fHist->GetTimeSigma();
|
|---|
| 196 | fTimeProb = fHist->GetTimeProb();
|
|---|
| 197 |
|
|---|
| 198 | return kTRUE;
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|