Automates the writing of datacards into directory structures. More...
Public Member Functions | |
CardWriter (std::string const &text_pattern, std::string const &root_pattern) | |
Must be constructed with text and ROOT file patterns. More... | |
std::map< std::string, CombineHarvester > | WriteCards (std::string const &tag, ch::CombineHarvester &cmb) const |
Write datacards according to patterns, substituting $TAG for tag More... | |
CardWriter & | SetVerbosity (unsigned v) |
Set >= 1 for verbose output, otherwise silent. More... | |
CardWriter & | CreateDirectories (bool flag) |
Control whether directories can be created if missing. More... | |
CardWriter & | SetWildcardMasses (std::vector< std::string > const &masses) |
Redefine the mass values that should be treated as wildcards. More... | |
Automates the writing of datacards into directory structures.
A CardWriter is constructed with two strings which give patterns for where the datacard text and ROOT files should be located and how they should be named. These patterns can contain placeholders for the object metadata, e.g.:
ch::CardWriter writer( "$TAG/$MASS/$ANALYSIS_$CHANNEL_$BINID_$ERA.txt", "$TAG/common/$ANALYSIS_$CHANNEL.input_$ERA.root");
All of the standard metadata placeholders are supported. Then, assuming a CombineHarvester instance cb
has already been configured, the cards are written with:
writer.WriteCards("LIMITS/cmb", cb);
The CardWriter will determine the sets of root files and datacards to create given the metadata of the objects in cb
. The first argument of WriteCards
is substituted into the $TAG
placeholder. In this way multiple calls to WriteCards can produce output in different folders.
By default CardWriter will create any directories that are needed, but this behaviour can be switched off with the CreateDirectories
method. Also note that any existing files with the same name will be over-written.
*
should not give rise to actual files containing the *
character, but rather implies an Object that is valid for any mass-point. It is commonly used to denote background processes that do not depend on the signal mass hypothesis. Therefore this class ignores objects with a mass value of *
when determining which files to create, and when creating the files treats this object as matching any mass value. It is possible to alter or remove this behaviour by supplying a new list of wildcard values with the SetWildcardMasses method. Definition at line 50 of file CardWriter.h.
ch::CardWriter::CardWriter | ( | std::string const & | text_pattern, |
std::string const & | root_pattern | ||
) |
Must be constructed with text and ROOT file patterns.
Definition at line 12 of file CardWriter.cc.
std::map< std::string, CombineHarvester > ch::CardWriter::WriteCards | ( | std::string const & | tag, |
ch::CombineHarvester & | cmb | ||
) | const |
Write datacards according to patterns, substituting $TAG
for tag
Definition at line 96 of file CardWriter.cc.
CardWriter & ch::CardWriter::SetVerbosity | ( | unsigned | v | ) |
Set >= 1 for verbose output, otherwise silent.
Definition at line 20 of file CardWriter.cc.
CardWriter & ch::CardWriter::CreateDirectories | ( | bool | flag | ) |
Control whether directories can be created if missing.
Definition at line 25 of file CardWriter.cc.
CardWriter & ch::CardWriter::SetWildcardMasses | ( | std::vector< std::string > const & | masses | ) |
Redefine the mass values that should be treated as wildcards.
Definition at line 31 of file CardWriter.cc.