@@ -332,6 +332,35 @@ HMixFit::HMixFit(json outconfig) : config(outconfig) {
332
332
_current_ds.comp_orig .insert ({comp_idx, thh});
333
333
_current_ds.comp .insert ({comp_idx, utils::ReformatHistogram (thh, _current_ds.data )});
334
334
}
335
+ // it's a user defined file list with weights
336
+ else if (!iso.value ().contains (" TFormula" ) and it.contains (" root-files" )) {
337
+ BCLog::OutDebug (" user-specified ROOT file list (with weights) detected" );
338
+ auto obj_name = iso.value ().value (" hist-name" , elh.key ());
339
+
340
+ TH1* sum = nullptr ;
341
+ if (it[" root-files" ].is_object ()) {
342
+ for (auto & p : it[" root-files" ].items ()) {
343
+ // get histogram
344
+ BCLog::OutDebug (" opening file " + p.key ());
345
+ BCLog::OutDebug (" summing object '" + obj_name + " with weight "
346
+ + std::to_string (p.value ().get <double >()));
347
+ auto thh = this ->GetFitComponent (p.key (), obj_name, _current_ds.data_orig );
348
+ // add it with weight
349
+ if (!sum) {
350
+ sum = thh;
351
+ sum->Scale (p.value ().get <double >());
352
+ }
353
+ else {
354
+ sum->Add (thh, p.value ().get <double >());
355
+ delete thh;
356
+ }
357
+ }
358
+ }
359
+ else throw std::runtime_error (" \" root-files\" must be a dictionary" );
360
+ sum->SetName (utils::SafeROOTName (iso.key ()).c_str ());
361
+ _current_ds.comp_orig .insert ({comp_idx, sum});
362
+ _current_ds.comp .insert ({comp_idx, utils::ReformatHistogram (sum, _current_ds.data )});
363
+ }
335
364
// it's a explicit TFormula
336
365
else if (iso.value ().contains (" TFormula" )) {
337
366
BCLog::OutDebug (" TFormula expression detected" );
0 commit comments