mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 05:17:13 +02:00
parallelized ratecorrection
This commit is contained in:
@ -2828,41 +2828,74 @@ int multiSlsDetector::setRateCorrection(double t){
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Setting rate correction with dead time "<< thisMultiDetector->tDead << std::endl;
|
||||
#endif
|
||||
int ret=OK;
|
||||
int posmax=thisMultiDetector->numberOfDetectors;
|
||||
|
||||
// eiger return value is ok/fail
|
||||
if (getDetectorsType() == EIGER){
|
||||
int ret = OK, ret1= OK;
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
|
||||
if (detectors[idet]) {
|
||||
ret=detectors[idet]->setRateCorrection(t);
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return FAIL;
|
||||
}else{
|
||||
int* iret[posmax];
|
||||
for(int idet=0; idet<posmax; ++idet){
|
||||
if(detectors[idet]){
|
||||
iret[idet]= new int(OK);
|
||||
Task* task = new Task(new func1_t<int,double>(&slsDetector::setRateCorrection,
|
||||
detectors[idet],t,iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
}
|
||||
threadpool->startExecuting();
|
||||
threadpool->wait_for_tasks_to_complete();
|
||||
for(int idet=0; idet<posmax; ++idet){
|
||||
if(detectors[idet]){
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] != OK)
|
||||
ret = FAIL;
|
||||
delete iret[idet];
|
||||
}else ret = FAIL;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if (ret != OK)
|
||||
ret1=FAIL;
|
||||
}
|
||||
}
|
||||
return ret1; //only success/fail
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//mythen, others
|
||||
|
||||
// mythen, others
|
||||
if (t==0) {
|
||||
thisMultiDetector->correctionMask&=~(1<<RATE_CORRECTION);
|
||||
return thisMultiDetector->correctionMask&(1<<RATE_CORRECTION);
|
||||
} else
|
||||
thisMultiDetector->correctionMask|=(1<<RATE_CORRECTION);
|
||||
|
||||
int ret, ret1=-100;
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
|
||||
if (detectors[idet]) {
|
||||
ret=detectors[idet]->setRateCorrection(t);
|
||||
ret = -100;
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return -1;
|
||||
}else{
|
||||
int* iret[posmax];
|
||||
for(int idet=0; idet<posmax; ++idet){
|
||||
if(detectors[idet]){
|
||||
iret[idet]= new int(-1);
|
||||
Task* task = new Task(new func1_t<int,double>(&slsDetector::setRateCorrection,
|
||||
detectors[idet],t,iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
}
|
||||
threadpool->startExecuting();
|
||||
threadpool->wait_for_tasks_to_complete();
|
||||
for(int idet=0; idet<posmax; ++idet){
|
||||
if(detectors[idet]){
|
||||
if(iret[idet] != NULL)
|
||||
delete iret[idet];
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1)
|
||||
ret1=-1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return thisMultiDetector->correctionMask&(1<<RATE_CORRECTION);
|
||||
}
|
||||
|
||||
@ -2889,22 +2922,44 @@ int multiSlsDetector::getRateCorrection(double &t){
|
||||
|
||||
double multiSlsDetector::getRateCorrectionTau(){
|
||||
|
||||
double ret1=-100,ret;
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet) {
|
||||
if (detectors[idet]) {
|
||||
ret=detectors[idet]->getRateCorrectionTau();
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1){
|
||||
double ret=-100.0;
|
||||
int posmax = thisMultiDetector->numberOfDetectors;
|
||||
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return -1;
|
||||
}else{
|
||||
double* iret[posmax];
|
||||
for(int idet=0; idet<thisMultiDetector->numberOfDetectors; ++idet){
|
||||
if(detectors[idet]){
|
||||
iret[idet]= new double(-1);
|
||||
Task* task = new Task(new func0_t<double>(&slsDetector::getRateCorrectionTau,
|
||||
detectors[idet],iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
}
|
||||
threadpool->startExecuting();
|
||||
threadpool->wait_for_tasks_to_complete();
|
||||
|
||||
for(int idet=0; idet<posmax; ++idet){
|
||||
if(detectors[idet]){
|
||||
if(iret[idet] != NULL){
|
||||
if(*iret[idet] == -100.0)
|
||||
ret = *iret[idet];
|
||||
else if ((ret - *iret[idet]) > 0.000000001) {
|
||||
std::cout<< "Rate correction is different for different readouts " << std::endl;
|
||||
ret1=-1;
|
||||
ret=-1;
|
||||
}
|
||||
delete iret[idet];
|
||||
}else ret = -1;
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getDetectorsType() == EIGER)
|
||||
return ret1;
|
||||
|
||||
return ret;
|
||||
|
||||
|
||||
//only mythen
|
||||
@ -2916,9 +2971,9 @@ double multiSlsDetector::getRateCorrectionTau(){
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Rate correction is disabled " << std::endl;
|
||||
#endif
|
||||
ret1=0;
|
||||
ret=0;
|
||||
}
|
||||
return ret1;
|
||||
return ret;
|
||||
|
||||
};
|
||||
|
||||
|
@ -109,7 +109,7 @@ private:
|
||||
class SuperTask: public virtual slsDetectorDefs {
|
||||
public:
|
||||
SuperTask():
|
||||
m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0),m16(0){};
|
||||
m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0),m16(0),m17(0),m18(0){};
|
||||
~SuperTask(){};
|
||||
protected:
|
||||
/** Function signature defined
|
||||
@ -117,20 +117,22 @@ protected:
|
||||
*/
|
||||
func00_t <void >* m1;
|
||||
func0_t <int >* m2;
|
||||
func0_t <runStatus >* m3;
|
||||
func1_t <int, int>* m4;
|
||||
func1_t <string, string>* m5;
|
||||
func1_t <detectorSettings, int>* m6;
|
||||
func2_t <int, int,int>* m7;
|
||||
func2_t <int, string,int>* m8;
|
||||
func2_t <dacs_t, dacIndex,int>* m9;
|
||||
func2_t <detectorSettings, detectorSettings,int>* m10;
|
||||
func2_t <int64_t, timerIndex,int64_t>* m11;
|
||||
func2_t <string, networkParameter,string>* m12;
|
||||
func3_t <int, int,int,int>* m13;
|
||||
func4_t <int, trimMode,int,int,int>* m14;
|
||||
func4_t <int, int,int,detectorSettings,int>* m15;
|
||||
func4_t <dacs_t, dacs_t,dacIndex,int,int>* m16;
|
||||
func0_t <double >* m3;
|
||||
func0_t <runStatus >* m4;
|
||||
func1_t <int, int>* m5;
|
||||
func1_t <int, double>* m6;
|
||||
func1_t <string, string>* m7;
|
||||
func1_t <detectorSettings, int>* m8;
|
||||
func2_t <int, int,int>* m9;
|
||||
func2_t <int, string,int>* m10;
|
||||
func2_t <dacs_t, dacIndex,int>* m11;
|
||||
func2_t <detectorSettings, detectorSettings,int>* m12;
|
||||
func2_t <int64_t, timerIndex,int64_t>* m13;
|
||||
func2_t <string, networkParameter,string>* m14;
|
||||
func3_t <int, int,int,int>* m15;
|
||||
func4_t <int, trimMode,int,int,int>* m16;
|
||||
func4_t <int, int,int,detectorSettings,int>* m17;
|
||||
func4_t <dacs_t, dacs_t,dacIndex,int,int>* m18;
|
||||
};
|
||||
|
||||
class Task: public virtual SuperTask {
|
||||
@ -140,20 +142,22 @@ public:
|
||||
*/
|
||||
Task(func00_t <void >* t): SuperTask(),fnum(1){m1 = t;};
|
||||
Task(func0_t <int >* t): SuperTask(),fnum(2){m2 = t;};
|
||||
Task(func0_t <runStatus >* t): SuperTask(),fnum(3){m3 = t;};
|
||||
Task(func1_t <int, int>* t): SuperTask(),fnum(4){m4 = t;};
|
||||
Task(func1_t <string, string>* t): SuperTask(),fnum(5){m5 = t;};
|
||||
Task(func1_t <detectorSettings, int>* t): SuperTask(),fnum(6){m6 = t;};
|
||||
Task(func2_t <int, int,int>* t): SuperTask(),fnum(7){m7 = t;};
|
||||
Task(func2_t <int, string,int>* t): SuperTask(),fnum(8){m8 = t;};
|
||||
Task(func2_t <dacs_t, dacIndex,int>* t): SuperTask(),fnum(9){m9 = t;};
|
||||
Task(func2_t <detectorSettings, detectorSettings,int>* t): SuperTask(),fnum(10){m10 = t;};
|
||||
Task(func2_t <int64_t, timerIndex,int64_t>* t): SuperTask(),fnum(11){m11 = t;};
|
||||
Task(func2_t <string, networkParameter,string>* t): SuperTask(),fnum(12){m12 = t;};
|
||||
Task(func3_t <int, int,int,int>* t): SuperTask(),fnum(13){m13 = t;};
|
||||
Task(func4_t <int, trimMode,int,int,int>* t): SuperTask(),fnum(14){m14 = t;};
|
||||
Task(func4_t <int, int,int,detectorSettings,int>* t): SuperTask(),fnum(15){m15 = t;};
|
||||
Task(func4_t <dacs_t, dacs_t,dacIndex,int,int>* t): SuperTask(),fnum(16){m16 = t;};
|
||||
Task(func0_t <double >* t): SuperTask(),fnum(3){m3 = t;};
|
||||
Task(func0_t <runStatus >* t): SuperTask(),fnum(4){m4 = t;};
|
||||
Task(func1_t <int, int>* t): SuperTask(),fnum(5){m5 = t;};
|
||||
Task(func1_t <int, double>* t): SuperTask(),fnum(6){m6 = t;};
|
||||
Task(func1_t <string, string>* t): SuperTask(),fnum(7){m7 = t;};
|
||||
Task(func1_t <detectorSettings, int>* t): SuperTask(),fnum(8){m8 = t;};
|
||||
Task(func2_t <int, int,int>* t): SuperTask(),fnum(9){m9 = t;};
|
||||
Task(func2_t <int, string,int>* t): SuperTask(),fnum(10){m10 = t;};
|
||||
Task(func2_t <dacs_t, dacIndex,int>* t): SuperTask(),fnum(11){m11 = t;};
|
||||
Task(func2_t <detectorSettings, detectorSettings,int>* t): SuperTask(),fnum(12){m12 = t;};
|
||||
Task(func2_t <int64_t, timerIndex,int64_t>* t): SuperTask(),fnum(13){m13 = t;};
|
||||
Task(func2_t <string, networkParameter,string>* t): SuperTask(),fnum(14){m14 = t;};
|
||||
Task(func3_t <int, int,int,int>* t): SuperTask(),fnum(15){m15 = t;};
|
||||
Task(func4_t <int, trimMode,int,int,int>* t): SuperTask(),fnum(16){m16 = t;};
|
||||
Task(func4_t <int, int,int,detectorSettings,int>* t): SuperTask(),fnum(17){m17 = t;};
|
||||
Task(func4_t <dacs_t, dacs_t,dacIndex,int,int>* t): SuperTask(),fnum(18){m18 = t;};
|
||||
|
||||
~Task(){}
|
||||
|
||||
@ -175,6 +179,8 @@ public:
|
||||
case 14: (*m14)(); break;
|
||||
case 15: (*m15)(); break;
|
||||
case 16: (*m16)(); break;
|
||||
case 17: (*m17)(); break;
|
||||
case 18: (*m18)(); break;
|
||||
default:
|
||||
cprintf(RED, "Error: Task not defined. Abort!\n");
|
||||
break;
|
||||
|
Reference in New Issue
Block a user