Skip to content

Commit

Permalink
Merge pull request #627 from ajgilbert/ch-may-15
Browse files Browse the repository at this point in the history
CombineHarvester May updates
  • Loading branch information
ajgilbert committed May 30, 2015
2 parents 0b1894d + 87df71d commit 3639cfc
Show file tree
Hide file tree
Showing 62 changed files with 2,665 additions and 639 deletions.
8 changes: 3 additions & 5 deletions CombineHarvester/CombinePdfs/test/MorphingMSSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ int main() {
}

cout << "Setting standardised bin names...";
cb.ForEachObs(ch::SetStandardBinName<ch::Observation>);
cb.ForEachProc(ch::SetStandardBinName<ch::Process>);
cb.ForEachSyst(ch::SetStandardBinName<ch::Systematic>);
ch::SetStandardBinNames(cb);
cout << " done\n";

RooWorkspace ws("htt", "htt");
Expand Down Expand Up @@ -300,8 +298,8 @@ int main() {
}
}
demo.Close();
cb.AddWorkspace(&ws);
cb.cp().signals().ExtractPdfs("htt", "$BIN_$PROCESS_morph", &cb);
cb.AddWorkspace(ws);
cb.cp().signals().ExtractPdfs(cb, "htt", "$BIN_$PROCESS_morph");
cb.PrintAll();

// cout << "Adding bbb...\n";
Expand Down
8 changes: 3 additions & 5 deletions CombineHarvester/CombinePdfs/test/ParametricMSSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ int main() {
cb.era({"8TeV"});

std::cout << "Setting standardised bin names...";
cb.ForEachObs(ch::SetStandardBinName<ch::Observation>);
cb.ForEachProc(ch::SetStandardBinName<ch::Process>);
cb.ForEachSyst(ch::SetStandardBinName<ch::Systematic>);
ch::SetStandardBinNames(cb);
std::cout << " done\n";

// cb.era({"8TeV"}).bin_id({8});
Expand Down Expand Up @@ -219,8 +217,8 @@ int main() {
}
cb_hm.process({"ggH", "bbH", "bkg"});

cb_hm.AddWorkspace(&ws);
cb_hm.cp().backgrounds().ExtractPdfs("htt", "$CHANNEL_bkgpdf");
cb_hm.AddWorkspace(ws);
cb_hm.cp().backgrounds().ExtractPdfs(cb_hm, "htt", "$CHANNEL_bkgpdf");
// cb_hm.PrintAll();
} else {
cb_hm.cp().bin_id({8}).VariableRebin(
Expand Down
4 changes: 2 additions & 2 deletions CombineHarvester/CombinePdfs/test/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ int main() {
}
}
}
cb.AddWorkspace(&ws);
cb.cp().signals().ExtractPdfs("htt", "$BIN_$PROCESS_morph", &cb);
cb.AddWorkspace(ws);
cb.cp().signals().ExtractPdfs(cb, "htt", "$BIN_$PROCESS_morph");

string folder = "output/sm_cards_morphed";
boost::filesystem::create_directories(folder);
Expand Down
5 changes: 3 additions & 2 deletions CombineHarvester/CombineTools/Rules.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
SUBDIRS :=
LIB_DEPS :=
LIB_EXTRA := -lboost_python -L$(shell scramv1 tool tag python LIBDIR) -l$(shell scramv1 tool tag python LIB) -lPyROOT
LIB_EXTRA := -lRooStats -lboost_python -L$(shell scramv1 tool tag python LIBDIR) -l$(shell scramv1 tool tag python LIB) -lPyROOT
PY_MODULES := combineharvester
PY_SRC_combineharvester := CombineHarvester_Python.pycc

