| 1 | #ifndef  BRVISCALC_H_SEEN
 | 
|---|
| 2 | #define  BRVISCALC_H_SEEN
 | 
|---|
| 3 | 
 | 
|---|
| 4 | //----------------------------------------------------------------
 | 
|---|
| 5 | // Projet BAORadio - (C) LAL/IRFU  2008-2010
 | 
|---|
| 6 | // Classes de threads de calcul de visibilites pour BAORadio 
 | 
|---|
| 7 | //  Principales classes utilisables 
 | 
|---|
| 8 | //  - BRVisibilityCalculator (donnees FFT)
 | 
|---|
| 9 | //  - BRVisCalcGroup  
 | 
|---|
| 10 | //----------------------------------------------------------------
 | 
|---|
| 11 | 
 | 
|---|
| 12 | #include <string>
 | 
|---|
| 13 | #include <vector>
 | 
|---|
| 14 | #include <iostream>
 | 
|---|
| 15 | 
 | 
|---|
| 16 | // --- include SOPHYA
 | 
|---|
| 17 | #include "machdefs.h"
 | 
|---|
| 18 | #include "sopnamsp.h"
 | 
|---|
| 19 | #include "tvector.h"
 | 
|---|
| 20 | #include "parlex.h"
 | 
|---|
| 21 | #include "datatable.h"
 | 
|---|
| 22 | #include "ctimer.h"
 | 
|---|
| 23 | 
 | 
|---|
| 24 | //--- include BAORadio 
 | 
|---|
| 25 | #include "racqumem.h"
 | 
|---|
| 26 | #include "brpaqu.h"
 | 
|---|
| 27 | #include "brbaseproc.h"
 | 
|---|
| 28 | 
 | 
|---|
| 29 | using namespace std;
 | 
|---|
| 30 | 
 | 
|---|
| 31 | //---------------------------------------------------------------------
 | 
|---|
| 32 | // Classe de traitement - calcul de visibilite pour n fibres 
 | 
|---|
| 33 | //---------------------------------------------------------------------
 | 
|---|
| 34 | class BRVisibilityCalculator : public BRBaseProcessor, ParallelTaskInterface {
 | 
|---|
| 35 | public: 
 | 
|---|
| 36 |   BRVisibilityCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000, size_t nthr=1);
 | 
|---|
| 37 |   virtual ~BRVisibilityCalculator(); // Fait le nettoyage final , sauvegarde des objets ...
 | 
|---|
| 38 | 
 | 
|---|
| 39 |   // Pour definir le rang de l'objet lors d'un traitement avec plusieurs BRVisibilityCalculator en //
 | 
|---|
| 40 |   void DefineRank(uint_4 nbc, uint_4 cid);
 | 
|---|
| 41 | 
 | 
|---|
| 42 |   // Pour limiter le calcul des visibilites a certaines fibres 
 | 
|---|
| 43 |   uint_4 SelectPairs(uint_4 pair1=0, uint_4 nbpairs=99999999);
 | 
|---|
| 44 |   // pour definir le binning en frequence pour la VisibDataTable 
 | 
|---|
| 45 |   // par defaut, toutes les frequences avec un pas de 1 
 | 
|---|
| 46 |   int SelectFreqBinning(uint_4 freq1=0, uint_4 freq2=0, uint_4 nbfreq=0);
 | 
|---|
| 47 | 
 | 
|---|
| 48 |   // Pour activer la verification des timetag
 | 
|---|
| 49 |   // Creation / sauvegarde d'une matrice de TimeTag / FrameCounter avec NCols=maxnpaq (nb de paquets/trigger)  
 | 
|---|
| 50 |   int ActivateTimeTagCheck(uint_8 maxnpaq);
 | 
|---|
| 51 | 
 | 
|---|
| 52 |   // Methode d'execution standard du thread (on redefinit la methode de BRBaseProcessor)
 | 
|---|
| 53 |   virtual void run();  
 | 
|---|
| 54 |   // Methode de la classe ParallelTaskInterface 
 | 
|---|
| 55 |   virtual int    execute(int tid);
 | 
|---|
| 56 | 
 | 
|---|
| 57 |   // Le nombre total d'operations effectuees
 | 
|---|
| 58 |   inline r_8 TotNbFLOP() { return nb_flop_; }
 | 
|---|
| 59 | 
 | 
|---|
| 60 | protected:
 | 
|---|
| 61 |   virtual int Process(); 
 | 
|---|
| 62 |   virtual void UpdateVisMtxInfo();
 | 
|---|
| 63 |   virtual int FillVisibTable(double fcm, double ttm); 
 | 
|---|
| 64 |   virtual int CheckTimeTag(); 
 | 
|---|
| 65 | 
 | 
|---|
| 66 |   ParallelExecutor paralex_;  // Pour l'execution en parallele  
 | 
