CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
SplittingConfigurableHisto Class Reference

#include <ConfigurableHisto.h>

Inheritance diagram for SplittingConfigurableHisto:
ConfigurableHisto

Public Member Functions

void book (TFileDirectory *dir) override
 
ConfigurableHistoclone () const override
 
void complete ()
 
void fill (const edm::Event &e) override
 
 SplittingConfigurableHisto (HType t, std::string name, edm::ParameterSet &pset)
 
- Public Member Functions inherited from ConfigurableHisto
void complete ()
 
 ConfigurableHisto (HType t, std::string name, edm::ParameterSet &iConfig)
 
TH1 * h ()
 
const HTypetype ()
 
virtual ~ConfigurableHisto ()
 

Private Types

typedef std::map< const Splitter *, std::vector< ConfigurableHisto * > > SubHistoMap
 
typedef std::map< const Splitter *, THStack * > SubHistoStacks
 

Private Member Functions

 SplittingConfigurableHisto (const SplittingConfigurableHisto &master)
 

Private Attributes

const Splittersplitter_
 
THStack * stack_
 
SubHistoMap subHistoMap_
 
std::vector< ConfigurableHisto * > subHistos_
 
SubHistoStacks subHistoStacks_
 

Additional Inherited Members

- Public Types inherited from ConfigurableHisto
enum  HType { h1, h2, prof }
 
- Protected Member Functions inherited from ConfigurableHisto
 ConfigurableHisto (const ConfigurableHisto &master)
 
- Protected Attributes inherited from ConfigurableHisto
edm::ParameterSet conf_
 
TH1 * h_
 
std::string name_
 
HType type_
 
const CachingVariablew_
 
const CachingVariablex_
 
const CachingVariabley_
 
const CachingVariablez_
 

Detailed Description

Definition at line 241 of file ConfigurableHisto.h.

Member Typedef Documentation

◆ SubHistoMap

typedef std::map<const Splitter*, std::vector<ConfigurableHisto*> > SplittingConfigurableHisto::SubHistoMap
private

Definition at line 410 of file ConfigurableHisto.h.

◆ SubHistoStacks

typedef std::map<const Splitter*, THStack*> SplittingConfigurableHisto::SubHistoStacks
private

Definition at line 411 of file ConfigurableHisto.h.

Constructor & Destructor Documentation

◆ SplittingConfigurableHisto() [1/2]

SplittingConfigurableHisto::SplittingConfigurableHisto ( HType  t,
std::string  name,
edm::ParameterSet pset 
)
inline

Definition at line 243 of file ConfigurableHisto.h.

244  : ConfigurableHisto(t, name, pset), splitter_(nullptr) {
245  std::string title = pset.getParameter<std::string>("title");
246 
247  //allow for many splitters ...
248  if (pset.exists("splitters")) {
249  //you want more than one splitter
250  std::vector<std::string> splitters = pset.getParameter<std::vector<std::string> >("splitters");
251  for (unsigned int s = 0; s != splitters.size(); ++s) {
252  const CachingVariable* v = edm::Service<VariableHelperService>()->get().variable(splitters[s]);
253  const Splitter* splitter = dynamic_cast<const Splitter*>(v);
254  if (!splitter) {
255  edm::LogError("SplittingConfigurableHisto")
256  << "for: " << name_ << " the splitting variable: " << splitters[s] << " is not a Splitter";
257  continue;
258  }
259 
260  //insert in the map
261  std::vector<ConfigurableHisto*>& insertedHisto = subHistoMap_[splitter];
262  //now configure the histograms
263  unsigned int mSlots = splitter->maxSlots();
264  for (unsigned int i = 0; i != mSlots; ++i) {
265  //--- std::cout<<" slot: "<<i<<std::endl;
266  const std::string& slabel = splitter->shortLabel(i);
267  const std::string& label = splitter->label(i);
268  edm::ParameterSet mPset = pset;
269  edm::Entry e("string", title + " for " + label, true);
270  mPset.insert(true, "title", e);
271  insertedHisto.push_back(new ConfigurableHisto(t, name + slabel, mPset));
272  } //loop on slots
273  } //loop on splitters
274 
275  } //if splitters exists
276  else {
277  //single splitter
278  //get the splitting variable
279  const CachingVariable* v =
280  edm::Service<VariableHelperService>()->get().variable(pset.getParameter<std::string>("splitter"));
281  splitter_ = dynamic_cast<const Splitter*>(v);
282  if (!splitter_) {
283  edm::LogError("SplittingConfigurableHisto")
284  << "for: " << name_ << " the splitting variable: " << v->name() << " is not a Splitter";
285  } else {
286  //configure the splitted plots
287  unsigned int mSlots = splitter_->maxSlots();
288  for (unsigned int i = 0; i != mSlots; i++) {
289  const std::string& slabel = splitter_->shortLabel(i);
290  const std::string& label = splitter_->label(i);
291  edm::ParameterSet mPset = pset;
292  edm::Entry e("string", title + " for " + label, true);
293  mPset.insert(true, "title", e);
294  subHistos_.push_back(new ConfigurableHisto(t, name + slabel, mPset));
295  }
296  }
297  }
298  } //end of ctor

