1 #ifndef ConfigurableAnalysis_ConfigurableHisto_H
2 #define ConfigurableAnalysis_ConfigurableHisto_H
92 yLabel = yAxis.Label();
94 if (yAxisPSet.
exists(
"var"))
96 yVBin = yAxis.variableSize();
103 bool xVBin = xAxis.variableSize();
108 h_ = dir->
make<TH1F>(
name_.c_str(), title.c_str(), xAxis.nBin(), xAxis.xBins());
110 h_ = dir->
make<TH1F>(
name_.c_str(), title.c_str(), xAxis.nBin(), xAxis.Min(), xAxis.Max());
111 }
else if (
type() ==
h2) {
115 h_ = dir->
make<TH2F>(
name_.c_str(), title.c_str(), xAxis.nBin(), xAxis.xBins(), yAxis.
nBin(), yAxis.
xBins());
118 name_.c_str(), title.c_str(), xAxis.nBin(), xAxis.xBins(), yAxis.
nBin(), yAxis.
Min(), yAxis.
Max());
122 name_.c_str(), title.c_str(), xAxis.nBin(), xAxis.Min(), xAxis.Max(), yAxis.
nBin(), yAxis.
xBins());
141 name_.c_str(), title.c_str(), xAxis.nBin(), xAxis.xBins(), yAxis.
Min(), yAxis.
Max(), pFopt.c_str());
158 h_->GetXaxis()->SetTitle(xAxis.Label().c_str());
159 h_->SetYTitle(yLabel.c_str());
175 edm::LogInfo(
"ConfigurableHisto") <<
"could not compute the weight for: " <<
name_ <<
" with config:\n"
180 TProfile* pcast(
nullptr);
181 TH2* h2cast(
nullptr);
187 h_->Fill((*
x_)(iEvent), weight);
193 pcast =
dynamic_cast<TProfile*
>(
h_);
197 pcast->Fill((*
x_)(iEvent), (*
y_)(iEvent), weight);
203 h2cast =
dynamic_cast<TH2*
>(
h_);
207 h2cast->Fill((*
x_)(iEvent), (*
y_)(iEvent), weight);
248 if (pset.
exists(
"splitters")) {
250 std::vector<std::string> splitters = pset.
getParameter<std::vector<std::string> >(
"splitters");
251 for (
unsigned int s = 0;
s != splitters.size(); ++
s) {
256 <<
"for: " <<
name_ <<
" the splitting variable: " << splitters[
s] <<
" is not a Splitter";
263 unsigned int mSlots = splitter->
maxSlots();
264 for (
unsigned int i = 0;
i != mSlots; ++
i) {
269 edm::Entry e(
"string", title +
" for " + label,
true);
270 mPset.
insert(
true,
"title", e);
284 <<
"for: " <<
name_ <<
" the splitting variable: " << v->
name() <<
" is not a Splitter";
288 for (
unsigned int i = 0;
i != mSlots;
i++) {
292 edm::Entry e(
"string", title +
" for " + label,
true);
293 mPset.
insert(
true,
"title", e);
307 for (; i != i_end; ++
i) {
308 for (
unsigned int h = 0;
h != i->second.size(); ++
h) {
309 i->second[
h]->book(dir);
313 std::string sTitle =
"Stack histogram of " +
name_ +
" for splitter " + i->first->name();
323 stack_ = dir->
make<THStack>(sName.c_str(), sTitle.c_str());
336 for (; i != i_end; ++
i) {
342 unsigned int slot = (
unsigned int)(*splitter)(
e);
343 if (slot >= i->second.size()) {
345 <<
"slot index: " << slot <<
" is bigger than slots size: " << i->second.size()
346 <<
" from variable value: " << (*splitter)(
e);
350 i->second[slot]->fill(e);
359 unsigned int slot = (
unsigned int)(*
splitter_)(
e);
362 <<
"slot index: " << slot <<
" is bigger than slots size: " <<
subHistos_.size()
363 <<
" from variable value: " << (*splitter_)(
e);
375 for (; i != i_end; ++
i) {
376 for (
unsigned int h = 0;
h != i->second.size();
h++) {
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());
404 for (
unsigned int i = 0;
i != master.
subHistos_.size();
i++) {
410 typedef std::map<const Splitter*, std::vector<ConfigurableHisto*> >
SubHistoMap;
Master< F > master(const F &f)
void book(TFileDirectory *dir) override
std::string dump(unsigned int indent=0) const
std::vector< double > vBins_
const Splitter * splitter_
SplittingConfigurableHisto(const SplittingConfigurableHisto &master)
void fill(const edm::Event &e) override
const std::string & Label()
bool exists(std::string const ¶meterName) const
checks if a parameter exists
virtual ConfigurableHisto * clone() const
void insert(bool ok_to_replace, char const *, Entry const &)
Log< level::Error, false > LogError
SplittingConfigurableHisto(HType t, std::string name, edm::ParameterSet &pset)
std::vector< ConfigurableHisto * > subHistos_
SubHistoStacks subHistoStacks_
virtual void fill(const edm::Event &iEvent)
ConfigurableHisto(HType t, std::string name, edm::ParameterSet &iConfig)
const CachingVariable * y_
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_
Log< level::Info, false > LogInfo
virtual void book(TFileDirectory *dir)
const CachingVariable * w_
T getParameter(std::string const &) const
bool compute(const edm::Event &iEvent) const
std::map< const Splitter *, THStack * > SubHistoStacks
ConfigurableHisto * clone() const override
const CachingVariable * z_
const std::string & name() const
std::map< const Splitter *, std::vector< ConfigurableHisto * > > SubHistoMap
ConfigurableAxis(const edm::ParameterSet &par)