Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 13 TeV histogram analysers #1

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions HistogramAnalyser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__/
*.csv
*~
*.pdf
258,217 changes: 258,217 additions & 0 deletions HistogramAnalyser/13TeV_TransData.csv

Large diffs are not rendered by default.

223 changes: 223 additions & 0 deletions HistogramAnalyser/13TeV_crossfilter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Crossfilter for ATLAS Outreach Prototype</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="dc.css"/>
</head>
<style>
.dc-chart g.row text {
fill: black;
font-size: 120%;
}
table { border-collapse:collapse; }
table thead th { border-bottom: 1px solid #000; }
/* #hist9 tr:nth-child(odd) {background-color: #CCCCCC;}
#hist9 tr:nth-child(1) {background-color: #FFFFFF;}
*/
/* #hist9 tr:nth-child(2) {background-color: #1C5EA8;}
#hist9 tr:nth-child(3) {background-color: #F66A00;}
#hist9 tr:nth-child(4) {background-color: #2A9000;}
#hist9 tr:nth-child(5) {background-color: #C31318;}
*/

#hist9 {
font-size: 100%;
padding-top: 20px;
padding-left: 20px;
}
</style>

<body>
<div style="width:1050px">
<table style="width:100%">
<tr style="height: 50px">
<td valign="bottom">Channel</td>
<td valign="bottom">Reconstructed Dilepton Mass [GeV]</td>
<td valign="bottom">Number of Jets</td>
</tr>
<tr>
<td><div id="hist1" title="Channel: The leptonic decay channels are shown here: dielectron (ee), dimuon (mm) and electron-muon (em)"></div></td>
<td><div id="hist2" title="Reconstructed Dilepton Mass (M(ll)): the mass reconstructed from the two leptons in the final state."></div></td>
<td><div id="hist3" title="Number of Jets (N(Jets)): number of jets in the event."></div></td>
</tr>
<tr style="height: 50px">
<td valign="bottom">Are Jets b-tagged?</td>
<td valign="bottom">Total Lepton Transverse Momentum [GeV]</td>
<td valign="bottom">Missing Transverse Momentum (MET) [GeV]</td>
</tr>
<tr>
<td><div id="hist4" title="Are Jets b-tagged? (BTag) : jets originating from b-quarks are identified and labelled, or tagged, using so-called b-tagging algorithms."></div></td>
<td><div id="hist5" title="Total Lepton Transverse Momentum (PT(ll)): this is the vectorial sum of the transverse momenta of the observed charged leptons."></div></td>
<td><div id="hist6" title="Missing Transverse Momentum (MET) : MET is used to infer the presence of non-detectable particles such as the neutrino."></div></td>
</tr>
<tr style="height: 50px">
<td valign="bottom">Opening Angle Between MET and Leptons [phi]</td>
<td valign="bottom">Opening Angle Between Leptons [phi]</td>
<td valign="bottom">Expected Number of Events for 10/fb</td>
</tr>
<tr>
<td><div id="hist7" title="Opening Angle Between MET and Leptons (DeltaPhi(MET,ll)): This is the opening angle, measured in phi (&phi;), between the missing transverse momentum (MET) and the two leptons."></div></td>
<td><div id="hist8" title="Opening Angle Between Leptons (DeltaPhi(l,l)): this is the angle, measured in phi (&phi;), between the two leptons. The azimuthal angle &phi; is measured from the x-axis, around the beam."></div></td>
<td><div id="hist9" title="Number of Expected Events: the number of events expected to be detected, reconstructed and recorded by ATLAS for 10 inverse femtobarn of data. Numbers taken from simulation. The significance of the H &rarr; WW events quantifies how 'significant' the Higgs sample is with respect to the background. (Number of H &rarr; WW events)/Number of background events. The larger the significance value is, the better job you have done extracting the Higgs signal."></div></td>

</table>
</div>

<script charset="utf-8" type="text/javascript" src="d3.js"></script>
<script charset="utf-8" type="text/javascript" src="crossfilter.js"></script>
<script charset="utf-8" type="text/javascript" src="dc.js"></script>
<script charset="utf-8" type="text/javascript">

