24 int nx,
float xmin,
float xmax,
25 int ny,
float ymin,
float ymax) {
29 std::cout <<
"Histos::book() : Histogram "
30 << name <<
" exists already. Nothing done" << std::endl;
36 theHistos[
name] =
new TH2F(name.c_str(),
"",nx,xmin,xmax,ny,ymin,ymax);
52 int nx,
float xmin,
float xmax,
53 const std::string& option) {
57 std::cout <<
"Histos::book() : Histogram "
58 << name <<
" exists already. Nothing done" << std::endl;
62 theHistos[
name] =
new TProfile(name.c_str(),
"",nx,xmin,xmax,option.c_str());
71 TFile *
f =
new TFile(file.c_str(),
"recreate");
77 (*ho).second->Write((*ho).first.c_str());
86 if (
theTypes[(*hh).first] == 1 ) ( (TH1F*)((*hh).second) )->Write();
87 if (
theTypes[(*hh).first] == 2 ) ( (TH2F*)((*hh).second) )->Write();
88 if (
theTypes[(*hh).first] == 3 ) ( (TProfile*)((*hh).second) )->Write();
93 if (
theTypes[name] == 1 ) ( (TH1F*)((*hh).second) )->Write();
94 if (
theTypes[name] == 2 ) ( (TH2F*)((*hh).second) )->Write();
95 if (
theTypes[name] == 3 ) ( (TProfile*)((*hh).second) )->Write();
100 << name <<
" does not exist. Nothing done" << std::endl;
108 Histos::divide(
const std::string& h1,
const std::string& h2,
const std::string& h3) {
119 std::cout <<
"Histos::divide() : First histo "
120 << h1 <<
" does not exist" << std::endl;
123 std::cout <<
"Histos::divide() : Second histo "
124 << h2 <<
" does not exist" << std::endl;
127 std::cout <<
"Histos::divide() : Third histo "
128 << h3 <<
" already exists" << std::endl;
134 theHistos[h3] = (TH1F*) ((*hh1).second)->Clone(h3.c_str());
136 ((TH1F*)
theHistos[h3])->Divide( (TH1F*)( (*hh2).second ) );
142 theHistos[h3] = (TH2F*)((*hh1).second)->Clone(h3.c_str());
144 ((TH2F*)
theHistos[h3])->Divide( (TH2F*)( (*hh2).second ) );
157 std::cout <<
"FamosHistos::addObject() : Object " << name
158 <<
" already exists" << std::endl;
162 theObjects.insert(std::pair<std::string,TObject*>(name,obj->Clone()));
176 std::cout <<
"Histos::fill() : Histogram " << name
177 <<
" does not exist" << std::endl;
182 ( (TH1F*) ( (*hh).second ) )->
Fill(val1,val2);
185 ( (TH2F*) ( (*hh).second ) )->
Fill(val1,val2,val3);
188 ( (TProfile*) ( (*hh).second ) )->
Fill(val1,val2,val3);
195 std::ostringstream oss;
196 oss << name << number;
197 fill(oss.str(),val1,val2,val3);
201 int nx ,
float xmin ,
float xmax,
202 int ny ,
float ymin,
float ymax)
206 std::cout <<
" Histos: problem with bookByNumber - Do nothing" << std::endl;
208 for(
int ih=n1;ih<=n2;++ih)
210 std::ostringstream oss;
212 book(oss.str(),nx,xmin,xmax,ny,ymin,ymax);
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.)
std::map< std::string, TObject * >::const_iterator HistoItr
std::map< std::string, unsigned > theTypes
void fill(const std::string &name, float val1, float val2=1., float val3=1.)
Fill an histogram.
void addObject(const std::string &name, TObject *obj)
Add any object.
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
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)
static Histos * instance()
void fillByNumber(const std::string &name, int number, float val1, float val2=1., float val3=1.)
void put(const std::string &file, std::string name="")
Write one or all histogram(s) in a file.
void divide(const std::string &h1, const std::string &h2, const std::string &h3)
Divide two histograms and put the result in the first.
std::map< std::string, TObject * > theHistos
std::map< std::string, TObject * > theObjects
virtual ~Histos()
Destructor.