StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
L2Histo.h
1 #ifndef L2HISTO_h
2 #define L2HISTO_h
3 /*********************************************************************
4  * $Id: L2Histo.h,v 1.4 2010/04/18 06:05:32 pibero Exp $
5  * \author Jan Balewski, IUCF, 2006
6  *********************************************************************
7  * Descripion:
8  * primitive 1-D or 2-D histograming I/O
9  * all indexes run [0,nb-1]
10  *********************************************************************
11  */
12 
13 
14 class L2Histo {
15  private:
16  enum {mxTx=200, version=12}; // max length of text lable
17  struct Head {// keep it divisible by 4
18  int ver; // to trace evolution of the header
19  char title[mxTx];
20  int hid,nBin,nBinX,nBinY; // nBinY=1 for 1-D, for 2D: nBin=nBinX*nBinY
21  int nUnder,nOver; // simplified for 2-D
22  unsigned int dataSize;
23  } head;
24  int *data; // bin container
25  char y2c(float val);// yield -->character
26  void set( int id, const char *tit, int mxBinX, int mxBinY ); // generic histo init
27 
28  public:
29  L2Histo();
30  // all methods w/o '2' ignore value of 'nBinY'
31 
32  L2Histo( int id, const char *tit, int mxBinX, int mxBinY ) { // 2D histo
33  set(id, tit,mxBinX ,mxBinY); }
34  L2Histo( int id, const char *tit, int mxBin) { // 1D histo
35  set(id, tit, mxBin,1 ); }
36  void setTitle(const char *tit); // change title
37 
38  void print( int flag, FILE *fd=stdout);
39  void printCSV( FILE *fd=stdout);
40  void fill ( int binX); // 1D histo
41  void fill ( int binX, int binY); // 2D histo
42  void fillW( int binX, int w); // weight !=1
43  void fillW( int binX, int binY, int w);
44  void write(FILE *fd, int dbg=0);
45  int read(FILE *fd, int dbg=0);
46  void reset(); // erase all entries, retain definition
47  int getNbin(){return head.nBin;}
48  int getNbinX(){return head.nBinX;}
49  bool is1D(){return head.nBinY==1;}
50  bool is2D(){return head.nBinY>1;}
51  int getId(){return head.hid;}
52  int getNunder(){return head.nUnder;}
53  int getNover(){return head.nOver;}
54  bool findMax( int *iMax, int *iFWHM);
55  bool findMean( int *iMean, int *iRMS);
56 
57  void printPed( FILE *fd, int x0, int maxBin,char term='\n');
58  const int *getData(){ return data; };
59  const char *getTitle(){ return head.title; }
60 };
61 
62 
63 #endif
64 
65 
66 /*
67 *********************************************************************
68  $Log: L2Histo.h,v $
69  Revision 1.4 2010/04/18 06:05:32 pibero
70  Address compiler warnings.
71 
72  Revision 1.3 2010/04/17 16:42:09 pibero
73  *** empty log message ***
74 
75  Revision 1.2 2007/11/02 03:03:41 balewski
76  modified L2VirtualAlgo
77 
78  Revision 1.1 2007/10/11 00:33:15 balewski
79  L2algo added
80 
81  Revision 1.3 2006/03/28 19:33:23 balewski
82  ver16b , in L2new
83 
84  Revision 1.2 2006/03/11 17:08:32 balewski
85  now CVS comments should work
86 
87 */
88