CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
ConfigurableHistoclone () const
 
void complete ()
 
void fill (const edm::Event &e)
 
 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 225 of file ConfigurableHisto.h.

Member Typedef Documentation

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

Definition at line 375 of file ConfigurableHisto.h.

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

Definition at line 376 of file ConfigurableHisto.h.

Constructor & Destructor Documentation

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

Definition at line 227 of file ConfigurableHisto.h.

References ConfigurableHisto::ConfigurableHisto(), alignCSCRings::e, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), i, edm::ParameterSet::insert(), diffTwoXMLs::label, Splitter::label(), Splitter::maxSlots(), CachingVariable::name(), ConfigurableHisto::name_, alignCSCRings::s, Splitter::shortLabel(), confdb::splitter(), splitter_, AlCaHLTBitMon_QueryRunRegistry::string, subHistoMap_, subHistos_, indexGen::title, and findQualityFiles::v.

Referenced by clone().

227  :
228  ConfigurableHisto(t,name,pset) , splitter_(0) {
229  std::string title=pset.getParameter<std::string>("title");
230 
231  //allow for many splitters ...
232  if (pset.exists("splitters")){
233  //you want more than one splitter
234  std::vector<std::string> splitters = pset.getParameter<std::vector<std::string> >("splitters");
235  for (unsigned int s=0;s!=splitters.size();++s){
236  const CachingVariable * v=edm::Service<VariableHelperService>()->get().variable(splitters[s]);
237  const Splitter * splitter = dynamic_cast<const Splitter*>(v);
238  if (!splitter){
239  edm::LogError("SplittingConfigurableHisto")<<"for: "<<name_<<" the splitting variable: "<<splitters[s]<<" is not a Splitter";
240  continue;
241  }
242 
243  //insert in the map
244  std::vector<ConfigurableHisto*> & insertedHisto=subHistoMap_[splitter];
245  //now configure the histograms
246  unsigned int mSlots=splitter->maxSlots();
247  for (unsigned int i=0;i!=mSlots;++i){
248  //--- std::cout<<" slot: "<<i<<std::endl;
249  const std::string & slabel=splitter->shortLabel(i);
250  const std::string & label=splitter->label(i);
251  edm::ParameterSet mPset=pset;
252  edm::Entry e("string",title+" for "+label,true);
253  mPset.insert(true,"title",e);
254  insertedHisto.push_back(new ConfigurableHisto(t,name+slabel ,mPset));
255  }//loop on slots
256  }//loop on splitters
257 
258  }//if splitters exists
259  else{
260  //single splitter
261  //get the splitting variable
262  const CachingVariable * v=edm::Service<VariableHelperService>()->get().variable(pset.getParameter<std::string>("splitter"));
263  splitter_ = dynamic_cast<const Splitter*>(v);
264  if (!splitter_){
265  edm::LogError("SplittingConfigurableHisto")<<"for: "<<name_<<" the splitting variable: "<<v->name()<<" is not a Splitter";
266  }
267  else{
268  //configure the splitted plots
269  unsigned int mSlots=splitter_->maxSlots();
270  for (unsigned int i=0;i!=mSlots;i++){
271  const std::string & slabel=splitter_->shortLabel(i);
272  const std::string & label=splitter_->label(i);
273  edm::ParameterSet mPset=pset;
274  edm::Entry e("string",title+" for "+label,true);
275  mPset.insert(true,"title",e);
276  subHistos_.push_back(new ConfigurableHisto(t,name+slabel, mPset));
277  }
278  }
279  }
280  }//end of ctor
T getParameter(std::string const &) const
tuple t
Definition: tree.py:139
int i
Definition: DBlmapReader.cc:9
bool exists(std::string const &parameterName) const
checks if a parameter exists
void insert(bool ok_to_replace, char const *, Entry const &)
def splitter
Definition: confdb.py:11
ConfigurableHisto(HType t, std::string name, edm::ParameterSet &iConfig)
std::vector< ConfigurableHisto * > subHistos_
const std::string shortLabel(unsigned int i) const
virtual unsigned int maxSlots() const
const std::string & label(unsigned int i) const
const std::string & name() const
SplittingConfigurableHisto::SplittingConfigurableHisto ( const SplittingConfigurableHisto master)
inlineprivate

Definition at line 360 of file ConfigurableHisto.h.

References clone(), i, splitter_, subHistoMap_, and subHistos_.

360  : ConfigurableHisto(master){
361  splitter_ = master.splitter_;
362  if (master.subHistoMap_.size()!=0){
363  SubHistoMap::const_iterator i=master.subHistoMap_.begin();
364  SubHistoMap::const_iterator i_end=master.subHistoMap_.end();
365  for (;i!=i_end;++i){
366  const std::vector<ConfigurableHisto*> & masterHistos=i->second;
367  std::vector<ConfigurableHisto*> & clonedHistos=subHistoMap_[i->first];
368  for (unsigned int i=0;i!=masterHistos.size();i++){clonedHistos.push_back(masterHistos[i]->clone());}
369  }
370  }else{
371  for (unsigned int i=0;i!=master.subHistos_.size();i++){subHistos_.push_back(master.subHistos_[i]->clone());}
372  }
373  }
int i
Definition: DBlmapReader.cc:9
ConfigurableHisto(HType t, std::string name, edm::ParameterSet &iConfig)
std::vector< ConfigurableHisto * > subHistos_
ConfigurableHisto * clone() const

Member Function Documentation

void SplittingConfigurableHisto::book ( TFileDirectory dir)
inlinevirtual

