// A test histogram maker class -*- C++ -*- #ifndef _HistoMaker_H #define _HistoMaker_H /*___________________________________________________________________________*/ #include "TObject.h" #include "TH1.h" #include "TRandom.h" #include #include using namespace std; /*___________________________________________________________________________*/ class HistoMaker { public: // create/copy/destory: HistoMaker(){} HistoMaker(const HistoMaker &__hmaker){} virtual ~HistoMaker(){} HistoMaker& operator=(const HistoMaker &__hmaker){return *this;} // functions: vector GetHistos(int __num_histos,double __mean,double __sig, int __num_entries,int __seed) const { TRandom random(__seed); vector histos(__num_histos); char hname[100],htitle[100]; for(int h = 0; h < __num_histos; h++){ sprintf(hname,"hGaus_%d",h); sprintf(htitle,"Gaussian: #mu = %.2f #sigma = %.2f",__mean,__sig); cout << "Ready to build " << hname << "..." << endl; histos[h] = new TH1F(hname,htitle,100,__mean - 5*__sig,__mean + 5*__sig); cout << "Build successfull." << endl; for(int entry = 0; entry < __num_entries; entry++){ histos[h]->Fill(random.Gaus(__mean,__sig)); } } return histos; } ClassDef(HistoMaker,0); // Makes histograms }; /*___________________________________________________________________________*/ #endif /* _HistoMaker_H */