$(d)/interface/GitVersion.h: $(TOP)/../.git/logs/HEAD
@echo -e "Updating $@"
Expand All @@ -14,4 +16,3 @@ clean_$(d) : clean_$(d)/interface/GitVersion.h
dir_$(d) : | $(d)/interface/GitVersion.h
tree_$(d) : | $(d)/interface/GitVersion.h
all_proxy :: | $(d)/interface/GitVersion.h

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mH xsec scale_hi scale_lo pdf_hi pdf_lo
80.0 2.341 +1.0 -1.0 +2.3 -2.3
81.0 2.258 +0.9 -0.9 +2.3 -2.3
82.0 2.179 +0.9 -0.9 +2.3 -2.3
Expand Down Expand Up @@ -282,4 +283,4 @@
370.0 0.008106 +1.8 -1.8 +5.0 -5.0
380.0 0.007225 +1.8 -1.8 +5.1 -5.1
390.0 0.006457 +1.8 -1.8 +5.2 -5.2
400.0 0.005783 +1.8 -1.8 +5.1 -5.1
400.0 0.005783 +1.8 -1.8 +5.1 -5.1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mH xsec scale_hi scale_lo pdf_hi pdf_lo
80.0 2.808 +1.1 -1.1 +2.2 -2.2
81.0 2.711 +1.1 -1.1 +2.2 -2.2
82.0 2.619 +1.0 -1.0 +2.2 -2.2
Expand Down Expand Up @@ -282,4 +283,4 @@
370.0 0.01076 +1.7 -1.7 +4.5 -4.5
380.0 0.009627 +1.7 -1.7 +4.6 -4.6
390.0 0.008629 +1.7 -1.7 +4.6 -4.6
400.0 0.007765 +1.7 -1.7 +4.6 -4.6
400.0 0.007765 +1.7 -1.7 +4.6 -4.6
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mH xsec scale_hi scale_lo pdf_hi pdf_lo
80.0 1.244 +1.8 -1.8 +2.3 -2.3
81.0 1.203 +1.8 -1.8 +2.3 -2.3
82.0 1.163 +1.8 -1.8 +2.4 -2.4
Expand Down Expand Up @@ -282,4 +283,4 @@
370.0 0.004734 +2.7 -2.7 +5.4 -5.4
380.0 0.004212 +2.8 -2.8 +5.5 -5.5
390.0 0.003757 +2.8 -2.8 +5.6 -5.6
400.0 0.003357 +2.8 -2.8 +5.5 -5.5
400.0 0.003357 +2.8 -2.8 +5.5 -5.5
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mH xsec scale_hi scale_lo pdf_hi pdf_lo
80.0 1.508 +1.9 -1.9 +2.1 -2.1
81.0 1.459 +1.9 -1.9 +2.1 -2.1
82.0 1.411 +2.0 -2.0 +2.1 -2.1
Expand Down Expand Up @@ -282,4 +283,4 @@
370.0 0.006364 +2.7 -2.7 +4.9 -4.9
380.0 0.005684 +2.8 -2.8 +5.0 -5.0
390.0 0.005090 +2.8 -2.8 +5.0 -5.0
400.0 0.004568 +2.8 -2.8 +5.0 -5.0
400.0 0.004568 +2.8 -2.8 +5.0 -5.0
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mH xsec scale_hi scale_lo pdf_hi pdf_lo
80.0 36.59 +8.3 -8.8 +7.8 -6.7
81.0 35.71 +8.3 -8.8 +7.8 -6.7
82.0 34.86 +8.3 -8.8 +7.8 -6.7
Expand Down Expand Up @@ -318,4 +319,4 @@
950.0 0.0257 +6.8 -5.7 +13.5 -12.7
960.0 0.0242 +6.8 -5.7 +13.7 -12.9
980.0 0.0216 +6.9 -5.7 +14.0 -13.2
1000.0 0.0192 +7.0 -5.7 +14.2 -13.5
1000.0 0.0192 +7.0 -5.7 +14.2 -13.5
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mH xsec scale_hi scale_lo pdf_hi pdf_lo
80.0 45.37 +8.8 -9.2 +7.9 -6.7
81.0 44.31 +8.8 -9.1 +7.9 -6.7
82.0 43.28 +8.7 -9.1 +7.9 -6.6
Expand Down Expand Up @@ -318,4 +319,4 @@
950.0 0.0424 +6.4 -5.4 +11.5 -10.7
960.0 0.0400 +6.4 -5.4 +11.6 -10.8
980.0 0.0357 +6.5 -5.4 +11.8 -11.0
1000.0 0.0320 +6.9 -5.4 +12.0 -11.2
1000.0 0.0320 +6.9 -5.4 +12.0 -11.2
3 changes: 2 additions & 1 deletion CombineHarvester/CombineTools/input/xsecs_brs/htt_YR3.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mH br unc_hi unc_lo
80.0 8.27E-02 +7.01 -6.85
81.0 8.27E-02 +7.01 -6.83
82.0 8.28E-02 +7.00 -6.84
Expand Down Expand Up @@ -318,4 +319,4 @@
950.0 3.66E-06 +17.86 -14.55
960.0 3.56E-06 +18.63 -14.96
980.0 3.38E-06 +20.23 -15.91
1000.0 3.20E-06 +22.04 -16.87
1000.0 3.20E-06 +22.04 -16.87
3 changes: 2 additions & 1 deletion CombineHarvester/CombineTools/input/xsecs_brs/hww_YR3.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mH br unc_hi unc_lo
80.0 6.27E-04 +5.89 -5.73
81.0 6.96E-04 +5.86 -5.72
82.0 7.74E-04 +5.89 -5.73
Expand Down Expand Up @@ -318,4 +319,4 @@
950.0 6.16E-01 +2.16 -2.42
960.0 6.17E-01 +2.17 -2.45
980.0 6.19E-01 +2.19 -2.50
1000.0 6.21E-01 +2.20 -2.55
1000.0 6.21E-01 +2.20 -2.55
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mH ratio
90.0 0.0026087
95.0 0.0058916
100.0 0.0139382
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mPhi accept
90.0 1.0107
100.0 1.0109
120.0 1.0112
Expand All @@ -16,4 +17,4 @@
700.0 1.1175
800.0 1.1627
900.0 1.2221
1000.0 1.3023
1000.0 1.3023
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mPhi accept
90.0 1.0103
100.0 1.0107
120.0 1.0111
Expand All @@ -16,4 +17,4 @@
700.0 1.0972
800.0 1.1305
900.0 1.1716
1000.0 1.2235
1000.0 1.2235
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mPhi accept
90.0 1.0310
100.0 1.0317
120.0 1.0332
Expand All @@ -16,4 +17,4 @@
700.0 4.7654
800.0 6.9610
900.0 10.4280
1000.0 15.3254
1000.0 15.3254
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mPhi accept
90.0 1.0301
100.0 1.0309
120.0 1.0318
Expand All @@ -16,4 +17,4 @@
700.0 3.8186
800.0 5.3704
900.0 7.6101
1000.0 10.7387
1000.0 10.7387
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mH xsec scale_hi scale_lo pdf_hi pdf_lo
80.0 1.914 +0.6 -0.2 +2.1 -2.1
81.0 1.894 +0.6 -0.2 +2.1 -2.1
82.0 1.871 +0.6 -0.2 +2.1 -2.1
Expand Down Expand Up @@ -318,4 +319,4 @@
950.0 0.01538 +2.0 -3.3 +11.5 -1.4
960.0 0.01493 +2.0 -3.3 +11.6 -1.4
980.0 0.01404 +2.1 -3.4 +11.8 -1.4
1000.0 0.01322 +2.2 -3.5 +12.0 -1.4
1000.0 0.01322 +2.2 -3.5 +12.0 -1.4
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mH xsec scale_hi scale_lo pdf_hi pdf_lo
80.0 2.424 +0.2 -0.3 +2.7 -3.0
81.0 2.399 +0.4 -0.3 +2.6 -3.0
82.0 2.364 +0.3 -0.3 +2.6 -2.8
Expand Down Expand Up @@ -318,4 +319,4 @@
950.0 0.02745 +0.6 -1.3 +5.4 -5.5
960.0 0.02669 +0.7 -1.2 +5.4 -5.8
980.0 0.02524 +0.7 -1.3 +5.5 -5.8
1000.0 0.02399 +0.7 -1.3 +5.6 -5.9
1000.0 0.02399 +0.7 -1.3 +5.6 -5.9
138 changes: 138 additions & 0 deletions CombineHarvester/CombineTools/interface/BinByBin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#ifndef CombineTools_BinByBin_h
#define CombineTools_BinByBin_h
#include <string>
#include "CombineTools/interface/CombineHarvester.h"

