CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

SplittingConfigurableHisto Class Reference

#include <ConfigurableHisto.h>

Inheritance diagram for SplittingConfigurableHisto:
ConfigurableHisto

List of all members.

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)

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_

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(), Splitter::label(), label, Splitter::maxSlots(), CachingVariable::name(), ConfigurableHisto::name_, alignCSCRings::s, Splitter::shortLabel(), confdb::splitter(), splitter_, subHistoMap_, subHistos_, indexGen::title, and v.

Referenced by clone().

                                                                              :
    ConfigurableHisto(t,name,pset) , splitter_(0) {
    std::string title=pset.getParameter<std::string>("title");

    //allow for many splitters ...
    if (pset.exists("splitters")){
      //you want more than one splitter
      std::vector<std::string> splitters = pset.getParameter<std::vector<std::string> >("splitters");
      for (unsigned int s=0;s!=splitters.size();++s){
        const CachingVariable * v=edm::Service<VariableHelperService>()->get().variable(splitters[s]);
        const Splitter * splitter = dynamic_cast<const Splitter*>(v);
        if (!splitter){
          edm::LogError("SplittingConfigurableHisto")<<"for: "<<name_<<" the splitting variable: "<<splitters[s]<<" is not a Splitter";
          continue;
        }

        //insert in the map
        std::vector<ConfigurableHisto*> & insertedHisto=subHistoMap_[splitter];
        //now configure the histograms
        unsigned int mSlots=splitter->maxSlots();
        for (unsigned int i=0;i!=mSlots;++i){
          //---   std::cout<<" slot: "<<i<<std::endl;
          const std::string & slabel=splitter->shortLabel(i);
          const std::string & label=splitter->label(i);
          edm::ParameterSet mPset=pset;
          edm::Entry e("string",title+" for "+label,true);
          mPset.insert(true,"title",e);
          insertedHisto.push_back(new ConfigurableHisto(t,name+slabel ,mPset));
        }//loop on slots
      }//loop on splitters

    }//if splitters exists
    else{
      //single splitter
      //get the splitting variable
      const CachingVariable * v=edm::Service<VariableHelperService>()->get().variable(pset.getParameter<std::string>("splitter"));
      splitter_ = dynamic_cast<const Splitter*>(v);
      if (!splitter_){
        edm::LogError("SplittingConfigurableHisto")<<"for: "<<name_<<" the splitting variable: "<<v->name()<<" is not a Splitter";
      }
      else{
        //configure the splitted plots
        unsigned int mSlots=splitter_->maxSlots();
        for (unsigned int i=0;i!=mSlots;i++){
          const std::string & slabel=splitter_->shortLabel(i);
          const std::string & label=splitter_->label(i);
          edm::ParameterSet mPset=pset;
          edm::Entry e("string",title+" for "+label,true);
          mPset.insert(true,"title",e);
          subHistos_.push_back(new ConfigurableHisto(t,name+slabel, mPset));
        }
      }
    }
  }//end of ctor
SplittingConfigurableHisto::SplittingConfigurableHisto ( const SplittingConfigurableHisto master) [inline, private]

Definition at line 360 of file ConfigurableHisto.h.

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

                                                                        : ConfigurableHisto(master){
    splitter_ = master.splitter_;
    if (master.subHistoMap_.size()!=0){
      SubHistoMap::const_iterator i=master.subHistoMap_.begin();
      SubHistoMap::const_iterator i_end=master.subHistoMap_.end();
      for (;i!=i_end;++i){
        const std::vector<ConfigurableHisto*> & masterHistos=i->second;
        std::vector<ConfigurableHisto*> & clonedHistos=subHistoMap_[i->first];
        for (unsigned int i=0;i!=masterHistos.size();i++){clonedHistos.push_back(masterHistos[i]->clone());}
      }
    }else{
      for (unsigned int i=0;i!=master.subHistos_.size();i++){subHistos_.push_back(master.subHistos_[i]->clone());}
    }
  }

Member Function Documentation

void SplittingConfigurableHisto::book ( TFileDirectory dir) [inline, virtual]

Reimplemented from ConfigurableHisto.

