<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Josh Cogan&#039;s Projects</title>
	<atom:link href="http://joshcogan.com/wp/feed/" rel="self" type="application/rss+xml" />
	<link>http://joshcogan.com/wp</link>
	<description>Fun stuff Josh works on</description>
	<lastBuildDate>Tue, 19 Aug 2014 16:30:41 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>Server Farm Dynamic Feedback</title>
		<link>http://joshcogan.com/wp/2013/03/server-farm-dynamic-feedback/</link>
		<comments>http://joshcogan.com/wp/2013/03/server-farm-dynamic-feedback/#comments</comments>
		<pubDate>Tue, 26 Mar 2013 01:36:01 +0000</pubDate>
		<dc:creator><![CDATA[Josh]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[distributed computing]]></category>
		<category><![CDATA[farm]]></category>
		<category><![CDATA[feedback]]></category>
		<category><![CDATA[numerical computing]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://joshcogan.com/wp/?p=153</guid>
		<description><![CDATA[This project, lovingly knowns as the Online Beamspot Determination, was the coding project that received the lion&#8217;s share of my graduate coding hours.  And after many many grueling code-compile-test-redeploy cycles, all we got was this beautiful diagram.  Well, OK.  We<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://joshcogan.com/wp/2013/03/server-farm-dynamic-feedback/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>This project, lovingly knowns as the <strong>Online Beamspot Determination</strong>, was the coding project that received the lion&#8217;s share of my graduate coding hours.  And after many many grueling code-compile-test-redeploy cycles, all we got was this beautiful diagram.  Well, OK.  We also got a pretty damn cool tool.</p>
<p>Mostly this post is about &#8220;ooooh aaaaah pretty diagram&#8221;.  But below I&#8217;ll try to explain what we are doing using a web-server analogy.</p>
<p><![if !IE]><iframe src="http://docs.google.com/viewer?url=http%3A%2F%2Fjoshcogan.com%2Fwp%2Fwp-content%2Fuploads%2F2013%2F03%2Fonline_bst_sct.pdf&amp;embedded=true" class="pdf" frameborder="0" style="height:500px;width:600px;border:0" width="600" height="500"></iframe><![endif]><!--[if IE]><object width="600" height="500" type="application/pdf" data="http://joshcogan.com/wp/wp-content/uploads/2013/03/online_bst_sct.pdf" class="pdf ie"><!-- wpnl --> <div style="width:600;height:500;text-align:center;background:#fff;color:#000;margin:0;border:0;padding:0">Unable to display PDF<br /><a href="http://joshcogan.com/wp/wp-content/uploads/2013/03/online_bst_sct.pdf">Click here to download</a></div>
 <!-- wpnl --></object><![endif]--></p>
<h2>The Analogy:</h2>
<p>Imagine a farm of Google search servers: the waving wheat, the moo-ing cows.  Idyllic.  No but seriously, these server processes are getting <em>pounded</em> by search requests.  For the sake of discussion let&#8217;s make a few assumptions. First suppose that most requests were identical to others that occurred within the last few minutes.  For example, ever time Kobe Bryant scores a basket, a million people Google &#8220;Kobe&#8221; (and not the beef).</p>
<p>In such a universe, you might want to detect the onset of these correlated search waves and respond very quickly by updating a set of cached results the servers in the Western US use.  This is a tricky problem because you have thousands of machines who each see a slight uptick of &#8220;Kobe&#8221; searches and you need to make a decision to update caches that will affect those same machines, even though not one of them sees the whole picture.  And they&#8217;re all acting asynchronously.  Bummer, dude.</p>
<h2>The Limits of the Analogy and our Solution:</h2>
<p>Our problem, which is part of the ATLAS Trigger and Data Acquisition system, has two big differences.  Firstly, our system is partly synchronous.  This means that we have a single point, called the Central Trigger Processor, that is guaranteed to control the flow of data downstream of it (which is then asynchronously processed).  Secondly, our system really really needs the parallel processes to cooperate.  In the Kobe example you might argue that if the wave of searches was so damn big, each individual process would notice it.  Yea perhaps, its just an analogy!  In our system it takes thousands of processes working across dozens of racks to accumulate enough statistics to accurately measure these parameters of physical (and technical) interest called the<strong></strong> <em>Luminous Region</em><strong></strong>.</p>
<p>We accomplished the N:N communication problem by a <strong>big fan-in and fan-out</strong>, which uses a hierarchical data-collection and -distribution.  So we aggregate all the data across the processes for about ten minutes, crunch thousands and thousands of fits on them, then make a decision.  Have the parameters we&#8217;re measuring, changed so much that we need to inform the farm?  If so we push our values to an accessible location and trigger an update.  Then WHAMO!  Those exact same processes go fetch the fruits of their collective labor.  Many hands make light work =).</p>
<p>In this way, we were able to coordinate so many processes without ever letting them know about each other.  And when they all do go update their values (as close to synchronicity as the farm ever gets) it still induces &lt; 10ms of dead time on the system.  Not to shabby at all!</p>
<p>&nbsp;</p>
<p>Well that&#8217;s all I had on the diagram.  Like I said, just an overview.  Thanks for reading!</p>
]]></content:encoded>
			<wfw:commentRss>http://joshcogan.com/wp/2013/03/server-farm-dynamic-feedback/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Infinite Volume Simulations</title>
		<link>http://joshcogan.com/wp/2013/03/infinite-volume-simulations/</link>
		<comments>http://joshcogan.com/wp/2013/03/infinite-volume-simulations/#comments</comments>
		<pubDate>Wed, 20 Mar 2013 06:08:31 +0000</pubDate>
		<dc:creator><![CDATA[Josh]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[puzzles]]></category>

		<guid isPermaLink="false">http://joshcogan.com/wp/?p=123</guid>
		<description><![CDATA[Hi Team, So here&#8217;s a puzzler for today:  How can you numerically simulate two planets interacting via gravity, in a universe with infinite volume?  Of course you only have standard computing architecture available.  Once you have a guess, make gravity repulsive<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://joshcogan.com/wp/2013/03/infinite-volume-simulations/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>Hi Team,</p>
<p>So here&#8217;s a puzzler for today:  How can you numerically simulate two planets interacting via gravity, in a universe with <strong>infinite volume</strong>?  Of course you only have standard computing architecture available.  Once you have a guess, make gravity repulsive and see if your solution still works.</p>
<p>&nbsp;</p>
<p>And since I&#8217;m totally an evil T.A., discuss when and how your numerical error grows &#8220;too large&#8221;.  Good hunting!</p>
]]></content:encoded>
			<wfw:commentRss>http://joshcogan.com/wp/2013/03/infinite-volume-simulations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ineffective Sorts</title>
		<link>http://joshcogan.com/wp/2013/03/ineffective-sorts/</link>
		<comments>http://joshcogan.com/wp/2013/03/ineffective-sorts/#comments</comments>
		<pubDate>Fri, 15 Mar 2013 16:34:45 +0000</pubDate>
		<dc:creator><![CDATA[Josh]]></dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[puzzles]]></category>

		<guid isPermaLink="false">http://joshcogan.com/wp/?p=60</guid>
		<description><![CDATA[So xkcd had a delightful comic a few days ago about Ineffective Sorts (and below), and it really struck a chord with me. I&#8217;ve often hear of people being asked to (pseudo)code quicksort, or something similar, during an interview. This<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://joshcogan.com/wp/2013/03/ineffective-sorts/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>So xkcd had a delightful comic a few days ago about <a href="http://xkcd.com/1185/" title="Ineffective Sorts" target="_blank">Ineffective Sorts (and below)</a>, and it really struck a chord with me. I&#8217;ve often hear of people being asked to (pseudo)code quicksort, or something similar, during an interview.  This really irks me.  If <em>on the job</em> a boss says, &#8220;Quickly Josh, we need a quicksort!!&#8221;, the last thing I&#8217;m gonna do is sit down and stare at a page of pseudo-code riddled with off-by-one errors.  Nor am I very likely to go back to the textbooks and look it up (a much safer option anyway).  Am I really being hired to reimplement STL or Boost libraries?  Because those guys look like they got this stuff pretty darn well.  And its super tested.</p>
<p>But you, my avid reader, protest &#8220;it&#8217;s a test to see how you think and reason&#8221;.  Okay that&#8217;s fair, but I, for the sake of discussion, claim quicksort and other standard algorithms aren&#8217;t the right way to test an applicant&#8217;s reasoning ability.  All applicants know quicksort could be asked, so we all look it up.  Now, when we are sitting down during an interview, we&#8217;re trying to <em>recall</em> all the intricacies of a mature algorithm.  Instead of reasoning through divide-and-conquer, I&#8217;m thinking &#8220;oh crap, now how to I pick the pivot to avoid those QS-attacks?&#8221;. I&#8217;m trying to remember how to get all the details right, when I should be iteratively addressing problems as they arrive.</p>
<p>Of course, if you&#8217;re hiring someone to squeeze out the next 1% of execution time in some DB-query, then absolutely he or she should know every damn intricacy of the standard algorithms. But for the rest of us, I think non-standard brain teasers or puzzles seem much better than reproducing a well-known mature algorithm.</p>
<p>IMHO =)</p>
<div style="width: 723px" class="wp-caption aligncenter"><img src="http://imgs.xkcd.com/comics/ineffective_sorts.png" width="713" height="667" alt="Only Randall Munroe can write Alt Text" class /><p class="wp-caption-text">XKCD always getting to the heart of the matter</p></div>
]]></content:encoded>
			<wfw:commentRss>http://joshcogan.com/wp/2013/03/ineffective-sorts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Printing TTree Branches</title>
		<link>http://joshcogan.com/wp/2013/03/printing-ttree-branches/</link>
		<comments>http://joshcogan.com/wp/2013/03/printing-ttree-branches/#comments</comments>
		<pubDate>Fri, 15 Mar 2013 06:22:15 +0000</pubDate>
		<dc:creator><![CDATA[Josh]]></dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ROOT]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://joshcogan.com/wp/?p=51</guid>
		<description><![CDATA[I use ROOT, you use ROOT, all of high energy physics uses ROOT.  How many times have you found yourself scrolling through that graphical TBrowser trying to find that one particular TBranch in the TTree?  Like someone sends you the<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://joshcogan.com/wp/2013/03/printing-ttree-branches/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>I use ROOT, you use ROOT, all of high energy physics uses ROOT.  How many times have you found yourself scrolling through that graphical TBrowser trying to find that one particular TBranch in the TTree?  Like someone sends you the Release17 version of the blah-di-blah centrally produced NTuple and you just want to know if it has &#8220;photon_crazyRecoMethod_px&#8221; in it.  This crap happens to me all the time.  So I decided to write a little Unix-inspired bash script to solve all my life&#8217;s woes; or well..just this one.</p>
<p>The trick here is to get ROOT to echo all the TBranch names to stdout (through TTree::Print()) so that we can use all our normal grep tricks to find that one name we are looking for.  Here is the script in its totality:</p>
<pre>
#!/bin/bash
#./thisScript treeName fileName
{ echo "TFile f(\"$2\", \"READ\")" ; echo "$1-&gt;Print()" ; echo ".q" ; } |\
 root -l -b |\
 grep -v "^[*]Tree" |\
 sed -n -r "s/^[^:]*:([^ ]+)\s+:.*/\1/p"
#EOF</pre>
<p>Bash curly braces always freak me out, because they can do several different jobs. In this particular case, we are moving the output of several commands to stdin of another process.  Remember in the above script, the $1 and $2 get expanded to the first and second arguments passed to the shell script.  Here is, effectively, how the curly braces and ROOT call are interacting&#8230;</p>
<pre>$&gt; root -l -b
##ROOT ASCII ART###
&gt;&gt;&gt;TFile f("$2", "READ")
&gt;&gt;&gt;$1-&gt;Print()
&gt;&gt;&gt;.q
$&gt;</pre>
<p>Which causes ROOT to vomit lots of text like this&#8230;</p>
<pre>
...
*Entries : 172375 : Total Size= 23966439 bytes File Size = 13664685 *
*Baskets : 917 : Basket Size= 32000 bytes Compression= 1.75 *
*............................................................................*
*Br 180 :mooreseg_phi : vector&lt;double&gt; *
*Entries : 172375 : Total Size= 23968281 bytes File Size = 8502181 *
*Baskets : 917 : Basket Size= 32000 bytes Compression= 2.82 *
*............................................................................*
*Br 181 :mooreseg_theta : vector&lt;double&gt; *
*Entries : 172375 : Total Size= 23970123 bytes File Size = 14002768 *
*Baskets : 917 : Basket Size= 32000 bytes Compression= 1.71 *
*............................................................................*
...</pre>
<p>Since all that goes to stdout we can just grep/sed our way through it until we get a pretty list of branch names.  Now we just have a plain text stream.</p>
<pre>
$>./treeprint.sh CollectionTree data12_jte.root
...
mooreseg_z
mooreseg_phi
mooreseg_theta
...
$>
</pre>
<p>Pretty simple huh? How about that for <a href="http://en.wikipedia.org/wiki/Worse_is_better" title=""worse is better"" target="_blank">&#8220;worse is better&#8221;</a>?</p>
]]></content:encoded>
			<wfw:commentRss>http://joshcogan.com/wp/2013/03/printing-ttree-branches/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://joshcogan.com/wp/2013/03/hello-world/</link>
		<comments>http://joshcogan.com/wp/2013/03/hello-world/#comments</comments>
		<pubDate>Fri, 15 Mar 2013 02:18:39 +0000</pubDate>
		<dc:creator><![CDATA[Josh]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://joshcogan.com/wp/?p=1</guid>
		<description><![CDATA[print &#8220;Hello, World!&#8221; I&#8217;m trying to throw up this site quickly, so there will almost certainly be bugs/spelling mistakes/swearing in posts as I go.  Be patient, and lemme know what I&#8217;ve screwed up so it can get fixed pronto. &#160;<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://joshcogan.com/wp/2013/03/hello-world/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>print &#8220;Hello, World!&#8221;</p>
<p>I&#8217;m trying to throw up this site quickly, so there will almost certainly be bugs/spelling mistakes/swearing in posts as I go.  Be patient, and lemme know what I&#8217;ve screwed up so it can get fixed pronto.</p>
<p>&nbsp;</p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://joshcogan.com/wp/2013/03/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
