Changeset 3202 for trunk/MagicSoft/Mars/mcalib
- Timestamp:
- 02/16/04 16:00:57 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MCalibrationCalc.cc
r3197 r3202 34 34 // for every pixel. It is filled in the following way: 35 35 // 36 // ProProcess: Search for MPedestalCam, MExtractedSignalCam 36 // ProProcess: Search for MPedestalCam, MExtractedSignalCam and MExtractedSignalBlindPixel 37 37 // Initialize MCalibrationCam 38 38 // Initialize pulser light wavelength … … 69 69 // MPedestalCam 70 70 // MExtractedSignalCam 71 // MExtractedSignalBlindPixel 71 72 // 72 73 // Output Containers: … … 102 103 #include "MExtractedSignalCam.h" 103 104 #include "MExtractedSignalPix.h" 105 #include "MExtractedSignalBlindPixel.h" 104 106 105 107 #include "MCalibrationBlindPix.h" … … 109 111 using namespace std; 110 112 111 const UInt_t MCalibrationCalc::fgBlindPixelId = 559; 112 const UInt_t MCalibrationCalc::fgPINDiodeId = 9999; 113 const Byte_t MCalibrationCalc::fgSaturationLimit = 254; 114 const Int_t MCalibrationCalc::fgBlindPixelFirst = 3; 115 const Int_t MCalibrationCalc::fgBlindPixelLast = 14; 116 const Int_t MCalibrationCalc::fgBlindPixelSinglePheCut = 400; 113 const UInt_t MCalibrationCalc::fgBlindPixelIdx = 559; 114 const UInt_t MCalibrationCalc::fgPINDiodeIdx = 9999; 115 const UInt_t MCalibrationCalc::fgBlindPixelSinglePheCut = 400; 117 116 118 117 // -------------------------------------------------------------------------- … … 134 133 135 134 Clear(); 136 SetBlindPixelRange(); 135 SetBlindPixelIdx(); 136 SetPINDiodeIdx(); 137 137 } 138 138 … … 146 146 CLRBIT(fFlags, kHiGainOverFlow); 147 147 CLRBIT(fFlags, kLoGainOverFlow); 148 149 fBlindPixelFirst = 0;150 fBlindPixelLast = 0;151 148 152 149 fNumBlindPixelSinglePhe = 0; … … 159 156 160 157 fColor = kECT1; 161 }162 163 void MCalibrationCalc::SetBlindPixelRange(Int_t first, Int_t last)164 {165 166 fBlindPixelFirst = first;167 fBlindPixelLast = last;168 169 158 } 170 159 … … 251 240 return kFALSE; 252 241 } 242 243 fBlindPixel = (MExtractedSignalBlindPixel*)pList->FindObject("MExtractedSignalBlindPixel"); 244 if (!fBlindPixel) 245 { 246 *fLog << err << dbginf << "Cannot find MExtractedSignalBlindPixel ... aborting" << endl; 247 return kFALSE; 248 } 253 249 254 250 return kTRUE; … … 303 299 304 300 // Exclude the blind pixel and the PIN Diode from normal pixel calibration: 305 if (i == f gBlindPixelId)301 if (i == fBlindPixelIdx) 306 302 pix.SetExcluded(); 307 303 308 if (i == f gPINDiodeId)304 if (i == fPINDiodeIdx) 309 305 pix.SetExcluded(); 310 306 … … 381 377 { 382 378 383 //384 // Initialize pointers to blind pixel, PIN Diode and individual pixels385 //386 MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel());387 379 388 380 MRawEvtPixelIter pixel(fRawEvt); … … 391 383 // Create a loop to fill the calibration histograms 392 384 // Search for: a signal in MExtractedSignalCam 385 // Search for: a signal in MExtractedSignalBlindPixel 393 386 // Fill histograms with: 394 387 // charge 395 388 // charge vs. event nr. 396 389 // 390 // 391 // Initialize pointers to blind pixel and individual pixels 392 // 393 // FIXME: filling the bind pixel histograms in this class is preliminary 394 // and will be replaced soon to fill them with MFillH 395 // 396 MCalibrationBlindPix &blindpixel = *(fCalibrations->GetBlindPixel()); 397 MExtractedSignalBlindPixel &blindsig = (*fBlindPixel); 398 399 const UInt_t signal = blindsig.GetExtractedSignal(); 400 401 if (!blindpixel.FillCharge(signal)) 402 *fLog << warn << 403 "Overflow or Underflow occurred filling Blind Pixel sum = " << signal << endl; 404 405 blindpixel.FillGraphs(signal,0); 406 407 TH1I *hist; 408 409 if (signal > fBlindPixelSinglePheCut) 410 { 411 hist = (blindpixel.GetHist())->GetHSinglePheFADCSlices(); 412 fNumBlindPixelSinglePhe++; 413 } 414 else 415 { 416 hist = (blindpixel.GetHist())->GetHPedestalFADCSlices(); 417 fNumBlindPixelPedestal++; 418 } 419 420 pixel.Jump(fBlindPixelIdx); 421 422 const Byte_t *ptr = pixel.GetHiGainSamples(); 423 424 for (Int_t i=1;i<16;i++) 425 hist->Fill(i,*ptr++); 426 427 ptr = pixel.GetLoGainSamples(); 428 for (Int_t i=16;i<31;i++) 429 hist->Fill(i,*ptr++); 430 431 pixel.Reset(); 432 397 433 while (pixel.Next()) 398 434 { … … 400 436 const UInt_t pixid = pixel.GetPixelId(); 401 437 402 MCalibrationPix &pix = (*fCalibrations)[pixid]; 403 404 MExtractedSignalPix &sig = (*fSignals)[pixid]; 438 MCalibrationPix &pix = (*fCalibrations)[pixid]; 439 MExtractedSignalPix &sig = (*fSignals) [pixid]; 405 440 406 441 const Float_t sumhi = sig.GetExtractedSignalHiGain(); … … 408 443 409 444 Float_t abstime = 0.; 445 410 446 if (sig.IsLoGainUsed()) 411 447 abstime = (Float_t)pixel.GetIdxMaxLoGainSample(); … … 413 449 abstime = (Float_t)pixel.GetIdxMaxHiGainSample(); 414 450 415 switch(pixid) 451 if (pix.IsExcluded()) 452 continue; 453 454 pix.FillGraphs(sumhi,sumlo); 455 456 if (sig.IsLoGainUsed()) 416 457 { 417 458 418 case fgBlindPixelId: 419 420 if (TESTBIT(fFlags,kUseBlindPixelFit)) 421 { 459 if (!pix.FillChargeLoGain(sumlo)) 460 *fLog << warn << "Could not fill Lo Gain Charge of pixel: " << pixid 461 << " signal = " << sumlo << endl; 422 462 423 Byte_t *ptr = pixel.GetHiGainSamples(); 424 425 Int_t blindpixelsumhi = 0; 426 Int_t blindpixelsumlo = 0; 427 // 428 // We need a dedicated signal extractor for the blind pixel 429 // 430 Int_t diff = 0; 431 Int_t last = fBlindPixelLast; 432 Int_t first = fBlindPixelFirst; 433 434 if (last > 15) 435 { 436 diff = last - 15; 437 last = 15; 438 } 439 440 Byte_t *start = ptr + first - 1; 441 Byte_t *end = ptr + last - 1; 442 443 ptr = start; 444 445 Int_t sum = 0; 446 447 while (ptr<=end) 448 { 449 sum += *ptr; 450 ptr++; 451 } 452 453 if (diff > 0) 454 { 455 ptr = pixel.GetLoGainSamples(); 456 end = ptr + diff - 1; 457 458 while (ptr<=end) 459 { 460 sum += *ptr; 461 ptr++; 462 } 463 } 464 465 blindpixelsumhi = sum; 466 467 ptr = pixel.GetLoGainSamples(); 468 469 start = ptr + fBlindPixelFirst - 1; 470 end = ptr + fBlindPixelLast; 471 472 ptr = start; 473 474 sum = 0; 475 476 while (++ptr<end) 477 sum += *ptr; 478 479 blindpixelsumlo = sum; 480 481 // if (!CalcSignalBlindPixel(hiptr, blindpixelsumhi)) 482 // return kFALSE; 483 484 if (!blindpixel.FillCharge(blindpixelsumhi)) 485 *fLog << warn << 486 "Overflow or Underflow occurred filling Blind Pixel sum = " << blindpixelsumhi << endl; 487 488 // Byte_t *loptr = pixel.GetLoGainSamples(); 489 // CalcSignalBlindPixel(loptr, blindpixelsumlo); 490 491 blindpixel.FillGraphs(blindpixelsumhi,blindpixelsumlo); 463 if (!pix.FillAbsTimeLoGain(abstime)) 464 *fLog << warn << "Could not fill Lo Gain Abs. Time of pixel: " 465 << pixid << " time = " << abstime << endl; 466 } 467 else 468 { 469 if (!pix.FillChargeHiGain(sumhi)) 470 *fLog << warn << "Could not fill Hi Gain Charge of pixel: " << pixid 471 << " signal = " << sumhi << endl; 492 472 493 TH1I *hist; 494 495 if (blindpixelsumhi > fBlindPixelSinglePheCut) 496 { 497 hist = (blindpixel.GetHist())->GetHSinglePheFADCSlices(); 498 fNumBlindPixelSinglePhe++; 499 } 500 else 501 { 502 hist = (blindpixel.GetHist())->GetHPedestalFADCSlices(); 503 fNumBlindPixelPedestal++; 504 } 505 506 ptr = pixel.GetHiGainSamples(); 507 for (Int_t i=1;i<16;i++) 508 hist->Fill(i,*ptr++); 509 510 ptr = pixel.GetLoGainSamples(); 511 for (Int_t i=16;i<31;i++) 512 hist->Fill(i,*ptr++); 513 514 } /* if use blind pixel */ 515 516 break; 517 default: 518 519 if (pix.IsExcluded()) 520 continue; 521 522 pix.FillGraphs(sumhi,sumlo); 523 524 if (sig.IsLoGainUsed()) 525 { 526 527 if (!pix.FillChargeLoGain(sumlo)) 528 *fLog << warn << "Could not fill Lo Gain Charge of pixel: " << pixid 529 << " signal = " << sumlo << endl; 530 531 if (!pix.FillAbsTimeLoGain(abstime)) 532 *fLog << warn << "Could not fill Lo Gain Abs. Time of pixel: " 533 << pixid << " time = " << abstime << endl; 534 /* 535 if (!pix.FillRelTimeLoGain(reltime)) 536 *fLog << warn << "Could not fill Lo Gain Rel. Time of pixel: " 537 << pixid << " time = " << reltime << endl; 538 */ 539 } /* if (sig.IsLoGainUsed()) */ 540 else 541 { 542 if (!pix.FillChargeHiGain(sumhi)) 543 *fLog << warn << "Could not fill Hi Gain Charge of pixel: " << pixid 544 << " signal = " << sumhi << endl; 545 546 if (!pix.FillAbsTimeHiGain(abstime)) 547 *fLog << warn << "Could not fill Hi Gain Abs. Time of pixel: " 548 << pixid << " time = " << abstime << endl; 549 /* 550 if (!pix.FillRelTimeHiGain(reltime)) 551 *fLog << warn << "Could not fill Hi Gain Rel. Time of pixel: " 552 << pixid << " time = " << reltime << endl; 553 */ 554 } /* else (sig.IsLoGainUsed()) */ 555 break; 556 557 } /* switch(pixid) */ 473 if (!pix.FillAbsTimeHiGain(abstime)) 474 *fLog << warn << "Could not fill Hi Gain Abs. Time of pixel: " 475 << pixid << " time = " << abstime << endl; 476 } 558 477 559 478 } /* while (pixel.Next()) */ … … 584 503 585 504 // 505 // retrieve the histogram containers 506 // 507 MHCalibrationBlindPixel *hist = blindpixel.GetHist(); 508 509 // 586 510 // retrieve mean and sigma of the blind pixel pedestal, 587 511 // so that we can use it for the fit 588 512 // 589 Float_t pedestal; 590 Float_t pederr; 591 Float_t pedsigma; 592 Float_t pedsigmaerr; 593 594 const ULong_t nentries = fPedestals->GetTotalEntries(); 595 const Int_t nslices = fBlindPixelLast-fBlindPixelFirst+1; 596 const Float_t sqrslice = TMath::Sqrt((Float_t)nslices); 597 598 MPedestalPix &pedpix = (*fPedestals)[fgBlindPixelId]; 599 pedestal = pedpix.GetPedestal()*nslices; 600 pederr = pedpix.GetPedestalRms()*nslices/nentries; 601 pedsigma = pedpix.GetPedestalRms()*sqrslice; 602 pedsigmaerr = pederr/2.; 603 // 604 // retrieve the histogram containers 605 // 606 MHCalibrationBlindPixel *hist = blindpixel.GetHist(); 607 608 hist->SetMeanPedestal(pedestal); 609 hist->SetMeanPedestalErr(pederr); 610 hist->SetSigmaPedestal(pedsigma); 611 hist->SetSigmaPedestalErr(pedsigmaerr); 612 513 const UInt_t nentries = fPedestals->GetTotalEntries(); 514 const UInt_t nslices = 12; 515 const Float_t sqrslice = TMath::Sqrt((Float_t)nslices); 516 517 MPedestalPix &pedpix = (*fPedestals)[fBlindPixelIdx]; 518 if (&pedpix) 519 { 520 const Float_t pedestal = pedpix.GetPedestal()*nslices; 521 const Float_t pederr = pedpix.GetPedestalRms()*nslices/nentries; 522 const Float_t pedsigma = pedpix.GetPedestalRms()*sqrslice; 523 const Float_t pedsigmaerr = pederr/2.; 524 525 hist->SetMeanPedestal(pedestal); 526 hist->SetMeanPedestalErr(pederr); 527 hist->SetSigmaPedestal(pedsigma); 528 hist->SetSigmaPedestalErr(pedsigmaerr); 529 } 530 613 531 if (!blindpixel.FitCharge()) 614 532 { … … 708 626 709 627 710 Bool_t MCalibrationCalc::CalcSignalBlindPixel(Byte_t *ptr, Float_t &signal) const711 {712 713 Byte_t *newptr = ptr;714 Byte_t *start = ptr + fBlindPixelFirst-1;715 Byte_t *end = ptr + fBlindPixelLast;716 717 Byte_t sum = 0;718 Int_t sat = 0;719 720 newptr = start;721 722 while (ptr<end)723 {724 sum += *ptr;725 if (*ptr++ >= fgSaturationLimit)726 sat++;727 }728 729 if (sat)730 {731 *fLog << err << "HI Gain Saturation occurred in the blind pixel! "732 << " Do not know yet how to treat this ... aborting " << endl;733 *fLog << "If you need absolutely any other kind of calibration, "734 << " use SkipBlindPixelFit() " << endl;735 return kFALSE;736 }737 738 signal = (Float_t)sum;739 740 return kTRUE;741 }
Note:
See TracChangeset
for help on using the changeset viewer.