CMS 3D CMS Logo

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 
15 /*
16 void BaseHistoParams::beginRun(const edm::Run& iRun, TFileDirectory& subrun) {
17 
18  beginRun(iRun.run(),subrun);
19 
20 }
21 */
22 
24  : _fillHistograms(fillHistograms),
25  _histograms(),
26  _conditionsInRunToken(iC.consumes<edm::ConditionsInRunBlock, edm::InRun>(edm::InputTag("conditionsInEdm"))) {}
27 
29  : _fillHistograms(fillHistograms),
30  _histograms(),
31  _conditionsInRunToken(iC.consumes<edm::ConditionsInRunBlock, edm::InRun>(edm::InputTag("conditionsInEdm"))) {}
32 
34  const char* name, const char* title, const unsigned int nbinx, const double xmin, const double xmax) {
35  TH1F** pointer = new TH1F*(nullptr);
36 
37  BaseHistoParams* hp = new HistoParams<TH1F>(pointer, "TH1F", name, title, nbinx, xmin, xmax);
38  _histograms.push_back(hp);
39 
40  LogDebug("TH1Fmade") << "Histogram " << name << " " << title << " pre-booked:" << _histograms.size();
41 
42  return pointer;
43 }
44 
46  for (std::vector<BaseHistoParams*>::const_iterator hp = _histograms.begin(); hp != _histograms.end(); ++hp) {
47  delete *hp;
48  }
49  LogDebug("Destructor") << "All BaseHistoParams destroyed ";
50 }
51 
53  const char* name, const char* title, const unsigned int nbinx, const double xmin, const double xmax) {
54  TProfile** pointer = new TProfile*(nullptr);
55 
56  BaseHistoParams* hp = new HistoParams<TProfile>(pointer, "TProfile", name, title, nbinx, xmin, xmax);
57  _histograms.push_back(hp);
58 
59  LogDebug("TProfilemade") << "Histogram " << name << " " << title << " pre-booked:" << _histograms.size();
60 
61  return pointer;
62 }
63 
65  const char* title,
66  const unsigned int nbinx,
67  const double xmin,
68  const double xmax,
69  const unsigned int nbiny,
70  const double ymin,
71  const double ymax) {
72  TH2F** pointer = new TH2F*(nullptr);
73 
74  BaseHistoParams* hp = new HistoParams<TH2F>(pointer, "TH2F", name, title, nbinx, xmin, xmax, nbiny, ymin, ymax);
75  _histograms.push_back(hp);
76 
77  LogDebug("TH2Fmade") << "Histogram " << name << " " << title << " pre-booked :" << _histograms.size();
78 
79  return pointer;
80 }
81 
82 TProfile2D** RunHistogramManager::makeTProfile2D(const char* name,
83  const char* title,
84  const unsigned int nbinx,
85  const double xmin,
86  const double xmax,
87  const unsigned int nbiny,
88  const double ymin,
89  const double ymax) {
90  TProfile2D** pointer = new TProfile2D*(nullptr);
91 
93  new HistoParams<TProfile2D>(pointer, "TProfile2D", name, title, nbinx, xmin, xmax, nbiny, ymin, ymax);
94  _histograms.push_back(hp);
95 
96  LogDebug("TProfile2Dmade") << "Histogram " << name << " " << title << " pre-booked :" << _histograms.size();
97 
98  return pointer;
99 }
100 
103  beginRun(iRun, tfserv->tFileDirectory());
104 }
105 
107  if (!_fillHistograms) {
108  beginRun(iRun.run(), subdir);
109  } else {
110  unsigned int fillnum = 0;
111 
113  iRun.getByToken(_conditionsInRunToken, cirb);
114 
115  if (!cirb.failedToGet() && cirb.isValid())
116  fillnum = cirb->lhcFillNumber;
117 
118  beginRun(fillnum, subdir);
119  }
120 }
121 
122 void RunHistogramManager::beginRun(const unsigned int irun) {
124  beginRun(irun, tfserv->tFileDirectory());
125 }
126 
127 void RunHistogramManager::beginRun(const unsigned int irun, TFileDirectory& subdir) {
128  // create/go to the run subdirectory
129 
130  char fillrun[30];
131 
132  if (!_fillHistograms) {
133  sprintf(fillrun, "%s", "run");
134  } else {
135  sprintf(fillrun, "%s", "fill");
136  }
137 
138  char dirname[300];
139  sprintf(dirname, "%s_%d", fillrun, irun);
140  TFileDirectory subrun = subdir.mkdir(dirname);
141 
142  // loop on the histograms and update the pointer references
143 
144  for (unsigned int ih = 0; ih < _histograms.size(); ++ih) {
145  _histograms[ih]->beginRun(irun, subrun, fillrun);
146  }
147 }
HistoParams
Definition: RunHistogramManager.h:28
TFileDirectory::mkdir
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileDirectory.cc:112
BaseHistoParams::BaseHistoParams
BaseHistoParams()
Definition: RunHistogramManager.cc:11
MessageLogger.h
edm::Run
Definition: Run.h:45
RunHistogramManager::makeTH2F
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: RunHistogramManager.cc:64
edm
HLT enums.
Definition: AlignableModifier.h:19
HistoParams< TH2F >
Definition: RunHistogramManager.h:89
RPCNoise_cfi.fillHistograms
fillHistograms
Definition: RPCNoise_cfi.py:8
TFileService::tFileDirectory
TFileDirectory & tFileDirectory()
Definition: TFileService.h:42
TFileDirectory
Definition: TFileDirectory.h:24
edm::Handle
Definition: AssociativeIterator.h:50
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
RunHistogramManager::_histograms
std::vector< BaseHistoParams * > _histograms
Definition: RunHistogramManager.h:243
edm::InRun
Definition: BranchType.h:11
BaseHistoParams::~BaseHistoParams
virtual ~BaseHistoParams()
Definition: RunHistogramManager.cc:13
edm::ConditionsInRunBlock::lhcFillNumber
uint32_t lhcFillNumber
Definition: ConditionsInEdm.h:24
BTVHLTOfflineSource_cfi.dirname
dirname
Definition: BTVHLTOfflineSource_cfi.py:7
trackingPlots.hp
hp
Definition: trackingPlots.py:1246
RunHistogramManager::_conditionsInRunToken
edm::EDGetTokenT< edm::ConditionsInRunBlock > _conditionsInRunToken
Definition: RunHistogramManager.h:244
edm::Run::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Run.h:315
L1TOccupancyClient_cfi.ymax
ymax
Definition: L1TOccupancyClient_cfi.py:43
RunHistogramManager::~RunHistogramManager
~RunHistogramManager()
Definition: RunHistogramManager.cc:45
Service.h
RunHistogramManager.h
BaseHistoParams
Definition: RunHistogramManager.h:18
Run.h
TFileService.h
RunHistogramManager::makeTH1F
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
Definition: RunHistogramManager.cc:33
edm::HandleBase::failedToGet
bool failedToGet() const
Definition: HandleBase.h:72
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
RunHistogramManager::makeTProfile2D
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)
Definition: RunHistogramManager.cc:82
RunHistogramManager::beginRun
void beginRun(const edm::Run &iRun)
Definition: RunHistogramManager.cc:101
edm::Service< TFileService >
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
L1TOccupancyClient_cfi.ymin
ymin
Definition: L1TOccupancyClient_cfi.py:43
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
RunHistogramManager::_fillHistograms
bool _fillHistograms
Definition: RunHistogramManager.h:242
HistoParams< TProfile2D >
Definition: RunHistogramManager.h:150
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
RunHistogramManager::RunHistogramManager
RunHistogramManager(edm::ConsumesCollector &&iC, const bool fillHistograms=false)
Definition: RunHistogramManager.cc:28
RunHistogramManager::makeTProfile
TProfile ** makeTProfile(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
Definition: RunHistogramManager.cc:52