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->tFileDirectory());
94 
95 }
96 
98 
99  if(!_fillHistograms) {
100  beginRun(iRun.run(),subdir);
101  }
102  else {
103  unsigned int fillnum = 0;
104 
106  iRun.getByLabel("conditionsInEdm",cirb);
107 
108  if(!cirb.failedToGet() && cirb.isValid()) fillnum=cirb->lhcFillNumber;
109 
110  beginRun(fillnum,subdir);
111  }
112 }
113 
114 void RunHistogramManager::beginRun(const unsigned int irun) {
115 
117  beginRun(irun, tfserv->tFileDirectory());
118 
119 }
120 
121 void RunHistogramManager::beginRun(const unsigned int irun, TFileDirectory& subdir) {
122 
123  // create/go to the run subdirectory
124 
125  char fillrun[30];
126 
127  if(!_fillHistograms) {
128  sprintf(fillrun,"%s","run");
129  }
130  else {
131  sprintf(fillrun,"%s","fill");
132  }
133 
134  char dirname[300];
135  sprintf(dirname,"%s_%d",fillrun,irun);
136  TFileDirectory subrun = subdir.mkdir(dirname);
137 
138  // loop on the histograms and update the pointer references
139 
140  for(unsigned int ih=0;ih<_histograms.size();++ih) {
141 
142  _histograms[ih]->beginRun(irun,subrun,fillrun);
143 
144  }
145 }
146 
#define LogDebug(id)
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Definition: Run.h:200
RunNumber_t run() const
Definition: RunBase.h:42
RunHistogramManager(const bool fillHistograms=false)
TFileDirectory & tFileDirectory()
Definition: TFileService.h:42
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
TProfile ** makeTProfile(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
std::vector< BaseHistoParams * > _histograms
bool isValid() const
Definition: HandleBase.h:76
bool failedToGet() const
Definition: HandleBase.h:80
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:41