32{
33 void AlgCFlow ::
34 testInvariant () const
35 {
37 if (m_hist != 0)
38 {
41 RCU_INVARIANT (m_formulas.size() == std::size_t (m_hist->GetNbinsX()));
45 }
46 if (m_hist2)
47 {
50 } else
52 }
53
54
55
56 AlgCFlow ::
57 AlgCFlow ()
58 : m_hist (0), m_hist2 (0), m_formSvc (0)
59 {
61 }
62
63
64
65 AlgCFlow ::
66 AlgCFlow (TH1 *val_hist_swallow)
67 : m_hist (0), m_hist2 (0)
68 {
69 std::unique_ptr<TH1>
hist (val_hist_swallow);
70
73
74 for (std::size_t form = 0, end =
hist->GetNbinsX();
75 form != end; ++ form)
76 {
77 const std::string
label =
hist->GetXaxis()->GetBinLabel(form+1);
79
80 m_axis.push_back (
hist->GetXaxis()->GetBinCenter (form+1));
81 if (
split == std::string::npos)
82 {
83 m_formulas.push_back (
label);
84 m_back.push_back (form - 1);
85 } else
86 {
87 m_formulas.push_back (
label.substr (0,
split));
89 m_back.push_back (form);
90
92 {
93 for (std::size_t form2 = 0; form2 != form; ++ form2)
94 {
95 if (m_formulas[form2] == back)
96 m_back.back() = form2;
97 }
98 if (m_back.back() == form)
100 }
101 }
102 }
103
104 m_hist =
hist.release();
105 m_hist->SetDirectory (0);
106
107 m_values.resize (m_formulas.size());
108
110 }
111
112
113
116 {
119 return EL::StatusCode::SUCCESS;
120 }
121
122
123
125 initialize ()
126 {
128
129 try
130 {
132 for (std::size_t form = 0, end = m_formulas.size(); form != end; ++ form)
133 {
134 if (!m_formulas[form].
empty())
135 m_index.push_back (m_formSvc->addForm (m_formulas[form]));
136 else
138 }
139 m_hist2 = dynamic_cast<TH1*>(m_hist->Clone ());
141 wk()->addOutput (m_hist2);
142 } catch (...)
143 {
145 throw;
146 }
147 return EL::StatusCode::SUCCESS;
148 }
149
150
151
153 execute ()
154 {
156
158
159 int ndim = 0;
160 std::size_t
size = std::size_t (-1);
161 for (std::size_t form = 0; form != m_formulas.size(); ++ form)
162 {
163 if (m_index[form]) switch (m_index[form]->ndim())
164 {
165 case -1:
167 break;
168 case 0:
169 if (m_index[form]->ndata() > 0)
170 m_values[form] =
m_index[form]->value (0);
171 else
173 break;
174 case 1:
175 ndim = 1;
176 if (
size > m_index[form]->ndata())
178 break;
179 default:
180 RCU_THROW_MSG (
"unknown formula dimension: " + m_formulas[form]);
181 }
182 }
183
184 if (ndim == 0 &&
size > 1)
187 {
188 for (std::size_t form = 0, end = m_formulas.size(); form != end; ++ form)
189 {
191
192 if (m_back[form] < form)
193 weight = m_values[m_back[form]];
194
195 if (weight != 0 && !m_formulas[form].
empty())
196 {
197 if (m_index[form]->ndim() == 1)
199 else
201 }
202
204 m_hist2->Fill (m_axis[form], m_values[form]);
205 }
206 }
207 return EL::StatusCode::SUCCESS;
208 }
209}
#define RCU_CHANGE_INVARIANT(x)
#define RCU_NEW_INVARIANT(x)
#define RCU_REQUIRE_SOFT(x)
#define RCU_THROW_MSG(message)
size_t size() const
Number of registered mappings.
static const Attributes_t empty
std::vector< std::string > split(const std::string &s, const std::string &t=":")
std::string label(const std::string &format, int i)
return m_collEvts back().back().max_entries
::StatusCode StatusCode
StatusCode definition for legacy code.
FormulaSvc * formulas(EL::IWorker *worker)
returns: the formula service for this worker guarantee: strong failures: formula service not configur...
void useFormulas(EL::Job &job)
effects: register the formula service for this job guarantee: strong failures: out of memory I
size_t m_index
The index of this element within its container. Should be 0 if this object is not within a container.