-
Notifications
You must be signed in to change notification settings - Fork 184
/
Copy pathintro2.html
266 lines (264 loc) · 35.8 KB
/
intro2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<title>CombineHarvester: Examples Part II</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 70px;">
<td style="padding-left: 0.5em;">
<div id="projectname">CombineHarvester
</div>
</td>
<td> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.svg"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('intro2.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">Examples Part II </div> </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#ex2-p1">Defining categories and processes</a></li>
<li class="level1"><a href="#ex2-p2">Creating systematics</a></li>
<li class="level1"><a href="#ex2-p3">Extracting shape inputs</a></li>
<li class="level1"><a href="#ex2-p4">Adding bin-by-bin uncertainties</a></li>
<li class="level1"><a href="#ex2-p5">Writing datacards</a></li>
</ul>
</div>
<div class="textblock"><p><a class="anchor" id="md_docs_Example2"></a></p>
<p><b>File</b>: CombineTools/bin/Example2.cpp</p>
<p>In this example we will set up a simplified version of the Higgs to tau tau datacards, while exploring the main features of datacard creation with the CombineHarvester tool. To run the example, first make sure the code has been compiled: </p><pre class="fragment">cd $CMSSW_BASE/src
scram b -j4
Example2
</pre> <h1><a class="anchor" id="ex2-p1"></a>
Defining categories and processes</h1>
<p>We start by defining two analysis categories (or 'bins'). It's a good idea for each bin to have a unique name: this is required by combine, and while not required by CombineHarvester explicitly, a number of functions rely on this being true. CombineHarvester also allows for each object to be assigned an integer value, called a "bin_id", that does not need to be unique. This can be useful to label a "type-of-category" that might appear more than once. For example, VBF event categories for both the 7TeV and 8TeV datasets might have a common bin_id, but different names: "vbf_7TeV" and "vbf_8TeV".</p>
<div class="fragment"><div class="line"> <span class="comment">// First define the location of the "auxiliaries" directory where we can</span></div>
<div class="line"> <span class="comment">// source the input files containing the datacard shapes</span></div>
<div class="line"> <span class="keywordtype">string</span> aux_shapes = string(getenv(<span class="stringliteral">"CMSSW_BASE"</span>)) + <span class="stringliteral">"/src/auxiliaries/shapes/"</span>;</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Create an empty CombineHarvester instance that will hold all of the</span></div>
<div class="line"> <span class="comment">// datacard configuration and histograms etc.</span></div>
<div class="line"> <a class="code" href="classch_1_1_combine_harvester.html">ch::CombineHarvester</a> cb;</div>
<div class="line"> <span class="comment">// Uncomment this next line to see a *lot* of debug information</span></div>
<div class="line"> <span class="comment">// cb.SetVerbosity(3);</span></div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Here we will just define two categories for an 8TeV analysis. Each entry in</span></div>
<div class="line"> <span class="comment">// the vector below specifies a bin name and corresponding bin_id.</span></div>
<div class="line"> <a class="code" href="namespacech.html#aa97b500b98aeaa86756eb1c5395a866e">ch::Categories</a> cats = {</div>
<div class="line"> {1, <span class="stringliteral">"muTau_1jet_medium"</span>},</div>
<div class="line"> {2, <span class="stringliteral">"muTau_vbf_loose"</span>}</div>
<div class="line"> };</div>
<div class="line"> <span class="comment">// ch::Categories is just a typedef of vector<pair<int, string>></span></div>
<div class="ttc" id="aclassch_1_1_combine_harvester_html"><div class="ttname"><a href="classch_1_1_combine_harvester.html">ch::CombineHarvester</a></div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester_8h_source.html#l00030">CombineHarvester.h:30</a></div></div>
<div class="ttc" id="anamespacech_html_aa97b500b98aeaa86756eb1c5395a866e"><div class="ttname"><a href="namespacech.html#aa97b500b98aeaa86756eb1c5395a866e">ch::Categories</a></div><div class="ttdeci">std::vector< std::pair< int, std::string > > Categories</div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester_8h_source.html#l00028">CombineHarvester.h:28</a></div></div>
</div><!-- fragment --><p> Now we define the signal mass points we will build datacards for, but note these are specified as strings, not floats. The function <code><a class="el" href="namespacech.html#a9aa7fae276e9a3482b0e2e0b7adf779b" title="Generate a vector of mass values using ranges and intervals specified in a string.">ch::MassesFromRange</a></code> is used to quickly generate mass values from 120 to 135 GeV in 5 GeV steps.</p>
<div class="fragment"><div class="line"> vector<string> masses = <a class="code" href="namespacech.html#a9aa7fae276e9a3482b0e2e0b7adf779b">ch::MassesFromRange</a>(<span class="stringliteral">"120-135:5"</span>);</div>
<div class="line"> <span class="comment">// Or equivalently, specify the mass points explicitly:</span></div>
<div class="line"> <span class="comment">// vector<string> masses = {"120", "125", "130", "135"};</span></div>
<div class="ttc" id="anamespacech_html_a9aa7fae276e9a3482b0e2e0b7adf779b"><div class="ttname"><a href="namespacech.html#a9aa7fae276e9a3482b0e2e0b7adf779b">ch::MassesFromRange</a></div><div class="ttdeci">std::vector< std::string > MassesFromRange(std::string const &input, std::string const &fmt="%.0f")</div><div class="ttdoc">Generate a vector of mass values using ranges and intervals specified in a string.</div><div class="ttdef"><b>Definition:</b> <a href="_utilities_8cc_source.html#l00249">Utilities.cc:249</a></div></div>
</div><!-- fragment --><p> The next step is to add some new objects to the CombineHarvester instance. First we will specifiy the observations (i.e. the actual data). The <a class="el" href="classch_1_1_combine_harvester.html#a8d7ccde30bda35ec084f4e38b923ef23">AddObservations</a> method takes a series of vectors as arguments. Each vector specifies some property, such as the analysis name, the dataset era or the bin information. Every possible combination of elements from these vectors will be used to add a new Observation entry.</p>
<p>The arguments are: AddObservations(masses, analyses, eras, channels, categories)</p>
<p>Below we specify one mass entry ("*"), which implies we only need one entry that will cover all signal mass hypotheses. Then we specify the higgs-tau-tau analysis ("htt"), the 8TeV dataset ("8TeV"), the mu+tau analysis channel ("mt") and the categories we defined above. If the analysis, era and channel properties aren't relevant for your analysis, you can always leave them as a single emtpy string.</p>
<div class="fragment"><div class="line"> cb.<a class="code" href="classch_1_1_combine_harvester.html#a8d7ccde30bda35ec084f4e38b923ef23">AddObservations</a>({<span class="stringliteral">"*"</span>}, {<span class="stringliteral">"htt"</span>}, {<span class="stringliteral">"8TeV"</span>}, {<span class="stringliteral">"mt"</span>}, cats);</div>
<div class="ttc" id="aclassch_1_1_combine_harvester_html_a8d7ccde30bda35ec084f4e38b923ef23"><div class="ttname"><a href="classch_1_1_combine_harvester.html#a8d7ccde30bda35ec084f4e38b923ef23">ch::CombineHarvester::AddObservations</a></div><div class="ttdeci">void AddObservations(std::vector< std::string > mass, std::vector< std::string > analysis, std::vector< std::string > era, std::vector< std::string > channel, ch::Categories bin)</div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester___creation_8cc_source.html#l00020">CombineHarvester_Creation.cc:20</a></div></div>
</div><!-- fragment --><p> Next we add the signal and background processes. The arguments are similar to the AddObservations method. An extra argument is added after the channels for the list of processes, and a final boolean option specifies whether these are signal or background processes. Note that each process name here should correspond to the histogram name in your input file. In the signal case we pass the list of Higgs mass hypotheses generated above instead of the generic "*".</p>
<div class="fragment"><div class="line"> vector<string> bkg_procs = {<span class="stringliteral">"ZTT"</span>, <span class="stringliteral">"W"</span>, <span class="stringliteral">"QCD"</span>, <span class="stringliteral">"TT"</span>};</div>
<div class="line"> cb.<a class="code" href="classch_1_1_combine_harvester.html#a1ecb940a59ea7a2039956a07882e9ccc">AddProcesses</a>({<span class="stringliteral">"*"</span>}, {<span class="stringliteral">"htt"</span>}, {<span class="stringliteral">"8TeV"</span>}, {<span class="stringliteral">"mt"</span>}, bkg_procs, cats, <span class="keyword">false</span>);</div>
<div class="line"> </div>
<div class="line"> vector<string> sig_procs = {<span class="stringliteral">"ggH"</span>, <span class="stringliteral">"qqH"</span>};</div>
<div class="line"> cb.<a class="code" href="classch_1_1_combine_harvester.html#a1ecb940a59ea7a2039956a07882e9ccc">AddProcesses</a>(masses, {<span class="stringliteral">"htt"</span>}, {<span class="stringliteral">"8TeV"</span>}, {<span class="stringliteral">"mt"</span>}, sig_procs, cats, <span class="keyword">true</span>);</div>
<div class="ttc" id="aclassch_1_1_combine_harvester_html_a1ecb940a59ea7a2039956a07882e9ccc"><div class="ttname"><a href="classch_1_1_combine_harvester.html#a1ecb940a59ea7a2039956a07882e9ccc">ch::CombineHarvester::AddProcesses</a></div><div class="ttdeci">void AddProcesses(std::vector< std::string > mass, std::vector< std::string > analysis, std::vector< std::string > era, std::vector< std::string > channel, std::vector< std::string > procs, ch::Categories bin, bool signal)</div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester___creation_8cc_source.html#l00045">CombineHarvester_Creation.cc:45</a></div></div>
</div><!-- fragment --> <h1><a class="anchor" id="ex2-p2"></a>
Creating systematics</h1>
<p>The next step is to add details of the systematic uncertainties. The details of an uncertainty on a single process in a single bin is called a <a class="el" href="classch_1_1_systematic.html">ch::Systematic</a>. With CombineHarvester we create the <a class="el" href="classch_1_1_systematic.html">ch::Systematic</a> entries for each uncertainty source in turn. In doing so we must specify: the name of the nuisance parameter we want to use, the type (i.e. normalisation or shape), which processes it should be applied to and the magnitude of the uncertainty on each process. All this information can be expressed in a single line of code (though for clarity we will usually split it over multiple lines), for example the luminosity uncertainty:</p>
<div class="fragment"><div class="line"> cb.<a class="code" href="classch_1_1_combine_harvester.html#ade0f7c161d078a189404a274b93336d2">cp</a>().<a class="code" href="classch_1_1_combine_harvester.html#a21c176f208a1603055113bd00e920d2d">signals</a>()</div>
<div class="line"> .<a class="code" href="classch_1_1_combine_harvester.html#aab26f47e06ee53fcf1aab5c0940e916f">AddSyst</a>(cb, <span class="stringliteral">"lumi_$ERA"</span>, <span class="stringliteral">"lnN"</span>, SystMap<era>::init</div>
<div class="line"> ({<span class="stringliteral">"7TeV"</span>}, 1.022)</div>
<div class="line"> ({<span class="stringliteral">"8TeV"</span>}, 1.026));</div>
<div class="ttc" id="aclassch_1_1_combine_harvester_html_a21c176f208a1603055113bd00e920d2d"><div class="ttname"><a href="classch_1_1_combine_harvester.html#a21c176f208a1603055113bd00e920d2d">ch::CombineHarvester::signals</a></div><div class="ttdeci">CombineHarvester & signals()</div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester___filters_8cc_source.html#l00146">CombineHarvester_Filters.cc:146</a></div></div>
<div class="ttc" id="aclassch_1_1_combine_harvester_html_aab26f47e06ee53fcf1aab5c0940e916f"><div class="ttname"><a href="classch_1_1_combine_harvester.html#aab26f47e06ee53fcf1aab5c0940e916f">ch::CombineHarvester::AddSyst</a></div><div class="ttdeci">void AddSyst(CombineHarvester &target, std::string const &name, std::string const &type, Map const &valmap)</div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester_8h_source.html#l00682">CombineHarvester.h:682</a></div></div>
<div class="ttc" id="aclassch_1_1_combine_harvester_html_ade0f7c161d078a189404a274b93336d2"><div class="ttname"><a href="classch_1_1_combine_harvester.html#ade0f7c161d078a189404a274b93336d2">ch::CombineHarvester::cp</a></div><div class="ttdeci">CombineHarvester cp()</div><div class="ttdoc">Creates and returns a shallow copy of the CombineHarvester instance.</div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester_8cc_source.html#l00220">CombineHarvester.cc:220</a></div></div>
</div><!-- fragment --><p> We can break this line down into several parts. cb.cp() returns a shallow copy of the CombineHarvester instance - i.e. the Observation and Process entries are shared with the original object (see the documentation of <a class="el" href="intro1.html#ex1-p4">Example 1</a>). However, removing entries from this shallow copy leaves the entries in the original instance intact. The next method, <a class="el" href="classch_1_1_combine_harvester.html#a21c176f208a1603055113bd00e920d2d">signals()</a>, acts on this copy. This is one of several filter methods. It removes any non-signal process from the internal entries. We do this because we only want to create Systematic entries for the signal processes. Like all filter methods this returns a reference to itself. Then we can apply the actual <a class="el" href="classch_1_1_combine_harvester.html#aab26f47e06ee53fcf1aab5c0940e916f">AddSyst</a> method. The first argument is a reference to the CombineHarvester instance where the new Systematic entries should be created. In this case we just give it our original instance (remember we are calling the AddSyst method on a copy of this instance). The next argument is the Systematic name. Before the Systematic entry for each Process is created a number of string substitutions will be made, based on the properties of the process in question. These are: </p><pre class="fragment">$BIN --> proc.bin()
$PROCESS --> proc.process() (the process name)
$MASS --> proc.mass()
$ERA --> proc.era()
$CHANNEL --> proc.channel()
$ANALYSIS --> proc.analysis()
</pre><p> So in this example we will expect names like "lumi_8TeV". This substitution provides a quick way of renaming systematics to be correlated/uncorrelated between different channels/analyses/bins etc. Next we specifiy the nuisance type, which must be either "lnN" or "shape". The final argument is special map (SystMap) that contains the set of values that should be added. The <a class="el" href="classch_1_1syst_1_1_syst_map.html">SystMap</a> is a templated class, which can take an arbitrary number of template parameters. Each parameter specifies a Process property that will be used as part of the key to map to the values. In this case we will just use the process era as a key. We initialse a new map with <code>init</code>, then provide a series of entries. Each entry should consist of a series of vectors, one for each key value, and end in the lnN value that should be assigned. Processes matching any combination of key properties in this map will be assigned the given value. In this map, we assign any Process with era "7TeV" a value of 1.022, and any "8TeV" Process a value of 1.026. More examples are given below:</p>
<div class="fragment"><div class="line"> cb.<a class="code" href="classch_1_1_combine_harvester.html#ade0f7c161d078a189404a274b93336d2">cp</a>().<a class="code" href="classch_1_1_combine_harvester.html#a3afe330e302ad37b9fd69a821b8b4099">process</a>({<span class="stringliteral">"ggH"</span>})</div>
<div class="line"> .AddSyst(cb, <span class="stringliteral">"pdf_gg"</span>, <span class="stringliteral">"lnN"</span>, SystMap<>::init(1.097));</div>
<div class="line"> </div>
<div class="line"> cb.<a class="code" href="classch_1_1_combine_harvester.html#ade0f7c161d078a189404a274b93336d2">cp</a>().<a class="code" href="classch_1_1_combine_harvester.html#a3afe330e302ad37b9fd69a821b8b4099">process</a>(<a class="code" href="namespacech.html#abfd9e94a6fd4c33abe1bbd5fb03e7f28">ch::JoinStr</a>({sig_procs, {<span class="stringliteral">"ZTT"</span>, <span class="stringliteral">"TT"</span>}}))</div>
<div class="line"> .<a class="code" href="classch_1_1_combine_harvester.html#aab26f47e06ee53fcf1aab5c0940e916f">AddSyst</a>(cb, <span class="stringliteral">"CMS_eff_m"</span>, <span class="stringliteral">"lnN"</span>, SystMap<>::init(1.02));</div>
<div class="line"> </div>
<div class="line"> cb.<a class="code" href="classch_1_1_combine_harvester.html#ade0f7c161d078a189404a274b93336d2">cp</a>()</div>
<div class="line"> .<a class="code" href="classch_1_1_combine_harvester.html#aab26f47e06ee53fcf1aab5c0940e916f">AddSyst</a>(cb,</div>
<div class="line"> <span class="stringliteral">"CMS_scale_j_$ERA"</span>, <span class="stringliteral">"lnN"</span>, SystMap<era, bin_id, process>::init</div>
<div class="line"> ({<span class="stringliteral">"8TeV"</span>}, {1}, {<span class="stringliteral">"ggH"</span>}, 1.04)</div>
<div class="line"> ({<span class="stringliteral">"8TeV"</span>}, {1}, {<span class="stringliteral">"qqH"</span>}, 0.99)</div>
<div class="line"> ({<span class="stringliteral">"8TeV"</span>}, {2}, {<span class="stringliteral">"ggH"</span>}, 1.10)</div>
<div class="line"> ({<span class="stringliteral">"8TeV"</span>}, {2}, {<span class="stringliteral">"qqH"</span>}, 1.04)</div>
<div class="line"> ({<span class="stringliteral">"8TeV"</span>}, {2}, {<span class="stringliteral">"TT"</span>}, 1.05));</div>
<div class="line"> </div>
<div class="line"> cb.<a class="code" href="classch_1_1_combine_harvester.html#ade0f7c161d078a189404a274b93336d2">cp</a>().<a class="code" href="classch_1_1_combine_harvester.html#a3afe330e302ad37b9fd69a821b8b4099">process</a>(<a class="code" href="namespacech.html#abfd9e94a6fd4c33abe1bbd5fb03e7f28">ch::JoinStr</a>({sig_procs, {<span class="stringliteral">"ZTT"</span>}}))</div>
<div class="line"> .<a class="code" href="classch_1_1_combine_harvester.html#aab26f47e06ee53fcf1aab5c0940e916f">AddSyst</a>(cb, <span class="stringliteral">"CMS_scale_t_mutau_$ERA"</span>, <span class="stringliteral">"shape"</span>, SystMap<>::init(1.00));</div>
<div class="ttc" id="aclassch_1_1_combine_harvester_html_a3afe330e302ad37b9fd69a821b8b4099"><div class="ttname"><a href="classch_1_1_combine_harvester.html#a3afe330e302ad37b9fd69a821b8b4099">ch::CombineHarvester::process</a></div><div class="ttdeci">CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)</div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester___filters_8cc_source.html#l00035">CombineHarvester_Filters.cc:35</a></div></div>
<div class="ttc" id="anamespacech_html_abfd9e94a6fd4c33abe1bbd5fb03e7f28"><div class="ttname"><a href="namespacech.html#abfd9e94a6fd4c33abe1bbd5fb03e7f28">ch::JoinStr</a></div><div class="ttdeci">std::vector< std::string > JoinStr(std::vector< std::vector< std::string >> const &in)</div><div class="ttdef"><b>Definition:</b> <a href="_utilities_8cc_source.html#l00153">Utilities.cc:153</a></div></div>
</div><!-- fragment --><p> Creation of asymmetric "lnN" uncertainties is supported through the <a class="el" href="classch_1_1syst_1_1_syst_map_asymm.html">SystMapAsymm</a> class, whose interface is very similar to <a class="el" href="classch_1_1syst_1_1_syst_map.html">SystMap</a>. Instead of a single uncertainty value, simply provide the "down" and "up" relative uncertainties as two separate arguments.</p>
<h1><a class="anchor" id="ex2-p3"></a>
Extracting shape inputs</h1>
<p>Next we populate these Observation, Process and Systematic entries with the actual histograms (and also yields). The last two arguments are the patterns which will be used to determine the paths of the nominal and systematic shape templates in the given file. Here we must do this separately for signal and background shapes which use a different naming convention. NOTE: In this method only the following substitutions are supported: </p><pre class="fragment">$BIN --> proc.bin()
$PROCESS --> proc.process()
$MASS --> proc.mass()
$SYSTEMATIC --> syst.name()
</pre><p> Also note that data histogram must be named data_obs to be extracted by this command.</p>
<div class="fragment"><div class="line"> cb.<a class="code" href="classch_1_1_combine_harvester.html#ade0f7c161d078a189404a274b93336d2">cp</a>().<a class="code" href="classch_1_1_combine_harvester.html#a1efc38e1377d77deaf5e9c4c8adbb250">backgrounds</a>().<a class="code" href="classch_1_1_combine_harvester.html#ad4bd2bb5458d8435efd8fff49624b7b0">ExtractShapes</a>(</div>
<div class="line"> aux_shapes + <span class="stringliteral">"Imperial/htt_mt.inputs-sm-8TeV-hcg.root"</span>,</div>
<div class="line"> <span class="stringliteral">"$BIN/$PROCESS"</span>,</div>
<div class="line"> <span class="stringliteral">"$BIN/$PROCESS_$SYSTEMATIC"</span>);</div>
<div class="line"> cb.<a class="code" href="classch_1_1_combine_harvester.html#ade0f7c161d078a189404a274b93336d2">cp</a>().<a class="code" href="classch_1_1_combine_harvester.html#a21c176f208a1603055113bd00e920d2d">signals</a>().<a class="code" href="classch_1_1_combine_harvester.html#ad4bd2bb5458d8435efd8fff49624b7b0">ExtractShapes</a>(</div>
<div class="line"> aux_shapes + <span class="stringliteral">"Imperial/htt_mt.inputs-sm-8TeV-hcg.root"</span>,</div>
<div class="line"> <span class="stringliteral">"$BIN/$PROCESS$MASS"</span>,</div>
<div class="line"> <span class="stringliteral">"$BIN/$PROCESS$MASS_$SYSTEMATIC"</span>);</div>
<div class="ttc" id="aclassch_1_1_combine_harvester_html_a1efc38e1377d77deaf5e9c4c8adbb250"><div class="ttname"><a href="classch_1_1_combine_harvester.html#a1efc38e1377d77deaf5e9c4c8adbb250">ch::CombineHarvester::backgrounds</a></div><div class="ttdeci">CombineHarvester & backgrounds()</div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester___filters_8cc_source.html#l00156">CombineHarvester_Filters.cc:156</a></div></div>
<div class="ttc" id="aclassch_1_1_combine_harvester_html_ad4bd2bb5458d8435efd8fff49624b7b0"><div class="ttname"><a href="classch_1_1_combine_harvester.html#ad4bd2bb5458d8435efd8fff49624b7b0">ch::CombineHarvester::ExtractShapes</a></div><div class="ttdeci">void ExtractShapes(std::string const &file, std::string const &rule, std::string const &syst_rule)</div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester___creation_8cc_source.html#l00159">CombineHarvester_Creation.cc:159</a></div></div>
</div><!-- fragment --> <h1><a class="anchor" id="ex2-p4"></a>
Adding bin-by-bin uncertainties</h1>
<p>The next step is optional. This will generate additional shape uncertainties to account for limited template statistics, so-called "bin-by-bin" uncertainties.</p>
<div class="fragment"><div class="line"> <span class="keyword">auto</span> bbb = <a class="code" href="classch_1_1_bin_by_bin_factory.html">ch::BinByBinFactory</a>()</div>
<div class="line"> .<a class="code" href="classch_1_1_bin_by_bin_factory.html#a022063406869d59a03e7aef47ce53e34">SetAddThreshold</a>(0.1)</div>
<div class="line"> .<a class="code" href="classch_1_1_bin_by_bin_factory.html#a05d997b69c619df3c2f7d20e4e7106b7">SetFixNorm</a>(<span class="keyword">true</span>);</div>
<div class="line"> </div>
<div class="line"> bbb.<a class="code" href="classch_1_1_bin_by_bin_factory.html#ab097f067dce0a722af70dd86bf1b5398">AddBinByBin</a>(cb.<a class="code" href="classch_1_1_combine_harvester.html#ade0f7c161d078a189404a274b93336d2">cp</a>().<a class="code" href="classch_1_1_combine_harvester.html#a1efc38e1377d77deaf5e9c4c8adbb250">backgrounds</a>(), cb);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// This function modifies every entry to have a standardised bin name of</span></div>
<div class="line"> <span class="comment">// the form: {analysis}_{channel}_{bin_id}_{era}</span></div>
<div class="line"> <span class="comment">// which is commonly used in the htt analyses</span></div>
<div class="line"> <a class="code" href="namespacech.html#a99d1b22dfcd46bfde6a31a7a5765cd2b">ch::SetStandardBinNames</a>(cb);</div>
<div class="ttc" id="aclassch_1_1_bin_by_bin_factory_html"><div class="ttname"><a href="classch_1_1_bin_by_bin_factory.html">ch::BinByBinFactory</a></div><div class="ttdoc">Merges bin uncertainties and creates bin-by-bin statistical uncertainties.</div><div class="ttdef"><b>Definition:</b> <a href="_bin_by_bin_8h_source.html#l00021">BinByBin.h:21</a></div></div>
<div class="ttc" id="aclassch_1_1_bin_by_bin_factory_html_a022063406869d59a03e7aef47ce53e34"><div class="ttname"><a href="classch_1_1_bin_by_bin_factory.html#a022063406869d59a03e7aef47ce53e34">ch::BinByBinFactory::SetAddThreshold</a></div><div class="ttdeci">BinByBinFactory & SetAddThreshold(double val)</div><div class="ttdoc">Set the fractional bin error threshold for bin-by-bin creation and for participation in the merging a...</div><div class="ttdef"><b>Definition:</b> <a href="_bin_by_bin_8h_source.html#l00099">BinByBin.h:99</a></div></div>
<div class="ttc" id="aclassch_1_1_bin_by_bin_factory_html_a05d997b69c619df3c2f7d20e4e7106b7"><div class="ttname"><a href="classch_1_1_bin_by_bin_factory.html#a05d997b69c619df3c2f7d20e4e7106b7">ch::BinByBinFactory::SetFixNorm</a></div><div class="ttdeci">BinByBinFactory & SetFixNorm(bool fix)</div><div class="ttdoc">Whether or not the bin-by-bin systematics are allowed to vary the process normalisation.</div><div class="ttdef"><b>Definition:</b> <a href="_bin_by_bin_8h_source.html#l00124">BinByBin.h:124</a></div></div>
<div class="ttc" id="aclassch_1_1_bin_by_bin_factory_html_ab097f067dce0a722af70dd86bf1b5398"><div class="ttname"><a href="classch_1_1_bin_by_bin_factory.html#ab097f067dce0a722af70dd86bf1b5398">ch::BinByBinFactory::AddBinByBin</a></div><div class="ttdeci">void AddBinByBin(CombineHarvester &src, CombineHarvester &dest)</div><div class="ttdoc">Create bin-by-bin shape uncertainties for every process in src, and add these to dest</div><div class="ttdef"><b>Definition:</b> <a href="_bin_by_bin_8cc_source.html#l00105">BinByBin.cc:105</a></div></div>
<div class="ttc" id="anamespacech_html_a99d1b22dfcd46bfde6a31a7a5765cd2b"><div class="ttname"><a href="namespacech.html#a99d1b22dfcd46bfde6a31a7a5765cd2b">ch::SetStandardBinNames</a></div><div class="ttdeci">void SetStandardBinNames(CombineHarvester &cb, std::string const &pattern="$ANALYSIS_$CHANNEL_$BINID_$ERA")</div><div class="ttdef"><b>Definition:</b> <a href="_utilities_8cc_source.html#l00078">Utilities.cc:78</a></div></div>
</div><!-- fragment --><p> We first create a <a class="el" href="classch_1_1_bin_by_bin_factory.html" title="Merges bin uncertainties and creates bin-by-bin statistical uncertainties.">ch::BinByBinFactory</a> instance, and specify the bin error threshold over which an uncertainty should be created, expressed as a percentage of the bin content. We also set the flag "FixedNorm", which controls the normalisation of the Up and Down shapes that are created. If set to true, the normalisation is fixed to nominal rate. If false, the normalisation is allowed to vary. We then call the AddBinByBin method specifying that only the background processes should be considered.</p>
<h1><a class="anchor" id="ex2-p5"></a>
Writing datacards</h1>
<p>Now we will iterate through the set of bins and mass points and write a text datacard file for each:</p>
<div class="fragment"><div class="line"> <span class="comment">// First we generate a set of bin names:</span></div>
<div class="line"> set<string> bins = cb.<a class="code" href="classch_1_1_combine_harvester.html#a869c951c635b86fba33b2c550c9c39c9">bin_set</a>();</div>
<div class="line"> <span class="comment">// This method will produce a set of unique bin names by considering all</span></div>
<div class="line"> <span class="comment">// Observation, Process and Systematic entries in the CombineHarvester</span></div>
<div class="line"> <span class="comment">// instance.</span></div>
<div class="line"> </div>
<div class="line"> <span class="comment">// We create the output root file that will contain all the shapes.</span></div>
<div class="line"> TFile output(<span class="stringliteral">"htt_mt.input.root"</span>, <span class="stringliteral">"RECREATE"</span>);</div>
<div class="line"> </div>
<div class="line"> <span class="comment">// Finally we iterate through each bin,mass combination and write a</span></div>
<div class="line"> <span class="comment">// datacard.</span></div>
<div class="line"> <span class="keywordflow">for</span> (<span class="keyword">auto</span> b : bins) {</div>
<div class="line"> <span class="keywordflow">for</span> (<span class="keyword">auto</span> m : masses) {</div>
<div class="line"> cout << <span class="stringliteral">">> Writing datacard for bin: "</span> << b << <span class="stringliteral">" and mass: "</span> << m</div>
<div class="line"> << <span class="stringliteral">"\n"</span>;</div>
<div class="line"> <span class="comment">// We need to filter on both the mass and the mass hypothesis,</span></div>
<div class="line"> <span class="comment">// where we must remember to include the "*" mass entry to get</span></div>
<div class="line"> <span class="comment">// all the data and backgrounds.</span></div>
<div class="line"> cb.<a class="code" href="classch_1_1_combine_harvester.html#ade0f7c161d078a189404a274b93336d2">cp</a>().<a class="code" href="classch_1_1_combine_harvester.html#a83dd50569a1f1a4b5a46f2ad2b5c1cdb">bin</a>({b}).mass({m, <span class="stringliteral">"*"</span>}).WriteDatacard(</div>
<div class="line"> b + <span class="stringliteral">"_"</span> + m + <span class="stringliteral">".txt"</span>, output);</div>
<div class="line"> }</div>
<div class="line"> }</div>
<div class="ttc" id="aclassch_1_1_combine_harvester_html_a83dd50569a1f1a4b5a46f2ad2b5c1cdb"><div class="ttname"><a href="classch_1_1_combine_harvester.html#a83dd50569a1f1a4b5a46f2ad2b5c1cdb">ch::CombineHarvester::bin</a></div><div class="ttdeci">CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)</div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester___filters_8cc_source.html#l00013">CombineHarvester_Filters.cc:13</a></div></div>
<div class="ttc" id="aclassch_1_1_combine_harvester_html_a869c951c635b86fba33b2c550c9c39c9"><div class="ttname"><a href="classch_1_1_combine_harvester.html#a869c951c635b86fba33b2c550c9c39c9">ch::CombineHarvester::bin_set</a></div><div class="ttdeci">std::set< std::string > bin_set()</div><div class="ttdef"><b>Definition:</b> <a href="_combine_harvester___filters_8cc_source.html#l00190">CombineHarvester_Filters.cc:190</a></div></div>
</div><!-- fragment --><p> While we are required to write a separate datacard for each mass point, there is no obligation to generate one for each bin. For example, </p><pre class="fragment"> cb.cp().mass({"125", "*"}).WriteDatacard("combined_125.txt", output);
</pre><p> will produce a datacard containing all categories. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
</body>
</html>