namespace ch {
/**
* Merges bin uncertainties and creates bin-by-bin statistical uncertainties
*
* Typical usage:
*
* auto bbb = ch::BinByBinFactory()
* .SetAddThreshold(0.1)
* .SetMergeThreshold(0.5)
* .SetFixNorm(true);
* bbb.MergeBinErrors(cb.cp().backgrounds());
* bbb.AddBinByBin(cb.cp().backgrounds(), cb);
*
* See below for details on each class method.
*/
class BinByBinFactory {
public:
BinByBinFactory();

/**
* Merges histogram bin errors between processes
*
* The method will loop through each analysis category and apply the merging
* algorithm to the histograms of all processes within that category:
*
* * In a given histogram bin consider contributions from the \f$j\f$
* processes with bin contents \f$x_{i}\f$, bin errors \f$e_{i}\f$
* and with \f$e_{i}/x_{i}\f$ larger than the bin-by-bin addition
* threshold (\ref SetAddThreshold). Note that by setting this threshold
* to zero the contributions from all processes will be considered.
* * Evaluate the total squared uncertainty from these processes:
* \f$e_{TOT}^{2} = e_{1}^{2} + e_{2}^{2} + ... + e_{j}^{2} \f$
* * Rank bins from lowest to highest fraction error: \f$e_{i}^{2}/e_{TOT}^{2}\f$
* * Start removing bin errors from the lowest ranked bins as long as the total
* sum of squared error removed (\f$r_{sub}\f$) is less than the merge threshold
* (\ref SetMergeThreshold).
* * Once as many bin errors have been removed as possible, scale up the
* remaining errors by a factor \f$\sqrt{1/(1-r_{sub})}\f$, which ensure the
* total bin error from all processes remains the same.
* * Note that the BinByBinFactory default is a merging threshold of zero,
* in which no merging takes place. The most extreme threshold is 1, in
* which all errors will be merged into a single process.
*
* @note For a valid result all analysis event categories must have a unique
* `bin()` value.
*/
void MergeBinErrors(CombineHarvester &cb);

/**
* Create bin-by-bin shape uncertainties for every process in **src**, and
* add these to **dest**
*
* The behaviour of this function is controlled by three parameters:
*
* * The first is the uncertainty threshold which determines whether a
* systematic will be created for a given histogram bin
* (\ref SetAddThreshold). For a bin with content \f$x\f$ and bin error
* \f$e\f$, this threshold is thefractional error \f$e/x\f$.
* * The second parameters (\ref SetFixNorm) is a flag that when set to
* `true` will re-normalize the up and down shape templates to have the
* same integral as the nominal. This means the nuisance parameter for
* this bin is only able to change the shape of the distribution: if a
* bin is shifted up, all other bins are shifted down slightly to
* preserve the normalisation. This feature is useful when the
* statistical uncertainty in the process yield is considered as an
* independent nuisance parameter.
* * The third parameters is a pattern-string which prescribes how the
* bin-by-bin uncertainties should be named. By default this is
* `CMS_$ANALYSIS_$CHANNEL_$BIN_$ERA_$PROCESS_bin_$#`, but can be
* changed with \ref SetPattern. Note that the special term `$#`
* should always be included as this is replaced with the bin index.
*/
void AddBinByBin(CombineHarvester &src, CombineHarvester &dest);

/**
* A convenience function which calls \ref MergeBinErrors and \ref
* AddBinByBin in turn
*/
void MergeAndAdd(CombineHarvester &src, CombineHarvester &dest);

/**
* By default this class only produces output on the screen when an error
* occurs, set to a value greater than zero for more verbose output
*/
inline BinByBinFactory& SetVerbosity(unsigned verbosity) {
v_ = verbosity;
return *this;
}

/**
* Set the fractional bin error threshold for bin-by-bin creation and
* for participation in the merging algorithm
*/
inline BinByBinFactory& SetAddThreshold(double val) {
bbb_threshold_ = val;
return *this;
}

/**
* The threshold for the merging algorithm
*/
inline BinByBinFactory& SetMergeThreshold(double val) {
merge_threshold_ = val;
return *this;
}

/**
* The pattern-string for the systematic naming convention
*/
inline BinByBinFactory& SetPattern(std::string const& pattern) {
pattern_ = pattern;
return *this;
}

/**
* Whether or not the bin-by-bin systematics are allowed to vary the process
* normalisation
*/
inline BinByBinFactory& SetFixNorm(bool fix) {
fix_norm_ = fix;
return *this;
}

private:
std::string pattern_;
unsigned v_;
double bbb_threshold_;
double merge_threshold_;
bool fix_norm_;
};
}

#endif
Loading

0 comments on commit 3639cfc

Please sign in to comment.