added nchans for each dimension and edited update offsets to work better for 2d dets

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@514 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2013-04-16 13:39:58 +00:00
parent cec069f0e9
commit ca15ff971d
5 changed files with 91 additions and 43 deletions

View File

@ -341,47 +341,66 @@ int multiSlsDetector::addSlsDetector(int id, int pos) {
#endif #endif
//set offsets //set offsets
int offsetX=0,offsetY=0,numX,numY; updateOffsets();
int maxChanX = thisMultiDetector->maxNumberOfChannelsPerDetector[X];
int maxChanY = thisMultiDetector->maxNumberOfChannelsPerDetector[Y];
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
thisMultiDetector->offsetX[i] = offsetX;
thisMultiDetector->offsetY[i] = offsetY;
cout << "Detector pos: " << i << " offset X:" << offsetX << " offset Y:" << offsetY << endl;
numX = detectors[i]->getMaxNumberOfChannels(X);
numY = detectors[i]->getMaxNumberOfChannels(Y);
offsetX += numX;
if ((maxChanX == -1) || ((maxChanX > 0) && (offsetX < maxChanX))){
thisMultiDetector->numberOfChannel[X] += detectors[i]->getTotalNumberOfChannels(X);
thisMultiDetector->maxNumberOfChannel[X] += numX;
}else{
offsetX = 0;
thisMultiDetector->numberOfChannel[X] = 0;
thisMultiDetector->maxNumberOfChannel[X] = 0;
offsetY += numY;
if ((maxChanY == -1) || ((maxChanY > 0) && (offsetY < maxChanY))){
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
thisMultiDetector->maxNumberOfChannel[Y] += numY;
}else{
cout<<"Detector " << id << "exceeds maximum channels allowed for complete detector set in y dimension also!" << endl;
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
thisMultiDetector->maxNumberOfChannel[Y] += numY;
}
}
}
}
return thisMultiDetector->numberOfDetectors; return thisMultiDetector->numberOfDetectors;
} }
void multiSlsDetector::updateOffsets(){
int offsetX=0,offsetY=0,numX,numY;
int maxChanX = thisMultiDetector->maxNumberOfChannelsPerDetector[X];
int maxChanY = thisMultiDetector->maxNumberOfChannelsPerDetector[Y];
thisMultiDetector->numberOfChannel[X] = 0;
thisMultiDetector->maxNumberOfChannel[X] = 0;
thisMultiDetector->numberOfChannel[Y] = 0;
thisMultiDetector->maxNumberOfChannel[Y] = 0;
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
thisMultiDetector->offsetX[i] = offsetX;
thisMultiDetector->offsetY[i] = offsetY;
cout << "Detector pos: " << i << " offset X:" << offsetX << " offset Y:" << offsetY << endl;
numX = detectors[i]->getMaxNumberOfChannels(X);
numY = detectors[i]->getMaxNumberOfChannels(Y);
offsetX += numX;
if ((maxChanX == -1) || ((maxChanX > 0) && (offsetX < maxChanX))){
thisMultiDetector->numberOfChannel[X] += detectors[i]->getTotalNumberOfChannels(X);
thisMultiDetector->maxNumberOfChannel[X] += numX;
//the first time y should be added but offset not increased
if (thisMultiDetector->numberOfChannel[Y] == 0){
if ((maxChanY == -1) || ((maxChanY > 0) && (numY < maxChanY))){
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
thisMultiDetector->maxNumberOfChannel[Y] += numY;
}else{
cout<<"Detector at position " << i << "exceeds maximum channels allowed for complete detector set in y dimension also!" << endl;
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
thisMultiDetector->maxNumberOfChannel[Y] += numY;
}
}
}else{
offsetX = 0;
thisMultiDetector->numberOfChannel[X] = 0;
thisMultiDetector->maxNumberOfChannel[X] = 0;
offsetY += numY;
if ((maxChanY == -1) || ((maxChanY > 0) && (offsetY < maxChanY))){
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
thisMultiDetector->maxNumberOfChannel[Y] += numY;
}else{
cout<<"Detector at position " << i << "exceeds maximum channels allowed for complete detector set in y dimension also!" << endl;
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
thisMultiDetector->maxNumberOfChannel[Y] += numY;
}
}
}
}
}
string multiSlsDetector::setHostname(const char* name, int pos){ string multiSlsDetector::setHostname(const char* name, int pos){
// int id=0; // int id=0;
@ -762,6 +781,8 @@ int multiSlsDetector::removeSlsDetector(int pos) {
} }
} }
updateOffsets();
return thisMultiDetector->numberOfDetectors; return thisMultiDetector->numberOfDetectors;
} }

