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

Last change on this file since 2745 was 2630, checked in by cmv, 21 years ago

gestion des param par default, cmv+rz 26/10/04

File size: 2.8 KB
Line 
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
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.);}
37 //! Addition du contenu de l'histo pour le bin numBin poids w et l'erreur e
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.);}
49 //! remplissage contenu de l'histo pour le bin numBin poids w et l'erreur e
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.);}
54 //! remplissage nombre d'entrees pour le bin numBin
55 void SetNentB(int_4 numBin, r_8 nb=1.);
56
57 //! Retourne le nombre d'entree dans le bin
58 inline r_8 NEntBin(int_4 i) const
59 {if(mNData) return mNData[i]; else return 0.;}
60
61 //! get/put from/to a vector
62 void GetNBin(TVector<r_8>& v) const;
63 void PutNBin(TVector<r_8>& v);
64
65 //! Re-center bin abscissa
66 void ReCenterBin(void);
67 //! Compute the correlation histogram
68 void ToCorrel(void);
69
70 //! Fill an histogram with an histogram
71 void FillFrHErr(HistoErr& hfrom);
72
73 // Operators
74 HistoErr& operator = (const HistoErr& h);
75
76protected:
77 void allocate_mNData(int nbin);
78 void Delete(void);
79
80 r_8* mNData; //!< nombre d'entrees dans chaque bin
81};
82
83/*! \ingroup HiStats \fn operator<<(POuttPersist&,HistoErr)
84 \brief Persistance management */
85inline POutPersist& operator << (POutPersist& os, HistoErr & obj)
86{ ObjFileIO<HistoErr> fio(&obj); fio.Write(os); return(os); }
87/*! \ingroup HiStats \fn operator<<(POuttPersist&,HistoErr)
88 \brief Persistance management */
89inline PInPersist& operator >> (PInPersist& is, HistoErr & obj)
90{ ObjFileIO<HistoErr> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
91
92} // Fin du namespace
93
94#endif // HISTERR_SEEN
Note: See TracBrowser for help on using the repository browser.