Skip to content

No $ERA support for ExtractShapes and HistMapping #337

@IzaakWN

Description

@IzaakWN

I naively tried

cb.cp().backgrounds().ExtractShapes(
  infname, '$BIN_$ERA/$PROCESS', '$BIN_$ERA/$PROCESS_$SYSTEMATIC')
cb.cp().signals().ExtractShapes(
  infname, '$BIN_$ERA/$PROCESS_M$MASS','$BIN_$ERA/$PROCESS_M$MASS_$SYSTEMATIC')

but got the error

$ ./harvestcards_shapes.py
Traceback (most recent call last):
  File "/afs/cern.ch/user/i/ineuteli/analysis/CMSSW_14_1_X_comb/src/datacard-tutorial/./harvestcards_shapes.py", line 49, in <module>
    cb.cp().backgrounds().ExtractShapes(
cppyy.gbl.std.runtime_error: void ch::CombineHarvester::ExtractShapes(const string& file, const string& rule, const string& syst_rule) =>
    runtime_error: 
*******************************************************************************
Context: Function ch::GetClonedTH1 at 
  src/CombineHarvester/CombineTools/src/TFileIO.cc:24
Problem: TH1 SR_$ERA/data_obs not found in input/xmm_inputs.root
*******************************************************************************
Please report issues at
  https://github.com/cms-analysis/CombineHarvester/issues
*******************************************************************************

Digging in the source code, it seems like the $ERA keyword is not supported in CombineHarvester::ExtractShapes:

void CombineHarvester::ExtractShapes(std::string const& file,
std::string const& rule,
std::string const& syst_rule) {
std::vector<HistMapping> mapping(1);
mapping[0].process = "*";
mapping[0].category = "*";
mapping[0].file = std::make_shared<TFile>(file.c_str());
mapping[0].pattern = rule;
mapping[0].syst_pattern = syst_rule;

nor in CombineHarvester::LoadShapes:
HistMapping mapping =
ResolveMapping(entry->process(), entry->bin(), mappings);
boost::replace_all(mapping.pattern, "$CHANNEL", entry->bin());
boost::replace_all(mapping.pattern, "$BIN", entry->bin());
boost::replace_all(mapping.pattern, "$PROCESS", entry->process());
boost::replace_all(mapping.pattern, "$MASS", entry->mass());

nor in HistMapping:
struct HistMapping {
std::string process;
std::string category;
std::string pattern;

It this by design, or could we add it so one does not need to add an additional loop? If it's simple adding a couple of lines in the places above, I could open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions