CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/FastSimulation/Utilities/interface/Histos.h

Go to the documentation of this file.
00001 #ifndef Histos_H
00002 #define Histos_H
00003 
00009 // for debugging
00010 
00011 //#include "TROOT.h"
00012 #include "TObject.h"
00013 
00014 #include <string>
00015 #include <map>
00016 #include <iostream>
00017 //#include <sstream>
00018 
00019 class Histos
00020 {
00021  public:
00022 
00023   typedef std::map<std::string,TObject*>::const_iterator HistoItr;
00024 
00025   static Histos* instance();
00026 
00028   virtual ~Histos();
00029   
00031   void book(const std::string& name, 
00032             int nx  , float xmin   , float xmax,
00033             int ny=0, float ymin=0., float ymax=0.);
00034 
00035   // Same as before. Creates n2-n1 histos with name name+n1 ... name+n2
00036   void bookByNumber(const std::string& name, int n1,int n2,
00037             int nx  , float xmin   , float xmax,
00038             int ny=0, float ymin=0., float ymax=0.);
00039 
00040 
00044   void book(const std::string& name, int nx, float xmin, float xmax,
00045             const std::string& option);
00046 
00047 
00049   void put(const std::string& file, std::string name="");
00050 
00052   void divide(const std::string& h1, const std::string& h2, const std::string& h3);
00053 
00055   void fill(const std::string& name, float val1, float val2=1., float val3=1.);
00056 
00057   // Fill a series of histos. The name is name+number
00058   void fillByNumber(const std::string& name,int number,float val1,float val2=1.,float val3=1.);
00059 
00061   void addObject(const std::string& name, TObject * obj);
00062 
00064     void debug(std::string p="") const {std::cout << " Histos myMap : "<< &theHistos << " " << p <<std::endl;}
00065 
00066  private:
00067 
00068   // The constructor is hidden as we do not want to construct
00069   // more than one instance.
00070   Histos();
00071 
00072   // The instance
00073   static Histos* myself;
00074 
00075   // The histos booked
00076   TObject* theHisto;
00077   std::map<std::string,TObject*> theHistos;
00078   std::map<std::string,unsigned> theTypes;
00079   std::map<std::string,TObject*> theObjects;
00080   
00081 };
00082 #endif