Changeset 3646 in Sophya for trunk/AddOn/TAcq


Ignore:
Timestamp:
Jun 9, 2009, 11:50:46 PM (16 years ago)
Author:
ansari
Message:

Ajout du programme svv2mtx.cc de lecture des fichiers de mcrd.cc pour faire des tableaux 2D (matrices) temps-frequence + corrections mineures, Reza 09/06/2009

Location:
trunk/AddOn/TAcq
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/brfitsrd.cc

    r3640 r3646  
    4242    TimeStamp ts;
    4343    Timer tm("BRFitsReader", false);
    44     BRPaqChecker pcheck(~fgnotrl_);  // Verification/comptage des paquets
     44    BRPaqChecker pcheck(!fgnotrl_);  // Verification/comptage des paquets
    4545   
    4646    size_t totnbytesrd = 0;
     
    7272      if (fgnotrl_) {
    7373        incpaqsz=16;
    74         cout << " Warning : FITS files without frame trailers ..." << endl;
     74        if (ifile==0) cout << " Warning : FITS files without frame trailers ..." << endl;
    7575      }
    7676      if (paqsz == 0)  {  // premier passage, on fixe la taille de paquet et on verifie compatibilite avec memgr
  • trunk/AddOn/TAcq/brproc.cc

    r3645 r3646  
    99#include "pexceptions.h"
    1010#include "tvector.h"
     11#include "ntuple.h"
    1112#include "fioarr.h"
    1213#include "timestamp.h"
     
    6364    Timer tm("BRProcARaw2C", false);
    6465    TimeStamp ts;
    65     BRPaqChecker pcheck(~fgnotrl_);  // Verification/comptage des paquets
     66    BRPaqChecker pcheck(!fgnotrl_);  // Verification/comptage des paquets
    6667   
    6768    size_t totnbytesout = 0;
     
    7778//    filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl;       
    7879
     80// NTuple
     81    const char* nnames[8] = {"fcs","tts","s1","s2","s12","s12re","s12im","s12phi"};
     82    NTuple nt(8, nnames);
     83    double xnt[10];
     84    uint_4 nmnt = 0;
     85    double ms1,ms2,ms12,ms12re,ms12im,ms12phi;
    7986// Initialisation pour calcul FFT
    8087    TVector< complex<r_4> > cfour1;  // composant TF
    8188    uint_4 paqsz = memgr.PaqSize();
    8289    uint_4 procpaqsz = memgr.ProcPaqSize();
     90   
     91   
    8392    BRPaquet pq(NULL, NULL, paqsz);
    8493    TVector<r_4> vx(pq.DataSize()/2);
     
    8695    FFTPackServer ffts;
    8796    ffts.FFTForward(vx, cfour1);
     97//    cfour1.SetSize((paqsz-40)/2+1);
    8898    TVector< complex<r_4> > cfour2(cfour1.Size());
    8999   
     
    92102    TVector< complex<r_4> > visiV12( cfour1.Size() );
    93103
     104    cout << " *DBG*BRProcARaw2C PaqSz=" << paqsz << " ProcPaqSize=" << procpaqsz
     105         << " procpaqsz/2=" << procpaqsz/2 << " cfour1.Size()=" << cfour1.Size()
     106         << " *8="  << cfour1.Size()*8 << endl;
    94107
    95108    fftwf_plan plan1 = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(),
     
    99112
    100113    uint_4 ifile = 0;                           
    101     uint_4 nzm = 0;
     114    uint_4 nzm = 0; 
    102115    for (uint_4 kmz=0; kmz<nmax_; kmz++) {
    103116      if (stop_) break;
     
    113126        break; 
    114127      }
    115 
     128      nmnt=0;  ms1=ms2=ms12=ms12re=ms12im=ms12phi=0.;
    116129      for(uint_4 i=0; i<memgr.NbPaquets(); i++) {
    117130            BRPaquet paq(NULL, buff+i*paqsz, paqsz);
    118131        if (!pcheck.Check(paq)) continue;   // on ne traite que les paquets OK
    119 
     132       
    120133// Traitement voie 1       
    121           for(sa_size_t j=0; j<vx.Size(); j++)
    122             vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
     134            for(sa_size_t j=0; j<vx.Size(); j++)
     135              vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
    123136//        fftwf_complex* coeff1 = (fftwf_complex*)(procbuff+i*procpaqsz);
    124           fftwf_execute(plan1);
    125 //        complex<r_4>* zp1 = (complex<r_4>*)(coeff1);
     137            fftwf_execute(plan1);
     138//        complex<r_4>* zp1 = (complex<r_4>*)(vx.Data());
    126139//        ffts.FFTForward(vx, cfour1);
    127140        for(sa_size_t j=0; j<spectreV1.Size(); j++)
     
    129142        memcpy(procbuff+i*procpaqsz, cfour1.Data(), sizeof(complex<r_4>)*cfour1.Size());
    130143// Traitement voie 2       
    131         for(sa_size_t j=0; j<vx.Size(); j++)
    132           vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
    133 
    134         fftwf_execute(plan2);
    135 
     144            for(sa_size_t j=0; j<vx.Size(); j++)
     145              vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
     146
     147        fftwf_execute(plan2);
    136148        for(sa_size_t j=0; j<spectreV2.Size(); j++)
    137149          spectreV2(j) += Zmod2(cfour2(j));  // Zmod2(zp2[j]);
     
    143155//        for(sa_size_t j=0; j<visiV12.Size(); j++) visiV12(j)+=zp1[j]*zp2[j];
    144156        nzm++;   
     157        if (nmnt==0)  { xnt[0]=paq.FrameCounter();  xnt[1]=paq.TimeTag(); }
     158        for(sa_size_t j=2700; j<2800; j++) {
     159          ms1 += Zmod2(cfour1(j)); ms2 += Zmod2(cfour2(j));
     160          complex<r_4> zvis =  cfour1(j)*conj(cfour2(j));
     161          ms12 += Zmod2(zvis);   ms12re += zvis.real();  ms12im += zvis.imag();
     162          ms12phi+= atan2(zvis.imag(),zvis.real());
     163        }
     164        nmnt++;   
    145165        totnbytesproc += paq.DataSize();
    146166        totnbytesout += (2*sizeof(complex<r_4>)*cfour1.Size());
    147167
    148168      } // Fin de boucle sur les paquets d'une zone
     169      if (nmnt>0)  {
     170        double fnorm = (double)nmnt*(2800-2700);
     171        xnt[2] = ms1 /= fnorm;
     172        xnt[3] = ms2 /= fnorm;
     173        xnt[4] = ms12 /= fnorm;
     174        xnt[5] = ms12re /= fnorm;
     175        xnt[6] = ms12im /= fnorm;
     176        xnt[7] = ms12phi /= fnorm;
     177        nt.Fill(xnt);
     178      }
    149179      if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) {
    150180        spectreV1 /= (r_4)(nzm);
     
    184214  cout << " ------------  BRProcARaw2C::run() END " << card2name_(card_)
    185215       << " ------------ " << endl;
     216  {     
     217  cout << nt;
     218  sprintf(fname,"%s_nt.ppf",path_.c_str());
     219  POutPersist po(fname);
     220  po << PPFNameTag("ntv12") << nt;
     221  cout << " BRProcARaw2C::run() created NTuple file " << fname << card2name_(card_) << endl;
     222  }     
    186223  ts.SetNow();
    187224  tm.SplitQ();
     
    240277    Timer tm("BRProcBRaw4C", false);
    241278    TimeStamp ts;
    242     BRPaqChecker pcheck1(~fgnotrl_);  // Verification/comptage des paquets
    243     BRPaqChecker pcheck2(~fgnotrl_);  // Verification/comptage des paquets
     279    BRPaqChecker pcheck1(!fgnotrl_);  // Verification/comptage des paquets
     280    BRPaqChecker pcheck2(!fgnotrl_);  // Verification/comptage des paquets
    244281
    245282    size_t totnbytesout = 0;
     
    261298
    262299    TVector< complex<r_4> > cfour;  // composant TF
    263     BRPaquet pq(NULL, NULL, paqsz);
     300/*   
     301    BRPaquet pq(NULL, NULL, paqsz);     
    264302    TVector<r_4> vx(pq.DataSize()/2);
    265303    vx = (r_4)(0.);
     
    271309    TVector< complex<r_4> > visiV23( cfour.Size() );
    272310    TVector< complex<r_4> > visiV24( cfour.Size() );
     311*/
     312    int szfour = (paqsz-40)/2+1;
     313    TVector< complex<r_4> > visiV13( szfour  );
     314    TVector< complex<r_4> > visiV14( szfour );
     315    TVector< complex<r_4> > visiV23( szfour );
     316    TVector< complex<r_4> > visiV24( szfour );
     317    // cout << " *DBG*AAAAA ---- Vectors OK" << endl;
     318    cout << " *DBG*BRProcBRaw4C PaqSz=" << paqsz << " ProcPaqSize=" << procpaqsz
     319         << " procpaqsz/2=" << procpaqsz/2 << " cfour.Size()=" << szfour
     320         << " *8="  << szfour*8 << endl;
    273321
    274322    uint_4 nzm = 0;
     
    281329      uint_4 nokpaq = 0;
    282330      if (stop_) break;
     331       // cout << " *DBG*BBBBB" << kmz << endl;
     332
    283333      int mid1 = memgr1.FindMemZoneId(MemZA_ProcB);
    284334      Byte* buff1 = memgr1.GetMemZone(mid1);
     
    305355      uint_4 i1,i2;
    306356      i1=i2=0;
     357//      cout << " *DBG*CCCCCC " << kmz << " memgr1.NbPaquets() =" << memgr1.NbPaquets() << endl;
    307358      while((i1<memgr1.NbPaquets())&&(i2<memgr2.NbPaquets())) {
    308359        BRPaquet paq1(NULL, buff1+i1*paqsz, paqsz);
     
    320371// <<","<<paq2.FrameCounter()<<endl;
    321372
     373        if ((i1>=memgr1.NbPaquets())||(i2>=memgr1.NbPaquets())) {
     374          cout << " *BUG*BUG i1=" << i1 << " i2=" << i2 << endl;
     375          break;
     376        }
    322377        // Les deux framecounters sont identiques ...
    323378        noksfc++;
     
    335390        totnbytesproc += 2*paq1.DataSize();
    336391      } // Fin de boucle sur les paquets d'une zone
     392      memgr1.FreeMemZone(mid1, MemZS_ProcB);
     393      memgr2.FreeMemZone(mid2, MemZS_ProcB);
     394
    337395      if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) {
    338396        visiV13 /= complex<r_4>((r_4)nzm, 0.);
     
    357415        visiV23 = complex<r_4>(0., 0.);
    358416        visiV24 = complex<r_4>(0., 0.);
    359         nzm = 0; 
     417        nzm = 0;  ifile++;
    360418//        ts.SetNow();
    361419//        filog << ts << " :  proc file  " << fname << endl;                   
    362420        cout << " BRProcBRaw4C::run() created file  " << fname << endl;
    363421      }   
    364       memgr1.FreeMemZone(mid1, MemZS_ProcB);
    365       memgr2.FreeMemZone(mid2, MemZS_ProcB);
    366422      double okfrac = (nokpaq>1)?((double)noksfc/(double)nokpaq*100.):0.;
    367       cout << "BRProcBRaw2C ["<<kmz<<"] NOKPaq=" << nokpaq << " NSameFC=" << noksfc
     423      cout << "BRProcBRaw4C ["<<kmz<<"] NOKPaq=" << nokpaq << " NSameFC=" << noksfc
    368424           << " (" << okfrac << " %)" << endl;
    369425      totnokpaq += nokpaq;
  • trunk/AddOn/TAcq/makefile

    r3645 r3646  
    22
    33# all : traidio  tmtfft tstminifits tbrpaq tpciew tmtacq tstrdfits mfits2spec tsok
    4 all : traidio  tmtfft tstminifits tmtacq tstrdfits mfits2spec tsok mcrd
     4# all : traidio  tmtfft tstminifits tmtacq tstrdfits mfits2spec tsok mcrd
     5all : traidio tstminifits tmtacq mfits2spec mcrd svv2mtx
    56
    67clean :
    7         rm -f *.o traidio tmtfft tstminifits tpciew tbrpaq tmtacq tstrdfits mfits2spec mcrd
     8        rm -f *.o traidio tmtfft tstminifits tpciew tbrpaq tmtacq tstrdfits mfits2spec mcrd svv2mtx
    89        rm -f mfits2spec tsok *.ppf *.fits
    910
     
    4041        $(CXXCOMPILE) -c  -o brproc.o brproc.cc
    4142
     43##   --------------
     44svv2mtx : svv2mtx.o
     45        $(CXXLINK) -o svv2mtx svv2mtx.o  $(SOPHYAEXTSLBLIST)
     46
     47svv2mtx.o : svv2mtx.cc
     48        $(CXXCOMPILE) -o svv2mtx.o svv2mtx.cc
    4249
    4350##   --------------
  • trunk/AddOn/TAcq/mcrd.cc

    r3645 r3646  
    8383    string act = arg[1];
    8484    bool fg4c=false;  // true -> 4 channels (2 fibers)
    85     bool fgrdfits=false;  // false -> Don't read fits files, generate paquets
     85    bool fgrdfits=true;  // false -> Don't read fits files, generate paquets
    8686    bool fgnotrl=false;   // true -> fichier fits SANS Trailer de frame (< mai 2009)
    8787    if (act.substr(0,2)=="-4") fg4c=true;
     
    242242
    243243  cout << " mcrd/Proc2FRawAB: Starting threads (reader1,2, procA1,2, procAB) ... " << endl;
    244 
     244//  cout << "[1]--- CR to continue ..." << endl;   char ans[32]; gets(ans);
    245245  if (fgrdfile) {
    246246    reader1.start();
     
    251251    pcird2.start();
    252252  }
     253//  sleep(1);  mmgr1.Print(cout);  mmgr2.Print(cout);
    253254  proc1.start();
    254255  proc2.start();
Note: See TracChangeset for help on using the changeset viewer.