Changeset 3652 in Sophya for trunk/AddOn


Ignore:
Timestamp:
Jun 15, 2009, 10:57:12 AM (16 years ago)
Author:
ansari
Message:

Ajout calcul histogramme des valeurs echantillons en temps, Reza 15/06/2009

Location:
trunk/AddOn/TAcq
Files:
3 edited

Legend:

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

    r3651 r3652  
    1111#include "ntuple.h"
    1212#include "datatable.h"
     13#include "histos.h"
    1314#include "fioarr.h"
    1415#include "timestamp.h"
     
    3435/* --Methode-- */
    3536BRProcARaw2C::BRProcARaw2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean,
    36                            uint_4 nmax, bool fgnotrl, int card)
     37                           uint_4 nmax, bool fghist, bool fgnotrl, int card)
    3738  :  memgr(mem)
    3839{
     
    4243  path_ = path;
    4344  fgnotrl_ = fgnotrl;
     45  fghist_ = fghist;
    4446  card_ = card;
    4547  if (pmutfftw==NULL) pmutfftw=new ZMutex; 
     
    9092    double ms1,ms2,ms12,ms12re,ms12im,ms12phi;
    9193----*/
     94// Time sample histograms
     95   Histo h1(-0.5, 255.5, 256);
     96   Histo h2(-0.5, 255.5, 256);
    9297// Initialisation pour calcul FFT
    9398    TVector< complex<r_4> > cfour1;  // composant TF
     
    152157        curtt=paq.TimeTag()-firsttt;
    153158// Traitement voie 1       
    154             for(sa_size_t j=0; j<vx.Size(); j++)
    155               vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
     159        if (fghist_) {
     160          for(sa_size_t j=0; j<vx.Size(); j++) {
     161            r_4 vts=(r_4)(*(paq.Data1()+j));
     162            h1.Add((r_8)vts);
     163            vx(j) = vts-127.5;
     164          }
     165        }
     166        else {
     167          for(sa_size_t j=0; j<vx.Size(); j++)
     168            vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
     169        }
    156170//        fftwf_complex* coeff1 = (fftwf_complex*)(procbuff+i*procpaqsz);
    157171            fftwf_execute(plan1);
     
    162176        memcpy(procbuff+i*procpaqsz, cfour1.Data(), sizeof(complex<r_4>)*cfour1.Size());
    163177// Traitement voie 2       
    164             for(sa_size_t j=0; j<vx.Size(); j++)
    165               vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
    166 
     178        if (fghist_) {
     179          for(sa_size_t j=0; j<vx.Size(); j++) {
     180            r_4 vts=(r_4)(*(paq.Data2()+j));
     181            h2.Add((r_8)vts);
     182            vx(j) = vts-127.5;
     183          }
     184        }
     185        else {
     186          for(sa_size_t j=0; j<vx.Size(); j++)
     187            vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
     188        }
    167189        fftwf_execute(plan2);
    168190        for(sa_size_t j=0; j<spectreV2.Size(); j++)
     
    225247        spectreV2.Info()["EndTT"] = curtt;
    226248        visiV12.Info()["EndTT"] = curtt;
    227             {
     249        {
    228250        sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile);
    229251        POutPersist po(fname);
     
    231253        string tag2="specV2";
    232254        string tag12="visiV12";
     255        string tagh1="tshV1";
     256        string tagh2="tshV2";
    233257        if (card_==2) {
    234258          tag1 = "specV3";
    235259          tag2 = "specV4";
     260          tagh1 = "tshV1";
     261          tagh2 = "tshV2";
    236262          tag12="visiV34";
    237263        }
     
    239265        po << PPFNameTag(tag2) << spectreV2;
    240266        po << PPFNameTag(tag12) << visiV12;
    241             }
     267        if (fghist_) {
     268          po << PPFNameTag(tagh1) << h1;
     269          po << PPFNameTag(tagh2) << h2;
     270        }
     271        }
    242272        spectreV1 = (r_4)(0.);
    243273        spectreV2 = (r_4)(0.);
    244274        visiV12 = complex<r_4>(0., 0.);
     275        if (fghist_) {
     276          h1.Zero();
     277          h2.Zero();
     278        }
    245279        nzm = 0;  ifile++;
    246280//        ts.SetNow();
  • trunk/AddOn/TAcq/brproc.h

    r3645 r3652  
    2323// Classe thread de traitement avec 2 voies par frame (donnees brutes)
    2424//---------------------------------------------------------------------
     25
     26/*-- Arguments du constructeur :
     27  o mem : gestionnaire zones memoires avec contenant les "frames" avec 2 voies/frame
     28  o path : Chemin et nom des fichiers PPF produits (on ajoute _numero.ppf )
     29  o nmean : Nombre de frame (paquets) moyennes
     30  o nmax : Nombre maxi de frames traites
     31  o fghist = true -> fait aussi l'histo des valeurs des echantillons temps
     32  o fgnotrl = true -> fichiers fits / paquets sans trailer
     33  o card : numero de carte , juste pour les impressions
     34*/
    2535class BRProcARaw2C : public ZThread {
    2636public:
    2737  BRProcARaw2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean=10,
    28                uint_4 nmax=100, bool fgnotrl=false, int card=1);
     38               uint_4 nmax=100, bool fgtshist=false, bool fgnotrl=false, int card=1);
    2939  virtual void run();
    3040  void Stop();
     
    3646  uint_4 nmean_;  // Nombre de blocs pour le calcul des moyennes
    3747  string path_; 
     48  bool fghist_;   // if true, fill and save histogram with time sample values
    3849  bool fgnotrl_;   // if true, don't check packet trailer - when using pre-june fits files
    3950  int card_;   // Numeros de voies 2*card_-1, 2*card_
     
    4354// Classe thread de traitement 2 x 2 voies/frames (Apres BRProcARaw2C)
    4455//---------------------------------------------------------------------
     56/*-- Arguments du constructeur :
     57  o mem1,mem2 : gestionnairea zones memoires avec contenant les donnees des 4 voies (2 voies/frame)
     58  o path : Chemin et nom des fichiers PPF produits (on ajoute _numero.ppf )
     59  o nmean : Nombre de frame (paquets) moyennes
     60  o nmax : Nombre maxi de frames traites
     61  o fgnotrl = true -> fichiers fits / paquets sans trailer
     62  o card : numero de carte , juste pour les impressions
     63*/
     64
    4565class BRProcBRaw4C : public ZThread {
    4666public:
  • trunk/AddOn/TAcq/mcrd.cc

    r3650 r3652  
    6161static int GPaqSz=16424;
    6262static double LossRate=0.1;
     63
     64static bool fg4c=false;  // true -> 4 channels (2 fibers)
     65static bool fgrdfits=true;  // false -> Don't read fits files, generate paquets
     66static bool fgnotrl=false;   // true -> fichier fits SANS Trailer de frame (< mai 2009)
     67static bool fghist=false;   // true -> histo des valeurs des time sample
     68
    6369// ----
    6470int Usage(bool fgshort=true);
    6571// Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW)
    66 int Proc1FRawA(string& outname, string& inpath, int jf1, int jf2, bool fgnotrl=false,
    67                bool fgrdfile=true);
     72int Proc1FRawA(string& outname, string& inpath, int jf1, int jf2);
    6873// Pour traitement (calcul FFT et visibilites (ProcA,ProcB) 2 fibre, 4 voies RAW)
    69 int Proc2FRawAB(string& outname, string& path1, string& path2, int jf1, int jf2,
    70                 bool fgnotrl=false, bool fgrdfile=true);
     74int Proc2FRawAB(string& outname, string& path1, string& path2, int jf1, int jf2);
    7175
    7276//----------------------------------------------------
     
    8286  try {
    8387    string act = arg[1];
    84     bool fg4c=false;  // true -> 4 channels (2 fibers)
    85     bool fgrdfits=true;  // false -> Don't read fits files, generate paquets
    86     bool fgnotrl=false;   // true -> fichier fits SANS Trailer de frame (< mai 2009)
     88    fg4c=false;  // true -> 4 channels (2 fibers)
     89    fgrdfits=true;  // false -> Don't read fits files, generate paquets
     90    fgnotrl=false;   // true -> fichier fits SANS Trailer de frame (< mai 2009)
     91    fghist=false;   // true -> histo des valeurs des time sample
    8792    if (act.substr(0,2)=="-4") fg4c=true;
    88     if (act.substr(2)=="g")  fgrdfits=false;
    89     else if (act.substr(2)=="nt")  fgnotrl=true;
     93    if (act.length()>2) {
     94      for(size_t ks=2; ks<act.length(); ks++) {
     95        if(act[ks]=='g') fgrdfits=false;
     96        else if(act[ks]=='n') fgnotrl=true;
     97        else if(act[ks]=='h') fghist=true;
     98      }
     99    }
    90100    if (fg4c && (narg<6)) return Usage(true);
    91101
     
    107117    ResourceUsage resu;
    108118    if (fg4c)
    109       rc =  Proc2FRawAB(outname, inpath, inpath2, imin, imax, fgnotrl, fgrdfits);
     119      rc =  Proc2FRawAB(outname, inpath, inpath2, imin, imax);
    110120    else
    111       rc =  Proc1FRawA(outname, inpath, imin, imax, fgnotrl, fgrdfits);
     121      rc =  Proc1FRawA(outname, inpath, imin, imax);
    112122    cout << resu ;
    113123  }
     
    135145
    136146// Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW)
    137 int Proc1FRawA(string& outname, string& inpath, int imin, int imax,
    138                bool fgnotrl, bool fgrdfile)
     147int Proc1FRawA(string& outname, string& inpath, int imin, int imax)
    139148{
    140149  vector<string> infiles;
     
    146155  uint_4 nmaxz;
    147156  uint_4 paqsz, npaqf;
    148   if (fgrdfile) {
     157  if (fgrdfits) {
    149158    DecodeMiniFitsHeader(infiles[0],paqsz, npaqf, fgnotrl);
    150159    nmaxz = infiles.size()*npaqf/NPaqinZone;
     
    167176
    168177  outname += "/Ch12";
    169   BRProcARaw2C proc(mmgr, outname, NMean, nmaxz, fgnotrl);
     178  BRProcARaw2C proc(mmgr, outname, NMean, nmaxz, fghist, fgnotrl);
    170179
    171180  cout << " mcrd/Proc1FRawA: Starting threads (reader, proc) ... " << endl;
    172181
    173   if (fgrdfile) reader.start();
     182  if (fgrdfits) reader.start();
    174183  else pcird.start();
    175184
     
    177186  sleep(1);
    178187  cout << " mcrd/Proc1FRawA: Waiting for reader thread to finish ... " << endl;
    179   if (fgrdfile) reader.join();
     188  if (fgrdfits) reader.join();
    180189  else pcird.join();
    181190  cout << " mcrd/Proc1FRawA: Reader finished, waiting for process thread to finish ... " << endl;
     
    189198
    190199// Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW)
    191 int Proc2FRawAB(string& outname, string& path1, string& path2, int imin, int imax,
    192                bool fgnotrl, bool fgrdfile)
     200int Proc2FRawAB(string& outname, string& path1, string& path2, int imin, int imax)
    193201{
    194202  vector<string> infiles1;
     
    203211  uint_4 nmaxz;
    204212  uint_4 paqsz, npaqf;
    205   if (fgrdfile) {
     213  if (fgrdfits) {
    206214    DecodeMiniFitsHeader(infiles1[0],paqsz, npaqf, fgnotrl);
    207215    nmaxz = infiles1.size()*npaqf/NPaqinZone;
     
    235243  string outname1 = outname;
    236244  outname1 += "/Ch12";
    237   BRProcARaw2C proc1(mmgr1, outname1, NMean, nmaxz, fgnotrl);
     245  BRProcARaw2C proc1(mmgr1, outname1, NMean, nmaxz, fghist, fgnotrl);
    238246  string outname2 = outname;
    239247  outname2 += "/Ch34";
    240   BRProcARaw2C proc2(mmgr2, outname2, NMean, nmaxz, fgnotrl,2);
     248  BRProcARaw2C proc2(mmgr2, outname2, NMean, nmaxz, fghist, fgnotrl,2);
    241249  string outname12 = outname;
    242250  outname12 += "/Ch1234";
     
    245253  cout << " mcrd/Proc2FRawAB: Starting threads (reader1,2, procA1,2, procAB) ... " << endl;
    246254//  cout << "[1]--- CR to continue ..." << endl;   char ans[32]; gets(ans);
    247   if (fgrdfile) {
     255  if (fgrdfits) {
    248256    reader1.start();
    249257    reader2.start();
     
    260268  sleep(1);
    261269  cout << " mcrd/Proc2FRawAB: Waiting for reader threads to finish ... " << endl;
    262   if (fgrdfile) {
     270  if (fgrdfits) {
    263271    reader1.join();
    264272    reader2.join();
     
    291299    return 1;
    292300  }
    293   cout << " ACT= -2 , -2g , -2nt -> 1 fiber, 2 raw channel processing (ProcA)\n"
    294        << " ACT= -4 , -4g , -4g , -4nt -> 2 fibers, 4 raw channels (ProcA, ProcB)\n"
    295        << "   nt (notrl) -> FITS files without frame trailer \n"
    296        << "   g (generate paquets) -> generate paquets instead of reading fits files" <<endl;
     301  cout << " ACT= -2[ghn] -> 1 fiber, 2 raw channel processing (ProcA)\n"
     302       << " ACT= -4[ghn] -> 2 fibers, 4 raw channels (ProcA, ProcB)\n"
     303       << "   n (notrl) -> FITS files without frame trailer \n"
     304       << "   g (generate paquets) -> generate paquets instead of reading fits files\n"
     305       << "   h (time sample histograms) -> compute time sample histograms also \n"
     306       << "   Example: ACT = -2h  1 fiber, 2 raw channels and compute time sample histograms" <<endl;
    297307  cout << " OutPath : Output directory name " << endl;
    298308  cout << " InPath [InPath2] Imin,Imax: Input fits files directory name(s)\n"
Note: See TracChangeset for help on using the changeset viewer.