|---|
| 67 |   size_t nparthr_;
 | 
|---|
| 68 | 
 | 
|---|
| 69 |   uint_4 nmean_;  // Nombre de spectres pour le calcul des moyennes 
 | 
|---|
| 70 |   string outpath_;  // directory pour fichiers de sortie
 | 
|---|
| 71 |   uint_4 nbcalc_, calcid_;  // Nombre total de threads/objets BRVisibilityCalculator parallèles, l'identificateur de l'objet  
 | 
|---|
| 72 | 
 | 
|---|
| 73 |   uint_4 pairst_, nbpairs_;   // Numero de la premiere paire, nombre de paires 
 | 
|---|
| 74 |   uint_4 jf1_,jf2_,djf_;  // binning en frequence pour la datatable
 | 
|---|
| 75 | 
 | 
|---|
| 76 |   vector<TwoByteComplex*> vpdata_;
 | 
|---|
| 77 |   bool* fgallfibok;  
 | 
|---|
| 78 | 
 | 
|---|
| 79 |   double moyfc_, moytt_;  // moyenne des FrameCounter / TimeTag pour chaque matrice de visibilite
 | 
|---|
| 80 |   uint_8 first_fc_,first_tt_;  // Valeurs premier FrameCounter / TimeTag pour chaque matrice de visibilite
 | 
|---|
| 81 |   TimeStamp first_tmstamp_;   // Date-Heure pour premier FrameCounter / TimeTag pour chaque matrice de visibilite
 | 
|---|
| 82 |   
 | 
|---|
| 83 |   TMatrix< complex<r_4> > vismtx_; 
 | 
|---|
| 84 |   TVector< uint_4 > chanum_;
 | 
|---|
| 85 |   //  FitsInOutFile dtfos_;
 | 
|---|
| 86 |   DataTable visdt_;
 | 
|---|
| 87 |   uint_4 numfile_;
 | 
|---|
| 88 |   uint_8 totnbpaq_;
 | 
|---|
| 89 | 
 | 
|---|
| 90 |   r_8 nb_flop_;   // Nombre total d'operations effectuees
 | 
|---|
| 91 | 
 | 
|---|
| 92 |   // Variables/objets pour la verifications des timetag
 | 
|---|
| 93 |   bool fgcktt_;  // true -> checktimetag 
 | 
|---|
| 94 |   int_8 mindeltatt_;       // difference minimum de deux timetag successifs 
 | 
|---|
| 95 |   TMatrix< uint_8 > fcmtx_; // matrices des framecounters
 | 
|---|
| 96 |   TMatrix< uint_8 > ttmtx_; // matrices des timetag 
 | 
|---|
| 97 |   vector< uint_8 > vlasttt_;  // dernieres valeurs de TimeTag / fibre
 | 
|---|
| 98 |   vector< uint_8 > vbadtt_;  // Number of bad TimeTag paquets per fiber 
 | 
|---|
| 99 |   vector< uint_8 > vnsamett_;  // Number of paquets having TimeTag <> TT_Fiber1 per fiber 
 | 
|---|
| 100 |   vector< uint_8 > vndiff5tt_;  // Number of paquets having |TimeTag-TT_Fiber1|>5 per fiber 
 | 
|---|
| 101 | 
 | 
|---|
| 102 | };
 | 
|---|
| 103 | 
 | 
|---|
| 104 | 
 | 
|---|
| 105 | //-------------------------------------------------------------------------------
 | 
|---|
| 106 | // Classe Groupe (ensemble) de Calculateur de Visibilites, tournant en parallele
 | 
|---|
| 107 | //-------------------------------------------------------------------------------
 | 
|---|
| 108 | 
 | 
|---|
| 109 | class BRVisCalcGroup {
 | 
|---|
| 110 | public: 
 | 
|---|
| 111 |   BRVisCalcGroup(size_t nbcalc, RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000, size_t nthr=1);
 | 
|---|
| 112 |   ~BRVisCalcGroup();
 | 
|---|
| 113 |   int SelectFreqBinning(uint_4 freq1=0, uint_4 freq2=0, uint_4 nbfreq=1);
 | 
|---|
| 114 |   inline int ActivateTimeTagCheck(uint_8 maxnpaq)
 | 
|---|
| 115 |   { return viscalcp_[0]->ActivateTimeTagCheck(maxnpaq); }
 | 
|---|
| 116 | 
 | 
|---|
| 117 |   void start();
 | 
|---|
| 118 |   void join();
 | 
|---|
| 119 | protected:
 | 
|---|
| 120 |   vector<BRVisibilityCalculator *> viscalcp_; 
 | 
|---|
| 121 |   Timer tm_;
 | 
|---|
| 122 | };
 | 
|---|
| 123 | 
 | 
|---|
| 124 | 
 | 
|---|
| 125 | #endif
 | 
|---|