1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <!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.8.13"/>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <title>TTTT Analysis: /home/caleb/Sources/TTTT/analysis/MiniTreeDataSet.hpp Source File</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="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>
- <link href="doxygen.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: 56px;">
- <td id="projectalign" style="padding-left: 0.5em;">
- <div id="projectname">TTTT Analysis
-  <span id="projectnumber">0.1</span>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- end header part -->
- <!-- Generated by Doxygen 1.8.13 -->
- <script type="text/javascript">
- var searchBox = new SearchBox("searchBox", "search",false,'Search');
- </script>
- <script type="text/javascript" src="menudata.js"></script>
- <script type="text/javascript" src="menu.js"></script>
- <script type="text/javascript">
- $(function() {
- initMenu('',true,false,'search.php','Search');
- $(document).ready(function() { init_search(); });
- });
- </script>
- <div id="main-nav"></div>
- <!-- 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 id="nav-path" class="navpath">
- <ul>
- <li class="navelem"><a class="el" href="dir_b8678fa8510b7ff9a55ffd4d18fd5e47.html">analysis</a></li> </ul>
- </div>
- </div><!-- top -->
- <div class="header">
- <div class="headertitle">
- <div class="title">MiniTreeDataSet.hpp</div> </div>
- </div><!--header-->
- <div class="contents">
- <a href="MiniTreeDataSet_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> </div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="preprocessor">#ifndef minitreedataset_h</span></div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="preprocessor">#define minitreedataset_h</span></div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span> </div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="preprocessor">#include <string></span></div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="preprocessor">#include <tuple></span></div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span> </div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="preprocessor">#include "filval/filval.hpp"</span></div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span> <span class="preprocessor">#include "filval_root/filval_root.hpp"</span></div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span> <span class="preprocessor">#include "<a class="code" href="MiniTree_8hpp.html">MiniTree.hpp</a>"</span></div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span> </div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span> <span class="keyword">using namespace </span><a class="code" href="namespacestd.html">std</a>;</div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span> <span class="keyword">using namespace </span><a class="code" href="namespacefv.html">fv</a>;</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span> <span class="keyword">using namespace </span><a class="code" href="namespacefv_1_1root.html">fv::root</a>;</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span> </div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span> <span class="keyword">class </span>MiniTreeDataSet : <span class="keyword">public</span> DataSet,</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  <span class="keyword">public</span> MiniTree{</div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  std::map<std::string,std::string> input_filenames_with_labels;</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <span class="comment">/* std::vector<TFile*> input_files; */</span></div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  std::string output_filename;</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  TFile* output_file;</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  <span class="keywordtype">long</span> next_entry;</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  <span class="keywordtype">long</span> nentries;</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <span class="keywordtype">bool</span> load_next(){</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  <span class="keywordflow">if</span> (next_entry >= nentries) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  fChain->GetEntry(next_entry);</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  ++next_entry;</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  }</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  <span class="keywordtype">int</span> get_events(){</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  <span class="keywordflow">return</span> nentries;</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  }</div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  <span class="keywordtype">int</span> get_current_event(){</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  <span class="keywordflow">return</span> next_entry-1;</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>  }</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span> </div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  MiniTreeDataSet(<span class="keyword">const</span> std::string& output_filename, <span class="keyword">const</span> std::string input_filename)</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  :DataSet(),</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  input_filenames_with_labels({ {input_filename, <span class="stringliteral">"signal"</span>} }),</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  output_filename(output_filename),</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  next_entry(0) {</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  TChain* chain = <span class="keyword">new</span> TChain(<span class="stringliteral">"tree"</span>);</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  chain->Add(input_filename.c_str());</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  Init(chain);</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  nentries = fChain->GetEntries();</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  output_file = TFile::Open(output_filename.c_str(), <span class="stringliteral">"RECREATE"</span>);</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  this->fChain->SetBranchStatus(<span class="stringliteral">"*"</span>, <span class="keyword">false</span>);</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  }</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span> </div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  MiniTreeDataSet(<span class="keyword">const</span> std::string& output_filename, <span class="keyword">const</span> std::map<std::string,std::string>& filenames_with_labels)</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  :DataSet(),</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  input_filenames_with_labels(filenames_with_labels),</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  output_filename(output_filename),</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  next_entry(0) {</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  TChain* chain = <span class="keyword">new</span> TChain(<span class="stringliteral">"tree"</span>);</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  <span class="keywordflow">for</span>(<span class="keyword">auto</span>& p : filenames_with_labels){</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  std::string filename;</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  std::tie(filename, std::ignore) = p;</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  chain->Add(filename.c_str());</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  }</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  Init(chain);</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  nentries = fChain->GetEntries();</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  output_file = TFile::Open(output_filename.c_str(), <span class="stringliteral">"RECREATE"</span>);</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  this->fChain->SetBranchStatus(<span class="stringliteral">"*"</span>, <span class="keyword">false</span>);</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  }</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span> </div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  ~MiniTreeDataSet(){</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  output_file->Close();</div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  }</div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span> </div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  <span class="keyword">const</span> std::string& get_current_event_label()<span class="keyword"> const</span>{</div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  TFile* file = fChain->GetFile();</div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span>  std::string filename = file->GetName();</div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span>  <span class="keywordflow">return</span> input_filenames_with_labels.at(filename);</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  }</div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span> </div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  <span class="keyword">template</span> <<span class="keyword">typename</span> T></div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  <a class="code" href="classfv_1_1Value.html">Value<T></a>* track_branch(<span class="keyword">const</span> std::string& bname){</div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  TBranch* branch = fChain->GetBranch(bname.c_str());</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  <span class="keywordflow">if</span> (branch == <span class="keyword">nullptr</span>){</div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  CRITICAL(<span class="stringliteral">"Branch: "</span> << bname << <span class="stringliteral">" does not exist in input tree."</span>, -1);</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span>  }</div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  T* bref = (T*) branch->GetAddress();</div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  fChain->SetBranchStatus(bname.c_str(), <span class="keyword">true</span>);</div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  INFO(<span class="stringliteral">"Registering branch \""</span> << bname</div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  << <span class="stringliteral">"\" with address "</span> << bref</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  << <span class="stringliteral">" and type "</span> << <span class="keyword">typeid</span>(bref).name());</div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classfv_1_1ObservedValue.html">ObservedValue<T></a>(bname, bref);</div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  }</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span> </div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  <span class="keyword">template</span> <<span class="keyword">typename</span> T></div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  <a class="code" href="classfv_1_1Value.html">Value<T*></a>* track_branch_ptr(<span class="keyword">const</span> std::string& bname){</div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  TBranch* branch = fChain->GetBranch(bname.c_str());</div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  <span class="keywordflow">if</span> (branch == <span class="keyword">nullptr</span>){</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  CRITICAL(<span class="stringliteral">"Branch: "</span> << bname << <span class="stringliteral">" does not exist in input tree."</span>, -1);</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  }</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  T* bref = (T*) branch->GetAddress();</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  fChain->SetBranchStatus(bname.c_str(), <span class="keyword">true</span>);</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  INFO(<span class="stringliteral">"Registering pointer branch \""</span> << bname</div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  << <span class="stringliteral">"\" with address "</span> << bref</div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  << <span class="stringliteral">" and type "</span> << <span class="keyword">typeid</span>(bref).name());</div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classfv_1_1PointerValue.html">PointerValue<T></a>(bname, bref);</div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  }</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span> </div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <span class="keyword">template</span> <<span class="keyword">typename</span> T></div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  decltype(<span class="keyword">auto</span>) track_branch_vec(const <a class="code" href="namespacestd.html">std</a>::<span class="keywordtype">string</span>& size_bname, const <a class="code" href="namespacestd.html">std</a>::<span class="keywordtype">string</span>& value_bname){</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  track_branch_ptr<T>(value_bname);</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  <span class="keywordflow">return</span> wrapper_vector<T>(lookup<int>(size_bname), lookup<T*>(value_bname), value_bname);</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  }</div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span> </div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  <span class="keywordtype">void</span> save_all(){</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  output_file->cd();</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span> </div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  <span class="comment">// Save the value names for each container to enable looking up</span></div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  <span class="comment">// what values are plotted</span></div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  std::map<string,string> value_lookup = this->get_container_name_value_map();</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  gDirectory->WriteObjectAny(&value_lookup, <span class="stringliteral">"std::map<std::string,std::string>"</span>, <span class="stringliteral">"_value_lookup"</span>);</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span> </div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  std::map<string,string> fn_impl_lookup = this->get_function_name_impl_map();</div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  gDirectory->WriteObjectAny(&fn_impl_lookup, <span class="stringliteral">"std::map<std::string,std::string>"</span>, <span class="stringliteral">"_function_impl_lookup"</span>);</div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span> </div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  <span class="keywordflow">for</span>(<span class="keyword">auto</span> container : containers){</div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  container.second->save_as(<span class="stringliteral">"outfile"</span>, SaveOption::ROOT);</div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  }</div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span>  }</div><div class="line"><a name="l00157"></a><span class="lineno"> 157</span> };</div><div class="line"><a name="l00158"></a><span class="lineno"> 158</span> <span class="preprocessor">#endif // minitreedataset_h</span></div><div class="ttc" id="namespacestd_html"><div class="ttname"><a href="namespacestd.html">std</a></div><div class="ttdoc">STL namespace. </div></div>
- <div class="ttc" id="classfv_1_1ObservedValue_html"><div class="ttname"><a href="classfv_1_1ObservedValue.html">fv::ObservedValue</a></div><div class="ttdoc">A value supplied by the dataset, not derived. </div><div class="ttdef"><b>Definition:</b> <a href="value_8hpp_source.html#l00450">value.hpp:450</a></div></div>
- <div class="ttc" id="namespacefv_html"><div class="ttname"><a href="namespacefv.html">fv</a></div><div class="ttdoc">The namespace containing all filval classes and functions. </div><div class="ttdef"><b>Definition:</b> <a href="api_8hpp_source.html#l00046">api.hpp:46</a></div></div>
- <div class="ttc" id="classfv_1_1Value_html"><div class="ttname"><a href="classfv_1_1Value.html">fv::Value</a></div><div class="ttdoc">A templated value. </div><div class="ttdef"><b>Definition:</b> <a href="value_8hpp_source.html#l00265">value.hpp:265</a></div></div>
- <div class="ttc" id="namespacefv_1_1root_html"><div class="ttname"><a href="namespacefv_1_1root.html">fv::root</a></div><div class="ttdef"><b>Definition:</b> <a href="root_2api_8hpp_source.html#l00008">api.hpp:8</a></div></div>
- <div class="ttc" id="MiniTree_8hpp_html"><div class="ttname"><a href="MiniTree_8hpp.html">MiniTree.hpp</a></div></div>
- <div class="ttc" id="classfv_1_1PointerValue_html"><div class="ttname"><a href="classfv_1_1PointerValue.html">fv::PointerValue</a></div><div class="ttdoc">A Value of a pointer. </div><div class="ttdef"><b>Definition:</b> <a href="value_8hpp_source.html#l01209">value.hpp:1209</a></div></div>
- </div><!-- fragment --></div><!-- contents -->
- <!-- start footer part -->
- <hr class="footer"/><address class="footer"><small>
- Generated by  <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/>
- </a> 1.8.13
- </small></address>
- </body>
- </html>
|