Changeset 1092 in Sophya for trunk/SophyaLib/HiStats/histos.h
- Timestamp:
- Jul 26, 2000, 3:15:52 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/HiStats/histos.h
r1089 r1092 1 1 // This may look like C code, but it is really -*- C++ -*- 2 2 // 3 // $Id: histos.h,v 1.1 0 2000-07-25 10:20:43ansari Exp $3 // $Id: histos.h,v 1.11 2000-07-26 13:15:15 ansari Exp $ 4 4 // 5 5 … … 26 26 // CREATOR / DESTRUCTOR 27 27 Histo(); 28 Histo(float xMin, float xMax, int nBin=100); 28 Histo(r_8 xMin, r_8 xMax, int_4 nBin=100); 29 Histo(r_4 xMin, r_4 xMax, int_4 nBin=100); 29 30 Histo(const Histo& H); 30 31 virtual ~Histo(); … … 35 36 // UPDATING or SETTING 36 37 void Zero(); 37 void Add( float x, floatw = 1.);38 void AddBin(int numBin, floatw = 1.);39 void SetBin( float x, floatw = 1.);40 void SetBin(int numBin, floatw = 1.);41 void SetErr2( float x, doublee2);42 void SetErr2(int numBin, doublee2);43 void SetErr( float x, floate);44 void SetErr(int numBin, floate);38 void Add(r_8 x, r_8 w = 1.); 39 void AddBin(int_4 numBin, r_8 w = 1.); 40 void SetBin(r_8 x, r_8 w = 1.); 41 void SetBin(int_4 numBin, r_8 w = 1.); 42 void SetErr2(r_8 x, r_8 e2); 43 void SetErr2(int_4 numBin, r_8 e2); 44 void SetErr(r_8 x, r_8 e); 45 void SetErr(int_4 numBin, r_8 e); 45 46 virtual inline void UpdateHisto() const { return;} 46 47 47 48 // Operators 48 49 Histo& operator = (const Histo& h); 49 Histo& operator *= ( doubleb);50 Histo& operator /= ( doubleb);51 Histo& operator += ( doubleb);52 Histo& operator -= ( doubleb);50 Histo& operator *= (r_8 b); 51 Histo& operator /= (r_8 b); 52 Histo& operator += (r_8 b); 53 Histo& operator -= (r_8 b); 53 54 Histo& operator += (const Histo& a); 54 55 Histo& operator -= (const Histo& a); … … 61 62 void GetError2(TVector<r_8>& v); 62 63 void GetError(TVector<r_8>& v); 63 void PutValue(TVector<r_8>& v, int ierr=0);64 void PutValueAdd(TVector<r_8> &v, int ierr=0);64 void PutValue(TVector<r_8>& v, int_4 ierr=0); 65 void PutValueAdd(TVector<r_8> &v, int_4 ierr=0); 65 66 void PutError2(TVector<r_8>& v); 66 67 void PutError2Add(TVector<r_8>& v); … … 69 70 // INLINES 70 71 //! Retourne l'abscisse minimum 71 inline float XMin() const {return min;}72 inline r_8 XMin() const {return mMin;} 72 73 //! Retourne l'abscisse maximum 73 inline float XMax() const {return max;}74 inline r_8 XMax() const {return mMax;} 74 75 //! Retourne le nombre de bins 75 inline int_4 NBins() const {return bins;}76 inline int_4 NBins() const {return mBins;} 76 77 //! Retourne la largeur du bin 77 inline floatBinWidth() const {return binWidth;}78 inline r_8 BinWidth() const {return binWidth;} 78 79 //! Retourne le pointeur sur le tableaux des contenus 79 inline float* Bins() const {return data;}80 inline r_8* Bins() const {return mData;} 80 81 //! Retourne le contenu du bin i 81 inline float operator()(int i) const {return data[i];}82 inline r_8 operator()(int_4 i) const {return mData[i];} 82 83 //! Remplit le contenu du bin i 83 inline float& operator()(int i) {return data[i];}84 inline r_8& operator()(int_4 i) {return mData[i];} 84 85 //! retourne "true" si il y a des erreurs stoquees 85 86 inline bool HasErrors() 86 {if( err2) return true; else return false;}87 {if(mErr2) return true; else return false;} 87 88 //! Retourne l'erreur du bin i 88 inline float Error(inti) const89 {if( err2) {if(err2[i]>0.) return sqrt(err2[i]); else return 0.;}89 inline r_8 Error(int_4 i) const 90 {if(mErr2) {if(mErr2[i]>0.) return sqrt(mErr2[i]); else return 0.;} 90 91 else return 0.;} 91 92 //! Retourne l'erreur au carre du bin i 92 inline double Error2(inti) const93 {if( err2) return err2[i]; else return 0.;}93 inline r_8 Error2(int_4 i) const 94 {if(mErr2) return mErr2[i]; else return 0.;} 94 95 //! Remplit l'erreur au carre du bin i 95 inline double& Error2(int i) {return err2[i];}96 inline r_8& Error2(int_4 i) {return mErr2[i];} 96 97 //! Retourne la somme ponderee 97 inline float NData() const {return (float)nHist;}98 inline r_8 NData() const {return nHist;} 98 99 //! Retourne le nombre d'entrees 99 inline floatNEntries() const {return nEntries;}100 inline r_8 NEntries() const {return nEntries;} 100 101 //! Retourne le nombre d'overflow 101 inline float NOver() const {return over;}102 inline r_8 NOver() const {return mOver;} 102 103 //! Retourne le nombre d'underflow 103 inline float NUnder() const {return under;}104 inline r_8 NUnder() const {return mUnder;} 104 105 105 106 //! Retourne l'abscisse du bord inferieur du bin i 106 inline float BinLowEdge(int i) const {return min + i*binWidth;}107 inline r_8 BinLowEdge(int_4 i) const {return mMin + i*binWidth;} 107 108 //! Retourne l'abscisse du centre du bin i 108 inline float BinCenter(int i) const {return min + (i+0.5)*binWidth;}109 inline r_8 BinCenter(int_4 i) const {return mMin + (i+0.5)*binWidth;} 109 110 //! Retourne l'abscisse du bord superieur du bin i 110 inline float BinHighEdge(int i) const {return min + (i+1)*binWidth;}111 inline r_8 BinHighEdge(int_4 i) const {return mMin + (i+1)*binWidth;} 111 112 //! Retourne le numero du bin contenant l'abscisse x 112 inline int_4 FindBin( floatx) const113 {return (int_4) floor f((x - min) / binWidth);}113 inline int_4 FindBin(r_8 x) const 114 {return (int_4) floor((x - mMin) / binWidth);} 114 115 115 116 // Info, statistique et calculs sur les histogrammes 116 int 117 int 118 int 119 int 120 floatVMax() const;121 floatVMin() const;122 floatMean() const;123 floatSigma() const;124 float MeanLH(int il,intih) const;125 float SigmaLH(int il,intih) const;126 float Mean(float x0, floatdx) const;127 float Sigma(float x0, floatdx) const;128 floatCleanedMean() const;129 float CleanedMean(float& sigma) const;130 int BinPercent(floatper) const;131 int BinPercent(float x,float per,int& imin,int& imax);132 int BinPercent(float x,float per,float& xmin,float& xmax);133 void HInteg( floatnorm = 0.);117 int_4 BinNonNul() const; 118 int_4 ErrNonNul() const; 119 int_4 IMax() const; 120 int_4 IMin() const; 121 r_8 VMax() const; 122 r_8 VMin() const; 123 r_8 Mean() const; 124 r_8 Sigma() const; 125 r_8 MeanLH(int_4 il,int_4 ih) const; 126 r_8 SigmaLH(int_4 il,int_4 ih) const; 127 r_8 Mean(r_8 x0, r_8 dx) const; 128 r_8 Sigma(r_8 x0, r_8 dx) const; 129 r_8 CleanedMean() const; 130 r_8 CleanedMean(r_8& sigma) const; 131 int_4 BinPercent(r_8 per) const; 132 int_4 BinPercent(r_8 x,r_8 per,int_4& imin,int_4& imax); 133 int_4 BinPercent(r_8 x,r_8 per,r_8& xmin,r_8& xmax); 134 void HInteg(r_8 norm = 0.); 134 135 void HDeriv(); 135 virtual void HRebin(int nbinew);136 137 int MaxiLocal(float& maxi,int& imax,float& maxn,int& imaxn);138 float FitMax(int degree=2, float frac=0.5f, intdebug=0) const;139 float FindWidth(float xmax,float frac=0.5f, intdebug=0) const;140 float FindWidth(float frac=0.5f, intdebug=0) const;141 int EstimeMax(float& xm,intSzPav = 3);142 int EstimeMax(int& im,float& xm,intSzPav = 3);143 void EstimeWidthS( float frac,float& widthG,float& widthD);136 virtual void HRebin(int_4 nbinew); 137 138 int_4 MaxiLocal(r_8& maxi,int_4& imax,r_8& maxn,int_4& imaxn); 139 r_8 FitMax(int_4 degree=2, r_8 frac=0.5f, int_4 debug=0) const; 140 r_8 FindWidth(r_8 xmax,r_8 frac=0.5f, int_4 debug=0) const; 141 r_8 FindWidth(r_8 frac=0.5f, int_4 debug=0) const; 142 int_4 EstimeMax(r_8& xm,int_4 SzPav = 3); 143 int_4 EstimeMax(int_4& im,r_8& xm,int_4 SzPav = 3); 144 void EstimeWidthS(r_8 frac,r_8& widthG,r_8& widthD); 144 145 145 146 // Fit 146 int 147 int_4 Fit(GeneralFit& gfit,unsigned short typ_err=0); 147 148 Histo FitResidus(GeneralFit& gfit); 148 149 Histo FitFunction(GeneralFit& gfit); 149 150 150 151 // Print et Display ASCII 151 void PrintF(FILE * fp, int dyn = 100, float hmin = 1., floathmax = -1.,152 int pflag = 0, int il = 1, intih = -1);153 void Print(int dyn = 100, float hmin = 1., floathmax = -1.,154 int pflag = 0, int il = 1, intih = -1);152 void PrintF(FILE * fp, int_4 dyn = 100, r_8 hmin = 1., r_8 hmax = -1., 153 int_4 pflag = 0, int_4 il = 1, int_4 ih = -1); 154 void Print(int_4 dyn = 100, r_8 hmin = 1., r_8 hmax = -1., 155 int_4 pflag = 0, int_4 il = 1, int_4 ih = -1); 155 156 156 157 protected: 157 158 void Delete(); 158 159 159 float* data;//!< donnees160 double* err2; //!< erreurs carrees161 float under;//!< underflow162 float over;//!< overflow163 doublenHist; //!< somme ponderee des entrees164 int_4 165 int_4 bins;//!< nombre de bins166 float min;//!< abscisse minimum167 float max;//!< abscisse maximum168 floatbinWidth; //!< largeur du bin160 r_8* mData; //!< donnees 161 r_8* mErr2; //!< erreurs carrees 162 r_8 mUnder; //!< underflow 163 r_8 mOver; //!< overflow 164 r_8 nHist; //!< somme ponderee des entrees 165 int_4 nEntries; //!< nombre d'entrees 166 int_4 mBins; //!< nombre de bins 167 r_8 mMin; //!< abscisse minimum 168 r_8 mMax; //!< abscisse maximum 169 r_8 binWidth; //!< largeur du bin 169 170 }; 170 171 … … 182 183 // ObjFileIO<Histo> 183 184 184 /*! \ingroup HiStats \fn operator*(const Histo&, double)185 /*! \ingroup HiStats \fn operator*(const Histo&,r_8) 185 186 \brief Operateur H2 = H1 * b */ 186 inline Histo operator * (const Histo& a, doubleb)187 inline Histo operator * (const Histo& a, r_8 b) 187 188 { 188 189 Histo result(a); … … 190 191 } 191 192 192 /*! \ingroup HiStats \fn operator*( double,const Histo&)193 /*! \ingroup HiStats \fn operator*(r_8,const Histo&) 193 194 \brief Operateur H2 = b * H1 */ 194 inline Histo operator * ( doubleb, const Histo& a)195 inline Histo operator * (r_8 b, const Histo& a) 195 196 { 196 197 Histo result(a); … … 198 199 } 199 200 200 /*! \ingroup HiStats \fn operator/(const Histo&, double)201 /*! \ingroup HiStats \fn operator/(const Histo&,r_8) 201 202 \brief Operateur H2 = H1 / b */ 202 inline Histo operator / (const Histo& a, doubleb)203 inline Histo operator / (const Histo& a, r_8 b) 203 204 { 204 205 Histo result(a); … … 206 207 } 207 208 208 /*! \ingroup HiStats \fn operator+(const Histo&, double)209 /*! \ingroup HiStats \fn operator+(const Histo&,r_8) 209 210 \brief Operateur H2 = H1 + b */ 210 inline Histo operator + (const Histo& a, doubleb)211 inline Histo operator + (const Histo& a, r_8 b) 211 212 { 212 213 Histo result(a); … … 214 215 } 215 216 216 /*! \ingroup HiStats \fn operator+( double,const Histo&)217 /*! \ingroup HiStats \fn operator+(r_8,const Histo&) 217 218 \brief Operateur H2 = b + H1 */ 218 inline Histo operator + ( doubleb, const Histo& a)219 inline Histo operator + (r_8 b, const Histo& a) 219 220 { 220 221 Histo result(a); … … 222 223 } 223 224 224 /*! \ingroup HiStats \fn operator-(const Histo&, double)225 /*! \ingroup HiStats \fn operator-(const Histo&,r_8) 225 226 \brief Operateur H2 = H1 - b */ 226 inline Histo operator - (const Histo& a, doubleb)227 inline Histo operator - (const Histo& a, r_8 b) 227 228 { 228 229 Histo result(a); … … 230 231 } 231 232 232 /*! \ingroup HiStats \fn operator-( double,const Histo&)233 /*! \ingroup HiStats \fn operator-(r_8,const Histo&) 233 234 \brief Operateur H2 = b - H1 */ 234 inline Histo operator - ( doubleb, const Histo& a)235 inline Histo operator - (r_8 b, const Histo& a) 235 236 { 236 237 Histo result(a);
Note:
See TracChangeset
for help on using the changeset viewer.