View File

@ -1194,6 +1194,9 @@ class multiSlsDetector : public slsDetectorUtils {
*/ */
int setReadReceiverFrequency(int i=-1); int setReadReceiverFrequency(int i=-1);
/** updates the multidetector offsets */
void updateOffsets();
protected: protected:

View File

@ -490,6 +490,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
switch(thisDetector->myDetectorType) { switch(thisDetector->myDetectorType) {
case MYTHEN: case MYTHEN:
thisDetector->nChans=128; thisDetector->nChans=128;
thisDetector->nChan[X]=128;
thisDetector->nChan[Y]=1;
thisDetector->nChips=10; thisDetector->nChips=10;
thisDetector->nDacs=6; thisDetector->nDacs=6;
thisDetector->nAdcs=0; thisDetector->nAdcs=0;
@ -503,6 +505,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
break; break;
case PICASSO: case PICASSO:
thisDetector->nChans=128; thisDetector->nChans=128;
thisDetector->nChan[X]=128;
thisDetector->nChan[Y]=1;
thisDetector->nChips=12; thisDetector->nChips=12;
thisDetector->nDacs=6; thisDetector->nDacs=6;
thisDetector->nAdcs=0; thisDetector->nAdcs=0;
@ -512,6 +516,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
break; break;
case GOTTHARD: case GOTTHARD:
thisDetector->nChans=128; thisDetector->nChans=128;
thisDetector->nChan[X]=128;
thisDetector->nChan[Y]=1;
thisDetector->nChips=10; thisDetector->nChips=10;
thisDetector->nDacs=8; thisDetector->nDacs=8;
thisDetector->nAdcs=5; thisDetector->nAdcs=5;
@ -521,6 +527,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
break; break;
case MOENCH: case MOENCH:
thisDetector->nChans=160*160; thisDetector->nChans=160*160;
thisDetector->nChan[X]=160;
thisDetector->nChan[Y]=160;
thisDetector->nChips=1; thisDetector->nChips=1;
thisDetector->nDacs=8; thisDetector->nDacs=8;
thisDetector->nAdcs=1; thisDetector->nAdcs=1;
@ -530,7 +538,9 @@ int slsDetector::initializeDetectorSize(detectorType type) {
break; break;
default: default:
thisDetector->nChans=0; thisDetector->nChans=0;
thisDetector->nChips=0; thisDetector->nChan[X]=0;
thisDetector->nChan[Y]=0;
thisDetector->nChips=0;
thisDetector->nDacs=0; thisDetector->nDacs=0;
thisDetector->nAdcs=0; thisDetector->nAdcs=0;
thisDetector->nModMax[X]=0; thisDetector->nModMax[X]=0;

View File

@ -116,6 +116,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int nModsMax; int nModsMax;
/** number of channels per chip */ /** number of channels per chip */
int nChans; int nChans;
/** number of channels per chip in one direction */
int nChan[2];
/** number of chips per module*/ /** number of chips per module*/
int nChips; int nChips;
/** number of dacs per module*/ /** number of dacs per module*/
@ -564,6 +566,9 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
/** Returns the number of channels per chip (without connecting to the detector) */ /** Returns the number of channels per chip (without connecting to the detector) */
int getNChans(){return thisDetector->nChans;}; // int getNChans(){return thisDetector->nChans;}; //
/** Returns the number of channels per chip (without connecting to the detector) in one direction */
int getNChans(dimension d){return thisDetector->nChan[d];}; //
/** Returns the number of chips per module (without connecting to the detector) */ /** Returns the number of chips per module (without connecting to the detector) */
int getNChips(){return thisDetector->nChips;}; // int getNChips(){return thisDetector->nChips;}; //
@ -575,6 +580,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int getChansPerMod(int imod=0){return thisDetector->nChans*thisDetector->nChips;}; int getChansPerMod(int imod=0){return thisDetector->nChans*thisDetector->nChips;};
int getChansPerMod( dimension d,int imod=0){return thisDetector->nChan[d]*thisDetector->nChips;};
/** Returns the max number of modules in direction d (without connecting to the detector) */ /** Returns the max number of modules in direction d (without connecting to the detector) */
int getNMaxMod(dimension d){return thisDetector->nModMax[d];}; // int getNMaxMod(dimension d){return thisDetector->nModMax[d];}; //
@ -584,11 +591,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int getTotalNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;}; int getTotalNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;};
int getTotalNumberOfChannels(dimension d){return thisDetector->nChans*thisDetector->nChips*thisDetector->nMod[X];}; int getTotalNumberOfChannels(dimension d){return thisDetector->nChan[d]*thisDetector->nChips*thisDetector->nMod[X];};
int getMaxNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;}; int getMaxNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;};
int getMaxNumberOfChannels(dimension d){return thisDetector->nChans*thisDetector->nChips*thisDetector->nModMax[d];}; int getMaxNumberOfChannels(dimension d){return thisDetector->nChan[d]*thisDetector->nChips*thisDetector->nModMax[d];};
/** Returns number of rois */ /** Returns number of rois */
int getNRoi(){return thisDetector->nROI;}; int getNRoi(){return thisDetector->nROI;};

