mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-08 19:10:42 +02:00
solved bug with multidetector angular conversion
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@180 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
b5e966bb58
commit
83ee449e3c
@ -1434,9 +1434,15 @@ float* multiSlsDetector::decodeData(int *datain, float *fdata) {
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
if (detectors[i]) {
|
||||
detectors[i]->decodeData(datap, detp);
|
||||
#ifdef VERBOSE
|
||||
cout << "increment pointers " << endl;
|
||||
#endif
|
||||
datap+=detectors[i]->getDataBytes()/sizeof(int);
|
||||
detp+=detectors[i]->getTotalNumberOfChannels();
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "done " << endl;
|
||||
#endif
|
||||
// for (int j=0; j<detectors[i]->getTotalNumberOfChannels(); j++) {
|
||||
// dataout[ich]=detp[j];
|
||||
// ich++;
|
||||
@ -1683,7 +1689,11 @@ int multiSlsDetector::getNMods(){
|
||||
|
||||
int multiSlsDetector::getChansPerMod(int imod){
|
||||
int id=-1, im=-1;
|
||||
if (decodeNMod(imod, id, im)>=0) {
|
||||
#ifdef VERBOSE
|
||||
cout << "get chans per mod " << imod << endl;
|
||||
#endif
|
||||
decodeNMod(imod, id, im);
|
||||
if (id >=0) {
|
||||
if (detectors[id]) {
|
||||
return detectors[id]->getChansPerMod(im);
|
||||
}
|
||||
@ -1709,6 +1719,9 @@ int multiSlsDetector::getMoveFlag(int imod){
|
||||
|
||||
angleConversionConstant * multiSlsDetector::getAngularConversionPointer(int imod){
|
||||
int id=-1, im=-1;
|
||||
#ifdef VERBOSE
|
||||
cout << "get angular conversion pointer " << endl;
|
||||
#endif
|
||||
if (decodeNMod(imod, id, im)>=0) {
|
||||
if (detectors[id]) {
|
||||
return detectors[id]->getAngularConversionPointer(im);
|
||||
@ -2695,6 +2708,21 @@ int multiSlsDetector::setDynamicRange(int p) {
|
||||
|
||||
}
|
||||
|
||||
int multiSlsDetector::getMaxMods() {
|
||||
|
||||
|
||||
int ret=0, ret1;
|
||||
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||
if (detectors[idet]) {
|
||||
ret1=detectors[idet]->getMaxMods();
|
||||
ret+=ret1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int multiSlsDetector::getMaxNumberOfModules(dimension d) {
|
||||
|
||||
@ -2702,7 +2730,7 @@ int multiSlsDetector::getMaxNumberOfModules(dimension d) {
|
||||
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||
if (detectors[idet]) {
|
||||
ret1=detectors[idet]->getMaxNumberOfModules();
|
||||
ret1=detectors[idet]->getMaxNumberOfModules(d);
|
||||
ret+=ret1;
|
||||
}
|
||||
}
|
||||
@ -2743,14 +2771,14 @@ int multiSlsDetector::setNumberOfModules(int p, dimension d) {
|
||||
|
||||
int multiSlsDetector::decodeNMod(int i, int &id, int &im) {
|
||||
#ifdef VERBOSE
|
||||
cout << " Module " << i << " belongs to detector ";
|
||||
cout << " Module " << i << " belongs to detector " << id ;
|
||||
#endif
|
||||
|
||||
if (i<0 || i>=getMaxNumberOfModules()) {
|
||||
if (i<0 || i>=getMaxMods()) {
|
||||
id=-1;
|
||||
im=-1;
|
||||
#ifdef VERBOSE
|
||||
cout << id << " position " << im << endl;
|
||||
cout << "A---------" << id << " position " << im << endl;
|
||||
#endif
|
||||
|
||||
return -1;
|
||||
@ -2763,7 +2791,7 @@ int multiSlsDetector::decodeNMod(int i, int &id, int &im) {
|
||||
id=idet;
|
||||
im=i;
|
||||
#ifdef VERBOSE
|
||||
cout << id << " position " << im << endl;
|
||||
cout << "B---------" <<id << " position " << im << endl;
|
||||
#endif
|
||||
return im;
|
||||
} else {
|
||||
@ -2774,7 +2802,7 @@ int multiSlsDetector::decodeNMod(int i, int &id, int &im) {
|
||||
id=-1;
|
||||
im=-1;
|
||||
#ifdef VERBOSE
|
||||
cout << id << " position " << im << endl;
|
||||
cout <<"C---------" << id << " position " << im << endl;
|
||||
#endif
|
||||
return -1;
|
||||
|
||||
@ -3426,6 +3454,9 @@ int multiSlsDetector::writeDataFile(string fname, int *data) {
|
||||
{
|
||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
if (detectors[i]) {
|
||||
#ifdef VERBOSE
|
||||
cout << " write " << i << endl;
|
||||
#endif
|
||||
detectors[i]->writeDataFile(outfile, detectors[i]->getTotalNumberOfChannels(), data+off, choff);
|
||||
choff+=detectors[i]->getMaxNumberOfChannels();
|
||||
off+=detectors[i]->getTotalNumberOfChannels();
|
||||
|
@ -288,9 +288,10 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
|
||||
|
||||
|
||||
|
||||
int getMaxMods();
|
||||
int getNMods();
|
||||
int getChansPerMod(int imod=0);
|
||||
|
||||
angleConversionConstant *getAngularConversionPointer(int imod=0);
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ int ififostart, ififostop, ififostep, ififo;
|
||||
|
||||
int masterMode=NO_MASTER, syncMode=NO_SYNCHRONIZATION, timingMode=AUTO_TIMING;
|
||||
|
||||
enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF};
|
||||
enum externalSignalFlag signals[4]={GATE_IN_ACTIVE_HIGH, TRIGGER_IN_RISING_EDGE, SIGNAL_OFF, SIGNAL_OFF};
|
||||
|
||||
|
||||
#ifdef MCB_FUNCS
|
||||
|
@ -1380,7 +1380,7 @@ int slsDetector::getMaxNumberOfModules(dimension d){
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
else {
|
||||
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
std::cout<< "Deterctor returned error: " << mess << std::endl;
|
||||
std::cout<< "Detector returned error: " << mess << std::endl;
|
||||
}
|
||||
controlSocket->Disconnect();
|
||||
if (ret==FORCE_UPDATE)
|
||||
@ -4919,6 +4919,8 @@ int slsDetector::writeConfigurationFile(ofstream &outfile){
|
||||
|
||||
slsDetectorCommand *cmd=new slsDetectorCommand(this);
|
||||
int nvar;
|
||||
int nsig=-1;
|
||||
|
||||
string names[]={ \
|
||||
"hostname", \
|
||||
"port", \
|
||||
@ -4941,7 +4943,8 @@ int slsDetector::writeConfigurationFile(ofstream &outfile){
|
||||
"threaded", \
|
||||
"waitstates", \
|
||||
"setlength", \
|
||||
"clkdivider"};
|
||||
"clkdivider", \
|
||||
"extsig" };
|
||||
|
||||
switch (thisDetector->myDetectorType) {
|
||||
case GOTTHARD:
|
||||
@ -4951,8 +4954,11 @@ int slsDetector::writeConfigurationFile(ofstream &outfile){
|
||||
names[9]="servermac";
|
||||
nvar=10;
|
||||
break;
|
||||
case MYTHEN:
|
||||
nsig=4;
|
||||
default:
|
||||
nvar=22;
|
||||
nvar=23;
|
||||
|
||||
}
|
||||
|
||||
int iv=0;
|
||||
@ -4963,9 +4969,17 @@ int slsDetector::writeConfigurationFile(ofstream &outfile){
|
||||
|
||||
|
||||
for (iv=0; iv<nvar; iv++) {
|
||||
cout << iv << " " << names[iv] << endl;
|
||||
if (names[iv]=="extsig") {
|
||||
for (int is=0; is<nsig; is++) {
|
||||
sprintf(args[0],"%s:%d",names[iv].c_str(),is);
|
||||
outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl;
|
||||
}
|
||||
} else {
|
||||
strcpy(args[0],names[iv].c_str());
|
||||
outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl;
|
||||
}
|
||||
}
|
||||
delete cmd;
|
||||
return iv;
|
||||
}
|
||||
@ -5030,7 +5044,7 @@ int slsDetector::dumpDetectorSetup(string const fname, int level){
|
||||
"badchannels",\
|
||||
"angconv",\
|
||||
"trimbits",\
|
||||
"extsig"
|
||||
"timing"
|
||||
};
|
||||
int nvar=41;
|
||||
int iv=0;
|
||||
@ -5103,10 +5117,11 @@ int slsDetector::dumpDetectorSetup(string const fname, int level){
|
||||
outfile << names[iv] << " " << cmd->executeLine(nargs,args,GET_ACTION) << std::endl;
|
||||
iv++;
|
||||
|
||||
for (int is=0; is<4; is++) {
|
||||
sprintf(args[0],"%s:%d",names[iv].c_str(),is);
|
||||
strcpy(args[0],names[iv].c_str());
|
||||
// for (int is=0; is<4; is++) {
|
||||
// sprintf(args[0],"%s:%d",names[iv].c_str(),is);
|
||||
outfile << args[0] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl;
|
||||
}
|
||||
// }
|
||||
iv++;
|
||||
outfile.close();
|
||||
}
|
||||
|
@ -36,21 +36,40 @@ angularConversion::~angularConversion(){
|
||||
|
||||
|
||||
float* angularConversion::convertAngles(float pos) {
|
||||
int imod;
|
||||
int imod=0;
|
||||
float *ang=new float[getTotalNumberOfChannels()];
|
||||
float enc=pos;
|
||||
angleConversionConstant *p=NULL;
|
||||
for (int ip=0; ip<getTotalNumberOfChannels(); ip++) {
|
||||
imod=ip/(getChansPerMod(0)); // always for module 0?????
|
||||
p=getAngularConversionPointer(imod);
|
||||
|
||||
int ch0=0;
|
||||
int chlast=getChansPerMod(0);
|
||||
int nchmod=getChansPerMod(0);
|
||||
p=getAngularConversionPointer(imod);
|
||||
if (getMoveFlag(imod)==0)
|
||||
enc=0;
|
||||
else
|
||||
enc=pos;
|
||||
|
||||
for (int ip=0; ip<getTotalNumberOfChannels(); ip++) {
|
||||
#ifdef VERBOSE
|
||||
// cout << "ip " << ip << " ch0 " << ch0 << " chlast " << chlast << " imod " << imod << endl;
|
||||
#endif
|
||||
if (ip>=chlast) {
|
||||
imod++;
|
||||
p=getAngularConversionPointer(imod);
|
||||
if (getMoveFlag(imod)==0)
|
||||
enc=0;
|
||||
else
|
||||
enc=pos;
|
||||
|
||||
ch0=chlast;
|
||||
nchmod=getChansPerMod(imod);
|
||||
if (nchmod>0)
|
||||
chlast+=nchmod;
|
||||
}
|
||||
|
||||
if (p)
|
||||
ang[ip]=angle(ip%(getChansPerMod()), \
|
||||
ang[ip]=angle(ip-ch0, \
|
||||
enc, \
|
||||
(*fineOffset)+(*globalOffset), \
|
||||
p->r_conversion, \
|
||||
|
@ -417,8 +417,6 @@ class angularConversion : public virtual slsDetectorBase {
|
||||
current position of the detector
|
||||
*/
|
||||
float currentPosition;
|
||||
|
||||
|
||||
/**
|
||||
current position index of the detector
|
||||
*/
|
||||
|
@ -144,8 +144,10 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
||||
|
||||
delete [] myData;
|
||||
myData=NULL;
|
||||
fdata=NULL;
|
||||
|
||||
#ifdef VERBOSE
|
||||
// cout << "Pop data queue " << *fileIndex << endl;
|
||||
cout << "Pop data queue " << *fileIndex << endl;
|
||||
#endif
|
||||
|
||||
pthread_mutex_lock(&mp);
|
||||
@ -159,7 +161,7 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
||||
|
||||
|
||||
|
||||
void postProcessing::doProcessing(float *fdata, int delflag, string fname) {
|
||||
void postProcessing::doProcessing(float *lfdata, int delflag, string fname) {
|
||||
|
||||
|
||||
/** write raw data file */
|
||||
@ -187,13 +189,13 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) {
|
||||
if (*correctionMask&(1<<RATE_CORRECTION)) {
|
||||
rcdata=new float[getTotalNumberOfChannels()];
|
||||
rcerr=new float[getTotalNumberOfChannels()];
|
||||
rateCorrect(fdata,NULL,rcdata,rcerr);
|
||||
delete [] fdata;
|
||||
fdata=NULL;
|
||||
rateCorrect(lfdata,NULL,rcdata,rcerr);
|
||||
delete [] lfdata;
|
||||
} else {
|
||||
rcdata=fdata;
|
||||
fdata=NULL;
|
||||
rcdata=lfdata;
|
||||
}
|
||||
lfdata=NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -250,6 +252,7 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) {
|
||||
#endif
|
||||
|
||||
|
||||
cout << "lock 1" << endl;
|
||||
pthread_mutex_lock(&mp);
|
||||
if ((getCurrentPositionIndex()>=getNumberOfPositions() && posfinished==1 && queuesize==1)) {
|
||||
|
||||
@ -259,6 +262,7 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) {
|
||||
np=finalizeMerging();
|
||||
/** file writing */
|
||||
incrementPositionIndex();
|
||||
cout << "unlock 1" << endl;
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
|
||||
@ -279,16 +283,21 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) {
|
||||
} else {
|
||||
thisData=new detectorData(getMergedCounts(),getMergedErrors(),getMergedPositions(),getCurrentProgress(),(fname+ext).c_str(),np);
|
||||
|
||||
cout << "lock 2" << endl;
|
||||
pthread_mutex_lock(&mg);
|
||||
finalDataQueue.push(thisData);
|
||||
cout << "unlock 2" << endl;
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
cout << "lock 3" << endl;
|
||||
pthread_mutex_lock(&mp);
|
||||
}
|
||||
cout << "unlock 3" << endl;
|
||||
pthread_mutex_unlock(&mp);
|
||||
|
||||
if (ffcdata)
|
||||
delete [] ffcdata;
|
||||
|
||||
ffcdata=NULL;
|
||||
|
||||
if (ffcerr)
|
||||
@ -317,7 +326,9 @@ void postProcessing::doProcessing(float *fdata, int delflag, string fname) {
|
||||
}
|
||||
|
||||
incrementFileIndex();
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "fdata is " << fdata << endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@ -449,9 +460,15 @@ void* postProcessing::processData(int delflag) {
|
||||
dum=0;
|
||||
}
|
||||
|
||||
if (fdata)
|
||||
if (fdata) {
|
||||
#ifdef VERBOSE
|
||||
cout << "delete fdata" << endl;
|
||||
#endif
|
||||
delete [] fdata;
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "done " << endl;
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user