Changeset 3192 in Sophya for trunk/Cosmo/RadioBeam/treccyl.cc
- Timestamp:
- Mar 20, 2007, 11:48:15 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cosmo/RadioBeam/treccyl.cc
r3191 r3192 17 17 18 18 #include "timing.h" 19 #include "datacards.h" 20 #include <dvlist.h> 19 21 20 22 #include "multicyl.h" 21 23 #include "mbeamcyl.h" 24 #define LENGTH 1024 22 25 23 26 /* … … 32 35 // Declaration des fonctions de ce fichier 33 36 static int test1cyl(string& ppfname); 34 static int testmulticyl(string& ppfname, int ncyl=5); 37 static int testmulticyl(string& ppfname); 38 int ReadParam(char* fileName); 35 39 36 40 //----------------------------------------------------------- 37 41 // -------------- Parametres de simulation ----------------- 38 42 //----------------------------------------------------------- 43 static double tClock = 2.; // should come from param file !!!! 44 static double cLight=0.3; // in 1E9 m/s 45 //static double tClock = 1.; // should come from param file !!!! 46 //static double cLight=1.; // in 1E9 m/s 47 // 39 48 static int MR = 256; // Nombre de recepteur 40 static int NE = 1024; // Nombre d'echantillon en temps;49 static int NE = 64; // Nombre d'echantillon en temps; 41 50 static double freq0 = 2.; // frequence de base 42 51 static double da = 0.25; // pas des antennes le long du cylindre … … 44 53 static double maxangX = M_PI/3.; // angle max en X ( +/- ) 45 54 static double maxangY = M_PI/60.; // angle max en Y ( +/- ) 55 static int halfNY; 56 static int NX; 46 57 static int nsrcmax = 50; // Nb total de sources - en un plan 47 58 … … 53 64 static int nantgz = 0; // nb d'antennes morts (-> gain=0) 54 65 static int prtlevel = 0; // niveau de print 66 67 static int nCyl; 68 static double xCyl[1000]; 69 static double yCyl[1000]; 55 70 //----------------------------------------------------------- 56 71 … … 64 79 { 65 80 66 SophyaInit(); 67 InitTim(); // Initializing the CPU timer 68 69 string ppfname = "treccyl.ppf"; 70 int act = 1; 71 int ncyl = 5; 72 if (narg < 2) { 73 cout << "Usage: treccyl act ppfname [PrtLev=0] \n" 74 << " -act= X ou XY5 ou XY12 (5 ou 12 cylindres) \n" 81 SophyaInit(); 82 InitTim(); // Initializing the CPU timer 83 ReadParam("telescope.in"); 84 cout <<"MR="<< MR <<" NE="<<NE<<" freq0="<<freq0<<" "<<da<<" "<<maxangX <<endl; 85 cout << maxangY<<" "<<nsrcmax <<" "<< snoise<<" "<< tjit<<" "<< tos<<" "<<gmean <<endl; 86 cout << gsig<<" "<<nantgz <<" "<< prtlevel<<endl; 87 // return 1; 88 89 string ppfname = "treccyl.ppf"; 90 int act = 1; 91 // int ncyl = 5; 92 if (narg < 2) { 93 cout << "Usage: treccyl act ppfname \n" 94 << " -act= X ou XY \n" 75 95 << " -ppfname= treccyl.ppf par defaut" << endl; 76 return 1; 77 } 78 if (strcmp(arg[1],"XY5") == 0) { act = 2; ncyl = 5; } 79 else if (strcmp(arg[1],"XY12") == 0) { act = 2; ncyl = 12; } 80 if (narg > 2) ppfname = arg[2]; 81 if (narg > 3) prtlevel = atoi(arg[3]); 82 83 int rc = 0; 84 cout << ">>>> treccyl : " << arg[1] << " PPFName=" << ppfname << endl; 85 try { 86 if (act == 2) rc = testmulticyl(ppfname, ncyl); 87 else rc = test1cyl(ppfname); 88 } 96 return 1; 97 } 98 if (strcmp(arg[1],"XY") == 0) { act = 2 ;} 99 if (narg > 2) ppfname = arg[2]; 100 101 int rc = 0; 102 cout << ">>>> treccyl : " << arg[1] << " PPFName=" << ppfname << endl; 103 try { 104 if (act == 2) rc = testmulticyl(ppfname); 105 else rc = test1cyl(ppfname); 106 } 89 107 catch (PThrowable& exc) { 90 108 cerr << " treccyl.cc catched Exception " << exc.Msg() << endl; … … 101 119 } 102 120 103 cout << ">>>> treccyl ------- FIN ----------- Rc=" << rc << endl;104 return rc;121 cout << ">>>> treccyl ------- FIN ----------- Rc=" << rc << endl; 122 return rc; 105 123 } 106 124 107 125 126 //----------------------------------------------------------------------------- 108 127 //--- Fonction de test : reconstruction plan AngX-Frequence (1 cylindre) 109 128 int test1cyl(string& ppfname) … … 111 130 112 131 // BRSourceGen sg; 113 int nsrc = 60;132 // int nsrc = 60; 114 133 BRSourceGen sg(nsrcmax, maxangX, 0.); 115 134 // sg.WritePPF(string("brsrc1.ppf")); … … 140 159 141 160 POutPersist po(ppfname); 142 po << PPFNameTag("signal") << mb.signal; 143 po << PPFNameTag("sigjitt") << mb.sigjitt; 144 po << PPFNameTag("f_sig") << mb.f_sig; 145 po << PPFNameTag("f_sigjit") << mb.f_sigjit; 161 // direct access to variables members !!!! 162 po << PPFNameTag("signal") << mb.signal_; 163 po << PPFNameTag("sigjitt") << mb.sigjitt_; 164 po << PPFNameTag("f_sig") << mb.f_sig_; 165 po << PPFNameTag("f_sigjit") << mb.f_sigjit_; 146 166 147 167 NTuple ntsrc = sg.Convert2Table(freq0); … … 163 183 164 184 185 //----------------------------------------------------------------------------- 165 186 //--- Fonction de test : reconstruction cube AngX-AngY-Frequence (multi-cylindre) 166 int testmulticyl(string& ppfname , int ncyl)187 int testmulticyl(string& ppfname) 167 188 { 168 189 169 if ((ncyl != 5) && (ncyl != 12)) ncyl = 5; 170 190 //............. sources 171 191 // BRSourceGen sg; 172 192 int nsf = 6; 173 193 vector<double> frq; 174 frq.push_back(0.1 );175 frq.push_back(0.27 );176 frq.push_back(0.38 );194 frq.push_back(0.1/tClock); 195 frq.push_back(0.27/tClock); 196 frq.push_back(0.38/tClock); 177 197 178 198 … … 183 203 int is; 184 204 double fay[6] = {-0.7,-0.5,0.,0.,0.5,0.7}; 205 // double fay[6] = {-0.2,0.5,-0.3,0.6,-0.1,0.7}; 206 // double fax[6] = {0.6,-0.2,-0.5,0.4,-0.1,0.3}; 185 207 for(is=0; is<3*nsf; is++) { 186 208 int ism = is%nsf; 187 sg.angX(is) = maxangX*(ism-2.5)/3.; 188 sg.angY(is) = maxangY*fay[ism]; 209 sg.angX(is) = maxangX*(ism-2.5)/3.; // accessing data member 210 sg.angY(is) = maxangY*fay[ism]; // directly !!! 211 // sg.angX(is) = maxangX*fax[ism]; // accessing data member 189 212 } 190 213 // sg.WritePPF(string("brsrcm.ppf")); 191 214 // BRSourceGen sg(string("brsrcm.ppf")); 192 215 cout << "=== testmulticyl: NbSrc= " << sg.NbSources() 193 << " NbRecep=" << MR << " NSamples=" << NE << " NCyl=" << n cyl << endl;216 << " NbRecep=" << MR << " NSamples=" << NE << " NCyl=" << nCyl << endl; 194 217 if (prtlevel > 1) sg.Print(cout); 195 218 196 197 MultiCylinders mcyl (MR, NE); 198 mcyl.SetPrintLevel(prtlevel); 199 mcyl.SetBaseFreqDa(freq0, da); 200 mcyl.SetNoiseSigma(snoise); 201 mcyl.SetTimeJitter(tjit); 202 mcyl.SetTimeOffsetSigma(tos); 203 mcyl.SetGains(gmean, gsig, nantgz); 204 205 if (ncyl == 12) { 206 cout << " --- testmulticyl/ NCyl= " << ncyl << " posY=0 ... " << (ncyl-1)*5. 207 << " (EqualSpacing)" << endl; 208 for(int kkc=0; kkc<12; kkc++) { 209 cout << "..." << kkc << " - mcyl.AddCylinder(posY= " << 5.*kkc << " )" << endl; 210 mcyl.AddCylinder(5.*kkc,5.*kkc); 211 // mcyl.AddCylinder(0.,5.*kkc); 212 } 213 } 214 else { 215 cout << " --- testmulticyl/ NCyl= " << ncyl << " posY=0 ... 55 (IrregularSpacing)" << endl; 216 double posyc[5] = {0.,5.,15.,35.,55.}; 217 for(int kkc=0; kkc<5; kkc++) { 218 cout << "..." << kkc << " - mcyl.AddCylinder(posY= " << posyc[kkc] << " )" << endl; 219 mcyl.AddCylinder(posyc[kkc],posyc[kkc]); 220 } 221 } 219 //.......................... cylinders 220 MultiCylinders mcyl ("telescope.in"); 221 // MultiCylinders mcyl (MR, NE); 222 // mcyl.SetPrintLevel(prtlevel); 223 // mcyl.SetBaseFreqDa(freq0, da); 224 // mcyl.SetNoiseSigma(snoise); 225 // mcyl.SetTimeJitter(tjit); 226 // mcyl.SetTimeOffsetSigma(tos); 227 // mcyl.SetGains(gmean, gsig, nantgz); 228 229 // for (int iCyl=0; iCyl<nCyl; iCyl++) 230 // { 231 // mcyl.AddCylinder(xCyl[iCyl],yCyl[iCyl]); 232 // } 233 222 234 223 235 mcyl.SetSources(sg); … … 226 238 227 239 // mcyl.ReconstructCylinderPlaneS(true); 228 mcyl.ReconstructSourceBox( 10, maxangY/10.);240 mcyl.ReconstructSourceBox(halfNY, maxangY/halfNY, NX, maxangX/NX); 229 241 230 242 cout << "--- treccy/testmulticyl: Saving to PPF file " << ppfname << endl; 231 243 POutPersist po(ppfname); 232 244 245 DVList dvl; 246 dvl("Da") = da; 247 po << PPFNameTag("dvl") <<dvl; 248 233 249 NTuple ntsrc = sg.Convert2Table(freq0); 234 250 po << PPFNameTag("ntsrc") << ntsrc; 235 251 236 {237 252 // TMatrix<r_4> srcplane0 = module(mcyl.GetCylinder(0).getRecSrcPlane()); 238 253 TMatrix< complex<r_4> > srcplane0 = mcyl.GetCylinder(0).getRecSrcPlane(); 239 254 po << PPFNameTag("recsrcplane0") << srcplane0; 240 } 241 242 { 243 // TMatrix<r_4> srcplane2 = module(mcyl.GetCylinder(3).getRecSrcPlane()); 244 TMatrix< complex<r_4> > srcplane2 = mcyl.GetCylinder(2).getRecSrcPlane(); 245 po << PPFNameTag("recsrcplane2") << srcplane2; 246 } 247 248 { 249 // TMatrix<r_4> srcplane3 = module(mcyl.GetCylinder(3).getRecSrcPlane()); 250 TMatrix< complex<r_4> > srcplane3 = mcyl.GetCylinder(0).getRecSrcPlane(); 251 po << PPFNameTag("recsrcplane3") << srcplane3; 252 } 253 255 TMatrix< complex<r_4> > srcplane1 = mcyl.GetCylinder(1).getRecSrcPlane(); 256 po << PPFNameTag("recsrcplane1") << srcplane1; 257 // TMatrix< complex<r_4> > srcplane3 = mcyl.GetCylinder(3).getRecSrcPlane(); 258 // po << PPFNameTag("recsrcplane3") << srcplane3; 254 259 PrtTim("testmulticyl[2] "); 255 260 256 int kfmin, kfmax;257 261 po << PPFNameTag("recsrcbox") << mcyl.getRecSrcBox(); 258 kfmin = mcyl.getRecSrcBox().SizeZ()/0.5*frq[0] - 2; kfmax = kfmin+2; 262 263 // k= N T frq with N=2*SizeZ() 264 int kfmin = (int)(2.*frq[0]*tClock*(float)mcyl.getRecSrcBox().SizeZ() - 2.); 265 int kfmax = kfmin+2; 259 266 cout << "testmulticyl/Info: slice0 kfmin=" << kfmin << " kfmax=" << kfmax << endl; 260 {261 267 TMatrix<r_4> slice0 = mcyl.getRecXYSlice(kfmin, kfmax); 262 268 po << PPFNameTag("recXYf0") << slice0; 263 }264 kfm in = mcyl.getRecSrcBox().SizeZ()/0.5*frq[1] - 2; kfmax = kfmin+2;269 kfmin = (int)(2*frq[1]*tClock*(float)mcyl.getRecSrcBox().SizeZ() - 2.); 270 kfmax = kfmin+2; 265 271 cout << "testmulticyl/Info: slice1 kfmin=" << kfmin << " kfmax=" << kfmax << endl; 266 {267 272 TMatrix<r_4> slice1 = mcyl.getRecXYSlice(kfmin, kfmax); 268 273 po << PPFNameTag("recXYf1") << slice1; 269 }270 kfm in = mcyl.getRecSrcBox().SizeZ()/0.5*frq[2] - 2; kfmax = kfmin+2;274 kfmin = (int)(2*frq[2]*tClock*(float)mcyl.getRecSrcBox().SizeZ() - 2.); 275 kfmax = kfmin+2; 271 276 cout << "testmulticyl/Info: slice2 kfmin=" << kfmin << " kfmax=" << kfmax << endl; 272 {273 277 TMatrix<r_4> slice2 = mcyl.getRecXYSlice(kfmin, kfmax); 274 278 po << PPFNameTag("recXYf2") << slice2; 275 }276 279 277 280 PrtTim("testmulticyl[3] "); … … 280 283 281 284 } 285 286 //--------------------------------------------------------------------- 287 int ReadParam(char* fileName) 288 { 289 DataCards dc; 290 dc.ReadFile(fileName); 291 // frequences are in units of 1/T = 0.5 GHz 292 // distance are in units of cT =3E8 * 2E-9=0.60 m 293 // double fUnit=0.5; // 0.5 GHz <=> T = 2 ns 294 // double dUnit=0.6; // distance unit in m. 295 double fUnit=1.; // 0.5 GHz <=> T = 2 ns 296 double dUnit=1.; // distance unit in m. 297 298 NE=dc.IParam("nSample"); 299 freq0=dc.DParam("freq0")/fUnit; 300 // tClock=dc.DParam("tClock"); 301 nCyl=dc.IParam("nCyl"); 302 for (int i=0; i<nCyl; i++){ 303 xCyl[i]=dc.DParam("xCyl",i)/dUnit; 304 yCyl[i]=dc.DParam("yCyl",i)/dUnit; 305 } 306 MR=dc.IParam("nAntenna"); 307 da=dc.DParam("dAntenna")/dUnit; 308 maxangX=dc.DParam("angMaxX"); 309 double cylDiam=dc.DParam("cylinderDiam")/dUnit; 310 // thetaMax = lambda_M/d = c/freq_min/d; freq_min = freq0 + 1/2T 311 maxangY=cLight/(freq0+1./2./tClock)/cylDiam; 312 // cout << "*************** maxangY = " <<maxangY << endl; 313 // maxangY=dc.DParam("angMaxY"); 314 snoise=dc.DParam("noiseSigma"); 315 tjit=dc.DParam("sigmaTimeJitt"); 316 tos=dc.DParam("sigmaClockJitt"); 317 gmean=dc.DParam("meanGain"); 318 gsig=dc.DParam("sigmaGain"); 319 nantgz=dc.IParam("nDeadAntenna"); 320 prtlevel=dc.IParam("printLevel"); 321 halfNY=dc.IParam("halfNY"); 322 NX=dc.IParam("NX"); 323 return 1; 324 }
Note:
See TracChangeset
for help on using the changeset viewer.