View File

@ -24,7 +24,8 @@
#include <iomanip> //set precision #include <iomanip> //set precision
#include <sched.h> //#include <sched.h> //sched_idle
//#include <fcntl.h> //posix_fadvice
#include <string.h> #include <string.h>
#include <iostream> #include <iostream>
@ -91,6 +92,7 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
if (det == MOENCH) if (det == MOENCH)
aligned_frame_size = MOENCH_ALIGNED_FRAME_SIZE; aligned_frame_size = MOENCH_ALIGNED_FRAME_SIZE;
mem0=(char*)malloc(aligned_frame_size*FIFO_SIZE); mem0=(char*)malloc(aligned_frame_size*FIFO_SIZE);
if (mem0==NULL) { if (mem0==NULL) {
cout<<"++++++++++++++++++++++ COULD NOT ALLOCATE MEMORY!!!!!!!+++++++++++++++++++++" << endl; cout<<"++++++++++++++++++++++ COULD NOT ALLOCATE MEMORY!!!!!!!+++++++++++++++++++++" << endl;
@ -246,12 +248,12 @@ int slsReceiverFunctionList::startReceiver(){
cout << "ERROR: Could not prioritize threads. You need to be super user for that." << endl; cout << "ERROR: Could not prioritize threads. You need to be super user for that." << endl;
if (pthread_setschedparam(writing_thread, policy, &write_param) == EPERM) if (pthread_setschedparam(writing_thread, policy, &write_param) == EPERM)
cout << "ERROR: Could not prioritize threads. You need to be super user for that." << endl; cout << "ERROR: Could not prioritize threads. You need to be super user for that." << endl;
if (pthread_setschedparam(pthread_self(), 5, &tcp_param) == EPERM) if (pthread_setschedparam(pthread_self(),policy , &tcp_param) == EPERM)
cout << "ERROR: Could not prioritize threads. You need to be super user for that." << endl; cout << "ERROR: Could not prioritize threads. You need to be super user for that." << endl;
pthread_getschedparam(pthread_self(),&policy,&tcp_param); //pthread_getschedparam(pthread_self(),&policy,&tcp_param);
cout << "current priority of main tcp thread is " << tcp_param.sched_priority << endl; //cout << "current priority of main tcp thread is " << tcp_param.sched_priority << endl;
} }
@ -453,6 +455,7 @@ int slsReceiverFunctionList::startWriting(){
if(enableFileWrite || cbAction>0){ if(enableFileWrite || cbAction>0){
sfilefd = fopen((const char *) (savefilename), "w"); sfilefd = fopen((const char *) (savefilename), "w");
cout << savefilename << endl; cout << savefilename << endl;
//posix_fadvise(fileno(sfilefd),0,0,POSIX_FADV_DONTNEED|POSIX_FADV_SEQUENTIAL);
} }
@ -468,8 +471,10 @@ int slsReceiverFunctionList::startWriting(){
//start writing in new file //start writing in new file
if(enableFileWrite || cbAction>0){ if(enableFileWrite || cbAction>0){
//fsync(fileno(sfilefd));
fclose(sfilefd); fclose(sfilefd);
sfilefd = fopen((const char *) (savefilename), "w"); sfilefd = fopen((const char *) (savefilename), "w");
//posix_fadvise(fileno(sfilefd),0,0,POSIX_FADV_DONTNEED|POSIX_FADV_SEQUENTIAL);
} }
//currframenum=(int)(*((int*)latestData)); //currframenum=(int)(*((int*)latestData));
@ -535,7 +540,9 @@ int slsReceiverFunctionList::startWriting(){
cout << "Total Frames Caught:"<< totalFramesCaught << endl; cout << "Total Frames Caught:"<< totalFramesCaught << endl;
//close file //close file
if(sfilefd) fclose(sfilefd); if(sfilefd)
fclose(sfilefd);
//{ fsync(fileno(sfilefd));fclose(sfilefd);}
#ifdef VERBOSE #ifdef VERBOSE
cout << "sfield:" << (int)sfilefd << endl; cout << "sfield:" << (int)sfilefd << endl;
#endif #endif