Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lan13005 committed Mar 20, 2024
1 parent 46a506f commit 59b46c4
Show file tree
Hide file tree
Showing 19 changed files with 352 additions and 705 deletions.
29 changes: 8 additions & 21 deletions _modules/LoadParameters.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,19 +369,16 @@ <h1>Source code for LoadParameters</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">cfg</span> <span class="o">=</span> <span class="n">cfg</span>

<span class="n">constraintMap</span> <span class="o">=</span> <span class="n">cfg</span><span class="o">.</span><span class="n">constraintMap</span><span class="p">()</span>
<span class="n">constraintIndex</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">constraint_index</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">uniqueProdPars</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">allProdPars</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
<span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">vs</span> <span class="ow">in</span> <span class="n">constraintMap</span><span class="p">:</span>
<span class="n">allProdPars</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>
<span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">constraintIndex</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">cfg</span><span class="o">.</span><span class="n">amplitude</span><span class="p">(</span><span class="n">k</span><span class="p">)</span><span class="o">.</span><span class="n">fixed</span><span class="p">():</span>
<span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">constraint_index</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">cfg</span><span class="o">.</span><span class="n">amplitude</span><span class="p">(</span><span class="n">k</span><span class="p">)</span><span class="o">.</span><span class="n">fixed</span><span class="p">():</span>
<span class="n">constraint_index</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">i</span>
<span class="n">uniqueProdPars</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>
<span class="n">constraintIndex</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">i</span> <span class="c1">#uniqueProdPars[i]</span>
<span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">vs</span><span class="p">:</span>
<span class="k">if</span> <span class="n">v</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">constraintIndex</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">cfg</span><span class="o">.</span><span class="n">amplitude</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">.</span><span class="n">fixed</span><span class="p">():</span>
<span class="c1"># str(v) needed! appears that inserting v alone will go out of scope</span>
<span class="n">constraintIndex</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">v</span><span class="p">)]</span> <span class="o">=</span> <span class="n">i</span> <span class="c1">#uniqueProdPars[i] </span>
<span class="k">if</span> <span class="n">v</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">constraint_index</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">cfg</span><span class="o">.</span><span class="n">amplitude</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="o">.</span><span class="n">fixed</span><span class="p">():</span>
<span class="n">constraint_index</span><span class="p">[</span><span class="n">v</span><span class="p">]</span> <span class="o">=</span> <span class="n">i</span>
<span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>

<span class="c1">######## GET VALUES / REALNESS OF UNIQUE AMPLITUDES&#39; PRODUCTION PARAMETERS ########</span>
Expand All @@ -399,10 +396,7 @@ <h1>Source code for LoadParameters</h1><div class="highlight"><pre>

<span class="c1">####### MERGE DICTIONARIES ########</span>
<span class="bp">self</span><span class="o">.</span><span class="n">params</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">uniqueProdPars</span> <span class="o">|</span> <span class="bp">self</span><span class="o">.</span><span class="n">ampPars</span> <span class="c1"># python 3.9 - merge dictionaries</span>
<span class="bp">self</span><span class="o">.</span><span class="n">paramsIsReal</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">uniqueProdIsReal</span> <span class="o">|</span> <span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="kc">True</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ampPars</span><span class="o">.</span><span class="n">keys</span><span class="p">()}</span> <span class="c1"># all amp params are real</span>

<span class="c1">####### ADDITIONAL TRACKING #######</span>
<span class="bp">self</span><span class="o">.</span><span class="n">allProdPars</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">allProdPars</span><span class="p">)</span></div>
<span class="bp">self</span><span class="o">.</span><span class="n">paramsIsReal</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">uniqueProdIsReal</span> <span class="o">|</span> <span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="kc">True</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ampPars</span><span class="o">.</span><span class="n">keys</span><span class="p">()}</span> <span class="c1"># all amp params are real</span></div>

