Plotting two plots on top of each other, and the title changed. The output png file will have "nTracks" in it.

f = file ("C:\Users\Gordon\Downloads\dataJZ2W-MCQCDStudyResults.root");
h1 = f.Get("nTrackRaw");
h2 = f.Get("nTrackGood");

Here, showing off the ability to download the root file from a most recent build on a teamcity server. Also, note comments. Further, there is a default file preloaded which turns off stats boxes, does the normalization properly, and makes the lines thicker:

// test

f = teamcity ("");
h1 = f.Get("EMFL05/JetPtFirstJetAll");
h2 = f.Get("EMFL05/JetPtSecondJetAll");
[h1,h2].plot().title("Jet pT");

Legends are easily added. Here is an example that shows off configuring the string for the legend or just using the search string. The "key" in the call to Legend is a search string. If the plot title contains it, then it is used as the legend.

// Test this out

f = teamcity("");

Legend(First => 1);
Legend(Second => { Color => 2, Title => "Second Jet dude"}); 

h1 = f.Get("EMFL05/JetPtFirstJetAll");
h2 = f.Get("EMFL05/JetPtSecondJetAll");

[h1,h2].plot().title("Jet Pt");

It is possible to load in several histograms and sum them together. For example:

f = teamcity("");

mc = {
	JZ1 => f.Get("dataJZ1W/EF_J15/ProbeJet/JetPtProbe"),
	JZ2 => f.Get("dataJZ2W/EF_J15/ProbeJet/JetPtProbe"),
	JZ3 => f.Get("dataJZ3W/EF_J15/ProbeJet/JetPtProbe"),
	JZ4 => f.Get("dataJZ4W/EF_J15/ProbeJet/JetPtProbe")


For loops, and mapping's are now possible as well. The map construct will take a list of dictionaries as input, and run the block of statements for each dictionary. The result (the last statement that returns an expression) will be the result of that iteration. The map returns the list. The for loop is the same, though it will return only the last item in the iteration.
// Calc the quark pass rate and the gluon pass rate for a cut as a function of
// jet pT.

f = teamcity("");

plotformats = ["pdf", "png"];

// The cuts we want to run over
cut1 = { trig => "EMFL02", cutval => "EMF < 0.2" };
cut2 = { trig => "EMFL0059", cutval => "EMF < 0.059" };
cut3 = { trig => "TRKLE0", cutval => "nTrack = 0" };
for ([cut2, cut3]) {

	// Sum together the first and second jets
	j = map([{ty => "First"}, {ty => "Second"}])
			All => f.Get("{trig}/JetPt{ty}JetAll"),
			Gluon => f.Get("{trig}/JetPt{ty}JetGluon"),
			Quark => f.Get("{trig}/JetPt{ty}JetQuark"),
			GluonSelected => f.Get("{trig}/JetPt{ty}JetGluonSelected"),
			QuarkSelected => f.Get("{trig}/JetPt{ty}JetQuarkSelected")

	// Calculate the rate of the sum

	jGluonRate = j["GluonSelected"]/j["Gluon"];
	jQuarkRate = j["QuarkSelected"]/j["Quark"];

	// The legend...

	Legend("Quark" => 1);
	Legend("Gluon" => 2);

	// And the plot itself.

	[jQuarkRate, jGluonRate]
		.yaxis("Fraction of jets passing {cutval}")
		.title("Pass Rate {cutval}")

Last edited Jan 16, 2014 at 8:19 AM by gwatts, version 7