Changeset 2904 for trunk/MagicSoft/Mars
- Timestamp:
- 01/24/04 01:52:51 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2903 r2904 13 13 * mcalib/MCalibrationBlindPix.h 14 14 * mcalib/MHCalibrationBlindPixel.[h,cc] 15 * mcalib/MCalibrationPix.[h,cc] 15 16 * mcalib/MHCalibrationPixel.[h,cc] 16 * mcalib/M HCalibrationPixel.[h,cc]17 * mcalib/MCalibrationCalc.[h,cc] 17 18 - use MArrivalTime for Storage (or calculation) of time 18 19 in MExtractSignal 19 20 - pass from TH1I histos to TH1F for times 21 22 * mcalib/MCalibrationBlindPix.h 23 * mcalib/MHCalibrationBlindPixel.[h,cc] 24 * mcalib/MCalibrationPix.[h,cc] 25 * mcalib/MHCalibrationPixel.[h,cc] 26 * mcalib/MCalibrationCalc.[h,cc] 27 - clean up setters 28 - pass to bit-fields for all flags 20 29 21 30 -
trunk/MagicSoft/Mars/mcalib/MCalibrationBlindPix.h
r2885 r2904 57 57 // Fill histos 58 58 Bool_t FillCharge(Float_t q) { return fHist->FillBlindPixelCharge(q); } 59 Bool_t FillTime( Int_t t){ return fHist->FillBlindPixelTime(t); }59 Bool_t FillTime(Float_t t) { return fHist->FillBlindPixelTime(t); } 60 60 Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillBlindPixelChargevsN(rq,t); } 61 61 … … 68 68 void Draw(Option_t *opt="") { fHist->Draw(opt); } 69 69 TObject *DrawClone(Option_t *opt="") const { return fHist->DrawClone(opt); } 70 71 70 72 71 ClassDef(MCalibrationBlindPix, 1) // Storage Container for Calibration information of one pixel -
trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc
r2885 r2904 27 27 // MCalibrationCalc 28 28 // 29 // This is a task which calculates the number of photons from the FADC 30 // time slices. At the moment it integrates simply the FADC values. 31 // 32 // 33 // The class MCalibrationCam hold one entry of type MCalibrationPix for 34 // every pixel. It is filled in the following way: 35 // PreParocess: MalibrationCam::InitSize(577) is called which allocates 36 // memory in an TClonesArray of type MCalibrationPix and 37 // all pointers to NULL. 38 // 39 // Process: The NULL pointer is tested on every pixel via 40 // MalibrationCam::IsPixelUsed(npix). 41 // 42 // In case, IsPixelUsed returns NULL, 43 // MalibrationCam::AddPixel(npix) is invoked which creates a 44 // new MCalibrationPix(npix) in the npix's entry 45 // of the TClonesArray. 46 // 29 // Task to calculate the calibration conversion factors from the FADC 30 // time slices. The integrated time slices have to be delivered by an 31 // MExtractedSignalCam. The pedestals by an MPedestalCam and possibly 32 // arrival times from MArrivalTime 33 // 34 // The output container MCalibrationCam holds one entry of type MCalibrationPix 35 // for every pixel. It is filled in the following way: 36 // 37 // ProProcess: Search for MPedestalCam, MExtractedSignalCam 38 // Initialize MCalibrationCam 39 // Initialize MArrivalTime if exists 40 // Initialize pulser light wavelength 41 // 42 // ReInit: MCalibrationCam::InitSize(NumPixels) is called which allocates 43 // memory in a TClonesArray of type MCalibrationPix 44 // Initialize number of used FADC slices 45 // Optionally exclude pixels from calibration 46 // 47 // Process: Optionally, a cut on cosmics can be performed 48 // 47 49 // Every MCalibrationPix holds a histogram class, 48 50 // MHCalibrationPixel which itself hold histograms of type: … … 52 54 // HChargevsN(npix) (distribution of charges vs. event number. 53 55 // 54 // PostProcess: All histograms HCharge(npix) are fitted to a Gaussian 55 // All histograms HTime(npix) are fitted to a Gaussian 56 // The histogram HBlindPixelCharge (blind pixel) is fitted to 57 // a single 58 // PhE fit 59 // The histogram HBlindPixelTime (blind pixel) is fitted to a 60 // Gaussian 61 // The histograms of the PIN Diode are fitted to Gaussians 62 // 63 // Fits can be excluded via the commands: 64 // MalibrationCam::SetSkipTimeFits() (skip all time fits) 65 // MalibrationCam::SetSkipBlindPixelFits() (skip all blind 66 // pixel fits) 67 // MalibrationCam::SetSkipPinDiodeFits() (skip all PIN Diode 68 // fits) 56 // PostProcess: All histograms HCharge(npix) are fitted to a Gaussian 57 // All histograms HTime(npix) are fitted to a Gaussian 58 // The histogram HBlindPixelCharge (blind pixel) is fitted to 59 // a single PhE fit 60 // 61 // The histograms of the PIN Diode are fitted to Gaussians 62 // 63 // Fits can be excluded via the commands: 64 // MalibrationCam::SkipTimeFits() (skip all time fits) 65 // MalibrationCam::SkipBlindPixelFits() (skip all blind 66 // pixel fits) 67 // MalibrationCam::SkipPinDiodeFits() (skip all PIN Diode 68 // fits) 69 69 // 70 70 // Input Containers: 71 71 // MRawEvtData 72 // MPedestalCam 73 // MExtractedSignalCam 72 74 // 73 75 // Output Containers: … … 80 82 #include <fstream> 81 83 82 // FXIME: This has to be removed!!!! 84 // FXIME: This has to be removed!!!! (YES, WHEN WE HAVE ACCESS TO THE DATABASE!!!!!) 83 85 #include "MCalibrationConfig.h" 84 86 … … 106 108 #include "MCalibrationPINDiode.h" 107 109 110 #include "MArrivalTime.h" 111 108 112 ClassImp(MCalibrationCalc); 109 113 … … 116 120 MCalibrationCalc::MCalibrationCalc(const char *name, const char *title) 117 121 : fPedestals(NULL), fCalibrations(NULL), fSignals(NULL), 118 fRawEvt(NULL), fRunHeader(NULL), f EvtTime(NULL),119 fEvents(0), f HistOverFlow(0), fCosmics(0),122 fRawEvt(NULL), fRunHeader(NULL), fArrivalTime(NULL), fEvtTime(NULL), 123 fEvents(0), fCosmics(0), 120 124 fNumHiGainSamples(0), fNumLoGainSamples(0), fConversionHiLo(0.), 121 125 fNumExcludedPixels(0), … … 131 135 AddToBranchList("MRawEvtData.fLoGainFadcSamples"); 132 136 133 SETBIT(fFlags, kUseTime Fits);137 SETBIT(fFlags, kUseTimes); 134 138 SETBIT(fFlags, kUseBlindPixelFit); 135 139 SETBIT(fFlags, kUsePinDiodeFit); 140 SETBIT(fFlags, kUseCosmicsRejection); 141 SETBIT(fFlags, kUseQualityChecks); 136 142 137 143 } … … 158 164 // - MHCalibrationBlindPixel 159 165 // - MCalibrationCam 166 // 167 // The following output containers are only searched, but not created 168 // 169 // - MArrivaltime 160 170 // - MTime 161 171 // … … 186 196 } 187 197 198 fArrivalTime = (MArrivalTime*)pList->FindObject("MArrivalTime"); 199 200 if (!fArrivalTime) 201 CLRBIT(fFlags,kUseTimes); 202 203 fEvtTime = (MTime*)pList->FindObject("MTime"); 188 204 189 205 switch (fColor) … … 268 284 fSignals->GetLastUsedSliceLoGain()); 269 285 286 if (!TESTBIT(fFlags,kUseQualityChecks)) 287 pix.SetExcludeQualityCheck(); 288 270 289 } 271 290 … … 340 359 { 341 360 342 Int_t cosmicpix = 0; 343 344 MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel()); 345 MCalibrationPINDiode &pindiode = *(fCalibrations->GetPINDiode()); 346 347 MRawEvtPixelIter pixel(fRawEvt); 348 349 // 350 // Create a first loop to sort out the cosmics ... 351 // 352 // This is a very primitive check for the number of cosmicpixs 353 // The cut will be applied in the fit, but for the blind pixel, 354 // we need to remove this event 355 // 356 // FIXME: In the future need a much more sophisticated one!!! 357 // 358 359 while (pixel.Next()) 360 { 361 362 const UInt_t pixid = pixel.GetPixelId(); 363 364 MExtractedSignalPix &sig = (*fSignals)[pixid]; 365 MPedestalPix &ped = (*fPedestals)[pixid]; 366 Float_t pedrms = ped.GetPedestalRms()*fSqrtHiGainSamples; 367 Float_t sumhi = sig.GetExtractedSignalHiGain(); 361 // 362 // Initialize pointers to blind pixel, PIN Diode and individual pixels 363 // 364 MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel()); 365 MCalibrationPINDiode &pindiode = *(fCalibrations->GetPINDiode()); 366 367 MRawEvtPixelIter pixel(fRawEvt); 368 369 // 370 // Perform cosmics cut 371 // 372 if (TESTBIT(fFlags,kUseCosmicsRejection)) 373 { 368 374 369 // 370 // We consider a pixel as presumably due to cosmics 371 // if its sum of FADC slices is lower than 3 pedestal RMS 372 // 373 if (sumhi < 3.*pedrms ) 374 cosmicpix++; 375 } 376 377 // 378 // If the camera contains more than 230 379 // (this is the number of outer pixels plus about 50 inner ones) 380 // presumed pixels due to cosmics, then the event is discarted. 381 // This procedure is more or less equivalent to keeping only events 382 // with at least 350 pixels with high signals. 383 // 384 if (cosmicpix > 230.) 385 { 386 fCosmics++; 387 return kCONTINUE; 388 } 389 390 pixel.Reset(); 391 fEvents++; 392 393 394 // 395 // Create a second loop to do fill the calibration histograms 396 // 397 398 while (pixel.Next()) 399 { 400 401 const UInt_t pixid = pixel.GetPixelId(); 402 403 MCalibrationPix &pix = (*fCalibrations)[pixid]; 404 405 if (pix.IsExcluded()) 406 continue; 407 408 MExtractedSignalPix &sig = (*fSignals)[pixid]; 409 410 Float_t sumhi = sig.GetExtractedSignalHiGain(); 411 Float_t sumlo = sig.GetExtractedSignalLoGain(); 412 Float_t mtime = sig.GetMeanArrivalTime(); 413 414 415 switch(pixid) 416 { 417 418 case gkCalibrationBlindPixelId: 419 420 if (!blindpixel.FillCharge(sumhi)) 421 *fLog << warn << 422 "Overflow or Underflow occurred filling Blind Pixel sum = " << sumhi << endl; 423 424 if (!blindpixel.FillTime((int)mtime)) 425 *fLog << warn << 426 "Overflow or Underflow occurred filling Blind Pixel time = " << mtime << endl; 427 428 if (!blindpixel.FillRChargevsTime(sumhi,fEvents)) 429 *fLog << warn << 430 "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl; 431 break; 432 433 case gkCalibrationPINDiodeId: 434 if (!pindiode.FillCharge(sumhi)) 435 *fLog << warn << 436 "Overflow or Underflow occurred filling PINDiode: sum = " << sumhi << endl; 437 if (!pindiode.FillTime((int)mtime)) 438 *fLog << warn << 439 "Overflow or Underflow occurred filling PINDiode: time = " << mtime << endl; 440 if (!pindiode.FillRChargevsTime(sumhi,fEvents)) 441 *fLog << warn << 442 "Overflow or Underflow occurred filling PINDiode: eventnr = " << fEvents << endl; 443 break; 444 445 default: 446 447 pix.SetChargesInGraph(sumhi,sumlo); 448 449 if (!pix.FillRChargevsTimeLoGain(sumlo,fEvents)) 450 *fLog << warn << "Could not fill Lo Gain Charge vs. EvtNr of pixel: " 451 << pixid << " signal = " << sumlo << " event Nr: " << fEvents << endl; 452 453 if (!pix.FillRChargevsTimeHiGain(sumhi,fEvents)) 454 *fLog << warn << "Could not fill Hi Gain Charge vs. EvtNr of pixel: " 455 << pixid << " signal = " << sumhi << " event Nr: " << fEvents << endl; 456 457 if (sig.IsLoGainUsed()) 458 { 459 460 if (!pix.FillChargeLoGain(sumlo)) 461 *fLog << warn << "Could not fill Lo Gain Charge of pixel: " << pixid 462 << " signal = " << sumlo << endl; 463 464 if (!pix.FillTimeLoGain((int)mtime)) 465 *fLog << warn << "Could not fill Lo Gain Time of pixel: " 466 << pixid << " time = " << mtime << endl; 467 468 } 469 else 470 { 471 if (!pix.FillChargeHiGain(sumhi)) 472 *fLog << warn << "Could not fill Hi Gain Charge of pixel: " << pixid 473 << " signal = " << sumhi << endl; 474 475 if (!pix.FillTimeHiGain((int)mtime)) 476 *fLog << warn << "Could not fill Hi Gain Time of pixel: " 477 << pixid << " time = " << mtime << endl; 478 479 } 480 break; 481 482 } /* switch(pixid) */ 483 484 } /* while (pixel.Next()) */ 485 486 return kTRUE; 375 Int_t cosmicpix = 0; 376 377 // 378 // Create a first loop to sort out the cosmics ... 379 // 380 // This is a very primitive check for the number of cosmicpixs 381 // The cut will be applied in the fit, but for the blind pixel, 382 // we need to remove this event 383 // 384 // FIXME: In the future need a much more sophisticated one!!! 385 // 386 387 while (pixel.Next()) 388 { 389 390 const UInt_t pixid = pixel.GetPixelId(); 391 392 MExtractedSignalPix &sig = (*fSignals)[pixid]; 393 MPedestalPix &ped = (*fPedestals)[pixid]; 394 Float_t pedrms = ped.GetPedestalRms()*fSqrtHiGainSamples; 395 Float_t sumhi = sig.GetExtractedSignalHiGain(); 396 397 // 398 // We consider a pixel as presumably due to cosmics 399 // if its sum of FADC slices is lower than 3 pedestal RMS 400 // 401 if (sumhi < 3.*pedrms ) 402 cosmicpix++; 403 } 404 405 // 406 // If the camera contains more than 230 407 // (this is the number of outer pixels plus about 50 inner ones) 408 // presumed pixels due to cosmics, then the event is discarted. 409 // This procedure is more or less equivalent to keeping only events 410 // with at least 350 pixels with high signals. 411 // 412 if (cosmicpix > 230.) 413 { 414 fCosmics++; 415 return kCONTINUE; 416 } 417 418 pixel.Reset(); 419 } 420 421 fEvents++; 422 423 // 424 // Create a (second) loop to do fill the calibration histograms 425 // 426 427 while (pixel.Next()) 428 { 429 430 const UInt_t pixid = pixel.GetPixelId(); 431 432 MCalibrationPix &pix = (*fCalibrations)[pixid]; 433 434 if (pix.IsExcluded()) 435 continue; 436 437 MExtractedSignalPix &sig = (*fSignals)[pixid]; 438 439 const Float_t sumhi = sig.GetExtractedSignalHiGain(); 440 const Float_t sumlo = sig.GetExtractedSignalLoGain(); 441 442 Double_t mtime = 0.; 443 444 if (TESTBIT(fFlags,kUseTimes)) 445 mtime = (*fArrivalTime)[pixid]; 446 447 switch(pixid) 448 { 449 450 case gkCalibrationBlindPixelId: 451 452 if (!blindpixel.FillCharge(sumhi)) 453 *fLog << warn << 454 "Overflow or Underflow occurred filling Blind Pixel sum = " << sumhi << endl; 455 456 if (TESTBIT(fFlags,kUseTimes)) 457 { 458 if (!blindpixel.FillTime(mtime)) 459 *fLog << warn << 460 "Overflow or Underflow occurred filling Blind Pixel time = " << mtime << endl; 461 } 462 463 if (!blindpixel.FillRChargevsTime(sumhi,fEvents)) 464 *fLog << warn << 465 "Overflow or Underflow occurred filling Blind Pixel eventnr = " << fEvents << endl; 466 break; 467 468 case gkCalibrationPINDiodeId: 469 470 if (!pindiode.FillCharge(sumhi)) 471 *fLog << warn << 472 "Overflow or Underflow occurred filling PINDiode: sum = " << sumhi << endl; 473 474 if (TESTBIT(fFlags,kUseTimes)) 475 { 476 if (!pindiode.FillTime(mtime)) 477 *fLog << warn << 478 "Overflow or Underflow occurred filling PINDiode: time = " << mtime << endl; 479 } 480 481 if (!pindiode.FillRChargevsTime(sumhi,fEvents)) 482 *fLog << warn << 483 "Overflow or Underflow occurred filling PINDiode: eventnr = " << fEvents << endl; 484 break; 485 486 default: 487 488 pix.FillChargesInGraph(sumhi,sumlo); 489 490 if (!pix.FillRChargevsTimeLoGain(sumlo,fEvents)) 491 *fLog << warn << "Could not fill Lo Gain Charge vs. EvtNr of pixel: " 492 << pixid << " signal = " << sumlo << " event Nr: " << fEvents << endl; 493 494 if (!pix.FillRChargevsTimeHiGain(sumhi,fEvents)) 495 *fLog << warn << "Could not fill Hi Gain Charge vs. EvtNr of pixel: " 496 << pixid << " signal = " << sumhi << " event Nr: " << fEvents << endl; 497 498 if (sig.IsLoGainUsed()) 499 { 500 501 if (!pix.FillChargeLoGain(sumlo)) 502 *fLog << warn << "Could not fill Lo Gain Charge of pixel: " << pixid 503 << " signal = " << sumlo << endl; 504 505 if (TESTBIT(fFlags,kUseTimes)) 506 { 507 if (!pix.FillTimeLoGain(mtime)) 508 *fLog << warn << "Could not fill Lo Gain Time of pixel: " 509 << pixid << " time = " << mtime << endl; 510 } 511 } /* if (sig.IsLoGainUsed()) */ 512 else 513 { 514 if (!pix.FillChargeHiGain(sumhi)) 515 *fLog << warn << "Could not fill Hi Gain Charge of pixel: " << pixid 516 << " signal = " << sumhi << endl; 517 518 if (TESTBIT(fFlags,kUseTimes)) 519 { 520 if (!pix.FillTimeHiGain(mtime)) 521 *fLog << warn << "Could not fill Hi Gain Time of pixel: " 522 << pixid << " time = " << mtime << endl; 523 } 524 } /* else (sig.IsLoGainUsed()) */ 525 break; 526 527 } /* switch(pixid) */ 528 529 } /* while (pixel.Next()) */ 530 531 return kTRUE; 487 532 } 488 533 … … 531 576 } 532 577 533 //blindpixel.DrawClone();578 blindpixel.DrawClone(); 534 579 } 535 580 else … … 573 618 // Perform the Gauss fits to the arrival times 574 619 // 575 if (TESTBIT(fFlags,kUseTime Fits))620 if (TESTBIT(fFlags,kUseTimes)) 576 621 pix.FitTime(); 577 622 -
trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.h
r2885 r2904 1 1 #ifndef MARS_MCalibrationCalc 2 2 #define MARS_MCalibrationCalc 3 4 ///////////////////////////////////////////////////////////////////////////// 5 // // 6 // MCalibrationCalc // 7 // // 8 // Integrates the time slices of the all pixels of a calibration event // 9 // and substract the pedestal value // 10 // // 11 ///////////////////////////////////////////////////////////////////////////// 3 12 4 13 #ifndef MARS_MTask … … 6 15 #endif 7 16 17 #ifndef ROOT_TArrayI 18 #include "TArrayI.h" 19 #endif 20 21 #ifndef MARS_MCalibrationCam 22 #include "MCalibrationCam.h" 23 #endif 24 25 #include "TString.h" 26 27 class MRawEvtData; 28 class MRawRunHeader; 29 8 30 class MPedestalCam; 9 31 class MCalibrationCam; 10 32 class MExtractedSignalCam; 11 12 class MCalibrationBlindPix; 13 class MCalibrationPINDiode; 33 class MArrivalTime; 14 34 15 35 class MTime; 16 class MRawEvtData;17 class MRawRunHeader;18 36 19 37 class MCalibrationCalc : public MTask … … 28 46 MRawRunHeader *fRunHeader; // RunHeader information 29 47 48 MArrivalTime *fArrivalTime; // Calculated Arrival Times 49 30 50 MTime *fEvtTime; // Time of the event 31 51 32 52 Int_t fEvents; // Number of events 33 Int_t fHistOverFlow; // Number of events with saturated Low Gain34 53 Int_t fCosmics; // Number of events due to supposed cosmics 35 54 … … 61 80 MCalibrationCalc(const char *name=NULL, const char *title=NULL); 62 81 63 64 82 private: 65 83 66 enum { kUseTimeFits, kUseBlindPixelFit, kUsePinDiodeFit }; 84 enum { kUseTimes, kUseBlindPixelFit, kUsePinDiodeFit, 85 kUseCosmicsRejection, kUseQualityChecks }; 67 86 68 87 public: 69 88 70 // Skipping fits71 void SkipTime Fits(Bool_t b=kTRUE)72 {b ? CLRBIT(fFlags, kUseTime Fits) : SETBIT(fFlags, kUseTimeFits);}89 // Skipping parts of the work 90 void SkipTime(Bool_t b=kTRUE) 91 {b ? CLRBIT(fFlags, kUseTimes) : SETBIT(fFlags, kUseTimes);} 73 92 void SkipBlindPixelFit(Bool_t b=kTRUE) 74 93 {b ? CLRBIT(fFlags, kUseBlindPixelFit) : SETBIT(fFlags, kUseBlindPixelFit);} 75 94 void SkipPinDiodeFit(Bool_t b=kTRUE) 76 95 {b ? CLRBIT(fFlags, kUsePinDiodeFit) : SETBIT(fFlags, kUsePinDiodeFit);} 96 void SkipCosmicsRejection(Bool_t b=kTRUE) 97 {b ? CLRBIT(fFlags, kUseCosmicsRejection) : SETBIT(fFlags, kUseCosmicsRejection);} 98 void SkipQualityChecks(Bool_t b=kTRUE) 99 {b ? CLRBIT(fFlags, kUseQualityChecks) : SETBIT(fFlags, kUseQualityChecks);} 77 100 78 101 // Setters … … 82 105 // Getters 83 106 MCalibrationBlindPix *GetBlindPixel() const; 84 MCalibrationPINDiode *GetPINDiode() const;107 MCalibrationPINDiode *GetPINDiode() const; 85 108 86 109 // Exclude pixels from configuration file -
trunk/MagicSoft/Mars/mcalib/MCalibrationPINDiode.h
r2885 r2904 37 37 38 38 Bool_t FillCharge(Float_t q) { return fHist->FillChargeHiGain(q); } 39 Bool_t FillTime( Int_t t){ return fHist->FillTimeHiGain(t); }39 Bool_t FillTime(Float_t t) { return fHist->FillTimeHiGain(t); } 40 40 Bool_t FillRChargevsTime(Float_t rq, Int_t t) { return fHist->FillChargevsNHiGain(rq,t); } 41 41 -
trunk/MagicSoft/Mars/mcalib/MCalibrationPix.cc
r2852 r2904 83 83 fConversionSigmaBlindPixelMethod(-1.), 84 84 fConversionSigmaPINDiodeMethod(-1.), 85 fHiGainSaturation(kFALSE), 86 fExcluded(kFALSE), 87 fFitValid(kFALSE), 88 fFitted(kFALSE), 89 fBlindPixelMethodValid(kFALSE), 90 fFFactorMethodValid(kFALSE), 91 fPINDiodeMethodValid(kFALSE), 92 fChargeLimit(5.), 93 fChargeErrLimit(0.) 85 fFlags(0), 86 fChargeLimit(3.), 87 fChargeErrLimit(0.), 88 fChargeRelErrLimit(1.) 94 89 { 95 90 … … 109 104 *fLog << warn << dbginf << " Could not create MHCalibrationPixel " << endl; 110 105 106 CLRBIT(fFlags, kHiGainSaturation); 107 CLRBIT(fFlags, kExcluded); 108 CLRBIT(fFlags, kFitValid); 109 CLRBIT(fFlags, kFitted); 110 CLRBIT(fFlags, kBlindPixelMethodValid); 111 CLRBIT(fFlags, kFFactorMethodValid); 112 CLRBIT(fFlags, kPINDiodeMethodValid); 113 111 114 } 112 115 … … 115 118 delete fHist; 116 119 } 120 121 117 122 118 123 … … 132 137 void MCalibrationPix::Clear(Option_t *o) 133 138 { 139 134 140 fHist->Reset(); 141 142 CLRBIT(fFlags, kHiGainSaturation); 143 CLRBIT(fFlags, kExcluded); 144 CLRBIT(fFlags, kFitValid); 145 CLRBIT(fFlags, kFitted); 146 CLRBIT(fFlags, kBlindPixelMethodValid); 147 CLRBIT(fFlags, kFFactorMethodValid); 148 CLRBIT(fFlags, kPINDiodeMethodValid); 149 150 } 151 152 // -------------------------------------------------------------------------- 153 // 154 // Set the pedestals from outside 155 // 156 void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms) 157 { 158 159 fPed = ped; 160 fPedRms = pedrms; 161 162 } 163 164 // -------------------------------------------------------------------------- 165 // 166 // Set the conversion factors from outside (only for MC) 167 // 168 void MCalibrationPix::SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig) 169 { 170 fConversionFFactorMethod = c; 171 fConversionErrorFFactorMethod = err; 172 fConversionSigmaFFactorMethod = sig; 173 } 174 175 176 // -------------------------------------------------------------------------- 177 // 178 // Set the conversion factors from outside (only for MC) 179 // 180 void MCalibrationPix::SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig) 181 { 182 fConversionBlindPixelMethod = c; 183 fConversionErrorBlindPixelMethod = err; 184 fConversionSigmaBlindPixelMethod = sig; 185 } 186 187 // -------------------------------------------------------------------------- 188 // 189 // Set the conversion factors from outside (only for MC) 190 // 191 void MCalibrationPix::SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig) 192 { 193 fConversionPINDiodeMethod = c ; 194 fConversionErrorPINDiodeMethod = err; 195 fConversionSigmaPINDiodeMethod = sig; 196 } 197 198 // -------------------------------------------------------------------------- 199 // 200 // Set the Hi Gain Saturation Bit from outside (only for MC) 201 // 202 void MCalibrationPix::SetHiGainSaturation(Bool_t b) 203 { 204 205 if (b) 206 { 207 SETBIT(fFlags, kHiGainSaturation); 208 fHist->SetUseLoGain(1); 209 } 210 else 211 { 212 CLRBIT(fFlags, kHiGainSaturation); 213 fHist->SetUseLoGain(0); 214 } 215 } 216 217 // -------------------------------------------------------------------------- 218 // 219 // Set the Excluded Bit from outside 220 // 221 void MCalibrationPix::SetExcluded(Bool_t b ) 222 { 223 b ? SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded); 224 } 225 226 227 // -------------------------------------------------------------------------- 228 // 229 // Set the Excluded Bit from outside 230 // 231 void MCalibrationPix::SetExcludeQualityCheck(Bool_t b ) 232 { 233 b ? SETBIT(fFlags, kExcludeQualityCheck) : CLRBIT(fFlags, kExcludeQualityCheck); 234 } 235 236 // -------------------------------------------------------------------------- 237 // 238 // Set the Excluded Bit from outside 239 // 240 void MCalibrationPix::SetFitValid(Bool_t b ) 241 { 242 b ? SETBIT(fFlags, kFitValid) : CLRBIT(fFlags, kFitValid); 243 } 244 245 // -------------------------------------------------------------------------- 246 // 247 // Set the Excluded Bit from outside 248 // 249 void MCalibrationPix::SetFitted(Bool_t b ) 250 { 251 b ? SETBIT(fFlags, kFitted) : CLRBIT(fFlags, kFitted); 252 } 253 254 // -------------------------------------------------------------------------- 255 // 256 // Set the Excluded Bit from outside 257 // 258 void MCalibrationPix::SetBlindPixelMethodValid(Bool_t b ) 259 { 260 b ? SETBIT(fFlags, kBlindPixelMethodValid) : CLRBIT(fFlags, kBlindPixelMethodValid); 261 } 262 263 // -------------------------------------------------------------------------- 264 // 265 // Set the Excluded Bit from outside 266 // 267 void MCalibrationPix::SetFFactorMethodValid(Bool_t b ) 268 { 269 b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid); 270 } 271 272 // -------------------------------------------------------------------------- 273 // 274 // Set the Excluded Bit from outside 275 // 276 void MCalibrationPix::SetPINDiodeMethodValid(Bool_t b ) 277 { 278 b ? SETBIT(fFlags, kPINDiodeMethodValid) : CLRBIT(fFlags, kPINDiodeMethodValid); 279 } 280 281 282 Bool_t MCalibrationPix::IsExcluded() const 283 { 284 return TESTBIT(fFlags,kExcluded); 285 } 286 287 Bool_t MCalibrationPix::IsFitValid() const 288 { 289 return TESTBIT(fFlags, kFitValid); 290 } 291 292 Bool_t MCalibrationPix::IsFitted() const 293 { 294 return TESTBIT(fFlags, kFitted); 295 } 296 297 Bool_t MCalibrationPix::IsBlindPixelMethodValid() const 298 { 299 return TESTBIT(fFlags, kBlindPixelMethodValid); 300 } 301 302 Bool_t MCalibrationPix::IsFFactorMethodValid() const 303 { 304 return TESTBIT(fFlags, kFFactorMethodValid); 305 } 306 307 Bool_t MCalibrationPix::IsPINDiodeMethodValid() const 308 { 309 return TESTBIT(fFlags, kPINDiodeMethodValid); 135 310 } 136 311 … … 203 378 // 5) In case of failure print out the fit results 204 379 // 205 fHist->PrintChargeFitResult(); 380 // fHist->PrintChargeFitResult(); 381 CLRBIT(fFlags,kFitted); 206 382 } 383 else 384 SETBIT(fFlags,kFitted); 207 385 } 208 386 else … … 217 395 // 5) In case of failure print out the fit results 218 396 // 219 fHist->PrintChargeFitResult(); 397 // fHist->PrintChargeFitResult(); 398 CLRBIT(fFlags,kFitted); 220 399 } 400 else 401 SETBIT(fFlags,kFitted); 221 402 } 222 403 … … 231 412 fChargeProb = fHist->GetChargeProb(); 232 413 233 if (fCharge <= 0.) 234 { 235 *fLog << warn << "WARNING: Cannot apply calibration: Mean Fitted Charges are smaller than 0 in pixel " 236 << fPixId << endl; 414 if (CheckChargeFitValidity()) 415 SETBIT(fFlags,kFitValid); 416 else 417 { 418 CLRBIT(fFlags,kFitValid); 237 419 return kFALSE; 238 420 } 239 240 if (fErrCharge > 0.)241 fFitted = kTRUE;242 243 if (CheckChargeFitValidity())244 fFitValid = kTRUE;245 246 421 247 422 // … … 273 448 Float_t pedRmsSquareErrSquare = 4.*fErrPedRms*fErrPedRms * pedRmsSquare; 274 449 275 if ( fHiGainSaturation)450 if (TESTBIT(fFlags,kHiGainSaturation)) 276 451 { 277 452 … … 306 481 pedRmsSquareErrSquare = convertedNsbSquareErrSquare + elecRmsSquareErrSquare; 307 482 308 } /* if ( fHiGainSaturation) */483 } /* if (kHiGainSaturation) */ 309 484 310 485 // … … 317 492 << "WARNING: Cannot apply F-Factor calibration: Reduced Sigma smaller than 0 in pixel " 318 493 << fPixId << endl; 319 if ( fHiGainSaturation)494 if (TESTBIT(fFlags,kHiGainSaturation)) 320 495 ApplyLoGainConversion(); 321 496 return kFALSE; … … 340 515 // Calculate the conversion factors 341 516 // 342 if ( fHiGainSaturation)517 if (TESTBIT(fFlags,kHiGainSaturation)) 343 518 ApplyLoGainConversion(); 344 519 … … 352 527 (fConversionFFactorMethod > 0.) && 353 528 (fConversionErrorFFactorMethod/fConversionFFactorMethod < 0.1) ) 354 fFFactorMethodValid = kTRUE; 355 529 SETBIT(fFlags,kFFactorMethodValid); 530 else 531 CLRBIT(fFlags,kFFactorMethodValid); 356 532 357 533 } /* if ((fPed > 0.) && (fPedRms > 0.)) */ … … 366 542 // 1) Pixel has a fitted charge greater than 5*PedRMS 367 543 // 2) Pixel has a fit error greater than 0. 368 // 3) Pixel has a fit Probability greater than 0.0001 369 // 4) Pixel has a charge sigma bigger than its Pedestal RMS 544 // 3) Pixel has a fitted charge greater its charge error 545 // 4) Pixel has a fit Probability greater than 0.0001 546 // 5) Pixel has a charge sigma bigger than its Pedestal RMS 370 547 // 371 548 Bool_t MCalibrationPix::CheckChargeFitValidity() 372 549 { 373 550 551 if (TESTBIT(fFlags,kExcludeQualityCheck)) 552 return kTRUE; 553 374 554 Float_t equivpedestal = GetPedRms(); 375 555 376 if ( fHiGainSaturation)556 if (TESTBIT(fFlags,kHiGainSaturation)) 377 557 equivpedestal /= fConversionHiLo; 378 558 … … 391 571 } 392 572 573 if (fCharge < fChargeRelErrLimit*fErrCharge) 574 { 575 *fLog << warn << "WARNING: Error of Fitted Charge is greater than " 576 << fChargeRelErrLimit << "* Fitted Charges itself in Pixel " << fPixId << endl; 577 return kFALSE; 578 } 579 393 580 if (!fHist->IsFitOK()) 394 581 { … … 413 600 { 414 601 602 if (TESTBIT(fFlags,kExcludeQualityCheck)) 603 return kTRUE; 604 415 605 Float_t lowerrange; 416 606 Float_t upperrange; 417 607 418 if ( fHiGainSaturation)608 if (TESTBIT(fFlags,kHiGainSaturation)) 419 609 { 420 610 lowerrange = (Float_t)fHist->GetTimeLowerFitRangeLoGain()+1.; … … 481 671 482 672 483 // --------------------------------------------------------------------------484 //485 // Set the pedestals from outside486 //487 void MCalibrationPix::SetPedestal(Float_t ped, Float_t pedrms)488 {489 490 fPed = ped;491 fPedRms = pedrms;492 493 }494 673 495 674 // -------------------------------------------------------------------------- … … 510 689 // Fit the Low Gain 511 690 // 512 if ( fHiGainSaturation)691 if (TESTBIT(fFlags,kHiGainSaturation)) 513 692 { 514 693 if(!fHist->FitTimeLoGain()) … … 538 717 fTimeProb = fHist->GetTimeProb(); 539 718 540 if (!CheckTimeFitValidity()) 541 fFitValid = kFALSE; 719 if (CheckTimeFitValidity()) 720 SETBIT(fFlags,kFitValid); 721 else 722 CLRBIT(fFlags,kFitValid); 542 723 543 724 return kTRUE; -
trunk/MagicSoft/Mars/mcalib/MCalibrationPix.h
r2852 r2904 52 52 Float_t fConversionHiLoError; // The error of the conversion factor between Hi Gain and Lo Gain 53 53 54 B ool_t fHiGainSaturation; // Is Lo-Gain used at all?54 Byte_t fFlags; // Flag for the set Bits 55 55 56 Bool_t fExcluded; 57 Bool_t fFitValid; 58 Bool_t fFitted; 59 Bool_t fBlindPixelMethodValid; 60 Bool_t fFFactorMethodValid; 61 Bool_t fPINDiodeMethodValid; 56 enum { kHiGainSaturation, 57 kExcluded, kExcludeQualityCheck, 58 kFitValid, kFitted, 59 kBlindPixelMethodValid, kFFactorMethodValid, kPINDiodeMethodValid }; 62 60 63 MHCalibrationPixel *fHist; //! Pointer to the histograms performing the fits, etc.61 MHCalibrationPixel *fHist; //! Pointer to the histograms performing the fits, etc. 64 62 65 63 Float_t fChargeLimit; 66 64 Float_t fChargeErrLimit; 65 Float_t fChargeRelErrLimit; 67 66 68 67 Bool_t CheckChargeFitValidity(); … … 78 77 79 78 // Getter 80 Bool_t IsExcluded() const { return fExcluded; } 81 Bool_t IsFitValid() const { return fFitValid; } 82 Bool_t IsFitted() const { return fFitted; } 83 Bool_t IsBlindPixelMethodValid() const { return fBlindPixelMethodValid; } 84 Bool_t IsFFactorMethodValid() const { return fFFactorMethodValid; } 85 Bool_t IsPINDiodeMethodValid() const { return fPINDiodeMethodValid; } 79 MHCalibrationPixel *GetHist() const { return fHist; } 86 80 87 81 // Charges … … 117 111 Float_t GetSigmaConversionPINDiodeMethod() const { return fConversionSigmaPINDiodeMethod ; } 118 112 119 // FIXME: Remove this from stored data members 113 Int_t GetPixId() const { return fPixId; } 114 120 115 Float_t GetPed() const { return fPed; } 121 116 Float_t GetPedRms() const { return fPedRms; } 122 117 118 Bool_t IsExcluded() const; 119 Bool_t IsFitValid() const; 120 Bool_t IsFitted() const; 121 Bool_t IsBlindPixelMethodValid() const; 122 Bool_t IsFFactorMethodValid() const; 123 Bool_t IsPINDiodeMethodValid() const; 124 123 125 // Setter 124 126 void SetPedestal(Float_t ped, Float_t pedrms); 125 void SetHiGainSaturation() { fHiGainSaturation = kTRUE; fHist->SetUseLoGain(); } 127 void SetConversionHiLo(Float_t c) { fConversionHiLo = c; } 128 void SetConversionHiLoError(Float_t e) { fConversionHiLoError = e; } 126 129 127 void SetConversionHiLo(Float_t c) { fConversionHiLo = c; } 128 void SetConversionHiLoError(Float_t e) { fConversionHiLoError = e; } 130 // Setters for MC 131 void SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig); 132 void SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig); 133 void SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig); 129 134 130 void SetConversionFFactorMethod(Float_t c, Float_t err, Float_t sig) 131 { 132 fConversionFFactorMethod = c; 133 fConversionErrorFFactorMethod = err; 134 fConversionSigmaFFactorMethod = sig; 135 } 136 void SetConversionBlindPixelMethod(Float_t c, Float_t err, Float_t sig) 137 { 138 fConversionBlindPixelMethod = c; 139 fConversionErrorBlindPixelMethod = err; 140 fConversionSigmaBlindPixelMethod = sig; 141 } 142 143 void SetConversionPINDiodeMethod(Float_t c, Float_t err, Float_t sig) 144 { 145 fConversionPINDiodeMethod = c ; 146 fConversionErrorPINDiodeMethod = err; 147 fConversionSigmaPINDiodeMethod = sig; 148 } 149 150 void SetExcluded(Bool_t b = kTRUE) { fExcluded = b; } 151 void SetFitValid(Bool_t b = kTRUE) { fFitValid = b; } 152 void SetFitted(Bool_t b = kTRUE) { fFitted = b; } 153 void SetBlindPixelMethodValid(Bool_t b = kTRUE) { fBlindPixelMethodValid = b; } 154 void SetFFactorMethodValid(Bool_t b = kTRUE) { fFFactorMethodValid = b; } 155 void SetPINDiodeMethodValid(Bool_t b = kTRUE) { fPINDiodeMethodValid = b; } 156 157 // Unknown 158 void ApplyLoGainConversion(); 159 160 void SetChargesInGraph(Float_t qhi,Float_t qlo) { fHist->SetPointInGraph(qhi,qlo); } 161 135 // Bit Setters 136 void SetHiGainSaturation(Bool_t b = kTRUE); 137 void SetExcluded(Bool_t b = kTRUE); 138 void SetExcludeQualityCheck(Bool_t b = kTRUE); 139 void SetFitValid(Bool_t b = kTRUE); 140 void SetFitted(Bool_t b = kTRUE); 141 void SetBlindPixelMethodValid(Bool_t b = kTRUE); 142 void SetFFactorMethodValid(Bool_t b = kTRUE); 143 void SetPINDiodeMethodValid(Bool_t b = kTRUE); 144 145 // Fill histos 162 146 Bool_t FillChargeHiGain(Float_t q) { return fHist->FillChargeHiGain(q); } 163 Bool_t FillTimeHiGain( Int_t t){ return fHist->FillTimeHiGain(t); }147 Bool_t FillTimeHiGain(Float_t t) { return fHist->FillTimeHiGain(t); } 164 148 Bool_t FillRChargevsTimeHiGain(Float_t rq, Int_t t) { return fHist->FillChargevsNHiGain(rq,t); } 165 149 166 150 Bool_t FillChargeLoGain(Float_t q) { return fHist->FillChargeLoGain(q); } 167 Bool_t FillTimeLoGain( Int_t t){ return fHist->FillTimeLoGain(t); }151 Bool_t FillTimeLoGain(Float_t t) { return fHist->FillTimeLoGain(t); } 168 152 Bool_t FillRChargevsTimeLoGain(Float_t rq, Int_t t) { return fHist->FillChargevsNLoGain(rq,t); } 169 153 170 // FIXME: Not necessary -> pixidx (not id anyhow!) == index in array! 171 // Only needed n histograms which have to move to an MH-class anyhow! 172 Int_t GetPixId() const { return fPixId; } 154 Bool_t FillChargesInGraph(Float_t qhi,Float_t qlo) { return fHist->FillPointInGraph(qhi,qlo); } 155 173 156 void DefinePixId(Int_t i); 174 157 158 // Fits 175 159 Bool_t FitCharge(); 176 160 Bool_t FitTime(); 177 161 178 MHCalibrationPixel *GetHist() const { return fHist; } 179 void Draw(Option_t *opt="") { fHist->Draw(opt); } 162 // Draws 163 void Draw(Option_t *opt="") { fHist->Draw(opt); } 164 TObject *DrawClone(Option_t *opt="") const { return fHist->DrawClone(opt); } 180 165 166 // Miscellaneous 167 void ApplyLoGainConversion(); 168 181 169 ClassDef(MCalibrationPix, 1) // Storage Container for Calibration information of one pixel 182 170 }; -
trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.cc
r2885 r2904 96 96 Int_t nbins = 16; 97 97 98 fHBlindPixelTime = new TH1 I("HBlindPixelTime","Distribution of Mean Arrival Times",nbins,tfirst,tlast);98 fHBlindPixelTime = new TH1F("HBlindPixelTime","Distribution of Mean Arrival Times",nbins,tfirst,tlast); 99 99 fHBlindPixelTime->SetXTitle("Mean Arrival Times [FADC slice nr]"); 100 100 fHBlindPixelTime->SetYTitle("Nr. of events"); … … 141 141 } 142 142 143 Bool_t MHCalibrationBlindPixel::FillBlindPixelTime( Int_t t)143 Bool_t MHCalibrationBlindPixel::FillBlindPixelTime(Float_t t) 144 144 { 145 145 return fHBlindPixelTime->Fill(t) > -1; -
trunk/MagicSoft/Mars/mcalib/MHCalibrationBlindPixel.h
r2885 r2904 10 10 class TF1; 11 11 class TPaveText; 12 13 /*14 #ifndef MARS_MHCalibrationConfig15 #include "MHCalibrationConfig.h"16 #endif17 18 #ifndef MARS_MFFT19 #include "MFFT.h"20 #endif21 22 #ifndef ROOT_TH123 #include "TH1.h"24 #endif25 26 #ifndef ROOT_TH1F27 #include "TH1F.h"28 #endif29 30 #ifndef ROOT_TF131 #include "TF1.h"32 #endif33 34 #ifndef ROOT_TPaveText35 #include "TPaveText.h"36 #endif37 */38 39 40 const Double_t NoWay = 10000000000.0;41 12 42 13 class TMath; … … 47 18 48 19 TH1F* fHBlindPixelCharge; // Histogram with the single Phe spectrum 49 TH1 I* fHBlindPixelTime; // Variance of summed FADC slices20 TH1F* fHBlindPixelTime; // Variance of summed FADC slices 50 21 TH1I* fHBlindPixelChargevsN; // Summed Charge vs. Event Nr. 51 22 TH1F* fHBlindPixelPSD; // Power spectrum density of fHBlindPixelChargevsN … … 95 66 96 67 Bool_t FillBlindPixelCharge(Float_t q); 97 Bool_t FillBlindPixelTime( Int_t t);68 Bool_t FillBlindPixelTime(Float_t t); 98 69 Bool_t FillBlindPixelChargevsN(Stat_t rq, Int_t t); 99 70 … … 153 124 private: 154 125 126 const static Double_t fNoWay = 10000000000.0; 127 155 128 Bool_t InitFit(Axis_t min, Axis_t max); 156 129 void ExitFit(TF1 *f); … … 168 141 169 142 if (mu1 < mu0) 170 return NoWay;143 return fNoWay; 171 144 172 145 Double_t sigma0 = par[3]; … … 174 147 175 148 if (sigma1 < sigma0) 176 return NoWay;149 return fNoWay; 177 150 178 151 Double_t mu2 = (2.*mu1)-mu0; … … 224 197 225 198 if (mu1 < mu0) 226 return NoWay;199 return fNoWay; 227 200 228 201 Double_t sigma0 = par[3]; … … 230 203 231 204 if (sigma1 < sigma0) 232 return NoWay;205 return fNoWay; 233 206 234 207 Double_t mu2 = (2.*mu1)-mu0; … … 281 254 282 255 if (mu1 < mu0) 283 return NoWay;256 return fNoWay; 284 257 285 258 Double_t sigma0 = par[3]; … … 287 260 288 261 if (sigma1 < sigma0) 289 return NoWay;262 return fNoWay; 290 263 291 264 … … 346 319 347 320 if (mu1 < mu0) 348 return NoWay;321 return fNoWay; 349 322 350 323 Double_t sigma0 = par[3]; … … 352 325 353 326 if (sigma1 < sigma0) 354 return NoWay;327 return fNoWay; 355 328 356 329 -
trunk/MagicSoft/Mars/mcalib/MHCalibrationPINDiode.h
r2885 r2904 16 16 TH1I* fHPCharge; //-> Histogram containing the summed 32 PINDiode slices 17 17 TH1F* fHErrCharge; //-> Variance of summed FADC slices 18 TH1I* fHPTime; //-> Histogram with time evolution of summed charges 19 18 TH1F* fHPTime; //-> Histogram with time evolution of summed charges 20 19 21 20 TF1 *fVarGausFit; -
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.cc
r2885 r2904 41 41 #include <TCanvas.h> 42 42 #include <TPaveText.h> 43 #include <TText.h> 43 44 44 45 #include "MLog.h" … … 56 57 : fPixId(-1), 57 58 fTotalEntries(0), 58 fHiGains(NULL), 59 fLoGains(NULL), 59 fHChargeHiGain(NULL), 60 fHTimeHiGain(NULL), 61 fHChargevsNHiGain(NULL), 62 fHChargeLoGain(NULL), 63 fHTimeLoGain(NULL), 64 fHChargevsNLoGain(NULL), 60 65 fChargeGausFit(NULL), 61 66 fTimeGausFit(NULL), 62 67 fHivsLoGain(NULL), 63 68 fFitLegend(NULL), 64 fLowerFitRange(- 2000.),65 fChargeFirstHiGain(- 2000.5),66 fChargeLastHiGain( 9999.5),67 fChargeNbinsHiGain( 12000),68 fChargeFirstLoGain(- 2000.5),69 fLowerFitRange(-100.), 70 fChargeFirstHiGain(-100.5), 71 fChargeLastHiGain(1999.5), 72 fChargeNbinsHiGain(2100), 73 fChargeFirstLoGain(-100.5), 69 74 fChargeLastLoGain(9999.5), 70 fChargeNbinsLoGain(1 200),75 fChargeNbinsLoGain(1010), 71 76 fChargeChisquare(-1.), 72 77 fChargeProb(-1.), … … 81 86 fTimeLowerFitRangeLoGain(0), 82 87 fTimeUpperFitRangeLoGain(0), 83 fUseLoGain(kFALSE),84 fFitOK(kFALSE),85 88 fOffset(0.), 86 89 fSlope(0.) … … 111 114 Int_t ntbins = 16; 112 115 113 fHTimeHiGain = new TH1 I("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ",116 fHTimeHiGain = new TH1F("HTimeHiGain","Distribution of Mean Arrival Hi Gain Times Pixel ", 114 117 ntbins,tfirst,tlast); 115 118 fHTimeHiGain->SetXTitle("Mean Arrival Times [Hi Gain FADC slice nr]"); … … 117 120 fHTimeHiGain->SetDirectory(NULL); 118 121 119 fHTimeLoGain = new TH1 I("HTimeLoGain","Distribution of Mean Arrival Lo Gain Times Pixel ",122 fHTimeLoGain = new TH1F("HTimeLoGain","Distribution of Mean Arrival Lo Gain Times Pixel ", 120 123 ntbins,tfirst,tlast); 121 124 fHTimeLoGain->SetXTitle("Mean Arrival Times [Lo Gain FADC slice nr]"); … … 170 173 delete fHivsLoGain; 171 174 172 173 } 174 175 const Double_t MHCalibrationPixel::GetArea() const 176 { 177 return fChargeGausFit->GetParameter(0); 178 } 179 180 const Double_t MHCalibrationPixel::GetAreaErr() const 181 { 182 return fChargeGausFit->GetParError(0); 183 } 184 185 Bool_t MHCalibrationPixel::IsEmpty() 175 } 176 177 Bool_t MHCalibrationPixel::IsEmpty() const 186 178 { 187 179 return !(fHChargeHiGain->GetEntries() || fHChargeLoGain->GetEntries()); 188 180 } 189 181 182 Bool_t MHCalibrationPixel::IsUseLoGain() const 183 { 184 return TESTBIT(fFlags,kUseLoGain); 185 } 186 187 Bool_t MHCalibrationPixel::IsFitOK() const 188 { 189 return TESTBIT(fFlags,kFitOK); 190 } 191 190 192 Bool_t MHCalibrationPixel::FillChargeLoGain(Float_t q) 191 193 { … … 193 195 } 194 196 195 Bool_t MHCalibrationPixel::FillTimeLoGain( Int_t t)197 Bool_t MHCalibrationPixel::FillTimeLoGain(Float_t t) 196 198 { 197 199 return (fHTimeLoGain->Fill(t) > -1); … … 205 207 Bool_t MHCalibrationPixel::FillChargeHiGain(Float_t q) 206 208 { 207 return (fHChargeHiGain->Fill(q) 208 } 209 210 Bool_t MHCalibrationPixel::FillTimeHiGain( Int_t t)211 { 212 return (fHTimeHiGain->Fill(t) 209 return (fHChargeHiGain->Fill(q) > -1); 210 } 211 212 Bool_t MHCalibrationPixel::FillTimeHiGain(Float_t t) 213 { 214 return (fHTimeHiGain->Fill(t) > -1); 213 215 } 214 216 … … 285 287 286 288 289 Bool_t MHCalibrationPixel::SetupFill(const MParList *plist) 290 { 291 292 fHChargeHiGain->Reset(); 293 fHTimeHiGain->Reset(); 294 fHChargeLoGain->Reset(); 295 fHTimeLoGain->Reset(); 296 297 return kTRUE; 298 } 299 300 287 301 void MHCalibrationPixel::Reset() 288 302 { … … 293 307 294 308 for (Int_t i = 0; i < 16; i++) 295 fHTimeHiGain->SetBinContent(i, 1.e-20); 296 297 fChargeLastHiGain = 9999.5; 298 299 fHChargeHiGain->GetXaxis()->SetRangeUser(0.,fChargeLastHiGain); 309 fHTimeHiGain->SetBinContent(i, 1.e-20); 310 311 fChargeFirstHiGain = -100.5; 312 fChargeLastHiGain = 1999.5; 313 314 fHChargeHiGain->GetXaxis()->UnZoom(); 300 315 301 316 for (Int_t i = fHChargeLoGain->FindBin(fChargeFirstLoGain); … … 306 321 fHTimeLoGain->SetBinContent(i, 1.e-20); 307 322 323 fChargeFirstLoGain = -100.5; 308 324 fChargeLastLoGain = 9999.5; 309 325 310 fHChargeLoGain->GetXaxis()-> SetRangeUser(0.,fChargeLastLoGain);326 fHChargeLoGain->GetXaxis()->UnZoom(); 311 327 312 328 return; … … 319 335 if (fHChargeHiGain->Integral() > fHChargeLoGain->Integral()) 320 336 { 321 fUseLoGain = kFALSE;337 CLRBIT(fFlags,kUseLoGain); 322 338 return kFALSE; 323 339 } 324 340 else 325 341 { 326 fUseLoGain = kTRUE;342 SETBIT(fFlags,kUseLoGain); 327 343 return kTRUE; 328 344 } 329 345 } 330 346 331 void MHCalibrationPixel::SetPointInGraph(Float_t qhi,Float_t qlo)347 Bool_t MHCalibrationPixel::FillPointInGraph(Float_t qhi,Float_t qlo) 332 348 { 333 349 … … 337 353 fHiGains->AddAt(qhi,fTotalEntries-1); 338 354 fLoGains->AddAt(qlo,fTotalEntries-1); 355 356 return kTRUE; 339 357 340 358 } … … 350 368 fFitLegend = new TPaveText(0.05,0.05,0.95,0.95); 351 369 352 if ( fFitOK)370 if (IsFitOK()) 353 371 fFitLegend->SetFillColor(80); 354 372 else … … 360 378 const TString line1 = 361 379 Form("Mean: Q_{#mu} = %2.2f #pm %2.2f",fChargeMean,fChargeMeanErr); 362 363 fFitLegend->AddText(line1); 364 380 TText *t1 = fFitLegend->AddText(line1); 381 t1->SetBit(kCanDelete); 365 382 366 383 const TString line4 = 367 384 Form("Sigma: #sigma_{Q} = %2.2f #pm %2.2f",fChargeSigma,fChargeSigmaErr); 368 369 fFitLegend->AddText(line4); 370 385 TText *t2 = fFitLegend->AddText(line4); 386 t2->SetBit(kCanDelete); 371 387 372 388 const TString line7 = 373 389 Form("#chi^{2} / N_{dof}: %4.2f / %3i",fChargeChisquare,fChargeNdf); 374 375 fFitLegend->AddText(line7); 376 390 TText *t3 = fFitLegend->AddText(line7); 391 t3->SetBit(kCanDelete); 377 392 378 393 const TString line8 = 379 394 Form("Probability: %4.3f ",fChargeProb); 380 381 fFitLegend->AddText(line8); 382 383 if (fFitOK) 384 fFitLegend->AddText("Result of the Fit: OK"); 395 TText *t4 = fFitLegend->AddText(line8); 396 t4->SetBit(kCanDelete); 397 398 if (IsFitOK()) 399 { 400 TText *t5 = fFitLegend->AddText("Result of the Fit: OK"); 401 t5->SetBit(kCanDelete); 402 } 385 403 else 386 fFitLegend->AddText("Result of the Fit: NOT OK"); 387 404 { 405 TText *t6 = fFitLegend->AddText("Result of the Fit: NOT OK"); 406 t6->SetBit(kCanDelete); 407 } 408 388 409 fFitLegend->SetBit(kCanDelete); 389 410 fFitLegend->Draw(); 390 411 391 412 } 413 414 415 TObject *MHCalibrationPixel::DrawClone(Option_t *option) const 416 { 417 418 gROOT->SetSelectedPad(NULL); 419 420 MHCalibrationPixel *newobj = (MHCalibrationPixel*)Clone(); 421 422 if (!newobj) 423 return 0; 424 newobj->SetBit(kCanDelete); 425 426 427 if (strlen(option)) 428 newobj->Draw(option); 429 else 430 newobj->Draw(GetDrawOption()); 431 432 return newobj; 433 } 434 392 435 393 436 … … 400 443 401 444 if (!fHivsLoGain) 402 445 FitHiGainvsLoGain(); 403 446 404 447 gStyle->SetOptFit(0); 405 gStyle->SetOptStat(1111111); 448 gStyle->SetOptStat(111111); 449 450 gROOT->SetSelectedPad(NULL); 406 451 407 452 TCanvas *c = MakeDefCanvas(this,600,900); 408 409 gROOT->SetSelectedPad(NULL);410 453 411 454 c->Divide(2,4); … … 420 463 gPad->SetLogy(0); 421 464 422 fHChargeHiGain->Draw Copy(opt);465 fHChargeHiGain->Draw(opt); 423 466 424 467 c->Modified(); 425 468 c->Update(); 426 469 427 if ( fUseLoGain)470 if (IsUseLoGain()) 428 471 { 429 472 … … 436 479 gPad->SetLogy(0); 437 480 438 fHChargeLoGain->Draw Copy(opt);481 fHChargeLoGain->Draw(opt); 439 482 440 483 if (fChargeGausFit) 441 484 { 442 if ( fFitOK)485 if (IsFitOK()) 443 486 fChargeGausFit->SetLineColor(kGreen); 444 487 else 445 488 fChargeGausFit->SetLineColor(kRed); 446 489 447 fChargeGausFit->Draw Copy("same");490 fChargeGausFit->Draw("same"); 448 491 } 449 492 c->Modified(); … … 453 496 gROOT->SetSelectedPad(NULL); 454 497 gStyle->SetOptFit(); 455 fHivsLoGain->Draw("prof");456 498 if (fHivsLoGain) 499 fHivsLoGain->Draw("prof"); 457 500 gPad->Modified(); 458 501 gPad->Update(); … … 466 509 if (fChargeGausFit) 467 510 { 468 if ( fFitOK)511 if (IsFitOK()) 469 512 fChargeGausFit->SetLineColor(kGreen); 470 513 else 471 514 fChargeGausFit->SetLineColor(kRed); 472 515 473 fChargeGausFit->Draw Copy("same");516 fChargeGausFit->Draw("same"); 474 517 } 475 518 … … 482 525 gPad->SetLogy(0); 483 526 484 fHChargeLoGain->Draw Copy(opt);527 fHChargeLoGain->Draw(opt); 485 528 c->Modified(); 486 529 c->Update(); … … 493 536 gROOT->SetSelectedPad(NULL); 494 537 gStyle->SetOptFit(); 495 fHivsLoGain->Draw("prof"); 538 if (fHivsLoGain) 539 fHivsLoGain->Draw("prof"); 496 540 gPad->Modified(); 497 541 gPad->Update(); … … 506 550 gPad->SetTicks(); 507 551 gPad->SetLogy(0); 508 fHTimeHiGain->Draw Copy(opt);552 fHTimeHiGain->Draw(opt); 509 553 c->Modified(); 510 554 c->Update(); 511 555 512 if ( fUseLoGain)556 if (IsUseLoGain()) 513 557 { 514 558 … … 516 560 gPad->SetTicks(); 517 561 gPad->SetLogy(0); 518 fHTimeLoGain->Draw Copy(opt);562 fHTimeLoGain->Draw(opt); 519 563 c->Modified(); 520 564 c->Update(); … … 527 571 fTimeGausFit->SetLineColor(kGreen); 528 572 529 fTimeGausFit->Draw Copy("same");573 fTimeGausFit->Draw("same"); 530 574 c->Modified(); 531 575 c->Update(); … … 541 585 fTimeGausFit->SetLineColor(kGreen); 542 586 543 fTimeGausFit->Draw Copy("same");587 fTimeGausFit->Draw("same"); 544 588 c->Modified(); 545 589 c->Update(); … … 549 593 gPad->SetTicks(); 550 594 gPad->SetLogy(0); 551 fHTimeLoGain->Draw Copy(opt);595 fHTimeLoGain->Draw(opt); 552 596 c->Modified(); 553 597 c->Update(); … … 559 603 c->cd(7); 560 604 gPad->SetTicks(); 561 fHChargevsNHiGain->Draw Copy(opt);605 fHChargevsNHiGain->Draw(opt); 562 606 c->Modified(); 563 607 c->Update(); … … 565 609 c->cd(8); 566 610 gPad->SetTicks(); 567 fHChargevsNLoGain->Draw Copy(opt);611 fHChargevsNLoGain->Draw(opt); 568 612 c->Modified(); 569 613 c->Update(); 570 614 571 615 return; 572 616 } 573 617 … … 575 619 { 576 620 621 *fLog << inf << "Fit Hi Gain vs Lo Gain " << endl; 622 577 623 if (fHivsLoGain) 624 return; 625 626 if ((!fHiGains) || (!fLoGains) || (fHiGains->GetSize() == 0) || (fLoGains->GetSize() == 0)) 578 627 return; 579 628 … … 587 636 titleHiLoGain += fPixId; 588 637 fHivsLoGain->SetName(titleHiLoGain.Data()); 589 590 638 591 639 for (Int_t i=0;i<fTotalEntries;i++) 592 640 fHivsLoGain->Fill(fHiGains->At(i),fLoGains->At(i),1); 593 641 594 fHivsLoGain->Fit("pol1","rq","",fHivsLoGain->GetMean()-2.5*fHivsLoGain->GetRMS(),fHivsLoGain->GetMean()+2.*fHivsLoGain->GetRMS()); 642 fHivsLoGain->Fit("pol1","rq","",fHivsLoGain->GetMean()-2.5*fHivsLoGain->GetRMS(), 643 fHivsLoGain->GetMean()+2.0*fHivsLoGain->GetRMS()); 595 644 596 645 fOffset = fHivsLoGain->GetFunction("pol1")->GetParameter(0); … … 772 821 if (fChargeProb < gkProbLimit) 773 822 { 774 *fLog << warn << "WARNING: Fit Probability " << fChargeProb775 << " is smaller than the allowed value: " << gkProbLimit << endl;776 fFitOK = kFALSE;823 // *fLog << warn << "WARNING: Fit Probability " << fChargeProb 824 // << " is smaller than the allowed value: " << gkProbLimit << endl; 825 CLRBIT(fFlags,kFitOK); 777 826 return kFALSE; 778 827 } 779 828 780 fFitOK = kTRUE;829 SETBIT(fFlags,kFitOK); 781 830 return kTRUE; 782 831 } … … 852 901 if (fChargeProb < gkProbLimit) 853 902 { 854 *fLog << warn << "WARNING: Fit Probability " << fChargeProb855 << " is smaller than the allowed value: " << gkProbLimit << endl;856 fFitOK = kFALSE;903 // *fLog << warn << "WARNING: Fit Probability " << fChargeProb 904 // << " is smaller than the allowed value: " << gkProbLimit << endl; 905 CLRBIT(fFlags,kFitOK); 857 906 return kFALSE; 858 907 } 859 908 860 861 fFitOK = kTRUE; 909 SETBIT(fFlags,kFitOK); 862 910 863 911 return kTRUE; -
trunk/MagicSoft/Mars/mcalib/MHCalibrationPixel.h
r2885 r2904 21 21 Int_t fTotalEntries; // Number of entries 22 22 23 TArrayF *fHiGains; 24 TArrayF *fLoGains; 23 TArrayF *fHiGains; //-> 24 TArrayF *fLoGains; //-> 25 25 26 26 protected: 27 27 28 28 TH1F* fHChargeHiGain; // Summed FADC slices High Gain 29 TH1 I* fHTimeHiGain; // Mean arrival time in number of FADC sice29 TH1F* fHTimeHiGain; // Mean arrival time in number of FADC sice 30 30 TH1I* fHChargevsNHiGain; // Summed Charge vs. Event Nr. 31 31 32 32 TH1F* fHChargeLoGain; // Summed FADC slices Low Gain 33 TH1 I* fHTimeLoGain; // Mean arrival time in number of FADC sice33 TH1F* fHTimeLoGain; // Mean arrival time in number of FADC sice 34 34 TH1I* fHChargevsNLoGain; // Summed Charge vs. Event Nr. 35 35 … … 70 70 Byte_t fTimeLowerFitRangeLoGain; 71 71 Byte_t fTimeUpperFitRangeLoGain; 72 73 Byte_t fFlags; 74 75 enum { kUseLoGain, kFitOK }; 72 76 73 Bool_t fUseLoGain;74 Bool_t fFitOK;75 76 77 Double_t fOffset; 77 78 Double_t fSlope; … … 87 88 88 89 // Setters 89 void Set PointInGraph(Float_t qhi, Float_t qlo);90 void SetUseLoGain(Bool_t b = kTRUE) { fUseLoGain = b; }90 void SetUseLoGain(Bool_t b = kTRUE) 91 { b ? SETBIT(fFlags, kUseLoGain) : SETBIT(fFlags, kUseLoGain); } 91 92 92 93 void SetTimeFitRangesHiGain(Byte_t low, Byte_t up) { fTimeLowerFitRangeHiGain = low, … … 105 106 const Double_t GetChargeSigma() const { return fChargeSigma; } 106 107 const Double_t GetChargeSigmaErr() const { return fChargeSigmaErr; } 107 const Double_t GetArea() const;108 const Double_t GetAreaErr() const;109 110 108 const Double_t GetChargeChiSquare() const { return fChargeChisquare; } 111 109 const Double_t GetChargeProb() const { return fChargeProb; } … … 124 122 const Int_t GetTimeNdf() const { return fTimeNdf; } 125 123 126 const TH1 I*GetHTime() { return fHTimeHiGain; }127 const TH1 I*GetHTime() const { return fHTimeHiGain; }124 const TH1F *GetHTime() { return fHTimeHiGain; } 125 const TH1F *GetHTime() const { return fHTimeHiGain; } 128 126 129 127 const TH1I *GetHChargevsN() { return fHChargevsNHiGain; } … … 135 133 Bool_t UseLoGain(); 136 134 137 Bool_t IsFitOK() { return fFitOK; } 138 Bool_t IsEmpty(); 135 Bool_t IsFitOK() const; 136 Bool_t IsUseLoGain() const; 137 Bool_t IsEmpty() const; 139 138 140 139 // Fill histos 141 140 Bool_t FillChargeLoGain(Float_t q); 142 Bool_t FillTimeLoGain( Int_t t);141 Bool_t FillTimeLoGain(Float_t t); 143 142 Bool_t FillChargevsNLoGain(Float_t q, Int_t n); 144 143 145 144 Bool_t FillChargeHiGain(Float_t q); 146 Bool_t FillTimeHiGain( Int_t t);145 Bool_t FillTimeHiGain(Float_t t); 147 146 Bool_t FillChargevsNHiGain(Float_t q, Int_t n); 148 147 148 Bool_t FillPointInGraph(Float_t qhi, Float_t qlo); 149 150 Bool_t SetupFill(const MParList *pList); 151 Bool_t Fill(const MParContainer *, const Stat_t w=1) { return kTRUE; } 152 149 153 // Fits 150 154 Bool_t FitChargeHiGain(Option_t *option="RQ0"); … … 158 162 // Draws 159 163 virtual void Draw(Option_t *option=""); 160 164 TObject *DrawClone(Option_t *option="") const; 165 161 166 // Prints 162 167 void PrintChargeFitResult();
Note:
See TracChangeset
for help on using the changeset viewer.