## [Nsclspectcl-cvscommits] SF.net SVN: nsclspectcl:[1794] branches/LLNLMadcChainSpecTcl

 [Nsclspectcl-cvscommits] SF.net SVN: nsclspectcl:[1794] branches/LLNLMadcChainSpecTcl From: - 2011-01-21 11:10:53 ```Revision: 1794 http://nsclspectcl.svn.sourceforge.net/nsclspectcl/?rev=1794&view=rev Author: ron-fox Date: 2011-01-21 11:10:47 +0000 (Fri, 21 Jan 2011) Log Message: ----------- I think we have the CBAR plot the way Phil wants it now. Also simplified the y2f computation to line us up for y3f etc. Modified Paths: -------------- branches/LLNLMadcChainSpecTcl/CMultiplicity.cpp branches/LLNLMadcChainSpecTcl/plotCbar.tcl Modified: branches/LLNLMadcChainSpecTcl/CMultiplicity.cpp =================================================================== --- branches/LLNLMadcChainSpecTcl/CMultiplicity.cpp 2011-01-19 22:06:35 UTC (rev 1793) +++ branches/LLNLMadcChainSpecTcl/CMultiplicity.cpp 2011-01-21 11:10:47 UTC (rev 1794) @@ -52,6 +52,13 @@ return product; } +/* compute (n m) binomial: n!/m!(n-m)! */ +/* The assumption is that n,m are small enough factorials won't blow up.. */ +static inline double +binomial(int n, int m) +{ + return factorial(n)/(factorial(m)*factorial(n-m)); +} /*! Construction builds the tree parameters and what we can of the CTCLVariable. @@ -1142,7 +1149,7 @@ for (int i = 0; i < mult.size(); i++) { - double coef = factorial(i)/2*(factorial(i-2)); // for our purposes factorial won't be too big. + double coef = binomial(i,2); pairs += coef*mult[i]; } double result = (pairs - 0.5*cb*cb)/cb; Modified: branches/LLNLMadcChainSpecTcl/plotCbar.tcl =================================================================== --- branches/LLNLMadcChainSpecTcl/plotCbar.tcl 2011-01-19 22:06:35 UTC (rev 1793) +++ branches/LLNLMadcChainSpecTcl/plotCbar.tcl 2011-01-21 11:10:47 UTC (rev 1794) @@ -166,6 +166,7 @@ puts \$fitf [expr {\$i*\$m}] } close \$fitf + set rate [expr \$m*1.0e6] # Open the gnu plot and tell it what to do: # note that if we're making postscript we need to prompt for the @@ -191,14 +192,28 @@ puts \$gp "set terminal postscript portrait enhanced mono dashed lw 1 'Helvetica' 14" puts \$gp "set output '\$outputFile'" } - puts \$gp "set title '\$title : Fit slope \$m'" + puts \$gp "set title '\$title'" puts \$gp "set xlabel '\$Xtitle'" puts \$gp "set ylabel '\$Ytitle'" if {\$logScale} { puts \$gp "set logscale y" } puts \$gp "set key off" - puts \$gp "plot '\$dataFile' with points 3 7, '\$fitFile' with points 1 22"; # blue solid circles + + # Labels in the plot frame: + + set labelBase [expr \$i*\$m*9/10] + set labelX [expr \$gateCount/10] + set labelIncr [expr \$i*\$m/20] + puts \$gp "set label \"Count rate [format %7.5e \$rate]\" at \$labelX,\$labelBase left" + set labelBase [expr \$labelBase + \$labelIncr] + puts \$gp "set label \"[\$self dataSourceLabel]\" at \$labelX,\$labelBase left" + + # End of the plot frame labels + + puts \$gp "plot '\$dataFile' with points 3 7, '\$fitFile' with lines 1"; # blue solid circles, red lines. + + puts \$gp "pause mouse button3 'Click right mouse button in window to close'" puts \$gp "exit" flush \$gp @@ -211,5 +226,17 @@ } + # + # This method determines the data source label for the plot + # + method dataSourceLabel {} { + set rawSource [attach -list] + set type [lindex \$rawSource 0] + if {\$type eq "File:"} { + return [file tail [lindex \$rawSource 1]] + } else { + return "Online" + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```