119 std::cerr << std::endl <<
"PRunNonMusr::PRunNonMusr(): **ERROR** Couldn't get raw run data!";
120 std::cerr << std::endl;
191 Double_t chisq = 0.0;
195 for (Int_t i=0; i<
fMsrInfo->GetNoOfFuncs(); i++) {
202 x =
fData.GetX()->at(i);
204 chisq += diff*diff / (
fData.GetError()->at(i)*
fData.GetError()->at(i));
237 std::cout << std::endl <<
"PRunNonMusr::CalcChiSquareExpected(): not implemented yet ..." << std::endl;
275 std::cout << std::endl <<
"PRunNonMusr::CalcMaxLikelihood(): not implemented yet ..." << std::endl;
334 for (UInt_t i=0; i<
fData.GetValue()->size(); i++) {
335 x =
fData.GetX()->at(i);
355 Bool_t success =
true;
360 if (
fRunInfo->GetRunNameSize() > 1) {
361 std::cerr << std::endl <<
">> PRunNonMusr::PrepareData(): **WARNING** ADDRUN NOT SUPPORTED FOR THIS FIT TYPE, WILL IGNORE IT." << std::endl;
370 std::cerr << std::endl <<
">> PRunNonMusr::PrepareData(): **ERROR** couldn't find any packing information." << std::endl;
404 Bool_t success =
true;
411 Double_t value = 0.0;
413 for (UInt_t i=0; i<
fRawRunData->fDataNonMusr.GetData()->at(xIndex).size(); i++) {
417 fData.AppendErrorValue(
fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i));
419 if ((i %
fPacking == 0) && (i != 0)) {
421 fData.AppendValue(value);
422 fData.AppendErrorValue(TMath::Sqrt(err));
427 value +=
fRawRunData->fDataNonMusr.GetData()->at(yIndex).at(i);
428 err +=
fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i)*
fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i);
435 for (UInt_t i=0; i<
fData.GetValue()->size(); i++) {
436 x =
fData.GetX()->at(i);
445 for (UInt_t i=0; i<xx->size(); i++) {
467 Bool_t success =
true;
475 Double_t value = 0.0;
477 for (UInt_t i=0; i<
fRawRunData->fDataNonMusr.GetData()->at(xIndex).size(); i++) {
481 fData.AppendErrorValue(
fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i));
483 if ((i %
fPacking == 0) && (i != 0)) {
485 fData.AppendValue(value);
486 fData.AppendErrorValue(TMath::Sqrt(err));
491 value +=
fRawRunData->fDataNonMusr.GetData()->at(yIndex).at(i);
492 err +=
fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i)*
fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i);
501 std::vector<Double_t> par;
503 for (UInt_t i=0; i<paramList->size(); i++)
504 par.push_back((*paramList)[i].fValue);
506 for (Int_t i=0; i<
fMsrInfo->GetNoOfFuncs(); i++) {
513 plotList =
fMsrInfo->GetMsrPlotList();
521 Double_t xMin = 0.0, xMax = 0.0;
524 plotBlock = plotList->at(0);
525 if (plotBlock.
fTmin.size() == 0) {
527 xMin = runList->at(0).GetFitRange(0);
528 xMax = runList->at(0).GetFitRange(1);
529 for (UInt_t i=1; i<runList->size(); i++) {
530 if (runList->at(i).GetFitRange(0) < xMin)
531 xMin = runList->at(i).GetFitRange(0);
532 if (runList->at(i).GetFitRange(1) > xMax)
533 xMax = runList->at(i).GetFitRange(1);
535 }
else if (plotBlock.
fTmin.size() == 1) {
536 xMin = plotBlock.
fTmin[0];
537 xMax = plotBlock.
fTmax[0];
538 }
else if (plotBlock.
fTmin.size() > 1) {
539 xMin = plotBlock.
fTmin[0];
540 xMax = plotBlock.
fTmax[0];
541 for (UInt_t i=1; i<plotBlock.
fTmin.size(); i++) {
542 if (plotBlock.
fTmin[i] < xMin)
543 xMin = plotBlock.
fTmin[i];
544 if (plotBlock.
fTmax[i] > xMax)
545 xMax = plotBlock.
fTmax[i];
551 xMin = runList->at(0).GetFitRange(0);
552 xMax = runList->at(0).GetFitRange(1);
553 for (UInt_t i=1; i<runList->size(); i++) {
554 if (runList->at(i).GetFitRange(0) < xMin)
555 xMin = runList->at(i).GetFitRange(0);
556 if (runList->at(i).GetFitRange(1) > xMax)
557 xMax = runList->at(i).GetFitRange(1);
561 for (UInt_t i=1; i<plotList->size(); i++) {
562 plotBlock = plotList->at(i);
564 if (plotBlock.
fTmin.size() == 0) {
566 for (UInt_t i=0; i<runList->size(); i++) {
567 if (runList->at(i).GetFitRange(0) < xMin)
568 xMin = runList->at(i).GetFitRange(0);
569 if (runList->at(i).GetFitRange(1) > xMax)
570 xMax = runList->at(i).GetFitRange(1);
572 }
else if (plotBlock.
fTmin.size() == 1) {
573 if (plotBlock.
fTmin[0] < xMin)
574 xMin = plotBlock.
fTmin[0];
575 if (plotBlock.
fTmax[0] > xMax)
576 xMax = plotBlock.
fTmax[0];
577 }
else if (plotBlock.
fTmin.size() > 1) {
578 for (UInt_t i=0; i<plotBlock.
fTmin.size(); i++) {
579 if (plotBlock.
fTmin[i] < xMin)
580 xMin = plotBlock.
fTmin[i];
581 if (plotBlock.
fTmax[i] > xMax)
582 xMax = plotBlock.
fTmax[i];
588 for (UInt_t i=0; i<runList->size(); i++) {
589 if (runList->at(i).GetFitRange(0) < xMin)
590 xMin = runList->at(i).GetFitRange(0);
591 if (runList->at(i).GetFitRange(1) > xMax)
592 xMax = runList->at(i).GetFitRange(1);
599 if (
fData.GetX()->size() > 1000.0)
600 xStep = (xMax-xMin)/
fData.GetX()->size();
602 xStep = (xMax-xMin)/1000.0;
606 for (UInt_t i=0; i<
fRawRunData->fDataNonMusr.GetData()->at(xIndex).size(); i++) {
608 xx =
fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i);
609 fData.AppendXTheoryValue(xx);
617 fData.AppendXTheoryValue(xx);
643 Bool_t found =
false;
649 if (
fRunInfo->GetXDataIndex() > 0) {
650 index =
fRunInfo->GetXDataIndex()-1;
653 for (UInt_t i=0; i<
fRawRunData->fDataNonMusr.GetDataTags()->size(); i++) {
654 if (
fRawRunData->fDataNonMusr.GetDataTags()->at(i).CompareTo(*
fRunInfo->GetXDataLabel()) == 0) {
664 std::cerr << std::endl <<
"PRunNonMusr::GetXIndex(): **ERROR** Couldn't obtain x-data index!";
665 std::cerr << std::endl;
684 Bool_t found =
false;
690 if (
fRunInfo->GetYDataIndex() > 0) {
691 index =
fRunInfo->GetYDataIndex()-1;
694 for (UInt_t i=0; i<
fRawRunData->fDataNonMusr.GetDataTags()->size(); i++) {
695 if (
fRawRunData->fDataNonMusr.GetDataTags()->at(i).CompareTo(*
fRunInfo->GetYDataLabel()) == 0) {
705 std::cerr << std::endl <<
"PRunNonMusr::GetYIndex(): **ERROR** Couldn't obtain y-data index!";
706 std::cerr << std::endl;
@ kEmpty
No operation active.
@ kFit
Fitting mode - perform least-squares fit to data.
@ kView
Viewing mode - display data and theory without fitting.
std::vector< PMsrRunBlock > PMsrRunList
std::vector< PMsrPlotStructure > PMsrPlotList
std::vector< PMsrParamStructure > PMsrParamList
std::vector< Double_t > PDoubleVector
MSR file parser and manager for the musrfit framework.
Bool_t fValid
Flag indicating if run object initialized successfully; false if any error occurred.
Double_t fFitEndTime
Fit range end time in microseconds (μs) relative to t0.
PDoubleVector fFuncValues
Cached values of user-defined functions from FUNCTIONS block, evaluated at current parameters.
PMsrHandler * fMsrInfo
Pointer to MSR file handler (owned externally, not deleted here)
PMetaData fMetaData
Experimental metadata extracted from data file header (magnetic field, temperature,...
std::unique_ptr< PTheory > fTheory
Theory function evaluator (smart pointer, automatically deleted)
EPMusrHandleTag fHandleTag
Operation mode: kFit (fitting), kView (display only), kEmpty (uninitialized)
PRunData fData
Processed data container: background-corrected, packed, with theory values.
PRunDataHandler * fRawData
Pointer to raw data handler (owned externally, not deleted here)
PRunBase()
Default constructor.
PMsrRunBlock * fRunInfo
Pointer to this run's RUN block settings within fMsrInfo.
Double_t fFitStartTime
Fit range start time in microseconds (μs) relative to t0.
Raw data file reader and format converter for μSR data.
Int_t fStartTimeBin
Index of first data point in fit range.
virtual ~PRunNonMusr()
Virtual destructor (no cleanup needed for this class).
virtual UInt_t GetNoOfFitBins()
Returns the number of x-y points within the fit range.
PRawRunData * fRawRunData
Pointer to raw run data handler (not owned).
virtual Bool_t PrepareData()
Main data preparation orchestrator for non-μSR data.
Bool_t fTheoAsData
Theory calculation mode flag.
Int_t fPacking
Data point averaging/grouping factor.
PRunNonMusr()
Default constructor creating an empty, invalid non-μSR run object.
virtual Double_t CalcChiSquareExpected(const std::vector< Double_t > &par)
Calculates expected χ² (NOT IMPLEMENTED for non-μSR).
Int_t fEndTimeBin
Index of last data point in fit range (inclusive).
virtual Double_t CalcChiSquare(const std::vector< Double_t > &par)
Calculates χ² between non-μSR data and theory.
virtual void CalcTheory()
Evaluates theory function (empty implementation for non-μSR).
virtual Bool_t PrepareViewData()
Prepares x-y data for viewing/plotting.
virtual UInt_t GetXIndex()
Returns the x-axis column index from MSR file specification.
virtual Double_t CalcMaxLikelihood(const std::vector< Double_t > &par)
Calculates maximum likelihood (NOT IMPLEMENTED for non-μSR).
virtual UInt_t GetYIndex()
Returns the y-axis column index from MSR file specification.
UInt_t fNoOfFitBins
Number of x-y points within fit range (fFitStartTime ≤ x ≤ fFitEndTime)
virtual Bool_t PrepareFitData()
Prepares x-y data for fitting.
Bool_t fUseFitRanges
yes -> use the fit ranges to plot the data, no (default) -> use range information if present
PDoubleVector fTmax
time maximum
PDoubleVector fTmin
time minimum