| 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 | // MHCalibrationChargeBlindPix
|
|---|
| 28 | //
|
|---|
| 29 | // Histogram class for the charge calibration of the Blind Pixel.
|
|---|
| 30 | // Stores and fits the charges and stores the averaged assumed pedestal and
|
|---|
| 31 | // single-phe FADC slice entries. Charges are taken from MExtractedSignalBlindPix.
|
|---|
| 32 | // Performs the Single Photo-electron fit to extract the Poisson mean and its errors.
|
|---|
| 33 | //
|
|---|
| 34 | // Different fits can be chosen with the function ChangeFitFunc().
|
|---|
| 35 | //
|
|---|
| 36 | // The fit result is accepted under the condition that:
|
|---|
| 37 | // 1) the Probability is greater than fProbLimit (default 0.001 == 99.7%)
|
|---|
| 38 | // 2) at least fNumSinglePheLimit events are found in the single Photo-electron peak
|
|---|
| 39 | //
|
|---|
| 40 | // The single FADC slice entries are averaged and stored in fASinglePheFADCSlices, if
|
|---|
| 41 | // their sum exceeds fSinglePheCut, otherwise in fAPedestalFADCSlices.
|
|---|
| 42 | //
|
|---|
| 43 | // Used numbers are the following:
|
|---|
| 44 | //
|
|---|
| 45 | // Electronic conversion factor:
|
|---|
| 46 | // Assume, we have N_e electrons at the anode,
|
|---|
| 47 | // thus a charge of N_e*e (e = electron charge) Coulomb.
|
|---|
| 48 | //
|
|---|
| 49 | // This charge is AC coupled and runs into a R_pre = 50 Ohm resistency.
|
|---|
| 50 | // The corresponding current is amplified by a gain factor G_pre = 400
|
|---|
| 51 | // (the precision of this value still has to be checked !!!) and again AC coupled to
|
|---|
| 52 | // the output.
|
|---|
| 53 | // The corresponding signal goes through the whole transmission and
|
|---|
| 54 | // amplification chain and is digitized in the FADCs.
|
|---|
| 55 | // The conversion Signal Area to FADC counts (Conv_trans) has been measured
|
|---|
| 56 | // by David and Oscar to be approx. 3.9 pVs^-1
|
|---|
| 57 | //
|
|---|
| 58 | // Thus: Conversion FADC counts to Number of Electrons at Anode:
|
|---|
| 59 | // FADC counts = (1/Conv_tran) * G_pre * R_pre * e * N_e = 8 * 10^-4 N_e.
|
|---|
| 60 | //
|
|---|
| 61 | // Also: FADC counts = 8*10^-4 * GAIN * N_phe
|
|---|
| 62 | //
|
|---|
| 63 | // In the blind pixel, there is an additional pre-amplifier with an amplification of
|
|---|
| 64 | // about 10. Therefore, we have for the blind pixel:
|
|---|
| 65 | //
|
|---|
| 66 | // FADC counts (Blind Pixel) = 8*10^-3 * GAIN * N_phe
|
|---|
| 67 | //
|
|---|
| 68 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 69 | #include "MHCalibrationChargeBlindPix.h"
|
|---|
| 70 |
|
|---|
| 71 | #include <TStyle.h>
|
|---|
| 72 | #include <TCanvas.h>
|
|---|
| 73 | #include <TPaveText.h>
|
|---|
| 74 |
|
|---|
| 75 | #include <TVector.h>
|
|---|
| 76 | #include <TF1.h>
|
|---|
| 77 | #include <TH1.h>
|
|---|
| 78 | #include <TRandom.h>
|
|---|
| 79 |
|
|---|
| 80 | #include "MLog.h"
|
|---|
| 81 | #include "MLogManip.h"
|
|---|
| 82 |
|
|---|
| 83 | #include "MParList.h"
|
|---|
| 84 |
|
|---|
| 85 | #include "MRawEvtData.h"
|
|---|
| 86 | #include "MRawEvtPixelIter.h"
|
|---|
| 87 |
|
|---|
| 88 | #include "MExtractedSignalBlindPixel.h"
|
|---|
| 89 | #include "MCalibrationChargeBlindPix.h"
|
|---|
| 90 |
|
|---|
| 91 | ClassImp(MHCalibrationChargeBlindPix);
|
|---|
| 92 |
|
|---|
| 93 | using namespace std;
|
|---|
| 94 |
|
|---|
| 95 | const Double_t MHCalibrationChargeBlindPix::gkElectronicAmp = 0.008;
|
|---|
| 96 | const Double_t MHCalibrationChargeBlindPix::gkElectronicAmpErr = 0.002;
|
|---|
| 97 |
|
|---|
| 98 | const Int_t MHCalibrationChargeBlindPix::fgChargeNbins = 300;
|
|---|
| 99 | const Axis_t MHCalibrationChargeBlindPix::fgChargeFirst = -100.5;
|
|---|
| 100 | const Axis_t MHCalibrationChargeBlindPix::fgChargeLast = 5199.5;
|
|---|
| 101 | const Float_t MHCalibrationChargeBlindPix::fgSinglePheCut = 200.;
|
|---|
| 102 | const Float_t MHCalibrationChargeBlindPix::fgNumSinglePheLimit = 50.;
|
|---|
| 103 | // --------------------------------------------------------------------------
|
|---|
| 104 | //
|
|---|
| 105 | // Default Constructor.
|
|---|
| 106 | //
|
|---|
| 107 | // Sets:
|
|---|
| 108 | // - the default number for fNbins (fgChargeNbins)
|
|---|
| 109 | // - the default number for fFirst (fgChargeFirst)
|
|---|
| 110 | // - the default number for fLast (fgChargeLast)
|
|---|
| 111 | // - the default number for fSinglePheCut (fgSingePheCut)
|
|---|
| 112 | // - the default number for fNumSinglePheLimit (fgNumSinglePheLimit)
|
|---|
| 113 | // - the default number of bins after stripping (30)
|
|---|
| 114 | //
|
|---|
| 115 | // - the default name of the fHGausHist ("HCalibrationChargeBlindPix")
|
|---|
| 116 | // - the default title of the fHGausHist ("Distribution of Summed FADC slices Blind Pixel ")
|
|---|
| 117 | // - the default x-axis title for fHGausHist ("Sum FADC Slices")
|
|---|
| 118 | // - the default y-axis title for fHGausHist ("Nr. of events")
|
|---|
| 119 | //
|
|---|
| 120 | // Initializes:
|
|---|
| 121 | // - all pointers to NULL
|
|---|
| 122 | // - fASinglePheFADCSlices(0);
|
|---|
| 123 | // - fAPedestalFADCSlices(0);
|
|---|
| 124 | //
|
|---|
| 125 | // Calls:
|
|---|
| 126 | // - Clear()
|
|---|
| 127 | //
|
|---|
| 128 | MHCalibrationChargeBlindPix::MHCalibrationChargeBlindPix(const char *name, const char *title)
|
|---|
| 129 | : fBlindPix(NULL), fSignal(NULL), fRawEvt(NULL),
|
|---|
| 130 | fSinglePheFit(NULL),
|
|---|
| 131 | fFitLegend(NULL),
|
|---|
| 132 | fHSinglePheFADCSlices(NULL), fHPedestalFADCSlices(NULL)
|
|---|
| 133 | {
|
|---|
| 134 |
|
|---|
| 135 | fName = name ? name : "MHCalibrationChargeBlindPix";
|
|---|
| 136 | fTitle = title ? title : "Statistics of the FADC sums of Blind Pixel calibration events";
|
|---|
| 137 |
|
|---|
| 138 | SetNbins( fgChargeNbins );
|
|---|
| 139 | SetFirst( fgChargeFirst );
|
|---|
| 140 | SetLast ( fgChargeLast );
|
|---|
| 141 |
|
|---|
| 142 | fASinglePheFADCSlices.ResizeTo(1);
|
|---|
| 143 | fAPedestalFADCSlices.ResizeTo(1);
|
|---|
| 144 |
|
|---|
| 145 | SetSinglePheCut();
|
|---|
| 146 | SetNumSinglePheLimit();
|
|---|
| 147 |
|
|---|
| 148 | SetBinsAfterStripping(30);
|
|---|
| 149 |
|
|---|
| 150 | fHGausHist.SetName("HCalibrationChargeBlindPix");
|
|---|
| 151 | fHGausHist.SetTitle("Distribution of Summed FADC slices Blind Pixel");
|
|---|
| 152 | fHGausHist.SetXTitle("Sum FADC Slices");
|
|---|
| 153 | fHGausHist.SetYTitle("Nr. of events");
|
|---|
| 154 |
|
|---|
| 155 | Clear();
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | // --------------------------------------------------------------------------
|
|---|
| 159 | //
|
|---|
| 160 | // Default Destructor.
|
|---|
| 161 | //
|
|---|
| 162 | // Deletes (if Pointer is not NULL):
|
|---|
| 163 | //
|
|---|
| 164 | // - fSinglePheFit
|
|---|
| 165 | // - fFitLegend
|
|---|
| 166 | // - fHSinglePheFADCSlices
|
|---|
| 167 | // - fHPedestalFADCSlices
|
|---|
| 168 | //
|
|---|
| 169 | MHCalibrationChargeBlindPix::~MHCalibrationChargeBlindPix()
|
|---|
| 170 | {
|
|---|
| 171 |
|
|---|
| 172 | if (fSinglePheFit)
|
|---|
| 173 | delete fSinglePheFit;
|
|---|
| 174 |
|
|---|
| 175 | if (fFitLegend)
|
|---|
| 176 | delete fFitLegend;
|
|---|
| 177 |
|
|---|
| 178 | if (fHSinglePheFADCSlices)
|
|---|
| 179 | delete fHSinglePheFADCSlices;
|
|---|
| 180 |
|
|---|
| 181 | if (fHPedestalFADCSlices)
|
|---|
| 182 | delete fHPedestalFADCSlices;
|
|---|
| 183 |
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | // --------------------------------------------------------------------------
|
|---|
| 187 | //
|
|---|
| 188 | // Sets:
|
|---|
| 189 | // - all variables to 0., except the fit result variables to -999.
|
|---|
| 190 | // - all flags to kFALSE
|
|---|
| 191 | // - all pointers to NULL
|
|---|
| 192 | // - the default fit function (kEPoisson5)
|
|---|
| 193 | //
|
|---|
| 194 | // Deletes:
|
|---|
| 195 | // - all pointers unequal NULL
|
|---|
| 196 | //
|
|---|
| 197 | // Calls:
|
|---|
| 198 | // - MHCalibrationChargePix::Clear()
|
|---|
| 199 | //
|
|---|
| 200 | void MHCalibrationChargeBlindPix::Clear(Option_t *o)
|
|---|
| 201 | {
|
|---|
| 202 |
|
|---|
| 203 | fLambda = -999.;
|
|---|
| 204 | fMu0 = -999.;
|
|---|
| 205 | fMu1 = -999.;
|
|---|
| 206 | fSigma0 = -999.;
|
|---|
| 207 | fSigma1 = -999.;
|
|---|
| 208 |
|
|---|
| 209 | fLambdaErr = -999.;
|
|---|
| 210 | fMu0Err = -999.;
|
|---|
| 211 | fMu1Err = -999.;
|
|---|
| 212 | fSigma0Err = -999.;
|
|---|
| 213 | fSigma1Err = -999.;
|
|---|
| 214 |
|
|---|
| 215 | fLambdaCheck = -999.;
|
|---|
| 216 | fLambdaCheckErr = -999.;
|
|---|
| 217 |
|
|---|
| 218 | fFitFunc = kEPoisson5;
|
|---|
| 219 |
|
|---|
| 220 | fNumSinglePhes = 0;
|
|---|
| 221 | fNumPedestals = 0;
|
|---|
| 222 |
|
|---|
| 223 | fChisquare = 0.;
|
|---|
| 224 | fNDF = 0 ;
|
|---|
| 225 | fProb = 0.;
|
|---|
| 226 |
|
|---|
| 227 | SetSinglePheFitOK ( kFALSE );
|
|---|
| 228 | SetPedestalFitOK ( kFALSE );
|
|---|
| 229 |
|
|---|
| 230 | if (fFitLegend)
|
|---|
| 231 | {
|
|---|
| 232 | delete fFitLegend;
|
|---|
| 233 | fFitLegend = NULL;
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | if (fSinglePheFit)
|
|---|
| 237 | {
|
|---|
| 238 | delete fSinglePheFit;
|
|---|
| 239 | fSinglePheFit = NULL;
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | if (fHSinglePheFADCSlices)
|
|---|
| 243 | {
|
|---|
| 244 | delete fHSinglePheFADCSlices;
|
|---|
| 245 | fHSinglePheFADCSlices = NULL;
|
|---|
| 246 | }
|
|---|
| 247 |
|
|---|
| 248 | if (fHPedestalFADCSlices)
|
|---|
| 249 | {
|
|---|
| 250 | delete fHPedestalFADCSlices;
|
|---|
| 251 | fHPedestalFADCSlices = NULL;
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 | MHCalibrationChargePix::Clear();
|
|---|
| 256 | return;
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 | // --------------------------------------------------------------------------
|
|---|
| 260 | //
|
|---|
| 261 | // Set bit kSinglePheFitOK from outside
|
|---|
| 262 | //
|
|---|
| 263 | void MHCalibrationChargeBlindPix::SetSinglePheFitOK (const Bool_t b)
|
|---|
| 264 | {
|
|---|
| 265 | b ? SETBIT(fFlags,kSinglePheFitOK) : CLRBIT(fFlags,kSinglePheFitOK);
|
|---|
| 266 | }
|
|---|
| 267 |
|
|---|
| 268 | // --------------------------------------------------------------------------
|
|---|
| 269 | //
|
|---|
| 270 | // Set bit kPedestalFitOK from outside
|
|---|
| 271 | //
|
|---|
| 272 | void MHCalibrationChargeBlindPix::SetPedestalFitOK(const Bool_t b)
|
|---|
| 273 | {
|
|---|
| 274 | b ? SETBIT(fFlags,kPedestalFitOK) : CLRBIT(fFlags,kPedestalFitOK);
|
|---|
| 275 | }
|
|---|
| 276 |
|
|---|
| 277 | // --------------------------------------------------------------------------
|
|---|
| 278 | //
|
|---|
| 279 | // Ask for status of bit kSinglePheFitOK
|
|---|
| 280 | //
|
|---|
| 281 | const Bool_t MHCalibrationChargeBlindPix::IsSinglePheFitOK() const
|
|---|
| 282 | {
|
|---|
| 283 | return TESTBIT(fFlags,kSinglePheFitOK);
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | // --------------------------------------------------------------------------
|
|---|
| 287 | //
|
|---|
| 288 | // Ask for status of bit kPedestalFitOK
|
|---|
| 289 | //
|
|---|
| 290 | const Bool_t MHCalibrationChargeBlindPix::IsPedestalFitOK() const
|
|---|
| 291 | {
|
|---|
| 292 | return TESTBIT(fFlags,kPedestalFitOK);
|
|---|
| 293 | }
|
|---|
| 294 |
|
|---|
| 295 | // --------------------------------------------------------------------------
|
|---|
| 296 | //
|
|---|
| 297 | // Gets the pointers to:
|
|---|
| 298 | // - MRawEvtData
|
|---|
| 299 | // - MExtractedSignalBlindPixel
|
|---|
| 300 | //
|
|---|
| 301 | // Calls:
|
|---|
| 302 | // - MHGausHist::InitBins()
|
|---|
| 303 | //
|
|---|
| 304 | Bool_t MHCalibrationChargeBlindPix::SetupFill(const MParList *pList)
|
|---|
| 305 | {
|
|---|
| 306 |
|
|---|
| 307 | fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
|
|---|
| 308 | if (!fRawEvt)
|
|---|
| 309 | {
|
|---|
| 310 | *fLog << err << "MRawEvtData not found... aborting." << endl;
|
|---|
| 311 | return kFALSE;
|
|---|
| 312 | }
|
|---|
| 313 |
|
|---|
| 314 | fSignal = (MExtractedSignalBlindPixel*)pList->FindObject("MExtractedSignalBlindPixel");
|
|---|
| 315 | if (!fSignal)
|
|---|
| 316 | {
|
|---|
| 317 | *fLog << err << "MExtractedSignalBlindPixel not found... aborting " << endl;
|
|---|
| 318 | return kFALSE;
|
|---|
| 319 | }
|
|---|
| 320 |
|
|---|
| 321 | InitBins();
|
|---|
| 322 |
|
|---|
| 323 | return kTRUE;
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 | // --------------------------------------------------------------------------
|
|---|
| 327 | //
|
|---|
| 328 | // Gets or creates the pointers to:
|
|---|
| 329 | // - MCalibrationChargeBlindPix
|
|---|
| 330 | //
|
|---|
| 331 | Bool_t MHCalibrationChargeBlindPix::ReInit(MParList *pList)
|
|---|
| 332 | {
|
|---|
| 333 |
|
|---|
| 334 | fBlindPix = (MCalibrationChargeBlindPix*)pList->FindCreateObj("MCalibrationChargeBlindPix");
|
|---|
| 335 | if (!fBlindPix)
|
|---|
| 336 | return kFALSE;
|
|---|
| 337 |
|
|---|
| 338 | return kTRUE;
|
|---|
| 339 | }
|
|---|
| 340 |
|
|---|
| 341 | // --------------------------------------------------------------------------
|
|---|
| 342 | //
|
|---|
| 343 | // Retrieves from MExtractedSignalBlindPixel:
|
|---|
| 344 | // - number of FADC samples
|
|---|
| 345 | // - extracted signal
|
|---|
| 346 | // - blind Pixel ID
|
|---|
| 347 | //
|
|---|
| 348 | // Resizes (if necessary):
|
|---|
| 349 | // - fASinglePheFADCSlices to sum of HiGain and LoGain samples
|
|---|
| 350 | // - fAPedestalFADCSlices to sum of HiGain and LoGain samples
|
|---|
| 351 | //
|
|---|
| 352 | // Fills the following histograms:
|
|---|
| 353 | // - MHGausEvents::FillHistAndArray(signal)
|
|---|
| 354 | //
|
|---|
| 355 | // Creates MRawEvtPixelIter, jumps to blind pixel ID,
|
|---|
| 356 | // fills the vectors fASinglePheFADCSlices and fAPedestalFADCSlices
|
|---|
| 357 | // with the full FADC slices, depending on the size of the signal w.r.t. fSinglePheCut
|
|---|
| 358 | //
|
|---|
| 359 | Bool_t MHCalibrationChargeBlindPix::Fill(const MParContainer *par, const Stat_t w)
|
|---|
| 360 | {
|
|---|
| 361 |
|
|---|
| 362 | const Int_t samples = (Int_t)fRawEvt->GetNumHiGainSamples()+(Int_t)fRawEvt->GetNumLoGainSamples();
|
|---|
| 363 |
|
|---|
| 364 | if (!fASinglePheFADCSlices.IsValid())
|
|---|
| 365 | {
|
|---|
| 366 | fASinglePheFADCSlices.ResizeTo(samples);
|
|---|
| 367 | fAPedestalFADCSlices.ResizeTo(samples);
|
|---|
| 368 | }
|
|---|
| 369 |
|
|---|
| 370 | if (fASinglePheFADCSlices.GetNrows() != samples)
|
|---|
| 371 | {
|
|---|
| 372 | fASinglePheFADCSlices.ResizeTo(samples);
|
|---|
| 373 | fAPedestalFADCSlices.ResizeTo(samples);
|
|---|
| 374 | }
|
|---|
| 375 |
|
|---|
| 376 | Float_t slices = (Float_t)fSignal->GetNumFADCSamples();
|
|---|
| 377 |
|
|---|
| 378 | if (slices == 0.)
|
|---|
| 379 | {
|
|---|
| 380 | *fLog << err << "Number of used signal slices in MExtractedSignalBlindPix is zero ... abort."
|
|---|
| 381 | << endl;
|
|---|
| 382 | return kFALSE;
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | //
|
|---|
| 386 | // Signal extraction and histogram filling
|
|---|
| 387 | //
|
|---|
| 388 | const Float_t signal = (Float_t)fSignal->GetExtractedSignal();
|
|---|
| 389 | if (signal > -1)
|
|---|
| 390 | FillHistAndArray(signal);
|
|---|
| 391 |
|
|---|
| 392 | //
|
|---|
| 393 | // IN order to study the single-phe posistion, we extract the slices
|
|---|
| 394 | //
|
|---|
| 395 | const Int_t blindpixIdx = fSignal->GetBlindPixelIdx();
|
|---|
| 396 |
|
|---|
| 397 | MRawEvtPixelIter pixel(fRawEvt);
|
|---|
| 398 | pixel.Jump(blindpixIdx);
|
|---|
| 399 |
|
|---|
| 400 | if (signal > fSinglePheCut)
|
|---|
| 401 | FillSinglePheFADCSlices(pixel);
|
|---|
| 402 | else
|
|---|
| 403 | FillPedestalFADCSlices(pixel);
|
|---|
| 404 |
|
|---|
| 405 | return kTRUE;
|
|---|
| 406 | }
|
|---|
| 407 |
|
|---|
| 408 | // --------------------------------------------------------------------------
|
|---|
| 409 | //
|
|---|
| 410 | // Returns kFALSE, if empty
|
|---|
| 411 | //
|
|---|
| 412 | // - Creates the fourier spectrum and sets bit MHGausEvents::IsFourierSpectrumOK()
|
|---|
| 413 | // - Retrieves the pedestals from MExtractedSignalBlindPixel
|
|---|
| 414 | // - Normalizes fASinglePheFADCSlices and fAPedestalFADCSlices
|
|---|
| 415 | // - Executes FitPedestal()
|
|---|
| 416 | // - Executes FitSinglePhe()
|
|---|
| 417 | // - Retrieves fit results and stores them in MCalibrationChargeBlindPix
|
|---|
| 418 | //
|
|---|
| 419 | Bool_t MHCalibrationChargeBlindPix::Finalize()
|
|---|
| 420 | {
|
|---|
| 421 |
|
|---|
| 422 | if (IsEmpty())
|
|---|
| 423 | {
|
|---|
| 424 | *fLog << err << GetDescriptor() << ": My histogram has not been filled !! " << endl;
|
|---|
| 425 | return kFALSE;
|
|---|
| 426 | }
|
|---|
| 427 |
|
|---|
| 428 | CreateFourierSpectrum();
|
|---|
| 429 | fBlindPix->SetOscillating ( !IsFourierSpectrumOK() );
|
|---|
| 430 |
|
|---|
| 431 | fBlindPix->SetValid(kTRUE);
|
|---|
| 432 |
|
|---|
| 433 | fMeanPedestal = fSignal->GetPed();
|
|---|
| 434 | fMeanPedestalErr = fSignal->GetPedErr();
|
|---|
| 435 | fSigmaPedestal = fSignal->GetPedRms();
|
|---|
| 436 | fSigmaPedestalErr = fSignal->GetPedRmsErr();
|
|---|
| 437 |
|
|---|
| 438 | if (fNumSinglePhes > 1)
|
|---|
| 439 | for (Int_t i=0;i<fASinglePheFADCSlices.GetNrows();i++)
|
|---|
| 440 | fASinglePheFADCSlices[i] = fASinglePheFADCSlices[i]/fNumSinglePhes;
|
|---|
| 441 | if (fNumPedestals > 1)
|
|---|
| 442 | for (Int_t i=0;i<fAPedestalFADCSlices.GetNrows();i++)
|
|---|
| 443 | fAPedestalFADCSlices[i] = fAPedestalFADCSlices[i]/fNumPedestals;
|
|---|
| 444 |
|
|---|
| 445 | FitPedestal();
|
|---|
| 446 |
|
|---|
| 447 | if (FitSinglePhe())
|
|---|
| 448 | fBlindPix->SetSinglePheFitOK();
|
|---|
| 449 | else
|
|---|
| 450 | fBlindPix->SetValid(kFALSE);
|
|---|
| 451 |
|
|---|
| 452 | fBlindPix->SetLambda ( fLambda );
|
|---|
| 453 | fBlindPix->SetLambdaVar ( fLambdaErr*fLambdaErr );
|
|---|
| 454 | fBlindPix->SetMu0 ( fMu0 );
|
|---|
| 455 | fBlindPix->SetMu0Err ( fMu0Err );
|
|---|
| 456 | fBlindPix->SetMu1 ( fMu1 );
|
|---|
| 457 | fBlindPix->SetMu1Err ( fMu1Err );
|
|---|
| 458 | fBlindPix->SetSigma0 ( fSigma0 );
|
|---|
| 459 | fBlindPix->SetSigma0Err ( fSigma0Err );
|
|---|
| 460 | fBlindPix->SetSigma1 ( fSigma1 );
|
|---|
| 461 | fBlindPix->SetSigma1Err ( fSigma1Err );
|
|---|
| 462 | fBlindPix->SetProb ( fProb );
|
|---|
| 463 |
|
|---|
| 464 | fBlindPix->SetLambdaCheck ( fLambdaCheck );
|
|---|
| 465 | fBlindPix->SetLambdaCheckErr ( fLambdaCheckErr );
|
|---|
| 466 |
|
|---|
| 467 | return kTRUE;
|
|---|
| 468 | }
|
|---|
| 469 |
|
|---|
| 470 |
|
|---|
| 471 | // --------------------------------------------------------------------------
|
|---|
| 472 | //
|
|---|
| 473 | // Checks again for the size and fills fASinglePheFADCSlices with the FADC slice entries
|
|---|
| 474 | //
|
|---|
| 475 | void MHCalibrationChargeBlindPix::FillSinglePheFADCSlices(const MRawEvtPixelIter &iter)
|
|---|
| 476 | {
|
|---|
| 477 |
|
|---|
| 478 | const Int_t n = iter.GetNumHiGainSamples() + iter.GetNumLoGainSamples();
|
|---|
| 479 |
|
|---|
| 480 | if (fASinglePheFADCSlices.GetNrows() < n)
|
|---|
| 481 | fASinglePheFADCSlices.ResizeTo(n);
|
|---|
| 482 |
|
|---|
| 483 | Int_t i=0;
|
|---|
| 484 |
|
|---|
| 485 | Byte_t *start = iter.GetHiGainSamples();
|
|---|
| 486 | Byte_t *end = start + iter.GetNumHiGainSamples();
|
|---|
| 487 |
|
|---|
| 488 | for (Byte_t *ptr = start; ptr < end; ptr++, i++)
|
|---|
| 489 | fASinglePheFADCSlices(i) = fASinglePheFADCSlices(i) + (Float_t)*ptr;
|
|---|
| 490 |
|
|---|
| 491 | start = iter.GetLoGainSamples();
|
|---|
| 492 | end = start + iter.GetNumLoGainSamples();
|
|---|
| 493 |
|
|---|
| 494 | for (Byte_t *ptr = start; ptr < end; ptr++, i++)
|
|---|
| 495 | fASinglePheFADCSlices(i) = fASinglePheFADCSlices(i) + (Float_t)*ptr;
|
|---|
| 496 |
|
|---|
| 497 | fNumSinglePhes++;
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 | // --------------------------------------------------------------------------
|
|---|
| 501 | //
|
|---|
| 502 | // Checks again for the size and fills fAPedestalFADCSlices with the FADC slice entries
|
|---|
| 503 | //
|
|---|
| 504 | void MHCalibrationChargeBlindPix::FillPedestalFADCSlices(const MRawEvtPixelIter &iter)
|
|---|
| 505 | {
|
|---|
| 506 |
|
|---|
| 507 | const Int_t n = iter.GetNumHiGainSamples() + iter.GetNumLoGainSamples();
|
|---|
| 508 |
|
|---|
| 509 | if (fAPedestalFADCSlices.GetNrows() < n)
|
|---|
| 510 | fAPedestalFADCSlices.ResizeTo(n);
|
|---|
| 511 |
|
|---|
| 512 | Int_t i = 0;
|
|---|
| 513 | Byte_t *start = iter.GetHiGainSamples();
|
|---|
| 514 | Byte_t *end = start + iter.GetNumHiGainSamples();
|
|---|
| 515 |
|
|---|
| 516 | for (Byte_t *ptr = start; ptr < end; ptr++, i++)
|
|---|
| 517 | fAPedestalFADCSlices(i) = fAPedestalFADCSlices(i)+ (Float_t)*ptr;
|
|---|
| 518 |
|
|---|
| 519 | start = iter.GetLoGainSamples();
|
|---|
| 520 | end = start + iter.GetNumLoGainSamples();
|
|---|
| 521 |
|
|---|
| 522 | for (Byte_t *ptr = start; ptr < end; ptr++, i++)
|
|---|
| 523 | fAPedestalFADCSlices(i) = fAPedestalFADCSlices(i)+ (Float_t)*ptr;
|
|---|
| 524 |
|
|---|
| 525 | fNumPedestals++;
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 |
|
|---|
| 529 | // --------------------------------------------------------------------------
|
|---|
| 530 | //
|
|---|
| 531 | // Task to simulate single phe spectrum with the given parameters
|
|---|
| 532 | //
|
|---|
| 533 | Bool_t MHCalibrationChargeBlindPix::SimulateSinglePhe(Double_t lambda, Double_t mu0, Double_t mu1, Double_t sigma0, Double_t sigma1)
|
|---|
| 534 | {
|
|---|
| 535 |
|
|---|
| 536 | gRandom->SetSeed();
|
|---|
| 537 |
|
|---|
| 538 | if (fHGausHist.GetIntegral() != 0)
|
|---|
| 539 | {
|
|---|
| 540 | *fLog << err << "Histogram " << fHGausHist.GetTitle() << " is already filled. " << endl;
|
|---|
| 541 | *fLog << err << "Create new class MHCalibrationBlindPixel for simulation! " << endl;
|
|---|
| 542 | return kFALSE;
|
|---|
| 543 | }
|
|---|
| 544 |
|
|---|
| 545 | if (!InitFit())
|
|---|
| 546 | return kFALSE;
|
|---|
| 547 |
|
|---|
| 548 | for (Int_t i=0;i<10000; i++)
|
|---|
| 549 | fHGausHist.Fill(fSinglePheFit->GetRandom());
|
|---|
| 550 |
|
|---|
| 551 | return kTRUE;
|
|---|
| 552 | }
|
|---|
| 553 |
|
|---|
| 554 | // --------------------------------------------------------------------------
|
|---|
| 555 | //
|
|---|
| 556 | // - Get the ranges from the stripped histogram
|
|---|
| 557 | // - choose reasonable start values for the fit
|
|---|
| 558 | // - initialize the fit function depending on fFitFunc
|
|---|
| 559 | // - initialize parameter names and limits depending on fFitFunc
|
|---|
| 560 | //
|
|---|
| 561 | Bool_t MHCalibrationChargeBlindPix::InitFit()
|
|---|
| 562 | {
|
|---|
| 563 |
|
|---|
| 564 | //
|
|---|
| 565 | // Get the fitting ranges
|
|---|
| 566 | //
|
|---|
| 567 | Axis_t rmin = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetFirst());
|
|---|
| 568 | Axis_t rmax = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetLast());
|
|---|
| 569 |
|
|---|
| 570 | if (rmin < 0.)
|
|---|
| 571 | rmin = 0.;
|
|---|
| 572 |
|
|---|
| 573 | //
|
|---|
| 574 | // First guesses for the fit (should be as close to reality as possible,
|
|---|
| 575 | // otherwise the fit goes gaga because of high number of dimensions ...
|
|---|
| 576 | //
|
|---|
| 577 | const Stat_t entries = fHGausHist.Integral("width");
|
|---|
| 578 | const Double_t lambda_guess = 0.1;
|
|---|
| 579 | const Double_t maximum_bin = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
|
|---|
| 580 | const Double_t norm = entries/TMath::Sqrt(TMath::TwoPi());
|
|---|
| 581 |
|
|---|
| 582 | //
|
|---|
| 583 | // Initialize the fit function
|
|---|
| 584 | //
|
|---|
| 585 | switch (fFitFunc)
|
|---|
| 586 | {
|
|---|
| 587 | case kEPoisson4:
|
|---|
| 588 | fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto4,rmin,rmax,6);
|
|---|
| 589 | break;
|
|---|
| 590 | case kEPoisson5:
|
|---|
| 591 | fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto5,rmin,rmax,6);
|
|---|
| 592 | break;
|
|---|
| 593 | case kEPoisson6:
|
|---|
| 594 | fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto6,rmin,rmax,6);
|
|---|
| 595 | break;
|
|---|
| 596 | case kEPolya:
|
|---|
| 597 | fSinglePheFit = new TF1("SinglePheFit",&fPolya,rmin,rmax,8);
|
|---|
| 598 | break;
|
|---|
| 599 | case kEMichele:
|
|---|
| 600 | break;
|
|---|
| 601 |
|
|---|
| 602 | default:
|
|---|
| 603 | *fLog << warn << "WARNING: Could not find Fit Function for Blind Pixel " << endl;
|
|---|
| 604 | return kFALSE;
|
|---|
| 605 | break;
|
|---|
| 606 | }
|
|---|
| 607 |
|
|---|
| 608 | if (!fSinglePheFit)
|
|---|
| 609 | {
|
|---|
| 610 | *fLog << warn << dbginf << "WARNING: Could not create fit function for Single Phe fit" << endl;
|
|---|
| 611 | return kFALSE;
|
|---|
| 612 | }
|
|---|
| 613 |
|
|---|
| 614 | const Double_t mu_0_guess = maximum_bin;
|
|---|
| 615 | const Double_t si_0_guess = 40.;
|
|---|
| 616 | const Double_t mu_1_guess = mu_0_guess + 100.;
|
|---|
| 617 | const Double_t si_1_guess = si_0_guess + si_0_guess;
|
|---|
| 618 | // Michele
|
|---|
| 619 | // const Double_t lambda_1cat_guess = 0.5;
|
|---|
| 620 | // const Double_t lambda_1dyn_guess = 0.5;
|
|---|
| 621 | // const Double_t mu_1cat_guess = mu_0_guess + 50.;
|
|---|
| 622 | // const Double_t mu_1dyn_guess = mu_0_guess + 20.;
|
|---|
| 623 | // const Double_t si_1cat_guess = si_0_guess + si_0_guess;
|
|---|
| 624 | // const Double_t si_1dyn_guess = si_0_guess;
|
|---|
| 625 | // Polya
|
|---|
| 626 | const Double_t excessPoisson_guess = 0.5;
|
|---|
| 627 | const Double_t delta1_guess = 8.;
|
|---|
| 628 | const Double_t delta2_guess = 5.;
|
|---|
| 629 | const Double_t electronicAmp_guess = gkElectronicAmp;
|
|---|
| 630 | const Double_t electronicAmp_limit = gkElectronicAmpErr;
|
|---|
| 631 |
|
|---|
| 632 | //
|
|---|
| 633 | // Initialize boundaries and start parameters
|
|---|
| 634 | //
|
|---|
| 635 | switch (fFitFunc)
|
|---|
| 636 | {
|
|---|
| 637 |
|
|---|
| 638 | case kEPoisson4:
|
|---|
| 639 | fSinglePheFit->SetParNames( "#lambda", "#mu_{0}", "#mu_{1}", "#sigma_{0}", "#sigma_{1}","Area");
|
|---|
| 640 | fSinglePheFit->SetParameters(lambda_guess,fMeanPedestal,mu_1_guess,fSigmaPedestal,si_1_guess,norm);
|
|---|
| 641 |
|
|---|
| 642 | fSinglePheFit->SetParLimits(0,0.,0.5);
|
|---|
| 643 | fSinglePheFit->SetParLimits(1,
|
|---|
| 644 | fMeanPedestal-5.*fMeanPedestalErr,
|
|---|
| 645 | fMeanPedestal+5.*fMeanPedestalErr);
|
|---|
| 646 | fSinglePheFit->SetParLimits(2,rmin,rmax);
|
|---|
| 647 | fSinglePheFit->SetParLimits(3,
|
|---|
| 648 | fSigmaPedestal-5.*fSigmaPedestalErr,
|
|---|
| 649 | fSigmaPedestal+5.*fSigmaPedestalErr);
|
|---|
| 650 | fSinglePheFit->SetParLimits(4,0.,(rmax-rmin));
|
|---|
| 651 | fSinglePheFit->SetParLimits(5,norm-(0.5*norm),norm+(0.5*norm));
|
|---|
| 652 | break;
|
|---|
| 653 | case kEPoisson5:
|
|---|
| 654 | case kEPoisson6:
|
|---|
| 655 | fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm);
|
|---|
| 656 | fSinglePheFit->SetParNames("#lambda","#mu_{0}","#mu_{1}","#sigma_{0}","#sigma_{1}","Area");
|
|---|
| 657 | fSinglePheFit->SetParLimits(0,0.,1.);
|
|---|
| 658 | fSinglePheFit->SetParLimits(1,rmin,(rmax-rmin)/1.5);
|
|---|
| 659 | fSinglePheFit->SetParLimits(2,(rmax-rmin)/2.,(rmax-0.05*(rmax-rmin)));
|
|---|
| 660 | fSinglePheFit->SetParLimits(3,1.0,(rmax-rmin)/2.0);
|
|---|
| 661 | fSinglePheFit->SetParLimits(4,1.0,(rmax-rmin)/2.5);
|
|---|
| 662 | fSinglePheFit->SetParLimits(5,norm-0.1,norm+0.1);
|
|---|
| 663 | break;
|
|---|
| 664 |
|
|---|
| 665 | case kEPolya:
|
|---|
| 666 | fSinglePheFit->SetParameters(lambda_guess, excessPoisson_guess,
|
|---|
| 667 | delta1_guess,delta2_guess,
|
|---|
| 668 | electronicAmp_guess,
|
|---|
| 669 | fSigmaPedestal,
|
|---|
| 670 | norm,
|
|---|
| 671 | fMeanPedestal);
|
|---|
| 672 | fSinglePheFit->SetParNames("#lambda","b_{tot}",
|
|---|
| 673 | "#delta_{1}","#delta_{2}",
|
|---|
| 674 | "amp_{e}","#sigma_{0}",
|
|---|
| 675 | "Area", "#mu_{0}");
|
|---|
| 676 | fSinglePheFit->SetParLimits(0,0.,1.);
|
|---|
| 677 | fSinglePheFit->SetParLimits(1,0.,1.);
|
|---|
| 678 | fSinglePheFit->SetParLimits(2,6.,12.);
|
|---|
| 679 | fSinglePheFit->SetParLimits(3,3.,8.);
|
|---|
| 680 | fSinglePheFit->SetParLimits(4,electronicAmp_guess-electronicAmp_limit,
|
|---|
| 681 | electronicAmp_guess+electronicAmp_limit);
|
|---|
| 682 | fSinglePheFit->SetParLimits(5,
|
|---|
| 683 | fSigmaPedestal-3.*fSigmaPedestalErr,
|
|---|
| 684 | fSigmaPedestal+3.*fSigmaPedestalErr);
|
|---|
| 685 | fSinglePheFit->SetParLimits(6,norm-0.1,norm+0.1);
|
|---|
| 686 | fSinglePheFit->SetParLimits(7,
|
|---|
| 687 | fMeanPedestal-3.*fMeanPedestalErr,
|
|---|
| 688 | fMeanPedestal+3.*fMeanPedestalErr);
|
|---|
| 689 | break;
|
|---|
| 690 | case kEMichele:
|
|---|
| 691 | break;
|
|---|
| 692 |
|
|---|
| 693 | default:
|
|---|
| 694 | *fLog << warn << "WARNING: Could not find Fit Function for Blind Pixel " << endl;
|
|---|
| 695 | return kFALSE;
|
|---|
| 696 | break;
|
|---|
| 697 | }
|
|---|
| 698 |
|
|---|
| 699 | fSinglePheFit->SetRange(rmin,rmax);
|
|---|
| 700 |
|
|---|
| 701 | return kTRUE;
|
|---|
| 702 | }
|
|---|
| 703 |
|
|---|
| 704 | // --------------------------------------------------------------------------
|
|---|
| 705 | //
|
|---|
| 706 | // - Retrieve the parameters depending on fFitFunc
|
|---|
| 707 | // - Retrieve probability, Chisquare and NDF
|
|---|
| 708 | //
|
|---|
| 709 | void MHCalibrationChargeBlindPix::ExitFit()
|
|---|
| 710 | {
|
|---|
| 711 |
|
|---|
| 712 |
|
|---|
| 713 | //
|
|---|
| 714 | // Finalize
|
|---|
| 715 | //
|
|---|
| 716 | switch (fFitFunc)
|
|---|
| 717 | {
|
|---|
| 718 |
|
|---|
| 719 | case kEPoisson4:
|
|---|
| 720 | case kEPoisson5:
|
|---|
| 721 | case kEPoisson6:
|
|---|
| 722 | case kEPoisson7:
|
|---|
| 723 | fLambda = fSinglePheFit->GetParameter(0);
|
|---|
| 724 | fMu0 = fSinglePheFit->GetParameter(1);
|
|---|
| 725 | fMu1 = fSinglePheFit->GetParameter(2);
|
|---|
| 726 | fSigma0 = fSinglePheFit->GetParameter(3);
|
|---|
| 727 | fSigma1 = fSinglePheFit->GetParameter(4);
|
|---|
| 728 |
|
|---|
| 729 | fLambdaErr = fSinglePheFit->GetParError(0);
|
|---|
| 730 | fMu0Err = fSinglePheFit->GetParError(1);
|
|---|
| 731 | fMu1Err = fSinglePheFit->GetParError(2);
|
|---|
| 732 | fSigma0Err = fSinglePheFit->GetParError(3);
|
|---|
| 733 | fSigma1Err = fSinglePheFit->GetParError(4);
|
|---|
| 734 | break;
|
|---|
| 735 | case kEPolya:
|
|---|
| 736 | fLambda = fSinglePheFit->GetParameter(0);
|
|---|
| 737 | fMu0 = fSinglePheFit->GetParameter(7);
|
|---|
| 738 | fMu1 = 0.;
|
|---|
| 739 | fSigma0 = fSinglePheFit->GetParameter(5);
|
|---|
| 740 | fSigma1 = 0.;
|
|---|
| 741 |
|
|---|
| 742 | fLambdaErr = fSinglePheFit->GetParError(0);
|
|---|
| 743 | fMu0Err = fSinglePheFit->GetParError(7);
|
|---|
| 744 | fMu1Err = 0.;
|
|---|
| 745 | fSigma0Err = fSinglePheFit->GetParError(5);
|
|---|
| 746 | fSigma1Err = 0.;
|
|---|
| 747 | default:
|
|---|
| 748 | break;
|
|---|
| 749 | }
|
|---|
| 750 |
|
|---|
| 751 | fProb = fSinglePheFit->GetProb();
|
|---|
| 752 | fChisquare = fSinglePheFit->GetChisquare();
|
|---|
| 753 | fNDF = fSinglePheFit->GetNDF();
|
|---|
| 754 |
|
|---|
| 755 | *fLog << all << "Results of the Blind Pixel Fit: " << endl;
|
|---|
| 756 | *fLog << all << "Chisquare: " << fChisquare << endl;
|
|---|
| 757 | *fLog << all << "DoF: " << fNDF << endl;
|
|---|
| 758 | *fLog << all << "Probability: " << fProb << endl;
|
|---|
| 759 |
|
|---|
| 760 | }
|
|---|
| 761 |
|
|---|
| 762 | // --------------------------------------------------------------------------
|
|---|
| 763 | //
|
|---|
| 764 | // - Executes InitFit()
|
|---|
| 765 | // - Fits the fHGausHist with fSinglePheFit
|
|---|
| 766 | // - Executes ExitFit()
|
|---|
| 767 | //
|
|---|
| 768 | // The fit result is accepted under condition:
|
|---|
| 769 | // 1) The results are not nan's
|
|---|
| 770 | // 2) The NDF is not smaller than fNDFLimit (5)
|
|---|
| 771 | // 3) The Probability is greater than fProbLimit (default 0.001 == 99.9%)
|
|---|
| 772 | // 4) at least fNumSinglePheLimit events are in the single Photo-electron peak
|
|---|
| 773 | //
|
|---|
| 774 | Bool_t MHCalibrationChargeBlindPix::FitSinglePhe(Option_t *opt)
|
|---|
| 775 | {
|
|---|
| 776 |
|
|---|
| 777 | if (!InitFit())
|
|---|
| 778 | return kFALSE;
|
|---|
| 779 |
|
|---|
| 780 | fHGausHist.Fit(fSinglePheFit,opt);
|
|---|
| 781 |
|
|---|
| 782 | ExitFit();
|
|---|
| 783 |
|
|---|
| 784 | //
|
|---|
| 785 | // The fit result is accepted under condition:
|
|---|
| 786 | // 1) The results are not nan's
|
|---|
| 787 | // 2) The NDF is not smaller than fNDFLimit (5)
|
|---|
| 788 | // 3) The Probability is greater than fProbLimit (default 0.001 == 99.9%)
|
|---|
| 789 | // 4) at least fNumSinglePheLimit events are in the single Photo-electron peak
|
|---|
| 790 | //
|
|---|
| 791 | if ( TMath::IsNaN(fLambda)
|
|---|
| 792 | || TMath::IsNaN(fLambdaErr)
|
|---|
| 793 | || TMath::IsNaN(fProb)
|
|---|
| 794 | || TMath::IsNaN(fMu0)
|
|---|
| 795 | || TMath::IsNaN(fMu0Err)
|
|---|
| 796 | || TMath::IsNaN(fMu1)
|
|---|
| 797 | || TMath::IsNaN(fMu1Err)
|
|---|
| 798 | || TMath::IsNaN(fSigma0)
|
|---|
| 799 | || TMath::IsNaN(fSigma0Err)
|
|---|
| 800 | || TMath::IsNaN(fSigma1)
|
|---|
| 801 | || TMath::IsNaN(fSigma1Err)
|
|---|
| 802 | || fNDF < fNDFLimit
|
|---|
| 803 | || fProb < fProbLimit )
|
|---|
| 804 | return kFALSE;
|
|---|
| 805 |
|
|---|
| 806 | const Stat_t entries = fHGausHist.Integral("width");
|
|---|
| 807 | const Float_t numSinglePhe = TMath::Exp(-1.0*fLambda)*fLambda*entries;
|
|---|
| 808 |
|
|---|
| 809 | if (numSinglePhe < fNumSinglePheLimit)
|
|---|
| 810 | {
|
|---|
| 811 | *fLog << warn << "WARNING - Statistics is too low: Only " << numSinglePhe
|
|---|
| 812 | << " in the Single Photo-Electron peak " << endl;
|
|---|
| 813 | return kFALSE;
|
|---|
| 814 | }
|
|---|
| 815 | else
|
|---|
| 816 | *fLog << all << numSinglePhe << " in Single Photo-Electron peak " << endl;
|
|---|
| 817 |
|
|---|
| 818 | SetSinglePheFitOK();
|
|---|
| 819 | return kTRUE;
|
|---|
| 820 | }
|
|---|
| 821 |
|
|---|
| 822 | // --------------------------------------------------------------------------
|
|---|
| 823 | //
|
|---|
| 824 | // - Retrieves limits for the fit
|
|---|
| 825 | // - Fits the fHGausHist with Gauss
|
|---|
| 826 | // - Retrieves the results to fLambdaCheck and fLambdaCheckErr
|
|---|
| 827 | // - Sets a flag IsPedestalFitOK()
|
|---|
| 828 | //
|
|---|
| 829 | void MHCalibrationChargeBlindPix::FitPedestal (Option_t *opt)
|
|---|
| 830 | {
|
|---|
| 831 |
|
|---|
| 832 | // Perform the cross-check fitting only the pedestal:
|
|---|
| 833 | const Axis_t rmin = 0.;
|
|---|
| 834 | const Axis_t rmax = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
|
|---|
| 835 |
|
|---|
| 836 | FitGaus(opt, rmin, rmax);
|
|---|
| 837 |
|
|---|
| 838 | const Stat_t entries = fHGausHist.Integral("width");
|
|---|
| 839 | const Double_t fitarea = fFGausFit->GetParameter(0);
|
|---|
| 840 | const Double_t pedarea = fitarea * TMath::Sqrt(TMath::TwoPi()) * fFGausFit->GetParameter(2);
|
|---|
| 841 |
|
|---|
| 842 | fLambdaCheck = TMath::Log(entries/pedarea);
|
|---|
| 843 | fLambdaCheckErr = fFGausFit->GetParError(0)/fFGausFit->GetParameter(0)
|
|---|
| 844 | + fFGausFit->GetParError(2)/fFGausFit->GetParameter(2);
|
|---|
| 845 |
|
|---|
| 846 |
|
|---|
| 847 | SetPedestalFitOK();
|
|---|
| 848 | return;
|
|---|
| 849 | }
|
|---|
| 850 |
|
|---|
| 851 |
|
|---|
| 852 | // -------------------------------------------------------------------------
|
|---|
| 853 | //
|
|---|
| 854 | // Draw a legend with the fit results
|
|---|
| 855 | //
|
|---|
| 856 | void MHCalibrationChargeBlindPix::DrawLegend()
|
|---|
| 857 | {
|
|---|
| 858 |
|
|---|
| 859 | if (!fFitLegend)
|
|---|
| 860 | {
|
|---|
| 861 | fFitLegend = new TPaveText(0.05,0.05,0.95,0.95);
|
|---|
| 862 | fFitLegend->SetLabel(Form("%s%s", "Results of the single PhE Fit (",
|
|---|
| 863 | (fFitFunc = kEPoisson4) ? "Poisson(k=4))" :
|
|---|
| 864 | (fFitFunc = kEPoisson5) ? "Poisson(k=5))" :
|
|---|
| 865 | (fFitFunc = kEPoisson6) ? "Poisson(k=4))" :
|
|---|
| 866 | (fFitFunc = kEPolya ) ? "Polya(k=4))" :
|
|---|
| 867 | (fFitFunc = kEMichele ) ? "Michele)" : " none )" ));
|
|---|
| 868 | fFitLegend->SetTextSize(0.05);
|
|---|
| 869 | }
|
|---|
| 870 | else
|
|---|
| 871 | fFitLegend->Clear();
|
|---|
| 872 |
|
|---|
| 873 | const TString line1 =
|
|---|
| 874 | Form("Mean: #lambda = %2.2f #pm %2.2f",fLambda,fLambdaErr);
|
|---|
| 875 | TText *t1 = fFitLegend->AddText(line1.Data());
|
|---|
| 876 | t1->SetBit(kCanDelete);
|
|---|
| 877 |
|
|---|
| 878 | const TString line6 =
|
|---|
| 879 | Form("Mean #lambda (check) = %2.2f #pm %2.2f",fLambdaCheck,fLambdaCheckErr);
|
|---|
| 880 | TText *t2 = fFitLegend->AddText(line6.Data());
|
|---|
| 881 | t2->SetBit(kCanDelete);
|
|---|
| 882 |
|
|---|
| 883 | const TString line2 =
|
|---|
| 884 | Form("Pedestal: #mu_{0} = %2.2f #pm %2.2f",fMu0,fMu0Err);
|
|---|
| 885 | TText *t3 = fFitLegend->AddText(line2.Data());
|
|---|
| 886 | t3->SetBit(kCanDelete);
|
|---|
| 887 |
|
|---|
| 888 | const TString line3 =
|
|---|
| 889 | Form("Width Pedestal: #sigma_{0} = %2.2f #pm %2.2f",fSigma0,fSigma0Err);
|
|---|
| 890 | TText *t4 = fFitLegend->AddText(line3.Data());
|
|---|
| 891 | t4->SetBit(kCanDelete);
|
|---|
| 892 |
|
|---|
| 893 | const TString line4 =
|
|---|
| 894 | Form("1^{st} Phe-peak: #mu_{1} = %2.2f #pm %2.2f",fMu1,fMu1Err);
|
|---|
| 895 | TText *t5 = fFitLegend->AddText(line4.Data());
|
|---|
| 896 | t5->SetBit(kCanDelete);
|
|---|
| 897 |
|
|---|
| 898 | const TString line5 =
|
|---|
| 899 | Form("Width 1^{st} Phe-peak: #sigma_{1} = %2.2f #pm %2.2f",fSigma1,fSigma1Err);
|
|---|
| 900 | TText *t6 = fFitLegend->AddText(line5.Data());
|
|---|
| 901 | t6->SetBit(kCanDelete);
|
|---|
| 902 |
|
|---|
| 903 | const TString line7 =
|
|---|
| 904 | Form("#chi^{2} / N_{dof}: %4.2f / %3i",fChisquare,fNDF);
|
|---|
| 905 | TText *t7 = fFitLegend->AddText(line7.Data());
|
|---|
| 906 | t7->SetBit(kCanDelete);
|
|---|
| 907 |
|
|---|
| 908 | const TString line8 =
|
|---|
| 909 | Form("Probability: %4.2f ",fProb);
|
|---|
| 910 | TText *t8 = fFitLegend->AddText(line8.Data());
|
|---|
| 911 | t8->SetBit(kCanDelete);
|
|---|
| 912 |
|
|---|
| 913 | if (IsSinglePheFitOK())
|
|---|
| 914 | {
|
|---|
| 915 | TText *t = fFitLegend->AddText(0.,0.,"Result of the Fit: OK");
|
|---|
| 916 | t->SetBit(kCanDelete);
|
|---|
| 917 | }
|
|---|
| 918 | else
|
|---|
| 919 | {
|
|---|
| 920 | TText *t = fFitLegend->AddText("Result of the Fit: NOT OK");
|
|---|
| 921 | t->SetBit(kCanDelete);
|
|---|
| 922 | }
|
|---|
| 923 |
|
|---|
| 924 | fFitLegend->SetFillColor(IsSinglePheFitOK() ? 80 : 2);
|
|---|
| 925 | fFitLegend->Draw();
|
|---|
| 926 |
|
|---|
| 927 | return;
|
|---|
| 928 | }
|
|---|
| 929 |
|
|---|
| 930 |
|
|---|
| 931 | // -------------------------------------------------------------------------
|
|---|
| 932 | //
|
|---|
| 933 | // Draw the histogram
|
|---|
| 934 | //
|
|---|
| 935 | // The following options can be chosen:
|
|---|
| 936 | //
|
|---|
| 937 | // "": displays the fHGausHist, the legend and fASinglePheFADCSlices and fAPedestalFADCSlices
|
|---|
| 938 | // "all": executes additionally MHGausEvents::Draw(), with option "fourierevents"
|
|---|
| 939 | //
|
|---|
| 940 | void MHCalibrationChargeBlindPix::Draw(Option_t *opt)
|
|---|
| 941 | {
|
|---|
| 942 |
|
|---|
| 943 | TString option(opt);
|
|---|
| 944 | option.ToLower();
|
|---|
| 945 |
|
|---|
| 946 | Int_t win = 1;
|
|---|
| 947 |
|
|---|
| 948 | TVirtualPad *oldpad = gPad ? gPad : MH::MakeDefCanvas(this,900, 600);
|
|---|
| 949 | TVirtualPad *pad = NULL;
|
|---|
| 950 |
|
|---|
| 951 | oldpad->SetBorderMode(0);
|
|---|
| 952 |
|
|---|
| 953 | if (option.Contains("all"))
|
|---|
| 954 | {
|
|---|
| 955 | option.ReplaceAll("all","");
|
|---|
| 956 | oldpad->Divide(2,1);
|
|---|
| 957 | win = 2;
|
|---|
| 958 | oldpad->cd(1);
|
|---|
| 959 | TVirtualPad *newpad = gPad;
|
|---|
| 960 | pad = newpad;
|
|---|
| 961 | pad->Divide(2,2);
|
|---|
| 962 | pad->cd(1);
|
|---|
| 963 | }
|
|---|
| 964 | else
|
|---|
| 965 | {
|
|---|
| 966 | pad = oldpad;
|
|---|
| 967 | pad->Divide(2,2);
|
|---|
| 968 | pad->cd(1);
|
|---|
| 969 | }
|
|---|
| 970 |
|
|---|
| 971 | if (!IsEmpty())
|
|---|
| 972 | gPad->SetLogy();
|
|---|
| 973 |
|
|---|
| 974 | gPad->SetTicks();
|
|---|
| 975 |
|
|---|
| 976 | fHGausHist.Draw(opt);
|
|---|
| 977 | if (fFGausFit)
|
|---|
| 978 | {
|
|---|
| 979 | fFGausFit->SetLineColor(kBlue);
|
|---|
| 980 | fFGausFit->Draw("same");
|
|---|
| 981 | }
|
|---|
| 982 | if (fSinglePheFit)
|
|---|
| 983 | {
|
|---|
| 984 | fSinglePheFit->SetLineColor(IsSinglePheFitOK() ? kGreen : kRed);
|
|---|
| 985 | fSinglePheFit->Draw("same");
|
|---|
| 986 | }
|
|---|
| 987 |
|
|---|
| 988 | pad->cd(2);
|
|---|
| 989 | DrawLegend();
|
|---|
| 990 |
|
|---|
| 991 | pad->cd(3);
|
|---|
| 992 |
|
|---|
| 993 | if (fASinglePheFADCSlices.GetNrows()!=1)
|
|---|
| 994 | {
|
|---|
| 995 | if (fHSinglePheFADCSlices)
|
|---|
| 996 | delete fHSinglePheFADCSlices;
|
|---|
| 997 | fHSinglePheFADCSlices = new TH1F(fASinglePheFADCSlices);
|
|---|
| 998 | fHSinglePheFADCSlices->SetName("SinglePheFADCSlices");
|
|---|
| 999 | fHSinglePheFADCSlices->SetTitle(Form("%s%f","Assumed Single Phe FADC Slices, Sum > ",fSinglePheCut));
|
|---|
| 1000 | fHSinglePheFADCSlices->SetXTitle("FADC slice number");
|
|---|
| 1001 | fHSinglePheFADCSlices->SetYTitle("FADC counts");
|
|---|
| 1002 | fHSinglePheFADCSlices->Draw(opt);
|
|---|
| 1003 | }
|
|---|
| 1004 |
|
|---|
| 1005 | pad->cd(4);
|
|---|
| 1006 | if (fAPedestalFADCSlices.GetNrows()!=1)
|
|---|
| 1007 | {
|
|---|
| 1008 |
|
|---|
| 1009 | if (fHPedestalFADCSlices)
|
|---|
| 1010 | delete fHPedestalFADCSlices;
|
|---|
| 1011 |
|
|---|
| 1012 | fHPedestalFADCSlices = new TH1F(fAPedestalFADCSlices);
|
|---|
| 1013 | fHPedestalFADCSlices->SetName("PedestalFADCSlices");
|
|---|
| 1014 | fHPedestalFADCSlices->SetTitle(Form("%s%f","Pedestal FADC Slices, Sum < ",fSinglePheCut));
|
|---|
| 1015 | fHPedestalFADCSlices->SetXTitle("FADC slice number");
|
|---|
| 1016 | fHPedestalFADCSlices->SetYTitle("FADC counts");
|
|---|
| 1017 | fHPedestalFADCSlices->Draw(opt);
|
|---|
| 1018 | }
|
|---|
| 1019 |
|
|---|
| 1020 | if (win < 2)
|
|---|
| 1021 | return;
|
|---|
| 1022 |
|
|---|
| 1023 | oldpad->cd(2);
|
|---|
| 1024 | MHGausEvents::Draw("fourierevents");
|
|---|
| 1025 | }
|
|---|
| 1026 |
|
|---|
| 1027 |
|
|---|
| 1028 |
|
|---|
| 1029 |
|
|---|
| 1030 |
|
|---|
| 1031 |
|
|---|
| 1032 |
|
|---|
| 1033 |
|
|---|
| 1034 |
|
|---|
| 1035 |
|
|---|
| 1036 |
|
|---|