Changeset 3872 in Sophya for trunk/AddOn/TAcq/brproc.h


Ignore:
Timestamp:
Aug 28, 2010, 12:43:04 AM (15 years ago)
Author:
ansari
Message:

Ajout classe BRFFTCalculator et programme specmfib.cc, Reza 28/08/2010

File:
1 edited

Legend:

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

    r3777 r3872  
    55// Projet BAORadio - (C) LAL/IRFU  2008-2010
    66// Classes de threads de traitememt donnees BAORadio
     7//  Principales classes utilisables
     8//  - BRMeanSpecCalculator (donnees FFT)
     9//  - BRFFTCalculator (donnees RAW)
    710//----------------------------------------------------------------
    811
     
    1922#include "ntuple.h"
    2023#include "datatable.h"
     24#include "FFTW/fftw3.h"
    2125
    2226using namespace std;
    2327
    2428
    25 //---------------------------------------------------------------------
    26 // Classe de traitement - calcul de visibilite pour n fibres
    27 //---------------------------------------------------------------------
    28 class BRVisibilityCalculator : public BRBaseProcessor, ParallelTaskInterface {
    29 public:
    30   BRVisibilityCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000, size_t nthr=1);
    31   virtual ~BRVisibilityCalculator(); // Fait le nettoyage final , sauvegarde des objets ...
    32 
    33   // Pour definir le rang de l'objet lors d'un traitement avec plusieurs BRVisibilityCalculator en //
    34   void DefineRank(uint_4 nbc, uint_4 cid);
    35 
    36   // Pour limiter le calcul des visibilites a certaines fibres
    37   uint_4 SelectPairs(uint_4 pair1=0, uint_4 nbpairs=99999999);
    38   // pour definir le binning en frequence pour la VisibDataTable
    39   int SelectFreqBinning(uint_4 freq1=0, uint_4 freq2=0, uint_4 nbfreq=1);
    40 
    41   // Pour activer la verification des timetag
    42   // Creation / sauvegarde d'une matrice de TimeTag / FrameCounter avec NCols=maxnpaq (nb de paquets/trigger) 
    43   int ActivateTimeTagCheck(uint_8 maxnpaq);
    44 
    45   // Methode d'execution standard du thread (on redefinit la methode de BRBaseProcessor)
    46   virtual void run(); 
    47   // Methode de la classe ParallelTaskInterface
    48   virtual int    execute(int tid);
    49 
    50   // Le nombre total d'operations effectuees
    51   inline r_8 TotNbFLOP() { return nb_flop_; }
    52 
    53 protected:
    54   virtual int Process();
    55   virtual int FillVisibTable(double fcm, double ttm);
    56   virtual int CheckTimeTag();
    57 
    58   ParallelExecutor paralex_;  // Pour l'execution en parallele 
    59   size_t nparthr_;
    60 
    61   uint_4 nmean_;  // Nombre de spectres pour le calcul des moyennes
    62   string outpath_;  // directory pour fichiers de sortie
    63   uint_4 nbcalc_, calcid_;  // Nombre total de threads/objets BRVisibilityCalculator parallèles, l'identificateur de l'objet 
    64 
    65   uint_4 pairst_, nbpairs_;   // Numero de la premiere paire, nombre de paires
    66   uint_4 jf1_,jf2_,djf_;  // binning en frequence pour la datatable
    67 
    68   vector<TwoByteComplex*> vpdata_;
    69   bool* fgallfibok; 
    70 
    71   double moyfc_, moytt_;
    72   TMatrix< complex<r_4> > vismtx_;
    73   TVector< uint_4 > chanum_;
    74   //  FitsInOutFile dtfos_;
    75   DataTable visdt_;
    76 
    77   uint_4 numfile_;
    78   uint_8 totnbpaq_;
    79 
    80   r_8 nb_flop_;   // Nombre total d'operations effectuees
    81 
    82   // Variables/objets pour la verifications des timetag
    83   bool fgcktt_;  // true -> checktimetag
    84   int_8 mindeltatt_;       // difference minimum de deux timetag successifs
    85   TMatrix< uint_8 > fcmtx_; // matrices des framecounters
    86   TMatrix< uint_8 > ttmtx_; // matrices des timetag
    87   vector< uint_8 > vlasttt_;  // dernieres valeurs de TimeTag / fibre
    88   vector< uint_8 > vbadtt_;  // Number of bad TimeTag paquets per fiber
    89   vector< uint_8 > vnsamett_;  // Number of paquets having TimeTag <> TT_Fiber1 per fiber
    90   vector< uint_8 > vndiff5tt_;  // Number of paquets having |TimeTag-TT_Fiber1|>5 per fiber
    91 
    92 };
    93 
    94 
    95 //-------------------------------------------------------------------------------
    96 // Classe Groupe (ensemble) de Calculateur de Visibilites, tourant en parallele
    97 //-------------------------------------------------------------------------------
    98 
    99 class BRVisCalcGroup {
    100 public:
    101   BRVisCalcGroup(size_t nbcalc, RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000, size_t nthr=1);
    102   ~BRVisCalcGroup();
    103   int SelectFreqBinning(uint_4 freq1=0, uint_4 freq2=0, uint_4 nbfreq=1);
    104   inline int ActivateTimeTagCheck(uint_8 maxnpaq)
    105   { return viscalcp_[0]->ActivateTimeTagCheck(maxnpaq); }
    106 
    107   void start();
    108   void join();
    109 protected:
    110   vector<BRVisibilityCalculator *> viscalcp_;
    111   Timer tm_;
    112 };
    11329 
    11430//---------------------------------------------------------------------
    11531// Classe de traitement simple - calcul de spectres moyennes / voie
     32// a partir de donnees de type FFT (firmware FFT)
    11633//---------------------------------------------------------------------
    11734class BRMeanSpecCalculator : public BRBaseProcessor
    11835{
    11936public:
    120   BRMeanSpecCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000);
     37  BRMeanSpecCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000,
     38                       bool fgdatafft=true, bool fgsinglechan=false);
    12139  virtual ~BRMeanSpecCalculator(); // Fait le nettoyage final , sauvegarde des objets ...
    12240
    12341protected:
    12442  virtual int Process();
     43  virtual void SaveSpectra();
    12544
    12645  uint_4 nmean_;  // Nombre de spectres pour le calcul des moyennes
    12746  string outpath_;  // directory pour fichiers de sortie
     47  bool fgdatafft_;
     48  bool fgsinglechannel_;
    12849  uint_4 numfile_;
     50  uint_8 nbpaq4mean_;
    12951
    13052  uint_8 totnbpaq_;
    13153  TMatrix< r_4 > mspecmtx_;    // Matrice des spectres moyennees
    13254};
     55
     56//-------------------------------------------------------------------------
     57// Classe WBRFFT : Calcul de TF sur donnees brutes (firmware RAW)
     58//   en utilisant FFTW et en effectuant une copie ds tableau local
     59//-------------------------------------------------------------------------
     60typedef unsigned char IDT ;   // definition type de donnees en entree de WBRFFT
     61typedef int_2  IIDT ;      // definition type de donnees intermediaire
     62typedef float  ODT;  // type de donnees en sortie (complex < ODT > )
     63//----Classe WBRFFT----
     64class WBRFFT {
     65public:
     66  WBRFFT(uint_4 sz=0);
     67  virtual ~WBRFFT();
     68
     69  void SetInDataSize(uint_4 sz);
     70  void DoFFT(IDT *indata, complex<ODT> * ofc);
     71  static void PrintData(IDT *indata,  complex<ODT> * ofc, uint_4 sz);
     72
     73  uint_4 sz_;   // Taille tableau d'entree
     74  TVector< ODT > inp;
     75  TVector< complex<ODT> > outfc;
     76  fftwf_plan myplan_;
     77  static ZMutex* mtx_fftwp_;  // Mutex de protection pour la creation du plan fftw
     78};
     79//--------------------
     80
     81//---------------------------------------------------------------------
     82// Classe de thread de calcul de FFT sur donnees RAW
     83//---------------------------------------------------------------------
     84class BRFFTCalculator : public BRBaseProcessor
     85{
     86public:
     87  BRFFTCalculator(RAcqMemZoneMgr& memgr, bool fgsinglechannel=false);
     88  virtual ~BRFFTCalculator(); // Fait le nettoyage final , sauvegarde des objets ...
     89
     90protected:
     91  virtual int Process();
     92 
     93  bool fgsinglechannel_;
     94  uint_8 totnbfftpaq_;
     95  WBRFFT ffts_;
     96};
     97
    13398
    13499//-------------------------------------------------------------------------
     
    151116  o card : numero de carte , juste pour les impressions
    152117*/
    153 class BRProcA2C : public ZThread {
     118class BRProcA2C : public ZThread {   // !!!! OBSOLETE  !!!!
    154119public:
    155120  BRProcA2C(RAcqMemZoneMgr& mem, string& path, bool fgraw,
     
    174139//---------------------------------------------------------------------
    175140// Classe thread de traitement 2 x 2 voies/paquet (Apres BRProcA2C)
     141//         !!!! OBSOLETE  !!!!   
    176142//---------------------------------------------------------------------
    177143/*-- Arguments du constructeur :
     
    184150*/
    185151
    186 class BRProcB4C : public ZThread {
     152class BRProcB4C : public ZThread {  //   !!!! OBSOLETE  !!!!   
     153
    187154public:
    188155  BRProcB4C(RAcqMemZoneMgr& mem1, RAcqMemZoneMgr& mem2, string& path,
Note: See TracChangeset for help on using the changeset viewer.