<div class="viewcode-block" id="LoadParameters.flatten_parameters"><a class="viewcode-back" href="../api/loadParameters.html#LoadParameters.LoadParameters.flatten_parameters">[docs]</a> <span class="k">def</span> <span class="nf">flatten_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">params</span><span class="o">=</span><span class="p">{}):</span>
<span class="w"> </span><span class="sd">&#39;&#39;&#39;</span>
Expand All @@ -419,7 +413,7 @@ <h1>Source code for LoadParameters</h1><div class="highlight"><pre>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">parameters</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">keys</span> <span class="o">=</span> <span class="p">[]</span> <span class="c1"># lose information on flatten, use key to keep track of provenance</span>
<span class="n">names</span> <span class="o">=</span> <span class="p">[]</span> <span class="c1"># track parameters in a prettier format</span>
<span class="n">names</span> <span class="o">=</span> <span class="p">[]</span> <span class="c1"># track parameter names, appending re/im to name if complex</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">params</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">:</span>
<span class="n">params</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">params</span>
<span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">params</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
Expand All @@ -428,14 +422,7 @@ <h1>Source code for LoadParameters</h1><div class="highlight"><pre>
<span class="n">real_value</span> <span class="o">=</span> <span class="n">v</span><span class="o">.</span><span class="n">real</span> <span class="k">if</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">uniqueProdPars</span> <span class="k">else</span> <span class="n">v</span>
<span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;Re[</span><span class="si">{</span><span class="n">pk</span><span class="si">}</span><span class="s1">]&#39;</span> <span class="k">if</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">uniqueProdPars</span> <span class="k">else</span> <span class="n">pk</span><span class="p">)</span>
<span class="n">parameters</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> <span class="n">real_value</span> <span class="p">)</span>

<span class="c1"># Production coefficients will have :: in their name. Normal parameters will not</span>
<span class="k">if</span> <span class="s1">&#39;::&#39;</span> <span class="ow">in</span> <span class="n">k</span><span class="p">:</span>
<span class="n">keys</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="o">+</span><span class="s2">&quot;_re&quot;</span><span class="p">)</span> <span class="c1"># MUST match notation in AmpTools&#39; parameterManager</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">keys</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>

<span class="c1"># If parameters are complex, we will include their imaginary components</span>
<span class="n">keys</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="o">+</span><span class="s2">&quot;_re&quot;</span><span class="p">)</span> <span class="c1"># MUST match notation in AmpTools&#39; parameterManager</span>
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">paramsIsReal</span><span class="p">[</span><span class="n">k</span><span class="p">]:</span>
<span class="n">parameters</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">v</span><span class="o">.</span><span class="n">imag</span><span class="p">)</span>
<span class="n">keys</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="o">+</span><span class="s2">&quot;_im&quot;</span><span class="p">)</span>
Expand Down
8 changes: 3 additions & 5 deletions _modules/atiSetup.html
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ <h1>Source code for atiSetup</h1><div class="highlight"><pre>
<span class="sd"> use_fsroot (bool): True if FSRoot library should be loaded</span>
<span class="sd"> use_genamp (bool): True if GenAmp library should be loaded</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">USE_MPI</span><span class="p">,</span> <span class="n">USE_GPU</span><span class="p">,</span> <span class="n">RANK_MPI</span> <span class="o">=</span> <span class="n">loadLibraries</span><span class="p">(</span> <span class="n">accelerator</span><span class="p">,</span> <span class="n">use_fsroot</span><span class="p">,</span> <span class="n">use_genamp</span> <span class="p">)</span>
<span class="n">set_aliases</span><span class="p">(</span> <span class="n">calling_globals</span><span class="p">,</span> <span class="n">USE_MPI</span><span class="p">,</span> <span class="n">USE_GPU</span> <span class="p">)</span>
<span class="n">USE_MPI</span><span class="p">,</span> <span class="n">USE_GPU</span><span class="p">,</span> <span class="n">RANK_MPI</span> <span class="o">=</span> <span class="n">loadLibraries</span><span class="p">(</span><span class="n">accelerator</span><span class="p">,</span> <span class="n">use_fsroot</span><span class="p">,</span> <span class="n">use_genamp</span><span class="p">)</span>
<span class="n">set_aliases</span><span class="p">(</span><span class="n">calling_globals</span><span class="p">,</span> <span class="n">USE_MPI</span><span class="p">)</span>

<span class="k">return</span> <span class="n">USE_MPI</span><span class="p">,</span> <span class="n">USE_GPU</span><span class="p">,</span> <span class="n">RANK_MPI</span></div>

