Changeset 3192 in Sophya for trunk/Cosmo/RadioBeam/multicyl.cc
- Timestamp:
- Mar 20, 2007, 11:48:15 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/RadioBeam/multicyl.cc
r3191 r3192 6 6 #include "ctimer.h" 7 7 #include "resusage.h" 8 #include "datacards.h" 9 10 static double cLight=0.3; // in 1E9 m/s 11 static double tClock = 2.; // should come from param file !!!! 12 //static double cLight=1; 13 //static double tClock = 1.; 8 14 9 15 … … 12 18 MultiCylinders::MultiCylinders(int nr, int ns) 13 19 { 14 NR = nr;15 NS = ns;20 NR_ = nr; 21 NS_ = ns; 16 22 17 23 SetPrintLevel(0); … … 22 28 SetTimeOffsetSigma(0.); 23 29 SetGains(1., 0., 0); 24 adfg = false; src= NULL;30 adfg_ = false; src_ = NULL; 25 31 SetSources(new BRSourceGen, true); 26 32 } 27 33 34 //----------------------------------------------------------------------------- 35 MultiCylinders::MultiCylinders(char* fileName) 36 { 37 adfg_ = false; src_ = NULL; 38 SetSources(new BRSourceGen, true); 39 40 // read telescope parameters and fill variable members 41 DataCards dc; 42 dc.ReadFile(fileName); 43 // in old versions frequences were in units of 1/T = 0.5 GHz 44 // and distances in units of cT =3E8 * 2E-9=0.60 m 45 // double fUnit=0.5; // 0.5 GHz <=> T = 2 ns 46 // double dUnit=0.6; // distance unit in m. 47 // now f and d in real units 48 double fUnit=1.; // 0.5 GHz <=> T = 2 ns 49 double dUnit=1.; // distance unit in m. 50 51 NR_=dc.IParam("nAntenna"); 52 NS_=dc.IParam("nSample"); 53 PrtLev_=dc.IParam("printLevel"); 54 Da_=dc.DParam("dAntenna")/dUnit; 55 freq0_=dc.DParam("freq0")/fUnit; 56 timejitter_=dc.DParam("sigmaTimeJitt"); 57 toffsig_=dc.DParam("sigmaClockJitt"); 58 signoise_=dc.DParam("noiseSigma"); 59 gain_=dc.DParam("meanGain"); 60 siggain_=dc.DParam("sigmaGain"); 61 ngainzero_=dc.IParam("nDeadAntenna"); 62 63 // tClock=dc.DParam("tClock"); 64 int nCyl=dc.IParam("nCyl"); 65 for (int i=0; i<nCyl; i++){ 66 double xCyl=dc.DParam("xCyl",i)/dUnit; 67 double yCyl=dc.DParam("yCyl",i)/dUnit; 68 AddCylinder(xCyl,yCyl); 69 } 70 // maxangX=dc.DParam("angMaxX"); 71 // double cylDiam=dc.DParam("cylinderDiam")/dUnit; 72 //// thetaMax = lambda_M/d = c/freq_min/d; freq_min = freq0 + 1/2T 73 // maxangY=cLight/(freq0+1./2./tClock)/cylDiam; 74 // halfNY=dc.IParam("halfNY"); 75 // NX=dc.IParam("NX"); 76 } 77 78 //----------------------------------------------------------------------------- 28 79 MultiCylinders::~MultiCylinders() 29 80 { 30 if (adfg && src) delete src; 31 for(int k=0; k<mCyl.size(); k++) delete mCyl[k]; 32 } 33 81 if (adfg_ && src_) delete src_; 82 for(int k=0; k<(int)mCyl_.size(); k++) delete mCyl_[k]; 83 } 84 85 //----------------------------------------------------------------------------- 34 86 MultiBeamCyl& MultiCylinders::GetCylinder(int k) 35 87 { 36 if ((k < 0) || (k >= mCyl.size())) 88 if ((k < 0) || (k >= (int)mCyl_.size())) { 89 cout <<"******************************************* k="<<k<<endl; 37 90 throw RangeCheckError("MultiCylinders::GetCylinder(k) k<0 OR k>=NCyl"); 38 return (*mCyl[k]); 39 } 40 91 } 92 return (*mCyl_[k]); 93 } 94 95 //----------------------------------------------------------------------------- 41 96 void MultiCylinders::SetSources(BRSourceGen* brs, bool ad) 42 97 { 43 98 if (brs == NULL) return; 44 if (adfg && src) delete src; 45 src = brs; adfg=ad; 46 } 47 48 99 if (adfg_ && src_) delete src_; 100 src_ = brs; adfg_=ad; 101 } 102 103 104 //----------------------------------------------------------------------------- 49 105 void MultiCylinders::ConfigureCylinders() 50 106 { 51 cout << " MultiCylinders::ConfigureCylinders() with NCyl= " << mCyl.size() << endl; 52 for(int k=0; k<mCyl.size(); k++) { 53 mCyl[k]->SetPrintLevel(PrtLev); 54 mCyl[k]->SetBaseFreqDa(freq0, Da); 55 mCyl[k]->SetNoiseSigma(signoise); 56 mCyl[k]->SetTimeJitter(timejitter); 57 mCyl[k]->SetTimeOffsetSigma(toffsig); 58 mCyl[k]->SetGains(gain, siggain, ngainzero); 59 mCyl[k]->SetSources(src, false); 60 } 61 } 62 63 107 cout << " MultiCylinders::ConfigureCylinders() with NCyl= " << mCyl_.size() << endl; 108 for(int k=0; k<(int)mCyl_.size(); k++) { 109 mCyl_[k]->SetPrintLevel(PrtLev_); 110 mCyl_[k]->SetBaseFreqDa(freq0_, Da_); 111 mCyl_[k]->SetNoiseSigma(signoise_); 112 mCyl_[k]->SetTimeJitter(timejitter_); 113 mCyl_[k]->SetTimeOffsetSigma(toffsig_); 114 mCyl_[k]->SetGains(gain_, siggain_, ngainzero_); 115 mCyl_[k]->SetSources(src_, false); 116 } 117 } 118 119 120 //----------------------------------------------------------------------------- 64 121 void MultiCylinders::ReconstructCylinderPlaneS(bool fgzerocentre) 65 122 { 66 123 Timer tm("RecCylPlaneS"); 67 124 ResourceUsage resu; 68 cout << " MultiCylinders::ReconstructCylinderPlaneS()/Info - NCyl= " << mCyl .size()125 cout << " MultiCylinders::ReconstructCylinderPlaneS()/Info - NCyl= " << mCyl_.size() 69 126 << " MemSize=" << resu.getMemorySize() << " kb" << endl; 70 127 ConfigureCylinders(); 71 128 72 129 char buff[128]; 73 for(int k=0; k< mCyl.size(); k++) {130 for(int k=0; k<(int)mCyl_.size(); k++) { 74 131 cout << "---- Cyl[" << k << "] Calling MultiBeamCyl.ReconstructSourcePlane() ..." << endl; 75 mCyl [k]->ReconstructSourcePlane(fgzerocentre);132 mCyl_[k]->ReconstructSourcePlane(fgzerocentre); 76 133 sprintf(buff,"Cyl[%d].RecSrcPlane()",k); 77 134 tm.Split(buff); … … 82 139 } 83 140 84 void MultiCylinders::ReconstructSourceBox(int halfny, double stepangy) 85 { 141 //----------------------------------------------------------------------------- 142 void MultiCylinders::ReconstructSourceBox(int halfny, double stepangy, 143 int nx, double stepangx) 144 { 145 nx=256; 86 146 ReconstructCylinderPlaneS(true); 87 147 TMatrix< complex<r_4> > & mtx = GetCylinder(0).getRecSrcPlane(); 88 // boite 3D X:angX, Y:angY , Z: freq 148 // boite 3D X:angX, Y:angY , Z: freq 149 // if all cylinders at same x position NX is set to zero 150 // => x-size = mtx.NCols() = numbers of receptors per cylinders 151 // move that to readParam() ? 89 152 sa_size_t sz[5] = {0,0,0,0,0}; 90 // int nx=mtx.NCols(); // uncomment to go back to nxbin = nantenna91 int nx=256;92 153 sz[0] = nx; 93 154 sz[1] = halfny*2+1; 94 155 sz[2] = mtx.NRows(); 95 156 TArray< complex<r_4> > & box = getRecSrcBox(); 96 box.ReSize(3, sz); 97 // box = complex< r_4 >( 0.f, 0.f ); 157 box.ReSize(3, sz); // values initialized to zero ? 98 158 cout << " MultiCylinders::ReconstructSourceBox(" << halfny << "," << stepangy 99 159 << "=" << Angle(stepangy).ToArcMin() << " ) srcbox:" << endl; … … 102 162 103 163 104 int pmod = mtx.NRows()/10; 105 106 double fstep = 1.0/(double)NS; // pas en frequence, attention, on a vire la composante continu 164 // int pmod = mtx.NRows()/10; 165 166 double fstep = 1.0/(double)NS_/tClock; // pas en frequence, 167 // attention, on a vire la composante continu 168 // bool first=true; 107 169 for(int kf=0; kf<mtx.NRows(); kf++) { // Loop over frequencies 108 double frq = (double)(kf+1.)*fstep + freq0; // + 1 car f=0 a ete vire 109 110 for(int lc=0; lc<mCyl.size(); lc++) { // Loop over cylinders 170 double frq = (double)(kf+1.)*fstep + freq0_; // + 1 car f=0 a ete vire 171 // then up to frq = (mtx.NRows() +1 ) * fstep !!? 172 // cout<<"************"<<mCyl.size() 173 for(int lc=0; lc<(int)mCyl_.size(); lc++) { // Loop over cylinders 111 174 MultiBeamCyl& cyl = GetCylinder(lc); 112 175 113 176 TMatrix< complex<r_4> > & recp = cyl.getRecSrcPlane(); 114 177 115 double facl = - 2*M_PI*frq*cyl.getCylinderYPos(); // attention au signe - 116 // double facl_x = - 2*M_PI*cyl.getCylinderXPos()/cyl.Da/(double)cyl.NR; 117 double facl_x = - 2*M_PI*cyl.getCylinderXPos()/cyl.Da; 118 double dphi; 178 double facl_y = - 2*M_PI*frq*cyl.getCylinderYPos()/cLight; // attention signe - 179 double facl_x = - 2*M_PI*cyl.getCylinderXPos()/cyl.Da_; 119 180 complex< r_4 > phasefactor; 120 181 int jyy = 0; 182 121 183 for(int jy=-halfny; jy<=halfny; jy++) { // Loop over Y angular steps 122 123 double dphi = facl* sin( (double)jy*stepangy )124 125 126 127 int ixx=(int)(ix*(double)cyl.NR/double(nx));128 129 130 184 for(int ix=0; ix<nx; ix++) { // Loop over AngX directions 185 double dphi = facl_y * sin( (double)jy*stepangy ) 186 + facl_x*(double(ix)/double(nx)-1./2.); 187 phasefactor = complex< r_4 > ((r_4) cos(dphi) , (r_4) sin(dphi)); 188 // sur recp : index ligne -> frequence , index colonne -> angX , 189 int ixx=(int)(ix*(double)cyl.NR_/double(nx)); 190 box(ix, jyy, kf) += recp(kf, ixx)*phasefactor; 191 } // 192 jyy++; 131 193 } // End of Loop over Y angles 132 194 } // End of loop over cylinders 195 133 196 tm.Nop(); 134 if ( (PrtLev>0) && (kf%pmod == 0) ) 197 // if ( (PrtLev_>0) && (kf%pmod == 0) ) 198 if ( (PrtLev_>0) && (kf%(mtx.NRows()/10) == 0) ) 135 199 cout << " OK box(angx,angy, freq=kf) done for kf=" << kf 136 200 << " / Max_kf=" << mtx.NRows() << endl; 137 201 } // End of loop over over frequencies 138 202 … … 140 204 } 141 205 206 //----------------------------------------------------------------------------- 142 207 inline float myZmodule(complex<r_4>& z) 143 208 { … … 145 210 } 146 211 212 //----------------------------------------------------------------------------- 147 213 TMatrix< r_4 > MultiCylinders::getRecXYSlice(int kfmin, int kfmax) 148 214 { … … 158 224 return(rmtx); 159 225 } 226 //----------------------------------------------------------------------------- 227 TMatrix< r_4 > MultiCylinders::getRecYXSlice(int kfmin, int kfmax) 228 { 229 TArray< complex<r_4> > & box = getRecSrcBox(); 230 if ((kfmin < 0) || (kfmin >= box.SizeZ()) || (kfmax < kfmin) || (kfmax >= box.SizeZ()) ) 231 throw RangeCheckError("MultiCylinders::getRecXYSlice(kfmin, kfmax)"); 232 TMatrix< r_4> rmtx(box.SizeX(), box.SizeY()); 233 for(int kf=kfmin; kf<=kfmax; kf++) { 234 for(int jy=0; jy<box.SizeY(); jy++) 235 for(int ix=0; ix<box.SizeX(); ix++) 236 rmtx(ix, jy) += myZmodule(box(ix, jy, kf)); 237 } 238 return(rmtx); 239 }
Note:
See TracChangeset
for help on using the changeset viewer.