![]() |
FairShip
|
Classes | |
| class | EventHistogram |
Functions | |
| int | make_event_key (int run, int event) |
| _poisson1_cdf () | |
| np.ndarray | replica_weights (int key, int n_replicas) |
| _buffer (array, n) | |
| _cells (h) | |
| _sumw2 (h) | |
| _inner2 (h) | |
| int | generated_events (tfile) |
Variables | |
| tuple | _MASK64 = (1 << 64) - 1 |
| _CDF = _poisson1_cdf() | |
Histograms with event-level uncertainties for samples with split branches.
All branches of an event (split kaon/pion clones, their decay products and
secondaries) share the history of the primary interaction, so they are not
independent entries and sqrt(sum w^2) underestimates the error, by a large
factor when many clones of one decay land in the same bin. The independent unit
is the event: sum the weights of an event per bin first,
t_eb = sum_{i in e, x_i in b} w_i,
and treat the per-event sums as the observations. With N generated events,
including the ones that left no entry,
mu_b = sum_e t_eb / N, sigma_b^2 = (sum_e t_eb^2 / N - mu_b^2) / (N - 1).
This is the numpy counterpart of the C++ class EventHistogram (libShipData).
Both write the same ROOT objects, which hadd merges correctly, and give the same
bootstrap replicas for the same event keys::
h = EventHistogram("p_mu", np.geomspace(5, 400, 21), covariance=True)
for event in tree:
h.fill(momenta, weights)
h.end_event(make_event_key(run, event_id))
h.add_empty_events(n_generated - h.n_events)
h.values(), h.errors(), h.n_eff()
|
protected |
Definition at line 73 of file event_histogram.py.
|
protected |
Writable view of the bin contents of a ROOT histogram, flows included.
Definition at line 78 of file event_histogram.py.
|
protected |
In-range contents of a TH2D as a writable [x bin, y bin] view.
Definition at line 87 of file event_histogram.py.
|
protected |
Poisson(1) distribution function, accumulated as in the C++ code. k = 0..19, so searchsorted caps the weight at 20 like the C++ inversion.
Definition at line 44 of file event_histogram.py.
|
protected |
Definition at line 83 of file event_histogram.py.
| int event_histogram.generated_events | ( | tfile | ) |
Number of generated events of a FairShip output file, from its FileSummary. FairShip only writes events with activity, so the number of entries of the tree is not the normalisation.
Definition at line 308 of file event_histogram.py.
| int event_histogram.make_event_key | ( | int | run, |
| int | event ) |
Key of an event for the bootstrap replicas, as EventHistogram::MakeEventKey.
Definition at line 39 of file event_histogram.py.
| np.ndarray event_histogram.replica_weights | ( | int | key, |
| int | n_replicas ) |
Poisson(1) weights of one event for replicas 0..n-1 (EventHistogram::ReplicaWeight).
Definition at line 60 of file event_histogram.py.
|
protected |
Definition at line 57 of file event_histogram.py.
|
protected |
Definition at line 36 of file event_histogram.py.