Changeset 3636 for trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc
- Timestamp:
- 04/03/04 17:27:50 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MHCalibrationChargeCam.cc
r3631 r3636 127 127 #include "MGeomPix.h" 128 128 129 #include "MHGausEvents.h" 130 129 131 #include "MBadPixelsCam.h" 130 132 #include "MBadPixelsPix.h" … … 140 142 using namespace std; 141 143 142 const Int_t MHCalibrationChargeCam::fgAverageNbins = 4000;143 144 const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01; 144 145 const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005; … … 150 151 // - all pointers to NULL 151 152 // 152 // Initializes and sets owner of (done in MHCalibrationCam):153 // - fHiGainArray, fLoGainArray154 // - fAverageHiGainAreas, fAverageLoGainAreas155 // - fAverageHiGainSectors, fAverageLoGainSectors156 //157 153 // Initializes: 158 154 // - fNumHiGainSaturationLimit to fgNumHiGainSaturationLimit 159 155 // - fNumLoGainSaturationLimit to fgNumLoGainSaturationLimit 160 // - fPulserFrequency to fgPulserFrequency (in MHCalibrationCam)161 156 // 162 157 MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title) 163 : f Cam(NULL), fRawEvt(NULL), fGeom(NULL), fBadPixels(NULL)158 : fRawEvt(NULL) 164 159 { 165 160 fName = name ? name : "MHCalibrationChargeCam"; … … 174 169 // Gets the pointers to: 175 170 // - MRawEvtData 176 // - MGeomCam 177 // 178 // Calls Delete-Function of: 179 // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray 180 // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas 181 // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors 182 // 183 Bool_t MHCalibrationChargeCam::SetupFill(const MParList *pList) 171 // 172 Bool_t MHCalibrationChargeCam::SetupHists(const MParList *pList) 184 173 { 185 174 … … 191 180 } 192 181 193 fGeom = (MGeomCam*)pList->FindObject("MGeomCam");194 if (!fGeom)195 {196 *fLog << err << "MGeomCam not found... aborting." << endl;197 return kFALSE;198 }199 200 fHiGainArray->Delete();201 fLoGainArray->Delete();202 203 fAverageHiGainAreas->Delete();204 fAverageLoGainAreas->Delete();205 206 fAverageHiGainSectors->Delete();207 fAverageLoGainSectors->Delete();208 209 182 return kTRUE; 210 183 } … … 213 186 // 214 187 // Gets or creates the pointers to: 215 // - MBadPixelsCam216 188 // - MCalibrationChargeCam 217 189 // … … 219 191 // - MExtractedSignalCam 220 192 // 221 // Initializes, if empty to MExtractedSignalCam::GetSize() for: 222 // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray 223 // 224 // Initializes, if empty to MGeomCam::GetNumAreas() for: 225 // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas 226 // 227 // Initializes, if empty to MGeomCam::GetNumSectors() for: 228 // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors 229 // 230 // Initializes TArrays to MGeomCam::GetNumAreas and MGeomCam::GetNumSectors, respectively 231 // Fills with number of valid pixels (if !MBadPixelsPix::IsBad()): 232 // - MHCalibrationCam::fAverageAreaNum[area index] 233 // - MHCalibrationCam::fAverageSectorNum[area index] 234 // 235 // Calls InitializeHiGainHists() and InitializeLoGainHists() for every entry in: 193 // Calls InitializeHists() for every entry in: 236 194 // - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray 237 195 // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas … … 239 197 // 240 198 // Sets Titles and Names for the Charge Histograms and 241 // Sets number of bins to fAverageNbins for:199 // Sets number of bins to MHCalibrationCam::fAverageNbins for: 242 200 // - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas 243 201 // - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors 244 202 // 245 Bool_t MHCalibrationChargeCam::ReInit (MParList *pList)203 Bool_t MHCalibrationChargeCam::ReInitHists(MParList *pList) 246 204 { 247 205 248 fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam"); 249 if (!fBadPixels) 250 return kFALSE; 251 252 253 fCam = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam"); 206 fCam = (MCalibrationCam*)pList->FindCreateObj("MCalibrationChargeCam"); 254 207 if (!fCam) 255 208 return kFALSE; … … 262 215 } 263 216 264 const Int_t n = signal->GetSize();217 const Int_t npixels = fGeom->GetNumPixels(); 265 218 const Int_t nsectors = fGeom->GetNumSectors(); 266 219 const Int_t nareas = fGeom->GetNumAreas(); 267 220 268 //269 // The function TArrayF::Set() already sets all entries to 0.270 //271 fAverageAreaNum. Set(nareas);272 fAverageAreaSat. Set(nareas);273 fAverageAreaSigma. Set(nareas);274 fAverageAreaSigmaErr. Set(nareas);275 fAverageAreaRelSigma. Set(nareas);276 fAverageAreaRelSigmaErr.Set(nareas);277 fAverageSectorNum. Set(nsectors);278 279 for (Int_t i=0; i<n; i++)280 {281 if ((*fBadPixels)[i].IsBad())282 continue;283 fAverageAreaNum [(*fGeom)[i].GetAidx() ]++;284 fAverageSectorNum[(*fGeom)[i].GetSector()]++;285 }286 287 221 if (fHiGainArray->GetEntries()==0) 288 222 { 289 fHiGainArray->Expand(n );290 for (Int_t i=0; i<n ; i++)223 fHiGainArray->Expand(npixels); 224 for (Int_t i=0; i<npixels; i++) 291 225 { 292 226 (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix; 293 Init ializeHiGainHists((MHCalibrationChargePix&)(*this)[i],(*fBadPixels)[i],i);227 InitHists((*this)[i],(*fBadPixels)[i],i); 294 228 } 295 229 } 296 230 297 298 231 if (fLoGainArray->GetEntries()==0) 299 232 { 300 fLoGainArray->Expand(n );301 302 for (Int_t i=0; i<n ; i++)233 fLoGainArray->Expand(npixels); 234 235 for (Int_t i=0; i<npixels; i++) 303 236 { 304 237 (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix; 305 Init ializeLoGainHists((MHCalibrationChargePix&)(*this)(i),(*fBadPixels)[i],i);238 InitHists((*this)(i),(*fBadPixels)[i],i); 306 239 } 307 240 … … 318 251 "Average HiGain FADC sums area idx "); 319 252 253 InitHists(GetAverageHiGainArea(j),fCam->GetAverageBadArea(j),j); 254 320 255 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainArea(j); 321 256 322 InitializeHiGainHists(hist,fCam->GetAverageBadArea(j),j);323 324 257 hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Area Idx "); 325 hist.Set ChargeNbins(fAverageNbins);258 hist.SetNbins(fAverageNbins); 326 259 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Area Idx "); 327 260 } … … 340 273 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainArea(j); 341 274 342 Init ializeLoGainHists(hist,fCam->GetAverageBadArea(j),j);275 InitHists(hist,fCam->GetAverageBadArea(j),j); 343 276 344 277 hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Area Idx "); 345 hist.Set ChargeNbins(fAverageNbins);278 hist.SetNbins(fAverageNbins); 346 279 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Area Idx "); 347 280 … … 361 294 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainSector(j); 362 295 363 Init ializeHiGainHists(hist,fCam->GetAverageBadSector(j),j);296 InitHists(hist,fCam->GetAverageBadSector(j),j); 364 297 365 298 hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Sector "); 366 hist.Set ChargeNbins(fAverageNbins);299 hist.SetNbins(fAverageNbins); 367 300 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Sector "); 368 301 … … 382 315 MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainSector(j); 383 316 384 Init ializeLoGainHists(hist,fCam->GetAverageBadSector(j),j);317 InitHists(hist,fCam->GetAverageBadSector(j),j); 385 318 386 319 hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Sector "); 387 hist.Set ChargeNbins(fAverageNbins);320 hist.SetNbins(fAverageNbins); 388 321 hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Sector "); 389 322 … … 394 327 } 395 328 396 // -------------------------------------------------------------397 //398 // If MBadPixelsPix::IsBad():399 // - calls MHCalibrationChargePix::SetExcluded()400 //401 // Calls:402 // - MHCalibrationChargePix::Init()403 // - MHCalibrationChargePix::ChangeHistId(i)404 // - MHGausEvents::SetEventFrequency(fPulserFrequency)405 //406 void MHCalibrationChargeCam::InitializeHiGainHists(MHCalibrationChargePix &hist, MBadPixelsPix &bad, const Int_t i)407 {408 409 if (bad.IsBad())410 {411 *fLog << warn << "Excluded pixel: " << i << " from calibration " << endl;412 hist.SetExcluded();413 }414 415 hist.Init();416 hist.ChangeHistId(i);417 hist.SetEventFrequency(fPulserFrequency);418 419 }420 421 // -------------------------------------------------------------422 //423 // If MBadPixelsPix::IsBad():424 // - calls MHCalibrationChargePix::SetExcluded()425 //426 // Calls:427 // - MHCalibrationChargePix::Init()428 // - MHCalibrationChargePix::ChangeHistId(i)429 // - MHGausEvents::SetEventFrequency(fPulserFrequency)430 //431 void MHCalibrationChargeCam::InitializeLoGainHists(MHCalibrationChargePix &hist,MBadPixelsPix &bad, const Int_t i)432 {433 434 if (bad.IsBad())435 hist.SetExcluded();436 437 hist.Init();438 hist.ChangeHistId(i);439 hist.SetEventFrequency(fPulserFrequency);440 }441 442 329 443 330 // -------------------------------------------------------------------------- 444 331 // 445 332 // Retrieves from MExtractedSignalCam: 333 // - first used LoGain FADC slice 334 // 335 // Retrieves from MGeomCam: 446 336 // - number of pixels 447 // - first used LoGain FADC slice448 //449 // Retrieves from MGeomCam:450 337 // - number of pixel areas 451 338 // - number of sectors … … 453 340 // For all TObjArray's (including the averaged ones), the following steps are performed: 454 341 // 455 // 1) Test size and return kFALSE if not matching 456 // 457 // 2) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with: 342 // 1) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with: 458 343 // - MExtractedSignalPix::GetExtractedSignalHiGain(); 459 344 // - MExtractedSignalPix::GetExtractedSignalLoGain(); 460 345 // 461 // 3) Set number of saturated slices (MHCalibrationChargePix::SetSaturated()) with:346 // 2) Set number of saturated slices (MHCalibrationChargePix::SetSaturated()) with: 462 347 // - MExtractedSignalPix::GetNumHiGainSaturated(); 463 348 // - MExtractedSignalPix::GetNumLoGainSaturated(); 464 349 // 465 // 4) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with:350 // 3) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with: 466 351 // - MRawEvtPixelIter::GetIdxMaxHiGainSample(); 467 352 // - MRawEvtPixelIter::GetIdxMaxLoGainSample(first slice); 468 353 // 469 Bool_t MHCalibrationChargeCam::Fill (const MParContainer *par, const Stat_t w)354 Bool_t MHCalibrationChargeCam::FillHists(const MParContainer *par, const Stat_t w) 470 355 { 471 356 … … 477 362 } 478 363 479 const Int_t npixels = signal->GetSize(); 480 const Int_t lofirst = signal->GetFirstUsedSliceLoGain(); 364 const Int_t npixels = fGeom->GetNumPixels(); 481 365 const Int_t nareas = fGeom->GetNumAreas(); 482 366 const Int_t nsectors = fGeom->GetNumSectors(); 483 484 if (fHiGainArray->GetEntries() != npixels) 485 { 486 *fLog << err << "ERROR - Size mismatch in number of pixels ... abort." << endl; 487 return kFALSE; 488 } 489 490 if (fLoGainArray->GetEntries() != npixels) 491 { 492 *fLog << err << "ERROR - Size mismatch in number of pixels ... abort." << endl; 493 return kFALSE; 494 } 495 496 if (fAverageHiGainAreas->GetEntries() != nareas) 497 { 498 *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl; 499 return kFALSE; 500 } 501 502 if (fAverageLoGainAreas->GetEntries() != nareas) 503 { 504 *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl; 505 return kFALSE; 506 } 507 508 if (fAverageHiGainSectors->GetEntries() != nsectors) 509 { 510 *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl; 511 return kFALSE; 512 } 513 514 if (fAverageLoGainSectors->GetEntries() != nsectors) 515 { 516 *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl; 517 return kFALSE; 518 } 367 const Int_t lofirst = signal->GetFirstUsedSliceLoGain(); 519 368 520 369 Float_t sumhiarea [nareas], sumloarea [nareas], timehiarea [nareas], timeloarea [nareas]; … … 526 375 { 527 376 sumhiarea [j] = sumloarea [j] = timehiarea [j] = timeloarea [j] = 0.; 377 sathiarea [j] = satloarea [j] = 0; 378 } 379 380 for (UInt_t j=0; j<nsectors; j++) 381 { 528 382 sumhisector[j] = sumlosector[j] = timehisector[j] = timelosector[j] = 0.; 529 sathiarea [j] = satloarea [j] = 0;530 383 sathisector[j] = satlosector[j] = 0; 531 384 } 532 385 386 533 387 for (Int_t i=0; i<npixels; i++) 534 388 { … … 596 450 } 597 451 598 599 452 for (UInt_t j=0; j<nareas; j++) 600 453 { … … 642 495 // For all TObjArray's (including the averaged ones), the following steps are performed: 643 496 // 644 // 1) Return if the pixel is excluded 645 // 646 // 2) Call to FinalizeHiGainHists() and FinalizeLoGainHists() 647 // 648 // For all averaged areas, the fitted sigma is multiplied with the square root of 649 // the number involved pixels 650 // 651 Bool_t MHCalibrationChargeCam::Finalize() 497 // 1) Returns if the pixel is excluded. 498 // 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation() 499 // or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated ) 500 // 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag 501 // MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored, 502 // otherwise the Hi-Gain ones. 503 // 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays() 504 // and sets the flags (if occurring): 505 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) 506 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted ) 507 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) 508 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating ) 509 // 5) Retrieves the results and store them in MCalibrationChargePix 510 // 511 Bool_t MHCalibrationChargeCam::FinalizeHists() 652 512 { 653 513 … … 656 516 657 517 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i]; 658 518 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 519 659 520 if (histhi.IsExcluded()) 660 521 continue; 661 522 662 MCalibrationChargePix &pix = (*fCam)[i]; 523 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries()) 524 { 525 pix.SetHiGainSaturation(); 526 histhi.CreateFourierSpectrum(); 527 continue; 528 } 529 530 pix.SetAbsTimeMean ( histhi.GetAbsTimeMean()); 531 pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() ); 532 } 533 534 for (Int_t i=0; i<fLoGainArray->GetSize(); i++) 535 { 536 537 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i); 663 538 MBadPixelsPix &bad = (*fBadPixels)[i]; 664 665 FinalizeHiGainHists(histhi,pix,bad);666 667 }668 669 for (Int_t i=0; i<fLoGainArray->GetSize(); i++)670 {671 672 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);673 539 674 540 if (histlo.IsExcluded()) 675 541 continue; 676 542 677 MCalibrationChargePix &pix = (*fCam)[i]; 678 MBadPixelsPix &bad = (*fBadPixels)[i]; 679 680 FinalizeLoGainHists(histlo,pix,bad); 681 682 } 683 543 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries()) 544 { 545 *fLog << warn << "Saturated Lo Gain histogram in pixel: " << i << endl; 546 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation ); 547 histlo.CreateFourierSpectrum(); 548 continue; 549 } 550 551 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 552 553 if (pix.IsHiGainSaturation()) 554 { 555 pix.SetAbsTimeMean ( histlo.GetAbsTimeMean()); 556 pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() ); 557 } 558 } 559 684 560 for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++) 685 561 { 686 562 687 563 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j); 688 MCalibrationChargePix &pix = fCam->GetAverageArea(j); 689 MBadPixelsPix &bad = fCam->GetAverageBadArea(j); 690 691 FinalizeHiGainHists(histhi,pix,bad); 564 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j); 565 566 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries()) 567 { 568 pix.SetHiGainSaturation(); 569 histhi.CreateFourierSpectrum(); 570 continue; 571 } 572 573 pix.SetAbsTimeMean ( histhi.GetAbsTimeMean()); 574 pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() ); 692 575 } 693 576 … … 696 579 697 580 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j); 698 MCalibrationChargePix &pix = fCam->GetAverageArea(j); 699 MBadPixelsPix &bad = fCam->GetAverageBadArea(j); 700 701 FinalizeLoGainHists(histlo,pix,bad); 581 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(j); 582 583 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries()) 584 { 585 *fLog << warn << "Saturated Lo Gain histogram in area idx: " << j << endl; 586 histlo.CreateFourierSpectrum(); 587 continue; 588 } 589 590 if (pix.IsHiGainSaturation()) 591 { 592 pix.SetAbsTimeMean ( histlo.GetAbsTimeMean()); 593 pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() ); 594 } 702 595 } 703 596 … … 706 599 707 600 MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j); 708 MCalibrationChargePix &pix = fCam->GetAverageSector(j); 601 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j); 602 603 if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries()) 604 { 605 pix.SetHiGainSaturation(); 606 histhi.CreateFourierSpectrum(); 607 continue; 608 } 609 610 pix.SetAbsTimeMean ( histhi.GetAbsTimeMean()); 611 pix.SetAbsTimeRms ( histhi.GetAbsTimeRms() ); 612 } 613 614 for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++) 615 { 616 617 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j); 618 MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(j); 709 619 MBadPixelsPix &bad = fCam->GetAverageBadSector(j); 710 620 711 FinalizeHiGainHists(histhi,pix,bad); 712 } 713 714 for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++) 715 { 716 717 MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j); 718 MCalibrationChargePix &pix = fCam->GetAverageSector(j); 719 MBadPixelsPix &bad = fCam->GetAverageBadSector(j); 720 721 FinalizeLoGainHists(histlo,pix,bad); 722 } 723 724 for (Int_t j=0; j<fGeom->GetNumAreas();j++) 725 { 726 727 MCalibrationChargePix &pix = fCam->GetAverageArea(j); 621 if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries()) 622 { 623 *fLog << warn << "Saturated Lo Gain histogram in sector: " << j << endl; 624 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation ); 625 histlo.CreateFourierSpectrum(); 626 continue; 627 } 728 628 729 629 if (pix.IsHiGainSaturation()) 730 fAverageAreaSat[j]++;731 732 fAverageAreaSigma[j] = pix.GetSigmaCharge () * TMath::Sqrt((Float_t)fAverageAreaNum[j]);733 fAverageAreaSigmaErr[j] = pix.GetSigmaChargeErr () * TMath::Sqrt((Float_t)fAverageAreaNum[j]);734 735 pix.SetSigmaCharge (fAverageAreaSigma[j]);736 pix.SetSigmaChargeErr(fAverageAreaSigmaErr[j]);737 738 fAverageAreaRelSigma[j] = fAverageAreaSigma[j] / pix.GetMeanCharge();739 740 Float_t relsigmaerr = fAverageAreaSigmaErr[j]*fAverageAreaSigmaErr[j]741 / (fAverageAreaSigma[j] *fAverageAreaSigma[j]);742 relsigmaerr += pix.GetMeanChargeErr()*pix.GetMeanChargeErr()743 / (pix.GetMeanCharge() *pix.GetMeanCharge() );744 relsigmaerr *= fAverageAreaRelSigma[j];745 fAverageAreaRelSigmaErr[j] = TMath::Sqrt(relsigmaerr);746 747 }748 630 { 631 pix.SetAbsTimeMean ( histlo.GetAbsTimeMean()); 632 pix.SetAbsTimeRms ( histlo.GetAbsTimeRms() ); 633 } 634 } 635 636 // 637 // Perform the fitting for the High Gain (done in MHCalibrationCam) 638 // 639 FitHiGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels), 640 MBadPixelsPix::kHiGainNotFitted, 641 MBadPixelsPix::kHiGainOscillating); 642 // 643 // Perform the fitting for the Low Gain (done in MHCalibrationCam) 644 // 645 FitLoGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels), 646 MBadPixelsPix::kLoGainNotFitted, 647 MBadPixelsPix::kLoGainOscillating); 648 749 649 return kTRUE; 750 650 } 751 651 752 // --------------------------------------------------------------------------- 753 // 754 // Returns if the histogram is empty and sets the following flag: 755 // - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun) 756 // 757 // Returns if the number of saturated slices (MHCalibrationChargePix::GetSaturated()) is 758 // higher than the allowed limit (fNumHiGainSaturationLimit*histogram-entries), creates 759 // the fourier spectrum and sets the following flags: 760 // - MCalibrationChargePix::SetHiGainSaturation() 761 // 762 // Fits the histograms with a Gaussian, in case of failure 763 // calls MHCalibrationChargePix::RepeatFit(), in case of repeated failure 764 // calls MHGausEvents::BypassFit() and sets the following flags: 765 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) 766 // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun ) 767 // 768 // Counts the number of pickup events 769 // 770 // Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK(). 771 // In case no, sets the following flags: 772 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) 773 // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun ) 774 // 775 // Retrieves the results and store them in MCalibrationChargePix 776 // 777 void MHCalibrationChargeCam::FinalizeHiGainHists(MHCalibrationChargePix &hist, 778 MCalibrationChargePix &pix, 779 MBadPixelsPix &bad) 652 // -------------------------------------------------------------------------- 653 // 654 // Takes the decisions under which conditions a pixel is declared: 655 // MBadPixelsPix::kUnsuitableRun or MBadPixelsPix::kUnreliableRun, namely: 656 // * if MBadPixelsPix::kHiGainNotFitted and !MCalibrationPix::IsHiGainSaturation() 657 // sets MBadPixelsPix::kUnreliableRun 658 // * if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation() 659 // sets MBadPixelsPix::kUnreliableRun 660 // * if MBadPixelsPix::kLoGainNotFitted and MCalibrationPix::IsLoGainSaturation() 661 // sets MBadPixelsPix::kUnreliableRun 662 // * if MBadPixelsPix::kLoGainOscillating and MCalibrationPix::IsLoGainSaturation() 663 // sets MBadPixelsPix::kUnreliableRun 664 // * if MBadPixelsPix::kLoGainSaturation 665 // sets MBadPixelsPix::kUnsuitableRun 666 // 667 void MHCalibrationChargeCam::FinalizeBadPixels() 780 668 { 781 782 if (hist.IsEmpty()) 783 { 784 *fLog << warn << "Empty Hi Gain histogram in pixel: " << pix.GetPixId() << endl; 785 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 786 return; 787 } 788 789 if (hist.GetSaturated() > fNumHiGainSaturationLimit*hist.GetHGausHist()->GetEntries()) 790 { 791 *fLog << warn << "Saturated Hi Gain histogram in pixel: " << pix.GetPixId() << endl; 792 pix.SetHiGainSaturation(); 793 hist.CreateFourierSpectrum(); 794 return; 795 } 796 797 // 798 // 2) Fit the Hi Gain histograms with a Gaussian 799 // 800 if (!hist.FitGaus()) 801 // 802 // 3) In case of failure set the bit Fitted to false and take histogram means and RMS 803 // 804 if (!hist.RepeatFit()) 805 { 806 hist.BypassFit(); 807 *fLog << warn << "Hi Gain could not be fitted in pixel: " << pix.GetPixId() << endl; 808 bad.SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ); 809 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun ); 810 } 811 812 // 813 // 4) Check for pickup 814 // 815 hist.CountPickup(); 816 817 // 818 // 5) Check for oscillations 819 // 820 hist.CreateFourierSpectrum(); 821 822 if (!hist.IsFourierSpectrumOK()) 823 { 824 *fLog << warn << "Oscillating Hi Gain in pixel: " << pix.GetPixId() << endl; 825 bad.SetUncalibrated( MBadPixelsPix::kHiGainOscillating ); 826 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun ); 827 } 828 829 // 830 // 6) Retrieve the results and store them in this class 831 // 832 pix.SetHiGainMeanCharge( hist.GetMean() ); 833 pix.SetHiGainMeanChargeErr( hist.GetMeanErr() ); 834 pix.SetHiGainSigmaCharge( hist.GetSigma() ); 835 pix.SetHiGainSigmaChargeErr( hist.GetSigmaErr() ); 836 pix.SetHiGainChargeProb ( hist.GetProb() ); 837 838 pix.SetAbsTimeMean ( hist.GetAbsTimeMean()); 839 pix.SetAbsTimeRms ( hist.GetAbsTimeRms() ); 840 841 pix.SetHiGainNumPickup ( hist.GetPickup() ); 842 669 670 for (Int_t i=0; i<fBadPixels->GetSize(); i++) 671 { 672 673 MBadPixelsPix &bad = (*fBadPixels)[i]; 674 MCalibrationPix &pix = (*fCam)[i]; 675 676 if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted )) 677 if (!pix.IsHiGainSaturation()) 678 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun ); 679 680 if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOscillating )) 681 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun ); 682 683 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainNotFitted )) 684 if (pix.IsHiGainSaturation()) 685 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun ); 686 687 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOscillating )) 688 if (pix.IsHiGainSaturation()) 689 bad.SetUnsuitable( MBadPixelsPix::kUnreliableRun ); 690 691 if (bad.IsUncalibrated( MBadPixelsPix::kLoGainSaturation )) 692 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun ); 693 } 843 694 } 844 845 // ---------------------------------------------------------------------------846 //847 // Returns if the histogram is empty. If yes and the flag MCalibrationChargePix::IsHiGainSaturation()848 // is set, sets the following flag:849 // - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun)850 //851 // Returns if the number of saturated slices (MHCalibrationChargePix::GetSaturated()) is852 // higher than the allowed limit (fNumLoGainSaturationLimit*histogram-entries), creates853 // the fourier spectrum and sets the following flags:854 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturation );855 // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnsuitableRun );856 //857 // Fits the histograms with a Gaussian, in case of failure calls MHCalibrationChargePix::RepeatFit(),858 // in case of repeated failure calls MHGausEvents::BypassFit() and sets the following flags:859 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )860 // If the flag MCalibrationChargePix::IsHiGainSaturation() is set, sets additionally:861 // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )862 //863 // Counts the number of pickup events864 //865 // Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK().866 // In case no, sets the following flags:867 // - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )868 // If the flag MCalibrationChargePix::IsHiGainSaturation() is set, sets additionally:869 // - MBadPixelsPix::SetUnsuitable( MBadPixelsPix::kUnreliableRun )870 //871 // Retrieves the results and store them in MCalibrationChargePix872 //873 void MHCalibrationChargeCam::FinalizeLoGainHists(MHCalibrationChargePix &hist,874 MCalibrationChargePix &pix,875 MBadPixelsPix &bad)876 {877 878 if (hist.IsEmpty())879 {880 if (pix.IsHiGainSaturation())881 bad.SetUnsuitable(MBadPixelsPix::kUnsuitableRun);882 return;883 }884 885 if (hist.GetSaturated() > fNumLoGainSaturationLimit*hist.GetHGausHist()->GetEntries())886 {887 *fLog << warn << "Saturated Lo Gain histogram in pixel: " << pix.GetPixId() << endl;888 bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation );889 bad.SetUnsuitable( MBadPixelsPix::kUnsuitableRun );890 hist.CreateFourierSpectrum();891 return;892 }893 894 //895 // 2) Fit the Lo Gain histograms with a Gaussian896 //897 if (!hist.FitGaus())898 //899 // 3) In case of failure set the bit kFitted to false and take histogram means and RMS900 //901 if (!hist.RepeatFit())902 {903 hist.BypassFit();904 bad.SetUncalibrated( MBadPixelsPix::kLoGainNotFitted );905 if (pix.IsHiGainSaturation())906 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);907 }908 909 //910 // 4) Check for pickup911 //912 hist.CountPickup();913 914 //915 // 5) Check for oscillations916 //917 hist.CreateFourierSpectrum();918 919 if (!hist.IsFourierSpectrumOK())920 {921 bad.SetUncalibrated( MBadPixelsPix::kLoGainOscillating );922 if (pix.IsHiGainSaturation())923 bad.SetUnsuitable(MBadPixelsPix::kUnreliableRun);924 }925 //926 // 6) Retrieve the results and store them in this class927 //928 pix.SetLoGainMeanCharge( hist.GetMean() );929 pix.SetLoGainMeanChargeErr( hist.GetMeanErr() );930 pix.SetLoGainSigmaCharge( hist.GetSigma() );931 pix.SetLoGainSigmaChargeErr( hist.GetSigmaErr() );932 pix.SetLoGainChargeProb ( hist.GetProb() );933 934 if (pix.IsHiGainSaturation())935 {936 pix.SetAbsTimeMean ( hist.GetAbsTimeMean());937 pix.SetAbsTimeRms ( hist.GetAbsTimeRms() );938 }939 940 pix.SetLoGainNumPickup ( hist.GetPickup() );941 942 }943 695 944 696 // --------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.