41 #include <TObjArray.h> 42 #include <TObjString.h> 81 PRunBase(msrInfo, rawData, runNo, tag), fTheoAsData(theoAsData)
90 std::cerr << std::endl <<
">> PRunMuMinus::PRunMuMinus: **SEVERE ERROR**: Couldn't find any packing information!";
91 std::cerr << std::endl <<
">> This is very bad :-(, will quit ...";
92 std::cerr << std::endl;
106 std::cerr << std::endl <<
">> PRunMuMinus::PRunMuMinus: **SEVERE ERROR**: Couldn't prepare data for fitting!";
107 std::cerr << std::endl <<
">> This is very bad :-(, will quit ...";
108 std::cerr << std::endl;
137 Double_t chisq = 0.0;
160 #pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq) 184 Double_t chisq = 0.0;
208 #pragma omp parallel for default(shared) private(i,time,diff) schedule(dynamic,chunk) reduction(+:chisq) 214 chisq += diff*diff / theo;
257 #pragma omp parallel for default(shared) private(i,time,theo,data) schedule(dynamic,chunk) reduction(-:mllh) 267 std::cerr <<
">> PRunMuMinus::CalcMaxLikelihood: **WARNING** NEGATIVE theory!!" << std::endl;
272 mllh += (theo-data) + data*log(data/theo);
312 TObjArray *tok =
nullptr;
313 TObjString *ostr =
nullptr;
318 tok = fitRange.Tokenize(
" \t");
320 if (tok->GetEntries() == 3) {
322 ostr =
dynamic_cast<TObjString*
>(tok->At(1));
323 str = ostr->GetString();
325 idx = str.First(
"+");
327 str.Remove(0, idx+1);
334 ostr =
dynamic_cast<TObjString*
>(tok->At(2));
335 str = ostr->GetString();
337 idx = str.First(
"-");
339 str.Remove(0, idx+1);
344 }
else if ((tok->GetEntries() > 3) && (tok->GetEntries() % 2 == 1)) {
345 Int_t pos = 2*(
fRunNo+1)-1;
347 if (pos + 1 >= tok->GetEntries()) {
348 std::cerr << std::endl <<
">> PRunMuMinus::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange <<
"'";
349 std::cerr << std::endl <<
">> will ignore it. Sorry ..." << std::endl;
352 ostr =
dynamic_cast<TObjString*
>(tok->At(pos));
353 str = ostr->GetString();
355 idx = str.First(
"+");
357 str.Remove(0, idx+1);
364 ostr =
dynamic_cast<TObjString*
>(tok->At(pos+1));
365 str = ostr->GetString();
367 idx = str.First(
"-");
369 str.Remove(0, idx+1);
376 std::cerr << std::endl <<
">> PRunMuMinus::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange <<
"'";
377 std::cerr << std::endl <<
">> will ignore it. Sorry ..." << std::endl;
417 std::vector<Double_t> par;
419 for (UInt_t i=0; i<paramList->size(); i++)
420 par.push_back((*paramList)[i].fValue);
432 for (UInt_t i=0; i<size; i++) {
433 time = start +
static_cast<Double_t
>(i)*resolution;
459 Bool_t success =
true;
470 std::cerr << std::endl <<
">> PRunMuMinus::PrepareData(): **ERROR** Couldn't get run " <<
fRunInfo->
GetRunName()->Data() <<
"!";
471 std::cerr << std::endl;
491 std::cerr << std::endl <<
">> PRunMuMinus::PrepareData(): **PANIC ERROR**:";
492 std::cerr << std::endl <<
">> histoNo found = " << histoNo[i] <<
", which is NOT present in the data file!?!?";
493 std::cerr << std::endl <<
">> Will quit :-(";
494 std::cerr << std::endl;
502 std::cout.precision(10);
503 std::cout << std::endl <<
">> PRunMuMinus::PrepareData(): time resolution=" << std::fixed << runData->
GetTimeResolution() <<
"(ns)" << std::endl;
511 std::vector<PDoubleVector> forward;
512 forward.resize(histoNo.size());
513 for (UInt_t i=0; i<histoNo.size(); i++) {
514 forward[i].resize(runData->
GetDataBin(histoNo[i])->size());
515 forward[i] = *runData->
GetDataBin(histoNo[i]);
525 if (addRunData ==
nullptr) {
526 std::cerr << std::endl <<
">> PRunMuMinus::PrepareData(): **ERROR** Couldn't get addrun " <<
fRunInfo->
GetRunName(i)->Data() <<
"!";
527 std::cerr << std::endl;
533 for (UInt_t k=0; k<histoNo.size(); k++) {
534 addRunSize = addRunData->
GetDataBin(histoNo[k])->size();
535 for (UInt_t j=0; j<addRunData->
GetDataBin(histoNo[k])->size(); j++) {
537 if ((static_cast<Int_t>(j)+static_cast<Int_t>(
fAddT0s[i-1][k])-static_cast<Int_t>(
fT0s[k]) >= 0) &&
538 (j+
static_cast<Int_t
>(
fAddT0s[i-1][k])-static_cast<Int_t>(
fT0s[k]) < addRunSize)) {
539 forward[k][j] += addRunData->
GetDataBin(histoNo[k])->at(j+static_cast<Int_t>(
fAddT0s[i-1][k])-static_cast<Int_t>(
fT0s[k]));
548 for (UInt_t i=0; i<
fForward.size(); i++) {
553 for (UInt_t i=1; i<histoNo.size(); i++) {
554 for (UInt_t j=0; j<runData->
GetDataBin(histoNo[i])->size(); j++) {
557 fForward[j] += forward[i][j+
static_cast<Int_t
>(
fT0s[i])-static_cast<Int_t>(
fT0s[0])];
607 Int_t t0 =
static_cast<Int_t
>(
fT0s[0]);
608 Double_t value = 0.0;
668 Double_t theoryNorm = 1.0;
677 Int_t end = start + ((
fForward.size()-start)/packing)*packing;
681 start = (
static_cast<Int_t
>(
fT0s[0])+offset) - ((
static_cast<Int_t
>(
fT0s[0])+offset)/packing)*packing;
682 end = start + ((
fForward.size()-start)/packing)*packing;
683 std::cerr << std::endl <<
">> PRunMuMinus::PrepareData(): **WARNING** data range was not provided, will try data range start = " << start <<
".";
684 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
685 std::cerr << std::endl;
695 if ((start < 0) || (start >
static_cast<Int_t
>(
fForward.size()))) {
696 std::cerr << std::endl <<
">> PRunMuMinus::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!";
697 std::cerr << std::endl;
701 if ((end < 0) || (end >
static_cast<Int_t
>(
fForward.size()))) {
702 std::cerr << std::endl <<
">> PRunMuMinus::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!";
703 std::cerr << std::endl;
714 Int_t t0 =
static_cast<Int_t
>(
fT0s[0]);
715 Double_t value = 0.0;
720 for (Int_t i=start; i<end; i++) {
721 if (((i-start) % packing == 0) && (i != start)) {
737 std::vector<Double_t> par;
739 for (UInt_t i=0; i<paramList->size(); i++)
740 par.push_back((*paramList)[i].fValue);
772 Double_t theoryValue;
773 for (UInt_t i=0; i<size; i++) {
776 if (fabs(theoryValue) > 1.0e10) {
811 fT0s.resize(histoNo.size());
812 for (UInt_t i=0; i<
fT0s.size(); i++) {
823 if (
fT0s[i] == -1.0) {
829 for (UInt_t i=0; i<histoNo.size(); i++) {
830 if (
fT0s[i] == -1.0) {
831 if (runData->
GetT0Bin(histoNo[i]) > 0.0) {
839 for (UInt_t i=0; i<histoNo.size(); i++) {
840 if (
fT0s[i] == -1.0) {
844 std::cerr << std::endl <<
">> PRunMuMinus::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
846 std::cerr << std::endl <<
">> will try the estimated one: forward t0 = " << runData->
GetT0BinEstimated(histoNo[i]);
847 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
848 std::cerr << std::endl;
854 if ((
fT0s[i] < 0) || (
fT0s[i] >
static_cast<Int_t
>(runData->
GetDataBin(histoNo[i])->size()))) {
855 std::cerr << std::endl <<
">> PRunMuMinus::GetProperT0(): **ERROR** t0 data bin (" <<
fT0s[i] <<
") doesn't make any sense!";
856 std::cerr << std::endl;
869 if (addRunData ==
nullptr) {
870 std::cerr << std::endl <<
">> PRunMuMinus::GetProperT0(): **ERROR** Couldn't get addrun " <<
fRunInfo->
GetRunName(i)->Data() <<
"!";
871 std::cerr << std::endl;
877 fAddT0s[i-1].resize(histoNo.size());
878 for (UInt_t j=0; j<
fAddT0s[i-1].size(); j++) {
888 for (UInt_t j=0; j<histoNo.size(); j++) {
890 if (addRunData->
GetT0Bin(histoNo[j]) > 0.0) {
897 for (UInt_t j=0; j<histoNo.size(); j++) {
902 std::cerr << std::endl <<
">> PRunMuMinus::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
904 std::cerr << std::endl <<
">> will try the estimated one: forward t0 = " << addRunData->
GetT0BinEstimated(histoNo[j]);
905 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
906 std::cerr << std::endl;
913 std::cerr << std::endl <<
">> PRunMuMinus::GetProperT0(): **ERROR** addt0 data bin (" <<
fAddT0s[i-1][j] <<
") doesn't make any sense!";
914 std::cerr << std::endl;
956 start =
static_cast<Int_t
>(
fT0s[0])+offset;
958 std::cerr << std::endl <<
">> PRunMuMinus::GetProperDataRange(): **WARNING** data range was not provided, will try data range start = t0+" << offset <<
"(=10ns) = " << start <<
".";
959 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
960 std::cerr << std::endl;
965 std::cerr << std::endl <<
">> PRunMuMinus::GetProperDataRange(): **WARNING** data range was not provided, will try data range end = " << end <<
".";
966 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
967 std::cerr << std::endl;
978 if ((start < 0) || (start > static_cast<Int_t>(
fForward.size()))) {
979 std::cerr << std::endl <<
">> PRunMuMinus::GetProperDataRange(): **ERROR** start data bin (" << start <<
") doesn't make any sense!";
980 std::cerr << std::endl;
984 if ((end < 0) || (end >
static_cast<Int_t
>(
fForward.size()))) {
985 std::cerr << std::endl <<
">> PRunMuMinus::GetProperDataRange(): **ERROR** end data bin (" << end <<
") doesn't make any sense!";
986 std::cerr << std::endl;
1040 std::cerr <<
">> PRunMuMinus::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << std::endl;
1041 std::cerr <<
">> Will set it to fgb/lgb which given in time is: " <<
fFitStartTime <<
"..." <<
fFitEndTime <<
" (usec)" << std::endl;
virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock)
virtual UInt_t GetT0BinSize()
Bool_t fValid
flag showing if the state of the class is valid
virtual void SetDataRange(Int_t ival, Int_t idx)
virtual const PDoubleVector * GetError()
virtual Double_t CalcChiSquare(const std::vector< Double_t > &par)
virtual Int_t GetNoOfFuncs()
virtual Int_t GetDataRange(UInt_t idx)
virtual Double_t GetT0Bin(UInt_t idx=0)
virtual const Double_t GetTimeResolution()
virtual void CalcNoOfFitBins()
virtual Int_t GetPacking()
PRunDataHandler * fRawData
holds the raw run data
std::vector< PDoubleVector > fAddT0s
all t0 bins of all addrun's of a run! The derived classes will handle it.
virtual Int_t GetFitRangeOffset(UInt_t idx)
virtual void CalcTheory()
virtual void SetTheoryTimeStart(Double_t dval)
Int_t fPacking
packing for this particular run. Either given in the RUN- or GLOBAL-block.
PMsrHandler * fMsrInfo
msr-file handler
virtual Bool_t IsFitRangeInBin()
virtual const PDoublePairVector * GetTemperature() const
Double_t fTimeResolution
time resolution in (us)
PMetaData fMetaData
keeps the meta data from the data file like field, temperature, energy, ...
virtual Bool_t PrepareRawViewData(PRawRunData *runData, const UInt_t histoNo)
virtual PRawRunData * GetRunData(const TString &runName)
virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx)
virtual UInt_t GetT0BinSize()
virtual void AppendErrorValue(Double_t dval)
virtual Bool_t IsFitRangeInBin()
virtual Double_t GetTheoryTimeStep()
std::vector< UInt_t > PUIntVector
PRunData fData
data to be fitted, viewed, i.e. binned data
virtual void SetDataTimeStep(Double_t dval)
virtual Double_t GetTheoryTimeStart()
virtual Double_t GetT0Bin(UInt_t idx=0)
std::vector< PMsrParamStructure > PMsrParamList
virtual const Bool_t IsPresent(UInt_t histoNo)
virtual const Double_t GetT0Bin(const UInt_t histoNo)
virtual Bool_t PrepareFitData(PRawRunData *runData, const UInt_t histoNo)
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
virtual void AppendTheoryValue(Double_t dval)
virtual PMsrGlobalBlock * GetMsrGlobal()
virtual void SetDataTimeStart(Double_t dval)
virtual Int_t GetFitRangeOffset(UInt_t idx)
virtual void AppendValue(Double_t dval)
virtual const PDoubleVector * GetValue()
virtual const Double_t GetField()
virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx)
virtual UInt_t GetFuncNo(Int_t idx)
virtual Bool_t PrepareData()
Int_t fEndTimeBin
bin at which the fit ends
virtual const UInt_t GetNoOfTemperatures()
virtual Int_t GetForwardHistoNo(UInt_t idx=0)
PDoubleVector fT0s
all t0 bins of a run! The derived classes will handle it.
virtual PMsrPlotList * GetMsrPlotList()
EPMusrHandleTag fHandleTag
tag telling whether this is used for fit, view, ...
virtual UInt_t GetForwardHistoNoSize()
virtual UInt_t GetNoOfFitBins()
UInt_t fNoOfFitBins
number of bins to be fitted
PMsrRunBlock * fRunInfo
run info used to filter out needed infos of a run
virtual const Double_t GetEnergy()
Int_t fGoodBins[2]
keep first/last good bins. 0=fgb, 1=lgb
Int_t fStartTimeBin
bin at which the fit starts
virtual void SetFitRange(Double_t dval, UInt_t idx)
PDoubleVector fForward
forward histo data
Double_t fFitEndTime
fit end time
virtual void SetTheoryTimeStep(Double_t dval)
virtual void SetFitRange(Double_t dval, UInt_t idx)
Double_t fFitStartTime
fit start time
virtual PMsrParamList * GetMsrParamList()
virtual Double_t CalcChiSquareExpected(const std::vector< Double_t > &par)
virtual PIntVector * GetMap()
virtual Double_t EvalFunc(UInt_t i, std::vector< Int_t > map, std::vector< Double_t > param, PMetaData metaData)
virtual const PDoubleVector * GetDataBin(const UInt_t histoNo)
virtual Double_t GetDataTimeStart()
virtual UInt_t GetRunNameSize()
virtual Int_t GetDataRange(UInt_t idx)
Bool_t fTheoAsData
true=only calculate the theory points at the data points, false=calculate more points for the theory ...
virtual const Double_t GetT0BinEstimated(const UInt_t histoNo)
virtual Bool_t GetProperT0(PRawRunData *runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo)
std::unique_ptr< PTheory > fTheory
theory needed to calculate chi-square
virtual Int_t GetPacking()
virtual void SetFitRangeBin(const TString fitRange)
virtual Double_t GetFitRange(UInt_t idx)
virtual Double_t GetDataTimeStep()
Int_t fRunNo
number of the run within the msr-file
virtual Double_t CalcMaxLikelihood(const std::vector< Double_t > &par)
virtual TString * GetRunName(UInt_t idx=0)
virtual Bool_t GetProperDataRange()
virtual Double_t GetFitRange(UInt_t idx)
PDoubleVector fFuncValues
is keeping the values of the functions from the FUNCTIONS block