Changeset 4584 for trunk/MagicSoft/Mars/manalysis
- Timestamp:
- 08/12/04 06:58:34 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/manalysis
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/MPad.cc
r2798 r4584 64 64 #include <TCanvas.h> 65 65 #include <TFile.h> 66 #include <TVirtualPad.h> 66 67 67 68 #include "MBinning.h" 68 69 #include "MSigmabar.h" 69 #include "M McEvt.hxx"70 #include "MPointingPos.h" 70 71 #include "MLog.h" 71 72 #include "MLogManip.h" … … 75 76 #include "MCerPhotPix.h" 76 77 #include "MCerPhotEvt.h" 78 79 #include "MH.h" 77 80 78 81 #include "MPedPhotCam.h" … … 190 193 // from sigma_k to sigma_j 191 194 195 //*fLog << all << "MPad::Merge2Distributions(); Entry" << endl; 196 192 197 Double_t eps = 1.e-10; 193 198 … … 205 210 Double_t v, s, w, t, x, u, a, b, arg; 206 211 212 //*fLog << "Content of histcp : " << endl; 213 207 214 for (Int_t j=nbinssig; j >= 1; j--) 208 215 { 216 //*fLog << "j, hista, histb , histap : " << j << ", " 217 // << hista->GetBinContent(j) << ", " 218 // << histb->GetBinContent(j) << ", " 219 // << histap->GetBinContent(j) << endl; 220 209 221 v = histcp->GetBinContent(j); 222 //*fLog << "cp : j, v = " << j << ", " << v << endl; 223 210 224 if ( fabs(v) < eps ) continue; 211 225 if (v >= 0.0) … … 255 269 } 256 270 257 *fLog << all << "k, j, arg = " << k << ", " << j258 << ", " << arg << endl;271 //*fLog << all << "k, j, arg = " << k << ", " << j 272 // << ", " << arg << endl; 259 273 260 274 //...................................... … … 302 316 303 317 // check results 318 319 //*fLog << "Content of histap, histbp, histcp : " << endl; 320 304 321 for (Int_t j=1; j<=nbinssig; j++) 305 322 { … … 308 325 Double_t c = histcp->GetBinContent(j); 309 326 327 //*fLog << "j, a, b, c = " << j << ": " << a << ", " << b << ", " 328 // << c << endl; 329 310 330 if( fabs(a-b)>3.0*eps || fabs(c)>3.0*eps ) 311 331 *fLog << err << "MPad::Merge2Distributions(); inconsistency in results; j, a, b, c = " … … 314 334 315 335 //--------------------------------------------------------------- 316 TCanvas &c = *(MH::MakeDefCanvas("Merging", "", 600, 600)); 317 c.Divide(2, 2); 336 TCanvas *pad = MH::MakeDefCanvas("Merging", "", 600, 600); 318 337 gROOT->SetSelectedPad(NULL); 319 338 320 c.cd(1); 339 pad->Divide(2, 2); 340 341 pad->cd(1); 342 gPad->SetBorderMode(0); 321 343 hista->SetDirectory(NULL); 322 hista->Draw Copy();344 hista->Draw(); 323 345 hista->SetBit(kCanDelete); 324 346 325 c.cd(2); 347 pad->cd(2); 348 gPad->SetBorderMode(0); 326 349 histb->SetDirectory(NULL); 327 histb->Draw Copy();350 histb->Draw(); 328 351 histb->SetBit(kCanDelete); 329 352 330 c.cd(3); 353 pad->cd(3); 354 gPad->SetBorderMode(0); 331 355 histap->SetDirectory(NULL); 332 histap->Draw Copy();356 histap->Draw(); 333 357 histap->SetBit(kCanDelete); 358 359 pad->DrawClone(); 334 360 335 361 //-------------------------------------------------------------------- … … 339 365 delete histcp; 340 366 367 //*fLog << all << "MPad::Merge2Distributions(); Exit" << endl; 368 341 369 return kTRUE; 342 370 } … … 357 385 358 386 Bool_t MPad::MergeONOFFMC( 359 TH2D *sigthmc, TH3D *diffpixthmc, TH3D *sigmapixthmc,360 TH2D *blindidthmc, TH2D *blindnthmc,361 TH2D *sigthon, TH3D *diffpixthon, TH3D *sigmapixthon,362 TH2D *blindidthon, TH2D *blindnthon,363 TH2D *sigthoff, TH3D *diffpixthoff, TH3D *sigmapixthoff,364 TH2D *blindidthoff, TH2D *blindnthoff)387 TH2D& sigthmc, TH3D& diffpixthmc, TH3D& sigmapixthmc, 388 TH2D& blindidthmc, TH2D& blindnthmc, 389 TH2D& sigthon, TH3D& diffpixthon, TH3D& sigmapixthon, 390 TH2D& blindidthon, TH2D& blindnthon, 391 TH2D& sigthoff, TH3D& diffpixthoff, TH3D& sigmapixthoff, 392 TH2D& blindidthoff, TH2D& blindnthoff) 365 393 { 394 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 395 // for testing 396 /* 397 TAxis *xa = sigthon.GetXaxis(); 398 Int_t nbitheta = xa->GetNbins(); 399 400 TAxis *ya = sigthon.GetYaxis(); 401 Int_t nbisig = ya->GetNbins(); 402 for (Int_t i=1; i<=nbitheta; i++) 403 { 404 for (Int_t j=1; j<=nbisig; j++) 405 { 406 if (i>0) 407 { 408 sigthmc.SetBinContent( i, j, (Float_t) (625000.0+(nbisig*nbisig*nbisig-j*j*j)) ); 409 sigthon.SetBinContent( i, j, (Float_t)(1.0) ); 410 sigthoff.SetBinContent( i, j, (Float_t)( (0.5*nbisig-j)*(0.5*nbisig-j) ) ); 411 } 412 else 413 { 414 sigthmc.SetBinContent( i, j, 0.0); 415 sigthon.SetBinContent( i, j, 0.0); 416 sigthoff.SetBinContent(i, j, 0.0); 417 } 418 } 419 } 420 */ 421 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 422 366 423 *fLog << all << "----------------------------------------------------------------------------------" << endl; 367 424 *fLog << all << "MPad::MergeONOFFMC(); Merge the ON, OFF and MC histograms to obtain the target distributions for the padding" 368 425 << endl; 369 426 370 fHSigmaTheta = new TH2D( ( TH2D&)*sigthon );427 fHSigmaTheta = new TH2D( (const TH2D&) sigthon ); 371 428 fHSigmaTheta->SetNameTitle("2D-ThetaSigmabar", "2D-ThetaSigmabar (target)"); 372 429 373 fHDiffPixTheta = new TH3D( (TH3D&)*diffpixthon ); 430 *fLog << "after booking fHSigmaTheta" << endl; 431 432 fHDiffPixTheta = new TH3D( (const TH3D&) diffpixthon ); 374 433 fHDiffPixTheta->SetNameTitle("3D-ThetaPixDiff", "3D-ThetaPixDiff (target)"); 375 434 376 fHSigmaPixTheta = new TH3D( (TH3D&)*sigmapixthon ); 435 *fLog << "after booking fHDiffPixTheta" << endl; 436 437 fHSigmaPixTheta = new TH3D( (const TH3D&) sigmapixthon ); 377 438 fHSigmaPixTheta->SetNameTitle("3D-ThetaPixSigma", "3D-ThetaPixSigma (target)"); 378 379 fHBlindPixNTheta = new TH2D( (TH2D&)*blindnthon ); 439 *fLog << "after booking fHSigmaPixTheta" << endl; 440 441 fHBlindPixNTheta = new TH2D( (const TH2D&) blindnthon ); 380 442 fHBlindPixNTheta->SetNameTitle("2D-ThetaBlindN", "2D-ThetaBlindN (target)"); 381 443 382 fHBlindPixIdTheta = new TH2D( (TH2D&)*blindidthon ); 444 *fLog << "after booking fHBlindPixNTheta" << endl; 445 446 fHBlindPixIdTheta = new TH2D( (const TH2D&) blindidthon ); 383 447 fHBlindPixIdTheta->SetNameTitle("2D-ThetaBlindId", "2D-ThetaBlindId (target)"); 384 448 449 *fLog << "after booking fHBlindPixIdTheta" << endl; 450 *fLog << all << "Histograms for the merged padding plots were booked" 451 << endl; 452 385 453 //-------------------------- 386 fHSigmaThetaMC = sigthmc;454 fHSigmaThetaMC = &sigthmc; 387 455 fHSigmaThetaMC->SetNameTitle("2D-ThetaSigmabarMC", "2D-ThetaSigmabarMC (orig.)"); 388 fHSigmaThetaON = sigthon;456 fHSigmaThetaON = &sigthon; 389 457 fHSigmaThetaON->SetNameTitle("2D-ThetaSigmabarON", "2D-ThetaSigmabarON (orig.)"); 390 fHSigmaThetaOFF = sigthoff;458 fHSigmaThetaOFF = &sigthoff; 391 459 fHSigmaThetaOFF->SetNameTitle("2D-ThetaSigmabarOFF", "2D-ThetaSigmabarOFF (orig.)"); 392 460 461 //*fLog << all << "addresses of SigmaTheta padding plots were copied" 462 // << endl; 463 393 464 //-------------------------- 394 fHBlindPixNThetaMC = blindnthmc;465 fHBlindPixNThetaMC = &blindnthmc; 395 466 fHBlindPixNThetaMC->SetNameTitle("2D-ThetaBlindNMC", "2D-ThetaBlindNMC (orig.)"); 396 fHBlindPixNThetaON = blindnthon;467 fHBlindPixNThetaON = &blindnthon; 397 468 fHBlindPixNThetaON->SetNameTitle("2D-ThetaBlindNON", "2D-ThetaBlindNON (orig.)"); 398 fHBlindPixNThetaOFF = blindnthoff;469 fHBlindPixNThetaOFF = &blindnthoff; 399 470 fHBlindPixNThetaOFF->SetNameTitle("2D-ThetaBlindNOFF", "2D-ThetaBlindNOFF (orig.)"); 400 471 472 //*fLog << all << "addresses of BlindPixTheta padding plots were copied" 473 // << endl; 474 401 475 //-------------------------- 402 fHBlindPixIdThetaMC = blindidthmc;476 fHBlindPixIdThetaMC = &blindidthmc; 403 477 fHBlindPixIdThetaMC->SetNameTitle("2D-ThetaBlindIdMC", "2D-ThetaBlindIdMC (orig.)"); 404 fHBlindPixIdThetaON = blindidthon;478 fHBlindPixIdThetaON = &blindidthon; 405 479 fHBlindPixIdThetaON->SetNameTitle("2D-ThetaBlindIdON", "2D-ThetaBlindIdON (orig.)"); 406 fHBlindPixIdThetaOFF = blindidthoff;480 fHBlindPixIdThetaOFF = &blindidthoff; 407 481 fHBlindPixIdThetaOFF->SetNameTitle("2D-ThetaBlindIdOFF", "2D-ThetaBlindIdOFF (orig.)"); 408 482 483 //*fLog << all << "addresses of BlindPixIdTheta padding plots were copied" 484 // << endl; 485 409 486 //-------------------------- 410 fHDiffPixThetaMC = diffpixthmc;487 fHDiffPixThetaMC = &diffpixthmc; 411 488 fHDiffPixThetaMC->SetNameTitle("3D-ThetaPixDiffMC", "3D-ThetaPixDiffMC (orig.)"); 412 fHDiffPixThetaON = diffpixthon;489 fHDiffPixThetaON = &diffpixthon; 413 490 fHDiffPixThetaON->SetNameTitle("3D-ThetaPixDiffON", "3D-ThetaPixDiffON (orig.)"); 414 fHDiffPixThetaOFF = diffpixthoff;491 fHDiffPixThetaOFF = &diffpixthoff; 415 492 fHDiffPixThetaOFF->SetNameTitle("3D-ThetaPixDiffOFF", "3D-ThetaPixDiffOFF (orig.)"); 416 493 494 //*fLog << all << "addresses of DiffPixTheta padding plots were copied" 495 // << endl; 496 417 497 //-------------------------- 418 fHSigmaPixThetaMC = sigmapixthmc;498 fHSigmaPixThetaMC = &sigmapixthmc; 419 499 fHSigmaPixThetaMC->SetNameTitle("3D-ThetaPixSigmaMC", "3D-ThetaPixSigmaMC (orig.)"); 420 fHSigmaPixThetaON = sigmapixthon;500 fHSigmaPixThetaON = &sigmapixthon; 421 501 fHSigmaPixThetaON->SetNameTitle("3D-ThetaPixSigmaON", "3D-ThetaPixSigmaON (orig.)"); 422 fHSigmaPixThetaOFF = sigmapixthoff;502 fHSigmaPixThetaOFF = &sigmapixthoff; 423 503 fHSigmaPixThetaOFF->SetNameTitle("3D-ThetaPixSigmaOFF", "3D-ThetaPixSigmaOFF (orig.)"); 504 505 //*fLog << all << "addresses of SigmaPixTheta padding plots were copied" 506 // << endl; 507 424 508 //-------------------------- 425 509 … … 427 511 // get binning for fHgON, fHgOFF and fHgMC from sigthon 428 512 // binning in Theta 429 TAxis *ax = sigthon->GetXaxis(); 513 TAxis *ax = sigthon.GetXaxis(); 514 Int_t nbinstheta = ax->GetNbins(); 515 TArrayD edgesx; 516 edgesx.Set(nbinstheta+1); 517 for (Int_t i=0; i<=nbinstheta; i++) 518 { 519 edgesx[i] = ax->GetBinLowEdge(i+1); 520 //*fLog << all << "i, theta low edge = " << i << ", " << edgesx[i] 521 // << endl; 522 } 523 MBinning binth; 524 binth.SetEdges(edgesx); 525 526 // binning in sigmabar 527 TAxis *ay = sigthon.GetYaxis(); 528 Int_t nbinssig = ay->GetNbins(); 529 TArrayD edgesy; 530 edgesy.Set(nbinssig+1); 531 for (Int_t i=0; i<=nbinssig; i++) 532 { 533 edgesy[i] = ay->GetBinLowEdge(i+1); 534 //*fLog << all << "i, sigmabar low edge = " << i << ", " << edgesy[i] 535 // << endl; 536 } 537 MBinning binsg; 538 binsg.SetEdges(edgesy); 539 540 541 fHgMC = new TH3D; 542 MH::SetBinning(fHgMC, &binth, &binsg, &binsg); 543 fHgMC->SetNameTitle("3D-PaddingMatrixMC", "3D-PadMatrixThetaMC"); 544 545 fHgON = new TH3D; 546 MH::SetBinning(fHgON, &binth, &binsg, &binsg); 547 fHgON->SetNameTitle("3D-PaddingMatrixON", "3D-PadMatrixThetaON"); 548 549 fHgOFF = new TH3D; 550 MH::SetBinning(fHgOFF, &binth, &binsg, &binsg); 551 fHgOFF->SetNameTitle("3D-PaddingMatrixOFF", "3D-PadMatrixThetaOFF"); 552 553 //*fLog << all << "fHg histograms were booked" << endl; 554 555 //............ loop over Theta bins ........................... 556 557 558 559 //*fLog << all << "MPad::MergeONOFFMC(); bins of Theta, Sigmabarold, Sigmabarnew, fraction of events to be padded" << endl; 560 for (Int_t l=1; l<=nbinstheta; l++) 561 { 562 //------------------------------------------- 563 // merge ON and OFF distributions 564 // input : hista is the normalized 1D distr. of sigmabar for ON data 565 // histb is the normalized 1D distr. of sigmabar for OFF data 566 // output : histap will be the merged distribution (ON-OFF) 567 // fHga(k,j) will tell which fraction of ON events should be 568 // padded from bin k to bin j 569 // fHgb(k,j) will tell which fraction of OFF events should be 570 // padded from bin k to bin j 571 572 TH2D * fHga = new TH2D; 573 MH::SetBinning(fHga, &binsg, &binsg); 574 TH2D * fHgb = new TH2D; 575 MH::SetBinning(fHgb, &binsg, &binsg); 576 577 TH1D *hista = sigthon.ProjectionY("sigon_y", l, l, ""); 578 hista->SetNameTitle("ON-orig", "ON (orig)"); 579 Stat_t suma = hista->Integral(); 580 if (suma != 0.0) hista->Scale(1./suma); 581 582 TH1D *histap = new TH1D( (const TH1D&)*hista ); 583 histap->SetNameTitle("ON-OFF-merged)", "ON-OFF (merged)"); 584 585 TH1D *histb = sigthoff.ProjectionY("sigoff_y", l, l, ""); 586 histb->SetNameTitle("OFF-orig", "OFF (orig)"); 587 Stat_t sumb = histb->Integral(); 588 if (sumb != 0.0) histb->Scale(1./sumb); 589 590 if (suma == 0.0 || sumb == 0.0) 591 { 592 delete hista; 593 delete histb; 594 delete fHga; 595 delete fHgb; 596 delete histap; 597 598 *fLog << err 599 << "cannot call Merge2Distributions(ON, OFF) for theta bin l = " 600 << l << "; NevON, NevOFF = " << suma << ", " << sumb << endl; 601 602 // go to next theta bin (l) 603 continue; 604 } 605 606 //*fLog << "call Merge2Distributions(ON, OFF) for theta bin l = " 607 // << l << endl; 608 609 Merge2Distributions(hista, histb, histap, fHga, fHgb, nbinssig); 610 611 // fill fHgON and fHgOFF 612 for (Int_t k=1; k<=nbinssig; k++) 613 for (Int_t j=1; j<=nbinssig; j++) 614 { 615 Double_t a = fHga->GetBinContent(k,j); 616 fHgON->SetBinContent(l, k, j, a); 617 618 Double_t b = fHgb->GetBinContent(k,j); 619 fHgOFF->SetBinContent(l, k, j, b); 620 } 621 622 //------------------------------------------- 623 // now merge ON-OFF and MC distributions 624 // input : histe is the result of the merging of ON and OFF distributions 625 // histf is the normalized 1D distr. of sigmabar for MC data 626 // output : histep will be the merged distribution (target distribution) 627 // fHge(k,j) will tell which fraction of ON, OFF events should be 628 // padded from bin k to bin j 629 // fHgf(k,j) will tell which fraction of MC events should be 630 // padded from bin k to bin j 631 632 TH2D * fHge = new TH2D; 633 MH::SetBinning(fHge, &binsg, &binsg); 634 TH2D * fHgf = new TH2D; 635 MH::SetBinning(fHgf, &binsg, &binsg); 636 637 TH1D *histe = new TH1D( (const TH1D&)*histap); 638 histe->SetNameTitle("ON-OFF-merged", "ON-OFF (merged)"); 639 640 TH1D *histep = new TH1D( (const TH1D&)*histe); 641 histep->SetNameTitle("ON-OFF-MC-merged)", "ON-OFF-MC (merged)"); 642 643 TH1D *histf = sigthmc.ProjectionY("sigmc_y", l, l, ""); 644 histf->SetNameTitle("MC-orig", "MC (orig)"); 645 Double_t sumf = histf->Integral(); 646 if (sumf != 0.0) histf->Scale(1./sumf); 647 648 if (sumf == 0.0) 649 { 650 delete hista; 651 delete histb; 652 delete fHga; 653 delete fHgb; 654 delete histap; 655 656 delete histe; 657 delete histf; 658 delete fHge; 659 delete fHgf; 660 delete histep; 661 662 *fLog << err 663 << "cannot call Merge2Distributions(ON-OFF,MC) for theta bin l = " 664 << l << "; NevMC = " << sumf << endl; 665 666 // go to next theta bin (l) 667 continue; 668 } 669 670 //*fLog << "call Merge2Distributions(ON-OFF, MC) for theta bin l = " 671 // << l << endl; 672 673 Merge2Distributions(histe, histf, histep, fHge, fHgf, nbinssig); 674 675 // update fHgON and fHgOFF 676 UpdateHg(fHga, histap, fHge, fHgON, nbinssig, l); 677 UpdateHg(fHgb, histap, fHge, fHgOFF, nbinssig, l); 678 679 // fill fHgMC 680 for (Int_t k=1; k<=nbinssig; k++) 681 for (Int_t j=1; j<=nbinssig; j++) 682 { 683 Double_t f = fHgf->GetBinContent(k,j); 684 fHgMC->SetBinContent(l, k, j, f); 685 } 686 687 // fill target distribution fHSigmaTheta 688 // (only for plotting, it will not be used in the padding) 689 for (Int_t j=1; j<=nbinssig; j++) 690 { 691 Double_t ep = histep->GetBinContent(j); 692 fHSigmaTheta->SetBinContent(l, j, ep); 693 } 694 //------------------------------------------- 695 696 delete hista; 697 delete histb; 698 delete fHga; 699 delete fHgb; 700 delete histap; 701 702 delete histe; 703 delete histf; 704 delete fHge; 705 delete fHgf; 706 delete histep; 707 } 708 //............ end of loop over Theta bins .................... 709 710 711 // Define the target distributions 712 // fHDiffPixTheta, fHSigmaPixTheta 713 // (they are calculated as 714 // averages of the ON and OFF distributions) 715 // fHBlindPixNTheta, fHBlindPixIdTheta 716 // (they are calculated as 717 // the sum of the ON and OFF distributions) 718 // (fHDiffPixTheta will be used in the padding of MC events) 719 720 //............ start of new loop over Theta bins .................... 721 for (Int_t j=1; j<=nbinstheta; j++) 722 { 723 // fraction of ON/OFF/MC events to be padded : fracON, fracOFF, fracMC 724 725 Double_t fracON = fHgON->Integral (j, j, 1, nbinssig, 1, nbinssig, ""); 726 Double_t fracOFF = fHgOFF->Integral(j, j, 1, nbinssig, 1, nbinssig, ""); 727 Double_t fracMC = fHgMC->Integral(j, j, 1, nbinssig, 1, nbinssig, ""); 728 729 Double_t normON; 730 Double_t normOFF; 731 732 // set ranges for 2D-projections of 3D-histograms 733 TAxis *ax = diffpixthon.GetXaxis(); 734 ax->SetRange(j, j); 735 ax = diffpixthoff.GetXaxis(); 736 ax->SetRange(j, j); 737 738 TH2D *hist; 739 TH2D *histOFF; 740 741 TH1D *hist1; 742 TH1D *hist1OFF; 743 744 // weights for ON and OFF distrubtions when 745 // calculating the weighted average 746 Double_t facON = 0.5 * (1. - fracON + fracOFF); 747 Double_t facOFF = 0.5 * (1. + fracON - fracOFF); 748 749 *fLog << all << "Theta bin j : fracON, fracOFF, fracMC, facON, facOFF = " 750 << j << ", " << fracON << ", " << fracOFF << ", " 751 << fracMC << ", " << facON << ", " << facOFF << endl; 752 753 //------------------------------------------------------------------ 754 // define target distribution 'sigma^2-sigmavar^2 vs. pixel number' 755 ay = diffpixthon.GetYaxis(); 756 Int_t nbinspixel = ay->GetNbins(); 757 758 TAxis *az = diffpixthon.GetZaxis(); 759 Int_t nbinsdiff = az->GetNbins(); 760 761 hist = (TH2D*)diffpixthon.Project3D("zy"); 762 hist->SetName("dummy"); 763 histOFF = (TH2D*)diffpixthoff.Project3D("zy"); 764 765 normON = hist->Integral(); 766 normOFF = histOFF->Integral(); 767 if (normON != 0.0) hist->Scale(1.0/normON); 768 if (normOFF != 0.0) histOFF->Scale(1.0/normOFF); 769 770 // weighted average of ON and OFF distributions 771 hist->Scale(facON); 772 hist->Add(histOFF, facOFF); 773 774 for (Int_t k=1; k<=nbinspixel; k++) 775 for (Int_t l=1; l<=nbinsdiff; l++) 776 { 777 Double_t cont = hist->GetBinContent(k,l); 778 fHDiffPixTheta->SetBinContent(j, k, l, cont); 779 } 780 781 delete hist; 782 delete histOFF; 783 784 //------------------------------------------------------------------ 785 // define target distribution 'sigma vs. pixel number' 786 ay = sigmapixthon.GetYaxis(); 787 nbinspixel = ay->GetNbins(); 788 789 az = sigmapixthon.GetZaxis(); 790 Int_t nbinssigma = az->GetNbins(); 791 792 hist = (TH2D*)sigmapixthon.Project3D("zy"); 793 hist->SetName("dummy"); 794 histOFF = (TH2D*)sigmapixthoff.Project3D("zy"); 795 796 normON = hist->Integral(); 797 normOFF = histOFF->Integral(); 798 if (normON != 0.0) hist->Scale(1.0/normON); 799 if (normOFF != 0.0) histOFF->Scale(1.0/normOFF); 800 801 // weighted average of ON and OFF distributions 802 hist->Scale(facON); 803 hist->Add(histOFF, facOFF); 804 805 for (Int_t k=1; k<=nbinspixel; k++) 806 for (Int_t l=1; l<=nbinssigma; l++) 807 { 808 Double_t cont = hist->GetBinContent(k,l); 809 fHSigmaPixTheta->SetBinContent(j, k, l, cont); 810 } 811 812 delete hist; 813 delete histOFF; 814 815 816 //------------------------------------------------------------------ 817 // define target distribution 'number of blind pixels per event' 818 ay = blindnthon.GetYaxis(); 819 Int_t nbinsn = ay->GetNbins(); 820 821 hist1 = fHBlindPixNThetaON->ProjectionY("", j, j, ""); 822 hist1->SetName("dummy"); 823 hist1OFF = fHBlindPixNThetaOFF->ProjectionY("", j, j, ""); 824 825 normON = hist1->Integral(); 826 normOFF = hist1OFF->Integral(); 827 if (normON != 0.0) hist1->Scale(1.0/normON); 828 if (normOFF != 0.0) hist1OFF->Scale(1.0/normOFF); 829 830 // sum of ON and OFF distributions 831 hist1->Add(hist1OFF, 1.0); 832 Stat_t sum1 = hist1->Integral(); 833 if (sum1 != 0.0) hist1->Scale( 1.0/sum1 ); 834 835 for (Int_t k=1; k<=nbinsn; k++) 836 { 837 Double_t cont = hist1->GetBinContent(k); 838 fHBlindPixNTheta->SetBinContent(j, k, cont); 839 } 840 841 delete hist1; 842 delete hist1OFF; 843 844 //------------------------------------------------------------------ 845 // define target distribution 'id of blind pixel' 846 ay = blindidthon.GetYaxis(); 847 Int_t nbinsid = ay->GetNbins(); 848 849 hist1 = fHBlindPixIdThetaON->ProjectionY("", j, j, ""); 850 hist1->SetName("dummy"); 851 hist1OFF = fHBlindPixIdThetaOFF->ProjectionY("", j, j, ""); 852 853 // divide by the number of events (from fHBlindPixNTheta) 854 if (normON != 0.0) hist1->Scale(1.0/normON); 855 if (normOFF != 0.0) hist1OFF->Scale(1.0/normOFF); 856 857 // sum of ON and OFF distributions 858 hist1->Add(hist1OFF, 1.0); 859 860 for (Int_t k=1; k<=nbinsid; k++) 861 { 862 Double_t cont = hist1->GetBinContent(k); 863 fHBlindPixIdTheta->SetBinContent(j, k, cont); 864 } 865 866 delete hist1; 867 delete hist1OFF; 868 } 869 //............ end of new loop over Theta bins .................... 870 871 *fLog << all 872 << "MPad::MergeONOFFMC(); The target distributions for the padding have been created" 873 << endl; 874 *fLog << all << "----------------------------------------------------------" 875 << endl; 876 //-------------------------------------------- 877 878 fHSigmaThetaMC->SetDirectory(NULL); 879 fHSigmaThetaON->SetDirectory(NULL); 880 fHSigmaThetaOFF->SetDirectory(NULL); 881 882 fHDiffPixThetaMC->SetDirectory(NULL); 883 fHDiffPixThetaON->SetDirectory(NULL); 884 fHDiffPixThetaOFF->SetDirectory(NULL); 885 886 fHSigmaPixThetaMC->SetDirectory(NULL); 887 fHSigmaPixThetaON->SetDirectory(NULL); 888 fHSigmaPixThetaOFF->SetDirectory(NULL); 889 890 fHBlindPixIdThetaMC->SetDirectory(NULL); 891 fHBlindPixIdThetaON->SetDirectory(NULL); 892 fHBlindPixIdThetaOFF->SetDirectory(NULL); 893 894 fHBlindPixNThetaMC->SetDirectory(NULL); 895 fHBlindPixNThetaON->SetDirectory(NULL); 896 fHBlindPixNThetaOFF->SetDirectory(NULL); 897 898 fHgMC->SetDirectory(NULL); 899 fHgON->SetDirectory(NULL); 900 fHgOFF->SetDirectory(NULL); 901 902 return kTRUE; 903 } 904 905 // -------------------------------------------------------------------------- 906 // 907 // Update the matrix fHgA 908 // which contains the final padding prescriptions 909 // 910 911 Bool_t MPad::UpdateHg(TH2D *fHga, TH1D *histap, TH2D *fHge, TH3D *fHgA, 912 Int_t nbinssig, Int_t l) 913 { 914 // histap target distribution after ON-OFF merging 915 // fHga padding prescription for ON (or OFF) data to get to histap 916 // fHge padding prescription to get from histap to the target 917 // distribution after the ON-OFF-MC merging 918 // fHgA updated padding prescription for ON (or OFF) data to get 919 // from the original ON (or OFF) histogram to the target 920 // distribution after the ON-OFF-MC merging 921 // l Theta bin 922 923 Double_t eps = 1.e-10; 924 925 for (Int_t k=1; k<=nbinssig; k++) 926 { 927 Double_t na = fHga->Integral(1, nbinssig, k, k, " "); 928 Double_t ne = fHge->Integral(k, k, 1, nbinssig, " "); 929 Double_t nap = histap->GetBinContent(k); 930 931 if (ne <= eps) 932 { 933 // go to next k 934 continue; 935 } 936 937 Double_t r = nap - na; 938 939 if (r >= ne-eps) 940 { 941 for (Int_t j=k+1; j<=nbinssig; j++) 942 { 943 Double_t e = fHge->GetBinContent(k,j); 944 Double_t A = fHgA->GetBinContent(l,k,j); 945 fHgA->SetBinContent(l, k, j, A + e); 946 } 947 // go to next k 948 continue; 949 } 950 951 for (Int_t j=k+1; j<=nbinssig; j++) 952 { 953 Double_t e = fHge->GetBinContent(k,j); 954 Double_t A = fHgA->GetBinContent(l,k,j); 955 fHgA->SetBinContent(l, k, j, A + r*e/ne); 956 } 957 958 if (na <= eps) 959 { 960 // go to next k 961 continue; 962 } 963 964 for (Int_t i=1; i<k; i++) 965 { 966 Double_t a = fHga->GetBinContent(i,k); 967 Double_t A = fHgA->GetBinContent(l,i,k); 968 fHgA->SetBinContent(l, i, k, A - (ne-r)*a/na); 969 } 970 971 for (Int_t i=1; i<=nbinssig; i++) 972 { 973 if (i == k) continue; 974 for (Int_t j=i+1; j<=nbinssig; j++) 975 { 976 if (j == k) continue; 977 Double_t a = fHga->GetBinContent(i,k); 978 Double_t e = fHge->GetBinContent(k,j); 979 Double_t A = fHgA->GetBinContent(l,i,j); 980 fHgA->SetBinContent(l, i, j, A + (ne-r)*a*e/(na*ne) ); 981 } 982 } 983 } 984 985 return kTRUE; 986 } 987 988 // -------------------------------------------------------------------------- 989 // 990 // Merge the distributions 991 // fHSigmaTheta 2D-histogram (Theta, sigmabar) 992 // 993 // ===> of ON and MC data <============== 994 // 995 // and define the matrices fHgMC and fHgON 996 // 997 // These matrices tell which fraction of events should be padded 998 // from bin k of sigmabar to bin j 999 // 1000 1001 Bool_t MPad::MergeONMC( 1002 TH2D& sigthmc, TH3D& diffpixthmc, TH3D& sigmapixthmc, 1003 TH2D& blindidthmc, TH2D& blindnthmc, 1004 TH2D& sigthon, TH3D& diffpixthon, TH3D& sigmapixthon, 1005 TH2D& blindidthon, TH2D& blindnthon) 1006 { 1007 *fLog << all << "----------------------------------------------------------------------------------" << endl; 1008 *fLog << all << "MPad::MergeONMC(); Merge the ON and MC histograms to obtain the target distributions for the padding" 1009 << endl; 1010 1011 fHSigmaTheta = new TH2D( (TH2D&) sigthon ); 1012 fHSigmaTheta->SetNameTitle("2D-ThetaSigmabar", "2D-ThetaSigmabar (target)"); 1013 1014 fHDiffPixTheta = new TH3D( (TH3D&) diffpixthon ); 1015 fHDiffPixTheta->SetNameTitle("3D-ThetaPixDiff", "3D-ThetaPixDiff (target)"); 1016 1017 fHSigmaPixTheta = new TH3D( (TH3D&) sigmapixthon ); 1018 fHSigmaPixTheta->SetNameTitle("3D-ThetaPixSigma", "3D-ThetaPixSigma (target)"); 1019 1020 fHBlindPixNTheta = new TH2D( (TH2D&) blindnthon ); 1021 fHBlindPixNTheta->SetNameTitle("2D-ThetaBlindN", "2D-ThetaBlindN (target)"); 1022 1023 fHBlindPixIdTheta = new TH2D( (TH2D&) blindidthon ); 1024 fHBlindPixIdTheta->SetNameTitle("2D-ThetaBlindId", "2D-ThetaBlindId (target)"); 1025 1026 //-------------------------- 1027 fHSigmaThetaMC = &sigthmc; 1028 fHSigmaThetaMC->SetNameTitle("2D-ThetaSigmabarMC", "2D-ThetaSigmabarMC (orig.)"); 1029 fHSigmaThetaON = &sigthon; 1030 fHSigmaThetaON->SetNameTitle("2D-ThetaSigmabarON", "2D-ThetaSigmabarON (orig.)"); 1031 1032 //-------------------------- 1033 fHBlindPixNThetaMC = &blindnthmc; 1034 fHBlindPixNThetaMC->SetNameTitle("2D-ThetaBlindNMC", "2D-ThetaBlindNMC (orig.)"); 1035 fHBlindPixNThetaON = &blindnthon; 1036 fHBlindPixNThetaON->SetNameTitle("2D-ThetaBlindNON", "2D-ThetaBlindNON (orig.)"); 1037 1038 //-------------------------- 1039 fHBlindPixIdThetaMC = &blindidthmc; 1040 fHBlindPixIdThetaMC->SetNameTitle("2D-ThetaBlindIdMC", "2D-ThetaBlindIdMC (orig.)"); 1041 fHBlindPixIdThetaON = &blindidthon; 1042 fHBlindPixIdThetaON->SetNameTitle("2D-ThetaBlindIdON", "2D-ThetaBlindIdON (orig.)"); 1043 1044 //-------------------------- 1045 fHDiffPixThetaMC = &diffpixthmc; 1046 fHDiffPixThetaMC->SetNameTitle("3D-ThetaPixDiffMC", "3D-ThetaPixDiffMC (orig.)"); 1047 fHDiffPixThetaON = &diffpixthon; 1048 fHDiffPixThetaON->SetNameTitle("3D-ThetaPixDiffON", "3D-ThetaPixDiffON (orig.)"); 1049 1050 //-------------------------- 1051 fHSigmaPixThetaMC = &sigmapixthmc; 1052 fHSigmaPixThetaMC->SetNameTitle("3D-ThetaPixSigmaMC", "3D-ThetaPixSigmaMC (orig.)"); 1053 fHSigmaPixThetaON = &sigmapixthon; 1054 fHSigmaPixThetaON->SetNameTitle("3D-ThetaPixSigmaON", "3D-ThetaPixSigmaON (orig.)"); 1055 1056 //-------------------------- 1057 1058 1059 // get binning for fHgON and fHgMC from sigthon 1060 // binning in Theta 1061 TAxis *ax = sigthon.GetXaxis(); 430 1062 Int_t nbinstheta = ax->GetNbins(); 431 1063 TArrayD edgesx; … … 441 1073 442 1074 // binning in sigmabar 443 TAxis *ay = sigthon ->GetYaxis();1075 TAxis *ay = sigthon.GetYaxis(); 444 1076 Int_t nbinssig = ay->GetNbins(); 445 1077 TArrayD edgesy; … … 463 1095 fHgON->SetNameTitle("3D-PaddingMatrixON", "3D-PadMatrixThetaON"); 464 1096 465 fHgOFF = new TH3D;466 MH::SetBinning(fHgOFF, &binth, &binsg, &binsg);467 fHgOFF->SetNameTitle("3D-PaddingMatrixOFF", "3D-PadMatrixThetaOFF");468 469 //............ loop over Theta bins ...........................470 471 472 473 *fLog << all << "MPad::MergeONOFFMC(); bins of Theta, Sigmabarold, Sigmabarnew, fraction of events to be padded" << endl;474 for (Int_t l=1; l<=nbinstheta; l++)475 {476 TH2D * fHga = new TH2D;477 MH::SetBinning(fHga, &binsg, &binsg);478 TH2D * fHgb = new TH2D;479 MH::SetBinning(fHgb, &binsg, &binsg);480 481 //-------------------------------------------482 // merge ON and OFF distributions483 // input : hista is the normalized 1D distr. of sigmabar for ON data484 // histb is the normalized 1D distr. of sigmabar for OFF data485 // output : histap will be the merged distribution (ON-OFF)486 // fHga(k,j) will tell which fraction of ON events should be487 // padded from bin k to bin j488 // fHgb(k,j) will tell which fraction of OFF events should be489 // padded from bin k to bin j490 491 TH1D *hista = sigthon->ProjectionY("sigon_y", l, l, "");492 Stat_t suma = hista->Integral();493 hista->Scale(1./suma);494 495 TH1D *histap = new TH1D( (const TH1D&)*hista );496 497 TH1D *histb = sigthoff->ProjectionY("sigoff_y", l, l, "");498 Stat_t sumb = histb->Integral();499 histb->Scale(1./sumb);500 501 Merge2Distributions(hista, histb, histap, fHga, fHgb, nbinssig);502 delete hista;503 delete histb;504 505 // fill fHgON and fHgOFF506 for (Int_t k=1; k<=nbinssig; k++)507 for (Int_t j=1; j<=nbinssig; j++)508 {509 Double_t a = fHga->GetBinContent(k,j);510 fHga->SetBinContent (k, j, 0.0);511 fHgON->SetBinContent(l, k, j, a);512 513 Double_t b = fHgb->GetBinContent(k,j);514 fHgb->SetBinContent (k, j, 0.0);515 fHgOFF->SetBinContent(l, k, j, b);516 }517 518 //-------------------------------------------519 // now merge ON-OFF and MC distributions520 // input : hista is the result of the merging of ON and OFF distributions521 // histb is the normalized 1D distr. of sigmabar for MC data522 // output : histap will be the merged distribution (target distribution)523 // fHga(k,j) will tell which fraction of ON, OFF events should be524 // padded from bin k to bin j525 // fHgb(k,j) will tell which fraction of MC events should be526 // padded from bin k to bin j527 528 hista = new TH1D( (const TH1D&)*histap);529 530 histb = sigthmc->ProjectionY("sigmc_y", l, l, "");531 sumb = histb->Integral();532 histb->Scale(1./sumb);533 534 Merge2Distributions(hista, histb, histap, fHga, fHgb, nbinssig);535 delete hista;536 delete histb;537 538 // update fHgON and fHgOFF and fill fHgMC539 for (Int_t k=1; k<=nbinssig; k++)540 for (Int_t j=1; j<=nbinssig; j++)541 {542 Double_t a = fHga->GetBinContent (k,j);543 544 Double_t aON = fHgON->GetBinContent(l,k,j);545 fHgON->SetBinContent(l, k, j, aON+a);546 547 Double_t aOFF = fHgOFF->GetBinContent(l,k,j);548 fHgOFF->SetBinContent(l, k, j, aOFF+a);549 550 Double_t b = fHgb->GetBinContent(k,j);551 fHgMC->SetBinContent(l, k, j, b);552 }553 554 // fill target distribution fHSigmaTheta555 // (only for plotting, it will not be used in the padding)556 for (Int_t j=1; j<=nbinssig; j++)557 {558 Double_t a = histap->GetBinContent(j);559 fHSigmaTheta->SetBinContent(l, j, a);560 }561 562 delete fHga;563 delete fHgb;564 565 delete histap;566 }567 //............ end of loop over Theta bins ....................568 569 570 // Define the target distributions571 // fHDiffPixTheta, fHSigmaPixTheta572 // (they are calculated as573 // averages of the ON and OFF distributions)574 // fHBlindPixNTheta, fHBlindPixIdTheta575 // (they are calculated as576 // the sum of the ON and OFF distributions)577 // (fHDiffPixTheta will be used in the padding of MC events)578 579 //............ start of new loop over Theta bins ....................580 for (Int_t j=1; j<=nbinstheta; j++)581 {582 // fraction of ON/OFF/MC events to be padded : fracON, fracOFF, fracMC583 584 Double_t fracON = fHgON->Integral (j, j, 1, nbinssig, 1, nbinssig, "");585 Double_t fracOFF = fHgOFF->Integral(j, j, 1, nbinssig, 1, nbinssig, "");586 Double_t fracMC = fHgMC->Integral(j, j, 1, nbinssig, 1, nbinssig, "");587 588 Double_t normON;589 Double_t normOFF;590 591 // set ranges for 2D-projections of 3D-histograms592 TAxis *ax = diffpixthon->GetXaxis();593 ax->SetRange(j, j);594 ax = diffpixthoff->GetXaxis();595 ax->SetRange(j, j);596 597 TH2D *hist;598 TH2D *histOFF;599 600 TH1D *hist1;601 TH1D *hist1OFF;602 603 // weights for ON and OFF distrubtions when604 // calculating the weighted average605 Double_t facON = 0.5 * (1. - fracON + fracOFF);606 Double_t facOFF = 0.5 * (1. + fracON - fracOFF);607 608 *fLog << all << "Theta bin j : fracON, fracOFF, facON, facOFF = "609 << j << ", " << fracON << ", " << fracOFF << ", "610 << fracMC << ", " << facON << ", " << facOFF << endl;611 612 //------------------------------------------------------------------613 // define target distribution 'sigma^2-sigmavar^2 vs. pixel number'614 ay = diffpixthon->GetYaxis();615 Int_t nbinspixel = ay->GetNbins();616 617 TAxis *az = diffpixthon->GetZaxis();618 Int_t nbinsdiff = az->GetNbins();619 620 hist = (TH2D*)diffpixthon->Project3D("zy");621 hist->SetName("dummy");622 histOFF = (TH2D*)diffpixthoff->Project3D("zy");623 624 normON = hist->Integral();625 normOFF = histOFF->Integral();626 if (normON != 0.0) hist->Scale(1.0/normON);627 if (normOFF != 0.0) histOFF->Scale(1.0/normOFF);628 629 // weighted average of ON and OFF distributions630 hist->Scale(facON);631 hist->Add(histOFF, facOFF);632 633 for (Int_t k=1; k<=nbinspixel; k++)634 for (Int_t l=1; l<=nbinsdiff; l++)635 {636 Double_t cont = hist->GetBinContent(k,l);637 fHDiffPixTheta->SetBinContent(j, k, l, cont);638 }639 640 delete hist;641 delete histOFF;642 643 //------------------------------------------------------------------644 // define target distribution 'sigma vs. pixel number'645 ay = sigmapixthon->GetYaxis();646 nbinspixel = ay->GetNbins();647 648 az = sigmapixthon->GetZaxis();649 Int_t nbinssigma = az->GetNbins();650 651 hist = (TH2D*)sigmapixthon->Project3D("zy");652 hist->SetName("dummy");653 histOFF = (TH2D*)sigmapixthoff->Project3D("zy");654 655 normON = hist->Integral();656 normOFF = histOFF->Integral();657 if (normON != 0.0) hist->Scale(1.0/normON);658 if (normOFF != 0.0) histOFF->Scale(1.0/normOFF);659 660 // weighted average of ON and OFF distributions661 hist->Scale(facON);662 hist->Add(histOFF, facOFF);663 664 for (Int_t k=1; k<=nbinspixel; k++)665 for (Int_t l=1; l<=nbinssigma; l++)666 {667 Double_t cont = hist->GetBinContent(k,l);668 fHSigmaPixTheta->SetBinContent(j, k, l, cont);669 }670 671 delete hist;672 delete histOFF;673 674 675 //------------------------------------------------------------------676 // define target distribution 'number of blind pixels per event'677 ay = blindnthon->GetYaxis();678 Int_t nbinsn = ay->GetNbins();679 680 hist1 = fHBlindPixNThetaON->ProjectionY("", j, j, "");681 hist1->SetName("dummy");682 hist1OFF = fHBlindPixNThetaOFF->ProjectionY("", j, j, "");683 684 normON = hist1->Integral();685 normOFF = hist1OFF->Integral();686 if (normON != 0.0) hist1->Scale(1.0/normON);687 if (normOFF != 0.0) hist1OFF->Scale(1.0/normOFF);688 689 // sum of ON and OFF distributions690 hist1->Add(hist1OFF, 1.0);691 hist1->Scale( 1.0/hist1->Integral() );692 693 for (Int_t k=1; k<=nbinsn; k++)694 {695 Double_t cont = hist1->GetBinContent(k);696 fHBlindPixNTheta->SetBinContent(j, k, cont);697 }698 699 delete hist1;700 delete hist1OFF;701 702 //------------------------------------------------------------------703 // define target distribution 'id of blind pixel'704 ay = blindidthon->GetYaxis();705 Int_t nbinsid = ay->GetNbins();706 707 hist1 = fHBlindPixIdThetaON->ProjectionY("", j, j, "");708 hist1->SetName("dummy");709 hist1OFF = fHBlindPixIdThetaOFF->ProjectionY("", j, j, "");710 711 // divide by the number of events (from fHBlindPixNTheta)712 if (normON != 0.0) hist1->Scale(1.0/normON);713 if (normOFF != 0.0) hist1OFF->Scale(1.0/normOFF);714 715 // sum of ON and OFF distributions716 hist1->Add(hist1OFF, 1.0);717 718 for (Int_t k=1; k<=nbinsid; k++)719 {720 Double_t cont = hist1->GetBinContent(k);721 fHBlindPixIdTheta->SetBinContent(j, k, cont);722 }723 724 delete hist1;725 delete hist1OFF;726 }727 //............ end of new loop over Theta bins ....................728 729 *fLog << all730 << "MPad::MergeONOFFMC(); The target distributions for the padding have been created"731 << endl;732 *fLog << all << "----------------------------------------------------------"733 << endl;734 //--------------------------------------------735 736 fHSigmaThetaMC->SetDirectory(NULL);737 fHSigmaThetaON->SetDirectory(NULL);738 fHSigmaThetaOFF->SetDirectory(NULL);739 740 fHDiffPixThetaMC->SetDirectory(NULL);741 fHDiffPixThetaON->SetDirectory(NULL);742 fHDiffPixThetaOFF->SetDirectory(NULL);743 744 fHSigmaPixThetaMC->SetDirectory(NULL);745 fHSigmaPixThetaON->SetDirectory(NULL);746 fHSigmaPixThetaOFF->SetDirectory(NULL);747 748 fHBlindPixIdThetaMC->SetDirectory(NULL);749 fHBlindPixIdThetaON->SetDirectory(NULL);750 fHBlindPixIdThetaOFF->SetDirectory(NULL);751 752 fHBlindPixNThetaMC->SetDirectory(NULL);753 fHBlindPixNThetaON->SetDirectory(NULL);754 fHBlindPixNThetaOFF->SetDirectory(NULL);755 756 fHgMC->SetDirectory(NULL);757 fHgON->SetDirectory(NULL);758 fHgOFF->SetDirectory(NULL);759 760 return kTRUE;761 }762 763 // --------------------------------------------------------------------------764 //765 // Merge the distributions766 // fHSigmaTheta 2D-histogram (Theta, sigmabar)767 //768 // ===> of ON and MC data <==============769 //770 // and define the matrices fHgMC and fHgON771 //772 // These matrices tell which fraction of events should be padded773 // from bin k of sigmabar to bin j774 //775 776 Bool_t MPad::MergeONMC(777 TH2D *sigthmc, TH3D *diffpixthmc, TH3D *sigmapixthmc,778 TH2D *blindidthmc, TH2D *blindnthmc,779 TH2D *sigthon, TH3D *diffpixthon, TH3D *sigmapixthon,780 TH2D *blindidthon, TH2D *blindnthon)781 {782 *fLog << all << "----------------------------------------------------------------------------------" << endl;783 *fLog << all << "MPad::MergeONMC(); Merge the ON and MC histograms to obtain the target distributions for the padding"784 << endl;785 786 fHSigmaTheta = new TH2D( (TH2D&)*sigthon );787 fHSigmaTheta->SetNameTitle("2D-ThetaSigmabar", "2D-ThetaSigmabar (target)");788 789 fHDiffPixTheta = new TH3D( (TH3D&)*diffpixthon );790 fHDiffPixTheta->SetNameTitle("3D-ThetaPixDiff", "3D-ThetaPixDiff (target)");791 792 fHSigmaPixTheta = new TH3D( (TH3D&)*sigmapixthon );793 fHSigmaPixTheta->SetNameTitle("3D-ThetaPixSigma", "3D-ThetaPixSigma (target)");794 795 fHBlindPixNTheta = new TH2D( (TH2D&)*blindnthon );796 fHBlindPixNTheta->SetNameTitle("2D-ThetaBlindN", "2D-ThetaBlindN (target)");797 798 fHBlindPixIdTheta = new TH2D( (TH2D&)*blindidthon );799 fHBlindPixIdTheta->SetNameTitle("2D-ThetaBlindId", "2D-ThetaBlindId (target)");800 801 //--------------------------802 fHSigmaThetaMC = sigthmc;803 fHSigmaThetaMC->SetNameTitle("2D-ThetaSigmabarMC", "2D-ThetaSigmabarMC (orig.)");804 fHSigmaThetaON = sigthon;805 fHSigmaThetaON->SetNameTitle("2D-ThetaSigmabarON", "2D-ThetaSigmabarON (orig.)");806 807 //--------------------------808 fHBlindPixNThetaMC = blindnthmc;809 fHBlindPixNThetaMC->SetNameTitle("2D-ThetaBlindNMC", "2D-ThetaBlindNMC (orig.)");810 fHBlindPixNThetaON = blindnthon;811 fHBlindPixNThetaON->SetNameTitle("2D-ThetaBlindNON", "2D-ThetaBlindNON (orig.)");812 813 //--------------------------814 fHBlindPixIdThetaMC = blindidthmc;815 fHBlindPixIdThetaMC->SetNameTitle("2D-ThetaBlindIdMC", "2D-ThetaBlindIdMC (orig.)");816 fHBlindPixIdThetaON = blindidthon;817 fHBlindPixIdThetaON->SetNameTitle("2D-ThetaBlindIdON", "2D-ThetaBlindIdON (orig.)");818 819 //--------------------------820 fHDiffPixThetaMC = diffpixthmc;821 fHDiffPixThetaMC->SetNameTitle("3D-ThetaPixDiffMC", "3D-ThetaPixDiffMC (orig.)");822 fHDiffPixThetaON = diffpixthon;823 fHDiffPixThetaON->SetNameTitle("3D-ThetaPixDiffON", "3D-ThetaPixDiffON (orig.)");824 825 //--------------------------826 fHSigmaPixThetaMC = sigmapixthmc;827 fHSigmaPixThetaMC->SetNameTitle("3D-ThetaPixSigmaMC", "3D-ThetaPixSigmaMC (orig.)");828 fHSigmaPixThetaON = sigmapixthon;829 fHSigmaPixThetaON->SetNameTitle("3D-ThetaPixSigmaON", "3D-ThetaPixSigmaON (orig.)");830 831 //--------------------------832 833 834 // get binning for fHgON and fHgMC from sigthon835 // binning in Theta836 TAxis *ax = sigthon->GetXaxis();837 Int_t nbinstheta = ax->GetNbins();838 TArrayD edgesx;839 edgesx.Set(nbinstheta+1);840 for (Int_t i=0; i<=nbinstheta; i++)841 {842 edgesx[i] = ax->GetBinLowEdge(i+1);843 *fLog << all << "i, theta low edge = " << i << ", " << edgesx[i]844 << endl;845 }846 MBinning binth;847 binth.SetEdges(edgesx);848 849 // binning in sigmabar850 TAxis *ay = sigthon->GetYaxis();851 Int_t nbinssig = ay->GetNbins();852 TArrayD edgesy;853 edgesy.Set(nbinssig+1);854 for (Int_t i=0; i<=nbinssig; i++)855 {856 edgesy[i] = ay->GetBinLowEdge(i+1);857 *fLog << all << "i, sigmabar low edge = " << i << ", " << edgesy[i]858 << endl;859 }860 MBinning binsg;861 binsg.SetEdges(edgesy);862 863 864 fHgMC = new TH3D;865 MH::SetBinning(fHgMC, &binth, &binsg, &binsg);866 fHgMC->SetNameTitle("3D-PaddingMatrixMC", "3D-PadMatrixThetaMC");867 868 fHgON = new TH3D;869 MH::SetBinning(fHgON, &binth, &binsg, &binsg);870 fHgON->SetNameTitle("3D-PaddingMatrixON", "3D-PadMatrixThetaON");871 872 1097 873 1098 //............ loop over Theta bins ........................... … … 893 1118 // padded from bin k to bin j 894 1119 895 TH1D *hista = sigthon ->ProjectionY("sigon_y", l, l, "");1120 TH1D *hista = sigthon.ProjectionY("sigon_y", l, l, ""); 896 1121 Stat_t suma = hista->Integral(); 897 hista->Scale(1./suma);1122 if (suma != 0.0) hista->Scale(1./suma); 898 1123 899 1124 TH1D *histap = new TH1D( (const TH1D&)*hista ); 900 1125 901 TH1D *histb = sigthmc ->ProjectionY("sigmc_y", l, l, "");1126 TH1D *histb = sigthmc.ProjectionY("sigmc_y", l, l, ""); 902 1127 Stat_t sumb = histb->Integral(); 903 histb->Scale(1./sumb);1128 if (sumb != 0.0) histb->Scale(1./sumb); 904 1129 905 1130 Merge2Distributions(hista, histb, histap, fHga, fHgb, nbinssig); … … 958 1183 959 1184 // set ranges for 2D-projections of 3D-histograms 960 TAxis *ax = diffpixthon ->GetXaxis();1185 TAxis *ax = diffpixthon.GetXaxis(); 961 1186 ax->SetRange(j, j); 962 ax = diffpixthmc ->GetXaxis();1187 ax = diffpixthmc.GetXaxis(); 963 1188 ax->SetRange(j, j); 964 1189 … … 980 1205 //------------------------------------------------------------------ 981 1206 // define target distribution 'sigma^2-sigmavar^2 vs. pixel number' 982 ay = diffpixthon ->GetYaxis();1207 ay = diffpixthon.GetYaxis(); 983 1208 Int_t nbinspixel = ay->GetNbins(); 984 1209 985 TAxis *az = diffpixthon ->GetZaxis();1210 TAxis *az = diffpixthon.GetZaxis(); 986 1211 Int_t nbinsdiff = az->GetNbins(); 987 1212 988 hist = (TH2D*)diffpixthon ->Project3D("zy");1213 hist = (TH2D*)diffpixthon.Project3D("zy"); 989 1214 hist->SetName("dummy"); 990 histMC = (TH2D*)diffpixthmc ->Project3D("zy");1215 histMC = (TH2D*)diffpixthmc.Project3D("zy"); 991 1216 992 1217 normON = hist->Integral(); … … 1011 1236 //------------------------------------------------------------------ 1012 1237 // define target distribution 'sigma vs. pixel number' 1013 ay = sigmapixthon ->GetYaxis();1238 ay = sigmapixthon.GetYaxis(); 1014 1239 nbinspixel = ay->GetNbins(); 1015 1240 1016 az = sigmapixthon ->GetZaxis();1241 az = sigmapixthon.GetZaxis(); 1017 1242 Int_t nbinssigma = az->GetNbins(); 1018 1243 1019 hist = (TH2D*)sigmapixthon ->Project3D("zy");1244 hist = (TH2D*)sigmapixthon.Project3D("zy"); 1020 1245 hist->SetName("dummy"); 1021 histMC = (TH2D*)sigmapixthmc ->Project3D("zy");1246 histMC = (TH2D*)sigmapixthmc.Project3D("zy"); 1022 1247 1023 1248 normON = hist->Integral(); 1024 1249 normMC = histMC->Integral(); 1025 1250 if (normON != 0.0) hist->Scale(1.0/normON); 1026 if (normMC != 0.0) histMC->Scale(1.0/normMC);1251 if (normMC != 0.0) histMC->Scale(1.0/normMC); 1027 1252 1028 1253 // weighted average of ON and MC distributions … … 1043 1268 //------------------------------------------------------------------ 1044 1269 // define target distribution 'number of blind pixels per event' 1045 ay = blindnthon ->GetYaxis();1270 ay = blindnthon.GetYaxis(); 1046 1271 Int_t nbinsn = ay->GetNbins(); 1047 1272 … … 1053 1278 normMC = hist1MC->Integral(); 1054 1279 if (normON != 0.0) hist1->Scale(1.0/normON); 1055 if (normMC != 0.0)hist1MC->Scale(1.0/normMC);1280 if (normMC != 0.0) hist1MC->Scale(1.0/normMC); 1056 1281 1057 1282 // sum of ON and MC distributions 1058 1283 hist1->Add(hist1MC, 1.0); 1059 hist1->Scale( 1.0/hist1->Integral() ); 1284 Stat_t sum1 = hist1->Integral(); 1285 if (sum1 != 0.0) hist1->Scale( 1.0/sum1 ); 1060 1286 1061 1287 for (Int_t k=1; k<=nbinsn; k++) … … 1070 1296 //------------------------------------------------------------------ 1071 1297 // define target distribution 'id of blind pixel' 1072 ay = blindidthon ->GetYaxis();1298 ay = blindidthon.GetYaxis(); 1073 1299 Int_t nbinsid = ay->GetNbins(); 1074 1300 … … 1079 1305 // divide by the number of events (from fHBlindPixNTheta) 1080 1306 if (normON != 0.0) hist1->Scale(1.0/normON); 1081 if (normMC != 0.0)hist1MC->Scale(1.0/normMC);1307 if (normMC != 0.0) hist1MC->Scale(1.0/normMC); 1082 1308 1083 1309 // sum of ON and MC distributions … … 1138 1364 1139 1365 //------------------------------------ 1366 1367 /* 1140 1368 fHSigmaThetaMC = 1141 1369 (TH2D*) gROOT->FindObject("2D-ThetaSigmabarMC"); … … 1147 1375 return kFALSE; 1148 1376 } 1377 */ 1378 fHSigmaThetaMC = new TH2D; 1379 fHSigmaThetaMC->Read("2D-ThetaSigmabarMC"); 1149 1380 *fLog << all 1150 1381 << "MPad : Object '2D-ThetaSigmabarMC' was read in" << endl; 1151 1382 1383 /* 1152 1384 fHSigmaThetaON = 1153 1385 (TH2D*) gROOT->FindObject("2D-ThetaSigmabarON"); … … 1159 1391 return kFALSE; 1160 1392 } 1393 */ 1394 fHSigmaThetaON = new TH2D; 1395 fHSigmaThetaON->Read("2D-ThetaSigmabarON"); 1161 1396 *fLog << all 1162 1397 << "MPad : Object '2D-ThetaSigmabarON' was read in" << endl; 1163 1398 1399 /* 1164 1400 fHSigmaThetaOFF = 1165 1401 (TH2D*) gROOT->FindObject("2D-ThetaSigmabarOFF"); … … 1171 1407 return kFALSE; 1172 1408 } 1409 */ 1410 fHSigmaThetaOFF = new TH2D; 1411 fHSigmaThetaOFF->Read("2D-ThetaSigmabarOFF"); 1173 1412 *fLog << all 1174 1413 << "MPad:Object '2D-ThetaSigmabarOFF' was read in" << endl; 1175 1414 1176 1415 //------------------------------------ 1416 /* 1177 1417 fHDiffPixTheta = 1178 1418 (TH3D*) gROOT->FindObject("3D-ThetaPixDiff"); … … 1184 1424 return kFALSE; 1185 1425 } 1426 */ 1427 fHDiffPixTheta = new TH3D; 1428 fHDiffPixTheta->Read("3D-ThetaPixDiff"); 1186 1429 *fLog << all 1187 1430 << "MPad : Object '3D-ThetaPixDiff' was read in" << endl; 1188 1431 1432 /* 1189 1433 fHDiffPixThetaMC = 1190 1434 (TH3D*) gROOT->FindObject("3D-ThetaPixDiffMC"); … … 1196 1440 return kFALSE; 1197 1441 } 1442 */ 1443 fHDiffPixThetaMC = new TH3D; 1444 fHDiffPixThetaMC->Read("3D-ThetaPixDiffMC"); 1198 1445 *fLog << all 1199 1446 << "MPad : Object '3D-ThetaPixDiffMC' was read in" << endl; 1200 1447 1448 /* 1201 1449 fHDiffPixThetaON = 1202 1450 (TH3D*) gROOT->FindObject("3D-ThetaPixDiffON"); … … 1208 1456 return kFALSE; 1209 1457 } 1458 */ 1459 fHDiffPixThetaON = new TH3D; 1460 fHDiffPixThetaON->Read("3D-ThetaPixDiffON"); 1210 1461 *fLog << all 1211 1462 << "MPad : Object '3D-ThetaPixDiffON' was read in" << endl; 1212 1463 1464 /* 1213 1465 fHDiffPixThetaOFF = 1214 1466 (TH3D*) gROOT->FindObject("3D-ThetaPixDiffOFF"); … … 1220 1472 return kFALSE; 1221 1473 } 1474 */ 1475 fHDiffPixThetaOFF = new TH3D; 1476 fHDiffPixThetaOFF->Read("3D-ThetaPixDiffOFF"); 1222 1477 *fLog << all 1223 1478 << "MPad : Object '3D-ThetaPixDiffOFF' was read in" << endl; … … 1225 1480 1226 1481 //------------------------------------ 1482 /* 1227 1483 fHSigmaPixTheta = 1228 1484 (TH3D*) gROOT->FindObject("3D-ThetaPixSigma"); … … 1234 1490 return kFALSE; 1235 1491 } 1492 */ 1493 fHSigmaPixTheta = new TH3D; 1494 fHSigmaPixTheta->Read("3D-ThetaPixSigma"); 1236 1495 *fLog << all 1237 1496 << "MPad : Object '3D-ThetaPixSigma' was read in" << endl; 1238 1497 1498 /* 1239 1499 fHSigmaPixThetaMC = 1240 1500 (TH3D*) gROOT->FindObject("3D-ThetaPixSigmaMC"); … … 1246 1506 return kFALSE; 1247 1507 } 1508 */ 1509 fHSigmaPixThetaMC = new TH3D; 1510 fHSigmaPixThetaMC->Read("3D-ThetaPixSigmaMC"); 1248 1511 *fLog << all 1249 1512 << "MPad : Object '3D-ThetaPixSigmaMC' was read in" << endl; 1250 1513 1514 /* 1251 1515 fHSigmaPixThetaON = 1252 1516 (TH3D*) gROOT->FindObject("3D-ThetaPixSigmaON"); … … 1258 1522 return kFALSE; 1259 1523 } 1524 */ 1525 fHSigmaPixThetaON = new TH3D; 1526 fHSigmaPixThetaON->Read("3D-ThetaPixSigmaON"); 1260 1527 *fLog << all 1261 1528 << "MPad : Object '3D-ThetaPixSigmaON' was read in" << endl; 1262 1529 1530 /* 1263 1531 fHSigmaPixThetaOFF = 1264 1532 (TH3D*) gROOT->FindObject("3D-ThetaPixSigmaOFF"); … … 1270 1538 return kFALSE; 1271 1539 } 1540 */ 1541 fHSigmaPixThetaOFF = new TH3D; 1542 fHSigmaPixThetaOFF->Read("3D-ThetaPixSigmaOFF"); 1272 1543 *fLog << all 1273 1544 << "MPad : Object '3D-ThetaPixSigmaOFF' was read in" << endl; 1274 1545 1275 1546 //------------------------------------ 1547 /* 1276 1548 fHgMC = 1277 1549 (TH3D*) gROOT->FindObject("3D-PaddingMatrixMC"); … … 1283 1555 return kFALSE; 1284 1556 } 1557 */ 1558 fHgMC = new TH3D; 1559 fHgMC->Read("3D-PaddingMatrixMC"); 1285 1560 *fLog << all 1286 1561 << "MPad : Object '3D-PaddingMatrixMC' was read in" << endl; 1287 1562 1563 /* 1288 1564 fHgON = 1289 1565 (TH3D*) gROOT->FindObject("3D-PaddingMatrixON"); … … 1295 1571 return kFALSE; 1296 1572 } 1573 */ 1574 fHgON = new TH3D; 1575 fHgON->Read("3D-PaddingMatrixON"); 1297 1576 *fLog << all 1298 1577 << "MPad : Object '3D-PaddingMatrixON' was read in" << endl; 1299 1578 1579 /* 1300 1580 fHgOFF = 1301 1581 (TH3D*) gROOT->FindObject("3D-PaddingMatrixOFF"); … … 1307 1587 return kFALSE; 1308 1588 } 1589 */ 1590 fHgOFF = new TH3D; 1591 fHgOFF->Read("3D-PaddingMatrixOFF"); 1309 1592 *fLog << all 1310 1593 << "MPad : Object '3D-PaddingMatrixOFF' was read in" << endl; 1311 1594 1312 1595 //------------------------------------ 1596 /* 1597 fHBlindPixIdTheta = 1598 (TH2D*) gROOT->FindObject("2D-ThetaBlindId"); 1599 if (!fHBlindPixIdTheta) 1600 { 1601 *fLog << all 1602 << "MPad : Object '2D-ThetaBlindId' not found on root file" 1603 << endl; 1604 return kFALSE; 1605 } 1606 */ 1607 fHBlindPixIdTheta = new TH2D; 1608 fHBlindPixIdTheta->Read("2D-ThetaBlindId"); 1609 *fLog << all 1610 << "MPad : Object '2D-ThetaBlindId' was read in" << endl; 1611 1612 /* 1313 1613 fHBlindPixIdThetaMC = 1314 1614 (TH2D*) gROOT->FindObject("2D-ThetaBlindIdMC"); … … 1320 1620 return kFALSE; 1321 1621 } 1622 */ 1623 fHBlindPixIdThetaMC = new TH2D; 1624 fHBlindPixIdThetaMC->Read("2D-ThetaBlindIdMC"); 1322 1625 *fLog << all 1323 1626 << "MPad : Object '2D-ThetaBlindIdMC' was read in" << endl; 1324 1627 1628 /* 1325 1629 fHBlindPixIdThetaON = 1326 1630 (TH2D*) gROOT->FindObject("2D-ThetaBlindIdON"); … … 1332 1636 return kFALSE; 1333 1637 } 1638 */ 1639 fHBlindPixIdThetaON = new TH2D; 1640 fHBlindPixIdThetaON->Read("2D-ThetaBlindIdON"); 1334 1641 *fLog << all 1335 1642 << "MPad : Object '2D-ThetaBlindIdON' was read in" << endl; 1336 1643 1644 /* 1337 1645 fHBlindPixIdThetaOFF = 1338 1646 (TH2D*) gROOT->FindObject("2D-ThetaBlindIdOFF"); … … 1344 1652 return kFALSE; 1345 1653 } 1654 */ 1655 fHBlindPixIdThetaOFF = new TH2D; 1656 fHBlindPixIdThetaOFF->Read("2D-ThetaBlindIdOFF"); 1346 1657 *fLog << all 1347 << "MPad : Object '2D-ThetaBlindId MC' was read in" << endl;1658 << "MPad : Object '2D-ThetaBlindIdOFF' was read in" << endl; 1348 1659 1349 1660 //------------------------------------ 1661 /* 1662 fHBlindPixNTheta = 1663 (TH2D*) gROOT->FindObject("2D-ThetaBlindN"); 1664 if (!fHBlindPixNTheta) 1665 { 1666 *fLog << all 1667 << "MPad : Object '2D-ThetaBlindN' not found on root file" 1668 << endl; 1669 return kFALSE; 1670 } 1671 */ 1672 fHBlindPixNTheta = new TH2D; 1673 fHBlindPixNTheta->Read("2D-ThetaBlindN"); 1674 *fLog << all 1675 << "MPad : Object '2D-ThetaBlindN' was read in" << endl; 1676 1677 /* 1350 1678 fHBlindPixNThetaMC = 1351 1679 (TH2D*) gROOT->FindObject("2D-ThetaBlindNMC"); … … 1357 1685 return kFALSE; 1358 1686 } 1687 */ 1688 fHBlindPixNThetaMC = new TH2D; 1689 fHBlindPixNThetaMC->Read("2D-ThetaBlindNMC"); 1359 1690 *fLog << all 1360 1691 << "MPad : Object '2D-ThetaBlindNMC' was read in" << endl; 1361 1692 1693 /* 1362 1694 fHBlindPixNThetaON = 1363 1695 (TH2D*) gROOT->FindObject("2D-ThetaBlindNON"); … … 1369 1701 return kFALSE; 1370 1702 } 1703 */ 1704 fHBlindPixNThetaON = new TH2D; 1705 fHBlindPixNThetaON->Read("2D-ThetaBlindNON"); 1371 1706 *fLog << all 1372 1707 << "MPad : Object '2D-ThetaBlindNON' was read in" << endl; 1373 1708 1709 /* 1374 1710 fHBlindPixNThetaOFF = 1375 1711 (TH2D*) gROOT->FindObject("2D-ThetaBlindNOFF"); … … 1381 1717 return kFALSE; 1382 1718 } 1719 */ 1720 fHBlindPixNThetaOFF = new TH2D; 1721 fHBlindPixNThetaOFF->Read("2D-ThetaBlindNOFF"); 1383 1722 *fLog << all 1384 1723 << "MPad : Object '2D-ThetaBlindNOFF' was read in" << endl; … … 1402 1741 TFile outfile(namefileout, "RECREATE"); 1403 1742 1743 fHBlindPixNTheta->Write(); 1404 1744 fHBlindPixNThetaMC->Write(); 1405 1745 fHBlindPixNThetaON->Write(); 1406 1746 fHBlindPixNThetaOFF->Write(); 1407 1747 1748 fHBlindPixIdTheta->Write(); 1408 1749 fHBlindPixIdThetaMC->Write(); 1409 1750 fHBlindPixIdThetaON->Write(); … … 1470 1811 } 1471 1812 1472 f McEvt = (MMcEvt*)pList->FindObject("MMcEvt");1473 if (!f McEvt)1813 fPointPos = (MPointingPos*)pList->FindObject("MPointingPos"); 1814 if (!fPointPos) 1474 1815 { 1475 *fLog << err << dbginf << "MPad : M McEvtnot found... aborting."1816 *fLog << err << dbginf << "MPad : MPointingPos not found... aborting." 1476 1817 << endl; 1477 1818 return kFALSE; 1478 1819 } 1479 1820 1480 1821 fPed = (MPedPhotCam*)pList->FindObject("MPedPhotCam"); … … 1510 1851 } 1511 1852 1512 fBlind s= (MBlindPixels*)pList->FindCreateObj("MBlindPixels");1513 if (!fBlind s)1853 fBlindPix = (MBlindPixels*)pList->FindCreateObj("MBlindPixels"); 1854 if (!fBlindPix) 1514 1855 { 1515 1856 *fLog << err << "MPad : MBlindPixels not found... aborting." … … 1532 1873 // plot pedestal sigmas 1533 1874 fHSigmaPedestal = new TH2D("SigPed","Sigma: after vs. before padding", 1534 100, 0.0, 5.0, 100, 0.0,5.0);1875 100, 0.0, 75.0, 100, 0.0, 75.0); 1535 1876 fHSigmaPedestal->SetXTitle("Pedestal sigma before padding"); 1536 1877 fHSigmaPedestal->SetYTitle("Pedestal sigma after padding"); … … 1538 1879 // plot no.of photons (before vs. after padding) 1539 1880 fHPhotons = new TH2D("Photons","Photons: after vs.before padding", 1540 100, -10 .0, 90.0, 100, -10, 90);1881 100, -100.0, 300.0, 100, -100, 300); 1541 1882 fHPhotons->SetXTitle("no.of photons before padding"); 1542 1883 fHPhotons->SetYTitle("no.of photons after padding"); 1543 1884 1544 1885 // plot of added NSB 1545 fHNSB = new TH1D("NSB","Distribution of added NSB", 100, -10 .0, 10.0);1886 fHNSB = new TH1D("NSB","Distribution of added NSB", 100, -100.0, 200.0); 1546 1887 fHNSB->SetXTitle("no.of added NSB photons"); 1547 1888 fHNSB->SetYTitle("no.of pixels"); … … 1550 1891 //-------------------------------------------------------------------- 1551 1892 1552 fIter = 20;1893 fIter = 10; 1553 1894 1554 1895 memset(fErrors, 0, sizeof(fErrors)); … … 1570 1911 Int_t MPad::Process() 1571 1912 { 1572 *fLog << all << "Entry MPad::Process();" << endl;1913 //*fLog << all << "Entry MPad::Process();" << endl; 1573 1914 1574 1915 // this is the conversion factor from the number of photons … … 1576 1917 // later to be taken from MCalibration 1577 1918 // fPEperPhoton = PW * LG * QE * 1D 1578 Double_t fPEperPhoton = 0.9 5 * 0.90 * 0.13 * 0.9;1919 Double_t fPEperPhoton = 0.92 * 0.94 * 0.23 * 0.9; 1579 1920 1580 1921 //------------------------------------------------ 1581 // add pixels to MCerPhotEvt which are not yet in; 1582 // set their number of photons equal to zero 1583 1922 // Add pixels to MCerPhotEvt which are not yet in; 1923 // set their number of photons equal to zero. 1924 // Purpose : by the padding the number of photons is changed 1925 // so that cleaning and cuts may be affected. 1926 // However, no big effect is expectec unless the padding is strong 1927 // (strong increase of the noise level) 1928 // At present comment out this code 1929 1930 /* 1584 1931 UInt_t imaxnumpix = fCam->GetNumPixels(); 1585 1932 … … 1603 1950 fEvt->AddPixel(i, 0.0, (*fPed)[i].GetRms()); 1604 1951 } 1605 1952 */ 1606 1953 1607 1954 … … 1615 1962 // Calculate average sigma of the event 1616 1963 // 1617 Double_t sigbarold_phot = fSigmabar->Calc(*fCam, *fPed, *fEvt); 1618 *fLog << all << "MPad::Process(); before padding : " << endl; 1619 fSigmabar->Print(""); 1620 Double_t sigbarold = sigbarold_phot * fPEperPhoton; 1621 Double_t sigbarold2 = sigbarold*sigbarold; 1622 1623 const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta(); 1624 *fLog << all << "theta = " << theta << endl; 1964 1965 fSigmabar->Calc(*fCam, *fPed, *fEvt); 1966 //*fLog << all << "MPad::Process(); before padding : " << endl; 1967 //fSigmabar->Print(""); 1968 1969 // inner sigmabar/sqrt(area) 1970 Double_t sigbarInnerold_phot = fSigmabar->GetSigmabarInner(); 1971 Double_t sigbarInnerold = sigbarInnerold_phot * fPEperPhoton; 1972 Double_t sigbarInnerold2 = sigbarInnerold*sigbarInnerold; 1973 1974 // outer sigmabar/sqrt(area) 1975 Double_t sigbarOuterold_phot = fSigmabar->GetSigmabarOuter(); 1976 Double_t sigbarOuterold = sigbarOuterold_phot * fPEperPhoton; 1977 Double_t sigbarOuterold2 = sigbarOuterold*sigbarOuterold; 1978 1979 const Double_t theta = fPointPos->GetZd(); 1980 1981 //*fLog << all << "theta = " << theta << endl; 1625 1982 1626 1983 Int_t binTheta = fHBlindPixNTheta->GetXaxis()->FindBin(theta); … … 1629 1986 *fLog << warn 1630 1987 << "MPad::Process(); binNumber out of range : theta, binTheta = " 1631 << theta << ", " << binTheta << "; Skip event " << endl; 1632 // event cannot be padded; skip event 1988 << theta << ", " << binTheta << "; aborting " << endl; 1633 1989 1634 1990 rc = 2; … … 1637 1993 } 1638 1994 1995 //*fLog << all << "binTheta = " << binTheta << endl; 1996 1997 1639 1998 //------------------------------------------- 1640 1999 // get number of events in this theta bin 1641 // and number of events in this sigbar old_phot bin2000 // and number of events in this sigbarInnerold_phot bin 1642 2001 1643 2002 Double_t nTheta; … … 1657 2016 TH1D *hn; 1658 2017 hn = st->ProjectionY("", binTheta, binTheta, ""); 2018 2019 //*fLog << "Title of histogram : " << st->GetTitle() << endl; 2020 //for (Int_t i=1; i<=hn->GetNbinsX(); i++) 2021 //{ 2022 // *fLog << "bin " << i << " : no.of entries = " << hn->GetBinContent(i) 2023 // << endl; 2024 //} 2025 1659 2026 nTheta = hn->Integral(); 1660 Int_t binSigma = hn->FindBin(sigbar old_phot);2027 Int_t binSigma = hn->FindBin(sigbarInnerold_phot); 1661 2028 nSigma = hn->GetBinContent(binSigma); 1662 2029 1663 *fLog << all 1664 << "Theta, sigbarold_phot, binTheta, binSigma, nTheta, nSigma = " 1665 << theta << ", " << sigbarold_phot << ", " << binTheta << ", " 1666 << binSigma << ", " << nTheta << ", " << nSigma << endl; 2030 //*fLog << all 2031 // << "Theta, sigbarold_phot, binTheta, binSigma, nTheta, nSigma = " 2032 // << theta << ", " << sigbarInnerold_phot << ", " << binTheta 2033 // << ", " 2034 // << binSigma << ", " << nTheta << ", " << nSigma << endl; 1667 2035 1668 2036 delete hn; 1669 1670 2037 1671 2038 //------------------------------------------- 1672 2039 // for the current theta : … … 1688 2055 if ( nblind->Integral() == 0.0 ) 1689 2056 { 1690 *fLog << warn << "MPad::Process(); projection for Theta bin " 1691 << binTheta << " has no entries; Skip event " << endl; 2057 *fLog << warn << "MPad::Process(); projection of '" 2058 << fHBlindPixNThetaOFF->GetName() << "' for Theta bin " 2059 << binTheta << " has no entries; aborting " << endl; 1692 2060 // event cannot be padded; skip event 1693 2061 delete nblind; … … 1732 2100 nlist++; 1733 2101 1734 fBlind s->SetPixelBlind(idBlind);1735 *fLog << all << "idBlind = " << idBlind << endl;2102 fBlindPix->SetPixelBlind(idBlind); 2103 //*fLog << all << "idBlind = " << idBlind << endl; 1736 2104 } 1737 fBlind s->SetReadyToSave();2105 fBlindPix->SetReadyToSave(); 1738 2106 1739 2107 delete hblind; … … 1752 2120 if ( nblind->Integral() == 0.0 ) 1753 2121 { 1754 *fLog << warn << "MPad::Process(); projection for Theta bin " 2122 *fLog << warn << "MPad::Process(); projection of '" 2123 << fHBlindPixNThetaON->GetName() << "' for Theta bin " 1755 2124 << binTheta << " has no entries; Skip event " << endl; 1756 // event cannot be padded; skip event1757 2125 delete nblind; 1758 2126 … … 1796 2164 nlist++; 1797 2165 1798 fBlind s->SetPixelBlind(idBlind);1799 *fLog << all << "idBlind = " << idBlind << endl;2166 fBlindPix->SetPixelBlind(idBlind); 2167 //*fLog << all << "idBlind = " << idBlind << endl; 1800 2168 } 1801 fBlind s->SetReadyToSave();2169 fBlindPix->SetReadyToSave(); 1802 2170 1803 2171 delete hblind; … … 1810 2178 // 1811 2179 1812 Int_t binSig = fHgON->GetYaxis()->FindBin(sigbar old_phot);1813 *fLog << all << "binSig, sigbarold_phot = " << binSig << ", "1814 << sigbarold_phot << endl;2180 Int_t binSig = fHgON->GetYaxis()->FindBin(sigbarInnerold_phot); 2181 //*fLog << all << "binSig, sigbarInnerold_phot = " << binSig << ", " 2182 // << sigbarInnerold_phot << endl; 1815 2183 1816 2184 Double_t prob; … … 1843 2211 prob = 0.0; 1844 2212 1845 1846 << ", " << prob << endl;2213 //*fLog << all << "nTheta, nSigma, prob = " << nTheta << ", " << nSigma 2214 // << ", " << prob << endl; 1847 2215 1848 2216 if ( prob <= 0.0 || gRandom->Uniform() > prob ) … … 1850 2218 delete hpad; 1851 2219 // event should not be padded 1852 *fLog << all << "event is not padded" << endl;2220 //*fLog << all << "event is not padded" << endl; 1853 2221 1854 2222 rc = 8; … … 1857 2225 } 1858 2226 // event should be padded 1859 *fLog << all << "event will be padded" << endl;2227 //*fLog << all << "event will be padded" << endl; 1860 2228 1861 2229 … … 1864 2232 // for MC/ON/OFF data according to the matrix fHgMC/ON/OFF 1865 2233 // 1866 Double_t sigmabar _phot = 0;1867 Double_t sigmabar = 0;2234 Double_t sigmabarInner_phot = 0; 2235 Double_t sigmabarInner = 0; 1868 2236 1869 2237 … … 1876 2244 //} 1877 2245 1878 sigmabar _phot = hpad->GetRandom();1879 sigmabar = sigmabar_phot * fPEperPhoton;1880 1881 *fLog << all << "sigmabar_phot = " << sigmabar_phot << endl;2246 sigmabarInner_phot = hpad->GetRandom(); 2247 sigmabarInner = sigmabarInner_phot * fPEperPhoton; 2248 2249 //*fLog << all << "sigmabarInner_phot = " << sigmabarInner_phot << endl; 1882 2250 1883 2251 delete hpad; 1884 2252 1885 const Double_t sigmabar2 = sigmabar*sigmabar; 2253 // new inner sigmabar2/area 2254 const Double_t sigmabarInner2 = sigmabarInner*sigmabarInner; 1886 2255 1887 2256 //------------------------------------------- 1888 2257 1889 *fLog << all << "MPad::Process(); sigbarold, sigmabar = "1890 << sigbarold << ", "<< sigmabar << endl;1891 1892 // S kip eventif target sigmabar is <= sigbarold1893 if (sigmabar <= sigbarold)2258 //*fLog << all << "MPad::Process(); sigbarInnerold, sigmabarInner = " 2259 // << sigbarInnerold << ", "<< sigmabarInner << endl; 2260 2261 // Stop if target sigmabar is <= sigbarold 2262 if (sigmabarInner <= sigbarInnerold) 1894 2263 { 1895 *fLog << all << "MPad::Process(); target sigmabar is less than sigbarold : " 1896 << sigmabar << ", " << sigbarold << ", Skip event" << endl; 2264 *fLog << all << "MPad::Process(); target sigmabarInner is less than sigbarInnerold : " 2265 << sigmabarInner << ", " << sigbarInnerold << ", aborting" 2266 << endl; 1897 2267 1898 2268 rc = 4; … … 1923 2293 } 1924 2294 1925 // Get RMS of (Sigma^2-sigmabar^2) in this Theta bin. 1926 // The average electronic noise (to be added) has to be well above this RMS, 1927 // otherwise the electronic noise of an individual pixel (elNoise2Pix) 1928 // may become negative 2295 // In this Theta bin, get RMS of (Sigma^2-sigmabar^2) for inner pixels 2296 // The average electronic noise (to be added) has to be in the order of 2297 // this RMS, otherwise the electronic noise of an individual pixel 2298 // (elNoise2Pix) may become negative 2299 2300 // Attention : maximum ID of inner pixels hard coded !!! 2301 Int_t idmaxpixinner = 396; 2302 Int_t binmaxpixinner = 2303 fHDiffPixTheta->GetYaxis()->FindBin( (Double_t)idmaxpixinner ); 1929 2304 1930 2305 TH1D *hnoise; 1931 2306 if (fType == "MC") 1932 hnoise = fHDiffPixTheta->ProjectionZ("", binTheta, binTheta, 0, 9999, "");2307 hnoise = fHDiffPixTheta->ProjectionZ("", binTheta, binTheta, 0, binmaxpixinner, ""); 1933 2308 else if (fType == "ON") 1934 hnoise = fHDiffPixThetaOFF->ProjectionZ("", binTheta, binTheta, 0, 9999, "");2309 hnoise = fHDiffPixThetaOFF->ProjectionZ("", binTheta, binTheta, 0, binmaxpixinner, ""); 1935 2310 else if (fType == "OFF") 1936 hnoise = fHDiffPixThetaON->ProjectionZ("", binTheta, binTheta, 0, 9999, "");2311 hnoise = fHDiffPixThetaON->ProjectionZ("", binTheta, binTheta, 0, binmaxpixinner, ""); 1937 2312 else 1938 2313 { … … 1946 2321 delete hnoise; 1947 2322 1948 elNoise2 = TMath::Min( RMS, sigmabar2 - sigbarold2);1949 *fLog << all << "elNoise2 = " << elNoise2 << endl;1950 1951 lambdabar = (sigmabar 2 - sigbarold2 - elNoise2) / F2excess;2323 elNoise2 = TMath::Min(2.0*RMS, sigmabarInner2 - sigbarInnerold2); 2324 //*fLog << all << "elNoise2 = " << elNoise2 << endl; 2325 2326 lambdabar = (sigmabarInner2 - sigbarInnerold2 - elNoise2) / F2excess; 1952 2327 1953 2328 // This value of lambdabar is the same for all pixels; … … 1957 2332 // do the padding for each pixel 1958 2333 // 1959 // pad only pixels - which are used (before image cleaning)2334 // pad only pixels - which are used and not blind (before image cleaning) 1960 2335 // 1961 2336 … … 1971 2346 1972 2347 2348 // throw the Sigma for the pixels from the distribution fHDiffPixTheta 2349 // MC : from fHDiffPixTheta 2350 // ON : from fHDiffPixThetaOFF 2351 // OFF : from fHDiffPixThetaON 2352 2353 TH3D *sp = NULL; 2354 2355 if (fType == "MC") sp = fHDiffPixTheta; 2356 else if (fType == "ON") sp = fHDiffPixThetaOFF; 2357 else if (fType == "OFF") sp = fHDiffPixThetaON; 2358 else 2359 { 2360 *fLog << err << "MPad::Process(); illegal data type... aborting" 2361 << endl; 2362 return kERROR; 2363 } 2364 2365 Double_t sigbarold2; 2366 Double_t sigmabar2; 2367 Double_t sigmabarOuter2; 2368 2369 1973 2370 for (UInt_t i=0; i<npix; i++) 1974 2371 { 2372 1975 2373 MCerPhotPix &pix = (*fEvt)[i]; 1976 2374 if ( !pix.IsPixelUsed() ) … … 1990 2388 Double_t ratioArea = 1.0 / fCam->GetPixRatio(j); 1991 2389 2390 if (ratioArea < 1.5) 2391 { 2392 sigbarold2 = sigbarInnerold2; 2393 sigmabar2 = sigmabarInner2; 2394 } 2395 else 2396 { 2397 sigbarold2 = sigbarOuterold2; 2398 //sigbarOuter2 = sigmabarInner2 * sigbarOuterold2 / sigbarInnerold2; 2399 sigmabarOuter2 = sigmabarInner2 + (sigbarOuterold2 - sigbarInnerold2); 2400 sigmabar2 = sigmabarOuter2; 2401 } 2402 1992 2403 MPedPhotPix &ppix = (*fPed)[j]; 2404 2405 if ( fBlindPix != NULL && fBlindPix->IsBlind(j) ) 2406 { 2407 // this should never occur, because blind pixels should have 2408 // been set unused by MBlindPixelsCalc2::UnMap() 2409 //*fLog << all << "MPad::Process; blind pixel found which is used, j = " 2410 // << j << "... go to next pixel." << endl; 2411 continue; 2412 } 2413 2414 // count number of pixels treated 2415 fWarnings[0]++; 2416 2417 1993 2418 Double_t oldsigma_phot = ppix.GetRms(); 1994 2419 Double_t oldsigma = oldsigma_phot * fPEperPhoton; 1995 Double_t oldsigma2 = oldsigma*oldsigma ;2420 Double_t oldsigma2 = oldsigma*oldsigma / ratioArea; 1996 2421 1997 2422 //--------------------------------- … … 2005 2430 TH1D *hdiff; 2006 2431 2007 // throw the Sigma for this pixel from the distribution fHDiffPixTheta 2008 // MC : from fHDiffPixTheta 2009 // ON : from fHDiffPixThetaOFF 2010 // OFF : from fHDiffPixThetaON 2011 2012 TH3D *sp = NULL; 2013 2014 if (fType == "MC") sp = fHDiffPixTheta; 2015 else if (fType == "ON") sp = fHDiffPixThetaOFF; 2016 else if (fType == "OFF") sp = fHDiffPixThetaON; 2017 else 2018 { 2019 *fLog << err << "MPad::Process(); illegal data type... aborting" 2020 << endl; 2021 return kERROR; 2022 } 2023 2024 hdiff = sp->ProjectionZ("", binTheta, binTheta, 2025 binPixel, binPixel, ""); 2026 2027 if ( hdiff->GetEntries() == 0 ) 2028 { 2029 *fLog << warn << "MPad::Process(); projection for Theta bin " 2030 << binTheta << " and pixel bin " << binPixel 2031 << " has no entries; aborting " << endl; 2032 delete hdiff; 2033 2034 rc = 5; 2035 fErrors[rc]++; 2036 return kCONTINUE; 2037 } 2038 2039 count = 0; 2040 ok = kFALSE; 2041 for (Int_t m=0; m<fIter; m++) 2042 { 2043 count += 1; 2044 diff_phot = hdiff->GetRandom(); 2045 diff = diff_phot * fPEperPhoton * fPEperPhoton; 2432 2433 hdiff = sp->ProjectionZ("", binTheta, binTheta, 2434 binPixel, binPixel, ""); 2435 Double_t integral = hdiff->Integral(); 2436 // if there are no entries in hdiff, diff cannot be thrown 2437 // in this case diff will be set to zero 2438 if ( integral == 0 ) 2439 { 2440 //*fLog << warn << "MPad::Process(); fType = " << fType 2441 // << ", projection of '" 2442 // << sp->GetName() << "' for Theta bin " 2443 // << binTheta << " and pixel " << j 2444 // << " has no entries; set diff equal to the old difference " 2445 // << endl; 2446 2447 diff = TMath::Max(oldsigma2 - sigbarold2, 2448 lambdabar*F2excess + oldsigma2 - sigmabar2); 2449 2450 rc = 2; 2451 fWarnings[rc]++; 2452 } 2453 2454 // start of else ------------------- 2455 else 2456 { 2457 count = 0; 2458 ok = kFALSE; 2459 for (Int_t m=0; m<fIter; m++) 2460 { 2461 count += 1; 2462 diff_phot = hdiff->GetRandom(); 2463 2464 //*fLog << "after GetRandom : j, m, diff_phot = " << j << " : " 2465 // << m << ", " << diff_phot << endl; 2466 2467 diff = diff_phot * fPEperPhoton * fPEperPhoton; 2046 2468 2047 // the following condition ensures that elNoise2Pix > 0.0 2048 if ( (diff + sigmabar2 - oldsigma2/ratioArea 2049 - lambdabar*F2excess) > 0.0 ) 2050 { 2051 ok = kTRUE; 2052 break; 2053 } 2054 } 2055 2056 if (!ok) 2057 { 2058 *fLog << all << "theta, j, count, sigmabar, diff = " << theta 2059 << ", " 2060 << j << ", " << count << ", " << sigmabar << ", " 2061 << diff << endl; 2062 diff = lambdabar*F2excess + oldsigma2/ratioArea - sigmabar2; 2063 2064 rw = 1; 2065 fWarnings[rw]++; 2066 } 2067 else 2068 { 2069 rw = 0; 2070 fWarnings[rw]++; 2071 } 2469 // the following condition ensures that elNoise2Pix > 0.0 2470 if ( (diff + sigmabar2 - oldsigma2 2471 - lambdabar*F2excess) > 0.0 ) 2472 { 2473 ok = kTRUE; 2474 break; 2475 } 2476 } 2477 2478 if (!ok) 2479 { 2480 //*fLog << all << "theta, j, count, sigmabar2, diff, oldsigma2, ratioArea, lambdabar = " 2481 // << theta << ", " 2482 // << j << ", " << count << ", " << sigmabar2 << ", " 2483 // << diff << ", " << oldsigma2 << ", " << ratioArea << ", " 2484 // << lambdabar << endl; 2485 diff = lambdabar*F2excess + oldsigma2 - sigmabar2; 2486 2487 rw = 1; 2488 fWarnings[rw]++; 2489 } 2490 } 2491 // end of else -------------------- 2072 2492 2073 2493 delete hdiff; … … 2078 2498 // get the additional sigma^2 for this pixel (due to the padding) 2079 2499 2080 addSig2 = sigma2*ratioArea - oldsigma2;2500 addSig2 = (sigma2 - oldsigma2) * ratioArea; 2081 2501 addSig2_phot = addSig2 / (fPEperPhoton * fPEperPhoton); 2082 2502 … … 2139 2559 2140 2560 2141 Double_t newsigma = sqrt( oldsigma2 + addSig2);2561 Double_t newsigma = sqrt( sigma2 * ratioArea ); 2142 2562 Double_t newsigma_phot = newsigma / fPEperPhoton; 2143 2563 ppix.SetRms( newsigma_phot ); … … 2150 2570 2151 2571 fSigmabar->Calc(*fCam, *fPed, *fEvt); 2152 *fLog << all << "MPad::Process(); after padding : " << endl;2153 fSigmabar->Print("");2154 2155 *fLog << all << "Exit MPad::Process();" << endl;2572 //*fLog << all << "MPad::Process(); after padding : " << endl; 2573 //fSigmabar->Print(""); 2574 2575 //*fLog << all << "Exit MPad::Process();" << endl; 2156 2576 2157 2577 rc = 0; … … 2173 2593 *fLog << dec << setfill(' '); 2174 2594 2175 int temp; 2176 if (fWarnings[0] != 0.0) 2177 temp = (int)(fWarnings[1]*100/fWarnings[0]); 2178 else 2179 temp = 100; 2595 if (fWarnings[0] == 0 ) fWarnings[0] = 1; 2180 2596 2181 2597 *fLog << " " << setw(7) << fWarnings[1] << " (" << setw(3) 2182 << temp2183 << "%) Warning: iteration to find acceptable sigma failed"2598 << (int)(fWarnings[1]*100/fWarnings[0]) 2599 << "%) Pixel: iteration to find acceptable sigma failed" 2184 2600 << ", fIter = " << fIter << endl; 2185 2601 2186 *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3) 2187 << (int)(fErrors[1]*100/GetNumExecutions()) 2188 << "%) Evts skipped due to: Sigmabar_old > 0" << endl; 2602 *fLog << " " << setw(7) << fWarnings[2] << " (" << setw(3) 2603 << (int)(fWarnings[2]*100/fWarnings[0]) 2604 << "%) Pixel: No data for generating Sigma^2-Sigmabar^2" << endl; 2605 2189 2606 2190 2607 *fLog << " " << setw(7) << fErrors[2] << " (" << setw(3) … … 2192 2609 << "%) Evts skipped due to: Zenith angle out of range" << endl; 2193 2610 2194 *fLog << " " << setw(7) << fErrors[3] << " (" << setw(3)2195 << (int)(fErrors[3]*100/GetNumExecutions())2196 << "%) Evts skipped due to: No data for generating Sigmabar" << endl;2197 2198 2611 *fLog << " " << setw(7) << fErrors[4] << " (" << setw(3) 2199 2612 << (int)(fErrors[4]*100/GetNumExecutions()) 2200 2613 << "%) Evts skipped due to: Target sigma <= Sigmabar_old" << endl; 2201 2202 *fLog << " " << setw(7) << fErrors[5] << " (" << setw(3)2203 << (int)(fErrors[5]*100/GetNumExecutions())2204 << "%) Evts skipped due to: No data for generating Sigma^2-Sigmabar^2" << endl;2205 2206 *fLog << " " << setw(7) << fErrors[6] << " (" << setw(3)2207 << (int)(fErrors[6]*100/GetNumExecutions())2208 << "%) Evts skipped due to: No data for generating Sigma" << endl;2209 2614 2210 2615 *fLog << " " << setw(7) << fErrors[7] << " (" << setw(3) … … 2224 2629 2225 2630 //--------------------------------------------------------------- 2226 TCanvas &c = *(MH::MakeDefCanvas("Pad", "", 900, 1500));2227 c.Divide(3, 5);2631 TCanvas &c = *(MH::MakeDefCanvas("Pad", "", 900, 600)); 2632 c.Divide(3, 2); 2228 2633 gROOT->SetSelectedPad(NULL); 2229 2634 … … 2245 2650 //-------------------------------------------------------------------- 2246 2651 2247 2652 /* 2248 2653 c.cd(4); 2249 2654 fHSigmaTheta->SetDirectory(NULL); … … 2251 2656 fHSigmaTheta->DrawCopy(); 2252 2657 fHSigmaTheta->SetBit(kCanDelete); 2253 2658 */ 2254 2659 2255 2660 //-------------------------------------------------------------------- 2256 2661 2257 2662 /* 2258 2663 c.cd(7); 2259 2664 fHBlindPixNTheta->SetDirectory(NULL); … … 2261 2666 fHBlindPixNTheta->DrawCopy(); 2262 2667 fHBlindPixNTheta->SetBit(kCanDelete); 2668 */ 2263 2669 2264 2670 //-------------------------------------------------------------------- 2265 2671 2266 2672 /* 2267 2673 c.cd(10); 2268 2674 fHBlindPixIdTheta->SetDirectory(NULL); … … 2270 2676 fHBlindPixIdTheta->DrawCopy(); 2271 2677 fHBlindPixIdTheta->SetBit(kCanDelete); 2272 2678 */ 2273 2679 2274 2680 //-------------------------------------------------------------------- 2275 2681 // draw the 3D histogram (target): Theta, pixel, Sigma^2-Sigmabar^2 2276 2682 2683 /* 2277 2684 c.cd(5); 2278 2685 TH2D *l1 = NULL; … … 2296 2703 l2->DrawCopy("box"); 2297 2704 l2->SetBit(kCanDelete);; 2705 */ 2298 2706 2299 2707 //-------------------------------------------------------------------- 2300 2708 // draw the 3D histogram (target): Theta, pixel, Sigma 2301 2709 2710 /* 2302 2711 c.cd(6); 2303 2712 TH2D *k1 = NULL; … … 2321 2730 k2->DrawCopy("box"); 2322 2731 k2->SetBit(kCanDelete);; 2323 2732 */ 2324 2733 2325 2734 //-------------------------------------------------------------------- 2326 2735 2327 c.cd(13); 2736 2737 c.cd(4); 2328 2738 TH2D *m1; 2329 2739 m1 = (TH2D*) ((TH3*)fHgON)->Project3D("zy"); 2330 2740 m1->SetDirectory(NULL); 2331 m1->SetTitle("( Target) Sigmabar-new vs. Sigmabar-old (ON, all \\Theta)");2741 m1->SetTitle("(fHgON) Sigmabar-new vs. Sigmabar-old (ON, all \\Theta)"); 2332 2742 m1->SetXTitle("Sigmabar-old"); 2333 2743 m1->SetYTitle("Sigmabar-new"); … … 2336 2746 m1->SetBit(kCanDelete);; 2337 2747 2338 c.cd( 14);2748 c.cd(5); 2339 2749 TH2D *m2; 2340 2750 m2 = (TH2D*) ((TH3*)fHgOFF)->Project3D("zy"); 2341 2751 m2->SetDirectory(NULL); 2342 m2->SetTitle("( Target) Sigmabar-new vs. Sigmabar-old (OFF, all \\Theta)");2752 m2->SetTitle("(fHgOFF) Sigmabar-new vs. Sigmabar-old (OFF, all \\Theta)"); 2343 2753 m2->SetXTitle("Sigmabar-old"); 2344 2754 m2->SetYTitle("Sigmabar-new"); … … 2347 2757 m2->SetBit(kCanDelete);; 2348 2758 2349 c.cd( 15);2759 c.cd(6); 2350 2760 TH2D *m3; 2351 2761 m3 = (TH2D*) ((TH3*)fHgMC)->Project3D("zy"); 2352 2762 m3->SetDirectory(NULL); 2353 m3->SetTitle("( Target) Sigmabar-new vs. Sigmabar-old (MC, all \\Theta)");2763 m3->SetTitle("(fHgMC) Sigmabar-new vs. Sigmabar-old (MC, all \\Theta)"); 2354 2764 m3->SetXTitle("Sigmabar-old"); 2355 2765 m3->SetYTitle("Sigmabar-new"); … … 2369 2779 2370 2780 2781 2782 2783 2784 -
trunk/MagicSoft/Mars/manalysis/MPad.h
r2798 r4584 17 17 class MCerPhotEvt; 18 18 class MPedPhotCam; 19 class M McEvt;19 class MPointingPos; 20 20 class MSigmabar; 21 21 class MParList; … … 31 31 MCerPhotEvt *fEvt; 32 32 MSigmabar *fSigmabar; 33 M McEvt *fMcEvt;33 MPointingPos *fPointPos; 34 34 MPedPhotCam *fPed; 35 MBlindPixels *fBlind s;35 MBlindPixels *fBlindPix; 36 36 37 37 TString fType; // type of data to be padded … … 41 41 42 42 Int_t fErrors[9]; 43 Int_t fWarnings[ 2];43 Int_t fWarnings[3]; 44 44 45 45 //---------------------------------- … … 89 89 90 90 91 Bool_t Merge2Distributions(TH1D *hista, TH1D * histb, TH1D *histap,92 TH2D *fHga, TH2D * fHgb,Int_t nbinssig);91 Bool_t Merge2Distributions(TH1D *hista, TH1D *histb, TH1D *histap, 92 TH2D *fHga, TH2D *fHgb, Int_t nbinssig); 93 93 94 Bool_t UpdateHg(TH2D *fHga, TH1D *histap, TH2D *fHge, TH3D *fHgA, 95 Int_t nbinssig, Int_t l); 94 96 95 97 public: … … 98 100 99 101 Bool_t MergeONOFFMC( 100 TH2D *sigthmc, TH3D *diffpixthmc, TH3D *sigmapixthmc,101 TH2D *blindidthmc, TH2D *blindnthmc,102 TH2D *sigthon, TH3D *diffpixthon, TH3D *sigmapixthon,103 TH2D *blindidthon, TH2D *blindnthon,104 TH2D *sigthoff=NULL, TH3D *diffpixthoff=NULL,TH3D *sigmapixthoff=NULL,105 TH2D *blindidthoff=NULL, TH2D *blindnthoff=NULL);102 TH2D& sigthmc, TH3D& diffpixthmc, TH3D& sigmapixthmc, 103 TH2D& blindidthmc, TH2D& blindnthmc, 104 TH2D& sigthon, TH3D& diffpixthon, TH3D& sigmapixthon, 105 TH2D& blindidthon, TH2D& blindnthon, 106 TH2D& sigthoff, TH3D& diffpixthoff,TH3D& sigmapixthoff, 107 TH2D& blindidthoff, TH2D& blindnthoff); 106 108 107 109 Bool_t MergeONMC( 108 TH2D *sigthmc, TH3D *diffpixthmc, TH3D *sigmapixthmc,109 TH2D *blindidthmc, TH2D *blindnthmc,110 TH2D *sigthon, TH3D *diffpixthon, TH3D *sigmapixthon,111 TH2D *blindidthon, TH2D *blindnthon);110 TH2D& sigthmc, TH3D& diffpixthmc, TH3D& sigmapixthmc, 111 TH2D& blindidthmc, TH2D& blindnthmc, 112 TH2D& sigthon, TH3D&diffpixthon, TH3D& sigmapixthon, 113 TH2D& blindidthon, TH2D& blindnthon); 112 114 113 115 Bool_t ReadPaddingDist(const char *filein); -
trunk/MagicSoft/Mars/manalysis/MSigmabar.cc
r3530 r4584 30 30 // // 31 31 // This is the storage container to hold information about // 32 // "average" pedestal sigmas // 33 // // 34 // In calculating averages all sigmas are normalized to the area of pixel 0// 32 // "average" pedestal RMS // 33 // // 34 // The "average" pedestal RMS is calculated as // 35 // <pedRMS> = sqrt( sum_i( (pedRMS_i)^2/area_i ) / no.of pixels ) // 36 // // 37 // which is the sqrt of the average (pedRMS^2 per area) // 35 38 // // 36 39 ///////////////////////////////////////////////////////////////////////////// … … 109 112 110 113 // 111 // sum up sigma /sqrt(area)for each sector,114 // sum up sigma^2/area for each sector, 112 115 // separately for inner and outer region; 113 116 // … … 147 150 const Double_t ratio = geom.GetPixRatio(idx); 148 151 152 //*fLog << "pixel id, ratio = " << idx << ", " << ratio << endl; 153 149 154 const MGeomPix &gpix = geom[idx]; 150 155 … … 171 176 { 172 177 innerPixels[sector]++; 173 innerSum[sector]+= sigma * sqrt(ratio);178 innerSum[sector]+= sigma*sigma * ratio; 174 179 } 175 180 else 176 181 { 177 182 outerPixels[sector]++; 178 outerSum[sector]+= sigma * sqrt(ratio);183 outerSum[sector]+= sigma*sigma * ratio; 179 184 } 180 185 } … … 192 197 } 193 198 194 if (fInnerPixels > 0) fSigmabarInner = fSumInner / fInnerPixels;195 if (fOuterPixels > 0) fSigmabarOuter = fSumOuter / fOuterPixels;196 197 // 198 // this is the average sigma/sqrt(area) (over all pixels)199 if (fInnerPixels > 0) fSigmabarInner = sqrt(fSumInner / fInnerPixels); 200 if (fOuterPixels > 0) fSigmabarOuter = sqrt(fSumOuter / fOuterPixels); 201 202 // 203 // this is the sqrt of the average sigma^2/area 199 204 // 200 205 fSigmabar = (fInnerPixels+fOuterPixels)<=0 ? 0: 201 (fSumInner+fSumOuter)/(fInnerPixels+fOuterPixels);206 sqrt( (fSumInner+fSumOuter)/(fInnerPixels+fOuterPixels) ); 202 207 203 208 for (UInt_t i=0; i<6; i++) … … 209 214 210 215 const Double_t sum = ip + op; 211 fSigmabarInnerSector[i] = ip <=0 ? 0 : iss/ip;212 fSigmabarOuterSector[i] = op <=0 ? 0 : oss/op;213 fSigmabarSector[i] = sum<=0 ? 0 : (iss+oss)/sum;216 fSigmabarInnerSector[i] = ip <=0 ? 0 : sqrt(iss/ip); 217 fSigmabarOuterSector[i] = op <=0 ? 0 : sqrt(oss/op); 218 fSigmabarSector[i] = sum<=0 ? 0 : sqrt((iss+oss)/sum); 214 219 } 215 220 … … 217 222 //Print(opt); 218 223 219 return fSigmabar ;224 return fSigmabarInner; 220 225 } 221 226 -
trunk/MagicSoft/Mars/manalysis/MSigmabar.h
r2798 r4584 14 14 { 15 15 private: 16 Float_t fSigmabar; // Sigmabar ( "average" RMS) of pedestal16 Float_t fSigmabar; // Sigmabar ( sqrt(average pedestalRMS^2) ) 17 17 Float_t fSigmabarInner; // --only for inner pixels 18 18 Float_t fSigmabarOuter; // --only for outer pixels -
trunk/MagicSoft/Mars/manalysis/MSigmabarCalc.cc
r2798 r4584 37 37 // MPedPhotCam 38 38 // MRawRunHeader 39 // M McEvt (FIXME: Must be replaced by a 'real-data' container)39 // MPointingPos 40 40 // MCerPhotEvt 41 41 // … … 58 58 #include "MSigmabarParam.h" 59 59 60 #include "M McEvt.hxx"60 #include "MPointingPos.h" 61 61 62 62 ClassImp(MSigmabarCalc); … … 105 105 106 106 // This is needed for determining min/max Theta 107 f McEvt = (MMcEvt*)pList->FindObject(AddSerialNumber("MMcEvt"));108 if (!f McEvt)107 fPointPos = (MPointingPos*)pList->FindObject(AddSerialNumber("MPointingPos")); 108 if (!fPointPos) 109 109 { 110 *fLog << warn << "M McEvtnot found... aborting." << endl;110 *fLog << warn << "MPointingPos not found... aborting." << endl; 111 111 fThetaMin = 0; 112 112 fThetaMax = 90; … … 148 148 if (rc<fSigmabarMin) fSigmabarMin=rc; 149 149 150 if (!f McEvt)150 if (!fPointPos) 151 151 return kTRUE; 152 152 153 const Double_t theta = f McEvt->GetTelescopeTheta()*kRad2Deg;153 const Double_t theta = fPointPos->GetZd(); 154 154 155 if (theta>f SigmabarMax) fSigmabarMax=theta;156 if (theta<f SigmabarMax) fSigmabarMin=theta;155 if (theta>fThetaMax) fThetaMax=theta; 156 if (theta<fThetaMin) fThetaMin=theta; 157 157 158 158 return kTRUE; … … 176 176 void MSigmabarCalc::Reset() 177 177 { 178 if (!f McEvt)178 if (!fPointPos) 179 179 return; 180 180 -
trunk/MagicSoft/Mars/manalysis/MSigmabarCalc.h
r2798 r4584 10 10 #endif 11 11 12 #ifndef MARS_M McEvt13 #include "M McEvt.hxx"12 #ifndef MARS_MPointingPos 13 #include "MPointingPos.h" 14 14 #endif 15 15 … … 33 33 { 34 34 private: 35 M McEvt *fMcEvt;35 MPointingPos *fPointPos; 36 36 MCerPhotEvt *fEvt; 37 37 MGeomCam *fCam;
Note:
See TracChangeset
for help on using the changeset viewer.