Common Analysis Framework » SFRAMEWORK » TSModelBuilder

class TSModelBuilder: public TSSystematicsManager


	TSModelBuilder

	The TSModelBuilder class allows to create a complete definition of a statistical model to be
	passed to the TSModelFactory class to run HistFactory. The specifics of the model to be
	created have to be provided as configuration data by means of a TQFolder structure.

	A model is represented by the root instance of a TQFolder structure holding detailed
	definitions of channels, samples, systematic uncertainties as well as the corresponding
	histograms.

	Creation of a model by the TSModelBuilder class is split into two different steps: the
	preparation step and the finalization step. The finalization step involves retrieving
	histograms and counter representing signal and background expectations as well as data
	observations from a sample folders (instances of TQSampleFolder) either stored in external
	files or made available as memory resident object. Furthermore, it involves the analysis of
	variations corresponding to systematic uncertainties and their proper treatment.



	The configuration has to be provided as the following structure:

	Samples/                           A folder listing all samples to be used in the model
	                                   (entries starting with a dot "." are ignored)
	  {sample/}                        [one folder for each sample]
	    <Path>                         Default path to the corresponding sample (with respect to the
	                                   base sample folder), e.g. "sig/em/mh125/ggf". Placeholders
	                                   (e.g. "$(mass)") can be used and will be replaced using tags
	                                   from configuration of corresponding channel and from Parameter
	                                   block.
	    <Type>                         [optional] The type of the corresponding sample,
	                                   e.g. "S" for signal, "B" for background, and "D" for data
	    <ActivateStatError>            [optional, default as in TSModelFactory (false)]
	    <StatErrorHisto>               [optional]
	    <NormalizeByTheory>            [optional, default as in TSModelFactory (true)]
	    {additional-items/}            [one folder for each additional items]
	      <AppliesToChannels>          String filter to be passed by name of channel in order
	                                   to copy corresponding item to final instance of sample

	Channels/                          A folder listing all channels (regions) to be used in
	                                   the model (entries starting with a dot "." are ignored)
	  {channel/}                       [one folder for each channel/region]
	    <Histogram>                    Name of histogram to be used for corresponding channel,
	                                   e.g. "CutTopoDPhill_0jet/MT".
	    <Counter>                      Name of counter to be used for corresponding channel,
	                                   e.g. "CutTopoDPhill_0jet" (counter will be converted to
	                                   1-bin histogram)
	    <StatRelErrorThreshold>
	    <StatConstraintType>

	    <RemapXTo>                     Number of bins to remap X axis of histogram to (histogram is
	                                   remapped such that histogram obtained from <PathRemapFlat> is
	                                   approximately flat).
	    <RemapYTo>                     Number of bins to remap Y axis of histogram to (histogram is
	                                   remapped such that histogram obtained from <PathRemapFlat> is
	                                   approximately flat). Please note: remapping both X and Y axes
	                                   simultaneously is not supported.
	    <PathRemapFlat>                Path to histogram to become approximately flat by remapping
	    <RemapSlices>                  Controls whether when remapping a 2D histogram each bin of the
	                                   dimension NOT subject to the remapping is remapped individually
	                                   (<RemapSlices> == true) or only the full projection
	                                   (<RemapSlices> == false). This option is true by default
	    <convertTo1D>                  Definition of conversion ("unfolding", "unrolling") of a 2D
	                                   histogram to a 1D histogram.
	    <HistogramOptions>


	                                   ***** For documentation of the following options please refer to
	                                   the documentation of TQSampleDataReader::getHistogram(...) *****

	    <cutBinLowX>                   Removing bins from histograms
	    <cutBinHighX>                  /...
	    <cutBinLowY>                   /...
	    <cutBinHighY>                  /...
	    <cutBinLow>                    /...
	    <cutBinHigh>                   /...
	    <zoomBinLowX>                  Zooming into histograms
	    <zoomBinHighX>                 /...
	    <zoomBinLowY>                  /...
	    <zoomBinHighY>                 /...
	    <zoomBinLow>                   /...
	    <zoomBinHigh>                  /...
	    <projXBinLowY>                 Projecting 2D histograms onto one if its axes
	    <projXBinHighY>                /...
	    <projXBinY>                    /...
	    <projX>                        /...
	    <projYBinLowX>                 /...
	    <projYBinHighX>                /...
	    <projYBinX>                    /...
	    <projY>                        /...
	    <rebinX>                       Rebinning histograms
	    <rebin>                        /...
	    <rebinY>                       /...
	    <rebinZ>                       /...
	    <scale>                        Scaling the histogram
	    <verbosity>                    Temporarily setting the verbosity mode of the
	                                   TQSampleDataReader class
	    <applyPoissonErrors>           Set bin errors of histogram to sqrt(bin contents)

	    <forSample.<sample>.XXX>



	Variations/                        A folder listing all (systematic) variations to be used
	                                   in the model (entries starting with a dot "." are ignored)
	  {variation/}                     [one folder for each (systematic) variation]
	    <SampleFolder>                 Location of the sample folder of the corresponding
	                                   variation, e.g. "samples.root:samples_Nominal". Please
	                                   note: there at least needs to be a "Nominal" folder

	Systematics/                       A folder listing all sources of systematic uncertainties
	                                   to be used in the model (entries starting with a dot "."
	                                   are ignored)
	  {systematic/}                    [one folder for each source of systematic uncertainty]
	    <Up>                           Name of UP variation corresponding to systematic
	                                   uncertainty (must be listed in Variations/ folder)
	    <Down>                         Name of DOWN variation corresponding to systematic
	                                   uncertainty (must be listed in Variations/ folder)
	    <IsOverallSys>                 Selects if systematic uncertainty is treated as a
	                                   normalization systematic ('OverallSys')
	    <IsHistoSys>                   Selects if systematic uncertainty is treated as a shape
	                                   systematic ('HistoSys'). Please note: the normalization
	                                   component is factorized and removed for 'HistoSys'
	    <Include>                      String filter tested for each combination of channel
	                                   (region) and sample (in the form "<channel>:<sample>")
	                                   which has to be pass in order that the corresponding
	                                   systematic uncertainty is considered for this
	                                   combination of channel/sample
	    <Exclude>                      String filter tested for each combination of channel
	                                   (region) and sample (in the form "<channel>:<sample>")
	                                   which must NOT be pass in order that the corresponding
	                                   systematic uncertainty is considered for this
	                                   combination of channel/sample (if a combination passes
	                                   both the inclusion and the exclusion filter it is
	                                   excluded)
	    <InterpCode>                   Interpolation code to be used by HistFactory
	    <OverallSysMagnification>      Factor to artificially magnify the normalization
	                                   response of the systematic uncertainty
	    <HistoSysMagnification>        Factor to artificially magnify the shape response of
	                                   the systematic uncertainty
	    <Magnification>                Factor passed as default to <OverallSysMagnification>
	                                   and <HistoSysMagnification>

	Parameters
	  <Name>
	  <Title>
	  <OutputFilePrefix>
	  <ExportOnly>
	  <POI>                            Name of the Parameter Of Interest (POI)
	  <Lumi>                           Luminosity scale factor
	  <LumiRelErr>                     Relative luminosity uncertainty
	  <SysRelThreshold>                Minimum relative variation to be exceeded by a systematic
	                                   variation in order to be considered
	  <SysRelMin>                      Minimum relative variation to be exceeded by a systematic
	                                   variation in order to not be ignored
	  <SysRelCutoff>                   Maximum relative variation a systematic variation must
	                                   not exceed in order to be considered
	  <SysRelCap>                      The maximum relative variation a systematic variation. If
                                     the maximum is exceeded, the relative variation is set to this maximum
	  <MinBinContent>                  The minimum bin content of histograms of each process
	                                   (except Data histograms). If the bin content is lower
	                                   than this minimum it is set to the minimum

	The model built by the TSModelBuilder class uses the convention that each element available
	in HistFactory (e.g. a "Sample", a "Channel", a "NormFactor) is represented by a
	corresponding instance of TQFolder whose name prefix indicates the type of element followed
	by the name of the element (e.g. "Sample.ttbar"). Properties of an element are stored as
	tags on the corresponding folders and sub-elements are represented by sub folders. Available
	elements and their properties are:

	- Channel ("Channel.name/");
	  - <StatRelErrorThreshold>
	  - <StatConstraintType>

	- Sample ("Sample.name/");
	  - <Histo>
	  - <.HistogramFile>
	  - <.HistogramPathPrefix>
	  - <NormalizeByTheory>
	  - <ActivateStatError>
	  - <StatErrorHisto>

	- NormFactor ("NormFactor.name/");
	  - <Val>
	  - <Low>
	  - <High>
	  - <Const>

	- OverallSys ("OverallSys.name/");
	  - <High>
	  - <Low>

	- HistoSys ("HistoSys.name/");
	  - <HistoHigh>
	  - <HistoLow>
	  - <.HistogramFile>
	  - <.HistogramPathPrefix>


	It will have to following structure:

	{Channel.*/}                       [one folder for each channel]
	  {Sample.*/}                      [one folder for each sample in channel]
	.Configuration/                    The model configuration folder after the model building
	                                   process which includes additional information (e.g. bin
	                                   boundaries from remapping)
	.Configuration.PreBuild/           A copy of the model configuration folder BEFORE the model
	                                   building process
	.Histograms/                       All histograms used in the model building process
	                                   (including those created from counter on-the-fly) are
	                                   stored here (this is also the folder written to a ROOT
	                                   file to let HistFactory grab the histograms from).

	A model created by the TSModelBuilder class is interfaced by the TSModelFactory class to
	HistFactory.



Function Members (Methods)

public:
virtual~TSModelBuilder()
static voidapplyEdits(TQFolder* edit, TQFolder* model)
static voidapplyStyle(TQFolder* model, const TString& samplename, TH1* hist)
virtual TQFolder*buildModel(TQFolder* config)
static TClass*Class()
virtual TQFolder*createDefinition(TQFolder* config)
virtual Bool_tfinalizeModel(TQFolder* model, TQFolder* config)
TH1*TQSystematicsManager::getHisto(TString path, bool verbose = true)
TQSampleFolder*TQSystematicsManager::getSampleFolder(TQTaggable* var)
TH1*TQSystematicsManager::getSysHisto(const TString& path, bool verbose = true)
TH1*TQSystematicsManager::getVarHisto(const TString& path, bool verbose = true)
TH1*TQSystematicsManager::getVarHisto(const TString& nameVariation, const TString& nameChannel, const TString& nameSample, bool verbose = true)
Bool_tTSSystematicsManager::includeAllSystematics(TQFolder* systematics, TList* allSamples)
boolTQSystematicsManager::includeHistoSys(TQFolder* sysFolder, TQFolder* sys, const TString& nameChannel, const TString& nameSample)
boolTQSystematicsManager::includeOverallSys(TQFolder* sysFolder, TQFolder* sys, const TString& nameChannel, const TString& nameSample)
Bool_tTSSystematicsManager::includeSystematics(TList* allSamples, TQFolder* systematic)
virtual TClass*IsA() const
boolTQSystematicsManager::isBlacklistedSys(TQFolder* sys, const vector<TString>& systBlacklist, const vector<TString>& types = {"OverallSys", "HistoSys"})
boolTQSystematicsManager::isNegligibleSys(TQFolder* sys, TQTaggable* parameters)
boolTQSystematicsManager::isProtectedSys(TQFolder* sys, TQTaggable* parameters, const TString& prefix) const
Bool_tTQSystematicsManager::isSystBlacklisted(TQFolder* sys, const vector<TString>& systBlacklist, const vector<TString>& types = {"OverallSys", "HistoSys"})
TSModelBuilder&operator=(const TSModelBuilder&)
Bool_tparseConversion(TString def, Bool_t& alongX, Bool_t& includeUnderflowX, Bool_t& includeOverflowX, Bool_t& includeUnderflowY, Bool_t& includeOverflowY)
Bool_tTSSystematicsManager::processAllSystematics(TQFolder* parameters, TList* allSamples, const TString& filter = "*", const vector<TString>& sampleBlacklist = {}, const vector<TString>& systBlacklist = {})
TH1*processHistogram(TQFolder* config, TQFolder* sampleDef, const TH1* histo)
boolTQSystematicsManager::processHistoSys(TQTaggable* parameters, TQFolder* sys)
boolTQSystematicsManager::processHistoSys_checkCutoff(TQTaggable* parameters, TH1* ratio)
boolTQSystematicsManager::processHistoSys_isFlat(TQTaggable* parameters, TQFolder* sys, TH1* ratio)
boolTQSystematicsManager::processHistoSys_smoothVariation(TQTaggable* parameters, TQFolder* sys, TH1* nom, TH1* up, TH1* down)
boolTQSystematicsManager::processHistoSys_systsToSymmetrizeBins(TQTaggable* parameters, TQFolder* sys, TH1* nom, TH1* up, TH1* down)
boolTQSystematicsManager::processHistoSys_systsToSymmetrizeMaxBins(TQTaggable* parameters, TQFolder* sys, TH1* nom, TH1* up, TH1* down, bool force = false)
boolTQSystematicsManager::processOverallSys(TQTaggable* parameters, TQFolder* sys)
voidpurgeVariation(TQFolder* model, const TString& name, Bool_t notify = false)
TQFolder*TQSystematicsManager::repository()
voidTQSystematicsManager::setRepository(TQFolder* histos)
voidTQSystematicsManager::setSampleFolder(const TString& path, TQSampleFolder* sf)
voidTQSystematicsManager::setSystematicPrefix(const TString& prefix)
voidTQSystematicsManager::setVariationPrefix(const TString& prefix)
virtual voidShowMembers(TMemberInspector& insp) const
TStringTQSystematicsManager::storeSysHisto(TH1* histo, const TString& path)
TStringTQSystematicsManager::storeSysHisto(TH1* histo, const TString& nameVariation, const TString& direction, const TString& nameChannel)
TStringTQSystematicsManager::storeVarHisto(TH1* histo, const TString& path)
TStringTQSystematicsManager::storeVarHisto(TH1* histo, const TString& nameVariation, const TString& nameChannel)
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
TSModelBuilder()
TSModelBuilder(const TSModelBuilder&)
protected:
virtual Bool_tcollectAllHistograms(TQFolder* config, TQFolder* model)
virtual Bool_tcollectHistograms(TQFolder* config, TQFolder* model, TQFolder* variation)
TH1*TQSystematicsManager::computeHistogramVariation(TQFolder* computeFolder, const TString& nameChannel, const TString& nameSample)
virtual Bool_tcreateChannelDefinition(TQFolder* config, TQFolder* model, TString name)
virtual Bool_tcreateChannelDefinitions(TQFolder* config, TQFolder* model)
boolTQSystematicsManager::emitError()
voiderror(TString message)
virtual vector<int>getMergeBins(TQFolder* config, TQFolder* channelConfig, map<TQFolder*,TH1*> histograms, TString varname, Bool_t isNominal, Int_t& dim)
virtual vector<int>getRemapping(TQFolder* channelConfig, TQSampleFolder* refSamples, TString refPath, TString refHistogram, TQTaggable* refHistogramOptions, Int_t remapX, Int_t remapY, Int_t& dim, Bool_t remapSlices)
virtual vector<int>getRemappingOptimizedSgnf(TQFolder* channelConfig, TQSampleFolder* refSamples, TString sigPath, TString bkgPath, TString histname, TQTaggable* histogramOptions, Int_t& dim)
vector<int>TQSystematicsManager::getSmoothedBinBorders(TQFolder* sysConfig)
voidinfo(TString message)
voidTQSystematicsManager::magnifyShapeVariation(TH1*& shape_Var, const TH1* h_Nom, Double_t magnification)
TH1*TQSystematicsManager::normalizeShapeVariation(const TH1* h_Var, const TH1* h_Nom, const TH1* h_Sym)
boolTQSystematicsManager::smoothHist(const TString& alg, TH1* nom, TH1* var)
voidwarn(TString message)
private:
virtual Bool_tCheckTObjectHashConsistency() const

Data Members

protected:
interrorCount
intmaxErrorCount
intmaxWarnCount
intwarnCount

Class Charts

Inheritance Chart:
TQSystematicsManager
TSSystematicsManager
TSModelBuilder

Function documentation

TSModelBuilder()
 Default constructor for TSModelBuilder class.
~TSModelBuilder()
void info(TString message)
void error(TString message)
void warn(TString message)
Bool_t createChannelDefinitions(TQFolder* config, TQFolder* model)
 Creates the basic channel definitions of a model from configuration <config>
 and returns true in case of success or false in case of failure.
Bool_t createChannelDefinition(TQFolder* config, TQFolder* model, TString name)
 Creates the basic channel definitions of a model from configuration <config>
 and returns true in case of success or false in case of failure.
TQFolder * createDefinition(TQFolder* config)
void applyEdits(TQFolder* edit, TQFolder* model)
Bool_t finalizeModel(TQFolder* model, TQFolder* config)
 Finalizes the model <model> based on the configuration <config> by collecting
 all histograms, including systematic uncertainties inferred from variations of
 input histograms, and returns true in case of success or false otherwise.
TQFolder * buildModel(TQFolder* config)
 Builds a model from configuration <config> and returns a pointer to the
 corresponding instance of TQFolder representing the model or a NULL pointer in
 case of failure
void purgeVariation(TQFolder* model, const TString& name, Bool_t notify = false)
 remove a variation from a model
Bool_t collectAllHistograms(TQFolder* config, TQFolder* model)
 collect all histograms from the sample folder and store them in the model
Bool_t parseConversion(TString def, Bool_t& alongX, Bool_t& includeUnderflowX, Bool_t& includeOverflowX, Bool_t& includeUnderflowY, Bool_t& includeOverflowY)
std::vector<int> getRemapping(TQFolder* channelConfig, TQSampleFolder* refSamples, TString refPath, TString refHistogram, TQTaggable* refHistogramOptions, Int_t remapX, Int_t remapY, Int_t& dim, Bool_t remapSlices)
name of channel
std::vector<int> getRemappingOptimizedSgnf(TQFolder* channelConfig, TQSampleFolder* refSamples, TString sigPath, TString bkgPath, TString histname, TQTaggable* histogramOptions, Int_t& dim)
name of channel
std::vector<int> getMergeBins(TQFolder* config, TQFolder* channelConfig, map<TQFolder*,TH1*> histograms, TString varname, Bool_t isNominal, Int_t& dim)
 merge bins of a histogram such that no histogram has contributions below mergeBins.minimalBinContent (default: 0), and the stack has no bin below mergeBins.minimalSummedBinContent (default: 1)
Bool_t collectHistograms(TQFolder* config, TQFolder* model, TQFolder* variation)
 collect all histograms from the sample folder
TH1* processHistogram(TQFolder* config, TQFolder* sampleDef, const TH1* histo)
 parameter folder
void applyStyle(TQFolder* model, const TString& samplename, TH1* hist)
TSModelBuilder()