source: Sophya/trunk/Cosmo/RadioBeam/multicyl.cc@ 3160

Last change on this file since 3160 was 3160, checked in by ansari, 19 years ago

Creation du module Cosmo/RadioBeam de simulation pour reconstruction de lobe par FFT et correlation (manip BAORadio/HSHS) - Reza 29/01/2007

File size: 4.6 KB
Line 
1#include "multicyl.h"
2#include "fftpserver.h"
3#include "vector3d.h"
4#include "matharr.h"
5#include "srandgen.h"
6#include "ctimer.h"
7#include "resusage.h"
8
9
10//=================================================
11
12MultiCylinders::MultiCylinders(int nr, int ns)
13{
14 NR = nr;
15 NS = ns;
16
17 SetPrintLevel(0);
18
19 SetBaseFreqDa(2., 0.25);
20 SetNoiseSigma(0.);
21 SetTimeJitter(0.);
22 SetTimeOffsetSigma(0.);
23 SetGains(1., 0., 0);
24 adfg = false; src = NULL;
25 SetSources(new BRSourceGen, true);
26}
27
28MultiCylinders::~MultiCylinders()
29{
30 if (adfg && src) delete src;
31 for(int k=0; k<mCyl.size(); k++) delete mCyl[k];
32}
33
34MultiBeamCyl& MultiCylinders::GetCylinder(int k)
35{
36 if ((k < 0) || (k >= mCyl.size()))
37 throw RangeCheckError("MultiCylinders::GetCylinder(k) k<0 OR k>=NCyl");
38 return (*mCyl[k]);
39}
40
41void MultiCylinders::SetSources(BRSourceGen* brs, bool ad)
42{
43 if (brs == NULL) return;
44 if (adfg && src) delete src;
45 src = brs; adfg=ad;
46}
47
48
49void MultiCylinders::ConfigureCylinders()
50{
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
64void MultiCylinders::ReconstructCylinderPlaneS(bool fgzerocentre)
65{
66 Timer tm("RecCylPlaneS");
67 ResourceUsage resu;
68 cout << " MultiCylinders::ReconstructCylinderPlaneS()/Info - NCyl= " << mCyl.size()
69 << " MemSize=" << resu.getMemorySize() << " kb" << endl;
70 ConfigureCylinders();
71
72 char buff[128];
73 for(int k=0; k<mCyl.size(); k++) {
74 cout << "---- Cyl[" << k << "] Calling MultiBeamCyl.ReconstructSourcePlane() ..." << endl;
75 mCyl[k]->ReconstructSourcePlane(fgzerocentre);
76 sprintf(buff,"Cyl[%d].RecSrcPlane()",k);
77 tm.Split(buff);
78 }
79 resu.Update();
80 cout << " MultiCylinders::ReconstructCylinderPlaneS()/Info - Done "
81 << " MemSize=" << resu.getMemorySize() << " kb" << endl;
82}
83
84void MultiCylinders::ReconstructSourceBox(int halfny, double stepangy)
85{
86 Timer tm("RecSrcBox");
87
88 ReconstructCylinderPlaneS(true);
89 TMatrix< complex<r_4> > & mtx = GetCylinder(0).getRecSrcPlane();
90 // boite 3D X:angX, Y:angY , Z: freq
91 sa_size_t sz[5] = {0,0,0,0,0};
92 sz[0] = mtx.NCols();
93 sz[1] = halfny*2+1;
94 sz[2] = mtx.NRows();
95 TArray< complex<r_4> > & box = getRecSrcBox();
96 box.ReSize(3, sz);
97 // box = complex< r_4 >( 0.f, 0.f );
98 cout << " MultiCylinders::ReconstructSourceBox(" << halfny << "," << stepangy
99 << "=" << Angle(stepangy).ToArcMin() << " ) srcbox:" << endl;
100 box.Show(cout);
101
102
103 int pmod = mtx.NRows()/10;
104
105 double fstep = 1./(double)NS; // pas en frequence, attention, on a vire la composante continu
106 for(int kf=0; kf<mtx.NRows(); kf++) { // Loop over frequencies
107 double frq = (double)(kf+1.)*fstep + freq0; // + 1 car f=0 a ete vire
108
109 for(int lc=0; lc<mCyl.size(); lc++) { // Loop over cylinders
110 MultiBeamCyl& cyl = GetCylinder(lc);
111
112 TMatrix< complex<r_4> > & recp = cyl.getRecSrcPlane();
113
114 double facl = - 2*M_PI*frq*cyl.getCylinderYPos(); // attention au signe -
115 double dphi;
116 complex< r_4 > phasefactor;
117 int jyy = 0;
118 for(int jy=-halfny; jy<=halfny; jy++) { // Loop over Y angular steps
119 double dphi = facl * sin( (double)jy*stepangy );
120 phasefactor = complex< r_4 > ((r_4) cos(dphi) , (r_4) sin(dphi));
121 for(int ix=0; ix<sz[0]; ix++) { // Loop over AngX directions
122 // sur recp : index ligne -> frequence , index colonne -> angX ,
123 box(ix, jyy, kf) += recp(kf, ix)*phasefactor;
124 } //
125 jyy++;
126 } // End of Loop over Y angles
127 } // End of loop over cylinders
128 tm.Nop();
129 if ( (PrtLev>0) && (kf%pmod == 0) )
130 cout << " OK box(angx,angy, freq=kf) done for kf=" << kf
131 << " / Max_kf=" << mtx.NRows() << endl;
132 } // End of loop over over frequencies
133
134 cout << " MultiCylinders::ReconstructSourceBox() done " << endl;
135}
136
137inline float myZmodule(complex<r_4>& z)
138{
139 return (float)sqrt((double)(z.real()*z.real()+z.imag()*z.imag()));
140}
141
142TMatrix< r_4 > MultiCylinders::getRecXYSlice(int kfmin, int kfmax)
143{
144 TArray< complex<r_4> > & box = getRecSrcBox();
145 if ((kfmin < 0) || (kfmin >= box.SizeZ()) || (kfmax < kfmin) || (kfmax >= box.SizeZ()) )
146 throw RangeCheckError("MultiCylinders::getRecXYSlice(kfmin, kfmax)");
147 TMatrix< r_4> rmtx(box.SizeY(), box.SizeX());
148 for(int kf=kfmin; kf<=kfmax; kf++) {
149 for(int jy=0; jy<box.SizeY(); jy++)
150 for(int ix=0; ix<box.SizeX(); ix++)
151 rmtx(jy, ix) += myZmodule(box(ix, jy, kf));
152 }
153 return(rmtx);
154}
Note: See TracBrowser for help on using the repository browser.