some debugging of the post processing funcs

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@698 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
bergamaschi
2013-11-27 12:00:04 +00:00
parent 1ed2ba63b5
commit 0c3f1d95b9
5 changed files with 139 additions and 79 deletions

View File

@ -2821,13 +2821,13 @@ int multiSlsDetector::getBadChannelCorrection(int *bad) {
if (((thisMultiDetector->correctionMask)&(1<< DISCARD_BAD_CHANNELS))==0)
return 0;
else
cout << "bad chans corr enabled "<< thisMultiDetector->correctionMask << endl;
//else
// cout << "bad chans corr enabled "<< thisMultiDetector->correctionMask << endl;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) {
nd=detectors[idet]->getBadChannelCorrection();
cout << "det " << idet << " nbad " << nd << endl;
// cout << "det " << idet << " nbad " << nd << endl;
if (nd>0) {
bd = new int[nd];
nd=detectors[idet]->getBadChannelCorrection(bd);

View File

@ -67,6 +67,8 @@ int angularConversion::deleteMerging() {
int angularConversion::resetMerging() {
getAngularConversionParameter(BIN_SIZE);
cout << "reset merging * " << endl;
mergingBins=new double[nBins];
@ -83,6 +85,8 @@ int angularConversion::resetMerging() {
}
int angularConversion::resetMerging(double *mp, double *mv, double *me, int *mm) {
cout << "reset merging " << endl;
getAngularConversionParameter(BIN_SIZE);
if (nBins)
return angularConversionStatic::resetMerging(mp, mv, me, mm,nBins);
@ -94,6 +98,7 @@ int angularConversion::resetMerging(double *mp, double *mv, double *me, int *mm)
int angularConversion::finalizeMerging() {
cout << "finalize merging *" << endl;
int np=finalizeMerging(mergingBins, mergingCounts, mergingErrors, mergingMultiplicity);
if (mergingMultiplicity)

View File

@ -24,6 +24,9 @@ angularConversionStatic::~angularConversionStatic(){
double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir) {
// cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP convert angles " << endl;
int imod=0;
double *ang=new double[nch];
double enc=pos;
@ -86,6 +89,7 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe
double angularConversionStatic::convertAngle(double pos, int ich, angleConversionConstant *p, int mF, double fo, double go, int angdir) {
// cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP convert angle " << endl;
// if (p)
// cout << pos << endl << fo+go << endl << p->r_conversion << endl << p->center << endl << p->offset << endl << mF << endl << angdir << endl;
// else
@ -148,6 +152,7 @@ double angularConversionStatic::convertAngle(double pos, int ich, angleConversio
double angularConversionStatic::convertAngle(double pos, int ich, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir) {
// cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP convert angles xx" << endl;
int imod=0;
double ang;
// double enc=0, trans=0;
@ -302,6 +307,7 @@ int angularConversionStatic:: writeAngularConversion(ofstream& outfile, int nmod
//static
int angularConversionStatic::resetMerging(double *mp, double *mv, double *me, int *mm, int nb) {
// cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP reset merging " << endl;
#ifdef VERBOSE
cout << "creating merging arrays "<< nb << endl;
@ -320,13 +326,14 @@ int angularConversionStatic::resetMerging(double *mp, double *mv, double *me, in
//static
int angularConversionStatic::finalizeMerging(double *mp, double *mv, double *me, int *mm,int nb) {
// cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP finalize merging " << endl;
int np=0;
for (int ibin=0; ibin<nb; ibin++) {
if (mm[ibin]>0) {
// #ifdef VERBOSE
// cout << "finalize " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl;
// #endif
#ifdef VERBOSE
cout << "finalize " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< " " << mv[ibin] << " " << me[ibin] << endl;
#endif
mp[np]=mp[ibin]/mm[ibin];
mv[np]=mv[ibin]/mm[ibin];
me[np]=me[ibin]/mm[ibin];
@ -334,7 +341,8 @@ int angularConversionStatic::finalizeMerging(double *mp, double *mv, double *me,
mm[np]=mm[ibin];
np++;
}
}
}
// cout << endl ;
return np;
}
@ -342,6 +350,7 @@ int angularConversionStatic::finalizeMerging(double *mp, double *mv, double *me,
int angularConversionStatic::addToMerging(double *p1, double *v1, double *e1, double *mp, double *mv,double *me, int *mm, int nchans, double binsize,int nbins, int *badChanMask ) {
// cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP add to merging " << endl;
double binmi=-180.;
int ibin=0;
@ -404,6 +413,7 @@ int angularConversionStatic::addToMerging(double *p1, double *v1, double *e1, d
int angularConversionStatic::addPointToMerging(double p1, double v1, double e1, double *mp, double *mv,double *me, int *mm, double binsize,int nbins) {
// cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP add point to merging "<< v1 << " " << e1 << endl;
double binmi=-180.;
int ibin=0;
@ -429,6 +439,7 @@ int angularConversionStatic::addPointToMerging(double p1, double v1, double e1,
if (ibin<nbins && ibin>=0) {
// cout << "before " << ibin << " " << mp[ibin] << " " << mv[ibin] << " " << me[ibin] << endl;
mp[ibin]+=p1;
mv[ibin]+=v1;
if (e1)
@ -436,6 +447,7 @@ int angularConversionStatic::addPointToMerging(double p1, double v1, double e1,
else
me[ibin]+=v1;
mm[ibin]++;
// cout << "after " << ibin << " " << mp[ibin] << " " << mv[ibin] << " " << me[ibin] << endl;
// #ifdef VERBOSE
// cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl;

View File

@ -132,7 +132,7 @@ void postProcessing::processFrame(int *myData, int delflag) {
} else
if (dataReady){
cout << "callback arg "<< getCurrentProgress()<< " " << (fname+string(".raw")).c_str() << " " << getTotalNumberOfChannels() << endl;
// cout << "callback arg "<< getCurrentProgress()<< " " << (fname+string(".raw")).c_str() << " " << getTotalNumberOfChannels() << endl;
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),getTotalNumberOfChannels());
dataReady(thisData, currentFrameIndex, pCallbackArg);
@ -183,9 +183,9 @@ void postProcessing::processFrame(int *myData, int delflag) {
void postProcessing::doProcessing(double *lfdata, int delflag, string fname) {
#ifdef VERBOSE
cout << "do processing - data size is " << arraySize << endl;
#endif
#ifdef VERBOSE
cout << "??????????????????????????????????????????? do processing - data size is " << arraySize << endl;
#endif
int np;
@ -255,7 +255,7 @@ void postProcessing::doProcessing(double *lfdata, int delflag, string fname) {
if (dataReady) {
cout << "callback arg "<< getCurrentProgress()<< " " << (fname+ext).c_str() << " " << np << endl;
// cout << "callback arg "<< getCurrentProgress()<< " " << (fname+ext).c_str() << " " << np << endl;
thisData=new detectorData(val,err,ang,getCurrentProgress(),(fname+ext).c_str(),np);
dataReady(thisData, currentFrameIndex, pCallbackArg);
@ -306,9 +306,9 @@ int postProcessing::fillBadChannelMask() {
delete [] badChannelMask;
//#ifdef VERBOSE
#ifdef VERBOSE
cout << " nchans " << getTotalNumberOfChannels() << endl;
//#endif
#endif
badChannelMask=new int[getTotalNumberOfChannels()];
@ -350,8 +350,8 @@ int postProcessing::fillBadChannelMask() {
#ifdef VERBOSE
cout << "deleting bad channel mask beacuse no bad channel correction is selected" << endl;
#endif
//delete [] badChannelMask;
//badChannelMask=NULL;
delete [] badChannelMask;
badChannelMask=NULL;
}
}
@ -371,7 +371,7 @@ void* postProcessing::processData(int delflag) {
if(setReceiverOnline()==OFFLINE_FLAG){
#ifdef VERBOSE
std::cout<< " processing data - threaded mode " << *threadedProcessing << endl;
std::cout<< " ??????????????????????????????????????????? processing data - threaded mode " << *threadedProcessing << endl;
#endif
@ -741,6 +741,7 @@ void postProcessing::initDataset(int r) {
fillBadChannelMask();
// cout << "pp bad channel mask " << badChannelMask << endl;
//cout << "EEEEEEEEEEEEEEEEEEEE init dataset " << endl;
ppFun->initDataset(&nmod,chPM,mM,badChannelMask, ffcoeff, fferr, &tdead, &angdir, angRad, angOff, angCenter, &to, &bs, &sx, &sy);
#ifdef VERBOSE
@ -766,7 +767,7 @@ void postProcessing::initDataset(int r) {
} else {
cout << "implicit inti dataset! " << endl;
// cout << "EEEEEEEEEEEEEEEEEEEE init dataset XXXX " << endl;
ppFun->initDataset();
@ -781,12 +782,20 @@ void postProcessing::initDataset(int r) {
void postProcessing::addFrame(double *data, double pos, double i0, double t, string fname, double var) {
ppFun->addFrame(data, &pos, &i0, &t, fname.c_str(), &var);
// cout << "EEEEEEEEEEEEEEEEEEEE add frame " << pos << " " << i0 << endl;
if (*correctionMask&(1<< I0_NORMALIZATION))
ppFun->addFrame(data, &pos, &i0, &t, fname.c_str(), &var);
else
ppFun->addFrame(data, &pos,NULL, &t, fname.c_str(), &var);
}
void postProcessing::finalizeDataset(double *a, double *v, double *e, int &np) {
// cout << "EEEEEEEEEEEEEEEEEEEE finalize dataset " << endl;
ppFun->finalizeDataset(a, v, e, &np);
}

View File

@ -12,17 +12,19 @@ postProcessingFuncs::postProcessingFuncs(int *nModules,int *chPerMod,int modMask
int postProcessingFuncs::initDataset() {
// cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA init dataset " << endl;
if (nBins) {
mp=new double[nBins];
mv=new double[nBins];
me=new double[nBins];
mm=new int[nBins];
resetMerging(mp,mv,me,mm, nBins);
cout << "nbins " << nBins << endl;
// cout << "nbins " << nBins << endl;
} else {
mv=new double[totalChans];
me=new double[totalChans];
cout << "nchans " << totalChans << endl;
// cout << "nchans " << totalChans << endl;
}
totalI0=0;
@ -32,6 +34,8 @@ int postProcessingFuncs::initDataset() {
int postProcessingFuncs::finalizeDataset(double *ang, double *val, double *err, int *np) {
// cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA finalize dataset " << endl;
if (nBins)
*np=finalizeMerging(mp,mv,me,mm,nBins);
else
@ -78,14 +82,25 @@ int postProcessingFuncs::addFrame(double *data, double *pos, double *I0, double
double p1, vin, ein, vout, eout;
double e=0.;
double i0=*I0;
double i0;
int imod=0, ch0=0;
int chlast=chansPerMod[0]-1;
int nchmod=chansPerMod[0];
if (i0>0)
if (I0>0) {
i0=*I0;
totalI0+=i0;
} else
i0=-1;
// if (badChannelMask)
// cout << "---------------- Discarding bad chans " << endl;
// cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA add frame " << i0 << endl;
for (int ich=0; ich<totalChans; ich++) {
@ -108,9 +123,9 @@ int postProcessingFuncs::addFrame(double *data, double *pos, double *I0, double
if (tDead) {
#ifdef VERBOSE
cout << "ppFuncs ratecorrect" << endl;
#endif
//#ifdef VERBOSE
// cout << "ppFuncs ratecorrect" << endl;
//#endif
rateCorrect(vin, ein, vout, eout, tDead, *expTime);
vin=vout;
ein=eout;
@ -118,9 +133,9 @@ int postProcessingFuncs::addFrame(double *data, double *pos, double *I0, double
//ffcorrect
if (ffCoeff) {
#ifdef VERBOSE
cout << "ppFuncs ffcorrect" << endl;
#endif
//#ifdef VERBOSE
// cout << "ppFuncs ffcorrect" << endl;
//#endif
if (ffErr)
e=ffErr[ich];
else
@ -131,19 +146,21 @@ int postProcessingFuncs::addFrame(double *data, double *pos, double *I0, double
//i0correct
if (i0>0) {
#ifdef VERBOSE
cout << "ppFuncs i0 norm" << endl;
#endif
//#ifdef VERBOSE
// cout << "ppFuncs i0 norm" << endl;
//#endif
vout/=i0;
eout/=i0;
}
if (badChannelMask) {
#ifdef VERBOSE
cout << "ppFuncs badchans" << endl;
#endif
if (badChannelMask[ich])
//#ifdef VERBOSE
// cout << "ppFuncs badchans" << endl;
//#endif
if (badChannelMask[ich]) {
// cout << "------------------ Discarding channel " << ich << endl;
continue;
}
}
if (nBins) {
//angconv
@ -157,7 +174,7 @@ int postProcessingFuncs::addFrame(double *data, double *pos, double *I0, double
p1=convertAngle(*pos,ich-ch0,angConv[imod],moduleMask[imod],totalOffset,0,angDir);
// #ifdef VERBOSE
// cout << "ppFuncs merge" << endl;
// cout << "************************** ppFuncs merge" << endl;
// #endif
addPointToMerging(p1,vout,eout,mp,mv,me,mm, binSize, nBins);
@ -180,16 +197,17 @@ int postProcessingFuncs::addFrame(double *data, double *pos, double *I0, double
int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],int badCh[], double ffcoeff[], double fferr[], double* t, int *dir, double angRadius[], double angOffset[], double angCenter[], double* to, double* bs, double *sX, double *sY) {
#ifdef VERBOSE
cout << "delete pointers " << endl;
#endif
// cout << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA init dataset XXXXXX " << endl;
//#ifdef VERBOSE
// cout << "delete pointers " << endl;
//#endif
deletePointers();
#ifdef VERBOSE
cout << "nmod " << endl;
#endif
//#ifdef VERBOSE
// cout << "nmod " << endl;
//#endif
if (nModules)
nMods=*nModules;
@ -197,9 +215,9 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
nMods=0;
#ifdef VERBOSE
cout << nMods << endl;
#endif
//#ifdef VERBOSE
//cout << nMods << endl;
//#endif
#ifdef VERBOSE
cout << "tdead " << endl;
#endif
@ -225,18 +243,18 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
#endif
#ifdef VERBOSE
cout << "binsize " << endl;
#endif
//#ifdef VERBOSE
// cout << "binsize " << endl;
//#endif
if (bs)
binSize=*bs;
else
binSize=0;
#ifdef VERBOSE
cout << binSize << endl;
#endif
//#ifdef VERBOSE
// cout << binSize << endl;
//#endif
#ifdef VERBOSE
cout << "samplex " << endl;
#endif
@ -259,17 +277,17 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
#ifdef VERBOSE
cout << sampleY << endl;
#endif
#ifdef VERBOSE
cout << "angdir " << endl;
#endif
//#ifdef VERBOSE
// cout << "angdir " << endl;
//#endif
if (dir)
angDir=*dir;
else
angDir=1;
#ifdef VERBOSE
cout << angDir << endl;
#endif
//#ifdef VERBOSE
// cout << angDir << endl;
//#endif
totalChans=0;
@ -281,26 +299,32 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
nBins=0;
if (angRadius && angOffset && angCenter && (binSize>0)) {
// cout << "??????? creating angConv"<< endl;
angConv=new angleConversionConstant*[nMods];
nBins=(int)(360./binSize)+1;
}
#ifdef VERBOSE
cout << "nBins " << nBins << endl;
#endif
//#ifdef VERBOSE
//cout << "nBins " << nBins << endl;
//#endif
for (int im=0; im<nMods; im++) {
//#ifdef VERBOSE
// cout << "MODULE "<< im << endl;
//cout << "MODULE "<< im << endl;
//#endif
chansPerMod[im]=chPerMod[im];
//cout << chansPerMod[im] << endl;
moduleMask[im]=modMask[im];
//cout << modMask[im] << endl;
totalChans+=chansPerMod[im];
//cout << totalChans << endl;
if (angConv) {
//cout << "??????? angConv"<< endl;
angConv[im]=new angleConversionConstant(angCenter[im], angRadius[im], angOffset[im], 0);
}
// cout << angCenter[im] << " " << chansPerMod[im] << " " << angRadius[im] << " " << angOffset[im] << " " << moduleMask[im] << endl;
//cout << angCenter[im] << " " << chansPerMod[im] << " " << angRadius[im] << " " << angOffset[im] << " " << moduleMask[im] << endl;
}
//else cout << "no ang conv " << endl;
}
// cout << "finished modules loop" << endl;
#ifdef VERBOSE
cout << "badchans " << endl;
@ -334,7 +358,7 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
// cout << " init ff " << ich << " " << ffCoeff[ich] << ffcoeff[ich] << endl;
}
//cout << "init dataset finished " << endl;
return 0;
}
@ -345,25 +369,35 @@ int postProcessingFuncs::initDataset(int *nModules,int *chPerMod,int modMask[],i
void postProcessingFuncs::deletePointers() {
delete [] chansPerMod;
chansPerMod=NULL;
delete [] moduleMask;
if (badChannelMask)
moduleMask=NULL;
if (badChannelMask) {
delete [] badChannelMask;
badChannelMask=NULL;
}
if (ffCoeff)
if (ffCoeff) {
delete [] ffCoeff;
if (ffErr)
ffCoeff=NULL;
}
if (ffErr) {
delete [] ffErr;
if (angConv) {
for (int im=0; im<nMods; im++) {
if (angConv[im])
delete angConv[im];
}
delete [] angConv;
ffErr=NULL;
}
if (angConv) {
for (int im=0; im<nMods; im++) {
if (angConv[im])
delete angConv[im];
}
// cout << "deleting angConv "<< angConv << endl;
delete [] angConv;
angConv=NULL;
}
// cout << "angConv pointer " << angConv << endl;
}