40 testInvariant ()
const
47 RCU_INVARIANT (m_formulas.size() == std::size_t (m_hist->GetNbinsX()));
64 : m_hist (0), m_hist2 (0), m_formSvc (0)
72 AlgCFlow (TH1 *val_hist_swallow)
73 : m_hist (0), m_hist2 (0)
75 std::unique_ptr<TH1>
hist (val_hist_swallow);
80 for (std::size_t form = 0,
end =
hist->GetNbinsX();
83 const std::string
label =
hist->GetXaxis()->GetBinLabel(form+1);
86 m_axis.push_back (
hist->GetXaxis()->GetBinCenter (form+1));
87 if (
split == std::string::npos)
89 m_formulas.push_back (
label);
90 m_back.push_back (form - 1);
93 m_formulas.push_back (
label.substr (0,
split));
94 const std::string back =
label.substr (
split+1);
95 m_back.push_back (form);
99 for (std::size_t form2 = 0; form2 != form; ++ form2)
101 if (m_formulas[form2] == back)
102 m_back.back() = form2;
104 if (m_back.back() == form)
110 m_hist =
hist.release();
111 m_hist->SetDirectory (0);
113 m_values.resize (m_formulas.size());
125 return EL::StatusCode::SUCCESS;
138 for (std::size_t form = 0,
end = m_formulas.size(); form !=
end; ++ form)
140 if (!m_formulas[form].
empty())
141 m_index.push_back (m_formSvc->addForm (m_formulas[form]));
143 m_index.push_back (0);
145 m_hist2 =
dynamic_cast<TH1*
>(m_hist->Clone ());
147 wk()->addOutput (m_hist2);
153 return EL::StatusCode::SUCCESS;
166 std::size_t
size = std::size_t (-1);
167 for (std::size_t form = 0; form != m_formulas.size(); ++ form)
169 if (m_index[form])
switch (m_index[form]->ndim())
175 if (m_index[form]->ndata() > 0)
176 m_values[form] = m_index[form]->value (0);
182 if (
size > m_index[form]->ndata())
183 size = m_index[form]->ndata();
186 RCU_THROW_MSG (
"unknown formula dimension: " + m_formulas[form]);
190 if (ndim == 0 &&
size > 1)
192 for (std::size_t iter = 0; iter !=
size; ++ iter)
194 for (std::size_t form = 0,
end = m_formulas.size(); form !=
end; ++ form)
198 if (m_back[form] < form)
199 weight = m_values[m_back[form]];
203 if (m_index[form]->ndim() == 1)
204 weight *= m_index[form]->value (iter);
206 weight *= m_index[form]->value (0);
210 m_hist2->Fill (m_axis[form], m_values[form]);
213 return EL::StatusCode::SUCCESS;