test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Histos.h
Go to the documentation of this file.
1 #ifndef Histos_H
2 #define Histos_H
3 
9 // for debugging
10 
11 //#include "TROOT.h"
12 #include "TObject.h"
13 
14 #include <string>
15 #include <map>
16 #include <iostream>
17 //#include <sstream>
18 
19 class Histos
20 {
21  public:
22 
23  typedef std::map<std::string,TObject*>::const_iterator HistoItr;
24 
25  static Histos* instance();
26 
28  virtual ~Histos();
29 
31  void book(const std::string& name,
32  int nx , float xmin , float xmax,
33  int ny=0, float ymin=0., float ymax=0.);
34 
35  // Same as before. Creates n2-n1 histos with name name+n1 ... name+n2
36  void bookByNumber(const std::string& name, int n1,int n2,
37  int nx , float xmin , float xmax,
38  int ny=0, float ymin=0., float ymax=0.);
39 
40 
44  void book(const std::string& name, int nx, float xmin, float xmax,
45  const std::string& option);
46 
47 
49  void put(const std::string& file, std::string name="");
50 
52  void divide(const std::string& h1, const std::string& h2, const std::string& h3);
53 
55  void fill(const std::string& name, float val1, float val2=1., float val3=1.);
56 
57  // Fill a series of histos. The name is name+number
58  void fillByNumber(const std::string& name,int number,float val1,float val2=1.,float val3=1.);
59 
61  void addObject(const std::string& name, TObject * obj);
62 
64  void debug(std::string p="") const {std::cout << " Histos myMap : "<< &theHistos << " " << p <<std::endl;}
65 
66  private:
67 
68  // The constructor is hidden as we do not want to construct
69  // more than one instance.
70  Histos();
71 
72  // The instance
73  static Histos* myself;
74 
75  // The histos booked
76  TObject* theHisto;
77  std::map<std::string,TObject*> theHistos;
78  std::map<std::string,unsigned> theTypes;
79  std::map<std::string,TObject*> theObjects;
80 
81 };
82 #endif
void bookByNumber(const std::string &name, int n1, int n2, int nx, float xmin, float xmax, int ny=0, float ymin=0., float ymax=0.)
Definition: Histos.cc:200
std::map< std::string, TObject * >::const_iterator HistoItr
Definition: Histos.h:23
std::map< std::string, unsigned > theTypes
Definition: Histos.h:78
void debug(std::string p="") const
Definition: Histos.h:64
void fill(const std::string &name, float val1, float val2=1., float val3=1.)
Fill an histogram.
Definition: Histos.cc:168
void addObject(const std::string &name, TObject *obj)
Add any object.
Definition: Histos.cc:152
void book(const std::string &name, int nx, float xmin, float xmax, int ny=0, float ymin=0., float ymax=0.)
Book an histogram (1D or 2D)
Definition: Histos.cc:23
static Histos * instance()
Definition: Histos.cc:15
void fillByNumber(const std::string &name, int number, float val1, float val2=1., float val3=1.)
Definition: Histos.cc:193
void put(const std::string &file, std::string name="")
Write one or all histogram(s) in a file.
Definition: Histos.cc:69
static Histos * myself
Definition: Histos.h:73
Histos()
Definition: Histos.cc:13
Definition: Histos.h:19
void divide(const std::string &h1, const std::string &h2, const std::string &h3)
Divide two histograms and put the result in the first.
Definition: Histos.cc:108
tuple cout
Definition: gather_cfg.py:121
std::map< std::string, TObject * > theHistos
Definition: Histos.h:77
std::map< std::string, TObject * > theObjects
Definition: Histos.h:79
TObject * theHisto
Definition: Histos.h:76
virtual ~Histos()
Destructor.
Definition: Histos.cc:20