Definition at line 282 of file ConfigurableHisto.h.

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

                                {
    //book the base histogram
    ConfigurableHisto::book(dir);

    if (subHistoMap_.size()!=0){
      SubHistoMap::iterator i=subHistoMap_.begin();
      SubHistoMap::iterator i_end=subHistoMap_.end();
      for (;i!=i_end;++i){for (unsigned int h=0;h!=i->second.size();++h){ 
          i->second[h]->book(dir);}
        //book the THStack
        std::string sName= name_+"_"+i->first->name();
        std::string sTitle="Stack histogram of "+name_+" for splitter "+i->first->name();
        subHistoStacks_[i->first]= dir->make<THStack>(sName.c_str(),sTitle.c_str());
      }
    }else{
      for (unsigned int h=0;h!=subHistos_.size();h++){subHistos_[h]->book(dir);}
      //book a THStack
      std::string sName= name_+"_"+splitter_->name();
      std::string sTitle="Stack histogram of "+name_+" for splitter "+splitter_->name();
      stack_ = dir->make<THStack>(sName.c_str(),sTitle.c_str());
    }
    
  }
ConfigurableHisto* SplittingConfigurableHisto::clone ( void  ) const [inline, virtual]

Reimplemented from ConfigurableHisto.

Definition at line 306 of file ConfigurableHisto.h.

References SplittingConfigurableHisto().

Referenced by SplittingConfigurableHisto().

{    return new SplittingConfigurableHisto(*this);  }
void SplittingConfigurableHisto::complete ( ) [inline]

Reimplemented from ConfigurableHisto.

Definition at line 340 of file ConfigurableHisto.h.

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

                 {
    if (subHistoMap_.size()!=0){
      //fill up the stacks
      SubHistoMap::iterator i=subHistoMap_.begin();
      SubHistoMap::iterator i_end=subHistoMap_.end();
      for (;i!=i_end;++i){
        for (unsigned int h=0;h!=i->second.size();h++){
          //      if (i->second[h]->h()->Integral==0) continue;// do not add empty histograms. NO, because it will be tough to merge two THStack
          subHistoStacks_[i->first]->Add(i->second[h]->h(), i->first->label(h).c_str());
        }
      }

    }else{
      //fill up the only stack
      for (unsigned int i=0;i!=subHistos_.size();i++){  stack_->Add(subHistos_[i]->h(), splitter_->label(i).c_str());      }
    }


  }
void SplittingConfigurableHisto::fill ( const edm::Event e) [inline, virtual]

Reimplemented from ConfigurableHisto.

Definition at line 308 of file ConfigurableHisto.h.

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

                                {
    //fill the base histogram
    ConfigurableHisto::fill(e);
    
    if (subHistoMap_.size()!=0){
      SubHistoMap::iterator i=subHistoMap_.begin();
      SubHistoMap::iterator i_end=subHistoMap_.end();
      for (;i!=i_end;++i){
        const Splitter * splitter=i->first;
        if (!splitter) continue;
        if (!splitter->compute(e)) continue;
        unsigned int slot=(unsigned int)  (*splitter)(e);
        if (slot>=i->second.size()){
          edm::LogError("SplittingConfigurableHisto")<<"slot index: "<<slot<<" is bigger than slots size: "<<i->second.size()<<" from variable value: "<<(*splitter)(e);
          continue;}
        //fill in the proper slot
        i->second[slot]->fill(e);
      }
    }
    else{
      //fill the component histograms
      if (!splitter_) return;
      if (!splitter_->compute(e)){
        return;}
      unsigned int slot=(unsigned int) (*splitter_)(e);
      if (slot>=subHistos_.size()){
        edm::LogError("SplittingConfigurableHisto")<<"slot index: "<<slot<<" is bigger than slots size: "<< subHistos_.size() <<" from variable value: "<<(*splitter_)(e);
        return;}
      subHistos_[slot]->fill(e);
    }
  }

Member Data Documentation

Definition at line 380 of file ConfigurableHisto.h.

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

Definition at line 383 of file ConfigurableHisto.h.

Referenced by book(), and complete().

Definition at line 378 of file ConfigurableHisto.h.

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

Definition at line 381 of file ConfigurableHisto.h.

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

Definition at line 377 of file ConfigurableHisto.h.

Referenced by book(), and complete().