d3.csv("13TeV_outreach.csv", function(error, events) {

events.forEach(function(x) {
x.weight = +x.weight;
});


function add_by_channel(p, v) {
p[v.type] = (p[v.type] || 0) + v.weight;
return p;
}

function remove_by_channel(p, v) {
p[v.type] = (p[v.type] || 0) - v.weight;
return p;
}

function initial(p, v) {
return {};
}

var colorScale = d3.scale.ordinal().range(["#1C5EA8","#F66A00","#2A9000","#C31318"]);
var ndx = crossfilter(events),
njetDimension = ndx.dimension(function(d) {return +d.NJets;}),
typeDimension = ndx.dimension(function(d) {return +d.type;}),
METDimension = ndx.dimension(function(d) {return +Math.floor(d.MET*0.1)*10;}),
DeltaPhiMETLLDimension = ndx.dimension(function(d) {return +Math.floor(Math.abs(d.METLLDeltaPhi*0.31813*18))*10;}),
SumLepPtDimension = ndx.dimension(function(d) {return +Math.floor(d.SumLepPt*0.1)*10;}),
ZWindowDimension = ndx.dimension(function(d) {return +Math.floor(d.Mll*0.2)*5;}),
ChannelDimension = ndx.dimension(function(d) {return +d.Channel;}),
DeltaPhiDimension = ndx.dimension(function(d) {return +Math.floor(d.LepDeltaPhi*0.31813*18)*10;})
BTagDimension = ndx.dimension(function(d) {return +d.BTags})
NJetGroup = njetDimension.group().reduce(add_by_channel,remove_by_channel, initial),
DeltaPhiMETLLGroup = DeltaPhiMETLLDimension.group().reduce(add_by_channel,remove_by_channel, initial),
SumLepPtGroup = SumLepPtDimension.group().reduce(add_by_channel,remove_by_channel, initial),
ZWindowGroup = ZWindowDimension.group().reduce(add_by_channel,remove_by_channel, initial),
BTagGroup = BTagDimension.group().reduce(add_by_channel,remove_by_channel, initial),
compGroup = typeDimension.group().reduceSum(function(d) {return +d.weight;}),
mcstatGroup = typeDimension.group().reduceCount(),
ChannelGroup = ChannelDimension.group().reduce(add_by_channel,remove_by_channel, initial),
METGroup = METDimension.group().reduce(add_by_channel,remove_by_channel, initial),
DeltaPhiGroup = DeltaPhiDimension.group().reduce(add_by_channel,remove_by_channel, initial),
SignificanceGroup = typeDimension.groupAll().reduce(
function (p, v) {
if (v.type == 1) p.sig += v.weight;
else p.bkg += v.weight;
return p;
},
function (p, v) {
if (v.type == 1) p.sig -= v.weight;
else p.bkg -= v.weight;
return p;
},
function () { return {sig:0, bkg:0}; }
);

function sel_stack(i) {
return function(d) {
return d.value[i];
};
}

function type(i){
if (i == "1") return "H \u2192 WW";
if (i == "2") return "WW";
if (i == "3") return "ttbar";
if (i == "4") return "Z";
return "default"
}

function make_barchart( location, domain, label, dimension, group ){
var chart = dc.barChart(location)
chart.width(350)
.height(250)
.x(d3.scale.linear().domain(domain))
.margins({left: 60, top: 10, right: 10, bottom: 35})
.brushOn(true)
.elasticY(true)
.xAxisLabel(label)
.yAxisLabel("Events")
// .yAxisPadding("5%")
.clipPadding(10)
.dimension(dimension)
.group(group, "H \u2192 WW", sel_stack('1'))
.stack(group, "WW", sel_stack('2'))
.stack(group, "ttbar", sel_stack('3'))
.stack(group, "Z", sel_stack('4'))
.on('renderlet', function (chart) {
chart.selectAll('.x-axis-label').attr('transform', 'translate(345,238)').attr('text-anchor', 'end');
chart.selectAll('.y-axis-label').attr('transform', 'rotate(-90), translate(-30,12)');
});
return chart
}

var njetChart = make_barchart("#hist3", [-0.5,10], "N(Jets)", njetDimension, NJetGroup)
njetChart.centerBar(true)
njetChart.legend(dc.legend().x(270).y(10).itemHeight(20).gap(5))


var channelChart = make_barchart("#hist1", [0,3], "Channel", ChannelDimension, ChannelGroup)
channelChart.xAxis().tickFormat(function(d){if(d == 0.5){return "ee"}; if(d == 1.5){return "mm"};if(d == 2.5){return "em";}});

var ZWindowChart = make_barchart("#hist2", [0,104.9], "M(ll) [GeV]", ZWindowDimension, ZWindowGroup)
ZWindowChart.xUnits(dc.units.fp.precision(5));

var METChart = make_barchart("#hist6", [0,200], "MET [GeV]", METDimension, METGroup)
METChart.xUnits(dc.units.fp.precision(10));

var DeltaPhiMETLLChart = make_barchart("#hist7", [0, 180],"DeltaPhi(MET,ll) [deg]" ,DeltaPhiMETLLDimension, DeltaPhiMETLLGroup)
DeltaPhiMETLLChart.xUnits(dc.units.fp.precision(10));

var deltaphiChart = make_barchart("#hist8", [0,180], "DeltaPhi(l,l) [deg]", DeltaPhiDimension, DeltaPhiGroup)
deltaphiChart.xUnits(dc.units.fp.precision(10));

var sumlepptChart = make_barchart("#hist5", [0,200], "PT(ll) [GeV]", SumLepPtDimension, SumLepPtGroup)
sumlepptChart.xUnits(dc.units.fp.precision(10));

var BTagChart = make_barchart("#hist4", [0,3], "BTag", BTagDimension, BTagGroup)
BTagChart.xAxis().tickFormat(function(d){if(d == 0.5){return "no"}; if(d == 1.5){return "yes"}});
BTagChart.xAxis().tickValues([0, 0.5,1,1.5,2]);

var mcCompChart = dc.rowChart("#hist9")
mcCompChart.width(350).height(250)
.margins({left: 5, top: 10, right: 10, bottom: 57})
.x(d3.scale.log().domain([0,1000]))
.title("Process")
.dimension(typeDimension)
.group(compGroup)
.label(function(d) {
val = type(d.key) + " (" + d.value.toFixed(0) + ")"
return (d.key != 1) ? val : val + " Significance: " + significance(SignificanceGroup.value()).toFixed(3)
})

.elasticX(true)
.colors(colorScale)
.on('renderlet', function (chart) {
chart.selectAll('g.axis text').attr('transform', 'translate(-10,10) rotate(315)');
});

var significance = function(d) {
return d.sig/Math.sqrt(d.bkg);
};


dc.renderAll();

});

</script>

</body>
</html>
Loading