References ConfigurableHisto::ConfigurableHisto(), MillePedeFileConverter_cfg::e, mps_fire::i, edm::ParameterSet::insert(), label, Splitter::label(), Splitter::maxSlots(), Skims_PA_cff::name, ConfigurableHisto::name_, muonDTDigis_cfi::pset, alignCSCRings::s, Splitter::shortLabel(), confdb::splitter(), splitter_, AlCaHLTBitMon_QueryRunRegistry::string, subHistoMap_, subHistos_, OrderedSet::t, overlapproblemtsosanalyzer_cfi::title, and findQualityFiles::v.

Referenced by clone().

◆ SplittingConfigurableHisto() [2/2]

SplittingConfigurableHisto::SplittingConfigurableHisto ( const SplittingConfigurableHisto master)
inlineprivate

Definition at line 391 of file ConfigurableHisto.h.

392  splitter_ = master.splitter_;
393  if (!master.subHistoMap_.empty()) {
394  SubHistoMap::const_iterator i = master.subHistoMap_.begin();
395  SubHistoMap::const_iterator i_end = master.subHistoMap_.end();
396  for (; i != i_end; ++i) {
397  const std::vector<ConfigurableHisto*>& masterHistos = i->second;
398  std::vector<ConfigurableHisto*>& clonedHistos = subHistoMap_[i->first];
399  for (unsigned int i = 0; i != masterHistos.size(); i++) {
400  clonedHistos.push_back(masterHistos[i]->clone());
401  }
402  }
403  } else {
404  for (unsigned int i = 0; i != master.subHistos_.size(); i++) {
405  subHistos_.push_back(master.subHistos_[i]->clone());
406  }
407  }
408  }

References clone(), mps_fire::i, volumeBasedMagneticField_160812_cfi::master, splitter_, subHistoMap_, and subHistos_.

Member Function Documentation

◆ book()

void SplittingConfigurableHisto::book ( TFileDirectory dir)
inlineoverridevirtual

Reimplemented from ConfigurableHisto.

Definition at line 300 of file ConfigurableHisto.h.

300  {
301  //book the base histogram
303 
304  if (!subHistoMap_.empty()) {
305  SubHistoMap::iterator i = subHistoMap_.begin();
306  SubHistoMap::iterator i_end = subHistoMap_.end();
307  for (; i != i_end; ++i) {
308  for (unsigned int h = 0; h != i->second.size(); ++h) {
309  i->second[h]->book(dir);
310  }
311  //book the THStack
312  std::string sName = name_ + "_" + i->first->name();
313  std::string sTitle = "Stack histogram of " + name_ + " for splitter " + i->first->name();
314  subHistoStacks_[i->first] = dir->make<THStack>(sName.c_str(), sTitle.c_str());
315  }
316  } else {
317  for (unsigned int h = 0; h != subHistos_.size(); h++) {
318  subHistos_[h]->book(dir);
319  }
320  //book a THStack
321  std::string sName = name_ + "_" + splitter_->name();
322  std::string sTitle = "Stack histogram of " + name_ + " for splitter " + splitter_->name();
323  stack_ = dir->make<THStack>(sName.c_str(), sTitle.c_str());
324  }
325  }

