| [2014] | 1 | // This may look like C code, but it is really -*- C++ -*-
 | 
|---|
 | 2 | 
 | 
|---|
 | 3 | // ArchTOIPipe           (C)     CEA/DAPNIA/SPP IN2P3/LAL
 | 
|---|
 | 4 | //                               Eric Aubourg
 | 
|---|
 | 5 | //                               Christophe Magneville
 | 
|---|
 | 6 | //                               Reza Ansari
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | #ifndef SIMCLEANER_H
 | 
|---|
 | 9 | #define SIMCLEANER_H
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | #include "toiprocessor.h"
 | 
|---|
 | 12 | #include "tvector.h"
 | 
|---|
| [2048] | 13 | #include "ntuple.h"
 | 
|---|
| [2014] | 14 | 
 | 
|---|
 | 15 | // ---- Calcul de ligne de base 
 | 
|---|
 | 16 | //      Ajustement polynomial sur des echantillons moyennes
 | 
|---|
 | 17 | //
 | 
|---|
 | 18 | // Structure generale :
 | 
|---|
 | 19 | // 
 | 
|---|
 | 20 | //               -------------------------
 | 
|---|
 | 21 | //  toi in -->   |                       | ---> out = i+flag updated
 | 
|---|
 | 22 | //               |     SimpleCleaner     | ---> mean (opt)
 | 
|---|
 | 23 | //               |                       | ---> sigma (opt)
 | 
|---|
 | 24 | //               |                       |
 | 
|---|
 | 25 | //               -------------------------
 | 
|---|
 | 26 | 
 | 
|---|
 | 27 | class SimpleCleaner : public TOIProcessor {
 | 
|---|
 | 28 | public:
 | 
|---|
 | 29 |            SimpleCleaner(int wsz=256, int nbw=5);
 | 
|---|
 | 30 |   virtual  ~SimpleCleaner();
 | 
|---|
 | 31 | 
 | 
|---|
 | 32 |   void          SetMeanSigWindow(int wsz=256, int nbw=5);
 | 
|---|
 | 33 | 
 | 
|---|
| [2048] | 34 |   inline void    FillMeanSigNTuple(bool fg = false) 
 | 
|---|
 | 35 |     { fg_meansignt = fg; }
 | 
|---|
 | 36 |   inline NTuple& GetMeanSigNTuple() { return *meansignt; }
 | 
|---|
 | 37 | 
 | 
|---|
| [2014] | 38 |   inline void   SetRange(double min=-9.e19, double max=+9.e19)
 | 
|---|
 | 39 |     { range_min = min; range_max = max; }
 | 
|---|
 | 40 |   inline void   GetRange(double& min, double& max) const 
 | 
|---|
 | 41 |     { min = range_min; max = range_max; }
 | 
|---|
| [2054] | 42 |   inline void   SetFlagMask(uint_8 mask = 0)  // Aucun flag utilise par defaut
 | 
|---|
 | 43 |     { flag_mask = mask; }
 | 
|---|
 | 44 |   inline uint_8 GetFlagMask() { return flag_mask; }
 | 
|---|
 | 45 | 
 | 
|---|
 | 46 |   inline void   SetCleanForMeanThrNSig(double ns=5.)
 | 
|---|
| [2014] | 47 |     { nsigclean = ns; }
 | 
|---|
 | 48 |   inline double GetCleanForMeanThrNSig()
 | 
|---|
 | 49 |     { return(nsigclean); }
 | 
|---|
 | 50 |   inline void   SetFlaggingThrNSig(double ns1=4., double ns2=2., int npt2=3)
 | 
|---|
 | 51 |     { nsig1 = ns1;  nsig2 = ns2;  min_npt2 = npt2; } 
 | 
|---|
 | 52 |   inline void   GetFlaggingThrNSig(double& ns1, double& ns2, int& npt2)
 | 
|---|
 | 53 |     { ns1 = nsig1;  ns2 = nsig2; npt2 = npt2; } 
 | 
|---|
 | 54 | 
 | 
|---|
 | 55 |   inline double GetGlMean() { return( (ns_glms > 0) ? gl_sum/ns_glms : 0.) ; }
 | 
|---|
 | 56 |   inline double GetGlSigma2() 
 | 
|---|
 | 57 |     { 
 | 
|---|
 | 58 |       double m = GetGlMean();
 | 
|---|
 | 59 |       return( (ns_glms > 0) ? gl_sum2/ns_glms-m*m : 0.) ; 
 | 
|---|
 | 60 |     }
 | 
|---|
 | 61 | 
 | 
|---|
 | 62 |   inline int_4  GetGLMSNbSample() { return ns_glms; }
 | 
|---|
 | 63 | 
 | 
|---|
 | 64 |   virtual void  init();  
 | 
|---|
 | 65 |   virtual void  run();
 | 
|---|
 | 66 | 
 | 
|---|
 | 67 |   inline int_8  ProcessedSampleCount() const { return totnscount; }
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 |   virtual void  PrintStatus(::ostream & os) ; // const plus tard
 | 
|---|
 | 70 | 
 | 
|---|
 | 71 | protected:
 | 
|---|
 | 72 |   int_8 totnscount;   // Nombre total d'echantillon processe
 | 
|---|
 | 73 |   int_8 totnbblock;   // Nombre total de blocs 
 | 
|---|
 | 74 |   int mWSz;           // Fentre Calcul mean-sigma : mNbW*mWSz
 | 
|---|
 | 75 |   int mNbW;           //    "    "    "    "      " 
 | 
|---|
 | 76 |   double nsigclean;   // Point a +- nsig4mean pas pris en compte pour calcul mean
 | 
|---|
 | 77 |   double nsig1;       // Point a +- nsig1 flagge
 | 
|---|
 | 78 |   double nsig2;       // >=min_npt2 Points a +- nsig2 flagges
 | 
|---|
 | 79 |   int min_npt2;       // Min NPoints a += nsig2 
 | 
|---|
 | 80 |   double range_min, range_max;  // Range acceptable pour in
 | 
|---|
| [2054] | 81 |   uint_8 flag_mask;     // mask de flag utilise
 | 
|---|
 | 82 |   int_4 ns_inflagged;     // Nb d'echantillons flagges
 | 
|---|
 | 83 | 
 | 
|---|
| [2014] | 84 |   int_4 ns_outofrange;  // Nb de points out of range
 | 
|---|
| [2054] | 85 |   int_4 ns_cleannsig;   // Nb de points nettoyes a +/- nsigclean 
 | 
|---|
| [2014] | 86 |   int_4 ns_flag1p;       // Nb de points flagges avec nsig1 (> mean) 
 | 
|---|
 | 87 |   int_4 ns_flag2p;       // Nb de points flagges avec nsig2 (> mean)
 | 
|---|
 | 88 |   int_4 ns_flag1m;       // Nb de points flagges avec nsig1 (< mean) 
 | 
|---|
 | 89 |   int_4 ns_flag2m;       // Nb de points flagges avec nsig2 (< mean) 
 | 
|---|
 | 90 |   double gl_sum, gl_sum2;  // Global Sum(x) - Sum(x^2)
 | 
|---|
 | 91 |   int_4 ns_glms;             // Nb d'echantillon pour  Global Sum(x) - Sum(x^2)
 | 
|---|
| [2048] | 92 | 
 | 
|---|
 | 93 |   bool fg_meansignt;
 | 
|---|
 | 94 |   NTuple* meansignt;
 | 
|---|
| [2014] | 95 | };
 | 
|---|
 | 96 | 
 | 
|---|
 | 97 | #endif
 | 
|---|