43 #include <TObjArray.h> 44 #include <TObjString.h> 82 PRunBase(msrInfo, rawData, runNo, tag), fTheoAsData(theoAsData)
97 std::cerr << std::endl <<
">> PRunAsymmetry::PRunAsymmetry(): **SEVERE ERROR**: Couldn't find any packing information!";
98 std::cerr << std::endl <<
">> This is very bad :-(, will quit ...";
99 std::cerr << std::endl;
110 std::cerr << std::endl <<
">> PRunAsymmetry::PRunAsymmetry(): **ERROR** no alpha parameter given! This is needed for an asymmetry fit!";
111 std::cerr << std::endl;
119 std::cerr << std::endl <<
">> PRunAsymmetry::PRunAsymmetry(): **ERROR** alpha parameter is a function with no = " <<
fRunInfo->
GetAlphaParamNo();
120 std::cerr << std::endl <<
">> This is out of bound, since there are only " << msrInfo->
GetNoOfFuncs() <<
" functions.";
121 std::cerr << std::endl;
126 std::cerr << std::endl <<
">> PRunAsymmetry::PRunAsymmetry(): **ERROR** alpha parameter no = " <<
fRunInfo->
GetAlphaParamNo();
127 std::cerr << std::endl <<
">> This is out of bound, since there are only " << param->size() <<
" parameters.";
128 std::cerr << std::endl;
133 Bool_t alphaFixedToOne =
false;
137 alphaFixedToOne =
true;
140 Bool_t betaFixedToOne =
false;
142 betaFixedToOne =
true;
144 std::cerr << std::endl <<
">> PRunAsymmetry::PRunAsymmetry(): **ERROR** beta parameter no = " <<
fRunInfo->
GetBetaParamNo();
145 std::cerr << std::endl <<
">> This is out of bound, since there are only " << param->size() <<
" parameters.";
146 std::cerr << std::endl;
152 betaFixedToOne =
true;
156 if (alphaFixedToOne && betaFixedToOne)
158 else if (!alphaFixedToOne && betaFixedToOne)
160 else if (alphaFixedToOne && !betaFixedToOne)
197 Double_t chisq = 0.0;
199 Double_t asymFcnValue = 0.0;
273 #pragma omp parallel for default(shared) private(i,time,diff,asymFcnValue,f) schedule(dynamic,chunk) reduction(+:chisq) 278 asymFcnValue = (f*(a*b+1.0)-(a-1.0))/((a+1.0)-f*(a*b-1.0));
312 std::cout << std::endl <<
"PRunAsymmetry::CalcMaxLikelihood(): not implemented yet ..." << std::endl;
348 TObjArray *tok =
nullptr;
349 TObjString *ostr =
nullptr;
354 tok = fitRange.Tokenize(
" \t");
356 if (tok->GetEntries() == 3) {
358 ostr =
dynamic_cast<TObjString*
>(tok->At(1));
359 str = ostr->GetString();
361 idx = str.First(
"+");
363 str.Remove(0, idx+1);
370 ostr =
dynamic_cast<TObjString*
>(tok->At(2));
371 str = ostr->GetString();
373 idx = str.First(
"-");
375 str.Remove(0, idx+1);
380 }
else if ((tok->GetEntries() > 3) && (tok->GetEntries() % 2 == 1)) {
381 Int_t pos = 2*(
fRunNo+1)-1;
383 if (pos + 1 >= tok->GetEntries()) {
384 std::cerr << std::endl <<
">> PRunAsymmetry::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange <<
"'";
385 std::cerr << std::endl <<
">> will ignore it. Sorry ..." << std::endl;
388 ostr =
static_cast<TObjString*
>(tok->At(pos));
389 str = ostr->GetString();
391 idx = str.First(
"+");
393 str.Remove(0, idx+1);
400 ostr =
static_cast<TObjString*
>(tok->At(pos+1));
401 str = ostr->GetString();
403 idx = str.First(
"-");
405 str.Remove(0, idx+1);
412 std::cerr << std::endl <<
">> PRunAsymmetry::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange <<
"'";
413 std::cerr << std::endl <<
">> will ignore it. Sorry ..." << std::endl;
453 std::vector<Double_t> par;
455 for (UInt_t i=0; i<paramList->size(); i++)
456 par.push_back((*paramList)[i].fValue);
464 Double_t asymFcnValue = 0.0;
483 asymFcnValue = (f*(a+1.0)-(a-1.0))/((a+1.0)-f*(a-1.0));
495 asymFcnValue = f*(b+1.0)/(2.0-f*(b-1.0));
515 asymFcnValue = (f*(a*b+1.0)-(a-1.0))/((a+1.0)-f*(a*b-1.0));
562 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareData(): **ERROR** Couldn't get run " <<
fRunInfo->
GetRunName()->Data() <<
"!";
563 std::cerr << std::endl;
583 if (!runData->
IsPresent(forwardHistoNo[i])) {
584 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:";
585 std::cerr << std::endl <<
">> forwardHistoNo found = " << forwardHistoNo[i] <<
", which is NOT present in the data file!?!?";
586 std::cerr << std::endl <<
">> Will quit :-(";
587 std::cerr << std::endl;
589 forwardHistoNo.clear();
590 backwardHistoNo.clear();
597 if (!runData->
IsPresent(backwardHistoNo[i])) {
598 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:";
599 std::cerr << std::endl <<
">> backwardHistoNo found = " << backwardHistoNo[i] <<
", which is NOT present in the data file!?!?";
600 std::cerr << std::endl <<
">> Will quit :-(";
601 std::cerr << std::endl;
603 forwardHistoNo.clear();
604 backwardHistoNo.clear();
611 std::cout.precision(10);
612 std::cout << std::endl <<
">> PRunAsymmetry::PrepareData(): time resolution=" << std::fixed << runData->
GetTimeResolution() <<
"(ns)" << std::endl;
615 if (!
GetProperT0(runData, globalBlock, forwardHistoNo, backwardHistoNo)) {
620 std::vector<PDoubleVector> forward, backward;
621 forward.resize(forwardHistoNo.size());
622 for (UInt_t i=0; i<forwardHistoNo.size(); i++) {
623 forward[i].resize(runData->
GetDataBin(forwardHistoNo[i])->size());
624 forward[i] = *runData->
GetDataBin(forwardHistoNo[i]);
626 backward.resize(backwardHistoNo.size());
627 for (UInt_t i=0; i<backwardHistoNo.size(); i++) {
628 backward[i].resize(runData->
GetDataBin(backwardHistoNo[i])->size());
629 backward[i] = *runData->
GetDataBin(backwardHistoNo[i]);
639 if (addRunData ==
nullptr) {
640 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareData(): **ERROR** Couldn't get addrun " <<
fRunInfo->
GetRunName(i)->Data() <<
"!";
641 std::cerr << std::endl;
647 for (UInt_t k=0; k<forwardHistoNo.size(); k++) {
648 addRunSize = addRunData->
GetDataBin(forwardHistoNo[k])->size();
649 for (UInt_t j=0; j<addRunData->
GetDataBin(forwardHistoNo[k])->size(); j++) {
651 if ((static_cast<Int_t>(j)+static_cast<Int_t>(
fAddT0s[i-1][2*k])-static_cast<Int_t>(
fT0s[2*k]) >= 0) &&
652 (j+
static_cast<Int_t
>(
fAddT0s[i-1][2*k])-static_cast<Int_t>(
fT0s[2*k]) < addRunSize)) {
653 forward[k][j] += addRunData->
GetDataBin(forwardHistoNo[k])->at(j+static_cast<Int_t>(
fAddT0s[i-1][2*k])-static_cast<Int_t>(
fT0s[2*k]));
659 for (UInt_t k=0; k<backwardHistoNo.size(); k++) {
660 addRunSize = addRunData->
GetDataBin(backwardHistoNo[k])->size();
661 for (UInt_t j=0; j<addRunData->
GetDataBin(backwardHistoNo[k])->size(); j++) {
663 if ((static_cast<Int_t>(j)+static_cast<Int_t>(
fAddT0s[i-1][2*k+1])-static_cast<Int_t>(
fT0s[2*k+1]) >= 0) &&
664 (j+
static_cast<Int_t
>(
fAddT0s[i-1][2*k+1])-static_cast<Int_t>(
fT0s[2*k+1]) < addRunSize)) {
665 backward[k][j] += addRunData->
GetDataBin(backwardHistoNo[k])->at(j+static_cast<Int_t>(
fAddT0s[i-1][2*k+1])-static_cast<Int_t>(
fT0s[2*k+1]));
674 for (UInt_t i=0; i<
fForward.size(); i++) {
678 for (UInt_t i=0; i<
fBackward.size(); i++) {
683 for (UInt_t i=1; i<forwardHistoNo.size(); i++) {
684 for (UInt_t j=0; j<runData->
GetDataBin(forwardHistoNo[i])->size(); j++) {
687 fForward[j] += forward[i][j+
static_cast<Int_t
>(
fT0s[2*i])-static_cast<Int_t>(
fT0s[0])];
693 for (UInt_t i=1; i<backwardHistoNo.size(); i++) {
694 for (UInt_t j=0; j<runData->
GetDataBin(backwardHistoNo[i])->size(); j++) {
697 fBackward[j] += backward[i][j+
static_cast<Int_t
>(
fT0s[2*i+1])-static_cast<Int_t>(
fT0s[1])];
712 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareData(): **WARNING** Neither fix background nor background bins are given!";
713 std::cerr << std::endl <<
">> Will try the following:";
716 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ...";
717 std::cerr << std::endl;
726 UInt_t histoNo[2] = {forwardHistoNo[0], backwardHistoNo[0]};
754 forwardHistoNo.clear();
755 backwardHistoNo.clear();
782 std::cerr <<
"PRunAsymmetry::SubtractFixBkg(): **ERROR** no fixed bkg for forward set. Will do nothing here." << std::endl;
786 std::cerr <<
"PRunAsymmetry::SubtractFixBkg(): **ERROR** no fixed bkg for backward set. Will do nothing here." << std::endl;
787 std::cerr <<
" you need an entry like:" << std::endl;
788 std::cerr <<
" backgr.fix 2 3" << std::endl;
789 std::cerr <<
" i.e. two entries for forward and backward." << std::endl;
796 for (UInt_t i=0; i<
fForward.size(); i++) {
839 Double_t beamPeriod = 0.0;
854 for (UInt_t i=0; i<2; i++) {
855 if (end[i] < start[i]) {
856 std::cout << std::endl <<
"PRunAsymmetry::SubtractEstimatedBkg(): end = " << end[i] <<
" > start = " << start[i] <<
"! Will swap them!";
857 UInt_t keep = end[i];
864 for (UInt_t i=0; i<2; i++) {
865 if (beamPeriod != 0.0) {
867 UInt_t fullCycles =
static_cast<UInt_t
>(timeBkg/beamPeriod);
870 std::cout <<
"PRunAsymmetry::SubtractEstimatedBkg(): Background " << start[i] <<
", " << end[i] << std::endl;
871 if (end[i] == start[i])
877 if ((start[0] < 0) || (start[0] >=
fForward.size()) ||
878 (start[1] < 0) || (start[1] >=
fBackward.size())) {
879 std::cerr << std::endl <<
">> PRunAsymmetry::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!";
880 std::cerr << std::endl <<
">> histo lengths (f/b) = (" <<
fForward.size() <<
"/" <<
fBackward.size() <<
").";
881 std::cerr << std::endl <<
">> background start (f/b) = (" << start[0] <<
"/" << start[1] <<
").";
886 if ((end[0] < 0) || (end[0] >=
fForward.size()) ||
887 (end[1] < 0) || (end[1] >=
fBackward.size())) {
888 std::cerr << std::endl <<
">> PRunAsymmetry::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!";
889 std::cerr << std::endl <<
">> histo lengths (f/b) = (" <<
fForward.size() <<
"/" <<
fBackward.size() <<
").";
890 std::cerr << std::endl <<
">> background end (f/b) = (" << end[0] <<
"/" << end[1] <<
").";
895 Double_t bkg[2] = {0.0, 0.0};
896 Double_t errBkg[2] = {0.0, 0.0};
899 for (UInt_t i=start[0]; i<=end[0]; i++)
901 errBkg[0] = TMath::Sqrt(bkg[0])/(end[0] - start[0] + 1);
902 bkg[0] /=
static_cast<Double_t
>(end[0] - start[0] + 1);
903 std::cout << std::endl <<
">> estimated forward histo background: " << bkg[0];
906 for (UInt_t i=start[1]; i<=end[1]; i++)
908 errBkg[1] = TMath::Sqrt(bkg[1])/(end[1] - start[1] + 1);
909 bkg[1] /=
static_cast<Double_t
>(end[1] - start[1] + 1);
910 std::cout << std::endl <<
">> estimated backward histo background: " << bkg[1] << std::endl;
913 Double_t errVal = 0.0;
914 for (UInt_t i=0; i<
fForward.size(); i++) {
916 errVal = TMath::Sqrt(
fForward[i]+errBkg[0]*errBkg[0]);
921 errVal = TMath::Sqrt(
fBackward[i]+errBkg[1]*errBkg[1]);
928 for (UInt_t i=0; i<
fForward.size(); i++) {
961 Double_t value = 0.0;
962 Double_t error = 0.0;
1009 UInt_t noOfBins = forwardPacked.
GetValue()->size();
1010 if (forwardPacked.
GetValue()->size() != backwardPacked.
GetValue()->size()) {
1012 noOfBins = backwardPacked.
GetValue()->size();
1017 Double_t f, b, ef, eb;
1022 for (UInt_t i=0; i<noOfBins; i++) {
1024 f = forwardPacked.
GetValue()->at(i);
1025 b = backwardPacked.
GetValue()->at(i);
1026 ef = forwardPacked.
GetError()->at(i);
1027 eb = backwardPacked.
GetError()->at(i);
1030 asym = (f-b) / (f+b);
1036 error = 2.0/((f+b)*(f+b))*TMath::Sqrt(b*b*ef*ef+eb*eb*f*f);
1081 std::vector<Double_t> par;
1083 for (UInt_t i=0; i<paramList->size(); i++)
1084 par.push_back((*paramList)[i].fValue);
1092 Int_t t0[2] = {
static_cast<Int_t
>(
fT0s[0]), static_cast<Int_t>(
fT0s[1])};
1096 if (start[0]-t0[0] != start[1]-t0[1]) {
1097 if (abs(start[0]-t0[0]) > abs(start[1]-t0[1])) {
1099 fgb[1] = t0[1] + start[0]-t0[0];
1100 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareViewData(): **WARNING** needed to shift backward fgb from ";
1101 std::cerr << start[1] <<
" to " << fgb[1] << std::endl;
1103 fgb[0] = t0[0] + start[1]-t0[1];
1105 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareViewData(): **WARNING** needed to shift forward fgb from ";
1106 std::cerr << start[0] <<
" to " << fgb[0] << std::endl;
1113 Int_t val = fgb[0]-packing*(fgb[0]/packing);
1115 if (fgb[1] - fgb[0] < 0)
1117 }
while (val + fgb[1] - fgb[0] < 0);
1120 start[1] = val + fgb[1] - fgb[0];
1123 UInt_t noOfBins0 = (runData->
GetDataBin(histoNo[0])->size()-start[0])/packing;
1124 UInt_t noOfBins1 = (runData->
GetDataBin(histoNo[1])->size()-start[1])/packing;
1125 if (noOfBins0 > noOfBins1)
1126 noOfBins0 = noOfBins1;
1127 end[0] = start[0] + noOfBins0 * packing;
1128 end[1] = start[1] + noOfBins0 * packing;
1132 for (UInt_t i=0; i<2; i++) {
1133 if (end[i] < start[i]) {
1134 Int_t keep = end[i];
1139 if ((start[i] < 0) || (start[i] >
static_cast<Int_t
>(runData->
GetDataBin(histoNo[i])->size()))) {
1140 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareViewData(): **ERROR** start data bin doesn't make any sense!";
1141 std::cerr << std::endl;
1145 if ((end[i] < 0) || (end[i] >
static_cast<Int_t
>(runData->
GetDataBin(histoNo[i])->size()))) {
1146 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareViewData(): **ERROR** end data bin doesn't make any sense!";
1147 std::cerr << std::endl;
1151 if ((t0[i] < 0) || (t0[i] >
static_cast<Int_t
>(runData->
GetDataBin(histoNo[i])->size()))) {
1152 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareViewData(): **ERROR** t0 data bin doesn't make any sense!";
1153 std::cerr << std::endl;
1161 Double_t value = 0.0;
1162 Double_t error = 0.0;
1165 for (Int_t i=start[0]; i<end[0]; i++) {
1170 if (((i-start[0]) % packing == 0) && (i != start[0])) {
1188 for (Int_t i=start[1]; i<end[1]; i++) {
1193 if (((i-start[1]) % packing == 0) && (i != start[1])) {
1211 UInt_t noOfBins = forwardPacked.
GetValue()->size();
1212 if (forwardPacked.
GetValue()->size() != backwardPacked.
GetValue()->size()) {
1214 noOfBins = backwardPacked.
GetValue()->size();
1219 Double_t f, b, ef, eb, alpha = 1.0, beta = 1.0;
1275 for (UInt_t i=0; i<forwardPacked.
GetValue()->size(); i++) {
1277 f = forwardPacked.
GetValue()->at(i);
1278 b = backwardPacked.
GetValue()->at(i);
1279 ef = forwardPacked.
GetError()->at(i);
1280 eb = backwardPacked.
GetError()->at(i);
1283 asym = (alpha*f-b) / (alpha*beta*f+b);
1289 error = 2.0/((f+b)*(f+b))*TMath::Sqrt(b*b*ef*ef+eb*eb*f*f);
1311 UInt_t size = runData->
GetDataBin(histoNo[0])->size()/packing;
1323 for (UInt_t i=0; i<size; i++) {
1326 if (fabs(value) > 10.0) {
1359 std::vector<Double_t> par;
1361 for (UInt_t i=0; i<paramList->size(); i++)
1362 par.push_back((*paramList)[i].fValue);
1371 Int_t t0[2] = {
static_cast<Int_t
>(
fT0s[0]), static_cast<Int_t>(
fT0s[1])};
1376 if (start[0]-t0[0] != start[1]-t0[1]) {
1377 if (abs(start[0]-t0[0]) > abs(start[1]-t0[1])) {
1379 fgb[1] = t0[1] + start[0]-t0[0];
1380 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareRRFViewData(): **WARNING** needed to shift backward fgb from ";
1381 std::cerr << start[1] <<
" to " << fgb[1] << std::endl;
1383 fgb[0] = t0[0] + start[1]-t0[1];
1385 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareRRFViewData(): **WARNING** needed to shift forward fgb from ";
1386 std::cerr << start[1] <<
" to " << fgb[0] << std::endl;
1393 Int_t val = fgb[0]-packing*(fgb[0]/packing);
1395 if (fgb[1] - fgb[0] < 0)
1397 }
while (val + fgb[1] - fgb[0] < 0);
1400 start[1] = val + fgb[1] - fgb[0];
1403 UInt_t noOfBins0 = runData->
GetDataBin(histoNo[0])->size()-start[0];
1404 UInt_t noOfBins1 = runData->
GetDataBin(histoNo[1])->size()-start[1];
1405 if (noOfBins0 > noOfBins1)
1406 noOfBins0 = noOfBins1;
1407 end[0] = start[0] + noOfBins0;
1408 end[1] = start[1] + noOfBins0;
1412 for (UInt_t i=0; i<2; i++) {
1413 if (end[i] < start[i]) {
1414 Int_t keep = end[i];
1419 if ((start[i] < 0) || (start[i] > static_cast<Int_t>(runData->
GetDataBin(histoNo[i])->size()))) {
1420 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** start data bin doesn't make any sense!";
1421 std::cerr << std::endl;
1425 if ((end[i] < 0) || (end[i] >
static_cast<Int_t
>(runData->
GetDataBin(histoNo[i])->size()))) {
1426 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** end data bin doesn't make any sense!";
1427 std::cerr << std::endl;
1431 if ((t0[i] < 0) || (t0[i] >
static_cast<Int_t
>(runData->
GetDataBin(histoNo[i])->size()))) {
1432 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** t0 data bin doesn't make any sense!";
1433 std::cerr << std::endl;
1444 Double_t error = 0.0;
1446 for (Int_t i=start[0]; i<end[0]; i++) {
1451 for (Int_t i=start[1]; i<end[1]; i++) {
1457 UInt_t noOfBins = forward.size();
1458 if (forward.size() != backward.size()) {
1459 if (forward.size() > backward.size())
1460 noOfBins = backward.size();
1466 Double_t f, b, ef, eb, alpha = 1.0, beta = 1.0;
1518 for (UInt_t i=0; i<noOfBins; i++) {
1523 eb = backwardErr[i];
1526 asym = (alpha*f-b) / (alpha*beta*f+b);
1529 asymmetry.push_back(asym);
1532 error = 2.0/((f+b)*(f+b))*TMath::Sqrt(b*b*ef*ef+eb*eb*f*f);
1535 asymmetryErr.push_back(error);
1550 Double_t gammaRRF = 0.0, wRRF = 0.0, phaseRRF = 0.0;
1555 gammaRRF = TMath::TwoPi()*1.0e-3;
1558 gammaRRF = TMath::TwoPi();
1570 gammaRRF = TMath::TwoPi();
1576 for (UInt_t i=0; i<asymmetry.size(); i++) {
1577 time =
fTimeResolution*(
static_cast<Double_t
>(start[0])-t0[0]+static_cast<Double_t>(i));
1578 asymmetry[i] *= 2.0*TMath::Cos(wRRF*time+phaseRRF);
1584 Double_t value = 0.0;
1586 for (UInt_t i=0; i<asymmetry.size(); i++) {
1587 if ((i % packing == 0) && (i != 0)) {
1595 value += asymmetry[i];
1596 error += asymmetryErr[i]*asymmetryErr[i];
1608 UInt_t rebinRRF =
static_cast<UInt_t
>((TMath::Pi()/2.0/wRRF)/
fTimeResolution);
1617 Double_t theoryValue;
1618 for (UInt_t i=0; i<asymmetry.size(); i++) {
1621 theoryValue *= 2.0*TMath::Cos(wRRF * time + phaseRRF);
1623 if (fabs(theoryValue) > 10.0) {
1635 Double_t dval = 0.0;
1637 if ((i % rebinRRF == 0) && (i != 0)) {
1638 theo.push_back(dval/rebinRRF);
1665 backwardErr.clear();
1667 asymmetryErr.clear();
1699 size_t size = 2*forwardHistoNo.size();
1700 if (backwardHistoNo.size() > forwardHistoNo.size())
1701 size = 2*backwardHistoNo.size();
1703 for (UInt_t i=0; i<
fT0s.size(); i++) {
1714 if (
fT0s[i] == -1) {
1720 for (UInt_t i=0; i<forwardHistoNo.size(); i++) {
1721 if (
fT0s[2*i] == -1.0)
1722 if (runData->
GetT0Bin(forwardHistoNo[i]) > 0.0) {
1727 for (UInt_t i=0; i<backwardHistoNo.size(); i++) {
1728 if (
fT0s[2*i+1] == -1.0)
1729 if (runData->
GetT0Bin(backwardHistoNo[i]) > 0.0) {
1736 for (UInt_t i=0; i<forwardHistoNo.size(); i++) {
1737 if (
fT0s[2*i] == -1.0) {
1741 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
1743 std::cerr << std::endl <<
">> will try the estimated one: forward t0 = " << runData->
GetT0BinEstimated(forwardHistoNo[i]);
1744 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
1745 std::cerr << std::endl;
1748 for (UInt_t i=0; i<backwardHistoNo.size(); i++) {
1749 if (
fT0s[2*i+1] == -1.0) {
1753 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
1755 std::cerr << std::endl <<
">> will try the estimated one: backward t0 = " << runData->
GetT0BinEstimated(backwardHistoNo[i]);
1756 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
1757 std::cerr << std::endl;
1762 for (UInt_t i=0; i<forwardHistoNo.size(); i++) {
1763 if ((
fT0s[2*i] < 0) || (
fT0s[2*i] >
static_cast<Int_t
>(runData->
GetDataBin(forwardHistoNo[i])->size()))) {
1764 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperT0(): **ERROR** t0 data bin (" <<
fT0s[2*i] <<
") doesn't make any sense!";
1765 std::cerr << std::endl <<
">> forwardHistoNo " << forwardHistoNo[i];
1766 std::cerr << std::endl;
1770 for (UInt_t i=0; i<backwardHistoNo.size(); i++) {
1771 if ((
fT0s[2*i+1] < 0) || (
fT0s[2*i+1] >
static_cast<Int_t
>(runData->
GetDataBin(backwardHistoNo[i])->size()))) {
1772 std::cerr << std::endl <<
">> PRunAsymmetry::PrepareData(): **ERROR** t0 data bin (" <<
fT0s[2*i+1] <<
") doesn't make any sense!";
1773 std::cerr << std::endl <<
">> backwardHistoNo " << backwardHistoNo[i];
1774 std::cerr << std::endl;
1786 if (addRunData == 0) {
1787 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperT0(): **ERROR** Couldn't get addrun " <<
fRunInfo->
GetRunName(i)->Data() <<
"!";
1788 std::cerr << std::endl;
1795 fAddT0s[i-1].resize(2*forwardHistoNo.size());
1796 for (UInt_t j=0; j<
fAddT0s[i-1].size(); j++) {
1806 for (UInt_t j=0; j<forwardHistoNo.size(); j++) {
1807 if (
fAddT0s[i-1][2*j] == -1.0)
1808 if (addRunData->
GetT0Bin(forwardHistoNo[j]) > 0.0) {
1813 for (UInt_t j=0; j<backwardHistoNo.size(); j++) {
1814 if (
fAddT0s[i-1][2*j+1] == -1.0)
1815 if (addRunData->
GetT0Bin(backwardHistoNo[j]) > 0.0) {
1822 for (UInt_t j=0; j<forwardHistoNo.size(); j++) {
1823 if (
fAddT0s[i-1][2*j] == -1.0) {
1827 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
1829 std::cerr << std::endl <<
">> will try the estimated one: forward t0 = " << addRunData->
GetT0BinEstimated(forwardHistoNo[j]);
1830 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
1831 std::cerr << std::endl;
1834 for (UInt_t j=0; j<backwardHistoNo.size(); j++) {
1835 if (
fAddT0s[i-1][2*j+1] == -1.0) {
1839 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
1841 std::cerr << std::endl <<
">> will try the estimated one: backward t0 = " << runData->
GetT0BinEstimated(backwardHistoNo[j]);
1842 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
1843 std::cerr << std::endl;
1874 if (start[0] == -1) {
1877 if (start[1] == -1) {
1887 Double_t t0[2] = {
fT0s[0],
fT0s[1]};
1892 start[0] =
static_cast<Int_t
>(t0[0])+offset;
1894 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (forward) was not provided, will try data range start = t0+" << offset <<
"(=10ns) = " << start[0] <<
".";
1895 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
1896 std::cerr << std::endl;
1899 start[1] =
static_cast<Int_t
>(t0[1])+offset;
1901 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (backward) was not provided, will try data range start = t0+" << offset <<
"(=10ns) = " << start[1] <<
".";
1902 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
1903 std::cerr << std::endl;
1906 end[0] = runData->
GetDataBin(histoNo[0])->size();
1908 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (forward) was not provided, will try data range end = " << end[0] <<
".";
1909 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
1910 std::cerr << std::endl;
1913 end[1] = runData->
GetDataBin(histoNo[1])->size();
1915 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperDataRange(): **WARNING** data range (backward) was not provided, will try data range end = " << end[1] <<
".";
1916 std::cerr << std::endl <<
">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
1917 std::cerr << std::endl;
1922 for (UInt_t i=0; i<2; i++) {
1923 if (end[i] < start[i]) {
1924 Int_t keep = end[i];
1929 if ((start[i] < 0) || (start[i] > static_cast<Int_t>(runData->
GetDataBin(histoNo[i])->size()))) {
1930 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperDataRange(): **ERROR** start data bin doesn't make any sense!";
1931 std::cerr << std::endl;
1936 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperDataRange(): **ERROR** end data bin (" << end[i] <<
") doesn't make any sense!";
1937 std::cerr << std::endl;
1940 if (end[i] > static_cast<Int_t>(runData->
GetDataBin(histoNo[i])->size())) {
1941 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperDataRange(): **WARNING** end data bin (" << end[i] <<
") > histo length (" <<
static_cast<Int_t
>(runData->
GetDataBin(histoNo[i])->size()) <<
").";
1942 std::cerr << std::endl <<
">> Will set end = (histo length - 1). Consider to change it in the msr-file." << std::endl;
1943 std::cerr << std::endl;
1944 end[i] =
static_cast<Int_t
>(runData->
GetDataBin(histoNo[i])->size())-1;
1947 if ((t0[i] < 0) || (t0[i] >
static_cast<Int_t
>(runData->
GetDataBin(histoNo[i])->size()))) {
1948 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperDataRange(): **ERROR** t0 data bin doesn't make any sense!";
1949 std::cerr << std::endl;
1955 if (fabs(static_cast<Double_t>(start[0])-t0[0]) > fabs(static_cast<Double_t>(start[1])-t0[1])){
1956 start[1] =
static_cast<Int_t
>(t0[1] +
static_cast<Double_t
>(start[0]) - t0[0]);
1957 end[1] =
static_cast<Int_t
>(t0[1] +
static_cast<Double_t
>(end[0]) - t0[0]);
1958 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperDataRange **WARNING** needed to shift backward data range.";
1960 std::cerr << std::endl <<
">> used : " << start[1] <<
", " << end[1];
1961 std::cerr << std::endl;
1963 if (fabs(static_cast<Double_t>(start[0])-t0[0]) < fabs(static_cast<Double_t>(start[1])-t0[1])){
1964 start[0] =
static_cast<Int_t
>(t0[0] +
static_cast<Double_t
>(start[1]) - t0[1]);
1965 end[0] =
static_cast<Int_t
>(t0[0] +
static_cast<Double_t
>(end[1]) - t0[1]);
1966 std::cerr << std::endl <<
">> PRunAsymmetry::GetProperDataRange **WARNING** needed to shift forward data range.";
1968 std::cerr << std::endl <<
">> used : " << start[0] <<
", " << end[0];
1969 std::cerr << std::endl;
2024 std::cerr <<
">> PRunSingleHisto::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << std::endl;
2025 std::cerr <<
">> Will set it to fgb/lgb which given in time is: " <<
fFitStartTime <<
"..." <<
fFitEndTime <<
" (usec)" << std::endl;
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)
UInt_t fNoOfFitBins
number of bins to be be fitted
virtual Bool_t GetProperDataRange(PRawRunData *runData, UInt_t histoNo[2])
virtual const PDoubleVector * GetError()
Int_t fStartTimeBin
bin at which the fit starts
virtual Bool_t PrepareFitData()
virtual Int_t GetNoOfFuncs()
virtual Int_t GetDataRange(UInt_t idx)
virtual Double_t GetT0Bin(UInt_t idx=0)
virtual const Double_t GetTimeResolution()
Int_t fEndTimeBin
bin at which the fit ends
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 void SetBkgEstimated(Double_t dval, Int_t idx)
virtual Int_t GetFitRangeOffset(UInt_t idx)
UInt_t fAlphaBetaTag
; ; ; .
virtual Bool_t GetProperT0(PRawRunData *runData, PMsrGlobalBlock *globalBlock, PUIntVector &forwardHisto, PUIntVector &backwardHistoNo)
virtual void SetTheoryTimeStart(Double_t dval)
PMsrHandler * fMsrInfo
msr-file handler
virtual Bool_t IsFitRangeInBin()
PDoubleVector fForwardErr
forward histo errors
virtual const PDoublePairVector * GetTemperature() const
Double_t fTimeResolution
time resolution in (us)
virtual const PDoubleVector * GetTheory()
PMetaData fMetaData
keeps the meta data from the data file like field, temperature, energy, ...
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()
Int_t fGoodBins[4]
keep first/last good bins. 0=fgb, 1=lgb (forward); 2=fgb, 3=lgb (backward)
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
std::vector< Double_t > PDoubleVector
virtual const Bool_t IsPresent(UInt_t histoNo)
#define MSR_PARAM_FUN_OFFSET
#define ACCEL_PERIOD_TRIUMF
virtual void CalcNoOfFitBins()
virtual const Double_t GetT0Bin(const UInt_t histoNo)
Bool_t fTheoAsData
true=only calculate the theory points at the data points, false=calculate more points for the theory ...
virtual Int_t GetBackwardHistoNo(UInt_t idx=0)
PDoubleVector fBackwardErr
backward histo errors
virtual void SetT0Bin(Double_t dval, Int_t idx=-1)
virtual Double_t CalcMaxLikelihood(const std::vector< Double_t > &par)
virtual void AppendTheoryValue(Double_t dval)
virtual PMsrGlobalBlock * GetMsrGlobal()
virtual Int_t GetAddT0BinSize(UInt_t addRunIdx)
virtual void SetDataTimeStart(Double_t dval)
virtual Int_t GetFitRangeOffset(UInt_t idx)
virtual UInt_t GetNoOfFitBins()
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 Double_t CalcChiSquareExpected(const std::vector< Double_t > &par)
PDoubleVector fForward
forward histo data
virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock)
virtual void CalculateKaiserFilterCoeff(Double_t wc, Double_t A, Double_t dw)
virtual Double_t GetBkgFix(UInt_t idx)
virtual UInt_t GetFuncNo(Int_t idx)
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 Bool_t PrepareViewData(PRawRunData *runData, UInt_t histoNo[2])
virtual PMsrPlotList * GetMsrPlotList()
Bool_t SubtractEstimatedBkg()
virtual Int_t GetBkgRange(UInt_t idx)
EPMusrHandleTag fHandleTag
tag telling whether this is used for fit, view, ...
virtual UInt_t GetForwardHistoNoSize()
virtual void SetFitRangeBin(const TString fitRange)
PMsrRunBlock * fRunInfo
run info used to filter out needed infos of a run
virtual const Double_t GetEnergy()
PDoubleVector fBackward
backward histo data
virtual void SetBkgRange(Int_t ival, Int_t idx)
virtual void SetFitRange(Double_t dval, UInt_t idx)
Double_t fFitEndTime
fit end time
virtual void SetTheoryTimeStep(Double_t dval)
virtual TString * GetInstitute(UInt_t idx=0)
virtual void CalcTheory()
virtual Bool_t PrepareData()
virtual Int_t GetAlphaParamNo()
virtual Bool_t PrepareRRFViewData(PRawRunData *runData, UInt_t histoNo[2])
virtual void SetFitRange(Double_t dval, UInt_t idx)
Double_t fFitStartTime
fit start time
virtual Int_t GetBetaParamNo()
virtual PMsrParamList * GetMsrParamList()
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 CalcChiSquare(const std::vector< Double_t > &par)
virtual Double_t GetDataTimeStart()
virtual UInt_t GetRunNameSize()
virtual Int_t GetDataRange(UInt_t idx)
virtual const Double_t GetT0BinEstimated(const UInt_t histoNo)
virtual void FilterTheo()
std::unique_ptr< PTheory > fTheory
theory needed to calculate chi-square
virtual Int_t GetPacking()
virtual Double_t GetFitRange(UInt_t idx)
virtual void ReplaceTheory(const PDoubleVector &theo)
virtual Double_t GetDataTimeStep()
Int_t fRunNo
number of the run within the msr-file
virtual TString * GetRunName(UInt_t idx=0)
virtual Double_t GetFitRange(UInt_t idx)
Int_t fPacking
packing for this particular run. Either given in the RUN- or GLOBAL-block.
PDoubleVector fFuncValues
is keeping the values of the functions from the FUNCTIONS block
virtual UInt_t GetBackwardHistoNoSize()