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.
7 #include "TH1F.h"
8 #include "TH2F.h"
9 #include "TProfile.h"
10 #include "TProfile2D.h"
11 
13 
15 
16 /*
17 void BaseHistoParams::beginRun(const edm::Run& iRun, TFileDirectory& subrun) {
18 
19  beginRun(iRun.run(),subrun);
20 
21 }
22 */
23 
24 
25 
27  _fillHistograms(fillHistograms), _histograms() { }
28 
29 TH1F** RunHistogramManager::makeTH1F(const char* name, const char* title, const unsigned int nbinx, const double xmin, const double xmax) {
30 
31  TH1F** pointer =new TH1F*(0);
32 
33  BaseHistoParams* hp = new HistoParams<TH1F>(pointer,"TH1F",name,title,nbinx,xmin,xmax);
34  _histograms.push_back(hp);
35 
36  LogDebug("TH1Fmade") << "Histogram " << name << " " << title << " pre-booked:" << _histograms.size();
37 
38  return pointer;
39 
40 }
41 
43 
44  for(std::vector<BaseHistoParams*>::const_iterator hp=_histograms.begin();hp!=_histograms.end();++hp) {
45 
46  delete *hp;
47 
48  }
49  LogDebug("Destructor") << "All BaseHistoParams destroyed ";
50 
51 }
52 
53 TProfile** RunHistogramManager::makeTProfile(const char* name, const char* title, const unsigned int nbinx, const double xmin, const double xmax) {
54 
55  TProfile** pointer =new TProfile*(0);
56 
57  BaseHistoParams* hp = new HistoParams<TProfile>(pointer,"TProfile",name,title,nbinx,xmin,xmax);
58  _histograms.push_back(hp);
59 
60  LogDebug("TProfilemade") << "Histogram " << name << " " << title << " pre-booked:" << _histograms.size();
61 
62  return pointer;
63 
64 }
65 
66 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 ) {
67 
68  TH2F** pointer = new TH2F*(0);
69 
70  BaseHistoParams* hp = new HistoParams<TH2F>(pointer,"TH2F",name,title,nbinx,xmin,xmax,nbiny,ymin,ymax);
71  _histograms.push_back(hp);
72 
73  LogDebug("TH2Fmade") << "Histogram " << name << " " << title << " pre-booked :" << _histograms.size();
74 
75  return pointer;
76 }
77 
78 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 ) {
79 
80  TProfile2D** pointer = new TProfile2D*(0);
81 
82  BaseHistoParams* hp = new HistoParams<TProfile2D>(pointer,"TProfile2D",name,title,nbinx,xmin,xmax,nbiny,ymin,ymax);
83  _histograms.push_back(hp);
84 
85  LogDebug("TProfile2Dmade") << "Histogram " << name << " " << title << " pre-booked :" << _histograms.size();
86 
87  return pointer;
88 }
89 
91 
93  beginRun(iRun,*tfserv);
94 
95 }
96 
98 
99  if(!_fillHistograms) {
100  beginRun(iRun.run(),subdir);
101  }
102  else {
104  iRun.getByLabel("conditionsInEdm",cirb);
105 
106  beginRun(cirb->lhcFillNumber,subdir);
107  }
108 }
109 
110 void RunHistogramManager::beginRun(const unsigned int irun) {
111 
113  beginRun(irun,*tfserv);
114 
115 }
116 
117 void RunHistogramManager::beginRun(const unsigned int irun, TFileDirectory& subdir) {
118 
119  // create/go to the run subdirectory
120 
121  char fillrun[30];
122 
123  if(!_fillHistograms) {
124  sprintf(fillrun,"%s","run");
125  }
126  else {
127  sprintf(fillrun,"%s","fill");
128  }
129 
130  char dirname[300];
131  sprintf(dirname,"%s_%d",fillrun,irun);
132  TFileDirectory subrun = subdir.mkdir(dirname);
133 
134  // loop on the histograms and update the pointer references
135 
136  for(unsigned int ih=0;ih<_histograms.size();++ih) {
137 
138  _histograms[ih]->beginRun(irun,subrun,fillrun);
139 
140  }
141 }
142 
#define LogDebug(id)
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Definition: Run.h:177
RunNumber_t run() const
Definition: RunBase.h:42
RunHistogramManager(const bool fillHistograms=false)
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
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:33