1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
2 | // Classe d'emballage (wrapper) d'histos pour trace PI
|
---|
3 | // C. Magneville / R. Ansari 2007
|
---|
4 | // (C) CEA-DAPNIA LAL-IN2P3/CNRS
|
---|
5 |
|
---|
6 | #ifndef PHISTOWRAPPER_H
|
---|
7 | #define PHISTOWRAPPER_H
|
---|
8 |
|
---|
9 | #include <string>
|
---|
10 | #include <vector>
|
---|
11 | #include "parradapter.h"
|
---|
12 |
|
---|
13 |
|
---|
14 | //! Wrapper class interface for 1d-histogram like objects , used by PIHisto
|
---|
15 | // methodes par defaut dans pihisto.cc
|
---|
16 | class P1DHistoWrapper : public P1DArrayAdapter
|
---|
17 | {
|
---|
18 | public:
|
---|
19 | P1DHistoWrapper(int asz); // asz: taille du tableau pour P1DArrayAdapter
|
---|
20 | virtual ~P1DHistoWrapper();
|
---|
21 |
|
---|
22 | virtual int_4 NBins() = 0;
|
---|
23 | virtual r_8 XMin() = 0;
|
---|
24 | virtual r_8 XMax() = 0;
|
---|
25 | virtual r_8 BinWidth() = 0;
|
---|
26 |
|
---|
27 | virtual r_8 BinLowEdge(int_4 i) = 0;
|
---|
28 | virtual r_8 BinCenter(int_4 i) = 0;
|
---|
29 | virtual r_8 BinHighEdge(int_4 i) = 0;
|
---|
30 |
|
---|
31 | // Renvoie contenu du bin i
|
---|
32 | virtual r_8 Content(int_4 i) = 0;
|
---|
33 | virtual r_8 Error(int_4 i) = 0;
|
---|
34 | virtual r_8 NbEntries(int_4 i) = 0;
|
---|
35 |
|
---|
36 | inline r_8 operator()(int_4 i)
|
---|
37 | {
|
---|
38 | r_8 rv = (mRetFg == 2) ? NbEntries(i) : ( (mRetFg == 1) ? Error(i) : Content(i) ) ;
|
---|
39 | return ( rv*mScale+mOff );
|
---|
40 | }
|
---|
41 |
|
---|
42 | // Implementation de la methode P1DArrayAdapter::Value(int i)
|
---|
43 | // Identique a l'operateur ()(i)
|
---|
44 | virtual double Value(int i) { return (*this)(i); }
|
---|
45 |
|
---|
46 | // Methode de mise a jour du contenu
|
---|
47 | // avec implementation par defaut - ne faisant rien
|
---|
48 | virtual void Update() { return; }
|
---|
49 |
|
---|
50 | // ajoute des lignes de texte avec les infos statistiques (dans text)
|
---|
51 | // renvoie le nombre de lignes ajoutees - avec implementation par defaut
|
---|
52 | virtual int GetStatInfoAsText(vector<string> & text );
|
---|
53 |
|
---|
54 | // Methode de decodage des options - herite de P1DArrayAdapter
|
---|
55 | // implementation ds le fichier pihisto.cc
|
---|
56 | virtual int DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
|
---|
57 | // liste des options sous forme text - herite de P1DArrayAdapter (ds pihisto.cc )
|
---|
58 | virtual int OptionToString(vector<string> & opt) const;
|
---|
59 |
|
---|
60 | protected:
|
---|
61 | r_8 mScale, mOff; // scaling coefficient, offset coefficient used in operator ()
|
---|
62 | short mRetFg; // operator() : 0 -> bin content , 1 -> bin error , 2 -> bin nentries
|
---|
63 | };
|
---|
64 |
|
---|
65 | //-----------------------------------------------------------------------------
|
---|
66 |
|
---|
67 | //! Wrapper class interface for 2d-histogram like objects , used by PIHisto2D
|
---|
68 | // methodes par defaut dans pihisto2d.cc
|
---|
69 | class P2DHistoWrapper : public P2DArrayAdapter
|
---|
70 | {
|
---|
71 | public:
|
---|
72 | P2DHistoWrapper(int_4 asx, int_4 asy); // asx,asy: tailles du tableau pour P2DArrayAdapter
|
---|
73 | virtual ~P2DHistoWrapper();
|
---|
74 |
|
---|
75 | virtual int_4 NBinX() = 0;
|
---|
76 | virtual int_4 NBinY() = 0;
|
---|
77 | virtual r_8 XMin() = 0;
|
---|
78 | virtual r_8 XMax() = 0;
|
---|
79 | virtual r_8 YMin() = 0;
|
---|
80 | virtual r_8 YMax() = 0;
|
---|
81 | virtual r_8 WBinX() = 0;
|
---|
82 | virtual r_8 WBinY() = 0;
|
---|
83 |
|
---|
84 | virtual void BinLowEdge(int_4 i, int_4 j, r_8& xr, r_8& yr) = 0;
|
---|
85 | virtual void BinCenter(int_4 i, int_4 j, r_8& xr, r_8& yr) = 0;
|
---|
86 | virtual void BinHighEdge(int_4 i, int_4 j, r_8& xr, r_8& yr) = 0;
|
---|
87 |
|
---|
88 | // Renvoie contenu du bin i
|
---|
89 | virtual r_8 Content(int_4 i, int_4 j) = 0;
|
---|
90 | virtual r_8 Error(int_4 i, int_4 j) = 0;
|
---|
91 | virtual r_8 NbEntries(int_4 i, int_4 j) = 0;
|
---|
92 |
|
---|
93 | inline r_8 operator()(int_4 i, int_4 j)
|
---|
94 | {
|
---|
95 | r_8 rv = (mRetFg == 2) ? NbEntries(i,j) : ( (mRetFg == 1) ? Error(i,j) : Content(i,j) ) ;
|
---|
96 | return ( rv*mScale+mOff );
|
---|
97 | }
|
---|
98 | // Implementation de la methode P2DArrayAdapter::Value(int i, j)
|
---|
99 | // Identique a l'operateur ()(i)
|
---|
100 | virtual double Value(int i, int j) { return (*this)(i, j); }
|
---|
101 |
|
---|
102 | // Methode de mise a jour du contenu
|
---|
103 | // avec implementation par defaut - ne faisant rien
|
---|
104 | virtual void Update() { return; }
|
---|
105 |
|
---|
106 | // ajoute des lignes de texte avec les infos statistiques (dans text)
|
---|
107 | // renvoie le nombre de lignes ajoutees - avec implementation par defaut
|
---|
108 | virtual int GetStatInfoAsText(vector<string> & text );
|
---|
109 |
|
---|
110 | // Methode de decodage des options - herite de P2DArrayAdapter
|
---|
111 | // l'implementation ds le fichier pihisto2d.cc
|
---|
112 | virtual int DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
|
---|
113 | // liste des options sous forme text - herite de P2DArrayAdapter (ds pihisto2d.cc )
|
---|
114 | virtual int OptionToString(vector<string> & opt) const;
|
---|
115 |
|
---|
116 | protected:
|
---|
117 | r_8 mScale, mOff; // scaling coefficient, offset coefficient used in operator ()
|
---|
118 | short mRetFg; // operator() : 0 -> bin content , 1 -> bin error , 2 -> bin nentries
|
---|
119 | };
|
---|
120 |
|
---|
121 |
|
---|
122 |
|
---|
123 |
|
---|
124 | #endif
|
---|