Zmq communication uses additional headers, moench processing fixed

This commit is contained in:
2018-09-11 17:05:11 +02:00
parent 83600fcb15
commit f288390255
26 changed files with 1826 additions and 868 deletions

View File

@ -55,13 +55,11 @@ class interpolatingDetector : public singlePhotonDetector {
interpolatingDetector(interpolatingDetector *orig) : singlePhotonDetector(orig) {
interp=(orig->interp)->Clone();
if (orig->interp)
interp=(orig->interp)->Clone();
else
interp=orig->interp;
id=orig->id;
/* xmin=orig->xmin; */
/* xmax=orig->xmax; */
/* ymin=orig->ymin; */
/* ymax=orig->ymax; */
}
@ -72,26 +70,34 @@ class interpolatingDetector : public singlePhotonDetector {
virtual int setId(int i) {id=i; interp->setId(id); return id;};
virtual void prepareInterpolation(int &ok) {
cout << "*"<< endl;
#ifdef SAVE_ALL
char tit[1000];
sprintf(tit,"/scratch/ped_%d.tiff",id);
writePedestals(tit);
sprintf(tit,"/scratch/ped_rms_%d.tiff",id);
writePedestalRMS(tit);
if (gmap) {
sprintf(tit,"/scratch/gmap_%d.tiff",id);
writeGainMap(tit);
}
#endif
/* cout << "*"<< endl; */
/* #ifdef SAVE_ALL */
/* char tit[1000]; */
/* sprintf(tit,"/scratch/ped_%d.tiff",id); */
/* writePedestals(tit); */
/* sprintf(tit,"/scratch/ped_rms_%d.tiff",id); */
/* writePedestalRMS(tit); */
/* if (gmap) { */
/* sprintf(tit,"/scratch/gmap_%d.tiff",id); */
/* writeGainMap(tit); */
/* } */
/* #endif */
if (interp)
interp->prepareInterpolation(ok);
}
void clearImage() {if (interp) interp->clearInterpolatedImage(); else singlePhotonDetector::clearImage();};
void clearImage() {
if (interp) interp->clearInterpolatedImage();
else singlePhotonDetector::clearImage();
};
int getImageSize(int &nnx, int &nny, int &ns) {
if (interp) return interp->getImageSize(nnx, nny, ns);
else return analogDetector<uint16_t>::getImageSize(nnx, nny, ns);
};
int getImageSize(int &nnx, int &nny, int &ns) {if (interp) return interp->getImageSize(nnx, nny, ns); else return analogDetector<uint16_t>::getImageSize(nnx, nny, ns);};
#ifdef MYROOT1
virtual TH2F *getImage()
#endif
@ -146,478 +152,149 @@ class interpolatingDetector : public singlePhotonDetector {
return NULL;
}
int addFrame(char *data, int *ph=NULL, int ff=0) {
/* int addFrame(char *data, int *ph=NULL, int ff=0) { */
int nph=0;
double val[ny][nx];
int cy=(clusterSizeY+1)/2;
int cs=(clusterSize+1)/2;
int ir, ic;
double rms;
double int_x,int_y, eta_x, eta_y;
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
// cout << "********** Add frame "<< iframe << endl;
if (ph==NULL)
ph=image;
/* int nph=0; */
/* double val[ny][nx]; */
/* int cy=(clusterSizeY+1)/2; */
/* int cs=(clusterSize+1)/2; */
/* int ir, ic; */
/* double rms; */
/* double int_x,int_y, eta_x, eta_y; */
/* double max=0, tl=0, tr=0, bl=0,br=0, *v, vv; */
/* // cout << "********** Add frame "<< iframe << endl; */
/* if (ph==NULL) */
/* ph=image; */
if (iframe<nDark) {
addToPedestal(data);
return 0;
}
newFrame();
// cout << "********** Data "<< endl;
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
/* if (iframe<nDark) { */
/* addToPedestal(data); */
/* return 0; */
/* } */
/* newFrame(); */
/* // cout << "********** Data "<< endl; */
/* for (int ix=xmin; ix<xmax; ix++) { */
/* for (int iy=ymin; iy<ymax; iy++) { */
max=0;
tl=0;
tr=0;
bl=0;
br=0;
tot=0;
quadTot=0;
quad=UNDEFINED_QUADRANT;
/* max=0; */
/* tl=0; */
/* tr=0; */
/* bl=0; */
/* br=0; */
/* tot=0; */
/* quadTot=0; */
/* quad=UNDEFINED_QUADRANT; */
eventMask[iy][ix]=PEDESTAL;
/* eventMask[iy][ix]=PEDESTAL; */
rms=getPedestalRMS(ix,iy);
(clusters+nph)->rms=rms;
/* rms=getPedestalRMS(ix,iy); */
/* (clusters+nph)->rms=rms; */
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
/* for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { */
/* for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { */
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) {
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir);
}
/* if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) { */
/* val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir); */
/* } */
v=&(val[iy+ir][ix+ic]);
tot+=*v;
if (ir<=0 && ic<=0)
bl+=*v;
if (ir<=0 && ic>=0)
br+=*v;
if (ir>=0 && ic<=0)
tl+=*v;
if (ir>=0 && ic>=0)
tr+=*v;
if (*v>max) {
max=*v;
}
/* v=&(val[iy+ir][ix+ic]); */
/* tot+=*v; */
/* if (ir<=0 && ic<=0) */
/* bl+=*v; */
/* if (ir<=0 && ic>=0) */
/* br+=*v; */
/* if (ir>=0 && ic<=0) */
/* tl+=*v; */
/* if (ir>=0 && ic>=0) */
/* tr+=*v; */
/* if (*v>max) { */
/* max=*v; */
/* } */
if (ir==0 && ic==0) {
if (*v<-nSigma*rms)
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
}
/* if (ir==0 && ic==0) { */
/* if (*v<-nSigma*rms) */
/* eventMask[iy][ix]=NEGATIVE_PEDESTAL; */
/* } */
}
/* } */
/* } */
/* if (bl>=br && bl>=tl && bl>=tr) { */
/* (clusters+nph)->quad=BOTTOM_LEFT; */
/* (clusters+nph)->quadTot=bl; */
/* } else if (br>=bl && br>=tl && br>=tr) { */
/* (clusters+nph)->quad=BOTTOM_RIGHT; */
/* (clusters+nph)->quadTot=br; */
/* } else if (tl>=br && tl>=bl && tl>=tr) { */
/* (clusters+nph)->quad=TOP_LEFT; */
/* (clusters+nph)->quadTot=tl; */
/* } else if (tr>=bl && tr>=tl && tr>=br) { */
/* (clusters+nph)->quad=TOP_RIGHT; */
/* (clusters+nph)->quadTot=tr; */
/* } */
/* if (max>nSigma*rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*rms) { */
/* if (val[iy][ix]>=max) { */
/* eventMask[iy][ix]=PHOTON_MAX; */
/* (clusters+nph)->tot=tot; */
/* (clusters+nph)->x=ix; */
/* (clusters+nph)->y=iy; */
/* (clusters+nph)->iframe=det->getFrameNumber(data); */
/* (clusters+nph)->ped=getPedestal(ix,iy,0); */
/* for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { */
/* for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { */
/* (clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir); */
/* } */
/* } */
/* nph++; */
/* image[iy*nx+ix]++; */
/* } else { */
/* eventMask[iy][ix]=PHOTON; */
/* } */
/* } else if (eventMask[iy][ix]==PEDESTAL) { */
/* addToPedestal(data,ix,iy); */
/* } */
/* } */
/* } */
/* nphFrame=nph; */
/* nphTot+=nph; */
/* writeClusters(); */
/* return nphFrame; */
/* }; */
int addFrame(char *data, int *ph=NULL, int ff=0) {
singlePhotonDetector::processData(data,ph);
int nph=0;
double int_x, int_y;
double eta_x, eta_y;
if (interp) {
for (nph=0; nph<nphFrame; nph++) {
if (ff) {
interp->addToFlatField((clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),eta_x, eta_y);
} else {
interp->getInterpolatedPosition((clusters+nph)->x, (clusters+nph)->y, (clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),int_x, int_y);
interp->addToImage(int_x, int_y);
}
if (bl>=br && bl>=tl && bl>=tr) {
(clusters+nph)->quad=BOTTOM_LEFT;
(clusters+nph)->quadTot=bl;
} else if (br>=bl && br>=tl && br>=tr) {
(clusters+nph)->quad=BOTTOM_RIGHT;
(clusters+nph)->quadTot=br;
} else if (tl>=br && tl>=bl && tl>=tr) {
(clusters+nph)->quad=TOP_LEFT;
(clusters+nph)->quadTot=tl;
} else if (tr>=bl && tr>=tl && tr>=br) {
(clusters+nph)->quad=TOP_RIGHT;
(clusters+nph)->quadTot=tr;
}
if (max>nSigma*rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*rms) {
if (val[iy][ix]>=max) {
eventMask[iy][ix]=PHOTON_MAX;
(clusters+nph)->tot=tot;
(clusters+nph)->x=ix;
(clusters+nph)->y=iy;
(clusters+nph)->iframe=det->getFrameNumber(data);
(clusters+nph)->ped=getPedestal(ix,iy,0);
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
}
}
if (interp) {
if (ff) {
interp->addToFlatField((clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),eta_x, eta_y);
} else {
interp->getInterpolatedPosition(ix, iy, (clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),int_x, int_y);
interp->addToImage(int_x, int_y);
}
} else
image[ix+nx*iy]++;
nph++;
image[iy*nx+ix]++;
} else {
eventMask[iy][ix]=PHOTON;
}
} else if (eventMask[iy][ix]==PEDESTAL) {
addToPedestal(data,ix,iy);
}
}
}
}
nphFrame=nph;
nphTot+=nph;
//cout << nphFrame << endl;
// cout <<"**********************************"<< endl;
writeClusters();
return nphFrame;
};
/*********************************************************
int addFrame(char *data, int ff=0) {
double g=1;
single_photon_hit *cl;
single_photon_hit clust;
if (clusters)
cl=clusters;
else
cl=&clust;
int ccs=clusterSize;
int ccy=clusterSizeY;
double int_x,int_y, eta_x, eta_y;
int nph=0;
double rest[ny][nx];
int cy=(clusterSizeY+1)/2;
int cs=(clusterSize+1)/2;
int ir, ic;
double cc[2][2];
double max=0, tl=0, tr=0, bl=0,br=0, v, vv;
int xoff,yoff;
int skip=0;
// cout <<"fr"<< endl;
double tthr;
if (iframe<nDark) {
//cout << iframe << "+"<< nDark <<endl;
addToPedestal(data);
return 0;
}
newFrame();
// cout << xmin << " " << xmax << " " << ymin << " " << ymax << endl;
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
// for (int ix=clusterSize/2; ix<clusterSize/2-1; ix++) {
// for (int iy=clusterSizeY/2; iy<ny-clusterSizeY/2; iy++) {
// cout << ix << " " << iy << endl;
eventMask[iy][ix]=PEDESTAL;
tthr=nSigma*getPedestalRMS(ix,iy)/g;
if (ix==xmin || iy==ymin)
rest[iy][ix]=subtractPedestal(data,ix,iy);
max=0;
tl=0;
tr=0;
bl=0;
br=0;
tot=0;
quadTot=0;
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
if ((iy+ir)>=ymin && (iy+ir)<ymax && (ix+ic)>=xmin && (ix+ic)<xmax) {
//cluster->set_data(rest[iy+ir][ix+ic], ic, ir);
if (ir>=0 && ic>=0 )
rest[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir);
v=rest[iy+ir][ix+ic];//cluster->get_data(ic,ir);
tot+=v;
if (ir<=0 && ic<=0)
bl+=v;
if (ir<=0 && ic>=0)
br+=v;
if (ir>=0 && ic<=0)
tl+=v;
if (ir>=0 && ic>=0)
tr+=v;
if (v>max) {
max=v;
}
// if (ir==0 && ic==0) {
if (v>tthr) {
eventMask[iy][ix]=NEIGHBOUR;
}
//}
}
}
}
if (rest[iy][ix]<=-tthr) {
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
//if (cluster->get_data(0,0)>=max) {
} else if (max>tthr || tot>sqrt(ccy*ccs)*tthr || quadTot>sqrt(cy*cs)*tthr) {
if (rest[iy][ix]>=max) {
if (bl>=br && bl>=tl && bl>=tr) {
cl->quad=BOTTOM_LEFT;
cl->quadTot=bl;
} else if (br>=bl && br>=tl && br>=tr) {
cl->quad=BOTTOM_RIGHT;
cl->quadTot=br;
} else if (tl>=br && tl>=bl && tl>=tr) {
cl->quad=TOP_LEFT;
cl->quadTot=tl;
} else if (tr>=bl && tr>=tl && tr>=br) {
cl->quad=TOP_RIGHT;
cl->quadTot=tr;
}
eventMask[iy][ix]=PHOTON_MAX;
cl->tot=tot;
cl->x=ix;
cl->y=iy;
cl->ped=getPedestal(ix,iy, 0);
cl->rms=getPedestalRMS(ix,iy);
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
if ((iy+ir)>=ymin && (iy+ir)<ymax && (ix+ic)>=xmin && (ix+ic)<xmax) {
cl->set_data(rest[iy+ir][ix+ic],ic,ir);
}
}
}
if (interp) {
if (ff) {
#ifdef M015
if (iy>100)
#endif
interp->addToFlatField(cl->quadTot,cl->quad,cl->get_cluster(),eta_x, eta_y);
// if ((eta_x<0.1 || eta_x>0.9)&&(eta_y<0.1 || eta_y>0.9))
// cout << ix << " " << iy << " " << eta_x <<" " << eta_y << endl;
} else {
interp->getInterpolatedPosition(ix, iy, cl->quadTot,cl->quad,cl->get_cluster(),int_x, int_y);
interp->addToImage(int_x, int_y);
}
} else
image[ix+nx*iy]++;
nph++;
if (clusters) cl=(clusters+nph);
// rest[iy][ix]-=tthr;
} else
eventMask[iy][ix]=PHOTON;
//else if (thr<=0 ) {
//addToPedestal(data,ix,iy);
// }
}
if (eventMask[iy][ix]==PEDESTAL) {
addToPedestal(data,ix,iy);
}
}
}
return nph;
}
******************************************/
/* for (int ix=0; ix<nx; ix++) { */
/* for (int iy=0; iy<ny; iy++) { */
/* skip=0; */
/* max=0; */
/* tl=0; */
/* tr=0; */
/* bl=0; */
/* br=0; */
/* tot=0; */
/* quadTot=0; */
/* quad=UNDEFINED_QUADRANT; */
/* cl->rms=getPedestalRMS(ix,iy); */
/* //(clusters+nph)->rms=getPedestalRMS(ix,iy); */
/* // cout << iframe << " " << nph << " " << ix << " " << iy << endl; */
/* if (ix==0 || iy==0) */
/* val[iy][ix]=subtractPedestal(data,ix,iy); */
/* if (val[iy][ix]<-nSigma*cl->rms) { */
/* eventMask[iy][ix]=NEGATIVE_PEDESTAL; */
/* // cout << "neg ped" << endl; */
/* } else { */
/* for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { */
/* for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { */
/* if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx) { */
/* if (ir>=0 && ic>=0) { */
/* val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir); */
/* eventMask[iy+ir][ix+ic]=PEDESTAL; */
/* } */
/* // cout << ir << " " << ic << " " << val[iy+ir][ix+ic] << endl; */
/* v=&(val[iy+ir][ix+ic]); */
/* // if (skip==0) { */
/* tot+=*v; */
/* if (ir<=0 && ic<=0) */
/* bl+=*v; */
/* if (ir<=0 && ic>=0) */
/* br+=*v; */
/* if (ir>=0 && ic<=0) */
/* tl+=*v; */
/* if (ir>=0 && ic>=0) */
/* tr+=*v; */
/* if (*v>max) { */
/* max=*v; */
/* } */
/* } */
/* } */
/* } */
/* if (bl>=br && bl>=tl && bl>=tr) { */
/* cl->quad=BOTTOM_LEFT; */
/* cl->quadTot=bl; */
/* } else if (br>=bl && br>=tl && br>=tr) { */
/* cl->quad=BOTTOM_RIGHT; */
/* cl->quadTot=br; */
/* } else if (tl>=br && tl>=bl && tl>=tr) { */
/* cl->quad=TOP_LEFT; */
/* cl->quadTot=tl; */
/* } else if (tr>=bl && tr>=tl && tr>=br) { */
/* cl->quad=TOP_RIGHT; */
/* cl->quadTot=tr; */
/* } */
/* if (max>nSigma*cl->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*cl->rms || (cl->quadTot)>sqrt(cy*cs)*nSigma*cl->rms) { */
/* if (val[iy][ix]>=max) { */
/* eventMask[iy][ix]=PHOTON_MAX; */
/* cl->tot=tot; */
/* cl->x=ix; */
/* cl->y=iy; */
/* cl->ped=getPedestal(ix,iy, 0); */
/* if (interp) { */
/* if (ff) { */
/* interp->addToFlatField(cl->quadTot,cl->quad,cl->get_cluster(),eta_x, eta_y); */
/* // if ((eta_x<0.1 || eta_x>0.9)&&(eta_y<0.1 || eta_y>0.9)) */
/* // cout << ix << " " << iy << " " << eta_x <<" " << eta_y << endl; */
/* } else { */
/* interp->getInterpolatedPosition(ix, iy, cl->quadTot,cl->quad,cl->get_cluster(),int_x, int_y); */
/* interp->addToImage(int_x, int_y); */
/* } */
/* } else */
/* image[ix+nx*iy]++; */
/* if (clusters) cl=(clusters+nph); */
/* nph++; */
/* } else { */
/* eventMask[iy][ix]=PHOTON; */
/* } */
/* } else if (eventMask[iy][ix]==PEDESTAL) { */
/* addToPedestal(data,ix,iy); */
/* } */
/* } */
/* } */
/* } */
/* return nph; */
/* }; */
virtual void processData(char *data, int *val=NULL) {
if (interp){
@ -633,11 +310,12 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
}
} else
singlePhotonDetector::processData(data,val);
};
virtual char *getInterpolation(){return (char*)interp;};
virtual char *setInterpolation(char *ii){int ok; interp=(slsInterpolation*)ii; interp->prepareInterpolation(ok); return (char*)interp;};
protected: