Changeset 7188 for trunk/MagicSoft/Mars/mpedestal
- Timestamp:
- 07/13/05 19:06:26 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mpedestal
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.cc
r7070 r7188 175 175 176 176 const TString MExtractPedestal::fgNamePedestalCam = "MPedestalCam"; 177 const TString MExtractPedestal::fgNameRawEvtData = "MRawEvtData"; 177 178 const UInt_t MExtractPedestal::fgNumDump = 500; 178 179 … … 191 192 MExtractPedestal::MExtractPedestal(const char *name, const char *title) 192 193 : fGeom(NULL), fPedestalsIn(NULL), fPedestalsInter(NULL), fPedestalsOut(NULL), 193 fExtractor(NULL), fExtractWinFirst(0), fExtractWinSize(0) 194 fExtractor(NULL), fExtractWinFirst(0), fExtractWinSize(0), fUseSpecialPixels(kFALSE) 194 195 { 195 196 fName = name ? name : "MExtractPedestal"; … … 207 208 SetNamePedestalCamIn(); 208 209 SetNamePedestalCamOut(); 210 SetNamePedestalCamInter(); 211 SetNameRawEvtData(); 209 212 SetNumDump(); 210 213 … … 311 314 312 315 Clear(); 313 316 317 fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber(fNameRawEvtData)); 318 if (!fRawEvt) 319 if (!fUseSpecialPixels) 320 { 321 *fLog << err << AddSerialNumber(fNameRawEvtData) << " not found... aborting." << endl; 322 return kFALSE; 323 } 324 325 314 326 fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData")); 315 327 if (!fRawEvt) … … 372 384 Int_t MExtractPedestal::Process() 373 385 { 386 // 387 // Necessary check for extraction of special pixels 388 // together with data which does not yet have them 389 // 390 if (fSumx.GetSize()==0) 391 return kTRUE; 392 374 393 if (fExtractor) 375 394 fExtractor->SetNoiseCalculation(fRandomCalculation); … … 405 424 Bool_t MExtractPedestal::ReInit(MParList *pList) 406 425 { 407 // If the size is not yet set, set the size 408 if (fSumx.GetSize()==0) 409 { 410 const Int_t npixels = fPedestalsOut->GetSize(); 411 const Int_t areas = fPedestalsOut->GetNumAverageArea(); 412 const Int_t sectors = fPedestalsOut->GetNumAverageSector(); 413 414 fSumx. Set(npixels); 415 fSumx2. Set(npixels); 416 fSumAB0.Set(npixels); 417 fSumAB1.Set(npixels); 418 419 fAreaSumx. Set(areas); 420 fAreaSumx2. Set(areas); 421 fAreaSumAB0.Set(areas); 422 fAreaSumAB1.Set(areas); 423 fAreaFilled.Set(areas); 424 fAreaValid .Set(areas); 425 426 fSectorSumx. Set(sectors); 427 fSectorSumx2. Set(sectors); 428 fSectorSumAB0.Set(sectors); 429 fSectorSumAB1.Set(sectors); 430 fSectorFilled.Set(sectors); 431 fSectorValid .Set(sectors); 432 433 for (Int_t i=0; i<npixels; i++) 434 { 435 const UInt_t aidx = (*fGeom)[i].GetAidx(); 436 const UInt_t sector = (*fGeom)[i].GetSector(); 437 438 fAreaValid [aidx] ++; 439 fSectorValid[sector]++; 440 } 441 } 442 443 if (fExtractor) 444 { 445 if (!((MTask*)fExtractor)->ReInit(pList)) 446 return kFALSE; 447 448 SetExtractWindow(fExtractor->GetHiGainFirst(), (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples())); 449 } 450 451 return kTRUE; 426 // Necessary check for special pixels which might not yet have existed 427 if (!fRawEvt) 428 { 429 if (fRunHeader->GetFormatVersion() > 3) 430 return kTRUE; 431 432 *fLog << err << "ERROR - " << fNameRawEvtData << " [MRawEvtData] has not "; 433 *fLog << "been found and format version > 3... abort." << endl; 434 return kFALSE; 435 } 436 437 // If the size is not yet set, set the size 438 if (fSumx.GetSize()==0) 439 { 440 // Initialize the normal pixels (size of MPedestalCam already set by MGeomApply) 441 const Int_t npixels = fPedestalsOut->GetSize(); 442 443 fSumx. Set(npixels); 444 fSumx2. Set(npixels); 445 fSumAB0.Set(npixels); 446 fSumAB1.Set(npixels); 447 448 if (fUseSpecialPixels) 449 { 450 // Initialize size of MPedestalCam in case of special pixels (not done by MGeomApply) 451 const UShort_t nspecial = fRunHeader->GetNumSpecialPixels(); 452 if (nspecial == 0) 453 { 454 *fLog << warn << "WARNING - Number of special pixels is 0." << endl; 455 return kTRUE; 456 } 457 458 fPedestalsOut->InitSize((UInt_t)nspecial); 459 } 460 else 461 { 462 // Initialize the averaged areas and sectors (do not exist for special pixels) 463 const Int_t areas = fPedestalsOut->GetNumAverageArea(); 464 const Int_t sectors = fPedestalsOut->GetNumAverageSector(); 465 466 fAreaSumx. Set(areas); 467 fAreaSumx2. Set(areas); 468 fAreaSumAB0.Set(areas); 469 fAreaSumAB1.Set(areas); 470 fAreaFilled.Set(areas); 471 fAreaValid .Set(areas); 472 473 fSectorSumx. Set(sectors); 474 fSectorSumx2. Set(sectors); 475 fSectorSumAB0.Set(sectors); 476 fSectorSumAB1.Set(sectors); 477 fSectorFilled.Set(sectors); 478 fSectorValid .Set(sectors); 479 480 for (Int_t i=0; i<npixels; i++) 481 { 482 const UInt_t aidx = (*fGeom)[i].GetAidx(); 483 const UInt_t sector = (*fGeom)[i].GetSector(); 484 485 fAreaValid [aidx] ++; 486 fSectorValid[sector]++; 487 } 488 } 489 } 490 491 if (fExtractor) 492 { 493 if (!((MTask*)fExtractor)->ReInit(pList)) 494 return kFALSE; 495 496 SetExtractWindow(fExtractor->GetHiGainFirst(), (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples())); 497 } 498 499 return kTRUE; 452 500 } 453 501 454 502 Int_t MExtractPedestal::PostProcess() 455 503 { 456 fPedestalsIn = NULL;457 return fExtractor ? fExtractor->CallPostProcess() : kTRUE;504 fPedestalsIn = NULL; 505 return fExtractor ? fExtractor->CallPostProcess() : kTRUE; 458 506 } 459 507 … … 486 534 } 487 535 536 // find resource for fUseSpecialPixels 537 if (IsEnvDefined(env, prefix, "UseSpecialPixels", print)) 538 { 539 SetUseSpecialPixels(GetEnvValue(env, prefix, "UseSpecialPixels", fUseSpecialPixels)); 540 rc = kTRUE; 541 } 542 488 543 // find resource for numeventsdump 489 544 if (IsEnvDefined(env, prefix, "NumEventsDump", print)) … … 577 632 void MExtractPedestal::CalcPixResults(const UInt_t nevts, const UInt_t pixid) 578 633 { 579 const Float_t sum = fSumx[pixid];580 const Float_t sum2 = fSumx2[pixid];634 const Double_t sum = fSumx[pixid]; 635 const Double_t sum2 = fSumx2[pixid]; 581 636 582 637 // 1. Calculate the mean of the sums: 583 Float_t ped= sum/nevts;638 Double_t ped = sum/nevts; 584 639 585 640 // 2. Calculate the Variance of the sums: 586 Float_t var = (sum2-sum*sum/nevts)/(nevts-1.);641 Double_t var = (sum2-sum*sum/nevts)/(nevts-1.); 587 642 588 643 // 3. Calculate the amplitude of the 150MHz "AB" noise 589 Float_t abOffs = (fSumAB0[pixid] - fSumAB1[pixid]) / nevts;644 Double_t abOffs = (fSumAB0[pixid] - fSumAB1[pixid]) / nevts; 590 645 591 646 // 4. Scale the mean, variance and AB-noise to the number of slices: … … 595 650 596 651 // 5. Calculate the RMS from the Variance: 597 const Float_t rms = var<0 ? 0 : TMath::Sqrt(var);652 const Double_t rms = var<0 ? 0 : TMath::Sqrt(var); 598 653 599 654 (*fPedestalsOut)[pixid].Set(ped, rms, abOffs, nevts); … … 612 667 void MExtractPedestal::CalcAreaResults(const UInt_t nevts, const UInt_t napix, const UInt_t aidx) 613 668 { 614 const Float_t sum = fAreaSumx[aidx];615 const Float_t sum2 = fAreaSumx2[aidx];669 const Double_t sum = fAreaSumx[aidx]; 670 const Double_t sum2 = fAreaSumx2[aidx]; 616 671 617 672 // 1. Calculate the mean of the sums: 618 Float_t ped= sum/nevts;673 Double_t ped = sum/nevts; 619 674 620 675 // 2. Calculate the Variance of the sums: 621 Float_t var = (sum2-sum*sum/nevts)/(nevts-1.);676 Double_t var = (sum2/napix-sum*sum/nevts)/(nevts-1.); 622 677 623 678 // 3. Calculate the amplitude of the 150MHz "AB" noise 624 Float_t abOffs = (fAreaSumAB0[aidx] - fAreaSumAB1[aidx]) / nevts;679 Double_t abOffs = (fAreaSumAB0[aidx] - fAreaSumAB1[aidx]) / nevts; 625 680 626 681 // 4. Scale the mean, variance and AB-noise to the number of slices: … … 635 690 636 691 // 6. Calculate the RMS from the Variance: 637 const Float_t rms = var<0 ? 0 : TMath::Sqrt(var);692 const Double_t rms = var<0 ? 0 : TMath::Sqrt(var); 638 693 639 694 fPedestalsOut->GetAverageArea(aidx).Set(ped, rms, abOffs, nevts); … … 652 707 void MExtractPedestal::CalcSectorResults(const UInt_t nevts, const UInt_t nspix, const UInt_t sector) 653 708 { 654 const Float_t sum = fSectorSumx[sector];655 const Float_t sum2 = fSectorSumx2[sector];709 const Double_t sum = fSectorSumx[sector]; 710 const Double_t sum2 = fSectorSumx2[sector]; 656 711 657 712 // 1. Calculate the mean of the sums: 658 Float_t ped = sum/nevts;713 Double_t ped = sum/nevts; 659 714 660 715 // 2. Calculate the Variance of the sums: 661 Float_t var = (sum2-sum*sum/nevts)/(nevts-1.);716 Double_t var = (sum2/nspix-sum*sum/nevts)/(nevts-1.); 662 717 663 718 // 3. Calculate the amplitude of the 150MHz "AB" noise 664 Float_t abOffs = (fSectorSumAB0[sector] - fSectorSumAB1[sector]) / nevts;719 Double_t abOffs = (fSectorSumAB0[sector] - fSectorSumAB1[sector]) / nevts; 665 720 666 721 // 4. Scale the mean, variance and AB-noise to the number of slices: … … 675 730 676 731 // 6. Calculate the RMS from the Variance: 677 const Float_t rms = var<0 ? 0 : TMath::Sqrt(var);732 const Double_t rms = var<0 ? 0 : TMath::Sqrt(var); 678 733 679 734 fPedestalsOut->GetAverageSector(sector).Set(ped, rms, abOffs, nevts); … … 688 743 *fLog << "Intermediate Storage is " << (fIntermediateStorage?"on":"off") << endl; 689 744 *fLog << "Pedestal Update is " << (fPedestalUpdate?"on":"off") << endl; 745 *fLog << "Special pixel mode " << (fUseSpecialPixels?"on":"off") << endl; 690 746 if (fPedestalUpdate) 691 747 { -
trunk/MagicSoft/Mars/mpedestal/MExtractPedestal.h
r6913 r7188 25 25 private: 26 26 static const TString fgNamePedestalCam; //! "MPedestalCam" 27 static const TString fgNameRawEvtData; //! "MRawEvtData" 27 28 static const UInt_t fgNumDump; //! 28 29 29 30 TString fNamePedestalCamIn; // Name of the incoming 'MPedestalCam' container 30 31 TString fNamePedestalCamOut; // Name of the outgoing 'MPedestalCam' container 31 TString fNamePedestalCamInter; // Name of the intermediate 'MPedestalCam' container 32 TString fNamePedestalCamInter; // Name of the intermediate 'MPedestalCam' container 33 TString fNameRawEvtData; // Name of MRawEvtData 32 34 33 35 Bool_t fRandomCalculation; // Is pedestalextraction by extractor random? … … 55 57 56 58 Bool_t fPedestalUpdate; // Flag if the pedestal shall be updated after every fNumEventsDump 59 Bool_t fUseSpecialPixels; // Flag if the special pixels shall be treated 57 60 58 61 MArrayD fSumx; // sum of values … … 103 106 104 107 // names 105 void SetNamePedestalCamIn (const char *name=fgNamePedestalCam.Data()) { fNamePedestalCamIn = name; } 106 void SetNamePedestalCamInter(const char *name=fgNamePedestalCam.Data()) { fNamePedestalCamInter = name; } 107 void SetNamePedestalCamOut (const char *name=fgNamePedestalCam.Data()) { fNamePedestalCamOut = name; } 108 void SetNamePedestalCamIn (const char *name=fgNamePedestalCam) { fNamePedestalCamIn = name; } 109 void SetNamePedestalCamInter(const char *name=fgNamePedestalCam) { fNamePedestalCamInter = name; } 110 void SetNamePedestalCamOut (const char *name=fgNamePedestalCam) { fNamePedestalCamOut = name; } 111 void SetNameRawEvtData (const char *name=fgNameRawEvtData) { fNameRawEvtData = name; } 108 112 109 113 // pointers … … 115 119 // flags 116 120 void SetIntermediateStorage (Bool_t b=kTRUE) { fIntermediateStorage = b; } 121 void SetUseSpecialPixels (Bool_t b=kTRUE) { fUseSpecialPixels = b; } 117 122 void SetPedestalUpdate (Bool_t b=kTRUE) { fPedestalUpdate = b; } 118 123 void SetRandomCalculation (Bool_t b=kTRUE) { fRandomCalculation = b; } -
trunk/MagicSoft/Mars/mpedestal/MMcPedestalCopy.cc
r3803 r7188 79 79 Bool_t MMcPedestalCopy::CheckRunType(MParList *pList) const 80 80 { 81 const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject( "MRawRunHeader");81 const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader")); 82 82 if (!run) 83 83 { 84 *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl; 84 *fLog << warn << dbginf << "Warning - cannot check file type, " 85 << AddSerialNumber("MRawRunHeader") << " not found." << endl; 85 86 return kTRUE; 86 87 } … … 138 139 } 139 140 140 MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject( "MMcRunHeader");141 MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject(AddSerialNumber("MMcRunHeader")); 141 142 if (!mcrun) 142 *fLog << warn << dbginf << "MMcRunHeader not found... assuming camera<0.7" << endl; 143 *fLog << warn << dbginf << AddSerialNumber("MMcRunHeader") 144 << " not found... assuming camera<0.7" << endl; 143 145 144 146 const int num = pedcam->GetSize(); -
trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc
r7130 r7188 276 276 277 277 // 278 // In the other case, produce the MPedestalCam to be use the subsequent (non-pedestal) events 278 // In the other case, produce the MPedestalCam to be use the subsequent 279 // (non-pedestal) events 279 280 // 280 281 *fLog << inf << "Finalizing pedestal calculations..." << flush; … … 299 300 Int_t MPedCalcPedRun::Calc() 300 301 { 301 302 302 if (fIsNotPedRun && !IsPedBitSet()) 303 303 return kTRUE; … … 317 317 while (pixel.Next()) 318 318 { 319 const UInt_t idx = pixel.GetPixelId(); 320 const UInt_t aidx = (*fGeom)[idx].GetAidx(); 321 const UInt_t sector = (*fGeom)[idx].GetSector(); 319 const UInt_t idx = pixel.GetPixelId(); 322 320 323 321 Float_t sum = 0.; … … 330 328 CalcSums(pixel, sum, ab0, ab1); 331 329 332 fSumx[idx] += sum; 330 fSumx[idx] += sum; 331 332 if (fIntermediateStorage) 333 (*fPedestalsInter)[idx].Set(sum,0.,0.,fUsedEvents); 334 335 const Float_t sqrsum = sum*sum; 336 337 fSumx2[idx] += sqrsum; 338 fSumAB0[idx] += ab0; 339 fSumAB1[idx] += ab1; 340 341 if (fUseSpecialPixels) 342 continue; 343 344 const UInt_t aidx = (*fGeom)[idx].GetAidx(); 345 const UInt_t sector = (*fGeom)[idx].GetSector(); 346 333 347 fAreaSumx[aidx] += sum; 334 348 fSectorSumx[sector] += sum; 335 349 336 if (fIntermediateStorage) 337 (*fPedestalsInter)[idx].Set(sum,0.,0.,fUsedEvents); 338 339 const Float_t sqrsum = sum*sum; 340 fSumx2[idx] += sqrsum; 341 fAreaSumx2[aidx] += sqrsum; 342 fSectorSumx2[sector] += sqrsum; 343 344 fSumAB0[idx] += ab0; 345 fSumAB1[idx] += ab1; 350 fAreaSumx2[aidx] += sqrsum; 351 fSectorSumx2[sector] += sqrsum; 346 352 347 353 fAreaSumAB0[aidx] += ab0; … … 422 428 } 423 429 424 425 430 // -------------------------------------------------------------------------- 426 431 // … … 429 434 Int_t MPedCalcPedRun::Finalize() 430 435 { 431 432 if (fUsedEvents == 0) 436 if (fUsedEvents == 0) 437 return kTRUE; 438 439 // 440 // Necessary check for extraction of special pixels 441 // together with data which does not yet have them 442 // 443 if (fSumx.GetSize()==0) 444 return kTRUE; 445 446 MRawEvtPixelIter pixel(fRawEvt); 447 while (pixel.Next()) 448 CalcPixResults(fUsedEvents, pixel.GetPixelId()); 449 450 if (!fUseSpecialPixels) 451 { 452 453 // 454 // Loop over the (two) area indices to get the averaged pedestal per aidx 455 // 456 for (UInt_t aidx=0; aidx<fAreaValid.GetSize(); aidx++) 457 if (fAreaValid[aidx]>0) 458 CalcAreaResults(fUsedEvents, fAreaValid[aidx], aidx); 459 460 // 461 // Loop over the (six) sector indices to get the averaged pedestal per sector 462 // 463 for (UInt_t sector=0; sector<fSectorValid.GetSize(); sector++) 464 if (fSectorValid[sector]>0) 465 CalcSectorResults(fUsedEvents, fSectorValid[sector], sector); 466 } 467 468 fPedestalsOut->SetTotalEntries(fUsedEvents*fExtractWinSize); 469 fPedestalsOut->SetReadyToSave(); 470 433 471 return kTRUE; 434 435 MRawEvtPixelIter pixel(fRawEvt);436 while (pixel.Next())437 CalcPixResults(fUsedEvents, pixel.GetPixelId());438 439 //440 // Loop over the (two) area indices to get the averaged pedestal per aidx441 //442 for (UInt_t aidx=0; aidx<fAreaValid.GetSize(); aidx++)443 if (fAreaValid[aidx]>0)444 CalcAreaResults(fUsedEvents, fAreaValid[aidx], aidx);445 446 //447 // Loop over the (six) sector indices to get the averaged pedestal per sector448 //449 for (UInt_t sector=0; sector<fSectorValid.GetSize(); sector++)450 if (fSectorValid[sector]>0)451 CalcSectorResults(fUsedEvents, fSectorValid[sector], sector);452 453 fPedestalsOut->SetTotalEntries(fUsedEvents*fExtractWinSize);454 fPedestalsOut->SetReadyToSave();455 456 return kTRUE;457 472 } 458 473 459 474 Int_t MPedCalcPedRun::PostProcess() 460 475 { 461 if (!Finalize()) 462 return kFALSE; 463 464 return MExtractPedestal::PostProcess(); 476 if (!fRawEvt) 477 return kTRUE; 478 479 if (!Finalize()) 480 return kFALSE; 481 482 return MExtractPedestal::PostProcess(); 465 483 } 466 484 … … 485 503 void MPedCalcPedRun::Print(Option_t *o) const 486 504 { 487 488 505 MExtractPedestal::Print(o); 489 506 -
trunk/MagicSoft/Mars/mpedestal/MPedestalCam.cc
r5558 r7188 276 276 } 277 277 278 void MPedestalCam::PrintArr(const TCollection &list) const 279 { 280 Int_t id = 0; 281 282 TIter Next(&list); 283 MPedestalPix *pix = 0; 284 285 while ((pix=(MPedestalPix*)Next())) 286 *fLog << Form("Nr.: %4i Pedestal: %5.2f RMS: %5.2f ABOffset: %5.2f ", 287 id++, pix->GetPedestal(), pix->GetPedestalRms(), pix->GetPedestalABoffset()) << endl; 288 } 289 278 290 void MPedestalCam::Print(Option_t *o) const 279 291 { 280 292 *fLog << all << GetDescriptor() << ":" << endl; 281 int id = 0; 282 283 TIter Next(fArray); 284 MPedestalPix *pix; 285 while ((pix=(MPedestalPix*)Next())) 286 { 287 id++; 288 289 if (!pix->IsValid()) 290 continue; 291 292 *fLog << id-1 << ": "; 293 *fLog << pix->GetPedestal() << " " << pix->GetPedestalRms() << endl; 294 } 293 *fLog << "Pixels:" << endl; 294 *fLog << endl; 295 296 PrintArr(*fArray); 297 298 *fLog << endl; 299 *fLog << "Event-by-event averaged areas:" << endl; 300 *fLog << endl; 301 302 PrintArr(*fAverageAreas); 303 304 *fLog << endl; 305 *fLog << "Event-by-event averaged sectors:" << endl; 306 *fLog << endl; 307 308 PrintArr(*fAverageSectors); 295 309 } 296 310 -
trunk/MagicSoft/Mars/mpedestal/MPedestalCam.h
r5558 r7188 24 24 25 25 UInt_t fTotalEntries; // Total number of times, the Process was executed (to estimate the error of pedestal) 26 27 void PrintArr(const TCollection &list) const; 26 28 27 29 public:
Note:
See TracChangeset
for help on using the changeset viewer.