mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
adding 16 bit rate correction in eiger
This commit is contained in:
@ -51,6 +51,7 @@ double Feb_Control_exposure_period_in_sec;
|
||||
|
||||
int64_t Feb_Control_RateTable_Tau_in_nsec = -1;
|
||||
int64_t Feb_Control_RateTable_Subexptime_in_nsec = -1;
|
||||
int64_t Feb_Control_RateTable_Exptime_in_nsec = -1;
|
||||
|
||||
unsigned int Feb_Control_trimbit_size;
|
||||
unsigned int* Feb_Control_last_downloaded_trimbits;
|
||||
@ -1371,6 +1372,7 @@ int Feb_Control_SetExposureTime(double the_exposure_time_in_sec){
|
||||
return 1;
|
||||
}
|
||||
double Feb_Control_GetExposureTime(){return Feb_Control_exposure_time_in_sec;}
|
||||
int64_t Feb_Control_GetExposureTime_in_nsec(){return (int64_t)(Feb_Control_exposure_time_in_sec*(1E9));}
|
||||
|
||||
int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10nsec){
|
||||
Feb_Control_subframe_exposure_time_in_10nsec = the_subframe_exposure_time_in_10nsec;
|
||||
@ -1790,25 +1792,39 @@ int Feb_Control_PulseChip(int npulses){
|
||||
|
||||
int64_t Feb_Control_Get_RateTable_Tau_in_nsec(){ return Feb_Control_RateTable_Tau_in_nsec;}
|
||||
int64_t Feb_Control_Get_RateTable_Subexptime_in_nsec(){ return Feb_Control_RateTable_Subexptime_in_nsec;}
|
||||
int64_t Feb_Control_Get_RateTable_Exptime_in_nsec(){ return Feb_Control_RateTable_Exptime_in_nsec;}
|
||||
|
||||
//returns -1 if slope is too high
|
||||
int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec){
|
||||
|
||||
double exptime_in_sec = Feb_Control_GetExposureTime();
|
||||
double sub_expure_time_in_sec = (double)(Feb_Control_GetSubFrameExposureTime())/(double)1e9;
|
||||
|
||||
|
||||
int dr = Feb_Control_GetDynamicRange();
|
||||
double period_in_sec = sub_expure_time_in_sec;
|
||||
if(dr == 16)
|
||||
period_in_sec = exptime_in_sec;
|
||||
|
||||
double tau_in_sec = (double)tau_in_Nsec/(double)1e9;
|
||||
unsigned int np = 16384; //max slope 16 * 1024
|
||||
double b0[1024];
|
||||
double m[1024];
|
||||
|
||||
if(tau_in_sec<0||sub_expure_time_in_sec<0){
|
||||
printf("Error tau %f and sub_expure_time %f must be greater than 0.\n", tau_in_sec, sub_expure_time_in_sec);
|
||||
|
||||
if(tau_in_sec<0||period_in_sec<0){
|
||||
if(dr == 32)
|
||||
printf("Error tau %f and sub_exposure_time %f must be greater than 0.\n", tau_in_sec, sub_expure_time_in_sec);
|
||||
else
|
||||
printf("Error tau %f and exposure_time %f must be greater than 0.\n", tau_in_sec, exptime_in_sec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("\tCalculating table for tau of %lld ns.\n", tau_in_Nsec);
|
||||
int i;
|
||||
for(i=0;i<np;i++)
|
||||
Feb_Control_rate_meas[i] = i*exp(-i/sub_expure_time_in_sec*tau_in_sec);
|
||||
|
||||
Feb_Control_rate_meas[i] = i*exp(-i/period_in_sec*tau_in_sec);
|
||||
|
||||
/*
|
||||
b : index/address of block ram/rate correction table
|
||||
@ -1886,11 +1902,18 @@ int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec){
|
||||
|
||||
if(Feb_Control_SetRateCorrectionTable(Feb_Control_rate_correction_table)){
|
||||
Feb_Control_RateTable_Tau_in_nsec = tau_in_Nsec;
|
||||
Feb_Control_RateTable_Subexptime_in_nsec = Feb_Control_GetSubFrameExposureTime();
|
||||
if(dr == 32){
|
||||
Feb_Control_RateTable_Subexptime_in_nsec = Feb_Control_GetSubFrameExposureTime();
|
||||
Feb_Control_RateTable_Exptime_in_nsec = -1;
|
||||
}else{
|
||||
Feb_Control_RateTable_Exptime_in_nsec = Feb_Control_GetExposureTime_in_nsec();
|
||||
Feb_Control_RateTable_Subexptime_in_nsec = -1;
|
||||
}
|
||||
return 1;
|
||||
}else{
|
||||
Feb_Control_RateTable_Tau_in_nsec = -1;
|
||||
Feb_Control_RateTable_Subexptime_in_nsec = -1;
|
||||
Feb_Control_RateTable_Exptime_in_nsec = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -159,6 +159,7 @@ int Feb_Control_GetModuleNumber();
|
||||
unsigned int Feb_Control_GetNExposures();
|
||||
int Feb_Control_SetExposureTime(double the_exposure_time_in_sec);
|
||||
double Feb_Control_GetExposureTime();
|
||||
int64_t Feb_Control_GetExposureTime_in_nsec();
|
||||
int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10nsec);
|
||||
int64_t Feb_Control_GetSubFrameExposureTime();
|
||||
int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec);
|
||||
@ -186,6 +187,7 @@ int Feb_Control_GetModuleNumber();
|
||||
|
||||
int64_t Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
int64_t Feb_Control_Get_RateTable_Subexptime_in_nsec();
|
||||
int64_t Feb_Control_Get_RateTable_Exptime_in_nsec();
|
||||
int Feb_Control_SetRateCorrectionTau(int64_t tau_in_Nsec);
|
||||
int Feb_Control_SetRateCorrectionTable(unsigned int *table);
|
||||
int Feb_Control_GetRateCorrectionVariable();
|
||||
|
@ -533,12 +533,29 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec){//in nanosec (will never b
|
||||
return 0;
|
||||
}
|
||||
|
||||
//when dynamic range changes, use old tau
|
||||
else if(custom_tau_in_nsec == -1)
|
||||
custom_tau_in_nsec = Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
|
||||
int64_t tau_in_nsec = Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
int64_t subexp_in_nsec = Feb_Control_Get_RateTable_Subexptime_in_nsec();
|
||||
int dr = Feb_Control_GetDynamicRange();
|
||||
//default for 32 bit
|
||||
int64_t ratetable_period_in_nsec = Feb_Control_Get_RateTable_Subexptime_in_nsec();
|
||||
int64_t actual_period = Feb_Control_GetSubFrameExposureTime(); //already in nsec
|
||||
//16 bit mode
|
||||
if(dr == 16){
|
||||
ratetable_period_in_nsec = Feb_Control_Get_RateTable_Exptime_in_nsec();
|
||||
actual_period = Feb_Control_GetExposureTime_in_nsec();
|
||||
}
|
||||
|
||||
//same setting
|
||||
if((tau_in_nsec == custom_tau_in_nsec) && (subexp_in_nsec == Feb_Control_GetSubFrameExposureTime())){
|
||||
if((tau_in_nsec == custom_tau_in_nsec) && (ratetable_period_in_nsec == actual_period)){
|
||||
if(dr == 32)
|
||||
printf("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n",
|
||||
tau_in_nsec,subexp_in_nsec);
|
||||
tau_in_nsec,ratetable_period_in_nsec);
|
||||
else
|
||||
printf("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n",
|
||||
tau_in_nsec,ratetable_period_in_nsec);
|
||||
}
|
||||
//different setting, calculate table
|
||||
else{
|
||||
|
Reference in New Issue
Block a user