musrfit 1.10.0
PRunListCollection.cpp
Go to the documentation of this file.
1/***************************************************************************
2
3 PRunListCollection.cpp
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8***************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2007-2026 by Andreas Suter *
12 * andreas.suter@psi.ch *
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
29
30#include <iostream>
31
32#include "PRunListCollection.h"
33
34//--------------------------------------------------------------------------
35// Constructor
36//--------------------------------------------------------------------------
62 fMsrInfo(msrInfo), fData(data), fTheoAsData(theoAsData)
63{
64}
65
66//--------------------------------------------------------------------------
67// Destructor
68//--------------------------------------------------------------------------
90{
91 for (UInt_t i=0; i<fRunSingleHistoList.size(); i++) {
92 fRunSingleHistoList[i]->CleanUp();
93 fRunSingleHistoList[i]->~PRunSingleHisto();
94 }
95 fRunSingleHistoList.clear();
96
97 for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++) {
98 fRunSingleHistoRRFList[i]->CleanUp();
99 fRunSingleHistoRRFList[i]->~PRunSingleHistoRRF();
100 }
102
103 for (UInt_t i=0; i<fRunAsymmetryList.size(); i++) {
104 fRunAsymmetryList[i]->CleanUp();
105 fRunAsymmetryList[i]->~PRunAsymmetry();
106 }
107 fRunAsymmetryList.clear();
108
109 for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++) {
110 fRunAsymmetryRRFList[i]->CleanUp();
111 fRunAsymmetryRRFList[i]->~PRunAsymmetryRRF();
112 }
113 fRunAsymmetryRRFList.clear();
114
115 for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++) {
116 fRunAsymmetryBNMRList[i]->CleanUp();
117 fRunAsymmetryBNMRList[i]->~PRunAsymmetryBNMR();
118 }
119 fRunAsymmetryBNMRList.clear();
120
121 for (UInt_t i=0; i<fRunMuMinusList.size(); i++) {
122 fRunMuMinusList[i]->CleanUp();
123 fRunMuMinusList[i]->~PRunMuMinus();
124 }
125 fRunMuMinusList.clear();
126
127 for (UInt_t i=0; i<fRunNonMusrList.size(); i++) {
128 fRunNonMusrList[i]->CleanUp();
129 fRunNonMusrList[i]->~PRunNonMusr();
130 }
131 fRunNonMusrList.clear();
132}
133
134//--------------------------------------------------------------------------
135// Add (public)
136//--------------------------------------------------------------------------
169{
170 Bool_t success = true;
171
172 // try to get the fit type from the RUN block
173 Int_t fitType = (*fMsrInfo->GetMsrRunList())[runNo].GetFitType();
174 if (fitType == -1) { // fit type NOT given in the RUN block, check the GLOBAL block
175 fitType = (*fMsrInfo->GetMsrGlobal()).GetFitType();
176 }
177
178 switch (fitType) {
180 fRunSingleHistoList.push_back(new PRunSingleHisto(fMsrInfo, fData, runNo, tag, fTheoAsData));
181 if (!fRunSingleHistoList[fRunSingleHistoList.size()-1]->IsValid())
182 success = false;
183 break;
186 if (!fRunSingleHistoRRFList[fRunSingleHistoRRFList.size()-1]->IsValid())
187 success = false;
188 break;
189 case PRUN_ASYMMETRY:
190 fRunAsymmetryList.push_back(new PRunAsymmetry(fMsrInfo, fData, runNo, tag, fTheoAsData));
191 if (!fRunAsymmetryList[fRunAsymmetryList.size()-1]->IsValid())
192 success = false;
193 break;
195 fRunAsymmetryRRFList.push_back(new PRunAsymmetryRRF(fMsrInfo, fData, runNo, tag, fTheoAsData));
196 if (!fRunAsymmetryRRFList[fRunAsymmetryRRFList.size()-1]->IsValid())
197 success = false;
198 break;
201 if (!fRunAsymmetryBNMRList[fRunAsymmetryBNMRList.size()-1]->IsValid())
202 success = false;
203 break;
204 case PRUN_MU_MINUS:
205 fRunMuMinusList.push_back(new PRunMuMinus(fMsrInfo, fData, runNo, tag, fTheoAsData));
206 if (!fRunMuMinusList[fRunMuMinusList.size()-1]->IsValid())
207 success = false;
208 break;
209 case PRUN_NON_MUSR:
210 fRunNonMusrList.push_back(new PRunNonMusr(fMsrInfo, fData, runNo, tag, fTheoAsData));
211 if (!fRunNonMusrList[fRunNonMusrList.size()-1]->IsValid())
212 success = false;
213 break;
214 default:
215 success = false;
216 break;
217 }
218
219 return success;
220}
221
222//--------------------------------------------------------------------------
223// SetFitRange (public)
224//--------------------------------------------------------------------------
253void PRunListCollection::SetFitRange(const TString fitRange)
254{
255 for (UInt_t i=0; i<fRunSingleHistoList.size(); i++)
256 fRunSingleHistoList[i]->SetFitRangeBin(fitRange);
257 for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
258 fRunSingleHistoRRFList[i]->SetFitRangeBin(fitRange);
259 for (UInt_t i=0; i<fRunAsymmetryList.size(); i++)
260 fRunAsymmetryList[i]->SetFitRangeBin(fitRange);
261 for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
262 fRunAsymmetryRRFList[i]->SetFitRangeBin(fitRange);
263 for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++)
264 fRunAsymmetryBNMRList[i]->SetFitRangeBin(fitRange);
265 for (UInt_t i=0; i<fRunMuMinusList.size(); i++)
266 fRunMuMinusList[i]->SetFitRangeBin(fitRange);
267 for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
268 fRunNonMusrList[i]->SetFitRangeBin(fitRange);
269}
270
271//--------------------------------------------------------------------------
272// SetFitRange (public)
273//--------------------------------------------------------------------------
304{
305 for (UInt_t i=0; i<fRunSingleHistoList.size(); i++) {
306 fRunSingleHistoList[i]->SetFitRange(fitRange);
307 fRunSingleHistoList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
308 }
309 for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++) {
310 fRunSingleHistoRRFList[i]->SetFitRange(fitRange);
311 fRunSingleHistoRRFList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
312 }
313 for (UInt_t i=0; i<fRunAsymmetryList.size(); i++) {
314 fRunAsymmetryList[i]->SetFitRange(fitRange);
315 fRunAsymmetryList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
316 }
317 for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++) {
318 fRunAsymmetryRRFList[i]->SetFitRange(fitRange);
319 fRunAsymmetryRRFList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
320 }
321 for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++) {
322 fRunAsymmetryBNMRList[i]->SetFitRange(fitRange);
323 fRunAsymmetryBNMRList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
324 }
325 for (UInt_t i=0; i<fRunMuMinusList.size(); i++) {
326 fRunMuMinusList[i]->SetFitRange(fitRange);
327 fRunMuMinusList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
328 }
329 for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
330 fRunNonMusrList[i]->SetFitRange(fitRange);
331}
332
333//--------------------------------------------------------------------------
334// GetSingleHistoChisq (public)
335//--------------------------------------------------------------------------
353Double_t PRunListCollection::GetSingleHistoChisq(const std::vector<Double_t>& par) const
354{
355 Double_t chisq = 0.0;
356
357 for (UInt_t i=0; i<fRunSingleHistoList.size(); i++)
358 chisq += fRunSingleHistoList[i]->CalcChiSquare(par);
359
360 return chisq;
361}
362
363//--------------------------------------------------------------------------
364// GetSingleHistoRRFChisq (public)
365//--------------------------------------------------------------------------
374Double_t PRunListCollection::GetSingleHistoRRFChisq(const std::vector<Double_t>& par) const
375{
376 Double_t chisq = 0.0;
377
378 for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
379 chisq += fRunSingleHistoRRFList[i]->CalcChiSquare(par);
380
381 return chisq;
382}
383
384//--------------------------------------------------------------------------
385// GetAsymmetryChisq (public)
386//--------------------------------------------------------------------------
402Double_t PRunListCollection::GetAsymmetryChisq(const std::vector<Double_t>& par) const
403{
404 Double_t chisq = 0.0;
405
406 for (UInt_t i=0; i<fRunAsymmetryList.size(); i++)
407 chisq += fRunAsymmetryList[i]->CalcChiSquare(par);
408
409 return chisq;
410}
411
412//--------------------------------------------------------------------------
413// GetAsymmetryRRFChisq (public)
414//--------------------------------------------------------------------------
423Double_t PRunListCollection::GetAsymmetryRRFChisq(const std::vector<Double_t>& par) const
424{
425 Double_t chisq = 0.0;
426
427 for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
428 chisq += fRunAsymmetryRRFList[i]->CalcChiSquare(par);
429
430 return chisq;
431}
432
433//--------------------------------------------------------------------------
434// GetAsymmetryBNMRChisq (public)
435//--------------------------------------------------------------------------
444Double_t PRunListCollection::GetAsymmetryBNMRChisq(const std::vector<Double_t>& par) const
445{
446 Double_t chisq = 0.0;
447
448 for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++)
449 chisq += fRunAsymmetryBNMRList[i]->CalcChiSquare(par);
450
451 return chisq;
452}
453
454//--------------------------------------------------------------------------
455// GetMuMinusChisq (public)
456//--------------------------------------------------------------------------
465Double_t PRunListCollection::GetMuMinusChisq(const std::vector<Double_t>& par) const
466{
467 Double_t chisq = 0.0;
468
469 for (UInt_t i=0; i<fRunMuMinusList.size(); i++)
470 chisq += fRunMuMinusList[i]->CalcChiSquare(par);
471
472 return chisq;
473}
474
475//--------------------------------------------------------------------------
476// GetNonMusrChisq (public)
477//--------------------------------------------------------------------------
486Double_t PRunListCollection::GetNonMusrChisq(const std::vector<Double_t>& par) const
487{
488 Double_t chisq = 0.0;
489
490 for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
491 chisq += fRunNonMusrList[i]->CalcChiSquare(par);
492
493 return chisq;
494}
495
496//--------------------------------------------------------------------------
497// GetSingleRunChisqExpected (public)
498//--------------------------------------------------------------------------
508Double_t PRunListCollection::GetSingleRunChisqExpected(const std::vector<Double_t>& par, const UInt_t idx) const
509{
510 Double_t expectedChisq = 0.0;
511
512 if (idx > fMsrInfo->GetMsrRunList()->size()) {
513 std::cerr << ">> PRunListCollection::GetSingleRunChisqExpected() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << std::endl << std::endl;
514 return expectedChisq;
515 }
516
517 UInt_t subIdx = 0;
518 Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
519 if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
520 type = fMsrInfo->GetMsrGlobal()->GetFitType();
521 subIdx = idx;
522 } else { // found in the RUN block
523 // count how many entries of this fit-type are present up to idx
524 for (UInt_t i=0; i<idx; i++) {
525 if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
526 subIdx++;
527 }
528 }
529
530
531 // return the chisq of the single run
532 switch (type) {
534 expectedChisq = fRunSingleHistoList[subIdx]->CalcChiSquareExpected(par);
535 break;
537 expectedChisq = fRunSingleHistoRRFList[subIdx]->CalcChiSquareExpected(par);
538 break;
539 case PRUN_ASYMMETRY:
540 expectedChisq = fRunAsymmetryList[subIdx]->CalcChiSquareExpected(par);
541 break;
543 expectedChisq = fRunAsymmetryRRFList[subIdx]->CalcChiSquareExpected(par);
544 break;
546 expectedChisq = fRunAsymmetryBNMRList[subIdx]->CalcChiSquareExpected(par);
547 break;
548 case PRUN_MU_MINUS:
549 expectedChisq = fRunMuMinusList[subIdx]->CalcChiSquareExpected(par);
550 break;
551 case PRUN_NON_MUSR:
552 expectedChisq = fRunNonMusrList[subIdx]->CalcChiSquareExpected(par);
553 break;
554 default:
555 break;
556 }
557
558 return expectedChisq;
559}
560
561//--------------------------------------------------------------------------
562// GetSingleRunChisq (public)
563//--------------------------------------------------------------------------
573Double_t PRunListCollection::GetSingleRunChisq(const std::vector<Double_t>& par, const UInt_t idx) const
574{
575 Double_t chisq = 0.0;
576
577 if (idx > fMsrInfo->GetMsrRunList()->size()) {
578 std::cerr << ">> PRunListCollection::GetSingleRunChisq() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << std::endl << std::endl;
579 return chisq;
580 }
581
582 Int_t subIdx = 0;
583 Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
584 if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
585 type = fMsrInfo->GetMsrGlobal()->GetFitType();
586 subIdx = idx;
587 } else { // found in the RUN block
588 // count how many entries of this fit-type are present up to idx
589 for (UInt_t i=0; i<idx; i++) {
590 if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
591 subIdx++;
592 }
593 }
594
595 // return the chisq of the single run
596 switch (type) {
598 chisq = fRunSingleHistoList[subIdx]->CalcChiSquare(par);
599 break;
601 chisq = fRunSingleHistoRRFList[subIdx]->CalcChiSquare(par);
602 break;
603 case PRUN_ASYMMETRY:
604 chisq = fRunAsymmetryList[subIdx]->CalcChiSquare(par);
605 break;
607 chisq = fRunAsymmetryRRFList[subIdx]->CalcChiSquare(par);
608 break;
610 chisq = fRunAsymmetryBNMRList[subIdx]->CalcChiSquare(par);
611 break;
612 case PRUN_MU_MINUS:
613 chisq = fRunMuMinusList[subIdx]->CalcChiSquare(par);
614 break;
615 case PRUN_NON_MUSR:
616 chisq = fRunNonMusrList[subIdx]->CalcChiSquare(par);
617 break;
618 default:
619 break;
620 }
621
622 return chisq;
623}
624
625//--------------------------------------------------------------------------
626// GetSingleHistoMaximumLikelihood (public)
627//--------------------------------------------------------------------------
636Double_t PRunListCollection::GetSingleHistoMaximumLikelihood(const std::vector<Double_t>& par) const
637{
638 Double_t mlh = 0.0;
639
640 for (UInt_t i=0; i<fRunSingleHistoList.size(); i++)
641 mlh += fRunSingleHistoList[i]->CalcMaxLikelihood(par);
642
643 return mlh;
644}
645
646//--------------------------------------------------------------------------
647// GetSingleHistoRRFMaximumLikelihood (public)
648//--------------------------------------------------------------------------
657Double_t PRunListCollection::GetSingleHistoRRFMaximumLikelihood(const std::vector<Double_t>& par) const
658{
659 Double_t mlh = 0.0;
660
661 for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
662 mlh += fRunSingleHistoRRFList[i]->CalcMaxLikelihood(par);
663
664 return mlh;
665}
666
667//--------------------------------------------------------------------------
668// GetAsymmetryMaximumLikelihood (public)
669//--------------------------------------------------------------------------
679Double_t PRunListCollection::GetAsymmetryMaximumLikelihood(const std::vector<Double_t>& par) const
680{
681 Double_t mlh = 0.0;
682
683 for (UInt_t i=0; i<fRunAsymmetryList.size(); i++)
684 mlh += fRunAsymmetryList[i]->CalcChiSquare(par);
685
686 return mlh;
687}
688
689//--------------------------------------------------------------------------
690// GetAsymmetryRRFMaximumLikelihood (public)
691//--------------------------------------------------------------------------
701Double_t PRunListCollection::GetAsymmetryRRFMaximumLikelihood(const std::vector<Double_t>& par) const
702{
703 Double_t mlh = 0.0;
704
705 for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
706 mlh += fRunAsymmetryRRFList[i]->CalcChiSquare(par);
707
708 return mlh;
709}
710
711//--------------------------------------------------------------------------
712// GetAsymmetryBNMRMaximumLikelihood (public)
713//--------------------------------------------------------------------------
723Double_t PRunListCollection::GetAsymmetryBNMRMaximumLikelihood(const std::vector<Double_t>& par) const
724{
725 Double_t mlh = 0.0;
726
727 for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++)
728 mlh += fRunAsymmetryBNMRList[i]->CalcChiSquare(par);
729
730 return mlh;
731}
732
733//--------------------------------------------------------------------------
734// GetMuMinusMaximumLikelihood (public)
735//--------------------------------------------------------------------------
744Double_t PRunListCollection::GetMuMinusMaximumLikelihood(const std::vector<Double_t>& par) const
745{
746 Double_t mlh = 0.0;
747
748 for (UInt_t i=0; i<fRunMuMinusList.size(); i++)
749 mlh += fRunMuMinusList[i]->CalcMaxLikelihood(par);
750
751 return mlh;
752}
753
754//--------------------------------------------------------------------------
755// GetNonMusrMaximumLikelihood (public)
756//--------------------------------------------------------------------------
766Double_t PRunListCollection::GetNonMusrMaximumLikelihood(const std::vector<Double_t>& par) const
767{
768 Double_t mlh = 0.0;
769
770 for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
771 mlh += fRunNonMusrList[i]->CalcChiSquare(par);
772
773 return mlh;
774}
775
776//--------------------------------------------------------------------------
777// GetSingleRunMaximumLikelihoodExpected (public)
778//--------------------------------------------------------------------------
788Double_t PRunListCollection::GetSingleRunMaximumLikelihoodExpected(const std::vector<Double_t>& par, const UInt_t idx) const
789{
790 Double_t expected_mlh = 0.0;
791
792 if (idx > fMsrInfo->GetMsrRunList()->size()) {
793 std::cerr << ">> PRunListCollection::GetSingleRunMaximumLikelihoodExpected() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << std::endl << std::endl;
794 return expected_mlh;
795 }
796
797 UInt_t subIdx = 0;
798 Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
799 if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
800 type = fMsrInfo->GetMsrGlobal()->GetFitType();
801 subIdx = idx;
802 } else { // found in the RUN block
803 // count how many entries of this fit-type are present up to idx
804 for (UInt_t i=0; i<idx; i++) {
805 if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
806 subIdx++;
807 }
808 }
809
810 // return the mlh of the single run
811 switch (type) {
813 expected_mlh = fRunSingleHistoList[subIdx]->CalcMaxLikelihoodExpected(par);
814 break;
815 default:
816 break;
817 }
818
819 return expected_mlh;
820}
821
822//--------------------------------------------------------------------------
823// GetSingleRunMaximumLikelihood (public)
824//--------------------------------------------------------------------------
834Double_t PRunListCollection::GetSingleRunMaximumLikelihood(const std::vector<Double_t>& par, const UInt_t idx) const
835{
836 Double_t mlh = 0.0;
837
838 if (idx > fMsrInfo->GetMsrRunList()->size()) {
839 std::cerr << ">> PRunListCollection::GetSingleRunMaximumLikelihood() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << std::endl << std::endl;
840 return mlh;
841 }
842
843 Int_t subIdx = 0;
844 Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
845 if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
846 type = fMsrInfo->GetMsrGlobal()->GetFitType();
847 subIdx = idx;
848 } else { // found in the RUN block
849 // count how many entries of this fit-type are present up to idx
850 for (UInt_t i=0; i<idx; i++) {
851 if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
852 subIdx++;
853 }
854 }
855
856 // return the mlh of the single run
857 switch (type) {
859 mlh = fRunSingleHistoList[subIdx]->CalcMaxLikelihood(par);
860 break;
861 default:
862 break;
863 }
864
865 return mlh;
866}
867
868//--------------------------------------------------------------------------
869// GetNoOfBinsFitted (public)
870//--------------------------------------------------------------------------
880UInt_t PRunListCollection::GetNoOfBinsFitted(const UInt_t idx) const
881{
882 UInt_t result = 0;
883
884 if (idx > fMsrInfo->GetMsrRunList()->size()) {
885 std::cerr << ">> PRunListCollection::GetNoOfBinsFitted() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << std::endl << std::endl;
886 return result;
887 }
888
889 UInt_t subIdx = 0;
890 Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
891 if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
892 type = fMsrInfo->GetMsrGlobal()->GetFitType();
893 subIdx = idx;
894 } else { // found in the RUN block
895 // count how many entries of this fit-type are present up to idx
896 for (UInt_t i=0; i<idx; i++) {
897 if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
898 subIdx++;
899 }
900 }
901
902 // return the chisq of the single run
903 switch (type) {
905 result = fRunSingleHistoList[subIdx]->GetNoOfFitBins();
906 break;
908 result = fRunSingleHistoRRFList[subIdx]->GetNoOfFitBins();
909 break;
910 case PRUN_ASYMMETRY:
911 result = fRunAsymmetryList[subIdx]->GetNoOfFitBins();
912 break;
914 result = fRunAsymmetryRRFList[subIdx]->GetNoOfFitBins();
915 break;
917 result = fRunAsymmetryBNMRList[subIdx]->GetNoOfFitBins();
918 break;
919 case PRUN_MU_MINUS:
920 result = fRunMuMinusList[subIdx]->GetNoOfFitBins();
921 break;
922 case PRUN_NON_MUSR:
923 result = fRunNonMusrList[subIdx]->GetNoOfFitBins();
924 break;
925 default:
926 break;
927 }
928
929 return result;
930}
931
932
933//--------------------------------------------------------------------------
934// GetTotalNoOfBinsFitted (public)
935//--------------------------------------------------------------------------
943{
944 UInt_t counts = 0;
945
946 for (UInt_t i=0; i<fRunSingleHistoList.size(); i++)
947 counts += fRunSingleHistoList[i]->GetNoOfFitBins();
948
949 for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
950 counts += fRunSingleHistoRRFList[i]->GetNoOfFitBins();
951
952 for (UInt_t i=0; i<fRunAsymmetryList.size(); i++)
953 counts += fRunAsymmetryList[i]->GetNoOfFitBins();
954
955 for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
956 counts += fRunAsymmetryRRFList[i]->GetNoOfFitBins();
957
958 for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++)
959 counts += fRunAsymmetryBNMRList[i]->GetNoOfFitBins();
960
961 for (UInt_t i=0; i<fRunMuMinusList.size(); i++)
962 counts += fRunMuMinusList[i]->GetNoOfFitBins();
963
964 for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
965 counts += fRunNonMusrList[i]->GetNoOfFitBins();
966
967 return counts;
968}
969
970//--------------------------------------------------------------------------
971// GetSingleHisto (public)
972//--------------------------------------------------------------------------
984{
985 PRunData *data = nullptr;
986
987 switch (tag) {
988 case kIndex:
989 if (index >= fRunSingleHistoList.size()) {
990 std::cerr << std::endl << ">> PRunListCollection::GetSingleHisto(): **ERROR** index = " << index << " out of bounds";
991 std::cerr << std::endl;
992 return nullptr;
993 }
994
995 fRunSingleHistoList[index]->CalcTheory();
996 data = fRunSingleHistoList[index]->GetData();
997 break;
998 case kRunNo:
999 for (UInt_t i=0; i<fRunSingleHistoList.size(); i++) {
1000 if (fRunSingleHistoList[i]->GetRunNo() == index) {
1001 data = fRunSingleHistoList[i]->GetData();
1002 break;
1003 }
1004 }
1005 break;
1006 default: // error
1007 break;
1008 }
1009
1010 return data;
1011}
1012
1013//--------------------------------------------------------------------------
1014// GetSingleHistoRRF (public)
1015//--------------------------------------------------------------------------
1027{
1028 PRunData *data = nullptr;
1029
1030 switch (tag) {
1031 case kIndex:
1032 if (index >= fRunSingleHistoRRFList.size()) {
1033 std::cerr << std::endl << ">> PRunListCollection::GetSingleHistoRRF(): **ERROR** index = " << index << " out of bounds";
1034 std::cerr << std::endl;
1035 return nullptr;
1036 }
1037
1038 fRunSingleHistoRRFList[index]->CalcTheory();
1039 data = fRunSingleHistoRRFList[index]->GetData();
1040 break;
1041 case kRunNo:
1042 for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++) {
1043 if (fRunSingleHistoRRFList[i]->GetRunNo() == index) {
1044 data = fRunSingleHistoRRFList[i]->GetData();
1045 break;
1046 }
1047 }
1048 break;
1049 default: // error
1050 break;
1051 }
1052
1053 return data;
1054}
1055
1056//--------------------------------------------------------------------------
1057// GetAsymmetry (public)
1058//--------------------------------------------------------------------------
1070{
1071 PRunData *data = nullptr;
1072
1073 switch (tag) {
1074 case kIndex: // called from musrfit when dumping the data
1075 if (index > fRunAsymmetryList.size()) {
1076 std::cerr << std::endl << ">> PRunListCollection::GetAsymmetry(): **ERROR** index = " << index << " out of bounds";
1077 std::cerr << std::endl;
1078 return nullptr;
1079 }
1080
1081 fRunAsymmetryList[index]->CalcTheory();
1082 data = fRunAsymmetryList[index]->GetData();
1083 break;
1084 case kRunNo: // called from PMusrCanvas
1085 for (UInt_t i=0; i<fRunAsymmetryList.size(); i++) {
1086 if (fRunAsymmetryList[i]->GetRunNo() == index) {
1087 data = fRunAsymmetryList[i]->GetData();
1088 break;
1089 }
1090 }
1091 break;
1092 default: // error
1093 break;
1094 }
1095
1096 return data;
1097}
1098
1099//--------------------------------------------------------------------------
1100// GetAsymmetryBNMR (public)
1101//--------------------------------------------------------------------------
1113{
1114 PRunData *data = 0;
1115
1116 switch (tag) {
1117 case kIndex: // called from musrfit when dumping the data
1118 if (index > fRunAsymmetryBNMRList.size()) {
1119 std::cerr << std::endl << ">> PRunListCollection::GetAsymmetryBNMR(): **ERROR** index = " << index << " out of bounds";
1120 std::cerr << std::endl;
1121 return 0;
1122 }
1123
1124 fRunAsymmetryBNMRList[index]->CalcTheory();
1125 data = fRunAsymmetryBNMRList[index]->GetData();
1126 break;
1127 case kRunNo: // called from PMusrCanvas
1128 for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++) {
1129 if (fRunAsymmetryBNMRList[i]->GetRunNo() == index) {
1130 data = fRunAsymmetryBNMRList[i]->GetData();
1131 break;
1132 }
1133 }
1134 break;
1135 default: // error
1136 break;
1137 }
1138
1139 return data;
1140}
1141
1142//--------------------------------------------------------------------------
1143// GetAsymmetryRRF (public)
1144//--------------------------------------------------------------------------
1156{
1157 PRunData *data = nullptr;
1158
1159 switch (tag) {
1160 case kIndex: // called from musrfit when dumping the data
1161 if (index > fRunAsymmetryRRFList.size()) {
1162 std::cerr << std::endl << ">> PRunListCollection::GetAsymmetryRRF(): **ERROR** index = " << index << " out of bounds";
1163 std::cerr << std::endl;
1164 return nullptr;
1165 }
1166
1167 fRunAsymmetryRRFList[index]->CalcTheory();
1168 data = fRunAsymmetryRRFList[index]->GetData();
1169 break;
1170 case kRunNo: // called from PMusrCanvas
1171 for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++) {
1172 if (fRunAsymmetryRRFList[i]->GetRunNo() == index) {
1173 data = fRunAsymmetryRRFList[i]->GetData();
1174 break;
1175 }
1176 }
1177 break;
1178 default: // error
1179 break;
1180 }
1181
1182 return data;
1183}
1184
1185//--------------------------------------------------------------------------
1186// GetMuMinus (public)
1187//--------------------------------------------------------------------------
1199{
1200 PRunData *data = nullptr;
1201
1202 switch (tag) {
1203 case kIndex:
1204 if (index > fRunMuMinusList.size()) {
1205 std::cerr << std::endl << ">> PRunListCollection::GetMuMinus(): **ERROR** index = " << index << " out of bounds";
1206 std::cerr << std::endl;
1207 return nullptr;
1208 }
1209 fRunMuMinusList[index]->CalcTheory();
1210 data = fRunMuMinusList[index]->GetData();
1211 break;
1212 case kRunNo:
1213 for (UInt_t i=0; i<fRunMuMinusList.size(); i++) {
1214 if (fRunMuMinusList[i]->GetRunNo() == index) {
1215 data = fRunMuMinusList[i]->GetData();
1216 break;
1217 }
1218 }
1219 break;
1220 default: // error
1221 break;
1222 }
1223
1224 return data;
1225}
1226
1227//--------------------------------------------------------------------------
1228// GetNonMusr (public)
1229//--------------------------------------------------------------------------
1241{
1242 PRunData *data = nullptr;
1243
1244 switch (tag) {
1245 case kIndex:
1246 if (index > fRunNonMusrList.size()) {
1247 std::cerr << std::endl << ">> PRunListCollection::GetNonMusr(): **ERROR** index = " << index << " out of bounds";
1248 std::cerr << std::endl;
1249 return nullptr;
1250 }
1251 break;
1252 case kRunNo:
1253 for (UInt_t i=0; i<fRunNonMusrList.size(); i++) {
1254 if (fRunNonMusrList[i]->GetRunNo() == index) {
1255 data = fRunNonMusrList[i]->GetData();
1256 break;
1257 }
1258 }
1259 break;
1260 default: // error
1261 break;
1262 }
1263
1264 return data;
1265}
1266
1267//--------------------------------------------------------------------------
1268// GetTemp (public)
1269//--------------------------------------------------------------------------
1278const PDoublePairVector* PRunListCollection::GetTemp(const TString &runName) const
1279{
1280 return fData->GetRunData(runName)->GetTemperature();
1281}
1282
1283//--------------------------------------------------------------------------
1284// GetField (public)
1285//--------------------------------------------------------------------------
1294Double_t PRunListCollection::GetField(const TString &runName) const
1295{
1296 return fData->GetRunData(runName)->GetField();
1297}
1298
1299//--------------------------------------------------------------------------
1300// GetEnergy (public)
1301//--------------------------------------------------------------------------
1310Double_t PRunListCollection::GetEnergy(const TString &runName) const
1311{
1312 return fData->GetRunData(runName)->GetEnergy();
1313}
1314
1315//--------------------------------------------------------------------------
1316// GetSetup (public)
1317//--------------------------------------------------------------------------
1326const Char_t* PRunListCollection::GetSetup(const TString &runName) const
1327{
1328 return fData->GetRunData(runName)->GetSetup()->Data();
1329}
1330
1331//--------------------------------------------------------------------------
1332// GetXAxisTitle (public)
1333//--------------------------------------------------------------------------
1343const Char_t* PRunListCollection::GetXAxisTitle(const TString &runName, const UInt_t idx) const
1344{
1345 PRawRunData *runData = fData->GetRunData(runName);
1346
1347 const Char_t *result = nullptr;
1348
1349 if (runData->fDataNonMusr.FromAscii()) {
1350 result = runData->fDataNonMusr.GetLabels()->at(0).Data();
1351 } else {
1352 for (UInt_t i=0; i<fRunNonMusrList.size(); i++) {
1353 if (fRunNonMusrList[i]->GetRunNo() == idx) {
1354 Int_t index = fRunNonMusrList[i]->GetXIndex();
1355 result = runData->fDataNonMusr.GetLabels()->at(index).Data();
1356 break;
1357 }
1358 }
1359 }
1360
1361 return result;
1362}
1363
1364//--------------------------------------------------------------------------
1365// GetYAxisTitle (public)
1366//--------------------------------------------------------------------------
1376const Char_t* PRunListCollection::GetYAxisTitle(const TString &runName, const UInt_t idx) const
1377{
1378 PRawRunData *runData = fData->GetRunData(runName);
1379
1380 const Char_t *result = nullptr;
1381
1382 if (runData->fDataNonMusr.FromAscii()) {
1383 result = runData->fDataNonMusr.GetLabels()->at(1).Data();
1384 } else {
1385 for (UInt_t i=0; i<fRunNonMusrList.size(); i++) {
1386 if (fRunNonMusrList[i]->GetRunNo() == idx) {
1387 Int_t index = fRunNonMusrList[i]->GetYIndex();
1388 result = runData->fDataNonMusr.GetLabels()->at(index).Data();
1389 break;
1390 }
1391 }
1392 }
1393
1394 return result;
1395}
1396
#define PRUN_ASYMMETRY
Asymmetry fit using forward and backward detectors.
Definition PMusr.h:89
#define PRUN_MU_MINUS
Negative muon (μ-) single histogram fit.
Definition PMusr.h:93
EPMusrHandleTag
Definition PMusr.h:413
#define PRUN_ASYMMETRY_RRF
Asymmetry fit in rotating reference frame (RRF)
Definition PMusr.h:91
#define PRUN_SINGLE_HISTO_RRF
Single histogram fit in rotating reference frame (RRF)
Definition PMusr.h:87
std::vector< PDoublePair > PDoublePairVector
Definition PMusr.h:397
#define PRUN_NON_MUSR
Non-μSR data fit (general x-y data)
Definition PMusr.h:97
#define PRUN_SINGLE_HISTO
Single histogram fit (e.g., forward or backward detector)
Definition PMusr.h:85
#define PRUN_ASYMMETRY_BNMR
Beta-detected NMR asymmetry fit.
Definition PMusr.h:95
MSR file parser and manager for the musrfit framework.
virtual const PStringVector * GetLabels()
Returns pointer to vector of axis/column labels.
Definition PMusr.h:554
virtual Bool_t FromAscii()
Returns true if data was loaded from ASCII file, false for db/dat format.
Definition PMusr.h:552
PNonMusrRawRunData fDataNonMusr
keeps all ascii- or db-file info in case of nonMusr fit
Definition PMusr.h:923
Class for handling β-NMR asymmetry fits.
Class for handling μSR asymmetry fits in the Rotating Reference Frame (RRF).
Class for handling standard μSR asymmetry fits.
Raw data file reader and format converter for μSR data.
virtual Double_t GetSingleRunMaximumLikelihood(const std::vector< Double_t > &par, const UInt_t idx) const
Calculates maximum likelihood for a single run.
virtual Double_t GetField(const TString &runName) const
Retrieves magnetic field value for a specific run.
virtual void SetFitRange(const PDoublePairVector fitRange)
Sets fit range for all runs (time-based or bin-based).
virtual PRunData * GetSingleHisto(UInt_t index, EDataSwitch tag=kIndex)
Retrieves processed data for a single histogram run.
virtual Double_t GetAsymmetryBNMRMaximumLikelihood(const std::vector< Double_t > &par) const
Calculates total maximum likelihood for all β-NMR asymmetry runs.
std::vector< PRunNonMusr * > fRunNonMusrList
Collection of non-μSR run objects.
virtual Double_t GetAsymmetryBNMRChisq(const std::vector< Double_t > &par) const
Calculates total χ² for all β-NMR asymmetry runs.
virtual Double_t GetMuMinusMaximumLikelihood(const std::vector< Double_t > &par) const
Calculates total maximum likelihood for all μ⁻ runs.
virtual PRunData * GetSingleHistoRRF(UInt_t index, EDataSwitch tag=kIndex)
Retrieves processed data for a single histogram RRF run.
virtual const Char_t * GetSetup(const TString &runName) const
Retrieves experimental setup identifier for a specific run.
virtual PRunData * GetNonMusr(UInt_t index, EDataSwitch tag=kIndex)
Retrieves processed data for a non-μSR run.
virtual const PDoublePairVector * GetTemp(const TString &runName) const
Retrieves temperature information for a specific run.
std::vector< PRunAsymmetry * > fRunAsymmetryList
Collection of asymmetry run objects.
virtual Double_t GetAsymmetryRRFMaximumLikelihood(const std::vector< Double_t > &par) const
Calculates total maximum likelihood for all asymmetry RRF runs.
EDataSwitch
Enumeration for data access mode.
virtual UInt_t GetNoOfBinsFitted(const UInt_t idx) const
Returns the number of bins fitted for a specific run.
virtual ~PRunListCollection()
Virtual destructor that cleans up all run objects.
virtual const Char_t * GetXAxisTitle(const TString &runName, const UInt_t idx) const
Retrieves x-axis label for plotting.
std::vector< PRunAsymmetryRRF * > fRunAsymmetryRRFList
Collection of asymmetry RRF run objects.
std::vector< PRunMuMinus * > fRunMuMinusList
Collection of μ⁻ (negative muon) run objects.
virtual Double_t GetNonMusrChisq(const std::vector< Double_t > &par) const
Calculates total χ² for all non-μSR runs.
virtual Double_t GetSingleHistoMaximumLikelihood(const std::vector< Double_t > &par) const
Calculates total maximum likelihood for all single histogram runs.
virtual Double_t GetEnergy(const TString &runName) const
Retrieves beam energy for a specific run.
virtual Double_t GetSingleHistoChisq(const std::vector< Double_t > &par) const
Calculates total χ² for all single histogram runs.
PRunDataHandler * fData
Pointer to raw data handler (not owned).
virtual Double_t GetSingleRunChisqExpected(const std::vector< Double_t > &par, const UInt_t idx) const
Calculates expected χ² for a single run by index.
virtual PRunData * GetAsymmetry(UInt_t index, EDataSwitch tag=kIndex)
Retrieves processed data for an asymmetry run.
std::vector< PRunSingleHistoRRF * > fRunSingleHistoRRFList
Collection of single histogram RRF run objects.
virtual Double_t GetSingleRunChisq(const std::vector< Double_t > &par, const UInt_t idx) const
Calculates χ² for a single run by index.
virtual Double_t GetAsymmetryRRFChisq(const std::vector< Double_t > &par) const
Calculates total χ² for all asymmetry RRF runs.
virtual Double_t GetSingleHistoRRFMaximumLikelihood(const std::vector< Double_t > &par) const
Calculates total maximum likelihood for all single histogram RRF runs.
virtual Double_t GetSingleHistoRRFChisq(const std::vector< Double_t > &par) const
Calculates total χ² for all single histogram RRF runs.
std::vector< PRunAsymmetryBNMR * > fRunAsymmetryBNMRList
Collection of β-NMR asymmetry run objects.
PMsrHandler * fMsrInfo
Pointer to MSR file handler (not owned).
virtual const Char_t * GetYAxisTitle(const TString &runName, const UInt_t idx) const
Retrieves y-axis label for plotting.
virtual Double_t GetAsymmetryChisq(const std::vector< Double_t > &par) const
Calculates total χ² for all asymmetry runs.
virtual UInt_t GetTotalNoOfBinsFitted() const
Returns total number of bins fitted across all runs.
Bool_t fTheoAsData
Theory calculation mode flag.
virtual Double_t GetSingleRunMaximumLikelihoodExpected(const std::vector< Double_t > &par, const UInt_t idx) const
Calculates expected maximum likelihood for a single run (theoretical expectation).
virtual PRunData * GetMuMinus(UInt_t index, EDataSwitch tag=kIndex)
Retrieves processed data for a μ⁻ run.
virtual Double_t GetMuMinusChisq(const std::vector< Double_t > &par) const
Calculates total χ² for all mu-minus runs.
PRunListCollection(PMsrHandler *msrInfo, PRunDataHandler *data, Bool_t theoAsdata=false)
Constructor that initializes the collection.
virtual Double_t GetNonMusrMaximumLikelihood(const std::vector< Double_t > &par) const
Calculates total maximum likelihood for all non-μSR runs.
std::vector< PRunSingleHisto * > fRunSingleHistoList
Collection of single histogram run objects.
virtual Double_t GetAsymmetryMaximumLikelihood(const std::vector< Double_t > &par) const
Calculates total maximum likelihood for all asymmetry runs.
virtual PRunData * GetAsymmetryRRF(UInt_t index, EDataSwitch tag=kIndex)
Retrieves processed data for an asymmetry RRF run.
virtual PRunData * GetAsymmetryBNMR(UInt_t index, EDataSwitch tag=kIndex)
Retrieves processed data for a β-NMR asymmetry run.
virtual Bool_t Add(Int_t runNo, EPMusrHandleTag tag)
Adds a run to the appropriate list based on fit type.
Class for handling negative muon (μ⁻) histogram fits.
Definition PRunMuMinus.h:98
Class for fitting general x-y data sets (non-μSR time series).
Class for fitting single histogram data in a Rotating Reference Frame (RRF).
Class for fitting single detector histograms (basic time-differential μSR).