| 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"
 | 
|---|
| 13 | #include "poly.h"
 | 
|---|
| 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 | 
 | 
|---|
| 34 |   inline void   SetRange(double min=-9.e19, double max=+9.e19)
 | 
|---|
| 35 |     { range_min = min; range_max = max; }
 | 
|---|
| 36 |   inline void   GetRange(double& min, double& max) const 
 | 
|---|
| 37 |     { min = range_min; max = range_max; }
 | 
|---|
| 38 |   inline void   SetCleanForMeanThrNSig(double ns=3.)
 | 
|---|
| 39 |     { nsigclean = ns; }
 | 
|---|
| 40 |   inline double GetCleanForMeanThrNSig()
 | 
|---|
| 41 |     { return(nsigclean); }
 | 
|---|
| 42 |   inline void   SetFlaggingThrNSig(double ns1=4., double ns2=2., int npt2=3)
 | 
|---|
| 43 |     { nsig1 = ns1;  nsig2 = ns2;  min_npt2 = npt2; } 
 | 
|---|
| 44 |   inline void   GetFlaggingThrNSig(double& ns1, double& ns2, int& npt2)
 | 
|---|
| 45 |     { ns1 = nsig1;  ns2 = nsig2; npt2 = npt2; } 
 | 
|---|
| 46 | 
 | 
|---|
| 47 |   inline double GetGlMean() { return( (ns_glms > 0) ? gl_sum/ns_glms : 0.) ; }
 | 
|---|
| 48 |   inline double GetGlSigma2() 
 | 
|---|
| 49 |     { 
 | 
|---|
| 50 |       double m = GetGlMean();
 | 
|---|
| 51 |       return( (ns_glms > 0) ? gl_sum2/ns_glms-m*m : 0.) ; 
 | 
|---|
| 52 |     }
 | 
|---|
| 53 | 
 | 
|---|
| 54 |   inline int_4  GetGLMSNbSample() { return ns_glms; }
 | 
|---|
| 55 | 
 | 
|---|
| 56 |   virtual void  init();  
 | 
|---|
| 57 |   virtual void  run();
 | 
|---|
| 58 | 
 | 
|---|
| 59 |   inline int_8  ProcessedSampleCount() const { return totnscount; }
 | 
|---|
| 60 | 
 | 
|---|
| 61 |   virtual void  PrintStatus(::ostream & os) ; // const plus tard
 | 
|---|
| 62 | 
 | 
|---|
| 63 | protected:
 | 
|---|
| 64 |   int_8 totnscount;   // Nombre total d'echantillon processe
 | 
|---|
| 65 |   int_8 totnbblock;   // Nombre total de blocs 
 | 
|---|
| 66 |   int mWSz;           // Fentre Calcul mean-sigma : mNbW*mWSz
 | 
|---|
| 67 |   int mNbW;           //    "    "    "    "      " 
 | 
|---|
| 68 |   double nsigclean;   // Point a +- nsig4mean pas pris en compte pour calcul mean
 | 
|---|
| 69 |   double nsig1;       // Point a +- nsig1 flagge
 | 
|---|
| 70 |   double nsig2;       // >=min_npt2 Points a +- nsig2 flagges
 | 
|---|
| 71 |   int min_npt2;       // Min NPoints a += nsig2 
 | 
|---|
| 72 |   double range_min, range_max;  // Range acceptable pour in
 | 
|---|
| 73 |   int_4 ns_outofrange;  // Nb de points out of range
 | 
|---|
| 74 |   int_4 ns_flag1p;       // Nb de points flagges avec nsig1 (> mean) 
 | 
|---|
| 75 |   int_4 ns_flag2p;       // Nb de points flagges avec nsig2 (> mean)
 | 
|---|
| 76 |   int_4 ns_flag1m;       // Nb de points flagges avec nsig1 (< mean) 
 | 
|---|
| 77 |   int_4 ns_flag2m;       // Nb de points flagges avec nsig2 (< mean) 
 | 
|---|
| 78 |   double gl_sum, gl_sum2;  // Global Sum(x) - Sum(x^2)
 | 
|---|
| 79 |   int_4 ns_glms;             // Nb d'echantillon pour  Global Sum(x) - Sum(x^2)
 | 
|---|
| 80 | };
 | 
|---|
| 81 | 
 | 
|---|
| 82 | #endif
 | 
|---|