Changeset 4568 for trunk/MagicSoft/Mars/mcalib
- Timestamp:
- 08/10/04 17:53:21 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mcalib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mcalib/MCalibrationTestCalc.cc
r4542 r4568 85 85 // 86 86 MCalibrationTestCalc::MCalibrationTestCalc(const char *name, const char *title) 87 : fBadPixels(NULL), fTestCam(NULL), fGeom(NULL) 87 : fMaxNumBadPixelsCluster(-1), 88 fBadPixels(NULL), fTestCam(NULL), fGeom(NULL) 88 89 { 89 90 … … 169 170 { 170 171 171 if (GetNumExecutions()==0)172 return kFALSE;172 // if (GetNumExecutions()==0) 173 // return kFALSE; 173 174 174 175 // … … 186 187 *fLog << GetDescriptor() << ": Not interpolated pixels statistics:" << endl; 187 188 188 PrintNotInterpolated(); 189 189 FinalizeNotInterpolated(); 190 CalcMaxNumBadPixelsCluster(); 191 192 *fLog << endl; 193 *fLog << " " << setw(7) << fMaxNumBadPixelsCluster 194 << " pixels in biggest not-interpolateable cluster " << endl; 195 *fLog << endl; 196 190 197 SetLogStream(&gLog); 191 198 … … 267 274 } 268 275 269 areavars[aidx] = (areavars[aidx] - areaphotons[aidx]*areaphotons[aidx]/numareavalid[aidx]) / (numareavalid[aidx]-1.); 270 areaphotons[aidx] = areaphotons[aidx] / numareavalid[aidx]; 271 276 if (numareavalid[aidx] == 1) 277 areavars[aidx] = 0.; 278 else if (numareavalid[aidx] == 0) 279 { 280 areaphotons[aidx] = -1.; 281 areavars[aidx] = -1.; 282 } 283 else 284 { 285 areavars[aidx] = (areavars[aidx] - areaphotons[aidx]*areaphotons[aidx]/numareavalid[aidx]) 286 / (numareavalid[aidx]-1.); 287 areaphotons[aidx] = areaphotons[aidx] / numareavalid[aidx]; 288 } 289 272 290 if (areavars[aidx] < 0.) 273 291 { … … 318 336 upplim [aidx] = mean + fPhotErrLimit*sigma; 319 337 320 *fLog << " Fitted number of photons in area index " << aidx 321 << ": " << Form("%6.2f +- %6.2f",fittedmean[aidx],fittedsigma[aidx]) << endl; 338 *fLog << inf << GetDescriptor() 339 << ": Fitted number of calib. equiv. Cher. photons in area index " << aidx 340 << ": " << Form("%7.2f +- %6.2f",fittedmean[aidx],fittedsigma[aidx]) << endl; 322 341 323 342 delete hist; 324 343 } 344 345 *fLog << endl; 325 346 326 347 memset(numareavalid,0,nareas*sizeof(Int_t)); … … 336 357 337 358 MHCalibrationTestPix &pix = (MHCalibrationTestPix&)(*fTestCam)[i]; 338 MBadPixelsPix &bad = (*fBadPixels)[i];339 359 340 360 const Int_t aidx = (*fGeom)[i].GetAidx(); … … 345 365 if ( nphot < lowlim[aidx] || nphot > upplim[aidx] ) 346 366 { 347 *fLog << warn << "Deviating number of calibrated photons: " 348 << Form("%4.2f",nphot) << " out of accepted limits: [" 349 << Form("%4.2f%s%4.2f",lowlim[aidx],",",upplim[aidx]) << "] in pixel " << i << endl; 367 *fLog << warn << GetDescriptor() << ": Number of photons: " 368 << Form("%8.2f out of %3.1f sigma limit: ",nphot,fPhotErrLimit) 369 << Form("[%8.2f,%8.2f] pixel%4i",lowlim[aidx],upplim[aidx],i) << endl; 370 MBadPixelsPix &bad = (*fBadPixels)[i]; 350 371 bad.SetUncalibrated( MBadPixelsPix::kDeviatingNumPhots ); 351 372 bad.SetUnsuitable ( MBadPixelsPix::kUnsuitableRun ); … … 362 383 } 363 384 385 *fLog << endl; 386 364 387 for (UInt_t aidx=0; aidx<nareas; aidx++) 365 388 { 366 389 367 areavars [aidx] -= areaphotons[aidx]*areaphotons[aidx]/numareavalid[aidx]; 368 areaphotons[aidx] /= numareavalid[aidx]; 369 areavars [aidx] /= numareavalid[aidx]-1.; 370 371 if (areavars[aidx] <= 0. || areaphotons[aidx] <= 0.) 372 { 373 *fLog << warn << " Mean number of photons per area in area index " 374 << aidx << " cannot be calculated! Mean: " << areaphotons[aidx] 390 if (numareavalid[aidx] == 1) 391 areavars[aidx] = 0.; 392 else if (numareavalid[aidx] == 0) 393 { 394 areaphotons[aidx] = -1.; 395 areavars[aidx] = -1.; 396 } 397 else 398 { 399 areavars[aidx] = (areavars[aidx] - areaphotons[aidx]*areaphotons[aidx]/numareavalid[aidx]) 400 / (numareavalid[aidx]-1.); 401 areaphotons[aidx] /= numareavalid[aidx]; 402 } 403 404 if (areavars[aidx] < 0. || areaphotons[aidx] <= 0.) 405 { 406 *fLog << warn << GetDescriptor() 407 << ": Mean number of photons per area in area index " 408 << aidx << " could not be calculated! Mean: " << areaphotons[aidx] 375 409 << " Variance: " << areavars[aidx] << endl; 376 410 continue; 377 411 } 378 412 379 *fLog << " Mean number of photons per area in area index " << aidx 380 << ": " << Form("%5.4f +- %5.4f",areaphotons[aidx],TMath::Sqrt(areavars[aidx])) << endl; 381 } 413 *fLog << inf << GetDescriptor() << ": Mean number of equiv. Cher. photons " 414 << "per area in area idx " << aidx << ": " 415 << Form("%5.3f+-%5.4f [ph/mm^2]",areaphotons[aidx],TMath::Sqrt(areavars[aidx])) << endl; 416 } 417 418 *fLog << endl; 382 419 383 420 for (UInt_t sector=0; sector<nsectors; sector++) 384 421 { 385 386 sectorvars [sector] -= sectorphotons[sector]*sectorphotons[sector]/numsectorvalid[sector]; 387 sectorphotons[sector] /= numsectorvalid[sector]; 388 sectorvars [sector] /= numsectorvalid[sector]-1.; 389 390 if (sectorvars[sector] <= 0. || sectorphotons[sector] <= 0.) 391 { 392 *fLog << warn << " Mean number of calibrated photons per area from sector " 393 << sector << " cannot be calculated! " << endl; 394 continue; 395 } 396 397 *fLog << " Mean number of photons per area in sector " << sector 398 << ": " << Form("%5.4f +- %5.4f",sectorphotons[sector],TMath::Sqrt(sectorvars[sector])) << endl; 422 423 if (numsectorvalid[sector] == 1) 424 sectorvars[sector] = 0.; 425 else if (numsectorvalid[sector] == 0) 426 { 427 sectorphotons[sector] = -1.; 428 sectorvars[sector] = -1.; 429 } 430 else 431 { 432 sectorvars[sector] = (sectorvars[sector] 433 - sectorphotons[sector]*sectorphotons[sector]/numsectorvalid[sector] 434 ) 435 / (numsectorvalid[sector]-1.); 436 sectorphotons[sector] /= numsectorvalid[sector]; 437 } 438 439 if (sectorvars[sector] < 0. || sectorphotons[sector] <= 0.) 440 { 441 *fLog << warn << GetDescriptor() 442 << ": Mean number of calibrated photons per area in sector " 443 << sector << " could not be calculated! Mean: " << sectorphotons[sector] 444 << " Variance: " << sectorvars[sector] << endl; 445 continue; 446 } 447 448 449 *fLog << inf << GetDescriptor() << ": Mean number of equiv. Cher. photons " 450 << "per area in sector " << sector << ": " 451 << Form("%5.3f+-%5.4f [ph/mm^2]",sectorphotons[sector],TMath::Sqrt(sectorvars[sector])) << endl; 399 452 } 400 453 … … 407 460 // Print out statistics about not interpolated pixels 408 461 // 409 void MCalibrationTestCalc:: PrintNotInterpolated() const462 void MCalibrationTestCalc::FinalizeNotInterpolated() 410 463 { 411 464 … … 418 471 newarr[aidx] = new TArrayI(0); 419 472 420 TArrayI numtot; 421 numtot.Set(areas); 473 fNumUninterpolateable.Set(areas); 422 474 423 475 for (Int_t i=0; i<arr.GetSize(); i++) … … 428 480 newarr[aidx]->Set(size+1); 429 481 newarr[aidx]->AddAt(id,size); 430 numtot[aidx]++;482 fNumUninterpolateable[aidx]++; 431 483 } 432 484 … … 436 488 { 437 489 *fLog << " " << setw(7) 438 << numtot[aidx] << " not interpolateable pixels in area index " << aidx << endl; 490 << fNumUninterpolateable[aidx] 491 << " not interpolateable pixels in area index " << aidx << endl; 439 492 *fLog << " " << setw(7) 440 493 << "Pixel software idx: "; … … 447 500 } 448 501 449 450 502 *fLog << " " << setw(7) << num << " total not interpolateable pixels " << endl; 451 503 452 504 } 505 506 void MCalibrationTestCalc::CalcMaxNumBadPixelsCluster() 507 { 508 509 const TArrayI &arr = fTestCam->GetNotInterpolateablePixels(); 510 const Int_t size = arr.GetSize(); 511 512 if (size == 0) 513 { 514 fMaxNumBadPixelsCluster = 0; 515 return; 516 } 517 518 if (size == 1) 519 { 520 fMaxNumBadPixelsCluster = 1; 521 return; 522 } 523 524 TArrayI knownpixels(0); 525 Int_t clustersize = 1; 526 Int_t oldclustersize = 0; 527 // 528 // Loop over the not-interpolateable pixels: 529 // 530 for (Int_t i=0; i<size; i++) 531 { 532 533 const Int_t id = arr[i]; 534 const Int_t knownsize = knownpixels.GetSize(); 535 knownpixels.Set(knownsize+1); 536 knownpixels[knownsize] = id; 537 LoopNeighbours(arr, knownpixels, clustersize, id); 538 if (clustersize > oldclustersize) 539 oldclustersize = clustersize; 540 clustersize = 1; 541 } 542 543 fMaxNumBadPixelsCluster = oldclustersize; 544 545 } 546 547 548 void MCalibrationTestCalc::LoopNeighbours( const TArrayI &arr, TArrayI &knownpixels, Int_t &clustersize, const Int_t idx ) 549 { 550 551 const MGeomPix &pix = (*fGeom)[idx]; 552 const Byte_t neighbours = pix.GetNumNeighbors(); 553 554 // 555 // Loop over the next neighbours: 556 // - Check if they are already in the list of known pixels 557 // - If not, call loopneighbours for the rest 558 // - grow clustersize for those 559 // 560 for (Int_t i=0;i<neighbours;i++) 561 { 562 const Int_t newid = pix.GetNeighbor(i); 563 Bool_t known = kFALSE; 564 565 for (Int_t j=knownpixels.GetSize()-1;j>=0;j--) 566 if (newid == knownpixels.At(j)) 567 { 568 known = kTRUE; 569 break; 570 } 571 if (known) 572 continue; 573 574 for (Int_t k=0;k<arr.GetSize();k++) 575 if (newid == arr.At(k)) 576 { 577 // This is an unknown, new pixel in the cluster!! 578 clustersize++; 579 const Int_t knownsize = knownpixels.GetSize(); 580 knownpixels.Set(knownsize+1); 581 knownpixels[knownsize] = newid; 582 LoopNeighbours(arr, knownpixels, clustersize, newid); 583 } 584 } 585 } 586 587 588 589 453 590 454 591 // -------------------------------------------------------------------------- … … 476 613 return Form("%s/%s", (const char*)fOutputPath, (const char*)fOutputFile); 477 614 } 615 616 const Int_t MCalibrationTestCalc::GetNumUninterpolateable(const Int_t aidx) const 617 { 618 if (aidx < 0) 619 return -1; 620 621 return aidx > fNumUninterpolateable.GetSize() ? -1 : fNumUninterpolateable[aidx]; 622 } -
trunk/MagicSoft/Mars/mcalib/MCalibrationTestCalc.h
r4542 r4568 15 15 #endif 16 16 17 #ifndef ROOT_TArrayI 18 #include <TArrayI.h> 19 #endif 20 17 21 class MHCalibrationTestCam; 18 22 class MBadPixelsCam; … … 26 30 // Variables 27 31 Float_t fPhotErrLimit; // Limit acceptance nr. cal. phots w.r.t. area idx mean (in sigmas) 32 Int_t fMaxNumBadPixelsCluster; // Number of not interpolateable pixels in biggest cluster 33 34 TArrayI fNumUninterpolateable; // Number uninterpolated Pixels per area index 28 35 29 36 TString fOutputPath; // Path to the output file … … 38 45 const char* GetOutputFile(); 39 46 40 void PrintNotInterpolated() const;47 void FinalizeNotInterpolated(); 41 48 void FinalizeCalibratedPhotons() const; 42 49 void CalcMaxNumBadPixelsCluster(); 50 void LoopNeighbours( const TArrayI &arr, TArrayI &known, Int_t &clustersize, const Int_t idx ); 51 43 52 Int_t PreProcess (MParList *pList); 44 53 Bool_t ReInit (MParList *pList); … … 50 59 MCalibrationTestCalc(const char *name=NULL, const char *title=NULL); 51 60 61 const Int_t GetMaxNumBadPixelsCluster () const { return fMaxNumBadPixelsCluster; } 62 const Int_t GetNumUninterpolateable ( const Int_t aidx ) const; 63 64 void SetOutputFile ( TString file="TestCalibStat.txt" ); 52 65 void SetOutputPath ( TString path="." ); 53 void SetOutputFile ( TString file="TestCalibStat.txt" ); 54 55 void SetPhotErrLimit ( const Float_t f=fgPhotErrLimit ) { fPhotErrLimit = f; } 66 void SetPhotErrLimit( const Float_t f=fgPhotErrLimit ) { fPhotErrLimit = f; } 56 67 57 68 ClassDef(MCalibrationTestCalc, 1) // Task retrieving the results of MHCalibrationTestCam
Note:
See TracChangeset
for help on using the changeset viewer.