References ConfigurableHisto::book(), DeadROC_duringRun::dir, ConfigurableHisto::h(), mps_fire::i, CachingVariable::name(), ConfigurableHisto::name_, splitter_, stack_, AlCaHLTBitMon_QueryRunRegistry::string, subHistoMap_, subHistos_, and subHistoStacks_.

◆ clone()

ConfigurableHisto* SplittingConfigurableHisto::clone ( void  ) const
inlineoverridevirtual

Reimplemented from ConfigurableHisto.

Definition at line 327 of file ConfigurableHisto.h.

327 { return new SplittingConfigurableHisto(*this); }

References SplittingConfigurableHisto().

Referenced by SplittingConfigurableHisto().

◆ complete()

void SplittingConfigurableHisto::complete ( )
inline

Definition at line 370 of file ConfigurableHisto.h.

370  {
371  if (!subHistoMap_.empty()) {
372  //fill up the stacks
373  SubHistoMap::iterator i = subHistoMap_.begin();
374  SubHistoMap::iterator i_end = subHistoMap_.end();
375  for (; i != i_end; ++i) {
376  for (unsigned int h = 0; h != i->second.size(); h++) {
377  // if (i->second[h]->h()->Integral==0) continue;// do not add empty histograms. NO, because it will be tough to merge two THStack
378  subHistoStacks_[i->first]->Add(i->second[h]->h(), i->first->label(h).c_str());
379  }
380  }
381 
382  } else {
383  //fill up the only stack
384  for (unsigned int i = 0; i != subHistos_.size(); i++) {
385  stack_->Add(subHistos_[i]->h(), splitter_->label(i).c_str());
386  }
387  }
388  }

References ConfigurableHisto::h(), mps_fire::i, Splitter::label(), splitter_, stack_, subHistoMap_, subHistos_, and subHistoStacks_.

◆ fill()

void SplittingConfigurableHisto::fill ( const edm::Event e)
inlineoverridevirtual

Reimplemented from ConfigurableHisto.

Definition at line 329 of file ConfigurableHisto.h.

329  {
330  //fill the base histogram
332 
333  if (!subHistoMap_.empty()) {
334  SubHistoMap::iterator i = subHistoMap_.begin();
335  SubHistoMap::iterator i_end = subHistoMap_.end();
336  for (; i != i_end; ++i) {
337  const Splitter* splitter = i->first;
338  if (!splitter)
339  continue;
340  if (!splitter->compute(e))
341  continue;
342  unsigned int slot = (unsigned int)(*splitter)(e);
343  if (slot >= i->second.size()) {
344  edm::LogError("SplittingConfigurableHisto")
345  << "slot index: " << slot << " is bigger than slots size: " << i->second.size()
346  << " from variable value: " << (*splitter)(e);
347  continue;
348  }
349  //fill in the proper slot
350  i->second[slot]->fill(e);
351  }
352  } else {
353  //fill the component histograms
354  if (!splitter_)
355  return;
356  if (!splitter_->compute(e)) {
357  return;
358  }
359  unsigned int slot = (unsigned int)(*splitter_)(e);
360  if (slot >= subHistos_.size()) {
361  edm::LogError("SplittingConfigurableHisto")
362  << "slot index: " << slot << " is bigger than slots size: " << subHistos_.size()
363  << " from variable value: " << (*splitter_)(e);
364  return;
365  }
366  subHistos_[slot]->fill(e);
367  }
368  }

References CachingVariable::compute(), MillePedeFileConverter_cfg::e, ConfigurableHisto::fill(), mps_fire::i, createfilelist::int, splitter_, subHistoMap_, and subHistos_.

Member Data Documentation

◆ splitter_

const Splitter* SplittingConfigurableHisto::splitter_
private

Definition at line 415 of file ConfigurableHisto.h.

