musrfit  1.9.2
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-2023 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 //--------------------------------------------------------------------------
44  fMsrInfo(msrInfo), fData(data), fTheoAsData(theoAsData)
45 {
46 }
47 
48 //--------------------------------------------------------------------------
49 // Destructor
50 //--------------------------------------------------------------------------
55 {
56  for (UInt_t i=0; i<fRunSingleHistoList.size(); i++) {
57  fRunSingleHistoList[i]->CleanUp();
58  fRunSingleHistoList[i]->~PRunSingleHisto();
59  }
60  fRunSingleHistoList.clear();
61 
62  for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++) {
63  fRunSingleHistoRRFList[i]->CleanUp();
64  fRunSingleHistoRRFList[i]->~PRunSingleHistoRRF();
65  }
66  fRunSingleHistoRRFList.clear();
67 
68  for (UInt_t i=0; i<fRunAsymmetryList.size(); i++) {
69  fRunAsymmetryList[i]->CleanUp();
70  fRunAsymmetryList[i]->~PRunAsymmetry();
71  }
72  fRunAsymmetryList.clear();
73 
74  for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++) {
75  fRunAsymmetryRRFList[i]->CleanUp();
76  fRunAsymmetryRRFList[i]->~PRunAsymmetryRRF();
77  }
78  fRunAsymmetryRRFList.clear();
79 
80  for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++) {
81  fRunAsymmetryBNMRList[i]->CleanUp();
82  fRunAsymmetryBNMRList[i]->~PRunAsymmetryBNMR();
83  }
84  fRunAsymmetryBNMRList.clear();
85 
86  for (UInt_t i=0; i<fRunMuMinusList.size(); i++) {
87  fRunMuMinusList[i]->CleanUp();
88  fRunMuMinusList[i]->~PRunMuMinus();
89  }
90  fRunMuMinusList.clear();
91 
92  for (UInt_t i=0; i<fRunNonMusrList.size(); i++) {
93  fRunNonMusrList[i]->CleanUp();
94  fRunNonMusrList[i]->~PRunNonMusr();
95  }
96  fRunNonMusrList.clear();
97 }
98 
99 //--------------------------------------------------------------------------
100 // Add (public)
101 //--------------------------------------------------------------------------
112 Bool_t PRunListCollection::Add(Int_t runNo, EPMusrHandleTag tag)
113 {
114  Bool_t success = true;
115 
116  // try to get the fit type from the RUN block
117  Int_t fitType = (*fMsrInfo->GetMsrRunList())[runNo].GetFitType();
118  if (fitType == -1) { // fit type NOT given in the RUN block, check the GLOBAL block
119  fitType = (*fMsrInfo->GetMsrGlobal()).GetFitType();
120  }
121 
122  switch (fitType) {
123  case PRUN_SINGLE_HISTO:
124  fRunSingleHistoList.push_back(new PRunSingleHisto(fMsrInfo, fData, runNo, tag, fTheoAsData));
125  if (!fRunSingleHistoList[fRunSingleHistoList.size()-1]->IsValid())
126  success = false;
127  break;
130  if (!fRunSingleHistoRRFList[fRunSingleHistoRRFList.size()-1]->IsValid())
131  success = false;
132  break;
133  case PRUN_ASYMMETRY:
134  fRunAsymmetryList.push_back(new PRunAsymmetry(fMsrInfo, fData, runNo, tag, fTheoAsData));
135  if (!fRunAsymmetryList[fRunAsymmetryList.size()-1]->IsValid())
136  success = false;
137  break;
138  case PRUN_ASYMMETRY_RRF:
139  fRunAsymmetryRRFList.push_back(new PRunAsymmetryRRF(fMsrInfo, fData, runNo, tag, fTheoAsData));
140  if (!fRunAsymmetryRRFList[fRunAsymmetryRRFList.size()-1]->IsValid())
141  success = false;
142  break;
143  case PRUN_ASYMMETRY_BNMR:
144  fRunAsymmetryBNMRList.push_back(new PRunAsymmetryBNMR(fMsrInfo, fData, runNo, tag, fTheoAsData));
145  if (!fRunAsymmetryBNMRList[fRunAsymmetryBNMRList.size()-1]->IsValid())
146  success = false;
147  break;
148  case PRUN_MU_MINUS:
149  fRunMuMinusList.push_back(new PRunMuMinus(fMsrInfo, fData, runNo, tag, fTheoAsData));
150  if (!fRunMuMinusList[fRunMuMinusList.size()-1]->IsValid())
151  success = false;
152  break;
153  case PRUN_NON_MUSR:
154  fRunNonMusrList.push_back(new PRunNonMusr(fMsrInfo, fData, runNo, tag, fTheoAsData));
155  if (!fRunNonMusrList[fRunNonMusrList.size()-1]->IsValid())
156  success = false;
157  break;
158  default:
159  success = false;
160  break;
161  }
162 
163  return success;
164 }
165 
166 //--------------------------------------------------------------------------
167 // SetFitRange (public)
168 //--------------------------------------------------------------------------
180 void PRunListCollection::SetFitRange(const TString fitRange)
181 {
182  for (UInt_t i=0; i<fRunSingleHistoList.size(); i++)
183  fRunSingleHistoList[i]->SetFitRangeBin(fitRange);
184  for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
185  fRunSingleHistoRRFList[i]->SetFitRangeBin(fitRange);
186  for (UInt_t i=0; i<fRunAsymmetryList.size(); i++)
187  fRunAsymmetryList[i]->SetFitRangeBin(fitRange);
188  for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
189  fRunAsymmetryRRFList[i]->SetFitRangeBin(fitRange);
190  for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++)
191  fRunAsymmetryBNMRList[i]->SetFitRangeBin(fitRange);
192  for (UInt_t i=0; i<fRunMuMinusList.size(); i++)
193  fRunMuMinusList[i]->SetFitRangeBin(fitRange);
194  for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
195  fRunNonMusrList[i]->SetFitRangeBin(fitRange);
196 }
197 
198 //--------------------------------------------------------------------------
199 // SetFitRange (public)
200 //--------------------------------------------------------------------------
209 {
210  for (UInt_t i=0; i<fRunSingleHistoList.size(); i++) {
211  fRunSingleHistoList[i]->SetFitRange(fitRange);
212  fRunSingleHistoList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
213  }
214  for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++) {
215  fRunSingleHistoRRFList[i]->SetFitRange(fitRange);
216  fRunSingleHistoRRFList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
217  }
218  for (UInt_t i=0; i<fRunAsymmetryList.size(); i++) {
219  fRunAsymmetryList[i]->SetFitRange(fitRange);
220  fRunAsymmetryList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
221  }
222  for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++) {
223  fRunAsymmetryRRFList[i]->SetFitRange(fitRange);
224  fRunAsymmetryRRFList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
225  }
226  for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++) {
227  fRunAsymmetryBNMRList[i]->SetFitRange(fitRange);
228  fRunAsymmetryBNMRList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
229  }
230  for (UInt_t i=0; i<fRunMuMinusList.size(); i++) {
231  fRunMuMinusList[i]->SetFitRange(fitRange);
232  fRunMuMinusList[i]->CalcNoOfFitBins(); // needed to update fStartTimeBin, fEndTimeBin
233  }
234  for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
235  fRunNonMusrList[i]->SetFitRange(fitRange);
236 }
237 
238 //--------------------------------------------------------------------------
239 // GetSingleHistoChisq (public)
240 //--------------------------------------------------------------------------
249 Double_t PRunListCollection::GetSingleHistoChisq(const std::vector<Double_t>& par) const
250 {
251  Double_t chisq = 0.0;
252 
253  for (UInt_t i=0; i<fRunSingleHistoList.size(); i++)
254  chisq += fRunSingleHistoList[i]->CalcChiSquare(par);
255 
256  return chisq;
257 }
258 
259 //--------------------------------------------------------------------------
260 // GetSingleHistoRRFChisq (public)
261 //--------------------------------------------------------------------------
270 Double_t PRunListCollection::GetSingleHistoRRFChisq(const std::vector<Double_t>& par) const
271 {
272  Double_t chisq = 0.0;
273 
274  for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
275  chisq += fRunSingleHistoRRFList[i]->CalcChiSquare(par);
276 
277  return chisq;
278 }
279 
280 //--------------------------------------------------------------------------
281 // GetAsymmetryChisq (public)
282 //--------------------------------------------------------------------------
291 Double_t PRunListCollection::GetAsymmetryChisq(const std::vector<Double_t>& par) const
292 {
293  Double_t chisq = 0.0;
294 
295  for (UInt_t i=0; i<fRunAsymmetryList.size(); i++)
296  chisq += fRunAsymmetryList[i]->CalcChiSquare(par);
297 
298  return chisq;
299 }
300 
301 //--------------------------------------------------------------------------
302 // GetAsymmetryRRFChisq (public)
303 //--------------------------------------------------------------------------
312 Double_t PRunListCollection::GetAsymmetryRRFChisq(const std::vector<Double_t>& par) const
313 {
314  Double_t chisq = 0.0;
315 
316  for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
317  chisq += fRunAsymmetryRRFList[i]->CalcChiSquare(par);
318 
319  return chisq;
320 }
321 
322 //--------------------------------------------------------------------------
323 // GetAsymmetryBNMRChisq (public)
324 //--------------------------------------------------------------------------
333 Double_t PRunListCollection::GetAsymmetryBNMRChisq(const std::vector<Double_t>& par) const
334 {
335  Double_t chisq = 0.0;
336 
337  for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++)
338  chisq += fRunAsymmetryBNMRList[i]->CalcChiSquare(par);
339 
340  return chisq;
341 }
342 
343 //--------------------------------------------------------------------------
344 // GetMuMinusChisq (public)
345 //--------------------------------------------------------------------------
354 Double_t PRunListCollection::GetMuMinusChisq(const std::vector<Double_t>& par) const
355 {
356  Double_t chisq = 0.0;
357 
358  for (UInt_t i=0; i<fRunMuMinusList.size(); i++)
359  chisq += fRunMuMinusList[i]->CalcChiSquare(par);
360 
361  return chisq;
362 }
363 
364 //--------------------------------------------------------------------------
365 // GetNonMusrChisq (public)
366 //--------------------------------------------------------------------------
375 Double_t PRunListCollection::GetNonMusrChisq(const std::vector<Double_t>& par) const
376 {
377  Double_t chisq = 0.0;
378 
379  for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
380  chisq += fRunNonMusrList[i]->CalcChiSquare(par);
381 
382  return chisq;
383 }
384 
385 //--------------------------------------------------------------------------
386 // GetSingleRunChisqExpected (public)
387 //--------------------------------------------------------------------------
397 Double_t PRunListCollection::GetSingleRunChisqExpected(const std::vector<Double_t>& par, const UInt_t idx) const
398 {
399  Double_t expectedChisq = 0.0;
400 
401  if (idx > fMsrInfo->GetMsrRunList()->size()) {
402  std::cerr << ">> PRunListCollection::GetSingleRunChisqExpected() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << std::endl << std::endl;
403  return expectedChisq;
404  }
405 
406  UInt_t subIdx = 0;
407  Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
408  if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
409  type = fMsrInfo->GetMsrGlobal()->GetFitType();
410  subIdx = idx;
411  } else { // found in the RUN block
412  // count how many entries of this fit-type are present up to idx
413  for (UInt_t i=0; i<idx; i++) {
414  if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
415  subIdx++;
416  }
417  }
418 
419 
420  // return the chisq of the single run
421  switch (type) {
422  case PRUN_SINGLE_HISTO:
423  expectedChisq = fRunSingleHistoList[subIdx]->CalcChiSquareExpected(par);
424  break;
426  expectedChisq = fRunSingleHistoRRFList[subIdx]->CalcChiSquareExpected(par);
427  break;
428  case PRUN_ASYMMETRY:
429  expectedChisq = fRunAsymmetryList[subIdx]->CalcChiSquareExpected(par);
430  break;
431  case PRUN_ASYMMETRY_RRF:
432  expectedChisq = fRunAsymmetryRRFList[subIdx]->CalcChiSquareExpected(par);
433  break;
434  case PRUN_ASYMMETRY_BNMR:
435  expectedChisq = fRunAsymmetryBNMRList[subIdx]->CalcChiSquareExpected(par);
436  break;
437  case PRUN_MU_MINUS:
438  expectedChisq = fRunMuMinusList[subIdx]->CalcChiSquareExpected(par);
439  break;
440  case PRUN_NON_MUSR:
441  expectedChisq = fRunNonMusrList[subIdx]->CalcChiSquareExpected(par);
442  break;
443  default:
444  break;
445  }
446 
447  return expectedChisq;
448 }
449 
450 //--------------------------------------------------------------------------
451 // GetSingleRunChisq (public)
452 //--------------------------------------------------------------------------
462 Double_t PRunListCollection::GetSingleRunChisq(const std::vector<Double_t>& par, const UInt_t idx) const
463 {
464  Double_t chisq = 0.0;
465 
466  if (idx > fMsrInfo->GetMsrRunList()->size()) {
467  std::cerr << ">> PRunListCollection::GetSingleRunChisq() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << std::endl << std::endl;
468  return chisq;
469  }
470 
471  Int_t subIdx = 0;
472  Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
473  if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
474  type = fMsrInfo->GetMsrGlobal()->GetFitType();
475  subIdx = idx;
476  } else { // found in the RUN block
477  // count how many entries of this fit-type are present up to idx
478  for (UInt_t i=0; i<idx; i++) {
479  if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
480  subIdx++;
481  }
482  }
483 
484  // return the chisq of the single run
485  switch (type) {
486  case PRUN_SINGLE_HISTO:
487  chisq = fRunSingleHistoList[subIdx]->CalcChiSquare(par);
488  break;
490  chisq = fRunSingleHistoRRFList[subIdx]->CalcChiSquare(par);
491  break;
492  case PRUN_ASYMMETRY:
493  chisq = fRunAsymmetryList[subIdx]->CalcChiSquare(par);
494  break;
495  case PRUN_ASYMMETRY_RRF:
496  chisq = fRunAsymmetryRRFList[subIdx]->CalcChiSquare(par);
497  break;
498  case PRUN_ASYMMETRY_BNMR:
499  chisq = fRunAsymmetryBNMRList[subIdx]->CalcChiSquare(par);
500  break;
501  case PRUN_MU_MINUS:
502  chisq = fRunMuMinusList[subIdx]->CalcChiSquare(par);
503  break;
504  case PRUN_NON_MUSR:
505  chisq = fRunNonMusrList[subIdx]->CalcChiSquare(par);
506  break;
507  default:
508  break;
509  }
510 
511  return chisq;
512 }
513 
514 //--------------------------------------------------------------------------
515 // GetSingleHistoMaximumLikelihood (public)
516 //--------------------------------------------------------------------------
525 Double_t PRunListCollection::GetSingleHistoMaximumLikelihood(const std::vector<Double_t>& par) const
526 {
527  Double_t mlh = 0.0;
528 
529  for (UInt_t i=0; i<fRunSingleHistoList.size(); i++)
530  mlh += fRunSingleHistoList[i]->CalcMaxLikelihood(par);
531 
532  return mlh;
533 }
534 
535 //--------------------------------------------------------------------------
536 // GetSingleHistoRRFMaximumLikelihood (public)
537 //--------------------------------------------------------------------------
546 Double_t PRunListCollection::GetSingleHistoRRFMaximumLikelihood(const std::vector<Double_t>& par) const
547 {
548  Double_t mlh = 0.0;
549 
550  for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
551  mlh += fRunSingleHistoRRFList[i]->CalcMaxLikelihood(par);
552 
553  return mlh;
554 }
555 
556 //--------------------------------------------------------------------------
557 // GetAsymmetryMaximumLikelihood (public)
558 //--------------------------------------------------------------------------
568 Double_t PRunListCollection::GetAsymmetryMaximumLikelihood(const std::vector<Double_t>& par) const
569 {
570  Double_t mlh = 0.0;
571 
572  for (UInt_t i=0; i<fRunAsymmetryList.size(); i++)
573  mlh += fRunAsymmetryList[i]->CalcChiSquare(par);
574 
575  return mlh;
576 }
577 
578 //--------------------------------------------------------------------------
579 // GetAsymmetryRRFMaximumLikelihood (public)
580 //--------------------------------------------------------------------------
590 Double_t PRunListCollection::GetAsymmetryRRFMaximumLikelihood(const std::vector<Double_t>& par) const
591 {
592  Double_t mlh = 0.0;
593 
594  for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
595  mlh += fRunAsymmetryRRFList[i]->CalcChiSquare(par);
596 
597  return mlh;
598 }
599 
600 //--------------------------------------------------------------------------
601 // GetAsymmetryBNMRMaximumLikelihood (public)
602 //--------------------------------------------------------------------------
612 Double_t PRunListCollection::GetAsymmetryBNMRMaximumLikelihood(const std::vector<Double_t>& par) const
613 {
614  Double_t mlh = 0.0;
615 
616  for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++)
617  mlh += fRunAsymmetryBNMRList[i]->CalcChiSquare(par);
618 
619  return mlh;
620 }
621 
622 //--------------------------------------------------------------------------
623 // GetMuMinusMaximumLikelihood (public)
624 //--------------------------------------------------------------------------
633 Double_t PRunListCollection::GetMuMinusMaximumLikelihood(const std::vector<Double_t>& par) const
634 {
635  Double_t mlh = 0.0;
636 
637  for (UInt_t i=0; i<fRunMuMinusList.size(); i++)
638  mlh += fRunMuMinusList[i]->CalcMaxLikelihood(par);
639 
640  return mlh;
641 }
642 
643 //--------------------------------------------------------------------------
644 // GetNonMusrMaximumLikelihood (public)
645 //--------------------------------------------------------------------------
655 Double_t PRunListCollection::GetNonMusrMaximumLikelihood(const std::vector<Double_t>& par) const
656 {
657  Double_t mlh = 0.0;
658 
659  for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
660  mlh += fRunNonMusrList[i]->CalcChiSquare(par);
661 
662  return mlh;
663 }
664 
665 //--------------------------------------------------------------------------
666 // GetSingleRunMaximumLikelihoodExpected (public)
667 //--------------------------------------------------------------------------
677 Double_t PRunListCollection::GetSingleRunMaximumLikelihoodExpected(const std::vector<Double_t>& par, const UInt_t idx) const
678 {
679  Double_t expected_mlh = 0.0;
680 
681  if (idx > fMsrInfo->GetMsrRunList()->size()) {
682  std::cerr << ">> PRunListCollection::GetSingleRunMaximumLikelihoodExpected() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << std::endl << std::endl;
683  return expected_mlh;
684  }
685 
686  UInt_t subIdx = 0;
687  Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
688  if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
689  type = fMsrInfo->GetMsrGlobal()->GetFitType();
690  subIdx = idx;
691  } else { // found in the RUN block
692  // count how many entries of this fit-type are present up to idx
693  for (UInt_t i=0; i<idx; i++) {
694  if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
695  subIdx++;
696  }
697  }
698 
699  // return the mlh of the single run
700  switch (type) {
701  case PRUN_SINGLE_HISTO:
702  expected_mlh = fRunSingleHistoList[subIdx]->CalcMaxLikelihoodExpected(par);
703  break;
704  default:
705  break;
706  }
707 
708  return expected_mlh;
709 }
710 
711 //--------------------------------------------------------------------------
712 // GetSingleRunMaximumLikelihood (public)
713 //--------------------------------------------------------------------------
723 Double_t PRunListCollection::GetSingleRunMaximumLikelihood(const std::vector<Double_t>& par, const UInt_t idx) const
724 {
725  Double_t mlh = 0.0;
726 
727  if (idx > fMsrInfo->GetMsrRunList()->size()) {
728  std::cerr << ">> PRunListCollection::GetSingleRunMaximumLikelihood() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << std::endl << std::endl;
729  return mlh;
730  }
731 
732  Int_t subIdx = 0;
733  Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
734  if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
735  type = fMsrInfo->GetMsrGlobal()->GetFitType();
736  subIdx = idx;
737  } else { // found in the RUN block
738  // count how many entries of this fit-type are present up to idx
739  for (UInt_t i=0; i<idx; i++) {
740  if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
741  subIdx++;
742  }
743  }
744 
745  // return the mlh of the single run
746  switch (type) {
747  case PRUN_SINGLE_HISTO:
748  mlh = fRunSingleHistoList[subIdx]->CalcMaxLikelihood(par);
749  break;
750  default:
751  break;
752  }
753 
754  return mlh;
755 }
756 
757 //--------------------------------------------------------------------------
758 // GetNoOfBinsFitted (public)
759 //--------------------------------------------------------------------------
769 UInt_t PRunListCollection::GetNoOfBinsFitted(const UInt_t idx) const
770 {
771  UInt_t result = 0;
772 
773  if (idx > fMsrInfo->GetMsrRunList()->size()) {
774  std::cerr << ">> PRunListCollection::GetNoOfBinsFitted() **ERROR** idx=" << idx << " is out of range [0.." << fMsrInfo->GetMsrRunList()->size() << "[" << std::endl << std::endl;
775  return result;
776  }
777 
778  UInt_t subIdx = 0;
779  Int_t type = fMsrInfo->GetMsrRunList()->at(idx).GetFitType();
780  if (type == -1) { // i.e. not found in the RUN block, try the GLOBAL block
781  type = fMsrInfo->GetMsrGlobal()->GetFitType();
782  subIdx = idx;
783  } else { // found in the RUN block
784  // count how many entries of this fit-type are present up to idx
785  for (UInt_t i=0; i<idx; i++) {
786  if (fMsrInfo->GetMsrRunList()->at(i).GetFitType() == type)
787  subIdx++;
788  }
789  }
790 
791  // return the chisq of the single run
792  switch (type) {
793  case PRUN_SINGLE_HISTO:
794  result = fRunSingleHistoList[subIdx]->GetNoOfFitBins();
795  break;
797  result = fRunSingleHistoRRFList[subIdx]->GetNoOfFitBins();
798  break;
799  case PRUN_ASYMMETRY:
800  result = fRunAsymmetryList[subIdx]->GetNoOfFitBins();
801  break;
802  case PRUN_ASYMMETRY_RRF:
803  result = fRunAsymmetryRRFList[subIdx]->GetNoOfFitBins();
804  break;
805  case PRUN_ASYMMETRY_BNMR:
806  result = fRunAsymmetryBNMRList[subIdx]->GetNoOfFitBins();
807  break;
808  case PRUN_MU_MINUS:
809  result = fRunMuMinusList[subIdx]->GetNoOfFitBins();
810  break;
811  case PRUN_NON_MUSR:
812  result = fRunNonMusrList[subIdx]->GetNoOfFitBins();
813  break;
814  default:
815  break;
816  }
817 
818  return result;
819 }
820 
821 
822 //--------------------------------------------------------------------------
823 // GetTotalNoOfBinsFitted (public)
824 //--------------------------------------------------------------------------
832 {
833  UInt_t counts = 0;
834 
835  for (UInt_t i=0; i<fRunSingleHistoList.size(); i++)
836  counts += fRunSingleHistoList[i]->GetNoOfFitBins();
837 
838  for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++)
839  counts += fRunSingleHistoRRFList[i]->GetNoOfFitBins();
840 
841  for (UInt_t i=0; i<fRunAsymmetryList.size(); i++)
842  counts += fRunAsymmetryList[i]->GetNoOfFitBins();
843 
844  for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++)
845  counts += fRunAsymmetryRRFList[i]->GetNoOfFitBins();
846 
847  for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++)
848  counts += fRunAsymmetryBNMRList[i]->GetNoOfFitBins();
849 
850  for (UInt_t i=0; i<fRunMuMinusList.size(); i++)
851  counts += fRunMuMinusList[i]->GetNoOfFitBins();
852 
853  for (UInt_t i=0; i<fRunNonMusrList.size(); i++)
854  counts += fRunNonMusrList[i]->GetNoOfFitBins();
855 
856  return counts;
857 }
858 
859 //--------------------------------------------------------------------------
860 // GetSingleHisto (public)
861 //--------------------------------------------------------------------------
873 {
874  PRunData *data = nullptr;
875 
876  switch (tag) {
877  case kIndex:
878  if (index >= fRunSingleHistoList.size()) {
879  std::cerr << std::endl << ">> PRunListCollection::GetSingleHisto(): **ERROR** index = " << index << " out of bounds";
880  std::cerr << std::endl;
881  return nullptr;
882  }
883 
884  fRunSingleHistoList[index]->CalcTheory();
885  data = fRunSingleHistoList[index]->GetData();
886  break;
887  case kRunNo:
888  for (UInt_t i=0; i<fRunSingleHistoList.size(); i++) {
889  if (fRunSingleHistoList[i]->GetRunNo() == index) {
890  data = fRunSingleHistoList[i]->GetData();
891  break;
892  }
893  }
894  break;
895  default: // error
896  break;
897  }
898 
899  return data;
900 }
901 
902 //--------------------------------------------------------------------------
903 // GetSingleHistoRRF (public)
904 //--------------------------------------------------------------------------
916 {
917  PRunData *data = nullptr;
918 
919  switch (tag) {
920  case kIndex:
921  if (index >= fRunSingleHistoRRFList.size()) {
922  std::cerr << std::endl << ">> PRunListCollection::GetSingleHistoRRF(): **ERROR** index = " << index << " out of bounds";
923  std::cerr << std::endl;
924  return nullptr;
925  }
926 
927  fRunSingleHistoRRFList[index]->CalcTheory();
928  data = fRunSingleHistoRRFList[index]->GetData();
929  break;
930  case kRunNo:
931  for (UInt_t i=0; i<fRunSingleHistoRRFList.size(); i++) {
932  if (fRunSingleHistoRRFList[i]->GetRunNo() == index) {
933  data = fRunSingleHistoRRFList[i]->GetData();
934  break;
935  }
936  }
937  break;
938  default: // error
939  break;
940  }
941 
942  return data;
943 }
944 
945 //--------------------------------------------------------------------------
946 // GetAsymmetry (public)
947 //--------------------------------------------------------------------------
959 {
960  PRunData *data = nullptr;
961 
962  switch (tag) {
963  case kIndex: // called from musrfit when dumping the data
964  if (index > fRunAsymmetryList.size()) {
965  std::cerr << std::endl << ">> PRunListCollection::GetAsymmetry(): **ERROR** index = " << index << " out of bounds";
966  std::cerr << std::endl;
967  return nullptr;
968  }
969 
970  fRunAsymmetryList[index]->CalcTheory();
971  data = fRunAsymmetryList[index]->GetData();
972  break;
973  case kRunNo: // called from PMusrCanvas
974  for (UInt_t i=0; i<fRunAsymmetryList.size(); i++) {
975  if (fRunAsymmetryList[i]->GetRunNo() == index) {
976  data = fRunAsymmetryList[i]->GetData();
977  break;
978  }
979  }
980  break;
981  default: // error
982  break;
983  }
984 
985  return data;
986 }
987 
988 //--------------------------------------------------------------------------
989 // GetAsymmetryBNMR (public)
990 //--------------------------------------------------------------------------
1002 {
1003  PRunData *data = 0;
1004 
1005  switch (tag) {
1006  case kIndex: // called from musrfit when dumping the data
1007  if (index > fRunAsymmetryBNMRList.size()) {
1008  std::cerr << std::endl << ">> PRunListCollection::GetAsymmetryBNMR(): **ERROR** index = " << index << " out of bounds";
1009  std::cerr << std::endl;
1010  return 0;
1011  }
1012 
1013  fRunAsymmetryBNMRList[index]->CalcTheory();
1014  data = fRunAsymmetryBNMRList[index]->GetData();
1015  break;
1016  case kRunNo: // called from PMusrCanvas
1017  for (UInt_t i=0; i<fRunAsymmetryBNMRList.size(); i++) {
1018  if (fRunAsymmetryBNMRList[i]->GetRunNo() == index) {
1019  data = fRunAsymmetryBNMRList[i]->GetData();
1020  break;
1021  }
1022  }
1023  break;
1024  default: // error
1025  break;
1026  }
1027 
1028  return data;
1029 }
1030 
1031 //--------------------------------------------------------------------------
1032 // GetAsymmetryRRF (public)
1033 //--------------------------------------------------------------------------
1045 {
1046  PRunData *data = nullptr;
1047 
1048  switch (tag) {
1049  case kIndex: // called from musrfit when dumping the data
1050  if (index > fRunAsymmetryRRFList.size()) {
1051  std::cerr << std::endl << ">> PRunListCollection::GetAsymmetryRRF(): **ERROR** index = " << index << " out of bounds";
1052  std::cerr << std::endl;
1053  return nullptr;
1054  }
1055 
1056  fRunAsymmetryRRFList[index]->CalcTheory();
1057  data = fRunAsymmetryRRFList[index]->GetData();
1058  break;
1059  case kRunNo: // called from PMusrCanvas
1060  for (UInt_t i=0; i<fRunAsymmetryRRFList.size(); i++) {
1061  if (fRunAsymmetryRRFList[i]->GetRunNo() == index) {
1062  data = fRunAsymmetryRRFList[i]->GetData();
1063  break;
1064  }
1065  }
1066  break;
1067  default: // error
1068  break;
1069  }
1070 
1071  return data;
1072 }
1073 
1074 //--------------------------------------------------------------------------
1075 // GetMuMinus (public)
1076 //--------------------------------------------------------------------------
1088 {
1089  PRunData *data = nullptr;
1090 
1091  switch (tag) {
1092  case kIndex:
1093  if (index > fRunMuMinusList.size()) {
1094  std::cerr << std::endl << ">> PRunListCollection::GetMuMinus(): **ERROR** index = " << index << " out of bounds";
1095  std::cerr << std::endl;
1096  return nullptr;
1097  }
1098  fRunMuMinusList[index]->CalcTheory();
1099  data = fRunMuMinusList[index]->GetData();
1100  break;
1101  case kRunNo:
1102  for (UInt_t i=0; i<fRunMuMinusList.size(); i++) {
1103  if (fRunMuMinusList[i]->GetRunNo() == index) {
1104  data = fRunMuMinusList[i]->GetData();
1105  break;
1106  }
1107  }
1108  break;
1109  default: // error
1110  break;
1111  }
1112 
1113  return data;
1114 }
1115 
1116 //--------------------------------------------------------------------------
1117 // GetNonMusr (public)
1118 //--------------------------------------------------------------------------
1130 {
1131  PRunData *data = nullptr;
1132 
1133  switch (tag) {
1134  case kIndex:
1135  if (index > fRunNonMusrList.size()) {
1136  std::cerr << std::endl << ">> PRunListCollection::GetNonMusr(): **ERROR** index = " << index << " out of bounds";
1137  std::cerr << std::endl;
1138  return nullptr;
1139  }
1140  break;
1141  case kRunNo:
1142  for (UInt_t i=0; i<fRunNonMusrList.size(); i++) {
1143  if (fRunNonMusrList[i]->GetRunNo() == index) {
1144  data = fRunNonMusrList[i]->GetData();
1145  break;
1146  }
1147  }
1148  break;
1149  default: // error
1150  break;
1151  }
1152 
1153  return data;
1154 }
1155 
1156 //--------------------------------------------------------------------------
1157 // GetTemp (public)
1158 //--------------------------------------------------------------------------
1167 const PDoublePairVector* PRunListCollection::GetTemp(const TString &runName) const
1168 {
1169  return fData->GetRunData(runName)->GetTemperature();
1170 }
1171 
1172 //--------------------------------------------------------------------------
1173 // GetField (public)
1174 //--------------------------------------------------------------------------
1183 Double_t PRunListCollection::GetField(const TString &runName) const
1184 {
1185  return fData->GetRunData(runName)->GetField();
1186 }
1187 
1188 //--------------------------------------------------------------------------
1189 // GetEnergy (public)
1190 //--------------------------------------------------------------------------
1199 Double_t PRunListCollection::GetEnergy(const TString &runName) const
1200 {
1201  return fData->GetRunData(runName)->GetEnergy();
1202 }
1203 
1204 //--------------------------------------------------------------------------
1205 // GetSetup (public)
1206 //--------------------------------------------------------------------------
1215 const Char_t* PRunListCollection::GetSetup(const TString &runName) const
1216 {
1217  return fData->GetRunData(runName)->GetSetup()->Data();
1218 }
1219 
1220 //--------------------------------------------------------------------------
1221 // GetXAxisTitle (public)
1222 //--------------------------------------------------------------------------
1232 const Char_t* PRunListCollection::GetXAxisTitle(const TString &runName, const UInt_t idx) const
1233 {
1234  PRawRunData *runData = fData->GetRunData(runName);
1235 
1236  const Char_t *result = nullptr;
1237 
1238  if (runData->fDataNonMusr.FromAscii()) {
1239  result = runData->fDataNonMusr.GetLabels()->at(0).Data();
1240  } else {
1241  for (UInt_t i=0; i<fRunNonMusrList.size(); i++) {
1242  if (fRunNonMusrList[i]->GetRunNo() == idx) {
1243  Int_t index = fRunNonMusrList[i]->GetXIndex();
1244  result = runData->fDataNonMusr.GetLabels()->at(index).Data();
1245  break;
1246  }
1247  }
1248  }
1249 
1250  return result;
1251 }
1252 
1253 //--------------------------------------------------------------------------
1254 // GetYAxisTitle (public)
1255 //--------------------------------------------------------------------------
1265 const Char_t* PRunListCollection::GetYAxisTitle(const TString &runName, const UInt_t idx) const
1266 {
1267  PRawRunData *runData = fData->GetRunData(runName);
1268 
1269  const Char_t *result = nullptr;
1270 
1271  if (runData->fDataNonMusr.FromAscii()) {
1272  result = runData->fDataNonMusr.GetLabels()->at(1).Data();
1273  } else {
1274  for (UInt_t i=0; i<fRunNonMusrList.size(); i++) {
1275  if (fRunNonMusrList[i]->GetRunNo() == idx) {
1276  Int_t index = fRunNonMusrList[i]->GetYIndex();
1277  result = runData->fDataNonMusr.GetLabels()->at(index).Data();
1278  break;
1279  }
1280  }
1281  }
1282 
1283  return result;
1284 }
1285 
virtual PRunData * GetAsymmetry(UInt_t index, EDataSwitch tag=kIndex)
virtual Bool_t FromAscii()
Definition: PMusr.h:290
virtual Double_t GetField(const TString &runName) const
virtual void SetFitRange(const PDoublePairVector fitRange)
virtual Double_t GetEnergy(const TString &runName) const
virtual UInt_t GetNoOfBinsFitted(const UInt_t idx) const
virtual Double_t GetAsymmetryMaximumLikelihood(const std::vector< Double_t > &par) const
virtual Bool_t Add(Int_t runNo, EPMusrHandleTag tag)
virtual Double_t GetMuMinusMaximumLikelihood(const std::vector< Double_t > &par) const
virtual const TString * GetSetup()
Definition: PMusr.h:409
std::vector< PRunAsymmetry * > fRunAsymmetryList
stores all processed asymmetry data
virtual Double_t GetSingleHistoChisq(const std::vector< Double_t > &par) const
std::vector< PRunSingleHisto * > fRunSingleHistoList
stores all processed single histogram data
virtual const PDoublePairVector * GetTemperature() const
Definition: PMusr.h:422
virtual PRawRunData * GetRunData(const TString &runName)
#define PRUN_MU_MINUS
Definition: PMusr.h:60
virtual const PStringVector * GetLabels()
Definition: PMusr.h:291
PRunDataHandler * fData
pointer to the run-data handler
virtual PRunData * GetMuMinus(UInt_t index, EDataSwitch tag=kIndex)
virtual PRunData * GetAsymmetryRRF(UInt_t index, EDataSwitch tag=kIndex)
virtual Double_t GetNonMusrMaximumLikelihood(const std::vector< Double_t > &par) const
virtual Double_t GetNonMusrChisq(const std::vector< Double_t > &par) const
virtual UInt_t GetTotalNoOfBinsFitted() const
PRunListCollection(PMsrHandler *msrInfo, PRunDataHandler *data, Bool_t theoAsdata=false)
virtual Double_t GetAsymmetryRRFMaximumLikelihood(const std::vector< Double_t > &par) const
virtual PRunData * GetSingleHisto(UInt_t index, EDataSwitch tag=kIndex)
#define PRUN_ASYMMETRY_BNMR
Definition: PMusr.h:61
virtual PMsrRunList * GetMsrRunList()
Definition: PMsrHandler.h:63
std::vector< PRunMuMinus * > fRunMuMinusList
stores all processed mu-minus data
Bool_t fTheoAsData
if true: calculate theory points only at the data points
virtual Double_t GetAsymmetryBNMRChisq(const std::vector< Double_t > &par) const
std::vector< PRunAsymmetryBNMR * > fRunAsymmetryBNMRList
stores all processed asymmetry BNMR data
#define PRUN_SINGLE_HISTO_RRF
Definition: PMusr.h:57
virtual Double_t GetSingleRunMaximumLikelihoodExpected(const std::vector< Double_t > &par, const UInt_t idx) const
#define PRUN_ASYMMETRY_RRF
Definition: PMusr.h:59
virtual PMsrGlobalBlock * GetMsrGlobal()
Definition: PMsrHandler.h:62
virtual const Char_t * GetXAxisTitle(const TString &runName, const UInt_t idx) const
virtual Double_t GetSingleRunChisq(const std::vector< Double_t > &par, const UInt_t idx) const
virtual const Double_t GetField()
Definition: PMusr.h:420
#define PRUN_NON_MUSR
Definition: PMusr.h:62
virtual PRunData * GetNonMusr(UInt_t index, EDataSwitch tag=kIndex)
virtual Double_t GetAsymmetryBNMRMaximumLikelihood(const std::vector< Double_t > &par) const
std::vector< PRunAsymmetryRRF * > fRunAsymmetryRRFList
stores all processed asymmetry RRF data
std::vector< PRunSingleHistoRRF * > fRunSingleHistoRRFList
stores all processed single histogram RRF data
EPMusrHandleTag
Definition: PMusr.h:220
virtual const Char_t * GetYAxisTitle(const TString &runName, const UInt_t idx) const
virtual const Double_t GetEnergy()
Definition: PMusr.h:425
virtual Int_t GetFitType()
Definition: PMusr.h:581
virtual PRunData * GetSingleHistoRRF(UInt_t index, EDataSwitch tag=kIndex)
virtual Double_t GetMuMinusChisq(const std::vector< Double_t > &par) const
std::vector< PDoublePair > PDoublePairVector
Definition: PMusr.h:208
virtual Double_t GetAsymmetryChisq(const std::vector< Double_t > &par) const
virtual const Char_t * GetSetup(const TString &runName) const
#define PRUN_ASYMMETRY
Definition: PMusr.h:58
virtual PRunData * GetAsymmetryBNMR(UInt_t index, EDataSwitch tag=kIndex)
virtual Double_t GetSingleHistoMaximumLikelihood(const std::vector< Double_t > &par) const
virtual Double_t GetSingleHistoRRFChisq(const std::vector< Double_t > &par) const
PNonMusrRawRunData fDataNonMusr
keeps all ascii- or db-file info in case of nonMusr fit
Definition: PMusr.h:479
virtual Double_t GetSingleHistoRRFMaximumLikelihood(const std::vector< Double_t > &par) const
virtual Double_t GetSingleRunChisqExpected(const std::vector< Double_t > &par, const UInt_t idx) const
virtual const PDoublePairVector * GetTemp(const TString &runName) const
virtual Double_t GetAsymmetryRRFChisq(const std::vector< Double_t > &par) const
std::vector< PRunNonMusr * > fRunNonMusrList
stores all processed non-muSR data
#define PRUN_SINGLE_HISTO
Definition: PMusr.h:56
virtual Double_t GetSingleRunMaximumLikelihood(const std::vector< Double_t > &par, const UInt_t idx) const
PMsrHandler * fMsrInfo
pointer to the msr-file handler