CombineHarvester
ch::CardWriter Class Reference

Automates the writing of datacards into directory structures. More...

#include "/afs/cern.ch/user/a/agilbert/CMSSW_14_1_0_pre4/src/CombineHarvester/CombineTools/interface/CardWriter.h"

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, CombineHarvesterWriteCards (std::string const &tag, ch::CombineHarvester &cmb) const
 Write datacards according to patterns, substituting $TAG for tag More...
 
CardWriterSetVerbosity (unsigned v)
 Set >= 1 for verbose output, otherwise silent. More...
 
CardWriterCreateDirectories (bool flag)
 Control whether directories can be created if missing. More...
 
CardWriterSetWildcardMasses (std::vector< std::string > const &masses)
 Redefine the mass values that should be treated as wildcards. More...
 

Detailed Description

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.

Note
The $MASS variable is treated differently than the others when constructing the list of output files. It is anticipated that a mass value of * 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.

Constructor & Destructor Documentation

◆ CardWriter()

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.

Member Function Documentation

◆ WriteCards()

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.

◆ SetVerbosity()

CardWriter & ch::CardWriter::SetVerbosity ( unsigned  v)

Set >= 1 for verbose output, otherwise silent.

Definition at line 20 of file CardWriter.cc.

◆ CreateDirectories()

CardWriter & ch::CardWriter::CreateDirectories ( bool  flag)

Control whether directories can be created if missing.

Definition at line 25 of file CardWriter.cc.

◆ SetWildcardMasses()

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.


The documentation for this class was generated from the following files: