source: Sophya/trunk/SophyaLib/HiStats/histerr.h@ 3044

Last change on this file since 3044 was 3044, checked in by cmv, 19 years ago

ReCenterBin deplace methode Histo (was HistErr) cmv 7/8/2006

File size: 2.8 KB
RevLine 
[2603]1#ifndef HISTERR_SEEN
2#define HISTERR_SEEN
3
4#include "objfio.h"
5#include <iostream>
6#include <stdio.h>
7#include "histos.h"
8
9namespace SOPHYA {
10
11//! 1 dimension histograms with errors given by user
12class HistoErr : public Histo {
13 friend class ObjFileIO<HistoErr>;
14public:
15
16 // CREATOR / DESTRUCTOR
17 HistoErr(void);
18 HistoErr(r_8 xMin, r_8 xMax, int_4 nBin=100);
19 HistoErr(const HistoErr& H);
20 virtual ~HistoErr(void);
21
22 // UPDATING or SETTING
23 void Zero(void);
24 //! Addition du contenu de l'histo pour abscisse x poids w et l'erreur e
[2630]25 inline void Add(r_8 x, r_8 w, r_8 e)
26 {
27 int_4 numBin = (int_4)floor((x-mMin)/binWidth);
28 if(numBin<0) mUnder += w;
29 else if(numBin>=mBins) mOver += w;
30 else {
31 mData[numBin] += w; mNData[numBin] += 1.; mErr2[numBin] += e*e;
32 nHist += w; nEntries++;
33 }
34 }
35 inline void Add(r_8 x, r_8 w) {Add(x,w,1.);}
36 inline void Add(r_8 x) {Add(x,1.,1.);}
[2603]37 //! Addition du contenu de l'histo pour le bin numBin poids w et l'erreur e
[2630]38 inline void AddBin(int_4 numBin, r_8 w, r_8 e)
39 {
40 if(numBin<0) mUnder += w;
41 else if(numBin>=mBins) mOver += w;
42 else {
43 mData[numBin] += w; mNData[numBin] += 1.; mErr2[numBin] += e*e;
44 nHist += w; nEntries++;
45 }
46 }
47 inline void AddBin(int_4 numBin, r_8 w) {AddBin(numBin,w,1.);}
48 inline void AddBin(int_4 numBin) {AddBin(numBin,1.,1.);}
[2604]49 //! remplissage contenu de l'histo pour le bin numBin poids w et l'erreur e
[2630]50 void SetBin(int_4 numBin, r_8 w, r_8 e, r_8 nb);
51 inline void SetBin(int_4 numBin, r_8 w, r_8 e) {SetBin(numBin,w,e,1.);}
52 inline void SetBin(int_4 numBin, r_8 w) {SetBin(numBin,w,1.,1.);}
53 inline void SetBin(int_4 numBin) {SetBin(numBin,1.,1.,1.);}
[2604]54 //! remplissage nombre d'entrees pour le bin numBin
[2626]55 void SetNentB(int_4 numBin, r_8 nb=1.);
[2603]56
57 //! Retourne le nombre d'entree dans le bin
[2626]58 inline r_8 NEntBin(int_4 i) const
59 {if(mNData) return mNData[i]; else return 0.;}
[2603]60
[2608]61 //! get/put from/to a vector
[2626]62 void GetNBin(TVector<r_8>& v) const;
63 void PutNBin(TVector<r_8>& v);
[2603]64
[2608]65 //! Compute the correlation histogram
[2604]66 void ToCorrel(void);
[2819]67 void FromCorrel(void);
[2604]68
[2628]69 //! Fill an histogram with an histogram
70 void FillFrHErr(HistoErr& hfrom);
71
[2619]72 // Operators
73 HistoErr& operator = (const HistoErr& h);
74
[2603]75protected:
[2608]76 void allocate_mNData(int nbin);
[2619]77 void Delete(void);
78
[2626]79 r_8* mNData; //!< nombre d'entrees dans chaque bin
[2603]80};
81
82/*! \ingroup HiStats \fn operator<<(POuttPersist&,HistoErr)
83 \brief Persistance management */
84inline POutPersist& operator << (POutPersist& os, HistoErr & obj)
85{ ObjFileIO<HistoErr> fio(&obj); fio.Write(os); return(os); }
86/*! \ingroup HiStats \fn operator<<(POuttPersist&,HistoErr)
87 \brief Persistance management */
88inline PInPersist& operator >> (PInPersist& is, HistoErr & obj)
89{ ObjFileIO<HistoErr> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
90
91} // Fin du namespace
92
93#endif // HISTERR_SEEN
Note: See TracBrowser for help on using the repository browser.