Reimplemented from ConfigurableHisto.

Definition at line 282 of file ConfigurableHisto.h.

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

282  {
283  //book the base histogram
285 
286  if (subHistoMap_.size()!=0){
287  SubHistoMap::iterator i=subHistoMap_.begin();
288  SubHistoMap::iterator i_end=subHistoMap_.end();
289  for (;i!=i_end;++i){for (unsigned int h=0;h!=i->second.size();++h){
290  i->second[h]->book(dir);}
291  //book the THStack
292  std::string sName= name_+"_"+i->first->name();
293  std::string sTitle="Stack histogram of "+name_+" for splitter "+i->first->name();
294  subHistoStacks_[i->first]= dir->make<THStack>(sName.c_str(),sTitle.c_str());
295  }
296  }else{
297  for (unsigned int h=0;h!=subHistos_.size();h++){subHistos_[h]->book(dir);}
298  //book a THStack
299  std::string sName= name_+"_"+splitter_->name();
300  std::string sTitle="Stack histogram of "+name_+" for splitter "+splitter_->name();
301  stack_ = dir->make<THStack>(sName.c_str(),sTitle.c_str());
302  }
303 
304  }
int i
Definition: DBlmapReader.cc:9
std::vector< ConfigurableHisto * > subHistos_
T * make(const Args &...args) const
make new ROOT object
virtual void book(TFileDirectory *dir)
const std::string & name() const
ConfigurableHisto* SplittingConfigurableHisto::clone ( void  ) const
inlinevirtual

Reimplemented from ConfigurableHisto.

Definition at line 306 of file ConfigurableHisto.h.

References SplittingConfigurableHisto().

Referenced by SplittingConfigurableHisto().

306 { return new SplittingConfigurableHisto(*this); }
SplittingConfigurableHisto(HType t, std::string name, edm::ParameterSet &pset)
void SplittingConfigurableHisto::complete ( )
inline

Definition at line 340 of file ConfigurableHisto.h.

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

340  {
341  if (subHistoMap_.size()!=0){
342  //fill up the stacks
343  SubHistoMap::iterator i=subHistoMap_.begin();
344  SubHistoMap::iterator i_end=subHistoMap_.end();
345  for (;i!=i_end;++i){
346  for (unsigned int h=0;h!=i->second.size();h++){
347  // if (i->second[h]->h()->Integral==0) continue;// do not add empty histograms. NO, because it will be tough to merge two THStack
348  subHistoStacks_[i->first]->Add(i->second[h]->h(), i->first->label(h).c_str());
349  }
350  }
351 
352  }else{
353  //fill up the only stack
354  for (unsigned int i=0;i!=subHistos_.size();i++){ stack_->Add(subHistos_[i]->h(), splitter_->label(i).c_str()); }
355  }
356 
357 
358  }
int i
Definition: DBlmapReader.cc:9
std::vector< ConfigurableHisto * > subHistos_
const std::string & label(unsigned int i) const
void SplittingConfigurableHisto::fill ( const edm::Event e)
inlinevirtual

Reimplemented from ConfigurableHisto.

Definition at line 308 of file ConfigurableHisto.h.

References CachingVariable::compute(), alignCSCRings::e, ConfigurableHisto::fill(), i, confdb::splitter(), splitter_, subHistoMap_, and subHistos_.

308  {
309  //fill the base histogram
311 
312  if (subHistoMap_.size()!=0){
313  SubHistoMap::iterator i=subHistoMap_.begin();
314  SubHistoMap::iterator i_end=subHistoMap_.end();
315  for (;i!=i_end;++i){
316  const Splitter * splitter=i->first;
317  if (!splitter) continue;
318  if (!splitter->compute(e)) continue;
319  unsigned int slot=(unsigned int) (*splitter)(e);
320  if (slot>=i->second.size()){
321  edm::LogError("SplittingConfigurableHisto")<<"slot index: "<<slot<<" is bigger than slots size: "<<i->second.size()<<" from variable value: "<<(*splitter)(e);
322  continue;}
323  //fill in the proper slot
324  i->second[slot]->fill(e);
325  }
326  }
327  else{
328  //fill the component histograms
329  if (!splitter_) return;
330  if (!splitter_->compute(e)){
331  return;}
332  unsigned int slot=(unsigned int) (*splitter_)(e);
333  if (slot>=subHistos_.size()){
334  edm::LogError("SplittingConfigurableHisto")<<"slot index: "<<slot<<" is bigger than slots size: "<< subHistos_.size() <<" from variable value: "<<(*splitter_)(e);
335  return;}
336  subHistos_[slot]->fill(e);
337  }
338  }
int i
Definition: DBlmapReader.cc:9
def splitter
Definition: confdb.py:11
virtual void fill(const edm::Event &iEvent)
std::vector< ConfigurableHisto * > subHistos_
bool compute(const edm::Event &iEvent) const

Member Data Documentation

const Splitter* SplittingConfigurableHisto::splitter_
private

Definition at line 380 of file ConfigurableHisto.h.

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

THStack* SplittingConfigurableHisto::stack_
private

Definition at line 383 of file ConfigurableHisto.h.

Referenced by book(), and complete().

SubHistoMap SplittingConfigurableHisto::subHistoMap_
private

Definition at line 378 of file ConfigurableHisto.h.

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

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

Definition at line 381 of file ConfigurableHisto.h.

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

SubHistoStacks SplittingConfigurableHisto::subHistoStacks_
private

Definition at line 377 of file ConfigurableHisto.h.

Referenced by book(), and complete().