Changeset 3192 in Sophya


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_)

Location:
trunk/Cosmo/RadioBeam
Files:
8 edited

Legend:

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

    r3160 r3192  
    7171
    7272  int j = 0;
    73   for(int k=0; k<f.size(); k++) {
     73  for(int k=0; k<(int)f.size(); k++) {
    7474    if (f[k] >= 0.5) {
    7575      cout << "BRSourceGen::BRSourceGen() f[k=" << k << "]=" << f[k] << " >=0.5 ignored " << endl;
  • trunk/Cosmo/RadioBeam/brsrc.h

    r3165 r3192  
    4949  NTuple Convert2Table(double freq0=0.);   
    5050
     51//private:
    5152  //-------- Variables / objets membres
    5253 Vector freq; // frequence des sources
  • trunk/Cosmo/RadioBeam/makefile

    r3160 r3192  
    1111        echo 'makefile : treccyl made'
    1212
     13testFFT : Objs/testFFT.o
    1314######
    1415
     
    3031        $(CXXCOMPILE) -o Objs/multicyl.o  multicyl.cc
    3132
     33testFFT :  Objs/testFFT.o
     34        $(CXXLINK) -o testFFT \
     35        Objs/testFFT.o \
     36        $(SOPHYAEXTSLBLIST)
     37
     38Objs/testFFT.o : testFFT.cc
     39        $(CXXCOMPILE) -o Objs/testFFT.o testFFT.cc
  • trunk/Cosmo/RadioBeam/mbeamcyl.cc

    r3191 r3192  
    55#include "srandgen.h"
    66
     7static double cLight=0.3;       // in 1E9 m/s
     8static double tClock = 2.; // should come from param file !!!!
     9//static double cLight=1;       
     10//static double tClock = 1.;
     11
    712//=================================================
    813
    914MultiBeamCyl::MultiBeamCyl(int nr, int ns, double posx, double posy)
    10   : texact(ns) , tjitt(ns) , toffset(nr) ,
    11     signal(ns), sigjitt(ns) , gain(nr)
    12 {
    13   NR = nr;
    14   NS = ns;
    15   posY = posy;
    16   posX = posx;
     15  : texact_(ns) , tjitt_(ns) , toffset_(nr) ,
     16    gain_(nr), signal_(ns), sigjitt_(ns)
     17{
     18  NR_ = nr;
     19  NS_ = ns;
     20  posY_ = posy;
     21  posX_ = posx;
    1722
    1823  SetPrintLevel(0);
     
    2328  SetTimeOffsetSigma(0.);
    2429  SetGains(1., 0., 0);
    25   adfg = false; src = NULL;
     30  adfg_ = false; src_ = NULL;
    2631  SetSources(new BRSourceGen, true);
    2732}
    2833
     34//-----------------------------------------------------------------------------
    2935MultiBeamCyl::~MultiBeamCyl()
    3036{
    31   if (adfg && src) delete src;
    32 }
    33 
     37  if (adfg_ && src_) delete src_;
     38}
     39
     40//-----------------------------------------------------------------------------
    3441void MultiBeamCyl::SetSources(BRSourceGen* brs, bool ad)
    3542{
    3643  if (brs == NULL) return;
    37   if (adfg && src) delete src;
    38   src = brs;  adfg=ad;
    39   if (PrtLev > 1)
     44  if (adfg_ && src_) delete src_;
     45  src_ = brs;  adfg_=ad;
     46  if (PrtLev_ > 1)
    4047    cout << " MultiBeamCyl::SetSources(brs=" << brs <<" ,bool) NbSrc="
    41          << src->NbSources() << endl;
    42 
    43 }
    44 
     48         << src_->NbSources() << endl;
     49
     50}
     51
     52//-----------------------------------------------------------------------------
    4553void MultiBeamCyl::SetGains(double g, double sigg, int nzerogain)
    4654{
    47   if (sigg < 1.e-6)  gain = g;
    48   else gain = RandomSequence(RandomSequence::Gaussian, g, sigg);
     55  if (sigg < 1.e-6)  gain_ = g;
     56  else gain_ = RandomSequence(RandomSequence::Gaussian, g, sigg);
    4957  int k;
    50   for (k=0; k<NR; k++) if (gain(k) < 0) gain(k) = 0.;
     58  for (k=0; k<NR_; k++) if (gain_(k) < 0) gain_(k) = 0.;
    5159  for(k=0; k<nzerogain; k++) {
    52     int zg = random()%NR;
    53     if ((zg >=0) && (zg < NR))  gain(zg) = 0.;
    54   }
    55   if (PrtLev > 1)
     60    int zg = random()%NR_;
     61    if ((zg >=0) && (zg < NR_))  gain_(zg) = 0.;
     62  }
     63  if (PrtLev_ > 1)
    5664    cout << " MultiBeamCyl::SetGains(g=" << g <<" ,sigg=" << sigg
    5765         << " ,nzg=" << nzerogain << " )" << endl;
    5866}
    5967
     68//-----------------------------------------------------------------------------
    6069void MultiBeamCyl::ComputeTimeVectors()
    6170{
    62   texact = RegularSequence(0., 1.);
    63   toffset = RandomSequence(RandomSequence::Gaussian, 0., toffsig);
     71  texact_ = RegularSequence(0., tClock);        // 0, tClock, 2*tClock, ...
     72//  for (int i=0;i<1024;i++) {cout << texact(i)<< endl;};
     73  toffset_ = RandomSequence(RandomSequence::Gaussian, 0., toffsig_);
    6474  NewTJitVector();
    6575}
    6676
     77//-----------------------------------------------------------------------------
    6778void MultiBeamCyl::NewTJitVector(int num)
    6879{
    69   if (timejitter > 1.e-19) {
    70     tjitt = RandomSequence(RandomSequence::Gaussian, 0., timejitter);
    71     tjitt += texact
    72   }
    73   else tjitt = texact
    74   if (num >= 0) tjitt += toffset(num);
     80  if (timejitter_ > 1.e-19) {
     81    tjitt_ = RandomSequence(RandomSequence::Gaussian, 0., timejitter_);
     82    tjitt_ += texact_
     83  }
     84  else tjitt_ = texact_
     85  if (num >= 0) tjitt_ += toffset_(num);
    7586 
    7687}
    7788
     89//-----------------------------------------------------------------------------
    7890int MultiBeamCyl::ComputeSignalVector(int num, bool fgsignojit)
    7991{
    8092  int nok = 0;
    81   signal = 0.;
    82   sigjitt = 0.;
    83   for(int is=0; is<src->freq.Size(); is++) {
    84     double fr = src->freq(is);
     93  signal_ = 0.;
     94  sigjitt_ = 0.;
     95  for(int is=0; is<src_->freq.Size(); is++) {
     96    double fr = src_->freq(is);
    8597    if ((fr < 0.) || (fr > 0.5)) continue;
    8698    nok++;
     
    88100    // pas celle apres shift (freq-reduite)
    89101    // lambda = c T = c/freq avec c = 1, dephasage = 2*pi*num*Da*sin(ang)/lambda
    90     double dephasage = (posX+num*Da)*sin(src->angX(is)) +
    91                                 posY*sin(src->angY(is)) ;
    92     dephasage *= (2*M_PI*(fr+freq0));
     102    double dephasage = (posX_+num*Da_)*sin(src_->angX(is))
     103                                + posY_*sin(src_->angY(is)) ;
     104    dephasage *= 2*M_PI*(fr+freq0_)/cLight;
    93105    // On ajoute alors la phase propre de chaque source
    94     dephasage += src->phase(is);
    95     double amprep = src->amp(is)*AngResponse(src->angX(is), src->angY(is));
    96     for(int k=0; k<NS; k++) {
    97       sigjitt(k) += amprep*sin(2.*M_PI*fr*tjitt(k)+dephasage);
     106    dephasage += src_->phase(is);
     107    double amprep = src_->amp(is)*AngResponse(src_->angX(is), src_->angY(is));
     108    for(int k=0; k<NS_; k++) {
     109      sigjitt_(k) += amprep*sin(2.*M_PI*fr*tjitt_(k)+dephasage);
    98110      if (fgsignojit)
    99         signal(k) += amprep*sin(2.*M_PI*fr*texact(k)+dephasage);
     111        signal_(k) += amprep*sin(2.*M_PI*fr*texact_(k)+dephasage);
    100112    }
    101113  }
    102114  // Application du gain du detecteur
    103   r_4 ga = gain(num);
     115  r_4 ga = gain_(num);
    104116  if (fabs(ga-1.) > 1.e-9) {
    105     signal *= ga;
    106     sigjitt *= ga;
     117    signal_ *= ga;
     118    sigjitt_ *= ga;
    107119  }
    108120  // Ajout de bruit (ampli ...)
    109   if (signoise > 1.e-18) {
    110     for(int k=0; k<NS; k++) {
    111       sigjitt(k) += GauRnd(0., signoise);
    112       if (fgsignojit) signal(k) += GauRnd(0., signoise);
    113     }
    114   }
    115 
     121  if (signoise_ > 1.e-18) {
     122    for(int k=0; k<NS_; k++) {
     123      sigjitt_(k) += GauRnd(0., signoise_);
     124      if (fgsignojit) signal_(k) += GauRnd(0., signoise_);
     125    }
     126  }
     127//............      FFT in time
    116128  FFTPackServer ffts;
    117 
    118   ffts.FFTForward(sigjitt, f_sigjit);
    119   if (fgsignojit) ffts.FFTForward(signal, f_sig);
     129  ffts.FFTForward(sigjitt_, f_sigjit_);
     130  if (fgsignojit) ffts.FFTForward(signal_, f_sig_);
    120131
    121132  return nok;
     
    123134
    124135
     136//-----------------------------------------------------------------------------
    125137/*  --- a supprimer ?
    126138inline float myZmodule(complex<r_4>& z)
     
    130142----- */
    131143
     144//-----------------------------------------------------------------------------
    132145void MultiBeamCyl::ReconstructSourcePlane(bool fgzerocentre)
    133146{
     
    135148  int noksrc = ComputeSignalVector(0, false);
    136149  vector<TVector< complex<r_4> > >  vvfc;
    137   cout << "MultiBeamCyl::ReconstructSourcePlane() NR=" << NR
    138        << " PosY=" << posY << " NFreq=" << f_sigjit.Size()-1 << " NOkSrc=" << noksrc << endl;
    139   if (PrtLev > 0) {
    140     cout << " ... posY= " << posY << " MeanGain=" << Mean(gain) << " MeanAmpSrc="
    141          << Mean(src->amp) << endl;
    142     cout << " ...SigNoise=" << signoise << " TimeJitter=" << timejitter
    143          << " TOffSig=" << toffsig << " Da=" << Da << " Freq0=" << freq0 << endl;
     150  cout << "MultiBeamCyl::ReconstructSourcePlane() NR=" << NR_
     151       << " PosY=" << posY_ << " NFreq=" << f_sigjit_.Size()-1 << " NOkSrc=" << noksrc << endl;
     152  if (PrtLev_ > 0) {
     153    cout << " ... posY= " << posY_ << " MeanGain=" << Mean(gain_) << " MeanAmpSrc="
     154         << Mean(src_->amp) << endl;
     155    cout << " ...SigNoise=" << signoise_ << " TimeJitter=" << timejitter_
     156         << " TOffSig=" << toffsig_ << " Da=" << Da_ << " Freq0=" << freq0_ << endl;
    144157  }
    145158  // On ne s'occupe pas de la composante continue
    146   for(int jf=1; jf<f_sigjit.Size(); jf++) {
    147     TVector<complex<r_4> > cf(NR);
     159  for(int jf=1; jf<f_sigjit_.Size(); jf++) {
     160    TVector<complex<r_4> > cf(NR_);
    148161    vvfc.push_back(cf);
    149162  }
    150163  cout << "ReconstructSourcePlane()/Info: computing s(t) for each receptor ..." << endl;
    151   int pmod = NR/10;
    152   for(int ir=0; ir<NR; ir++) {
    153     if (timejitter > 1.e-19) NewTJitVector(ir);
     164  int pmod = NR_/10;
     165  for(int ir=0; ir<NR_; ir++) {
     166    if (timejitter_ > 1.e-19) NewTJitVector(ir);
    154167    noksrc = ComputeSignalVector(ir, false);
    155     for(int jf=1; jf<f_sigjit.Size(); jf++)
    156       vvfc[jf-1](ir) = f_sigjit(jf);
    157     if ( (PrtLev>0) && (ir%pmod == 0) )
    158       cout << " OK s(t) for ir=" << ir << " / NR=" << NR << " NOkSrc=" << noksrc << endl;
     168    for(int jf=1; jf<f_sigjit_.Size(); jf++)
     169      vvfc[jf-1](ir) = f_sigjit_(jf);
     170    if ( (PrtLev_>0) && (ir%pmod == 0) )
     171      cout << " OK s(t) for ir=" << ir << " / NR=" << NR_ << " NOkSrc=" << noksrc << endl;
    159172  }
    160173
    161174  cout << "ReconstructSourcePlane()/Info: computing s(ang) for each freq by FFT" << endl;
    162   cmplx_srcplane.SetSize(f_sigjit.Size()-1, NR);
    163   // rec_srcplane.SetSize(f_sigjit.Size()-1, NR);
     175  cmplx_srcplane_.SetSize(f_sigjit_.Size()-1, NR_);
     176  // rec_srcplane.SetSize(f_sigjit_.Size()-1, NR_);
    164177  FFTPackServer ffts;
    165178  TVector<complex<r_4> > fcf;
    166179  pmod = vvfc.size()/10;
    167   for(int jf=0; jf<vvfc.size(); jf++) {
    168     ffts.FFTForward(vvfc[jf], fcf);
    169     if (fcf.Size() != NR) {
     180  for(int jf=0; jf<(int)vvfc.size(); jf++) {            // loop over frequencies
     181    ffts.FFTForward(vvfc[jf], fcf);     // FFT alomg cylinder
     182    if (fcf.Size() != NR_) {
    170183      cout << "ReconstructSourcePlane()/BUG jf=" << jf << " fcf.Size() != NR "
    171            << fcf.Size() << " != " << NR << endl;
     184           << fcf.Size() << " != " << NR_ << endl;
    172185      continue;
    173186    }
    174187    if (fgzerocentre) {  // On veut avoir la direction angle=0 au milieu de la matrice
    175       int milieu = (NR-1)/2;
    176       if (NR%2 == 0) milieu++;
    177       int decal = NR - milieu - 1;
     188      int milieu = (NR_-1)/2;
     189      if (NR_%2 == 0) milieu++;
     190      int decal = NR_ - milieu - 1;
    178191      for (int ir=0; ir<=milieu; ir++)
    179         cmplx_srcplane(jf, ir+decal) = fcf(ir);
     192        cmplx_srcplane_(jf, ir+decal) = fcf(ir);
    180193      //        rec_srcplane(jf, ir+decal) = myZmodule(fcf(ir));
    181194
    182       for (int ir=milieu+1; ir<NR; ir++)
    183         cmplx_srcplane(jf, decal-(NR-ir)) = fcf(ir);
    184       //        rec_srcplane(jf, decal-(NR-ir)) = myZmodule(fcf(ir));
     195      for (int ir=milieu+1; ir<NR_; ir++)
     196        cmplx_srcplane_(jf, decal-(NR_-ir)) = fcf(ir);
     197      //        rec_srcplane_(jf, decal-(NR_-ir)) = myZmodule(fcf(ir));
    185198     
    186199    }
    187     else for (int ir=0; ir<NR; ir++)
    188       cmplx_srcplane(jf, ir) = fcf(ir);
     200    else for (int ir=0; ir<NR_; ir++)
     201      cmplx_srcplane_(jf, ir) = fcf(ir);
    189202    //      rec_srcplane(jf, ir) = myZmodule(fcf(ir));
    190203
    191     if ( (PrtLev > 0) && (jf%pmod == 0))
     204    if ( (PrtLev_ > 0) && (jf%pmod == 0))
    192205      cout << " OK rec_srcplane(jf, ir) for jf=" << jf << endl;
    193206  }
  • trunk/Cosmo/RadioBeam/mbeamcyl.h

    r3191 r3192  
    3131  // ns = nb d'echantillons en temps de chaque paquet
    3232  // posy = position spatiale en Y pour chaque cylindre (unite ou lambda=1 pour f=1)
    33  MultiBeamCyl(int nr=1024, int ns=4096, double posx=0., double posy=0.);
     33  // posx = position spatiale en X pour chaque cylindre (unite ou lambda=1 pour f=1)
     34 MultiBeamCyl(int nr=1024, int ns=4096, double posx=0., double posy=0. );
    3435 ~MultiBeamCyl();
    3536
    3637 // Niveau de print de debug
    37  inline void SetPrintLevel(int prl=0) { PrtLev=prl; }
     38 inline void SetPrintLevel(int prl=0) { PrtLev_=prl; }
    3839
    3940 // Reponse angulaire pour un recepteur (cylindre+antenne)
     
    4142 inline double AngResponse(double angx, double angy) { return 1.; }
    4243
    43  inline double getCylinderYPos() { return posY; }
    44  inline double getCylinderXPos() { return posX; }
     44 inline double getCylinderYPos() { return posY_; }
     45 inline double getCylinderXPos() { return posX_; }
     46
    4547 // Specification de la frequence de base f0 et espacement des recepteurs
    4648 // freq_vrai = freq_BRSourceGen + f0
    4749 // pour f_vrai = 2, lambda = 0.5 et lambda/2 = 0.25
    4850 inline void SetBaseFreqDa(double f0=2., double a=0.25)
    49    {  freq0 = f0;   Da = a; }
     51   {  freq0_ = f0;   Da_ = a; }
    5052
    5153 // frequences reduites (entre 0 ... 0.5) , angle en radian, amp ~ 1
     
    5557
    5658 // Definition du sigma du bruit gaussien sur les echantillons
    57  inline void SetNoiseSigma(double sig=0.) {  signoise = sig; }
     59 inline void SetNoiseSigma(double sig=0.) {  signoise_ = sig; }
    5860 // Definition du sigma du jitter d'horloge (typ 0.01)
    59  inline void SetTimeJitter(double tjit=0.) { timejitter = tjit; }
     61 inline void SetTimeJitter(double tjit=0.) { timejitter_ = tjit; }
    6062 // Definition du sigma des offsets d'horloge entre recepteurs (typ 0.02)
    61  inline void SetTimeOffsetSigma(double tsig=0.) { toffsig = tsig; }
     63 inline void SetTimeOffsetSigma(double tsig=0.) { toffsig_ = tsig; }
    6264
    6365 // Definition du gain et sigma de fluctuations de gain
     
    7981 void ReconstructSourcePlane(bool fgzerocentre=true);
    8082
    81  inline  TMatrix< complex<r_4> > & getRecSrcPlane() { return cmplx_srcplane; }
     83 inline  TMatrix< complex<r_4> > & getRecSrcPlane() { return cmplx_srcplane_; }
    8284
    8385 //-------------- Variables membres ------------
    84  int NR, NS;  // nb recepteurs, nb d'echantillons ds chaque paquet
    85  double posY;    // Position selon Y (E-O) de la ligne de recepteurs
    86  double posX;    // Position selon X (N-S) de la ligne de recepteurs
     86 int NR_, NS_;  // nb recepteurs, nb d'echantillons ds chaque paquet
     87 double posX_;    // Position selon X (N-S) du premier recepteur du cylindre
     88 double posY_;    // Position selon Y (E-O) de la ligne de recepteurs
    8789
    88  int PrtLev;   // Niveau de print de debug
     90 int PrtLev_;   // Niveau de print de debug
    8991
    90  double Da; // distance entre recepteurs
    91  double freq0;  // frequence de base (freqvrai=f+freq0)
     92 double Da_; // distance entre recepteurs
     93 double freq0_;  // frequence de base (freqvrai=f+freq0)
    9294 
    93  Vector texact;  // les temps exact
    94  Vector tjitt;   // temps avec jitter
    95  Vector toffset;  // Offset en temps entre recepteurs
    96  double timejitter; // le sigma du jitter en temps des coups d'horloge
    97  double toffsig;    // sigma des offsets en temps
     95 Vector texact_;  // les temps exact
     96 Vector tjitt_;   // temps avec jitter
     97 Vector toffset_;  // Offset en temps entre recepteurs
     98 double timejitter_; // le sigma du jitter en temps des coups d'horloge
     99 double toffsig_;    // sigma des offsets en temps
    98100 
    99  BRSourceGen* src;  // Les sources
    100  bool adfg; // if true, delete src
     101 BRSourceGen* src_;  // Les sources
     102 bool adfg_; // if true, delete src
    101103
    102  double signoise; // sigma du bruit additif (bruit ampli ... )
     104 double signoise_; // sigma du bruit additif (bruit ampli ... )
    103105 
    104  TVector<r_4> gain;  // Gain de chaque recepteur
     106 TVector<r_4> gain_;  // Gain de chaque recepteur
    105107
    106  TVector<r_4> signal; // signal sans jitter en temps
    107  TVector<r_4> sigjitt; // signal avec jitter en temps
     108 TVector<r_4> signal_; // signal sans jitter en temps
     109 TVector<r_4> sigjitt_; // signal avec jitter en temps
    108110
    109  TVector< complex<r_4> > f_sig, f_sigjit;  // TF des vecteurs signal , sigjitt
     111 TVector< complex<r_4> > f_sig_, f_sigjit_;  // TF des vecteurs signal , sigjitt
    110112
    111  TMatrix< complex<r_4> > cmplx_srcplane; // composantes complexe du plan-source reconstruit
    112  // TMatrix<r_4> rec_srcplane;  // Matrice plan source colonnes->angX, lignes->freq
     113 TMatrix< complex<r_4> > cmplx_srcplane_; // composantes complexe du plan-source reconstruit
     114 // TMatrix<r_4> rec_srcplane_;  // Matrice plan source colonnes->angX, lignes->freq
    113115 };
    114116
  • trunk/Cosmo/RadioBeam/multicyl.cc

    r3191 r3192  
    66#include "ctimer.h"
    77#include "resusage.h"
     8#include "datacards.h"
     9
     10static double cLight=0.3;       // in 1E9 m/s
     11static double tClock = 2.; // should come from param file !!!!
     12//static double cLight=1;       
     13//static double tClock = 1.;
    814
    915
     
    1218MultiCylinders::MultiCylinders(int nr, int ns)
    1319{
    14   NR = nr;
    15   NS = ns;
     20  NR_ = nr;
     21  NS_ = ns;
    1622
    1723  SetPrintLevel(0);
     
    2228  SetTimeOffsetSigma(0.);
    2329  SetGains(1., 0., 0);
    24   adfg = false; src = NULL;
     30  adfg_ = false; src_ = NULL;
    2531  SetSources(new BRSourceGen, true);
    2632}
    2733
     34//-----------------------------------------------------------------------------
     35MultiCylinders::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//-----------------------------------------------------------------------------
    2879MultiCylinders::~MultiCylinders()
    2980{
    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//-----------------------------------------------------------------------------
    3486MultiBeamCyl& MultiCylinders::GetCylinder(int k)
    3587{
    36   if ((k < 0) || (k >= mCyl.size()))
     88  if ((k < 0) || (k >= (int)mCyl_.size())) {
     89    cout <<"******************************************* k="<<k<<endl;
    3790    throw RangeCheckError("MultiCylinders::GetCylinder(k) k<0 OR k>=NCyl");
    38   return (*mCyl[k]);
    39 }
    40 
     91  }
     92  return (*mCyl_[k]);
     93}
     94
     95//-----------------------------------------------------------------------------
    4196void MultiCylinders::SetSources(BRSourceGen* brs, bool ad)
    4297{
    4398  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//-----------------------------------------------------------------------------
    49105void MultiCylinders::ConfigureCylinders()
    50106{
    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//-----------------------------------------------------------------------------
    64121void MultiCylinders::ReconstructCylinderPlaneS(bool fgzerocentre)
    65122{
    66123  Timer tm("RecCylPlaneS");
    67124  ResourceUsage resu;
    68   cout << " MultiCylinders::ReconstructCylinderPlaneS()/Info - NCyl= " << mCyl.size()
     125  cout << " MultiCylinders::ReconstructCylinderPlaneS()/Info - NCyl= " << mCyl_.size()
    69126       << " MemSize=" << resu.getMemorySize() << " kb" << endl;       
    70127  ConfigureCylinders();
    71128
    72129  char buff[128];
    73   for(int k=0; k<mCyl.size(); k++) {
     130  for(int k=0; k<(int)mCyl_.size(); k++) {
    74131    cout << "---- Cyl[" << k << "] Calling MultiBeamCyl.ReconstructSourcePlane() ..." << endl;
    75     mCyl[k]->ReconstructSourcePlane(fgzerocentre);
     132    mCyl_[k]->ReconstructSourcePlane(fgzerocentre);
    76133    sprintf(buff,"Cyl[%d].RecSrcPlane()",k);
    77134    tm.Split(buff);
     
    82139}
    83140
    84 void MultiCylinders::ReconstructSourceBox(int halfny, double stepangy)
    85 {
     141//-----------------------------------------------------------------------------
     142void MultiCylinders::ReconstructSourceBox(int halfny, double stepangy,
     143        int nx, double stepangx)
     144{
     145  nx=256;
    86146  ReconstructCylinderPlaneS(true);
    87147  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() ?
    89152  sa_size_t sz[5] = {0,0,0,0,0};
    90 //  int nx=mtx.NCols(); // uncomment to go back to nxbin = nantenna
    91   int nx=256;
    92153  sz[0] = nx;
    93154  sz[1] = halfny*2+1;
    94155  sz[2] = mtx.NRows();
    95156  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 ?
    98158  cout << " MultiCylinders::ReconstructSourceBox(" << halfny << "," << stepangy
    99159       << "=" << Angle(stepangy).ToArcMin() << " ) srcbox:" << endl;
     
    102162
    103163
    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;
    107169  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
    111174      MultiBeamCyl& cyl = GetCylinder(lc);
    112175
    113176      TMatrix< complex<r_4> > & recp = cyl.getRecSrcPlane();
    114177
    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_;
    119180      complex< r_4 > phasefactor;
    120181      int jyy = 0;
     182     
    121183      for(int jy=-halfny; jy<=halfny; jy++) {  // Loop over Y angular steps
    122         for(int ix=0; ix<nx; ix++) {  // Loop over AngX directions
    123           double dphi = facl * sin( (double)jy*stepangy )
    124                         + facl_x*(double(ix)/double(nx)-1./2.);
    125           phasefactor = complex< r_4 > ((r_4) cos(dphi) , (r_4) sin(dphi));
    126           // sur recp : index ligne -> frequence  ,    index colonne -> angX ,
    127           int ixx=(int)(ix*(double)cyl.NR/double(nx));
    128           box(ix, jyy, kf) += recp(kf, ixx)*phasefactor;
    129         }  // 
    130         jyy++;
     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++;
    131193      } // End of Loop over Y angles
    132194    } // End of loop over cylinders
     195
    133196    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) )   
    135199      cout << " OK box(angx,angy, freq=kf) done for kf=" << kf
    136            << " / Max_kf=" << mtx.NRows() << endl;
     200         << " / Max_kf=" << mtx.NRows() << endl;
    137201  } // End of loop over over frequencies
    138202
     
    140204}
    141205
     206//-----------------------------------------------------------------------------
    142207inline float myZmodule(complex<r_4>& z)
    143208{
     
    145210}
    146211
     212//-----------------------------------------------------------------------------
    147213TMatrix< r_4 >  MultiCylinders::getRecXYSlice(int kfmin, int kfmax)
    148214{
     
    158224  return(rmtx);
    159225}
     226//-----------------------------------------------------------------------------
     227TMatrix< 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}
  • trunk/Cosmo/RadioBeam/multicyl.h

    r3191 r3192  
    2828  //   longueur @ f=2 ~ 64 (256*lambda/2 = 256*0.25)
    2929 MultiCylinders(int nr=256, int ns=1024);
     30 MultiCylinders(char* filename);
    3031 ~MultiCylinders();
    3132
    3233 // Niveau de print de debug
    33  inline void SetPrintLevel(int prl=0) { PrtLev=prl; }
     34 inline void SetPrintLevel(int prl=0) { PrtLev_=prl; }
    3435
    35  // Ajout d'un cylindre, en position posY
     36 // Ajout d'un cylindre, en position posX, posY
    3637 inline int AddCylinder(double posx, double posy)
    37    {  mCyl.push_back( new MultiBeamCyl(NR, NS, posx, posy) ); return mCyl.size(); }
     38   {  mCyl_.push_back( new MultiBeamCyl(NR_, NS_, posx, posy) ); return mCyl_.size(); }
    3839
    3940 MultiBeamCyl & GetCylinder(int i);
     
    4142 // Specification de la frequence de base f0 et espacement des recepteurs
    4243 inline void SetBaseFreqDa(double f0=2., double a=0.25)
    43    {  freq0 = f0;   Da = a;  }
     44   {  freq0_ = f0;   Da_ = a;  }
    4445
    4546 // frequences reduites (entre 0 ... 0.5) , angle en radian, amp ~ 1
     
    4950
    5051 // Definition du sigma du bruit gaussien sur les echantillons
    51  inline void SetNoiseSigma(double sig=0.) {  signoise = sig; }
     52 inline void SetNoiseSigma(double sig=0.) {  signoise_ = sig; }
    5253 // Definition du sigma du jitter d'horloge (typ 0.01)
    53  inline void SetTimeJitter(double tjit=0.) { timejitter = tjit; }
     54 inline void SetTimeJitter(double tjit=0.) { timejitter_ = tjit; }
    5455 // Definition du sigma des offsets d'horloge entre recepteurs (typ 0.02)
    55  inline void SetTimeOffsetSigma(double tsig=0.) { toffsig = tsig; }
     56 inline void SetTimeOffsetSigma(double tsig=0.) { toffsig_ = tsig; }
    5657
    5758 // Definition du gain et sigma de fluctuations de gain
    5859 // nzerogain: nb de recepteurs (choisis au hasard) avec gain mis a zero
    5960 inline void SetGains(double g=1., double sigg=0., int nzerogain=0)
    60    {  gain=g;  siggain=sigg;  ngainzero = nzerogain; }
     61   {  gain_=g;  siggain_=sigg;  ngainzero_ = nzerogain; }
    6162
    6263
     
    7273 // @f = 2 , lambda = 0.5 ===> posY <~ lambda/(2 sin resol)
    7374 //   ===> posY < ~ 20   
    74  void ReconstructSourceBox(int halfny=10, double stepangy=M_PI/300);
     75// void ReconstructSourceBox(int halfny=10, double stepangy=M_PI/300);
     76 void ReconstructSourceBox(int halfny, double stepangy, int ny, double stepangx);
    7577
    7678
     
    7880 // avec la moyenne des modules entre kfmin <= k (selon z) <= kfmax
    7981 TMatrix< r_4 > getRecXYSlice(int kfmin, int kfmax);
     82 TMatrix< r_4 > getRecYXSlice(int kfmin, int kfmax);
    8083
    8184 // Acces a la boite 3D de sources reconstruite
    82  inline TArray< complex<r_4> > & getRecSrcBox() { return cmplx_srcbox; }
     85 inline TArray< complex<r_4> > & getRecSrcBox() { return cmplx_srcbox_; }
    8386
    8487 // Configure chaque cylindre a partir des parametres de la classe
     
    8689 void ConfigureCylinders();
    8790
     91private:
    8892 //-------------- Variables membres ------------
    89  int NR, NS;  // nb recepteurs, nb d'echantillons ds chaque paquet
     93 int NR_, NS_;  // nb recepteurs, nb d'echantillons ds chaque paquet
    9094
    91  int PrtLev;   // Niveau de print de debug
     95 int PrtLev_;   // Niveau de print de debug
    9296
    93  double Da; // distance entre recepteurs
    94  double freq0;  // frequence de base (freqvrai=f+freq0)
     97 double Da_; // distance entre recepteurs
     98 double freq0_;  // frequence de base (freqvrai=f+freq0)
    9599 
    96  double timejitter; // le sigma du jitter en temps des coups d'horloge
    97  double toffsig;    // sigma des offsets en temps
     100 double timejitter_; // le sigma du jitter en temps des coups d'horloge
     101 double toffsig_;    // sigma des offsets en temps
    98102 
    99  BRSourceGen* src;  // Les sources
    100  bool adfg; // if true, delete src
     103 BRSourceGen* src_;  // Les sources
     104 bool adfg_; // if true, delete src
    101105
    102  double signoise; // sigma du bruit additif (bruit ampli ... )
    103  double gain, siggain;
    104  int ngainzero;
     106 double signoise_; // sigma du bruit additif (bruit ampli ... )
     107 double gain_, siggain_;
     108 int ngainzero_;
    105109
    106  vector<MultiBeamCyl *> mCyl;  // Les differents cylindres
     110 vector<MultiBeamCyl *> mCyl_;  // Les differents cylindres
    107111
    108  TArray< complex<r_4> > cmplx_srcbox; // boite3D des sources (angX,Y,freq) reconstruit
     112 TArray< complex<r_4> > cmplx_srcbox_; // boite3D des sources (angX,Y,freq) reconstruit
    109113 };
    110114
  • 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.