Referenced by book(), complete(), fill(), and SplittingConfigurableHisto().

◆ stack_

THStack* SplittingConfigurableHisto::stack_
private

Definition at line 418 of file ConfigurableHisto.h.

Referenced by book(), and complete().

◆ subHistoMap_

SubHistoMap SplittingConfigurableHisto::subHistoMap_
private

Definition at line 413 of file ConfigurableHisto.h.

Referenced by book(), complete(), fill(), and SplittingConfigurableHisto().

◆ subHistos_

std::vector<ConfigurableHisto*> SplittingConfigurableHisto::subHistos_
private

Definition at line 416 of file ConfigurableHisto.h.

Referenced by book(), complete(), fill(), and SplittingConfigurableHisto().

◆ subHistoStacks_

SubHistoStacks SplittingConfigurableHisto::subHistoStacks_
private

Definition at line 412 of file ConfigurableHisto.h.

Referenced by book(), and complete().

splitter
Definition: splitter.py:1
Splitter::shortLabel
const std::string shortLabel(unsigned int i) const
Definition: CachingVariable.h:195
mps_fire.i
i
Definition: mps_fire.py:355
SplittingConfigurableHisto::subHistoMap_
SubHistoMap subHistoMap_
Definition: ConfigurableHisto.h:413
SplittingConfigurableHisto::clone
ConfigurableHisto * clone() const override
Definition: ConfigurableHisto.h:327
ConfigurableHisto::ConfigurableHisto
ConfigurableHisto(HType t, std::string name, edm::ParameterSet &iConfig)
Definition: ConfigurableHisto.h:73
CachingVariable
Definition: CachingVariable.h:40
findQualityFiles.v
v
Definition: findQualityFiles.py:179
SplittingConfigurableHisto::stack_
THStack * stack_
Definition: ConfigurableHisto.h:418
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::ParameterSet::insert
void insert(bool ok_to_replace, char const *, Entry const &)
Definition: ParameterSet.cc:373
h
confdb.splitter
def splitter(iterator, n)
Definition: confdb.py:13
OrderedSet.t
t
Definition: OrderedSet.py:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
ConfigurableHisto::fill
virtual void fill(const edm::Event &iEvent)
Definition: ConfigurableHisto.h:166
edm::LogError
Definition: MessageLogger.h:183
Splitter
Definition: CachingVariable.h:182
ConfigurableHisto::h
TH1 * h()
Definition: ConfigurableHisto.h:217
edm::Service
Definition: Service.h:30
createfilelist.int
int
Definition: createfilelist.py:10
SplittingConfigurableHisto::subHistoStacks_
SubHistoStacks subHistoStacks_
Definition: ConfigurableHisto.h:412
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
SplittingConfigurableHisto::SplittingConfigurableHisto
SplittingConfigurableHisto(HType t, std::string name, edm::ParameterSet &pset)
Definition: ConfigurableHisto.h:243
SplittingConfigurableHisto::subHistos_
std::vector< ConfigurableHisto * > subHistos_
Definition: ConfigurableHisto.h:416
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
CachingVariable::compute
bool compute(const edm::Event &iEvent) const
Definition: CachingVariable.h:61
CachingVariable::name
const std::string & name() const
Definition: CachingVariable.h:66
volumeBasedMagneticField_160812_cfi.master
master
Definition: volumeBasedMagneticField_160812_cfi.py:60
ConfigurableHisto::book
virtual void book(TFileDirectory *dir)
Definition: ConfigurableHisto.h:80
Splitter::label
const std::string & label(unsigned int i) const
Definition: CachingVariable.h:205
edm::Entry
Definition: Entry.h:40
Splitter::maxSlots
virtual unsigned int maxSlots() const
Definition: CachingVariable.h:193
label
const char * label
Definition: PFTauDecayModeTools.cc:11
SplittingConfigurableHisto::splitter_
const Splitter * splitter_
Definition: ConfigurableHisto.h:415
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
ConfigurableHisto::name_
std::string name_
Definition: ConfigurableHisto.h:232
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37