40 testInvariant ()
const
73 for (std::size_t form = 0,
end = m_formulas.size(); form !=
end; ++ form)
87 : m_hist (0),
m_type (-1), m_valnum (1), m_cut (false), m_hist2 (0)
95 AlgHist (TH1 *val_hist_swallow,
96 const std::string& val_value0,
97 const std::string& val_value1,
98 const std::string& val_value2,
99 const std::string& val_value3)
100 : m_hist (0),
m_type (-1), m_valnum (1), m_cut (false), m_hist2 (0)
102 std::unique_ptr<TH1>
hist (val_hist_swallow);
107 m_formulas.push_back (val_value0);
108 if (!val_value1.empty())
109 m_formulas.push_back (val_value1);
110 if (!val_value2.empty())
111 m_formulas.push_back (val_value2);
112 if (!val_value3.empty())
113 m_formulas.push_back (val_value3);
115 m_hist =
hist.release();
116 m_hist->SetDirectory (0);
117 if (
dynamic_cast<TProfile*
>(m_hist) != 0)
121 }
else if (
dynamic_cast<TH2*
>(m_hist) != 0)
125 }
else if (
dynamic_cast<TH3*
>(m_hist) != 0)
134 m_values.resize (m_valnum + 1, 1);
135 if (m_valnum == m_formulas.size())
137 else if (m_valnum+1 == m_formulas.size())
149 if (m_hist !=
nullptr) {
161 return EL::StatusCode::SUCCESS;
174 for (std::size_t form = 0,
end = m_formulas.size(); form !=
end; ++ form)
175 m_index.push_back (m_formSvc->addForm (m_formulas[form]));
176 m_hist2 =
dynamic_cast<TH1*
>(m_hist->Clone ());
178 wk()->addOutput (m_hist2);
184 return EL::StatusCode::SUCCESS;
194 RCU_ASSERT (m_formulas.size() == m_index.size());
195 RCU_ASSERT (m_formulas.size() <= m_values.size());
197 if (m_cut && m_index.back()->ndim() == 0 &&
198 (m_values.back() = m_index.back()->value (0)) == 0)
199 return EL::StatusCode::SUCCESS;
202 std::size_t
size = std::size_t (-1);
203 for (std::size_t form = 0; form != m_valnum; ++ form)
205 switch (m_index[form]->ndim())
211 if (m_index[form]->ndata() > 0)
212 m_values[form] = m_index[form]->value (0);
218 if (
size > m_index[form]->ndata())
219 size = m_index[form]->ndata();
222 RCU_THROW_MSG (
"unknown formula dimension: " + m_formulas[form]);
226 if (ndim == 0 &&
size > 1)
228 for (std::size_t iter = 0; iter !=
size; ++ iter)
232 if (m_cut && m_index.back()->ndim() == 1 &&
233 (m_values.back() = m_index.back()->value (iter)) == 0)
236 for (std::size_t form = 0; form != m_valnum; ++ form)
238 if (m_index[form]->ndim() == 1)
239 m_values[form] = m_index[form]->value (iter);
246 m_hist2->Fill (m_values[0], m_values[1]);
249 static_cast<TProfile*
>(m_hist2)->Fill (m_values[0], m_values[1], m_values[2]);
252 static_cast<TH2*
>(m_hist2)->Fill (m_values[0], m_values[1], m_values[2]);
255 static_cast<TH3*
>(m_hist2)->Fill (m_values[0], m_values[1], m_values[2], m_values[3]);
261 return EL::StatusCode::SUCCESS;