source: Sophya/trunk/SophyaPI/PIext/phistwrapper.h@ 4010

Last change on this file since 4010 was 3520, checked in by ansari, 17 years ago

Ajout/codage methode P2DArrayAdapter::MeanVal() pour les classes adapter heritant de P2DArrayAdapter, Reza 11/09/2008

File size: 4.4 KB
Line 
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
16class P1DHistoWrapper : public P1DArrayAdapter
17{
18public:
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
60protected:
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
69class P2DHistoWrapper : public P2DArrayAdapter
70{
71public:
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 // Calcule la moyenne des bins entre (ix1,jy1) <= (ix2, jy2)
102 virtual double MeanVal(int ix1, int ix2, int jy1, int jy2);
103
104 // Methode de mise a jour du contenu
105 // avec implementation par defaut - ne faisant rien
106 virtual void Update() { return; }
107
108 // ajoute des lignes de texte avec les infos statistiques (dans text)
109 // renvoie le nombre de lignes ajoutees - avec implementation par defaut
110 virtual int GetStatInfoAsText(vector<string> & text );
111
112// Methode de decodage des options - herite de P2DArrayAdapter
113// l'implementation ds le fichier pihisto2d.cc
114 virtual int DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
115// liste des options sous forme text - herite de P2DArrayAdapter (ds pihisto2d.cc )
116 virtual int OptionToString(vector<string> & opt) const;
117
118protected:
119 r_8 mScale, mOff; // scaling coefficient, offset coefficient used in operator ()
120 short mRetFg; // operator() : 0 -> bin content , 1 -> bin error , 2 -> bin nentries
121};
122
123
124
125
126#endif
Note: See TracBrowser for help on using the repository browser.