added view_packing option in the PLOT block

This commit is contained in:
nemu
2009-06-09 12:56:58 +00:00
parent 0e1f33cc23
commit 7270e2e58d
3 changed files with 52 additions and 34 deletions

View File

@ -1392,7 +1392,7 @@ void PMusrCanvas::HandleDataSet(unsigned int plotNo, unsigned int runNo, PRunDat
end = data->fDataTimeStart + data->fValue.size()*data->fDataTimeStep; end = data->fDataTimeStart + data->fValue.size()*data->fDataTimeStep;
size = data->fValue.size(); size = data->fValue.size();
cout << endl << ">> PMusrCanvas::HandleDataSet(): data->fDataTimeStart = " << data->fDataTimeStart << ", data->fDataTimeStep = " << data->fDataTimeStep << endl; //cout << endl << ">> PMusrCanvas::HandleDataSet(): data->fDataTimeStart = " << data->fDataTimeStart << ", data->fDataTimeStep = " << data->fDataTimeStep << endl;
// check if 'use_fit_range' plotting is whished // check if 'use_fit_range' plotting is whished
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) { if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) {

View File

@ -755,6 +755,12 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
*/ */
bool PRunAsymmetry::PrepareViewData(PRawRunData* runData, unsigned int histoNo[2]) bool PRunAsymmetry::PrepareViewData(PRawRunData* runData, unsigned int histoNo[2])
{ {
// check if view_packing is wished
int packing = fRunInfo->fPacking;
if (fMsrInfo->GetMsrPlotList()->at(0).fViewPacking > 0) {
packing = fMsrInfo->GetMsrPlotList()->at(0).fViewPacking;
}
// feed the parameter vector // feed the parameter vector
std::vector<double> par; std::vector<double> par;
PMsrParamList *paramList = fMsrInfo->GetMsrParamList(); PMsrParamList *paramList = fMsrInfo->GetMsrParamList();
@ -764,10 +770,10 @@ bool PRunAsymmetry::PrepareViewData(PRawRunData* runData, unsigned int histoNo[2
// transform raw histo data. This is done the following way (for details see the manual): // transform raw histo data. This is done the following way (for details see the manual):
// first rebin the data, than calculate the asymmetry // first rebin the data, than calculate the asymmetry
// first get start data, end data, and t0 // first get start data, end data, and t0
int val = fRunInfo->fDataRange[0]-fRunInfo->fPacking*(fRunInfo->fDataRange[0]/fRunInfo->fPacking); int val = fRunInfo->fDataRange[0]-packing*(fRunInfo->fDataRange[0]/packing);
do { do {
if (fRunInfo->fDataRange[2] - fRunInfo->fDataRange[0] < 0) if (fRunInfo->fDataRange[2] - fRunInfo->fDataRange[0] < 0)
val += fRunInfo->fPacking; val += packing;
} while (val + fRunInfo->fDataRange[2] - fRunInfo->fDataRange[0] < 0); } while (val + fRunInfo->fDataRange[2] - fRunInfo->fDataRange[0] < 0);
int start[2] = {val, val + fRunInfo->fDataRange[2] - fRunInfo->fDataRange[0]}; int start[2] = {val, val + fRunInfo->fDataRange[2] - fRunInfo->fDataRange[0]};
@ -781,12 +787,12 @@ cout << endl;
*/ */
// make sure that there are equal number of rebinned bins in forward and backward // make sure that there are equal number of rebinned bins in forward and backward
unsigned int noOfBins0 = (runData->fDataBin[histoNo[0]].size()-start[0])/fRunInfo->fPacking; unsigned int noOfBins0 = (runData->fDataBin[histoNo[0]].size()-start[0])/packing;
unsigned int noOfBins1 = (runData->fDataBin[histoNo[1]].size()-start[1])/fRunInfo->fPacking; unsigned int noOfBins1 = (runData->fDataBin[histoNo[1]].size()-start[1])/packing;
if (noOfBins0 > noOfBins1) if (noOfBins0 > noOfBins1)
noOfBins0 = noOfBins1; noOfBins0 = noOfBins1;
end[0] = start[0] + noOfBins0 * fRunInfo->fPacking; end[0] = start[0] + noOfBins0 * packing;
end[1] = start[1] + noOfBins0 * fRunInfo->fPacking; end[1] = start[1] + noOfBins0 * packing;
// check if start, end, and t0 make any sense // check if start, end, and t0 make any sense
// 1st check if start and end are in proper order // 1st check if start and end are in proper order
@ -820,19 +826,19 @@ cout << endl;
double error = 0.0; double error = 0.0;
// forward // forward
for (int i=start[0]; i<end[0]; i++) { for (int i=start[0]; i<end[0]; i++) {
if (fRunInfo->fPacking == 1) { if (packing == 1) {
forwardPacked.fValue.push_back(fForward[i]); forwardPacked.fValue.push_back(fForward[i]);
forwardPacked.fError.push_back(fForwardErr[i]); forwardPacked.fError.push_back(fForwardErr[i]);
} else { // packed data, i.e. fRunInfo->fPacking > 1 } else { // packed data, i.e. packing > 1
if (((i-start[0]) % fRunInfo->fPacking == 0) && (i != start[0])) { // fill data if (((i-start[0]) % packing == 0) && (i != start[0])) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per bin // the value is normalize to per bin
value /= fRunInfo->fPacking; value /= packing;
forwardPacked.fValue.push_back(value); forwardPacked.fValue.push_back(value);
if (value == 0.0) if (value == 0.0)
forwardPacked.fError.push_back(1.0); forwardPacked.fError.push_back(1.0);
else else
forwardPacked.fError.push_back(TMath::Sqrt(error)/fRunInfo->fPacking); forwardPacked.fError.push_back(TMath::Sqrt(error)/packing);
value = 0.0; value = 0.0;
error = 0.0; error = 0.0;
} }
@ -842,19 +848,19 @@ cout << endl;
} }
// backward // backward
for (int i=start[1]; i<end[1]; i++) { for (int i=start[1]; i<end[1]; i++) {
if (fRunInfo->fPacking == 1) { if (packing == 1) {
backwardPacked.fValue.push_back(fBackward[i]); backwardPacked.fValue.push_back(fBackward[i]);
backwardPacked.fError.push_back(fBackwardErr[i]); backwardPacked.fError.push_back(fBackwardErr[i]);
} else { // packed data, i.e. fRunInfo->fPacking > 1 } else { // packed data, i.e. packing > 1
if (((i-start[1]) % fRunInfo->fPacking == 0) && (i != start[1])) { // fill data if (((i-start[1]) % packing == 0) && (i != start[1])) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per bin // the value is normalize to per bin
value /= fRunInfo->fPacking; value /= packing;
backwardPacked.fValue.push_back(value); backwardPacked.fValue.push_back(value);
if (value == 0.0) if (value == 0.0)
backwardPacked.fError.push_back(1.0); backwardPacked.fError.push_back(1.0);
else else
backwardPacked.fError.push_back(TMath::Sqrt(error)/fRunInfo->fPacking); backwardPacked.fError.push_back(TMath::Sqrt(error)/packing);
value = 0.0; value = 0.0;
error = 0.0; error = 0.0;
} }
@ -875,8 +881,8 @@ cout << endl;
double f, b, ef, eb, alpha = 1.0, beta = 1.0; double f, b, ef, eb, alpha = 1.0, beta = 1.0;
// fill data time start, and step // fill data time start, and step
// data start at data_start-t0 // data start at data_start-t0
fData.fDataTimeStart = fTimeResolution*((double)start[0]-t0[0]+(double)(fRunInfo->fPacking-1)/2.0); fData.fDataTimeStart = fTimeResolution*((double)start[0]-t0[0]+(double)(packing-1)/2.0);
fData.fDataTimeStep = fTimeResolution*(double)fRunInfo->fPacking; fData.fDataTimeStep = fTimeResolution*(double)packing;
/* /*
cout << endl << ">> start time = " << fData.fDataTimeStart << ", step = " << fData.fDataTimeStep; cout << endl << ">> start time = " << fData.fDataTimeStart << ", step = " << fData.fDataTimeStep;

View File

@ -553,11 +553,17 @@ bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int hi
*/ */
bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned int histoNo) bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned int histoNo)
{ {
// check if view_packing is wished
int packing = fRunInfo->fPacking;
if (fMsrInfo->GetMsrPlotList()->at(0).fViewPacking > 0) {
packing = fMsrInfo->GetMsrPlotList()->at(0).fViewPacking;
}
// raw data, since PMusrCanvas is doing ranging etc. // raw data, since PMusrCanvas is doing ranging etc.
// start = the first bin which is a multiple of packing backward from first good data bin // start = the first bin which is a multiple of packing backward from first good data bin
int start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/fRunInfo->fPacking)*fRunInfo->fPacking; int start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/packing)*packing;
// end = last bin starting from start which is a multipl of packing and still within the data // end = last bin starting from start which is a multipl of packing and still within the data
int end = start + ((runData->fDataBin[histoNo].size()-start)/fRunInfo->fPacking)*fRunInfo->fPacking; int end = start + ((runData->fDataBin[histoNo].size()-start)/packing)*packing;
// check if start, end, and t0 make any sense // check if start, end, and t0 make any sense
// 1st check if start and end are in proper order // 1st check if start and end are in proper order
if (end < start) { // need to swap them if (end < start) { // need to swap them
@ -581,21 +587,21 @@ bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned in
double value = 0.0; double value = 0.0;
// data start at data_start-t0 // data start at data_start-t0
// time shifted so that packing is included correctly, i.e. t0 == t0 after packing // time shifted so that packing is included correctly, i.e. t0 == t0 after packing
fData.fDataTimeStart = fTimeResolution*((double)start-(double)t0+(double)(fRunInfo->fPacking-1)/2.0); fData.fDataTimeStart = fTimeResolution*((double)start-(double)t0+(double)(packing-1)/2.0);
fData.fDataTimeStep = fTimeResolution*fRunInfo->fPacking; fData.fDataTimeStep = fTimeResolution*packing;
/* /*
cout << endl << ">> time resolution = " << fTimeResolution; cout << endl << ">> time resolution = " << fTimeResolution;
cout << endl << ">> start = " << start << ", t0 = " << t0 << ", packing = " << fRunInfo->fPacking; cout << endl << ">> start = " << start << ", t0 = " << t0 << ", packing = " << packing;
cout << endl << ">> data start time = " << fData.fDataTimeStart; cout << endl << ">> data start time = " << fData.fDataTimeStart;
*/ */
double normalizer = 1.0; double normalizer = 1.0;
for (int i=start; i<end; i++) { for (int i=start; i<end; i++) {
if (((i-start) % fRunInfo->fPacking == 0) && (i != start)) { // fill data if (((i-start) % packing == 0) && (i != start)) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per 1 nsec // the value is normalize to per 1 nsec
normalizer = fRunInfo->fPacking * (fTimeResolution * 1e3); // fTimeResolution us->ns normalizer = packing * (fTimeResolution * 1e3); // fTimeResolution us->ns
value /= normalizer; value /= normalizer;
fData.fValue.push_back(value); fData.fValue.push_back(value);
if (value == 0.0) if (value == 0.0)
@ -705,15 +711,21 @@ cout << endl << ">> data start time = " << fData.fDataTimeStart;
*/ */
bool PRunSingleHisto::PrepareViewData(PRawRunData* runData, const unsigned int histoNo) bool PRunSingleHisto::PrepareViewData(PRawRunData* runData, const unsigned int histoNo)
{ {
// check if view_packing is wished
int packing = fRunInfo->fPacking;
if (fMsrInfo->GetMsrPlotList()->at(0).fViewPacking > 0) {
packing = fMsrInfo->GetMsrPlotList()->at(0).fViewPacking;
}
// transform raw histo data. This is done the following way (for details see the manual): // 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 // for the single histo fit, just the rebinned raw data are copied
// first get start data, end data, and t0 // first get start data, end data, and t0
int t0 = fT0s[0]; int t0 = fT0s[0];
// start = the first bin which is a multiple of packing backward from first good data bin // start = the first bin which is a multiple of packing backward from first good data bin
int start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/fRunInfo->fPacking)*fRunInfo->fPacking; int start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/packing)*packing;
// end = last bin starting from start which is a multiple of packing and still within the data // end = last bin starting from start which is a multiple of packing and still within the data
int end = start + ((runData->fDataBin[histoNo].size()-start)/fRunInfo->fPacking)*fRunInfo->fPacking; int end = start + ((runData->fDataBin[histoNo].size()-start)/packing)*packing;
// check if start, end, and t0 make any sense // check if start, end, and t0 make any sense
// 1st check if start and end are in proper order // 1st check if start and end are in proper order
@ -780,8 +792,8 @@ bool PRunSingleHisto::PrepareViewData(PRawRunData* runData, const unsigned int h
double time; double time;
// data start at data_start-t0 shifted by (pack-1)/2 // data start at data_start-t0 shifted by (pack-1)/2
fData.fDataTimeStart = fTimeResolution*((double)start-(double)t0+(double)(fRunInfo->fPacking-1)/2.0); fData.fDataTimeStart = fTimeResolution*((double)start-(double)t0+(double)(packing-1)/2.0);
fData.fDataTimeStep = fTimeResolution*fRunInfo->fPacking; fData.fDataTimeStep = fTimeResolution*packing;
/* /*
cout << endl << ">> start time = " << fData.fDataTimeStart << ", step = " << fData.fDataTimeStep; cout << endl << ">> start time = " << fData.fDataTimeStart << ", step = " << fData.fDataTimeStep;
@ -791,17 +803,17 @@ cout << endl << "--------------------------------" << endl;
double normalizer = 1.0; double normalizer = 1.0;
for (int i=start; i<end; i++) { for (int i=start; i<end; i++) {
if (((i-start) % fRunInfo->fPacking == 0) && (i != start)) { // fill data if (((i-start) % packing == 0) && (i != start)) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per 1 nsec // the value is normalize to per 1 nsec
normalizer = fRunInfo->fPacking * (fTimeResolution * 1.0e3); // fTimeResolution us->ns normalizer = packing * (fTimeResolution * 1.0e3); // fTimeResolution us->ns
value /= normalizer; value /= normalizer;
time = (((double)i-(double)(fRunInfo->fPacking-1)/2.0)-t0)*fTimeResolution; time = (((double)i-(double)(packing-1)/2.0)-t0)*fTimeResolution;
expval = TMath::Exp(+time/tau)/N0; expval = TMath::Exp(+time/tau)/N0;
fData.fValue.push_back(-1.0+expval*(value-bkg)); fData.fValue.push_back(-1.0+expval*(value-bkg));
//cout << endl << ">> i=" << i << ",t0=" << t0 << ",time=" << time << ",expval=" << expval << ",value=" << value << ",bkg=" << bkg << ",expval*(value-bkg)-1=" << expval*(value-bkg)-1.0; //cout << endl << ">> i=" << i << ",t0=" << t0 << ",time=" << time << ",expval=" << expval << ",value=" << value << ",bkg=" << bkg << ",expval*(value-bkg)-1=" << expval*(value-bkg)-1.0;
fData.fError.push_back(expval*TMath::Sqrt(value/normalizer)); fData.fError.push_back(expval*TMath::Sqrt(value/normalizer));
//cout << endl << ">> " << time << ", " << expval << ", " << -1.0+expval*(value-bkg) << ", " << expval*TMath::Sqrt(value/fRunInfo->fPacking); //cout << endl << ">> " << time << ", " << expval << ", " << -1.0+expval*(value-bkg) << ", " << expval*TMath::Sqrt(value/packing);
value = 0.0; value = 0.0;
} }
value += runData->fDataBin[histoNo][i]; value += runData->fDataBin[histoNo][i];