3 #include "controller.h"
5 #include <odindata/fitting.h>
7 template<recoDim
interpolDim,
int interpolIndex,
int firstOrthoIndex,
int secondOrthoIndex>
11 Range all=Range::all();
14 TinyVector<int,3> shape=data.shape();
15 int nipol=shape(interpolIndex);
19 if(interpolDim==readout) {
21 ODINLOG(odinlog,errorLog) <<
"Not implemented: Interpolation at end of readout" << STD_endl;
31 float center=0.5*float(nipol-1);
32 int endindex=nipol-1-startindex;
33 ODINLOG(odinlog,normalDebug) <<
"startindex/endindex/center=" << startindex <<
"/" << endindex <<
"/" << center << STD_endl;
35 if(
float(startindex)<center) {
36 ODINLOG(odinlog,normalDebug) <<
"Homodyne reco"<< STD_endl;
43 Range symrange(startindex,endindex);
44 if(interpolIndex==0) symmetric(symrange,all,all)=data(symrange,all,all);
45 if(interpolIndex==1) symmetric(all,symrange,all)=data(all,symrange,all);
46 if(interpolIndex==2) symmetric(all,all,symrange)=data(all,all,symrange);
50 fvector transition(endindex-startindex+1);
51 transition.fill_linear(0.0,1.0);
53 weight=STD_complex(1.0);
54 TinyVector<int,3> index;
55 for(
int i=0; i<startindex; i++) weight(i)=STD_complex(0.0);
56 for(
int i=0; i<int(transition.size()); i++) weight(startindex+i)=transition[i];
57 for(
int iortho1=0; iortho1<shape(firstOrthoIndex); iortho1++) {
58 index(firstOrthoIndex)=iortho1;
59 for(
int iortho2=0; iortho2<shape(secondOrthoIndex); iortho2++) {
60 index(secondOrthoIndex)=iortho2;
61 for(
int ipol=0; ipol<shape(interpolIndex); ipol++) {
62 index(interpolIndex)=ipol;
63 data(index)*=weight(ipol);
77 data*=expc(float2imag(-
phase(symmetric)));
81 realpart=float2real(creal(data));
82 data.reference(realpart);
86 }
else if(fabs(
float(startindex)-center)<=1.0) {
87 ODINLOG(odinlog,significantDebug) <<
"Conjugate-mirror reco with startindex=" << startindex << STD_endl;
89 if(interpolDim!=line) {
90 ODINLOG(odinlog,errorLog) <<
"Not implemented: Conjugate-mirror reco in dimension " << recoDimLabel[interpolDim] << STD_endl;
100 data.
partial_fft(TinyVector<bool,3>(
false,
false,
true));
107 for(
int iread=0; iread<nread; iread++) centerr(iread)=
secureInv(pow(centmagn(iread),2));
110 linf.
fit(centphase,centerr);
112 for(
int iread=0; iread<nread; iread++) {
113 data(all,all,iread)*=expc(STD_complex(0.0, -(iread*linf.m.
val+linf.c.
val)));
116 data.
partial_fft(TinyVector<bool,3>(
false,
false,
true),
false);
120 int nmeas=nipol-startindex;
121 for(
int iphase3d=0; iphase3d<shape(0); iphase3d++) {
122 for(
int iline=1; iline<nmeas; iline++) {
125 int isrc=startindex+iline;
126 int idst=startindex-iline;
128 oneline=conjc(data(iphase3d,isrc,all).reverse(0));
129 if(!(nread%2)) oneline.shift(0,1);
130 data(iphase3d,idst,all)=oneline;
135 if(!(nread%2)) data(all,0,all)=STD_complex(0.0);
149 ODINLOG(odinlog,errorLog) <<
"startindex=" << startindex <<
" larger than center=" << center << STD_endl;
153 return execute_next_step(rd,controller);
159 template<recoDim
interpolDim,
int interpolIndex,
int firstOrthoIndex,
int secondOrthoIndex>
162 if(context.mode==RecoQueryContext::prep) {
163 if(interpolDim!=readout) {