Skip to content

Add cutflow reports

Pieter David requested to merge piedavid/bamboo:cutflowreport into master

Requested by @aguzel ; this can also be useful more generally, and for debugging.

With e.g.

from bamboo.plots import CutFlowReport
plots.append(CutFlowReport("cfrOSllL2b", osll2bSel_noCand.values()))

a counter (sum of weights, and number of events) is added to every selection, from "all events" to those specified. They are stored as histograms with a single bin (I tried Report and Stats, but they are too limited: Report cannot deal with weights, and TStatistic cannot be saved with a name; using a histogram is more pragmatic than rewriting the latter and making sure the dictionary is there for hadd).

Currently, the default postProcess action is to print the values of the counters for all samples, but this should be easy to customise (for an example of how to retrieve the values: see the Entry and CutFlowReport print methods, and bamboo.analysisutils.printCutFlowReports), output for a test with two samples with one file:

INFO:bamboo.analysisutils:Cutflow report cfrOSllL2b for sample SingleMuon_ver1_2016B1
INFO:bamboo.plots:Selection none: N=1886.0, SumW=1886.0
INFO:bamboo.plots:Selection trig: N=27.0, SumW=27.0
INFO:bamboo.plots:Selection metfilters: N=26.0, SumW=26.0
INFO:bamboo.plots:Selection goodlumis: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL_MuMu: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL2j_MuMu: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL2b_MuMu: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL_MuEl: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL2j_MuEl: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL2b_MuEl: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL_ElMu: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL2j_ElMu: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL2b_ElMu: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL_ElEl: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL2j_ElEl: N=0.0, SumW=0.0
INFO:bamboo.plots:Selection OSllL2b_ElEl: N=0.0, SumW=0.0
INFO:bamboo.analysisutils:Cutflow report cfrOSllL2b for sample TTTo2L2Nu_2016
INFO:bamboo.analysisutils:Sum of event weights for processed files: 1.534400e+05
WARNING:bamboo.plots:Could not find object cfrOSllL2b_goodlumis
INFO:bamboo.plots:Selection none: N=153440.0, SumW=153440.0
INFO:bamboo.plots:Selection trig: N=103418.0, SumW=103569.345885141
INFO:bamboo.plots:Selection metfilters: N=103298.0, SumW=103449.20355318877
INFO:bamboo.plots:Selection OSllL_MuMu: N=10825.0, SumW=10824.330044567294
INFO:bamboo.plots:Selection OSllL2j_MuMu: N=8448.0, SumW=8447.645288823114
INFO:bamboo.plots:Selection OSllL2b_MuMu: N=5424.0, SumW=5385.893022578501
INFO:bamboo.plots:Selection OSllL_MuEl: N=10332.0, SumW=10366.72630598204
INFO:bamboo.plots:Selection OSllL2j_MuEl: N=8051.0, SumW=8075.048919987748
INFO:bamboo.plots:Selection OSllL2b_MuEl: N=5078.0, SumW=5093.207397030201
INFO:bamboo.plots:Selection OSllL_ElMu: N=10252.0, SumW=10327.40856805403
INFO:bamboo.plots:Selection OSllL2j_ElMu: N=8026.0, SumW=8069.434475484479
INFO:bamboo.plots:Selection OSllL2b_ElMu: N=5091.0, SumW=5112.643522464845
INFO:bamboo.plots:Selection OSllL_ElEl: N=9375.0, SumW=9425.878806457447
INFO:bamboo.plots:Selection OSllL2j_ElEl: N=7386.0, SumW=7408.762902971765
INFO:bamboo.plots:Selection OSllL2b_ElEl: N=4699.0, SumW=4707.2662535134
Edited by Pieter David

Merge request reports