function to write pedestal rms and some fixes

This commit is contained in:
2020-06-03 10:43:16 +02:00
parent 8096d4078c
commit ab3877d9dd
5 changed files with 88 additions and 15 deletions

View File

@ -479,6 +479,37 @@ public:
return ped;
};
virtual double *getPedestalRMS(){
int nx, ny;
dets[0]->getDetectorSize(nx,ny);
double *rms=new double[nx*ny];
double *p0=new double[nx*ny];
for (int i=0; i<nThreads; i++) {
//inte=(slsInterpolation*)dets[i]->getInterpolation(nb,emi,ema);
// cout << i << endl;
p0=dets[i]->getPedestalRMS(p0);
if (p0) {
if (i==0) {
for (int ib=0; ib<nx*ny; ib++) {
rms[ib]=p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
} else {
for (int ib=0; ib<nx*ny; ib++) {
rms[ib]+=p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
}
}
}
delete [] p0;
return rms;
};
virtual double *setPedestal(double *h=NULL){
//int nb=0;
@ -515,6 +546,26 @@ public:
};
virtual void *writePedestalRMS(const char * imgname){
int nx, ny;
dets[0]->getDetectorSize(nx,ny);
double *rms=getPedestalRMS();
float *gm=new float[nx*ny];
if (gm) {
for (int ix=0; ix<nx*ny; ix++) {
gm[ix]=rms[ix];
}
WriteToTiff(gm,imgname ,nx, ny);
delete [] gm;
delete [] rms;
} else cout << "Could not allocate float image " << endl;
return NULL;
};
virtual void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){