CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RunHistogramManager.cc
Go to the documentation of this file.
6 #include "TH1F.h"
7 #include "TH2F.h"
8 #include "TProfile.h"
9 #include "TProfile2D.h"
10 
12 
14 
16 
17  beginRun(iRun.run(),subrun);
18 
19 }
20 
21 
22 
23 
25  _histograms() { }
26 
27 TH1F** RunHistogramManager::makeTH1F(const char* name, const char* title, const unsigned int nbinx, const double xmin, const double xmax) {
28 
29  TH1F** pointer =new TH1F*(0);
30 
31  BaseHistoParams* hp = new HistoParams<TH1F>(pointer,"TH1F",name,title,nbinx,xmin,xmax);
32  _histograms.push_back(hp);
33 
34  LogDebug("TH1Fmade") << "Histogram " << name << " " << title << " pre-booked:" << _histograms.size();
35 
36  return pointer;
37 
38 }
39 
41 
42  for(std::vector<BaseHistoParams*>::const_iterator hp=_histograms.begin();hp!=_histograms.end();++hp) {
43 
44  delete *hp;
45 
46  }
47  LogDebug("Destructor") << "All BaseHistoParams destroyed ";
48 
49 }
50 
51 TProfile** RunHistogramManager::makeTProfile(const char* name, const char* title, const unsigned int nbinx, const double xmin, const double xmax) {
52 
53  TProfile** pointer =new TProfile*(0);
54 
55  BaseHistoParams* hp = new HistoParams<TProfile>(pointer,"TProfile",name,title,nbinx,xmin,xmax);
56  _histograms.push_back(hp);
57 
58  LogDebug("TProfilemade") << "Histogram " << name << " " << title << " pre-booked:" << _histograms.size();
59 
60  return pointer;
61 
62 }
63 
64 TH2F** RunHistogramManager::makeTH2F(const char* name, const char* title, const unsigned int nbinx, const double xmin, const double xmax, const unsigned int nbiny, const double ymin, const double ymax ) {
65 
66  TH2F** pointer = new TH2F*(0);
67 
68  BaseHistoParams* hp = new HistoParams<TH2F>(pointer,"TH2F",name,title,nbinx,xmin,xmax,nbiny,ymin,ymax);
69  _histograms.push_back(hp);
70 
71  LogDebug("TH2Fmade") << "Histogram " << name << " " << title << " pre-booked :" << _histograms.size();
72 
73  return pointer;
74 }
75 
76 TProfile2D** RunHistogramManager::makeTProfile2D(const char* name, const char* title, const unsigned int nbinx, const double xmin, const double xmax, const unsigned int nbiny, const double ymin, const double ymax ) {
77 
78  TProfile2D** pointer = new TProfile2D*(0);
79 
80  BaseHistoParams* hp = new HistoParams<TProfile2D>(pointer,"TProfile2D",name,title,nbinx,xmin,xmax,nbiny,ymin,ymax);
81  _histograms.push_back(hp);
82 
83  LogDebug("TProfile2Dmade") << "Histogram " << name << " " << title << " pre-booked :" << _histograms.size();
84 
85  return pointer;
86 }
87 
89 
90  beginRun(iRun.run());
91 
92 }
93 
94 void RunHistogramManager::beginRun(const unsigned int irun) {
95 
97  beginRun(irun,*tfserv);
98 
99 }
100 
101 void RunHistogramManager::beginRun(const unsigned int irun, TFileDirectory& subdir) {
102 
103  // create/go to the run subdirectory
104 
105  char dirname[300];
106  sprintf(dirname,"run_%d",irun);
107  TFileDirectory subrun = subdir.mkdir(dirname);
108 
109  // loop on the histograms and update the pointer references
110 
111  for(unsigned int ih=0;ih<_histograms.size();++ih) {
112 
113  _histograms[ih]->beginRun(irun,subrun);
114 
115  }
116 }
117 
#define LogDebug(id)
RunNumber_t run() const
Definition: RunBase.h:44
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
TProfile ** makeTProfile(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
std::vector< BaseHistoParams * > _histograms
virtual void beginRun(const edm::Run &iRun, TFileDirectory &subrun)
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
TProfile2D ** makeTProfile2D(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax, const unsigned int nbiny, const double ymin, const double ymax)
void beginRun(const edm::Run &iRun)
TH2F ** makeTH2F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax, const unsigned int nbiny, const double ymin, const double ymax)
Definition: Run.h:31