@@ -47,12 +47,46 @@ std::vector<ch::Parameter> ExtractSampledFitParameters(
4747// ---------------------------------------------------------------------------
4848// Property matching & editing
4949// ---------------------------------------------------------------------------
50- void SetStandardBinNames (CombineHarvester & cb) {
51- cb.ForEachObs ( ch::SetStandardBinName<ch::Observation>);
52- cb. ForEachProc ( ch::SetStandardBinName<ch::Process> );
53- cb. ForEachSyst (ch::SetStandardBinName<ch::Systematic> );
50+ void SetStandardBinNames (CombineHarvester& cb, std::string const & pattern ) {
51+ cb.ForEachObj ([&]( ch::Object* obj) {
52+ ch::SetStandardBinName (obj, pattern );
53+ } );
5454}
5555
56+ void SetStandardBinName (ch::Object* obj, std::string pattern) {
57+ boost::replace_all (pattern, " $BINID" ,
58+ boost::lexical_cast<std::string>(obj->bin_id ()));
59+ boost::replace_all (pattern, " $BIN" , obj->bin ());
60+ boost::replace_all (pattern, " $PROCESS" , obj->process ());
61+ boost::replace_all (pattern, " $MASS" , obj->mass ());
62+ boost::replace_all (pattern, " $ERA" , obj->era ());
63+ boost::replace_all (pattern, " $CHANNEL" , obj->channel ());
64+ boost::replace_all (pattern, " $ANALYSIS" , obj->analysis ());
65+ obj->set_bin (pattern);
66+ }
67+
68+ void SetFromBinName (ch::Object *input, std::string parse_rules) {
69+ boost::replace_all (parse_rules, " $ANALYSIS" , " (?<ANALYSIS>\\ w+)" );
70+ boost::replace_all (parse_rules, " $ERA" , " (?<ERA>\\ w+)" );
71+ boost::replace_all (parse_rules, " $CHANNEL" , " (?<CHANNEL>\\ w+)" );
72+ boost::replace_all (parse_rules, " $BINID" , " (?<BINID>\\ w+)" );
73+ boost::replace_all (parse_rules, " $MASS" , " (?<MASS>\\ w+)" );
74+ boost::regex rgx (parse_rules);
75+ boost::smatch matches;
76+ boost::regex_search (input->bin (), matches, rgx);
77+ if (matches.str (" ANALYSIS" ).length ())
78+ input->set_analysis (matches.str (" ANALYSIS" ));
79+ if (matches.str (" ERA" ).length ())
80+ input->set_era (matches.str (" ERA" ));
81+ if (matches.str (" CHANNEL" ).length ())
82+ input->set_channel (matches.str (" CHANNEL" ));
83+ if (matches.str (" BINID" ).length ())
84+ input->set_bin_id (boost::lexical_cast<int >(matches.str (" BINID" )));
85+ if (matches.str (" MASS" ).length ())
86+ input->set_mass (matches.str (" MASS" ));
87+ }
88+
89+
5690// ---------------------------------------------------------------------------
5791// Rate scaling
5892// ---------------------------------------------------------------------------
0 commit comments