Expand Down Expand Up @@ -403,7 +403,7 @@ <h1>Source code for atiSetup</h1><div class="highlight"><pre>
<span class="k">else</span><span class="p">:</span> <span class="n">status</span> <span class="o">=</span> <span class="s2">&quot;OFF&quot;</span>
<span class="k">if</span> <span class="n">RANK_MPI</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39; </span><span class="si">{</span><span class="n">status</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span></div>

<div class="viewcode-block" id="set_aliases"><a class="viewcode-back" href="../api/atiSetup.html#atiSetup.set_aliases">[docs]</a><span class="k">def</span> <span class="nf">set_aliases</span><span class="p">(</span> <span class="n">called_globals</span><span class="p">,</span> <span class="n">USE_MPI</span><span class="p">,</span> <span class="n">USE_GPU</span> <span class="p">):</span>
<div class="viewcode-block" id="set_aliases"><a class="viewcode-back" href="../api/atiSetup.html#atiSetup.set_aliases">[docs]</a><span class="k">def</span> <span class="nf">set_aliases</span><span class="p">(</span><span class="n">called_globals</span><span class="p">,</span> <span class="n">USE_MPI</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&#39;&#39;&#39;</span>
<span class="sd"> Due to MPI requiring c++ templates and the fact that all classes live under the ROOT namespace, aliasing can clean up the code significantly.</span>
<span class="sd"> A dictionary of aliases is appended to the globals() function of the calling function thereby making the aliases available in the calling function.</span>
Expand Down Expand Up @@ -445,8 +445,6 @@ <h1>Source code for atiSetup</h1><div class="highlight"><pre>
<span class="s1">&#39;TFile&#39;</span><span class="p">:</span> <span class="n">ROOT</span><span class="o">.</span><span class="n">TFile</span><span class="p">,</span>
<span class="s1">&#39;AmplitudeInfo&#39;</span><span class="p">:</span> <span class="n">ROOT</span><span class="o">.</span><span class="n">AmplitudeInfo</span><span class="p">,</span>
<span class="p">}</span>
<span class="k">if</span> <span class="n">USE_GPU</span><span class="p">:</span>
<span class="n">aliases</span><span class="p">[</span><span class="s1">&#39;GPUManager&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">ROOT</span><span class="o">.</span><span class="n">GPUManager</span>

<span class="n">called_globals</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">aliases</span><span class="p">)</span></div>

Expand Down
2 changes: 0 additions & 2 deletions _modules/fit.html
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,8 @@ <h1>Source code for fit</h1><div class="highlight"><pre>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;ALL FITS FAILED!&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;MINIMUM LIKELHOOD FROM ITERATION </span><span class="si">{</span><span class="n">minFitTag</span><span class="si">}</span><span class="s1"> of </span><span class="si">{</span><span class="n">N</span><span class="si">}</span><span class="s1"> RANDOM PRODUCTION PARS = </span><span class="si">{</span><span class="n">minNLL</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;cp </span><span class="si">{</span><span class="n">fitName</span><span class="si">}</span><span class="s1">_</span><span class="si">{</span><span class="n">minFitTag</span><span class="si">}</span><span class="s1">.fit </span><span class="si">{</span><span class="n">fitName</span><span class="si">}</span><span class="s1">.fit&#39;</span><span class="p">)</span>
<span class="n">os</span><span class="o">.</span><span class="n">system</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;cp </span><span class="si">{</span><span class="n">fitName</span><span class="si">}</span><span class="s1">_</span><span class="si">{</span><span class="n">minFitTag</span><span class="si">}</span><span class="s1">.fit </span><span class="si">{</span><span class="n">fitName</span><span class="si">}</span><span class="s1">.fit&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">seedfile</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;cp </span><span class="si">{</span><span class="n">seedfile</span><span class="si">}</span><span class="s1">_</span><span class="si">{</span><span class="n">minFitTag</span><span class="si">}</span><span class="s1">.txt </span><span class="si">{</span><span class="n">seedfile</span><span class="si">}</span><span class="s1">.txt&#39;</span><span class="p">)</span>
<span class="n">os</span><span class="o">.</span><span class="n">system</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;cp </span><span class="si">{</span><span class="n">seedfile</span><span class="si">}</span><span class="s1">_</span><span class="si">{</span><span class="n">minFitTag</span><span class="si">}</span><span class="s1">.txt </span><span class="si">{</span><span class="n">seedfile</span><span class="si">}</span><span class="s1">.txt&#39;</span><span class="p">)</span>

<span class="k">return</span> <span class="n">minNLL</span></div>
Expand Down
Loading

0 comments on commit 59b46c4

Please sign in to comment.