Changeset 3192 in Sophya for trunk/Cosmo/RadioBeam/treccyl.cc


Ignore:
Timestamp:
Mar 20, 2007, 11:48:15 AM (19 years ago)
Author:
legoff
Message:

input file read with DVcards by treccyl.cc

and by multiCylinders(char* filename)

using real units (meter and GHz)
using _ for member variables (e.g. x_)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cosmo/RadioBeam/treccyl.cc

    r3191 r3192  
    1717
    1818#include "timing.h"
     19#include "datacards.h"
     20#include <dvlist.h>
    1921
    2022#include "multicyl.h"
    2123#include "mbeamcyl.h"
     24#define LENGTH 1024
    2225
    2326/*
     
    3235// Declaration des fonctions de ce fichier
    3336static int test1cyl(string& ppfname);
    34 static int testmulticyl(string& ppfname, int ncyl=5);
     37static int testmulticyl(string& ppfname);
     38int ReadParam(char* fileName);
    3539
    3640//-----------------------------------------------------------
    3741// -------------- Parametres de simulation  -----------------
    3842//-----------------------------------------------------------
     43static double tClock = 2.; // should come from param file !!!!
     44static 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//
    3948static int MR = 256;  // Nombre de recepteur
    40 static int NE = 1024;  // Nombre d'echantillon en temps;
     49static int NE = 64;  // Nombre d'echantillon en temps;
    4150static double freq0 = 2.;  // frequence de base
    4251static double da = 0.25;     // pas des antennes le long du cylindre
     
    4453static double maxangX = M_PI/3.; // angle max en X ( +/- )
    4554static double maxangY = M_PI/60.; // angle max en Y ( +/- )
     55static int halfNY;
     56static int NX;
    4657static int nsrcmax = 50;  // Nb total de sources - en un plan
    4758
     
    5364static int nantgz = 0;       // nb d'antennes morts (-> gain=0)
    5465static int prtlevel = 0;     // niveau de print
     66
     67static int nCyl;
     68static double xCyl[1000];
     69static double yCyl[1000];
    5570//-----------------------------------------------------------
    5671
     
    6479{
    6580
    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"
    7595       << " -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  }
    89107  catch (PThrowable& exc) {
    90108    cerr << " treccyl.cc catched Exception " << exc.Msg() << endl;
     
    101119  }
    102120
    103 cout << ">>>> treccyl ------- FIN ----------- Rc=" << rc << endl;
    104 return rc;
     121  cout << ">>>> treccyl ------- FIN ----------- Rc=" << rc << endl;
     122  return rc;
    105123}
    106124
    107125
     126//-----------------------------------------------------------------------------
    108127//--- Fonction de test : reconstruction plan AngX-Frequence (1 cylindre)
    109128int test1cyl(string& ppfname)
     
    111130
    112131  // BRSourceGen sg;
    113   int nsrc = 60;
     132//  int nsrc = 60;
    114133  BRSourceGen sg(nsrcmax, maxangX, 0.);
    115134  //  sg.WritePPF(string("brsrc1.ppf"));
     
    140159
    141160  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_;
    146166
    147167  NTuple ntsrc = sg.Convert2Table(freq0);
     
    163183
    164184
     185//-----------------------------------------------------------------------------
    165186//--- Fonction de test : reconstruction cube AngX-AngY-Frequence (multi-cylindre)
    166 int testmulticyl(string& ppfname, int ncyl)
     187int testmulticyl(string& ppfname)
    167188{
    168189
    169   if ((ncyl != 5) && (ncyl != 12)) ncyl = 5;
    170 
     190//.............  sources
    171191  // BRSourceGen sg;
    172192  int nsf = 6;
    173193  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);
    177197 
    178198 
     
    183203  int is;
    184204  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};
    185207  for(is=0; is<3*nsf; is++) {
    186208    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
    189212  }
    190213  // sg.WritePPF(string("brsrcm.ppf"));
    191214  // BRSourceGen  sg(string("brsrcm.ppf"));
    192215  cout << "=== testmulticyl: NbSrc= " << sg.NbSources()
    193        << " NbRecep=" << MR << " NSamples=" << NE << " NCyl=" << ncyl << endl;
     216       << " NbRecep=" << MR << " NSamples=" << NE << " NCyl=" << nCyl << endl;
    194217  if (prtlevel > 1)  sg.Print(cout);
    195218 
    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
    222234
    223235  mcyl.SetSources(sg);
     
    226238
    227239  //  mcyl.ReconstructCylinderPlaneS(true);
    228   mcyl.ReconstructSourceBox(10, maxangY/10.);
     240  mcyl.ReconstructSourceBox(halfNY, maxangY/halfNY, NX, maxangX/NX);
    229241
    230242  cout << "--- treccy/testmulticyl: Saving to PPF file " << ppfname << endl;
    231243  POutPersist po(ppfname);
    232244
     245  DVList  dvl;
     246  dvl("Da") = da;
     247  po << PPFNameTag("dvl") <<dvl;     
     248 
    233249  NTuple ntsrc = sg.Convert2Table(freq0);
    234250  po << PPFNameTag("ntsrc") << ntsrc;
    235251
    236   {
    237252    //  TMatrix<r_4> srcplane0 = module(mcyl.GetCylinder(0).getRecSrcPlane());
    238253  TMatrix< complex<r_4> > srcplane0 = mcyl.GetCylinder(0).getRecSrcPlane();
    239254  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;
    254259  PrtTim("testmulticyl[2] ");
    255260
    256   int kfmin, kfmax;
    257261  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;
    259266  cout << "testmulticyl/Info: slice0 kfmin=" << kfmin << " kfmax=" << kfmax << endl;
    260   {
    261267  TMatrix<r_4> slice0 = mcyl.getRecXYSlice(kfmin, kfmax);
    262268  po << PPFNameTag("recXYf0") << slice0;
    263   }
    264   kfmin = 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;
    265271  cout << "testmulticyl/Info: slice1 kfmin=" << kfmin << " kfmax=" << kfmax << endl;
    266   {
    267272  TMatrix<r_4> slice1 = mcyl.getRecXYSlice(kfmin, kfmax);
    268273  po << PPFNameTag("recXYf1") << slice1;
    269   }
    270   kfmin = 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;
    271276  cout << "testmulticyl/Info: slice2 kfmin=" << kfmin << " kfmax=" << kfmax << endl;
    272   {
    273277  TMatrix<r_4> slice2 = mcyl.getRecXYSlice(kfmin, kfmax);
    274278  po << PPFNameTag("recXYf2") << slice2;
    275   }
    276279
    277280  PrtTim("testmulticyl[3] ");
     
    280283
    281284}
     285
     286//---------------------------------------------------------------------
     287int 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.