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::string input_filename;</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  std::string output_filename;</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  TFile* input_file;</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& input_filename, <span class="keyword">const</span> std::string output_filename)</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  :input_filename(input_filename),</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  output_filename(output_filename),</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  next_entry(0) {</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  input_file = TFile::Open(input_filename.c_str());</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  Init((TTree*) input_file->Get(<span class="stringliteral">"tree"</span>));</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  nentries = fChain->GetEntriesFast();</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  output_file = TFile::Open(output_filename.c_str(), <span class="stringliteral">"RECREATE"</span>);</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  this->fChain->SetBranchStatus(<span class="stringliteral">"*"</span>, <span class="keyword">false</span>);</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  }</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span> </div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  ~MiniTreeDataSet(){</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  input_file->Close();</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  output_file->Close();</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  }</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span> </div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <span class="keyword">template</span> <<span class="keyword">typename</span> T></div><div class="line"><a name="l00085"></a><span class="lineno"> 85</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="l00086"></a><span class="lineno"> 86</span>  TBranch* branch = fChain->GetBranch(bname.c_str());</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  <span class="keywordflow">if</span> (branch == <span class="keyword">nullptr</span>){</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</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="l00089"></a><span class="lineno"> 89</span>  }</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  T* bref = (T*) branch->GetAddress();</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  fChain->SetBranchStatus(bname.c_str(), <span class="keyword">true</span>);</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  INFO(<span class="stringliteral">"Registering branch \""</span> << bname</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  << <span class="stringliteral">"\" with address "</span> << bref</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  << <span class="stringliteral">" and type "</span> << <span class="keyword">typeid</span>(bref).name());</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</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="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>  <span class="keyword">template</span> <<span class="keyword">typename</span> T></div><div class="line"><a name="l00099"></a><span class="lineno"> 99</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="l00100"></a><span class="lineno"> 100</span>  TBranch* branch = fChain->GetBranch(bname.c_str());</div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  <span class="keywordflow">if</span> (branch == <span class="keyword">nullptr</span>){</div><div class="line"><a name="l00102"></a><span class="lineno"> 102</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="l00103"></a><span class="lineno"> 103</span>  }</div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span>  T* bref = (T*) branch->GetAddress();</div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span>  fChain->SetBranchStatus(bname.c_str(), <span class="keyword">true</span>);</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  INFO(<span class="stringliteral">"Registering pointer branch \""</span> << bname</div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  << <span class="stringliteral">"\" with address "</span> << bref</div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  << <span class="stringliteral">" and type "</span> << <span class="keyword">typeid</span>(bref).name());</div><div class="line"><a name="l00109"></a><span class="lineno"> 109</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="l00110"></a><span class="lineno"> 110</span>  }</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span> </div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  <span class="keyword">template</span> <<span class="keyword">typename</span> T></div><div class="line"><a name="l00113"></a><span class="lineno"> 113</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="l00114"></a><span class="lineno"> 114</span>  track_branch_ptr<T>(value_bname);</div><div class="line"><a name="l00115"></a><span class="lineno"> 115</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="l00116"></a><span class="lineno"> 116</span>  }</div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span> </div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  <span class="keywordtype">void</span> save_all(){</div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  output_file->cd();</div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  <span class="keywordflow">for</span>(<span class="keyword">auto</span> container : containers){</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  container.second->save_as(<span class="stringliteral">"outfile"</span>, SaveOption::ROOT);</div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  }</div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  <span class="comment">// Save the value names for each container to enable looking up</span></div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  <span class="comment">// what values are plotted</span></div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  std::map<string,string> value_lookup = this->get_container_name_value_map();</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</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="l00127"></a><span class="lineno"> 127</span> </div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  std::map<string,string> fn_impl_lookup = this->get_function_name_impl_map();</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</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="l00130"></a><span class="lineno"> 130</span>  }</div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span> };</div><div class="line"><a name="l00132"></a><span class="lineno"> 132</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>
- <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> value.hpp:448</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> api.hpp:38</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> value.hpp:415</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> api.hpp:8</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> value.hpp:1208</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>
|