1 #ifndef ConfigurableAnalysis_ConfigurableHisto_H 2 #define ConfigurableAnalysis_ConfigurableHisto_H 57 type_(t),h_(0),name_(name), conf_(iConfig),x_(0),y_(0),z_(0),w_(0){}
72 if (conf_.exists(
"yAxis")){
77 if (yAxisPSet.
exists(
"var"))
79 yVBin=yAxis.variableSize();
82 if (conf_.exists(
"zAxis")){
86 bool xVBin=xAxis.variableSize();
92 h_=dir->
make<TH1F>(name_.c_str(),title.c_str(),
93 xAxis.nBin(), xAxis.xBins());
95 h_=dir->
make<TH1F>(name_.c_str(),title.c_str(),
96 xAxis.nBin(),xAxis.Min(),xAxis.Max());
102 h_=dir->
make<TH2F>(name_.c_str(),title.c_str(),
103 xAxis.nBin(),xAxis.xBins(),
106 h_=dir->
make<TH2F>(name_.c_str(),title.c_str(),
107 xAxis.nBin(),xAxis.xBins(),
111 h_=dir->
make<TH2F>(name_.c_str(),title.c_str(),
112 xAxis.nBin(),xAxis.Min(),xAxis.Max(),
115 h_=dir->
make<TH2F>(name_.c_str(),title.c_str(),
116 xAxis.nBin(),xAxis.Min(),xAxis.Max(),
120 else if (
type()==prof){
123 if (conf_.exists(
"Option"))
127 h_=dir->
make<TProfile>(name_.c_str(),title.c_str(),
128 xAxis.nBin(), xAxis.xBins(),
132 h_=dir->
make<TProfile>(name_.c_str(),title.c_str(),
133 xAxis.nBin(),xAxis.Min(),xAxis.Max(),
139 edm::LogError(
"ConfigurableHisto")<<
"cannot book: "<<name_<<
"\n"<<conf_.dump();
144 h_->GetXaxis()->SetTitle(xAxis.Label().c_str());
145 h_->SetYTitle(yLabel.c_str());
147 if (conf_.exists(
"weight"))
158 if (w_->compute(iEvent))
161 edm::LogInfo(
"ConfigurableHisto")<<
"could not compute the weight for: "<<name_
162 <<
" with config:\n"<<conf_.dump()
172 if (x_->compute(iEvent)) h_->Fill((*x_)(iEvent),weight);
174 edm::LogInfo(
"ConfigurableHisto")<<
"could not fill: "<<name_
175 <<
" with config:\n"<<conf_.dump();
179 pcast=
dynamic_cast<TProfile*
>(h_);
181 if (x_->compute(iEvent) && y_->compute(iEvent)) pcast->Fill((*x_)(iEvent),(*y_)(iEvent),weight);
183 edm::LogInfo(
"ConfigurableHisto")<<
"could not fill: "<<name_
184 <<
" with config:\n"<<conf_.dump();
188 h2cast=
dynamic_cast<TH2*
>(h_);
190 if (x_->compute(iEvent) && y_->compute(iEvent)) h2cast->Fill((*x_)(iEvent),(*y_)(iEvent),weight);
192 edm::LogInfo(
"ConfigurableHisto")<<
"could not fill: "<<name_
193 <<
" with config:\n"<<conf_.dump();
201 TH1 *
h() {
return h_;}
232 if (pset.
exists(
"splitters")){
234 std::vector<std::string> splitters = pset.
getParameter<std::vector<std::string> >(
"splitters");
235 for (
unsigned int s=0;
s!=splitters.size();++
s){
239 edm::LogError(
"SplittingConfigurableHisto")<<
"for: "<<name_<<
" the splitting variable: "<<splitters[
s]<<
" is not a Splitter";
244 std::vector<ConfigurableHisto*> & insertedHisto=subHistoMap_[
splitter];
246 unsigned int mSlots=splitter->
maxSlots();
247 for (
unsigned int i=0;
i!=mSlots;++
i){
253 mPset.
insert(
true,
"title",e);
263 splitter_ =
dynamic_cast<const Splitter*
>(
v);
265 edm::LogError(
"SplittingConfigurableHisto")<<
"for: "<<name_<<
" the splitting variable: "<<v->
name()<<
" is not a Splitter";
269 unsigned int mSlots=splitter_->maxSlots();
270 for (
unsigned int i=0;
i!=mSlots;
i++){
275 mPset.
insert(
true,
"title",e);
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);}
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());
297 for (
unsigned int h=0;
h!=subHistos_.size();
h++){subHistos_[
h]->book(dir);}
300 std::string sTitle=
"Stack histogram of "+name_+
" for splitter "+splitter_->name();
301 stack_ = dir->
make<THStack>(sName.c_str(),sTitle.c_str());
312 if (subHistoMap_.size()!=0){
313 SubHistoMap::iterator
i=subHistoMap_.begin();
314 SubHistoMap::iterator i_end=subHistoMap_.end();
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);
324 i->second[slot]->fill(e);
329 if (!splitter_)
return;
330 if (!splitter_->compute(e)){
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);
336 subHistos_[slot]->fill(e);
341 if (subHistoMap_.size()!=0){
343 SubHistoMap::iterator
i=subHistoMap_.begin();
344 SubHistoMap::iterator i_end=subHistoMap_.end();
346 for (
unsigned int h=0;
h!=i->second.size();
h++){
348 subHistoStacks_[i->first]->Add(i->second[
h]->h(), i->first->label(
h).c_str());
354 for (
unsigned int i=0;
i!=subHistos_.size();
i++){ stack_->Add(subHistos_[
i]->
h(), splitter_->label(
i).c_str()); }
364 SubHistoMap::const_iterator i_end=master.
subHistoMap_.end();
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());}
375 typedef std::map<const Splitter *, std::vector<ConfigurableHisto* > >
SubHistoMap;
T getParameter(std::string const &) const
Master< F > master(const F &f)
def splitter(iterator, n)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::vector< double > vBins_
const Splitter * splitter_
SplittingConfigurableHisto(const SplittingConfigurableHisto &master)
const std::string & Label()
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void fill(const edm::Event &e)
virtual ConfigurableHisto * clone() const
void insert(bool ok_to_replace, char const *, Entry const &)
std::map< const Splitter *, THStack * > SubHistoStacks
SplittingConfigurableHisto(HType t, std::string name, edm::ParameterSet &pset)
SubHistoStacks subHistoStacks_
virtual void fill(const edm::Event &iEvent)
ConfigurableHisto(HType t, std::string name, edm::ParameterSet &iConfig)
const CachingVariable * y_
std::vector< ConfigurableHisto * > subHistos_
std::map< const Splitter *, std::vector< ConfigurableHisto * > > SubHistoMap
void book(TFileDirectory *dir)
const std::string shortLabel(unsigned int i) const
virtual ~ConfigurableHisto()
virtual unsigned int maxSlots() const
ConfigurableHisto(const ConfigurableHisto &master)
const std::string & label(unsigned int i) const
T * make(const Args &...args) const
make new ROOT object
const CachingVariable * x_
virtual void book(TFileDirectory *dir)
const CachingVariable * w_
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
bool compute(const edm::Event &iEvent) const
const CachingVariable * z_
ConfigurableHisto * clone() const
const std::string & name() const
ConfigurableAxis(const edm::ParameterSet &par)