try to setup a much cleaner handling for t0's, fgb/lgb, and fit-range
This commit is contained in:
parent
0d4d0573e1
commit
e87672f632
File diff suppressed because it is too large
Load Diff
@ -493,6 +493,17 @@ Bool_t PRunMuMinus::PrepareData()
|
||||
}
|
||||
}
|
||||
|
||||
// keep the time resolution in (us)
|
||||
fTimeResolution = runData->GetTimeResolution()/1.0e3;
|
||||
cout.precision(10);
|
||||
cout << endl << ">> PRunMuMinus::PrepareData(): time resolution=" << fixed << runData->GetTimeResolution() << "(ns)" << endl;
|
||||
|
||||
// get all the proper t0's and addt0's for the current RUN block
|
||||
if (!GetProperT0(runData, globalBlock, histoNo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// feed all T0's
|
||||
// first init T0's, T0's are stored as (forward T0, backward T0, etc.)
|
||||
fT0s.clear();
|
||||
@ -544,7 +555,7 @@ Bool_t PRunMuMinus::PrepareData()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
// keep the histo of each group at this point (addruns handled below)
|
||||
vector<PDoubleVector> forward;
|
||||
forward.resize(histoNo.size()); // resize to number of groups
|
||||
@ -566,6 +577,7 @@ Bool_t PRunMuMinus::PrepareData()
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// feed all T0's
|
||||
// first init T0's, T0's are stored as (forward T0, backward T0, etc.)
|
||||
PDoubleVector t0Add;
|
||||
@ -610,21 +622,18 @@ Bool_t PRunMuMinus::PrepareData()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
// add forward run
|
||||
UInt_t addRunSize;
|
||||
for (UInt_t k=0; k<histoNo.size(); k++) { // fill each group
|
||||
addRunSize = addRunData->GetDataBin(histoNo[k])->size();
|
||||
for (UInt_t j=0; j<addRunData->GetDataBin(histoNo[k])->size(); j++) { // loop over the bin indices
|
||||
// make sure that the index stays in the proper range
|
||||
if ((j+(Int_t)t0Add[k]-(Int_t)fT0s[k] >= 0) && (j+(Int_t)t0Add[k]-(Int_t)fT0s[k] < addRunSize)) {
|
||||
forward[k][j] += addRunData->GetDataBin(histoNo[k])->at(j+(Int_t)t0Add[k]-(Int_t)fT0s[k]);
|
||||
if ((j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k] >= 0) && (j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k] < addRunSize)) {
|
||||
forward[k][j] += addRunData->GetDataBin(histoNo[k])->at(j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clean up
|
||||
t0Add.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -644,11 +653,15 @@ Bool_t PRunMuMinus::PrepareData()
|
||||
}
|
||||
}
|
||||
|
||||
// keep the time resolution in (us)
|
||||
fTimeResolution = runData->GetTimeResolution()/1.0e3;
|
||||
cout.precision(10);
|
||||
cout << endl << ">> PRunMuMinus::PrepareData(): time resolution=" << fixed << runData->GetTimeResolution() << "(ns)" << endl;
|
||||
// get the data range (fgb/lgb) for the current RUN block
|
||||
if (!GetProperDataRange()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// get the fit range for the current RUN block
|
||||
GetProperFitRange(globalBlock);
|
||||
|
||||
/*
|
||||
// first get start data, end data, and t0
|
||||
Int_t start;
|
||||
Int_t end;
|
||||
@ -732,7 +745,9 @@ Bool_t PRunMuMinus::PrepareData()
|
||||
return false;
|
||||
}
|
||||
cout << endl << "debug> PRunMuMinus::PrepareData(): fFitStartTime=" << fFitStartTime << ", fFitEndTime=" << fFitEndTime << endl;
|
||||
*/
|
||||
|
||||
// do the more fit/view specific stuff
|
||||
if (fHandleTag == kFit)
|
||||
success = PrepareFitData(runData, histoNo[0]);
|
||||
else if (fHandleTag == kView)
|
||||
@ -768,6 +783,7 @@ Bool_t PRunMuMinus::PrepareFitData(PRawRunData* runData, const UInt_t histoNo)
|
||||
// transform raw histo data. This is done the following way (for details see the manual):
|
||||
// for the single histo fit, just the rebinned raw data are copied
|
||||
|
||||
/*
|
||||
// first get start data, end data, and t0
|
||||
Int_t start;
|
||||
Int_t end;
|
||||
@ -822,15 +838,16 @@ Bool_t PRunMuMinus::PrepareFitData(PRawRunData* runData, const UInt_t histoNo)
|
||||
// keep good bins for potential latter use
|
||||
fGoodBins[0] = start;
|
||||
fGoodBins[1] = end;
|
||||
*/
|
||||
|
||||
// everything looks fine, hence fill data set
|
||||
Int_t t0 = (Int_t)fT0s[0];
|
||||
Double_t value = 0.0;
|
||||
// data start at data_start-t0
|
||||
// time shifted so that packing is included correctly, i.e. t0 == t0 after packing
|
||||
fData.SetDataTimeStart(fTimeResolution*((Double_t)start-(Double_t)t0+(Double_t)(fPacking-1)/2.0));
|
||||
fData.SetDataTimeStart(fTimeResolution*((Double_t)fGoodBins[0]-(Double_t)t0+(Double_t)(fPacking-1)/2.0));
|
||||
fData.SetDataTimeStep(fTimeResolution*fPacking);
|
||||
for (Int_t i=start; i<end; i++) {
|
||||
for (Int_t i=fGoodBins[0]; i<fGoodBins[1]; i++) {
|
||||
if (fPacking == 1) {
|
||||
value = fForward[i];
|
||||
fData.AppendValue(value);
|
||||
@ -839,7 +856,7 @@ Bool_t PRunMuMinus::PrepareFitData(PRawRunData* runData, const UInt_t histoNo)
|
||||
else
|
||||
fData.AppendErrorValue(TMath::Sqrt(value));
|
||||
} else { // packed data, i.e. fPacking > 1
|
||||
if (((i-start) % fPacking == 0) && (i != start)) { // fill data
|
||||
if (((i-fGoodBins[0]) % fPacking == 0) && (i != fGoodBins[0])) { // fill data
|
||||
fData.AppendValue(value);
|
||||
if (value == 0.0)
|
||||
fData.AppendErrorValue(1.0);
|
||||
@ -892,7 +909,7 @@ Bool_t PRunMuMinus::PrepareRawViewData(PRawRunData* runData, const UInt_t histoN
|
||||
|
||||
// raw data, since PMusrCanvas is doing ranging etc.
|
||||
// start = the first bin which is a multiple of packing backward from first good data bin
|
||||
Int_t start = fRunInfo->GetDataRange(0) - (fRunInfo->GetDataRange(0)/packing)*packing;
|
||||
Int_t start = fGoodBins[0] - (fGoodBins[0]/packing)*packing;
|
||||
// end = last bin starting from start which is a multipl of packing and still within the data
|
||||
Int_t end = start + ((fForward.size()-start)/packing)*packing;
|
||||
// check if data range has been provided, and if not try to estimate them
|
||||
@ -991,3 +1008,260 @@ Bool_t PRunMuMinus::PrepareRawViewData(PRawRunData* runData, const UInt_t histoN
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetProperT0 (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Get the proper t0 for the single histogram run.
|
||||
* -# the t0 vector size = number of detectors (grouping) for forward.
|
||||
* -# initialize t0's with -1
|
||||
* -# fill t0's from RUN block
|
||||
* -# if t0's are missing (i.e. t0 == -1), try to fill from the GLOBAL block.
|
||||
* -# if t0's are missing, try t0's from the data file
|
||||
* -# if t0's are missing, try to estimate them
|
||||
*
|
||||
* \param histoNo histogram number vector of forward; histoNo = msr-file forward + redGreen_offset - 1
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - true if everthing went smooth
|
||||
* - false, otherwise.
|
||||
*/
|
||||
Bool_t PRunMuMinus::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo)
|
||||
{
|
||||
// feed all T0's
|
||||
// first init T0's, T0's are stored as (forward T0, backward T0, etc.)
|
||||
fT0s.clear();
|
||||
fT0s.resize(histoNo.size());
|
||||
for (UInt_t i=0; i<fT0s.size(); i++) {
|
||||
fT0s[i] = -1.0;
|
||||
}
|
||||
|
||||
// fill in the T0's from the msr-file (if present)
|
||||
for (UInt_t i=0; i<fRunInfo->GetT0BinSize(); i++) {
|
||||
fT0s[i] = fRunInfo->GetT0Bin(i);
|
||||
}
|
||||
|
||||
// fill in the T0's from the GLOBAL block section (if present)
|
||||
for (UInt_t i=0; i<globalBlock->GetT0BinSize(); i++) {
|
||||
if (fT0s[i] == -1) { // i.e. not given in the RUN block section
|
||||
fT0s[i] = globalBlock->GetT0Bin(i);
|
||||
}
|
||||
}
|
||||
|
||||
// fill in the T0's from the data file, if not already present in the msr-file
|
||||
for (UInt_t i=0; i<histoNo.size(); i++) {
|
||||
if (fT0s[i] == -1.0) { // i.e. not present in the msr-file, try the data file
|
||||
if (runData->GetT0Bin(histoNo[i]) > 0.0) {
|
||||
fT0s[i] = runData->GetT0Bin(histoNo[i]);
|
||||
fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fill in the T0's gaps, i.e. in case the T0's are NOT in the msr-file and NOT in the data file
|
||||
for (UInt_t i=0; i<histoNo.size(); i++) {
|
||||
if (fT0s[i] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
|
||||
fT0s[i] = runData->GetT0BinEstimated(histoNo[i]);
|
||||
fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file
|
||||
|
||||
cerr << endl << ">> PRunMuMinus::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
|
||||
cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data();
|
||||
cerr << endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(histoNo[i]);
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
|
||||
cerr << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// check if t0 is within proper bounds
|
||||
for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); i++) {
|
||||
if ((fT0s[i] < 0) || (fT0s[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) {
|
||||
cerr << endl << ">> PRunMuMinus::GetProperT0(): **ERROR** t0 data bin (" << fT0s[i] << ") doesn't make any sense!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// check if there are runs to be added to the current one
|
||||
if (fRunInfo->GetRunNameSize() > 1) { // runs to be added present
|
||||
PRawRunData *addRunData;
|
||||
fAddT0s.resize(fRunInfo->GetRunNameSize()-1); // resize to the number of addruns
|
||||
for (UInt_t i=1; i<fRunInfo->GetRunNameSize(); i++) {
|
||||
|
||||
// get run to be added to the main one
|
||||
addRunData = fRawData->GetRunData(*fRunInfo->GetRunName(i));
|
||||
if (addRunData == 0) { // couldn't get run
|
||||
cerr << endl << ">> PRunMuMinus::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// feed all T0's
|
||||
// first init T0's, T0's are stored as (forward T0, backward T0, etc.)
|
||||
fAddT0s[i-1].resize(histoNo.size());
|
||||
for (UInt_t j=0; j<fAddT0s[i-1].size(); j++) {
|
||||
fAddT0s[i-1][j] = -1.0;
|
||||
}
|
||||
|
||||
// fill in the T0's from the msr-file (if present)
|
||||
for (UInt_t j=0; j<fRunInfo->GetT0BinSize(); j++) {
|
||||
fAddT0s[i-1][j] = fRunInfo->GetAddT0Bin(i-1,j); // addRunIdx starts at 0
|
||||
}
|
||||
|
||||
// fill in the T0's from the data file, if not already present in the msr-file
|
||||
for (UInt_t j=0; j<histoNo.size(); j++) {
|
||||
if (fAddT0s[i-1][j] == -1.0) // i.e. not present in the msr-file, try the data file
|
||||
if (addRunData->GetT0Bin(histoNo[j]) > 0.0) {
|
||||
fAddT0s[i-1][j] = addRunData->GetT0Bin(histoNo[j]);
|
||||
fRunInfo->SetAddT0Bin(fAddT0s[i-1][j], i-1, j); // keep value for the msr-file
|
||||
}
|
||||
}
|
||||
|
||||
// fill in the T0's gaps, i.e. in case the T0's are NOT in the msr-file and NOT in the data file
|
||||
for (UInt_t j=0; j<histoNo.size(); j++) {
|
||||
if (fAddT0s[i-1][j] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
|
||||
fAddT0s[i-1][j] = addRunData->GetT0BinEstimated(histoNo[j]);
|
||||
fRunInfo->SetAddT0Bin(fAddT0s[i-1][j], i-1, j); // keep value for the msr-file
|
||||
|
||||
cerr << endl << ">> PRunMuMinus::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
|
||||
cerr << endl << ">> run: " << fRunInfo->GetRunName(i)->Data();
|
||||
cerr << endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(histoNo[j]);
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
|
||||
cerr << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// check if t0 is within proper bounds
|
||||
for (UInt_t j=0; j<fRunInfo->GetForwardHistoNoSize(); j++) {
|
||||
if ((fAddT0s[i-1][j] < 0) || (fAddT0s[i-1][j] > (Int_t)addRunData->GetDataBin(histoNo[j])->size())) {
|
||||
cerr << endl << ">> PRunMuMinus::GetProperT0(): **ERROR** addt0 data bin (" << fAddT0s[i-1][j] << ") doesn't make any sense!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetProperDataRange (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Get the proper data range, i.e. first/last good bin (fgb/lgb).
|
||||
* -# get fgb/lgb from the RUN block
|
||||
* -# if fgb/lgb still undefined, try to get it from the GLOBAL block
|
||||
* -# if fgb/lgb still undefined, try to estimate them.
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - true if everthing went smooth
|
||||
* - false, otherwise.
|
||||
*/
|
||||
Bool_t PRunMuMinus::GetProperDataRange()
|
||||
{
|
||||
// get start/end data
|
||||
Int_t start;
|
||||
Int_t end;
|
||||
start = fRunInfo->GetDataRange(0);
|
||||
end = fRunInfo->GetDataRange(1);
|
||||
|
||||
// check if data range has been given in the RUN block, if not try to get it from the GLOBAL block
|
||||
if (start < 0) {
|
||||
start = fMsrInfo->GetMsrGlobal()->GetDataRange(0);
|
||||
}
|
||||
if (end < 0) {
|
||||
end = fMsrInfo->GetMsrGlobal()->GetDataRange(1);
|
||||
}
|
||||
|
||||
// check if data range has been provided, and if not try to estimate them
|
||||
if (start < 0) {
|
||||
Int_t offset = (Int_t)(10.0e-3/fTimeResolution);
|
||||
start = (Int_t)fT0s[0]+offset;
|
||||
fRunInfo->SetDataRange(start, 0);
|
||||
cerr << endl << ">> PRunMuMinus::GetProperDataRange(): **WARNING** data range was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start << ".";
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
|
||||
cerr << endl;
|
||||
}
|
||||
if (end < 0) {
|
||||
end = fForward.size();
|
||||
fRunInfo->SetDataRange(end, 1);
|
||||
cerr << endl << ">> PRunMuMinus::GetProperDataRange(): **WARNING** data range was not provided, will try data range end = " << end << ".";
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
|
||||
cerr << endl;
|
||||
}
|
||||
|
||||
// check if start and end make any sense
|
||||
// 1st check if start and end are in proper order
|
||||
if (end < start) { // need to swap them
|
||||
Int_t keep = end;
|
||||
end = start;
|
||||
start = keep;
|
||||
}
|
||||
// 2nd check if start is within proper bounds
|
||||
if ((start < 0) || (start > (Int_t)fForward.size())) {
|
||||
cerr << endl << ">> PRunMuMinus::GetProperDataRange(): **ERROR** start data bin (" << start << ") doesn't make any sense!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
// 3rd check if end is within proper bounds
|
||||
if ((end < 0) || (end > (Int_t)fForward.size())) {
|
||||
cerr << endl << ">> PRunMuMinus::GetProperDataRange(): **ERROR** end data bin (" << end << ") doesn't make any sense!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// keep good bins for potential later use
|
||||
fGoodBins[0] = start;
|
||||
fGoodBins[1] = end;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetProperFitRange (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Get the proper fit range. There are two possible fit range commands:
|
||||
* fit <start> <end> given in (usec), or
|
||||
* fit fgb+offset_0 lgb-offset_1 given in (bins), therefore it works the following way:
|
||||
* -# get fit range assuming given in time from RUN block
|
||||
* -# if fit range in RUN block is given in bins, replace start/end
|
||||
* -# if fit range is NOT given yet, try fit range assuming given in time from GLOBAL block
|
||||
* -# if fit range in GLOBAL block is given in bins, replace start/end
|
||||
* -# if still no fit range is given, use fgb/lgb.
|
||||
*
|
||||
* \param globalBlock pointer to the GLOBAL block information form the msr-file.
|
||||
*/
|
||||
void PRunMuMinus::GetProperFitRange(PMsrGlobalBlock *globalBlock)
|
||||
{
|
||||
// set fit start/end time; first check RUN Block
|
||||
fFitStartTime = fRunInfo->GetFitRange(0);
|
||||
fFitEndTime = fRunInfo->GetFitRange(1);
|
||||
// if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
|
||||
if (fRunInfo->IsFitRangeInBin()) {
|
||||
fFitStartTime = (fGoodBins[0] + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
|
||||
fFitEndTime = (fGoodBins[1] - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
|
||||
// write these times back into the data structure. This way it is available when writting the log-file
|
||||
fRunInfo->SetFitRange(fFitStartTime, 0);
|
||||
fRunInfo->SetFitRange(fFitEndTime, 1);
|
||||
}
|
||||
if (fFitStartTime == PMUSR_UNDEFINED) { // fit start/end NOT found in the RUN block, check GLOBAL block
|
||||
fFitStartTime = globalBlock->GetFitRange(0);
|
||||
fFitEndTime = globalBlock->GetFitRange(1);
|
||||
// if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
|
||||
if (globalBlock->IsFitRangeInBin()) {
|
||||
fFitStartTime = (fGoodBins[0] + globalBlock->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
|
||||
fFitEndTime = (fGoodBins[1] - globalBlock->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
|
||||
// write these times back into the data structure. This way it is available when writting the log-file
|
||||
globalBlock->SetFitRange(fFitStartTime, 0);
|
||||
globalBlock->SetFitRange(fFitEndTime, 1);
|
||||
}
|
||||
}
|
||||
if ((fFitStartTime == PMUSR_UNDEFINED) || (fFitEndTime == PMUSR_UNDEFINED)) {
|
||||
fFitStartTime = (fGoodBins[0] - fT0s[0]) * fTimeResolution; // (fgb-t0)*dt
|
||||
fFitEndTime = (fGoodBins[1] - fT0s[0]) * fTimeResolution; // (lgb-t0)*dt
|
||||
cerr << ">> PRunMuMinus::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << endl;
|
||||
cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << endl;
|
||||
}
|
||||
cout << endl << "debug> PRunMuMinus::GetProperFitRange(): fFitStartTime=" << fFitStartTime << ", fFitEndTime=" << fFitEndTime << endl;
|
||||
}
|
||||
|
@ -647,58 +647,29 @@ Bool_t PRunSingleHisto::PrepareData()
|
||||
}
|
||||
}
|
||||
|
||||
// feed all T0's
|
||||
// first init T0's, T0's are stored as (forward T0, backward T0, etc.)
|
||||
fT0s.clear();
|
||||
fT0s.resize(histoNo.size());
|
||||
for (UInt_t i=0; i<fT0s.size(); i++) {
|
||||
fT0s[i] = -1.0;
|
||||
// keep the time resolution in (us)
|
||||
fTimeResolution = runData->GetTimeResolution()/1.0e3;
|
||||
cout.precision(10);
|
||||
cout << endl << ">> PRunSingleHisto::PrepareData(): time resolution=" << fixed << runData->GetTimeResolution() << "(ns)" << endl;
|
||||
|
||||
// get all the proper t0's and addt0's for the current RUN block
|
||||
if (!GetProperT0(runData, globalBlock, histoNo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// fill in the T0's from the msr-file (if present)
|
||||
for (UInt_t i=0; i<fRunInfo->GetT0BinSize(); i++) {
|
||||
fT0s[i] = fRunInfo->GetT0Bin(i);
|
||||
}
|
||||
|
||||
// fill in the T0's from the GLOBAL block section (if present)
|
||||
for (UInt_t i=0; i<globalBlock->GetT0BinSize(); i++) {
|
||||
if (fT0s[i] == -1) { // i.e. not given in the RUN block section
|
||||
fT0s[i] = globalBlock->GetT0Bin(i);
|
||||
}
|
||||
}
|
||||
|
||||
// fill in the T0's from the data file, if not already present in the msr-file
|
||||
for (UInt_t i=0; i<histoNo.size(); i++) {
|
||||
if (fT0s[i] == -1.0) { // i.e. not present in the msr-file, try the data file
|
||||
if (runData->GetT0Bin(histoNo[i]) > 0.0) {
|
||||
fT0s[i] = runData->GetT0Bin(histoNo[i]);
|
||||
fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fill in the T0's gaps, i.e. in case the T0's are NOT in the msr-file and NOT in the data file
|
||||
for (UInt_t i=0; i<histoNo.size(); i++) {
|
||||
if (fT0s[i] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
|
||||
fT0s[i] = runData->GetT0BinEstimated(histoNo[i]);
|
||||
fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file
|
||||
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
|
||||
cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data();
|
||||
cerr << endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(histoNo[i]);
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
|
||||
cerr << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// check if t0 is within proper bounds
|
||||
for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); i++) {
|
||||
if ((fT0s[i] < 0) || (fT0s[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) {
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareData(): **ERROR** t0 data bin (" << fT0s[i] << ") doesn't make any sense!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
/* remove eventually as35
|
||||
cout << endl << "debug> PRunSingleHisto::PrepareData(): fT0s.size()=" << fT0s.size();
|
||||
cout << endl << "debug> PRunSingleHisto::PrepareData(): fT0s : ";
|
||||
for (UInt_t i=0; i<fT0s.size(); i++)
|
||||
cout << fT0s[i] << ", ";
|
||||
cout << endl << "debug> PRunSingleHisto::PrepareData(): fAddT0s.size()=" << fAddT0s.size();
|
||||
for (UInt_t i=0; i<fAddT0s.size(); i++) {
|
||||
cout << endl << "debug> PRunSingleHisto::PrepareData(): fAddT0s[" << i << "].size()=" << fAddT0s[i].size();
|
||||
cout << endl << "debug> PRunSingleHisto::PrepareData(): fAddT0s : " << i << ": ";
|
||||
for (UInt_t j=0; j<fAddT0s[i].size(); j++)
|
||||
cout << fAddT0s[i][j] << ", ";
|
||||
}
|
||||
*/
|
||||
|
||||
// keep the histo of each group at this point (addruns handled below)
|
||||
vector<PDoubleVector> forward;
|
||||
@ -721,72 +692,24 @@ Bool_t PRunSingleHisto::PrepareData()
|
||||
return false;
|
||||
}
|
||||
|
||||
// feed all T0's
|
||||
// first init T0's, T0's are stored as (forward T0, backward T0, etc.)
|
||||
PDoubleVector t0Add;
|
||||
t0Add.resize(histoNo.size());
|
||||
for (UInt_t j=0; j<t0Add.size(); j++) {
|
||||
t0Add[j] = -1.0;
|
||||
}
|
||||
|
||||
// fill in the T0's from the msr-file (if present)
|
||||
for (UInt_t j=0; j<fRunInfo->GetT0BinSize(); j++) {
|
||||
t0Add[j] = fRunInfo->GetAddT0Bin(i-1,j); // addRunIdx starts at 0
|
||||
}
|
||||
|
||||
// fill in the T0's from the data file, if not already present in the msr-file
|
||||
for (UInt_t j=0; j<histoNo.size(); j++) {
|
||||
if (t0Add[j] == -1.0) // i.e. not present in the msr-file, try the data file
|
||||
if (addRunData->GetT0Bin(histoNo[j]) > 0.0) {
|
||||
t0Add[j] = addRunData->GetT0Bin(histoNo[j]);
|
||||
fRunInfo->SetAddT0Bin(t0Add[j], i-1, j); // keep value for the msr-file
|
||||
}
|
||||
}
|
||||
|
||||
// fill in the T0's gaps, i.e. in case the T0's are NOT in the msr-file and NOT in the data file
|
||||
for (UInt_t j=0; j<histoNo.size(); j++) {
|
||||
if (t0Add[j] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
|
||||
t0Add[j] = addRunData->GetT0BinEstimated(histoNo[j]);
|
||||
fRunInfo->SetAddT0Bin(t0Add[j], i-1, j); // keep value for the msr-file
|
||||
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
|
||||
cerr << endl << ">> run: " << fRunInfo->GetRunName(i)->Data();
|
||||
cerr << endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(histoNo[j]);
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
|
||||
cerr << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// check if t0 is within proper bounds
|
||||
for (UInt_t j=0; j<fRunInfo->GetForwardHistoNoSize(); j++) {
|
||||
if ((t0Add[j] < 0) || (t0Add[j] > (Int_t)addRunData->GetDataBin(histoNo[j])->size())) {
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareData(): **ERROR** addt0 data bin (" << t0Add[j] << ") doesn't make any sense!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// add forward run
|
||||
UInt_t addRunSize;
|
||||
for (UInt_t k=0; k<histoNo.size(); k++) { // fill each group
|
||||
addRunSize = addRunData->GetDataBin(histoNo[k])->size();
|
||||
for (UInt_t j=0; j<addRunData->GetDataBin(histoNo[k])->size(); j++) { // loop over the bin indices
|
||||
// make sure that the index stays in the proper range
|
||||
if ((j+(Int_t)t0Add[k]-(Int_t)fT0s[k] >= 0) && (j+(Int_t)t0Add[k]-(Int_t)fT0s[k] < addRunSize)) {
|
||||
forward[k][j] += addRunData->GetDataBin(histoNo[k])->at(j+(Int_t)t0Add[k]-(Int_t)fT0s[k]);
|
||||
if ((j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k] >= 0) && (j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k] < addRunSize)) {
|
||||
forward[k][j] += addRunData->GetDataBin(histoNo[k])->at(j+(Int_t)fAddT0s[i-1][k]-(Int_t)fT0s[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clean up
|
||||
t0Add.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// set forward histo data of the first group
|
||||
fForward.resize(forward[0].size());
|
||||
for (UInt_t i=0; i<fForward.size(); i++) {
|
||||
fForward[i] = forward[0][i];
|
||||
fForward[i] = forward[0][i];
|
||||
}
|
||||
|
||||
// group histograms, add all the remaining forward histograms of the group
|
||||
@ -799,99 +722,20 @@ Bool_t PRunSingleHisto::PrepareData()
|
||||
}
|
||||
}
|
||||
|
||||
// keep the time resolution in (us)
|
||||
fTimeResolution = runData->GetTimeResolution()/1.0e3;
|
||||
cout.precision(10);
|
||||
cout << endl << ">> PRunSingleHisto::PrepareData(): time resolution=" << fixed << runData->GetTimeResolution() << "(ns)" << endl;
|
||||
|
||||
// first get start data, end data, and t0
|
||||
Int_t start;
|
||||
Int_t end;
|
||||
start = fRunInfo->GetDataRange(0);
|
||||
end = fRunInfo->GetDataRange(1);
|
||||
|
||||
// check if data range has been given in the RUN block, if not try to get it from the GLOBAL block
|
||||
if (start < 0) {
|
||||
start = fMsrInfo->GetMsrGlobal()->GetDataRange(0);
|
||||
}
|
||||
if (end < 0) {
|
||||
end = fMsrInfo->GetMsrGlobal()->GetDataRange(1);
|
||||
}
|
||||
|
||||
// check if data range has been provided, and if not try to estimate them
|
||||
if (start < 0) {
|
||||
Int_t offset = (Int_t)(10.0e-3/fTimeResolution);
|
||||
start = (Int_t)fT0s[0]+offset;
|
||||
fRunInfo->SetDataRange(start, 0);
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start << ".";
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
|
||||
cerr << endl;
|
||||
}
|
||||
if (end < 0) {
|
||||
end = fForward.size();
|
||||
fRunInfo->SetDataRange(end, 1);
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range end = " << end << ".";
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
|
||||
cerr << endl;
|
||||
}
|
||||
|
||||
// check if start and end make any sense
|
||||
// 1st check if start and end are in proper order
|
||||
if (end < start) { // need to swap them
|
||||
Int_t keep = end;
|
||||
end = start;
|
||||
start = keep;
|
||||
}
|
||||
// 2nd check if start is within proper bounds
|
||||
if ((start < 0) || (start > (Int_t)fForward.size())) {
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareFitData(): **ERROR** start data bin doesn't make any sense!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
// 3rd check if end is within proper bounds
|
||||
if ((end < 0) || (end > (Int_t)fForward.size())) {
|
||||
cerr << endl << ">> PRunSingleHisto::PrepareFitData(): **ERROR** end data bin doesn't make any sense!";
|
||||
cerr << endl;
|
||||
// get the data range (fgb/lgb) for the current RUN block
|
||||
if (!GetProperDataRange()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// keep good bins for potential later use
|
||||
fGoodBins[0] = start;
|
||||
fGoodBins[1] = end;
|
||||
|
||||
// set fit start/end time; first check RUN Block
|
||||
fFitStartTime = fRunInfo->GetFitRange(0);
|
||||
fFitEndTime = fRunInfo->GetFitRange(1);
|
||||
// if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
|
||||
if (fRunInfo->IsFitRangeInBin()) {
|
||||
fFitStartTime = (start + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
|
||||
fFitEndTime = (end - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
|
||||
// write these times back into the data structure. This way it is available when writting the log-file
|
||||
fRunInfo->SetFitRange(fFitStartTime, 0);
|
||||
fRunInfo->SetFitRange(fFitEndTime, 1);
|
||||
}
|
||||
if (fFitStartTime == PMUSR_UNDEFINED) { // fit start/end NOT found in the RUN block, check GLOBAL block
|
||||
fFitStartTime = globalBlock->GetFitRange(0);
|
||||
fFitEndTime = globalBlock->GetFitRange(1);
|
||||
// if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
|
||||
if (globalBlock->IsFitRangeInBin()) {
|
||||
fFitStartTime = (start + globalBlock->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
|
||||
fFitEndTime = (end - globalBlock->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
|
||||
// write these times back into the data structure. This way it is available when writting the log-file
|
||||
globalBlock->SetFitRange(fFitStartTime, 0);
|
||||
globalBlock->SetFitRange(fFitEndTime, 1);
|
||||
}
|
||||
}
|
||||
if ((fFitStartTime == PMUSR_UNDEFINED) || (fFitEndTime == PMUSR_UNDEFINED)) {
|
||||
cerr << "PRunSingleHisto::PrepareData(): **ERROR** Couldn't get fit start/end time!" << endl;
|
||||
return false;
|
||||
}
|
||||
cout << endl << "debug> PRunSingleHisto::PrepareData(): fFitStartTime=" << fFitStartTime << ", fFitEndTime=" << fFitEndTime << endl;
|
||||
// get the fit range for the current RUN block
|
||||
GetProperFitRange(globalBlock);
|
||||
|
||||
// get the lifetimecorrection flag
|
||||
Bool_t lifetimecorrection = false;
|
||||
PMsrPlotList *plot = fMsrInfo->GetMsrPlotList();
|
||||
lifetimecorrection = plot->at(0).fLifeTimeCorrection;
|
||||
|
||||
// do the more fit/view specific stuff
|
||||
if (fHandleTag == kFit)
|
||||
success = PrepareFitData(runData, histoNo[0]);
|
||||
else if ((fHandleTag == kView) && !lifetimecorrection)
|
||||
@ -1452,6 +1296,266 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetProperT0 (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Get the proper t0 for the single histogram run.
|
||||
* -# the t0 vector size = number of detectors (grouping) for forward.
|
||||
* -# initialize t0's with -1
|
||||
* -# fill t0's from RUN block
|
||||
* -# if t0's are missing (i.e. t0 == -1), try to fill from the GLOBAL block.
|
||||
* -# if t0's are missing, try t0's from the data file
|
||||
* -# if t0's are missing, try to estimate them
|
||||
*
|
||||
* \param runData pointer to the current RUN block entry from the msr-file
|
||||
* \param globalBlock pointer to the GLOBLA block entry from the msr-file
|
||||
* \param histoNo histogram number vector of forward; histoNo = msr-file forward + redGreen_offset - 1
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - true if everthing went smooth
|
||||
* - false, otherwise.
|
||||
*/
|
||||
Bool_t PRunSingleHisto::GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo)
|
||||
{
|
||||
// feed all T0's
|
||||
// first init T0's, T0's are stored as (forward T0, backward T0, etc.)
|
||||
fT0s.clear();
|
||||
fT0s.resize(histoNo.size());
|
||||
for (UInt_t i=0; i<fT0s.size(); i++) {
|
||||
fT0s[i] = -1.0;
|
||||
}
|
||||
|
||||
// fill in the T0's from the msr-file (if present)
|
||||
for (UInt_t i=0; i<fRunInfo->GetT0BinSize(); i++) {
|
||||
fT0s[i] = fRunInfo->GetT0Bin(i);
|
||||
}
|
||||
|
||||
// fill in the T0's from the GLOBAL block section (if present)
|
||||
for (UInt_t i=0; i<globalBlock->GetT0BinSize(); i++) {
|
||||
if (fT0s[i] == -1) { // i.e. not given in the RUN block section
|
||||
fT0s[i] = globalBlock->GetT0Bin(i);
|
||||
}
|
||||
}
|
||||
|
||||
// fill in the T0's from the data file, if not already present in the msr-file
|
||||
for (UInt_t i=0; i<histoNo.size(); i++) {
|
||||
if (fT0s[i] == -1.0) { // i.e. not present in the msr-file, try the data file
|
||||
if (runData->GetT0Bin(histoNo[i]) > 0.0) {
|
||||
fT0s[i] = runData->GetT0Bin(histoNo[i]);
|
||||
fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fill in the T0's gaps, i.e. in case the T0's are NOT in the msr-file and NOT in the data file
|
||||
for (UInt_t i=0; i<histoNo.size(); i++) {
|
||||
if (fT0s[i] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
|
||||
fT0s[i] = runData->GetT0BinEstimated(histoNo[i]);
|
||||
fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file
|
||||
|
||||
cerr << endl << ">> PRunSingleHisto::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
|
||||
cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data();
|
||||
cerr << endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(histoNo[i]);
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
|
||||
cerr << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// check if t0 is within proper bounds
|
||||
for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); i++) {
|
||||
if ((fT0s[i] < 0) || (fT0s[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) {
|
||||
cerr << endl << ">> PRunSingleHisto::GetProperT0(): **ERROR** t0 data bin (" << fT0s[i] << ") doesn't make any sense!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// check if there are runs to be added to the current one. If yes keep the needed t0's
|
||||
if (fRunInfo->GetRunNameSize() > 1) { // runs to be added present
|
||||
PRawRunData *addRunData;
|
||||
fAddT0s.resize(fRunInfo->GetRunNameSize()-1); // resize to the number of addruns
|
||||
for (UInt_t i=1; i<fRunInfo->GetRunNameSize(); i++) {
|
||||
|
||||
// get run to be added to the main one
|
||||
addRunData = fRawData->GetRunData(*fRunInfo->GetRunName(i));
|
||||
if (addRunData == 0) { // couldn't get run
|
||||
cerr << endl << ">> PRunSingleHisto::GetProperT0(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// feed all T0's
|
||||
// first init T0's, T0's are stored as (forward T0, backward T0, etc.)
|
||||
fAddT0s[i-1].resize(histoNo.size());
|
||||
for (UInt_t j=0; j<fAddT0s[i-1].size(); j++) {
|
||||
fAddT0s[i-1][j] = -1.0;
|
||||
}
|
||||
|
||||
// fill in the T0's from the msr-file (if present)
|
||||
for (UInt_t j=0; j<fRunInfo->GetT0BinSize(); j++) {
|
||||
fAddT0s[i-1][j] = fRunInfo->GetAddT0Bin(i-1,j); // addRunIdx starts at 0
|
||||
}
|
||||
|
||||
// fill in the T0's from the data file, if not already present in the msr-file
|
||||
for (UInt_t j=0; j<histoNo.size(); j++) {
|
||||
if (fAddT0s[i-1][j] == -1.0) // i.e. not present in the msr-file, try the data file
|
||||
if (addRunData->GetT0Bin(histoNo[j]) > 0.0) {
|
||||
fAddT0s[i-1][j] = addRunData->GetT0Bin(histoNo[j]);
|
||||
fRunInfo->SetAddT0Bin(fAddT0s[i-1][j], i-1, j); // keep value for the msr-file
|
||||
}
|
||||
}
|
||||
|
||||
// fill in the T0's gaps, i.e. in case the T0's are NOT in the msr-file and NOT in the data file
|
||||
for (UInt_t j=0; j<histoNo.size(); j++) {
|
||||
if (fAddT0s[i-1][j] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
|
||||
fAddT0s[i-1][j] = addRunData->GetT0BinEstimated(histoNo[j]);
|
||||
fRunInfo->SetAddT0Bin(fAddT0s[i-1][j], i-1, j); // keep value for the msr-file
|
||||
|
||||
cerr << endl << ">> PRunSingleHisto::GetProperT0(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
|
||||
cerr << endl << ">> run: " << fRunInfo->GetRunName(i)->Data();
|
||||
cerr << endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(histoNo[j]);
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
|
||||
cerr << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// check if t0 is within proper bounds
|
||||
for (UInt_t j=0; j<fRunInfo->GetForwardHistoNoSize(); j++) {
|
||||
if ((fAddT0s[i-1][j] < 0) || (fAddT0s[i-1][j] > (Int_t)addRunData->GetDataBin(histoNo[j])->size())) {
|
||||
cerr << endl << ">> PRunSingleHisto::GetProperT0(): **ERROR** addt0 data bin (" << fAddT0s[i-1][j] << ") doesn't make any sense!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetProperDataRange (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Get the proper data range, i.e. first/last good bin (fgb/lgb).
|
||||
* -# get fgb/lgb from the RUN block
|
||||
* -# if fgb/lgb still undefined, try to get it from the GLOBAL block
|
||||
* -# if fgb/lgb still undefined, try to estimate them.
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - true if everthing went smooth
|
||||
* - false, otherwise.
|
||||
*/
|
||||
Bool_t PRunSingleHisto::GetProperDataRange()
|
||||
{
|
||||
// get start/end data
|
||||
Int_t start;
|
||||
Int_t end;
|
||||
start = fRunInfo->GetDataRange(0);
|
||||
end = fRunInfo->GetDataRange(1);
|
||||
|
||||
// check if data range has been given in the RUN block, if not try to get it from the GLOBAL block
|
||||
if (start < 0) {
|
||||
start = fMsrInfo->GetMsrGlobal()->GetDataRange(0);
|
||||
}
|
||||
if (end < 0) {
|
||||
end = fMsrInfo->GetMsrGlobal()->GetDataRange(1);
|
||||
}
|
||||
|
||||
// check if data range has been provided, and if not try to estimate them
|
||||
if (start < 0) {
|
||||
Int_t offset = (Int_t)(10.0e-3/fTimeResolution);
|
||||
start = (Int_t)fT0s[0]+offset;
|
||||
fRunInfo->SetDataRange(start, 0);
|
||||
cerr << endl << ">> PRunSingleHisto::GetProperDataRange(): **WARNING** data range was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start << ".";
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
|
||||
cerr << endl;
|
||||
}
|
||||
if (end < 0) {
|
||||
end = fForward.size();
|
||||
fRunInfo->SetDataRange(end, 1);
|
||||
cerr << endl << ">> PRunSingleHisto::GetProperDataRange(): **WARNING** data range was not provided, will try data range end = " << end << ".";
|
||||
cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
|
||||
cerr << endl;
|
||||
}
|
||||
|
||||
// check if start and end make any sense
|
||||
// 1st check if start and end are in proper order
|
||||
if (end < start) { // need to swap them
|
||||
Int_t keep = end;
|
||||
end = start;
|
||||
start = keep;
|
||||
}
|
||||
// 2nd check if start is within proper bounds
|
||||
if ((start < 0) || (start > (Int_t)fForward.size())) {
|
||||
cerr << endl << ">> PRunSingleHisto::GetProperDataRange(): **ERROR** start data bin (" << start << ") doesn't make any sense!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
// 3rd check if end is within proper bounds
|
||||
if ((end < 0) || (end > (Int_t)fForward.size())) {
|
||||
cerr << endl << ">> PRunSingleHisto::GetProperDataRange(): **ERROR** end data bin (" << end << ") doesn't make any sense!";
|
||||
cerr << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// keep good bins for potential later use
|
||||
fGoodBins[0] = start;
|
||||
fGoodBins[1] = end;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetProperFitRange (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Get the proper fit range. There are two possible fit range commands:
|
||||
* fit <start> <end> given in (usec), or
|
||||
* fit fgb+offset_0 lgb-offset_1 given in (bins), therefore it works the following way:
|
||||
* -# get fit range assuming given in time from RUN block
|
||||
* -# if fit range in RUN block is given in bins, replace start/end
|
||||
* -# if fit range is NOT given yet, try fit range assuming given in time from GLOBAL block
|
||||
* -# if fit range in GLOBAL block is given in bins, replace start/end
|
||||
* -# if still no fit range is given, use fgb/lgb.
|
||||
*
|
||||
* \param globalBlock pointer to the GLOBAL block information form the msr-file.
|
||||
*/
|
||||
void PRunSingleHisto::GetProperFitRange(PMsrGlobalBlock *globalBlock)
|
||||
{
|
||||
// set fit start/end time; first check RUN Block
|
||||
fFitStartTime = fRunInfo->GetFitRange(0);
|
||||
fFitEndTime = fRunInfo->GetFitRange(1);
|
||||
// if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
|
||||
if (fRunInfo->IsFitRangeInBin()) {
|
||||
fFitStartTime = (fGoodBins[0] + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
|
||||
fFitEndTime = (fGoodBins[1] - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
|
||||
// write these times back into the data structure. This way it is available when writting the log-file
|
||||
fRunInfo->SetFitRange(fFitStartTime, 0);
|
||||
fRunInfo->SetFitRange(fFitEndTime, 1);
|
||||
}
|
||||
if (fFitStartTime == PMUSR_UNDEFINED) { // fit start/end NOT found in the RUN block, check GLOBAL block
|
||||
fFitStartTime = globalBlock->GetFitRange(0);
|
||||
fFitEndTime = globalBlock->GetFitRange(1);
|
||||
// if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now
|
||||
if (globalBlock->IsFitRangeInBin()) {
|
||||
fFitStartTime = (fGoodBins[0] + globalBlock->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt
|
||||
fFitEndTime = (fGoodBins[1] - globalBlock->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt
|
||||
// write these times back into the data structure. This way it is available when writting the log-file
|
||||
globalBlock->SetFitRange(fFitStartTime, 0);
|
||||
globalBlock->SetFitRange(fFitEndTime, 1);
|
||||
}
|
||||
}
|
||||
if ((fFitStartTime == PMUSR_UNDEFINED) || (fFitEndTime == PMUSR_UNDEFINED)) {
|
||||
fFitStartTime = (fGoodBins[0] - fT0s[0]) * fTimeResolution; // (fgb-t0)*dt
|
||||
fFitEndTime = (fGoodBins[1] - fT0s[0]) * fTimeResolution; // (lgb-t0)*dt
|
||||
cerr << ">> PRunSingleHisto::GetProperFitRange(): **WARNING** Couldn't get fit start/end time!" << endl;
|
||||
cerr << ">> Will set it to fgb/lgb which given in time is: " << fFitStartTime << "..." << fFitEndTime << " (usec)" << endl;
|
||||
}
|
||||
cout << endl << "debug> PRunSingleHisto::GetProperFitRange(): fFitStartTime=" << fFitStartTime << ", fFitEndTime=" << fFitEndTime << endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// EstimateN0 (private)
|
||||
//--------------------------------------------------------------------------
|
||||
@ -1489,8 +1593,6 @@ void PRunSingleHisto::EstimateN0()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// estimate N0
|
||||
Double_t dt = fTimeResolution;
|
||||
Double_t tau = PMUON_LIFETIME;
|
||||
@ -1509,7 +1611,7 @@ void PRunSingleHisto::EstimateN0()
|
||||
nom += xx;
|
||||
}
|
||||
|
||||
// calc: denominator
|
||||
// calc denominator
|
||||
for (UInt_t i=t0; i<fForward.size(); i++) {
|
||||
xx = exp(-dt*(Double_t)(i-t0)/tau);
|
||||
xx += alpha;
|
||||
|
@ -55,24 +55,28 @@ class PRunAsymmetry : public PRunBase
|
||||
protected:
|
||||
virtual void CalcNoOfFitBins();
|
||||
virtual Bool_t PrepareData();
|
||||
virtual Bool_t PrepareFitData(PRawRunData* runData, UInt_t histoNo[2]);
|
||||
virtual Bool_t PrepareFitData();
|
||||
virtual Bool_t PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]);
|
||||
virtual Bool_t PrepareRRFViewData(PRawRunData* runData, UInt_t histoNo[2]);
|
||||
|
||||
private:
|
||||
UInt_t fAlphaBetaTag; ///< \f$ 1 \to \alpha = \beta = 1\f$; \f$ 2 \to \alpha \neq 1, \beta = 1\f$; \f$ 3 \to \alpha = 1, \beta \neq 1\f$; \f$ 4 \to \alpha \neq 1, \beta \neq 1\f$.
|
||||
|
||||
UInt_t fNoOfFitBins; ///< number of bins to be be fitted
|
||||
UInt_t fNoOfFitBins; ///< number of bins to be be fitted
|
||||
Int_t fPacking; ///< packing for this particular run. Either given in the RUN- or GLOBAL-block.
|
||||
|
||||
PDoubleVector fForward; ///< forward histo data
|
||||
PDoubleVector fForwardErr; ///< forward histo errors
|
||||
PDoubleVector fBackward; ///< backward histo data
|
||||
PDoubleVector fBackwardErr; ///< backward histo errors
|
||||
|
||||
Int_t fGoodBins[2]; ///< keep first/last good bins. 0=fgb, 1=lgb
|
||||
Int_t fGoodBins[4]; ///< keep first/last good bins. 0=fgb, 1=lgb (forward); 2=fgb, 3=lgb (backward)
|
||||
|
||||
Bool_t SubtractFixBkg();
|
||||
Bool_t SubtractEstimatedBkg();
|
||||
|
||||
virtual Bool_t GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlock, PUIntVector &forwardHisto, PUIntVector &backwardHistoNo);
|
||||
virtual Bool_t GetProperDataRange(PRawRunData* runData, UInt_t histoNo[2]);
|
||||
virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock);
|
||||
};
|
||||
|
||||
#endif // _PRUNASYMMETRY_H_
|
||||
|
@ -64,6 +64,10 @@ class PRunMuMinus : public PRunBase
|
||||
Int_t fGoodBins[2]; ///< keep first/last good bins. 0=fgb, 1=lgb
|
||||
|
||||
PDoubleVector fForward; ///< forward histo data
|
||||
|
||||
virtual Bool_t GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo);
|
||||
virtual Bool_t GetProperDataRange();
|
||||
virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock);
|
||||
};
|
||||
|
||||
#endif // _PRUNMUMINUS_H_
|
||||
|
@ -68,6 +68,9 @@ class PRunSingleHisto : public PRunBase
|
||||
|
||||
PDoubleVector fForward; ///< forward histo data
|
||||
|
||||
virtual Bool_t GetProperT0(PRawRunData* runData, PMsrGlobalBlock *globalBlock, PUIntVector &histoNo);
|
||||
virtual Bool_t GetProperDataRange();
|
||||
virtual void GetProperFitRange(PMsrGlobalBlock *globalBlock);
|
||||
virtual void EstimateN0();
|
||||
virtual Bool_t EstimateBkg(UInt_t histoNo);
|
||||
virtual Bool_t IsScaleN0AndBkg();
|
||||
|
Loading…
x
Reference in New Issue
Block a user