Changeset 4584 for trunk/MagicSoft/Mars
- Timestamp:
- 08/12/04 06:58:34 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r4581 r4584 19 19 20 20 -*-*- END OF LINE -*-*- 21 22 23 24 2004/08/12 : Wolfgang Wittek 25 26 * manalysis/MSigmabarCalc.[h,cc] 27 - replace MMcEvt by MPointingPos 28 29 * manalysis/MSigmabar.[h,cc] 30 - in member function Calc() return fSigmabarInner, 31 not fSigmabar 32 - update comments 33 - sigmabar is the sqrt of the average (pedRMS^2/area) 34 35 * manalysis/MPad.[h,cc] 36 - replace MMcEvt by MPointingPos 37 - remove bugs 38 39 * mfilter/MFSelBasic.[h,cc] 40 - replace MMcEvt by MPointingPos 41 42 * mfilter/Makefile 43 - add -I../mpointing 44 45 46 * mhist/MHSigmaTheta.[h,cc] 47 - replace MMcEvt by MPointingPos 48 - replace 'MCerPhotPix cerpix' by 'MCerPhotPix &cerpix' 49 - add plot "Sigmabar(Outer) versus Theta" 50 51 * macros/ONOFFAnalysis.C 52 - Job A : got the padding working, work in progress 21 53 22 54 -
trunk/MagicSoft/Mars/macros/ONOFFAnalysis.C
r3598 r4584 171 171 //----------------------------------------------- 172 172 //TString tag = "040126"; 173 TString tag = "040127";174 //TString tag = "040215";173 //TString tag = "040127"; 174 TString tag = "040215"; 175 175 176 176 //const char *offfile = "~magican/ct1test/wittek/offdata.preproc"; … … 183 183 //const char *offfile = "*.OFF"; 184 184 // 15 Feb 04 185 const char *offfile = "*.OFF"; 185 //const char *offfile = "*.OFF"; 186 const char *offfile = "174*.OFF"; 186 187 187 188 … … 191 192 //const char *onfile = "MCerPhot_output"; 192 193 //const char *onfile = "*.ON"; 193 const char *onfile = "1216*.ON";194 //const char *onfile = "1216*.ON"; 194 195 // 27 Jan 04 195 196 //const char *onfile = "12*.ON"; … … 198 199 // 15 Feb 04 199 200 //const char *onfile = "*.ON"; 200 201 202 const char *mcfile = "/data/MAGIC/mc_eth/magLQE_3/gh/0/0/G_M0_00_0_550*.root"; 201 const char *onfile = "174*.ON"; 202 203 204 //const char *mcfile = "/data/MAGIC/mc_eth/magLQE_3/gh/0/0/G_M0_00_0_550*.root"; 203 205 //const char *mcfile = "/data/MAGIC/mc_eth/magLQE_4/gh/0/0/G_M0_00_0_550*.root"; 204 206 //const char *mcfile = "/data/MAGIC/mc_eth/magLQE_5/gh/0/0/G_M0_00_0_550*.root"; 207 //const char *mcfile = "calibrated_gammas"; 208 const char *mcfile = "calibrated_data_david*"; 209 205 210 //----------------------------------------------- 206 211 … … 224 229 225 230 // 15 Feb 04, David 226 if (tag == "040215") 227 TString inPath = "/mnt/magicserv01/scratch/David/CalibratedData/Crab/2004_02_15/"; 228 231 //if (tag == "040215") 232 // TString inPath = "/mnt/magicserv01/scratch/David/CalibratedData/Crab/2004_02_15/"; 233 if (tag == "040215") 234 TString inPathON = "/.magic/magicserv01/scratch/Daniel/CalibratedData/MispointingTest/2004_02_15ForgottenData/finesam20/"; 235 TString inPathOFF = "/.magic/magicserv01/scratch/David/CalibratedData/Mkn421/2004_02_15/"; 236 TString inPathMC = "/.magic/magicserv01/scratch/David/MCData/MCApril2004/Data/gammas_highnoise/"; 229 237 230 238 // path for output from Mars 231 239 //TString outPath = "~wittek/datacrab_feb04/"; 232 240 //TString outPath = "~wittek/datacrab_01march04/"; 233 TString outPath = "~wittek/datacrab_ 19mar04/";241 TString outPath = "~wittek/datacrab_27april04/"; 234 242 235 243 //----------------------------------------------- … … 248 256 249 257 Bool_t JobA = kTRUE; 250 Bool_t GPad = kFALSE; // generate padding histograms? 251 Bool_t WPad = kFALSE; // write out padding histograms ? 252 Bool_t RPad = kFALSE; // read in padding histograms ? 253 Bool_t Wout = kTRUE; // write out root file ON1.root 254 // (or OFF1.root or MC1.root)? 258 Bool_t GPadON = kFALSE; // \ generate padding histograms 259 Bool_t GPadOFF = kFALSE; // | and write them onto disk 260 Bool_t GPadMC = kFALSE; // / 261 Bool_t Merge = kFALSE; // merge padding histograms 262 // and write them onto disk 263 Bool_t Wout = kTRUE; // read in merged padding histograms and 264 // write out root file of padded data 265 // (ON1.root, OFF1.root or MC1.root) 255 266 256 267 … … 310 321 // Job E_XX : extended version of E_XX (including flux plots) 311 322 // - select g/h separation method XX 312 // - read MC root file 313 323 // - read MC root file 324 // - calculate eff. collection area 314 325 // - optimize energy estimator 315 326 // - read ON root file … … 346 357 gLog << "Macro ONOFFAnalysis : Start of Job A" << endl; 347 358 gLog << "" << endl; 348 gLog << "Macro ONOFFAnalysis : JobA, WPad, RPad, Wout = " 349 << (JobA ? "kTRUE" : "kFALSE") << ", " 350 << (WPad ? "kTRUE" : "kFALSE") << ", " 351 << (RPad ? "kTRUE" : "kFALSE") << ", " 352 << (Wout ? "kTRUE" : "kFALSE") << endl; 359 gLog << "Macro ONOFFAnalysis : JobA, GPadON, GPadOFF, GPadMC, Merge, Wout = " 360 << (JobA ? "kTRUE" : "kFALSE") << ", " 361 << (GPadON ? "kTRUE" : "kFALSE") << ", " 362 << (GPadOFF ? "kTRUE" : "kFALSE") << ", " 363 << (GPadMC ? "kTRUE" : "kFALSE") << ", " 364 << (Merge ? "kTRUE" : "kFALSE") << ", " 365 << (Wout ? "kTRUE" : "kFALSE") << endl; 353 366 354 367 … … 358 371 359 372 360 TString fileON = inPath ;373 TString fileON = inPathON; 361 374 fileON += onfile; 362 375 fileON += ".root"; 363 376 364 TString fileOFF = inPath ;377 TString fileOFF = inPathOFF; 365 378 fileOFF += offfile; 366 379 fileOFF += ".root"; 367 380 368 TString fileMC = mcfile;381 TString fileMC = inPathMC; 369 382 fileMC += mcfile; 370 383 fileMC += ".root"; … … 373 386 << fileOFF << ", " << fileMC << endl; 374 387 375 // name of file to conatin the histograms for the padding388 // name of file to conatin the merged histograms for the padding 376 389 TString outNameSigTh = outPath; 377 390 outNameSigTh += "SigmaTheta"; … … 379 392 380 393 //-------------------------------------------------- 394 // name of files to contain the paddding histograms of ON, OFF and MC data 395 TString NamePadON(outPath); 396 NamePadON += "PadON"; 397 NamePadON += ".root"; 398 399 TString NamePadOFF(outPath); 400 NamePadOFF += "PadOFF"; 401 NamePadOFF += ".root"; 402 403 TString NamePadMC(outPath); 404 NamePadMC += "PadMC"; 405 NamePadMC += ".root"; 406 407 //-------------------------------------------------- 381 408 // type of data to be padded 382 TString typeInput = "ON";383 //TString typeInput = "OFF";384 //TString typeInput = "MC";409 //TString typeInput = "ON"; 410 //TString typeInput = "OFF"; 411 TString typeInput = "MC"; 385 412 gLog << "typeInput = " << typeInput << endl; 386 413 … … 416 443 // 417 444 // read ON, OFF and MC data files 418 // generate (or read in) the padding histograms for ON and OFFdata419 // and merge these histograms445 // generate (or read in) the padding histograms for ON, OFF and MC data 446 // 420 447 421 448 MPad pad; … … 423 450 pad.SetDataType(typeInput); 424 451 452 if (GPadON || GPadOFF || GPadMC) 453 { 425 454 // generate the padding histograms 426 if (GPad)427 {428 455 gLog << "=====================================================" << endl; 429 456 gLog << "Start generating the padding histograms" << endl; 457 } 458 430 459 //----------------------------------------- 431 460 // ON events 461 462 if (GPadON) 463 { 432 464 433 465 gLog << "-----------" << endl; … … 438 470 MParList pliston; 439 471 472 MObservatory observon; 473 440 474 MReadMarsFile readON("Events", fileON); 441 475 readON.DisableAutoScheme(); 442 //MCT1ReadPreProc readON(fileON); 443 444 //MFSelBasic selthetaon; 445 //selthetaon.SetCuts(-100.0, 29.5, 35.5); 446 //MContinue contthetaon(&selthetaon); 447 448 MBlindPixelCalc blindon; 449 blindon.SetUseBlindPixels(); 476 477 MGeomApply apply; 478 479 MSourcePosfromStarPos sourcefromstaron; 480 sourcefromstaron.AddFile("~wittek/datacrab_26feb04/positions040215.txt", 0); 481 482 MBlindPixelsCalc2 blindon; 483 //blindon.SetUseBlindPixels(); 484 blindon.SetCheckPedestalRms(); 450 485 451 486 MFSelBasic selbasicon; … … 459 494 460 495 MHSigmaTheta sigthON("SigmaThetaON"); 461 MFillH fillsigthetaON ("SigmaThetaON[MHSigmaTheta]", "M McEvt");496 MFillH fillsigthetaON ("SigmaThetaON[MHSigmaTheta]", "MPointingPos"); 462 497 fillsigthetaON.SetName("FillSigTheta"); 463 498 … … 467 502 pliston.AddToList(&tliston); 468 503 InitBinnings(&pliston); 504 pliston.AddToList(&observon); 469 505 pliston.AddToList(&blindON); 470 506 pliston.AddToList(&sigthON); … … 475 511 476 512 tliston.AddToList(&readON); 477 //tliston.AddToList(&contthetaon); 513 tliston.AddToList(&apply); 514 tliston.AddToList(&sourcefromstaron); 478 515 479 516 tliston.AddToList(&blindon); … … 489 526 evtloopon.SetProgressBar(&baron); 490 527 491 Int_t maxeventson = -1;492 //Int_t maxeventson = 10000;528 //Int_t maxeventson = -1; 529 Int_t maxeventson = 10000; 493 530 if ( !evtloopon.Eventloop(maxeventson) ) 494 531 return; … … 507 544 TH2D *blindnthon = blindON.GetBlindN(); 508 545 546 gLog << "" << endl; 547 gLog << "Macro ONOFFAnalysis : write padding plots for ON data from file " 548 << NamePadON << endl; 549 550 TFile filewriteon(NamePadON, "RECREATE", ""); 551 sigthon->Write(); 552 sigpixthon->Write(); 553 diffpixthon->Write(); 554 blindidthon->Write(); 555 blindnthon->Write(); 556 filewriteon.Close(); 557 558 gLog << "" << endl; 559 gLog << "Macro ONOFFAnalysis : padding plots for ON data written onto file " 560 << NamePadON << endl; 561 } 562 // end of GPadON 563 564 509 565 //----------------------------------------- 510 566 // OFF events 567 568 if (GPadOFF) 569 { 511 570 512 571 gLog << "------------" << endl; … … 517 576 MParList plistoff; 518 577 578 MObservatory observoff; 579 519 580 MReadMarsFile readOFF("Events", fileOFF); 520 581 readOFF.DisableAutoScheme(); 521 // MCT1ReadPreProc readOFF(fileOFF); 522 523 MFSelBasic selthetaoff; 524 selthetaoff.SetCuts(-100.0, 29.5, 35.5); 525 MContinue contthetaoff(&selthetaoff); 526 527 MBlindPixelCalc blindoff; 528 blindoff.SetUseBlindPixels(); 582 583 MSourcePosfromStarPos sourcefromstaroff; 584 sourcefromstaroff.AddFile("~wittek/datacrab_26feb04/positions040215.txt", 0); 585 586 MBlindPixelsCalc2 blindoff; 587 //blindoff.SetUseBlindPixels(); 588 blindoff.SetCheckPedestalRms(); 529 589 530 590 MFSelBasic selbasicoff; … … 538 598 539 599 MHSigmaTheta sigthOFF("SigmaThetaOFF"); 540 MFillH fillsigthetaOFF ("SigmaThetaOFF[MHSigmaTheta]", "M McEvt");600 MFillH fillsigthetaOFF ("SigmaThetaOFF[MHSigmaTheta]", "MPointingPos"); 541 601 fillsigthetaOFF.SetName("FillSigThetaOFF"); 542 602 … … 546 606 plistoff.AddToList(&tlistoff); 547 607 InitBinnings(&plistoff); 608 plistoff.AddToList(&observoff); 548 609 plistoff.AddToList(&blindOFF); 549 610 plistoff.AddToList(&sigthOFF); … … 554 615 555 616 tlistoff.AddToList(&readOFF); 556 //tlistoff.AddToList(&contthetaoff);617 tlistoff.AddToList(&sourcefromstaroff); 557 618 558 619 tlistoff.AddToList(&blindoff); … … 568 629 evtloopoff.SetProgressBar(&baroff); 569 630 570 Int_t maxeventsoff = -1;571 //Int_t maxeventsoff = 20000;631 //Int_t maxeventsoff = -1; 632 Int_t maxeventsoff = 10000; 572 633 if ( !evtloopoff.Eventloop(maxeventsoff) ) 573 634 return; … … 586 647 TH2D *blindnthoff = blindOFF.GetBlindN(); 587 648 649 gLog << "" << endl; 650 gLog << "Macro ONOFFAnalysis : write padding plots for OFF data from file " 651 << NamePadOFF << endl; 652 653 TFile filewriteoff(NamePadOFF, "RECREATE", ""); 654 sigthoff->Write(); 655 sigpixthoff->Write(); 656 diffpixthoff->Write(); 657 blindidthoff->Write(); 658 blindnthoff->Write(); 659 filewriteoff.Close(); 660 661 gLog << "" << endl; 662 gLog << "Macro ONOFFAnalysis : padding plots for OFF data written onto file " 663 << NamePadOFF << endl; 664 } 665 // end of GPadOFF 666 667 588 668 589 669 //----------------------------------------- 590 670 // MC events 671 672 if (GPadMC) 673 { 591 674 592 675 gLog << "------------" << endl; … … 597 680 MParList plistmc; 598 681 682 MObservatory observmc; 683 599 684 MReadMarsFile readMC("Events", fileMC); 600 685 readMC.DisableAutoScheme(); 601 // MCT1ReadPreProc readMC(fileMC); 602 603 MFSelBasic selthetamc; 604 selthetamc.SetCuts(-100.0, 29.5, 35.5); 605 MContinue contthetamc(&selthetamc); 606 607 MBlindPixelCalc blindmc; 608 blindmc.SetUseBlindPixels(); 686 687 MSourcePosfromStarPos sourcefromstarmc; 688 689 MBlindPixelsCalc2 blindmc; 690 //blindmc.SetUseBlindPixels(); 691 blindmc.SetCheckPedestalRms(); 609 692 610 693 MFSelBasic selbasicmc; … … 618 701 619 702 MHSigmaTheta sigthMC("SigmaThetaMC"); 620 MFillH fillsigthetaMC ("SigmaThetaMC[MHSigmaTheta]", "M McEvt");703 MFillH fillsigthetaMC ("SigmaThetaMC[MHSigmaTheta]", "MPointingPos"); 621 704 fillsigthetaMC.SetName("FillSigThetaMC"); 622 705 … … 626 709 plistmc.AddToList(&tlistmc); 627 710 InitBinnings(&plistmc); 711 plistmc.AddToList(&observmc); 628 712 plistmc.AddToList(&blindMC); 629 713 plistmc.AddToList(&sigthMC); … … 634 718 635 719 tlistmc.AddToList(&readMC); 636 //tlistmc.AddToList(&contthetamc);720 tlistmc.AddToList(&sourcefromstarmc); 637 721 638 722 tlistmc.AddToList(&blindmc); … … 648 732 evtloopmc.SetProgressBar(&barmc); 649 733 650 Int_t maxeventsmc = -1;651 //Int_t maxeventsmc = 20000;734 //Int_t maxeventsmc = -1; 735 Int_t maxeventsmc = 10000; 652 736 if ( !evtloopmc.Eventloop(maxeventsmc) ) 653 737 return; … … 666 750 TH2D *blindnthmc = blindMC.GetBlindN(); 667 751 752 gLog << "" << endl; 753 gLog << "Macro ONOFFAnalysis : write padding plots for MC data from file " 754 << NamePadMC << endl; 755 756 TFile filewritemc(NamePadMC, "RECREATE", ""); 757 sigthmc->Write(); 758 sigpixthmc->Write(); 759 diffpixthmc->Write(); 760 blindidthmc->Write(); 761 blindnthmc->Write(); 762 filewritemc.Close(); 763 764 gLog << "" << endl; 765 gLog << "Macro ONOFFAnalysis : padding plots for MC data written onto file " 766 << NamePadMC << endl; 767 } 768 // end of GPadMC 668 769 669 770 //----------------------------------------- 670 771 772 if (GPadON || GPadOFF || GPadMC) 773 { 774 gLog << "" << endl; 671 775 gLog << "End of generating the padding histograms" << endl; 672 776 gLog << "=====================================================" << endl; 673 674 pad.MergeONOFFMC(sigthmc, diffpixthmc, sigpixthmc,675 blindidthmc, blindnthmc,676 sigthon, diffpixthon, sigpixthon,677 blindidthon, blindnthon,678 sigthoff, diffpixthoff, sigpixthoff,679 blindidthoff, blindnthoff);680 681 682 if (WPad)683 {684 // write the padding histograms onto a file ---------685 pad.WritePaddingDist(outNameSigTh);686 }687 777 } 688 778 689 // read the padding histograms --------------------------- 690 if (RPad) 779 if (Merge) 691 780 { 692 pad.ReadPaddingDist(outNameSigTh); 781 782 //----------------------------------- 783 TH2D sigon; 784 TH3D sigpixon; 785 TH3D diffpixon; 786 TH2D blindidon; 787 TH2D blindnon; 788 789 TFile filereadon(NamePadON); 790 filereadon.ls(); 791 sigon.Read("2D-ThetaSigmabar(Inner)"); 792 sigpixon.Read("3D-ThetaPixSigma"); 793 diffpixon.Read("3D-ThetaPixDiff"); 794 blindidon.Read("2D-IdBlindPixels"); 795 blindnon.Read("2D-NBlindPixels"); 796 797 TH2D *sigthon = new TH2D( (const TH2D&)sigon ); 798 TH3D *sigpixthon = new TH3D( (const TH3D&)sigpixon ); 799 TH3D *diffpixthon = new TH3D( (const TH3D&)diffpixon ); 800 TH2D *blindidthon = new TH2D( (const TH2D&)blindidon ); 801 TH2D *blindnthon = new TH2D( (const TH2D&)blindnon ); 802 803 /* 804 TH2D *sigthon = (TH2D*)sigon.Clone(); 805 TH3D *sigpixthon = (TH3D*)sigpixon.Clone(); 806 TH3D *diffpixthon = (TH3D*)diffpixon.Clone(); 807 TH2D *blindidthon = (TH2D*)blindidon.Clone(); 808 TH2D *blindnthon = (TH2D*)blindnon.Clone(); 809 */ 810 811 //filereadon.Close(); 812 gLog << "" << endl; 813 gLog << "Macro ONOFFAnalysis : padding plots for ON data read from file " 814 << NamePadON << endl; 815 816 817 //----------------------------------- 818 TH2D sigoff; 819 TH3D sigpixoff; 820 TH3D diffpixoff; 821 TH2D blindidoff; 822 TH2D blindnoff; 823 824 TFile filereadoff(NamePadOFF); 825 filereadoff.ls(); 826 sigoff.Read("2D-ThetaSigmabar(Inner)"); 827 sigpixoff.Read("3D-ThetaPixSigma"); 828 diffpixoff.Read("3D-ThetaPixDiff"); 829 blindidoff.Read("2D-IdBlindPixels"); 830 blindnoff.Read("2D-NBlindPixels"); 831 832 TH2D *sigthoff = new TH2D( (const TH2D&)sigoff ); 833 TH3D *sigpixthoff = new TH3D( (const TH3D&)sigpixoff ); 834 TH3D *diffpixthoff = new TH3D( (const TH3D&)diffpixoff ); 835 TH2D *blindidthoff = new TH2D( (const TH2D&)blindidoff ); 836 TH2D *blindnthoff = new TH2D( (const TH2D&)blindnoff ); 837 838 /* 839 TH2D *sigthoff = (TH2D*)sigoff.Clone(); 840 TH3D *sigpixthoff = (TH3D*)sigpixoff.Clone(); 841 TH3D *diffpixthoff = (TH3D*)diffpixoff.Clone(); 842 TH2D *blindidthoff = (TH2D*)blindidoff.Clone(); 843 TH2D *blindnthoff = (TH2D*)blindnoff.Clone(); 844 */ 845 846 //filereadoff.Close(); 847 gLog << "" << endl; 848 gLog << "Macro ONOFFAnalysis : padding plots for OFF data read from file " 849 << NamePadOFF << endl; 850 851 852 //----------------------------------- 853 TH2D sigmc; 854 TH3D sigpixmc; 855 TH3D diffpixmc; 856 TH2D blindidmc; 857 TH2D blindnmc; 858 859 TFile filereadmc(NamePadMC); 860 filereadmc.ls(); 861 sigmc.Read("2D-ThetaSigmabar(Inner)"); 862 sigpixmc.Read("3D-ThetaPixSigma"); 863 diffpixmc.Read("3D-ThetaPixDiff"); 864 blindidmc.Read("2D-IdBlindPixels"); 865 blindnmc.Read("2D-NBlindPixels"); 866 867 TH2D *sigthmc = new TH2D( (const TH2D&)sigmc ); 868 TH3D *sigpixthmc = new TH3D( (const TH3D&)sigpixmc ); 869 TH3D *diffpixthmc = new TH3D( (const TH3D&)diffpixmc ); 870 TH2D *blindidthmc = new TH2D( (const TH2D&)blindidmc ); 871 TH2D *blindnthmc = new TH2D( (const TH2D&)blindnmc ); 872 873 /* 874 TH2D *sigthmc = (TH2D*)sigmc.Clone(); 875 TH3D *sigpixthmc = (TH3D*)sigpixmc.Clone(); 876 TH3D *diffpixthmc = (TH3D*)diffpixmc.Clone(); 877 TH2D *blindidthmc = (TH2D*)blindidmc.Clone(); 878 TH2D *blindnthmc = (TH2D*)blindnmc.Clone(); 879 */ 880 881 //filereadmc.Close(); 882 gLog << "" << endl; 883 gLog << "Macro ONOFFAnalysis : padding plots for MC data read from file " 884 << NamePadMC << endl; 885 886 pad.MergeONOFFMC(*sigthmc, *diffpixthmc, *sigpixthmc, 887 *blindidthmc, *blindnthmc, 888 *sigthon, *diffpixthon, *sigpixthon, 889 *blindidthon, *blindnthon, 890 *sigthoff, *diffpixthoff,*sigpixthoff, 891 *blindidthoff,*blindnthoff); 892 893 // write the target padding histograms onto a file --------- 894 pad.WritePaddingDist(outNameSigTh); 693 895 } 896 // end of Merge 897 694 898 695 899 … … 698 902 if (Wout) 699 903 { 904 // read the target padding histograms --------------------------- 905 pad.ReadPaddingDist(outNameSigTh); 906 907 700 908 gLog << "=====================================================" << endl; 701 909 gLog << "Start the padding" << endl; … … 723 931 MGeomApply apply; 724 932 725 //MPedestalWorkaround waround;726 727 933 // a way to find out whether one is dealing with MC : 728 MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5); // MC 729 f1.SetName("Select MC"); 730 MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5); // data 731 f2.SetName("Select Data"); 732 733 //if (typeInput == "ON") 734 //{ 735 // MCT1PointingCorrCalc pointcorr(sourceName, "MCT1PointingCorrCalc", 736 // "MCT1PointingCorrCalc"); 737 //} 934 //MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5); // MC 935 //f1.SetName("Select MC"); 936 //MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5); // data 937 //f2.SetName("Select Data"); 938 738 939 MSourcePosfromStarPos sourcefromstar; 739 940 if (typeInput == "ON") 740 941 { 741 sourcefromstar.SetSourceAndStarPosition(742 "Crab", 22, 0, 52, 5, 34, 32.0,743 "Zeta-Tau", 21, 8, 33, 5, 37, 38.7);744 sourcefromstar.AddStar("Tau114", 21, 56, 13, 5, 27, 38.1);745 // sourcefromstar.AddFile("~wittek/datacrab_26feb04/positionsOn.4.txt",0);746 747 if(inPath == "/.magic/magicserv01/scratch/calibrated/")748 {749 sourcefromstar.AddFile("~wittek/datacrab_26feb04/positions2stars.txt", 0);750 // sourcefromstar.AddFile("~wittek/datacrab_26feb04/positionsNoStar.txt", 0);751 }752 else if(inPath == "/.magic/magicserv01/scratch/calibrated26/")753 sourcefromstar.AddFile("~wittek/datacrab_26feb04/stars_2004_01_26", 0);754 755 else if(inPath == "/mnt/magicserv01/scratch/David/CalibratedData/Crab/2004_02_15/")756 942 //sourcefromstar.SetSourceAndStarPosition( 943 // "Crab", 22, 0, 52, 5, 34, 32.0, 944 // "Zeta-Tau", 21, 8, 33, 5, 37, 38.7); 945 //sourcefromstar.AddStar("Tau114", 21, 56, 13, 5, 27, 38.1); 946 ////sourcefromstar.AddFile("~wittek/datacrab_26feb04/positionsOn.4.txt",0); 947 948 //if(inPath == "/.magic/magicserv01/scratch/calibrated/") 949 //{ 950 //sourcefromstar.AddFile("~wittek/datacrab_26feb04/positions2stars.txt", 0); 951 ////sourcefromstar.AddFile("~wittek/datacrab_26feb04/positionsNoStar.txt", 0); 952 //} 953 //else if(inPath == "/.magic/magicserv01/scratch/calibrated26/") 954 // sourcefromstar.AddFile("~wittek/datacrab_26feb04/stars_2004_01_26", 0); 955 956 //else if(inPath == "/mnt/magicserv01/scratch/David/CalibratedData/Crab/2004_02_15/") 957 sourcefromstar.AddFile("~wittek/datacrab_26feb04/positions040215.txt", 0); 757 958 } 758 959 else if (typeInput == "OFF") 759 960 { 760 if(inPath == "/.magic/magicserv01/scratch/calibrated/")761 sourcefromstar.AddFile("~wittek/datacrab_26feb04/positionsOff.txt", 0);762 else if(inPath == "/.magic/magicserv01/scratch/calibrated26/")763 sourcefromstar.AddFile("~wittek/datacrab_26feb04/positions_2004_01_26", 0);764 else if(inPath == "/mnt/magicserv01/scratch/David/CalibratedData/Crab/2004_02_15")765 961 //if(inPath == "/.magic/magicserv01/scratch/calibrated/") 962 // sourcefromstar.AddFile("~wittek/datacrab_26feb04/positionsOff.txt", 0); 963 //else if(inPath == "/.magic/magicserv01/scratch/calibrated26/") 964 // sourcefromstar.AddFile("~wittek/datacrab_26feb04/positions_2004_01_26", 0); 965 //else if(inPath == "/mnt/magicserv01/scratch/David/CalibratedData/Crab/2004_02_15") 966 sourcefromstar.AddFile("~wittek/datacrab_26feb04/positions040215.txt", 0); 766 967 } 767 768 769 //MBlindPixelCalc blindbeforepad; 968 else if (typeInput == "MC") 969 { 970 } 971 972 MBlindPixelsCalc2 blindbeforepad; 770 973 //blindbeforepad.SetUseBlindPixels(); 771 //blindbeforepad.SetName("BlindBeforePadding"); 772 773 //MBlindPixelCalc blind; 774 //blind.SetUseBlindPixels(); 775 //blind.SetUseInterpolation(); 776 //blind.SetName("BlindAfterPadding"); 777 778 MSigmabarCalc sigbar; 974 blindbeforepad.SetCheckPedestalRms(); 975 blindbeforepad.SetName("BlindBeforePadding"); 779 976 780 977 //MBadPixelCalcRms blind; … … 794 991 MSigmabarCalc sigbarcalc; 795 992 796 MFillH fillsigtheta ("SigmaTheta[MHSigmaTheta]", "M McEvt");993 MFillH fillsigtheta ("SigmaTheta[MHSigmaTheta]", "MPointingPos"); 797 994 fillsigtheta.SetName("HSigmaTheta"); 798 995 … … 845 1042 //write.AddContainer("MMcRunHeader", "RunHeaders", kFALSE); 846 1043 //write.AddContainer("MTime", "Events"); 847 write.AddContainer("MMcEvt", "Events"); 848 //write.AddContainer("ThetaOrig", "Events"); 1044 write.AddContainer("MPointingPos", "Events"); 849 1045 write.AddContainer("MSrcPosCam", "Events"); 850 1046 write.AddContainer("MSigmabar", "Events"); … … 868 1064 869 1065 tliston.AddToList(&read); 870 871 1066 //tliston.AddToList(&f1); 872 1067 //tliston.AddToList(&f2); 873 1068 tliston.AddToList(&apply); 874 //tliston.AddToList(&waround);875 1069 tliston.AddToList(&sourcefromstar); 876 1070 877 //tliston.AddToList(&blindbeforepad); 878 // tliston.AddToList(&pad); 879 // if (typeInput == "ON") 880 // tliston.AddToList(&pointcorr); 881 882 tliston.AddToList(&sigbar); 1071 tliston.AddToList(&blindbeforepad); 1072 1073 tliston.AddToList(&contbasic); 1074 tliston.AddToList(&pad); 1075 883 1076 tliston.AddToList(&blind); 884 tliston.AddToList(&contbasic);885 886 1077 tliston.AddToList(&fillblind); 887 //tliston.AddToList(&sigbarcalc);1078 tliston.AddToList(&sigbarcalc); 888 1079 tliston.AddToList(&fillsigtheta); 889 1080 tliston.AddToList(&clean); … … 913 1104 // evtloop.Write(); 914 1105 915 Int_t maxevents = -1;916 //Int_t maxevents = 1000;1106 //Int_t maxevents = -1; 1107 Int_t maxevents = 2000; 917 1108 if ( !evtloop.Eventloop(maxevents) ) 918 1109 return; … … 1109 1300 matrixg.EnableGraphicalOutput(); 1110 1301 1111 matrixg.AddColumn("cos( MMcEvt.fTelescopeTheta)");1302 matrixg.AddColumn("cos((MPointingPos.fZd)/kRad2Deg)"); 1112 1303 matrixg.AddColumn("MSigmabar.fSigmabar"); 1113 1304 matrixg.AddColumn("log10(MHillas.fSize)"); … … 1198 1389 bing.SetEdges(10, 0., 1.0); 1199 1390 1200 MH3 gref("cos( MMcEvt.fTelescopeTheta)");1391 MH3 gref("cos((MPointingPos.fZd)/kRad2Deg)"); 1201 1392 gref.SetName(mgname); 1202 1393 MH::SetBinning(&gref.GetHist(), &bing); … … 1231 1422 writetraing.AddContainer("MRawRunHeader", "RunHeaders"); 1232 1423 writetraing.AddContainer("MTime", "Events"); 1233 writetraing.AddContainer("M McEvt","Events");1424 writetraing.AddContainer("MPointingPos", "Events"); 1234 1425 writetraing.AddContainer("ThetaOrig", "Events"); 1235 1426 writetraing.AddContainer("MSrcPosCam", "Events"); … … 1248 1439 writetestg.AddContainer("MRawRunHeader", "RunHeaders"); 1249 1440 writetestg.AddContainer("MTime", "Events"); 1250 writetestg.AddContainer("M McEvt","Events");1441 writetestg.AddContainer("MPointingPos", "Events"); 1251 1442 writetestg.AddContainer("ThetaOrig", "Events"); 1252 1443 writetestg.AddContainer("MSrcPosCam", "Events"); … … 1331 1522 binh.SetEdges(10, 0., 1.0); 1332 1523 1333 //MH3 href("cos( MMcEvt.fTelescopeTheta)");1524 //MH3 href("cos((MPointingPos.fZd)/kRad2Deg)"); 1334 1525 //href.SetName(mhname); 1335 1526 //MH::SetBinning(&href.GetHist(), &binh); … … 1366 1557 writetrainh.AddContainer("MRawRunHeader", "RunHeaders"); 1367 1558 writetrainh.AddContainer("MTime", "Events"); 1368 writetrainh.AddContainer("M McEvt","Events");1559 writetrainh.AddContainer("MPointingPos", "Events"); 1369 1560 writetrainh.AddContainer("ThetaOrig", "Events"); 1370 1561 writetrainh.AddContainer("MSrcPosCam", "Events"); … … 1382 1573 writetesth.AddContainer("MRawRunHeader", "RunHeaders"); 1383 1574 writetesth.AddContainer("MTime", "Events"); 1384 writetesth.AddContainer("M McEvt","Events");1575 writetesth.AddContainer("MPointingPos", "Events"); 1385 1576 writetesth.AddContainer("ThetaOrig", "Events"); 1386 1577 writetesth.AddContainer("MSrcPosCam", "Events"); … … 1667 1858 write.AddContainer("MRawRunHeader", "RunHeaders"); 1668 1859 write.AddContainer("MTime", "Events"); 1669 write.AddContainer("M McEvt","Events");1860 write.AddContainer("MPointingPos", "Events"); 1670 1861 write.AddContainer("ThetaOrig", "Events"); 1671 1862 write.AddContainer("MSrcPosCam", "Events"); … … 1992 2183 bin.SetEdges(10, 0., 1.0); 1993 2184 1994 MH3 mh3("cos( MMcEvt.fTelescopeTheta)");2185 MH3 mh3("cos((MPointingPos.fZd)/kRad2Deg)"); 1995 2186 mh3.SetName(mname); 1996 2187 MH::SetBinning(&mh3.GetHist(), &bin); … … 2355 2546 2356 2547 write.AddContainer("MRawRunHeader", "RunHeaders"); 2357 //write.AddContainer("MTime", "Events"); 2358 write.AddContainer("MMcEvt", "Events"); 2359 //write.AddContainer("ThetaOrig", "Events"); 2548 write.AddContainer("MTime", "Events"); 2549 write.AddContainer("MPointingPos", "Events"); 2360 2550 write.AddContainer("MSrcPosCam", "Events"); 2361 2551 write.AddContainer("MSigmabar", "Events"); … … 3137 3327 3138 3328 3139 MFillH filler("MHMcCollectionArea", "M McEvt");3329 MFillH filler("MHMcCollectionArea", "MPointingPos"); 3140 3330 filler.SetName("CollectionArea"); 3141 3331 … … 3326 3516 write.AddContainer("MRawRunHeader", "RunHeaders"); 3327 3517 write.AddContainer("MTime", "Events"); 3328 write.AddContainer("M McEvt","Events");3518 write.AddContainer("MPointingPos", "Events"); 3329 3519 write.AddContainer("ThetaOrig", "Events"); 3330 3520 write.AddContainer("MSrcPosCam", "Events"); … … 3400 3590 // new from Robert 3401 3591 3402 MFillH hfill6("MHTimeDiffTheta", "M McEvt");3592 MFillH hfill6("MHTimeDiffTheta", "MPointingPos"); 3403 3593 hfill6.SetName("HTimeDiffTheta"); 3404 3594 3405 MFillH hfill6a("MHTimeDiffTime", "M McEvt");3595 MFillH hfill6a("MHTimeDiffTime", "MPointingPos"); 3406 3596 hfill6a.SetName("HTimeDiffTime"); 3407 3597 … … 3611 3801 3612 3802 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 -
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; -
trunk/MagicSoft/Mars/mfilter/MFSelBasic.cc
r3274 r4584 46 46 #include "MParList.h" 47 47 48 #include "M McEvt.hxx"48 #include "MPointingPos.h" 49 49 50 50 #include "MCerPhotEvt.h" … … 104 104 } 105 105 106 f McEvt = (MMcEvt*)pList->FindObject("MMcEvt");107 if (!f McEvt)108 { 109 *fLog << dbginf << "M McEvtnot found... aborting." << endl;106 fPointPos = (MPointingPos*)pList->FindObject("MPointingPos"); 107 if (!fPointPos) 108 { 109 *fLog << dbginf << "MPointingPos not found... aborting." << endl; 110 110 return kFALSE; 111 111 } … … 146 146 Int_t MFSelBasic::Process() 147 147 { 148 const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();148 const Double_t theta = fPointPos->GetZd(); 149 149 150 150 fResult = kFALSE; -
trunk/MagicSoft/Mars/mfilter/MFSelBasic.h
r2663 r4584 14 14 #endif 15 15 16 class M McEvt;16 class MPointingPos; 17 17 class MGeomCam; 18 18 class MCerPhotEvt; … … 23 23 { 24 24 private: 25 const M McEvt *fMcEvt;25 const MPointingPos *fPointPos; 26 26 const MGeomCam *fCam; // Camera Geometry 27 27 const MCerPhotEvt *fEvt; // Cerenkov Photon Event -
trunk/MagicSoft/Mars/mfilter/Makefile
r3927 r4584 13 13 INCLUDES = -I. -I../mbase -I../mfbase -I../mraw -I../mmc -I../mdata \ 14 14 -I../manalysis -I../mfileio -I../mgeom -I../mimage \ 15 -I../mhbase -I../mmain -I../mgui -I../msignal 15 -I../mhbase -I../mmain -I../mgui -I../msignal -I../mpointing \ 16 16 -I../mpedestal 17 17 -
trunk/MagicSoft/Mars/mhist/MHSigmaTheta.cc
r3339 r4584 26 26 ////////////////////////////////////////////////////////////////////////////// 27 27 // // 28 // MHSigmaTheta (extension of Robert's MHSigmabarTheta)//28 // MHSigmaTheta // 29 29 // // 30 // calculates - the 2D-histogram sigmabar vs. Theta, and // 30 // calculates - the 2D-histogram sigmabar vs. Theta (Inner), and // 31 // - the 2D-histogram sigmabar vs. Theta (Outer) // 31 32 // - the 3D-histogram sigma, pixel no., Theta // 32 33 // - the 3D-histogram (sigma^2-sigmabar^2), pixel no., Theta // … … 39 40 40 41 #include "MTime.h" 41 #include "M McEvt.hxx"42 #include "MPointingPos.h" 42 43 43 44 #include "MBinning.h" … … 46 47 47 48 #include "MGeomCam.h" 49 #include "MBlindPixels.h" 48 50 49 51 #include "MPedPhotCam.h" … … 70 72 71 73 fSigmaTheta.SetDirectory(NULL); 72 fSigmaTheta.SetName("2D-ThetaSigmabar ");74 fSigmaTheta.SetName("2D-ThetaSigmabar(Inner)"); 73 75 fSigmaTheta.SetTitle("2D: \\bar{\\sigma}, \\Theta"); 74 76 fSigmaTheta.SetXTitle("\\Theta [\\circ]"); 75 fSigmaTheta.SetYTitle("Sigmabar"); 77 fSigmaTheta.SetYTitle("Sigmabar(Inner) / SQRT(Area)"); 78 79 fSigmaThetaOuter.SetDirectory(NULL); 80 fSigmaThetaOuter.SetName("2D-ThetaSigmabar(Outer)"); 81 fSigmaThetaOuter.SetTitle("2D: \\bar{\\sigma}, \\Theta"); 82 fSigmaThetaOuter.SetXTitle("\\Theta [\\circ]"); 83 fSigmaThetaOuter.SetYTitle("Sigmabar(Outer) / SQRT(Area)"); 76 84 77 85 fSigmaPixTheta.SetDirectory(NULL); … … 80 88 fSigmaPixTheta.SetXTitle("\\Theta [\\circ]"); 81 89 fSigmaPixTheta.SetYTitle("Pixel Id"); 82 fSigmaPixTheta.SetZTitle(" \\sigma");90 fSigmaPixTheta.SetZTitle("Sigma"); 83 91 84 92 fDiffPixTheta.SetDirectory(NULL); … … 87 95 fDiffPixTheta.SetXTitle("\\Theta [\\circ]"); 88 96 fDiffPixTheta.SetYTitle("Pixel Id"); 89 fDiffPixTheta.SetZTitle(" {\\sigma}^{2}-\\bar{\\sigma}^{2}");97 fDiffPixTheta.SetZTitle("(Sigma2 - Sigmabar2)/Area"); 90 98 91 99 // Set default binning … … 102 110 binspix.SetEdges(578, -0.5, 577.5); 103 111 104 SetBinning(&fSigmaTheta, &binst, &binsb); 105 SetBinning(&fSigmaPixTheta, &binst, &binspix, &binsb); 106 SetBinning(&fDiffPixTheta, &binst, &binspix, &binsd); 112 SetBinning(&fSigmaTheta, &binst, &binsb); 113 SetBinning(&fSigmaThetaOuter, &binst, &binsb); 114 SetBinning(&fSigmaPixTheta, &binst, &binspix, &binsb); 115 SetBinning(&fDiffPixTheta, &binst, &binspix, &binsd); 107 116 } 108 117 … … 120 129 } 121 130 122 f McEvt = (MMcEvt*)plist->FindObject("MMcEvt");123 if (!f McEvt)124 *fLog << warn << "M McEvtnot found... aborting." << endl;131 fPointPos = (MPointingPos*)plist->FindObject("MPointingPos"); 132 if (!fPointPos) 133 *fLog << warn << "MPointingPos not found... aborting." << endl; 125 134 126 135 … … 132 141 } 133 142 fPed->InitSize(fCam->GetNumPixels()); 143 144 145 fBlindPix = (MBlindPixels*)plist->FindObject("MBlindPixels"); 146 if (!fBlindPix) 147 { 148 *fLog << err << "MBlindPixels not found... continue. " << endl; 149 } 134 150 135 151 … … 177 193 if (binssigma) 178 194 { 179 SetBinning(&fSigmaTheta, binstheta, binssigma); 180 SetBinning(&fSigmaPixTheta, binstheta, &binspix, binssigma); 195 SetBinning(&fSigmaTheta, binstheta, binssigma); 196 SetBinning(&fSigmaThetaOuter, binstheta, binssigma); 197 SetBinning(&fSigmaPixTheta, binstheta, &binspix, binssigma); 181 198 } 182 199 … … 191 208 // Fill the histograms 192 209 // 210 // ignore pixels if they are unused or blind 211 // 193 212 Bool_t MHSigmaTheta::Fill(const MParContainer *par, const Stat_t w) 194 213 { 195 Double_t theta = f McEvt ? fMcEvt->GetTelescopeTheta()*kRad2Deg : 0;214 Double_t theta = fPointPos->GetZd(); 196 215 fSigmabar->Calc(*fCam, *fPed, *fEvt); 197 Double_t mysig = fSigmabar->GetSigmabarInner(); 198 199 //*fLog << "theta, mysig = " << theta << ", " << mysig << endl; 216 Double_t mysig = fSigmabar->GetSigmabarInner(); 217 Double_t mysigouter = fSigmabar->GetSigmabarOuter(); 218 219 //*fLog << "theta, mysig, mysigouter = " << theta << ", " << mysig 220 // << ", " << mysigouter << endl; 200 221 201 222 fSigmaTheta.Fill(theta, mysig); 223 fSigmaThetaOuter.Fill(theta, mysigouter); 202 224 203 225 const UInt_t npix = fEvt->GetNumPixels(); … … 205 227 for (UInt_t i=0; i<npix; i++) 206 228 { 207 MCerPhotPix cerpix = (*fEvt)[i]; 229 MCerPhotPix &cerpix = (*fEvt)[i]; 230 const Int_t id = cerpix.GetPixId(); 231 208 232 if (!cerpix.IsPixelUsed()) 209 continue; 210 211 const Int_t id = cerpix.GetPixId(); 233 { 234 //*fLog << all << "MHSigmaTheta::Fill; unused pixel found, id = " 235 // << id << endl; 236 continue; 237 } 238 212 239 const MPedPhotPix &pix = (*fPed)[id]; 240 241 if ( fBlindPix != NULL && fBlindPix->IsBlind(id) ) 242 { 243 // this should never occur, because blind pixels should have 244 // been set unused by MBlindPixelsCalc2::UnMap() 245 //*fLog << all << "MHSigmaTheta::Fill; blind pixel found which is used, id = " 246 // << id << "... go to next pixel." << endl; 247 continue; 248 } 213 249 214 250 // ratio is the area of pixel 0 … … 219 255 fSigmaPixTheta.Fill(theta, (Double_t)id, sigma*sqrt(ratio)); 220 256 221 const Double_t diff = sigma*sigma*ratio - mysig*mysig; 257 Double_t diff; 258 if (ratio > 0.5) 259 { 260 // inner pixel 261 diff = sigma*sigma*ratio - mysig*mysig; 262 } 263 else 264 { 265 // outer pixel 266 diff = sigma*sigma*ratio - mysigouter*mysigouter; 267 } 268 222 269 fDiffPixTheta.Fill(theta, (Double_t)id, diff); 223 270 } … … 262 309 AppendPad(""); 263 310 264 pad->Divide(3, 2);311 pad->Divide(3, 3); 265 312 266 313 // draw the 2D histogram Sigmabar versus Theta … … 283 330 h->SetTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2} vs. \\Theta (all pixels)"); 284 331 h->SetXTitle("\\Theta [\\circ]"); 285 h->SetYTitle(" \\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2}");332 h->SetYTitle("(Sigma2 - Sigmabar2) / Area"); 286 333 h->Draw("box"); 287 334 h->SetBit(kCanDelete); … … 293 340 h->SetTitle("\\sigma_{ped} vs. \\Theta (all pixels)"); 294 341 h->SetXTitle("\\Theta [\\circ]"); 295 h->SetYTitle(" \\sigma_{ped}");342 h->SetYTitle("Sigma"); 296 343 h->Draw("box"); 297 344 h->SetBit(kCanDelete); … … 313 360 h->SetTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2} vs. pixel Id (all \\Theta)"); 314 361 h->SetXTitle("Pixel Id"); 315 h->SetYTitle(" \\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2}");362 h->SetYTitle("Sigma2 - sigmabar2) / Area"); 316 363 h->Draw("box"); 317 364 h->SetBit(kCanDelete); … … 323 370 h->SetTitle("\\sigma_{ped} vs. pixel Id (all \\Theta)"); 324 371 h->SetXTitle("Pixel Id"); 325 h->SetYTitle(" \\sigma_{ped}");372 h->SetYTitle("Sigma"); 326 373 h->Draw("box"); 327 374 h->SetBit(kCanDelete); … … 329 376 pad->cd(4); 330 377 fSigmaTheta.Draw(opt); 378 379 pad->cd(7); 380 fSigmaThetaOuter.Draw(opt); 331 381 332 382 //pad->cd(8); -
trunk/MagicSoft/Mars/mhist/MHSigmaTheta.h
r2798 r4584 16 16 class MGeomCam; 17 17 class MCerPhotEvt; 18 class M McEvt;18 class MPointingPos; 19 19 class MPedPhotCam; 20 20 class MSigmabar; 21 21 class MParList; 22 class MBlindPixels; 22 23 23 24 … … 29 30 MCerPhotEvt *fEvt; //! 30 31 MSigmabar *fSigmabar; //! 31 MMcEvt *fMcEvt; //! 32 33 TH2D fSigmaTheta; // 2D-distribution sigmabar versus Theta; 34 // sigmabar is the average pedestasl sigma in an event 32 MPointingPos *fPointPos; //! 33 MBlindPixels *fBlindPix; //! 34 35 // sigmabar is the average pedestal sigma 36 TH2D fSigmaTheta; // 2D-distribution sigmabar versus Theta (Inner) 37 TH2D fSigmaThetaOuter; // 2D-distribution sigmabar versus Theta (Outer) 38 35 39 TH3D fSigmaPixTheta; // 3D-distr.:Theta, pixel, pedestal sigma 36 40 TH3D fDiffPixTheta; // 3D-distr.:Theta, pixel, sigma^2-sigmabar^2 … … 46 50 const TH2D *GetSigmaTheta() { return &fSigmaTheta; } 47 51 const TH2D *GetSigmaTheta() const { return &fSigmaTheta; } 52 53 const TH2D *GetSigmaThetaOuter() { return &fSigmaThetaOuter; } 54 const TH2D *GetSigmaThetaOuter() const { return &fSigmaThetaOuter; } 48 55 49 56 const TH3D *GetSigmaPixTheta() { return &fSigmaPixTheta; }
Note:
See TracChangeset
for help on using the changeset viewer.