6.6.1. Event based analysis

Note

The analysis software framework is designed to work with particles. In the default candidate-wise paradigm the analyst takes lists of particles, builds up candidates, loads analysis modules, and saves information (i.e. using the VariablesToNtuple tool) for each candidate. If you are new, it is probably best to start with this approach.

In some situations, it is useful to make cuts on, and write out event-wise information.

Warning

Please note that this use model and the documentation are under development.

Please ask questions at Belle II questions and report bugs using JIRA. Be sure to tag your questions and bug reports as “analysis” and “event based” to help us find them.

VariablesToEventBasedTree

The VariablesToNtuple tool writes out one entry in a TTree for every candidate. If you want one entry for every event, you should use the VariableToEventBasedTree module. Note that this still operates on a particle list so you will still need to build up a list of candidates in the normal way.

Here is an example of writing event-wise information for all pions in the event:

import basf2
from stdCharged import stdPi

mypath = basf2.Path()
stdPi('all', path=mypath)
mypath.add_module('VariablesToEventBasedTree',
                  particleList='pi+:all',
                  variables=['isSignal', 'mcErrors', 'p', 'E'],
                  event_variables=['nTracks', 'expNum', 'runNum', 'evtNum'])
VariablesToEventBasedTree

Calculate variables specified by the user for a given ParticleList and save them into a TTree. The Tree is event-based, meaning that the variables of each candidate for each event are saved in an array of a branch of the Tree.

Package

analysis

Library

libVariablesToEventBasedTree.so

Parameters
  • event_variables (list(str), default=[])

    List of variables (or collections) to save for each event. Variables are taken from Variable::Manager, and are identical to those available to e.g. ParticleSelector. Only event-based variables are allowed here.

  • fileName (str, default=’VariablesToEventBasedTree.root’)

    Name of ROOT file for output.

  • maxCandidates (unsigned int, default=100)

    The maximum number of candidates in the ParticleList per entry of the Tree.

  • particleList (str, default=’’)

    Name of particle list with reconstructed particles. An empty ParticleList is not supported. Use the VariablesToNtupleModule for this use-case

  • sampling (tuple(str, dict(int -> unsigned int)), default=(‘’, {}))

    Tuple of variable name and a map of integer values and inverse sampling rate. E.g. (signal, {1: 0, 0:10}) selects all signal events and every 10th background event. Variable must be event-based.

  • treeName (str, default=’tree’)

    Name of the NTuple in the saved file.

  • variables (list(str), default=[])

    List of variables (or collections) to save for each candidate. Variables are taken from Variable::Manager, and are identical to those available to e.g. ParticleSelector.

Event based selection

Instead of making cuts on properties of particle lists, it is possible to reject all events that fail an event based variable cut. Here is a simple example:

from modularAnalysis import applyEventCuts
from stdCharged import stdPi

stdPi('all')
applyEventCuts('R2EventLevel < 0.3')

This builds the list of all pions but only processes events where the event-level R2 passes the cut.

See also

B2A307 shows a full example.

modularAnalysis.applyEventCuts(cut, path)[source]

Removes events that do not pass the cut (given selection criteria).

Example

continuum events (in mc only) with more than 5 tracks

applyEventCuts("[nTracks > 5] and [isContinuumEvent], path=mypath)

Warning

You must use square braces [ and ] for conditional statements.

Parameters
  • cut (str) – Events that do not pass these selection criteria are skipped

  • path (basf2.Path) – modules are added to this path

Event based variables

Here is a list of event based variables on which you can make a cut using the above.

B0Mode

[Eventbased] It will return the decays mode of B0 particles

Group

MCParticle tag variables

Bbar0Mode

[Eventbased] It will return the decays mode of anti-B0 particles

Group

MCParticle tag variables

BminusMode

[Eventbased] It will return the decays mode of B- particles

Group

MCParticle tag variables

BplusMode

[Eventbased] It will return the decays mode of B+ particles

Group

MCParticle tag variables

Bs0Mode

[Eventbased] It will return the decays mode of B_s0 particles

Group

MCParticle tag variables

Bsbar0Mode

[Eventbased] It will return the decays mode of anti-B_s0 particles

Group

MCParticle tag variables

D0Mode

[Eventbased] It will return the decays mode of D0 particles

Group

MCParticle tag variables

Dbar0Mode

[Eventbased] It will return the decays mode of anti-D0 particles

Group

MCParticle tag variables

DminusMode

[Eventbased] It will return the decays mode of D- particles

Group

MCParticle tag variables

DplusMode

[Eventbased] It will return the decays mode of D+ particles

Group

MCParticle tag variables

DsminusMode

[Eventbased] It will return the decays mode of D_s- particles

Group

MCParticle tag variables

DsplusMode

[Eventbased] It will return the decays mode of D_s+ particles

Group

MCParticle tag variables

DstminusMode

[Eventbased] It will return the decays mode of D*- particles

Group

MCParticle tag variables

DstplusMode

[Eventbased] It will return the decays mode of D*+ particles

Group

MCParticle tag variables

Ecms

[Eventbased] Returns center-of-mass energy.

Group

Event

EventType

[Eventbased] EventType (0 MC, 1 Data)

Warning

Deprecated since version light-minos-2012.

Use isMC instead of this variable but keep in mind that the meaning of the outcome is reversed.

Group

Event

HighLevelTrigger

[Eventbased] 1.0 if event passes the HLT trigger, 0.0 if not

Group

Software Trigger

IPCov(i, j)

[Eventbased] Returns (i,j)-th element of the covariance matrix of the measured interaction point.

Group

Event

IPY

[Eventbased] Returns y coordinate of the measured interaction point.

Group

Event

IPZ

[Eventbased] Returns z coordinate of the measured interaction point.

Group

Event

L1FTDL(name)

[Eventbased] Returns the FTDL (Final Trigger Decision Logic, before prescale) status of the trigger bit with the given name.

Group

L1 Trigger

L1FTDLBit(i)

[Eventbased] Returns the FTDL (Final Trigger Decision Logic, before prescale) status of i-th trigger bit.

Group

L1 Trigger

L1Input(name)

[Eventbased] Returns the input bit status of the trigger bit with the given name.

Group

L1 Trigger

L1InputBit(i)

[Eventbased] Returns the input bit status of the i-th input trigger bit.

Group

L1 Trigger

L1PSNM(name)

[Eventbased] Returns the PSNM (Prescale And Mask, after prescale) status of the trigger bit with the given name.

Group

L1 Trigger

L1PSNMBit(i)

[Eventbased] Returns the PSNM (Prescale And Mask, after prescale) status of i-th trigger bit.

Group

L1 Trigger

L1PSNMBitPrescale(i)

[Eventbased] Returns the PSNM (prescale and mask) prescale of i-th trigger bit.

Group

L1 Trigger

L1Prescale(name)

[Eventbased] Returns the PSNM (prescale and mask) prescale of the trigger bit with the given name.

Group

L1 Trigger

L1TimeQuality

[Eventbased] Returns ETimingQuality time quality.

Group

L1 Trigger

L1TimeType

[Eventbased] Returns ETimingType time type.

Group

L1 Trigger

L1Trigger

[Eventbased] Returns 1 if at least one PSNM L1 trigger bit is true.

Group

L1 Trigger

R2EventLevel

[Eventbased] Event-Level Reduced Fox-Wolfram moment R2.

Note

Deprecated since version release-05-00-00.

The same value can be calculated with the Event Shape module, see foxWolframR.

Group

Continuum Suppression

SoftwareTriggerPrescaling(triggerIdentifier)

[Eventbased] return the prescaling for the specific software trigger identifier. Please note, this prescaling is taken from the currently setup database. It only corresponds to the correct HLT prescale if you are using the online database!If the trigger identifier is not found, returns NaN.

Group

Software Trigger

SoftwareTriggerResultNonPrescaled(triggerIdentifier)

[Eventbased] [Expert] returns the SoftwareTriggerCutResult, if this trigger would not be prescaled.Please note, this is not the final HLT decision! It is defined as reject (-1), accept (1), or noResult (0). Note that the meanings of these change depending if using trigger or the skim stage, hence expert.If the trigger identifier is not found, returns NaN.

Group

Software Trigger

TauminusMode

[Eventbased] It will return the decays mode of tau- particles

Group

MCParticle tag variables

TauplusMode

[Eventbased] It will return the decays mode of tau+ particles

Group

MCParticle tag variables

beamE

[Eventbased] Returns total beam energy in the laboratory frame.

Group

Event

beamPx

[Eventbased] Returns x component of total beam momentum in the laboratory frame.

Group

Event

beamPy

[Eventbased] Returns y component of total beam momentum in the laboratory frame.

Group

Event

beamPz

[Eventbased] Returns z component of total beam momentum in the laboratory frame.

Group

Event

countInList(particleList, cut='')

[Eventbased] Returns number of particle which pass given in cut in the specified particle list. Useful for creating statistics about the number of particles in a list. E.g. countInList(e+, isSignal == 1) returns the number of correctly reconstructed electrons in the event. The variable is event-based and does not need a valid particle pointer as input.

Group

MetaFunctions

currentROEIsInList(particleList)

[Eventbased] Returns 1 the associated particle of the current ROE is contained in the given list or its charge-conjugated.Useful to restrict the for_each loop over ROEs to ROEs of a certain ParticleList.

Group

Rest Of Event

eventCached(variable)

[Eventbased] Returns value of event-based variable and caches this value in the EventExtraInfo. The result of second call to this variable in the same event will be provided from the cache. It is recommended to use this variable in order to declare custom aliases as event-based. This is necessary if using the eventwise mode of variablesToNtuple).

Group

MetaFunctions

eventExtraInfo(name)

[Eventbased] Returns extra info stored under the given name in the event extra info. The extraInfo has to be set first by another module like MVAExpert in event mode. If nothing is set under this name, NaN is returned.

Group

MetaFunctions

eventRandom

[Eventbased] Returns a random number between 0 and 1 for this event. Can be used, e.g. for applying an event prescale.

Group

Miscellaneous

eventTimeSeconds

[Eventbased] Time of the event in seconds (truncated down) since 1970/1/1 (Unix epoch).

Group

Event

evtNum

[Eventbased] Returns the event number.

Group

Event

expNum

[Eventbased] Returns the experiment number.

Group

Event

genIPY

[Eventbased] Returns y coordinate of the interaction point used for the underlying MC generation. Returns NaN for data.

Group

Event

genIPZ

[Eventbased] Returns z coordinate of the interaction point used for the underlying MC generation. Returns NaN for data.

Group

Event

generatorEventWeight

[Eventbased] Returns the event weight produced by the event generator

Group

MC matching and MC truth

hasExtraCDCHitsInLayer(i)

[Eventbased] Returns 1 if a non-assigned hit exists in the specified CDC layer

Group

Tracking

hasExtraCDCHitsInSuperLayer(i)

[Eventbased] Returns 1 if a non-assigned hit exists in the specified CDC SuperLayer

Group

Tracking

hasRecentInjection

[Eventbased] Returns 1 if an injection happened recently, 0 otherwise.

Group

Event

injectionInHER

[Eventbased] Returns 1 if injection was in HER, 0 otherwise.

Group

Event

isChargedBEvent

[Eventbased] Returns 1.0 if event contains a charged B-meson on generator level.

Group

Event

isContinuumEvent

[Eventbased] Returns 1.0 if event doesn’t contain a \(\Upsilon(4S)\) particle on generator level, 0.0 otherwise.

Group

Event

isMC

[Eventbased] Returns 1 if current basf2 process is running over simulated (Monte-Carlo) dataset and 0 in case of real experimental data.

Group

Event

isMajorityInRestOfEventFromB0

[Eventbased][Expert] Checks if the majority of the tracks in the current RestOfEvent are from a B0.

Group

Flavor Tagger Expert Variables

isMajorityInRestOfEventFromB0bar

[Eventbased][Expert] Check if the majority of the tracks in the current RestOfEvent are from a anti-B0.

Group

Flavor Tagger Expert Variables

isNotContinuumEvent

[Eventbased] Returns 1.0 if event does contain an \(\Upsilon(4S)\) particle on generator level and therefore is not a continuum event, 0.0 otherwise.

Group

Event

isPoissonTriggerInInjectionVeto

[Eventbased] Returns 1 if the poisson random trigger is within the injection veto window.

Group

L1 Trigger

isUnmixedBEvent

[Eventbased] Returns 1.0 if the event contains opposite flavor neutral B-mesons on generator level, 0.0 in case of same flavor B-mesons and NaN if the event has no generated neutral B.

Group

Event

nCleanedECLClusters(cut)

[Eventbased] Returns the number of clean Clusters in the event Clean clusters are defined by the clusters which pass the given cut assuming a photon hypothesis.

Group

MetaFunctions

nCleanedTracks(cut)

[Eventbased] Returns the number of clean Tracks in the event Clean tracks are defined by the tracks which pass the given cut assuming a pion hypothesis.

Group

MetaFunctions

nExtraCDCHits

[Eventbased] The number of CDC hits in the event not assigned to any track

Group

Tracking

nExtraCDCHitsPostCleaning

[Eventbased] The number of CDC hits in the event not assigned to any track nor very likely beam background (i.e. hits that survive a cleanup selection)

Group

Tracking

nExtraCDCSegments

[Eventbased] The number of CDC segments not assigned to any track

Group

Tracking

nKLMClusters

[Eventbased] Returns number of KLM clusters in the event.

Group

Event

nMCParticles

[Eventbased] Returns number of MCParticles in the event.

Group

Event

nParticlesInList(particleListName)

[Eventbased] Returns number of particles in the given particle List.

Group

MetaFunctions

particleRelatedToCurrentROE(var)

[Eventbased] Returns variable applied to the particle which is related to the current RestOfEvent objectOne can use this variable only in a for_each loop over the RestOfEvent StoreArray.

Group

Rest Of Event

passesEventCut(cut)

[Eventbased] Returns 1 if event passes the cut otherwise 0. Useful if you want to select events passing a cut without looping into particles, such as for skimming.

Group

MetaFunctions

runNum

[Eventbased] Returns the run number.

Group

Event

tauMinusMCMode

[Eventbased] Decay ID for the negative tau lepton in a tau pair generated event.

Group

Generated tau decay information

tauMinusMCProng

[Eventbased] Prong for the negative tau lepton in a tau pair generated event.

Group

Generated tau decay information

tauPlusMCMode

[Eventbased] Decay ID for the positive tau lepton in a tau pair generated event.

Group

Generated tau decay information

tauPlusMCProng

[Eventbased] Prong for the positive tau lepton in a tau pair generated event.

Group

Generated tau decay information

timeSinceLastInjectionClockTicks

[Eventbased] Time since the last injected bunch passed by the detector in micro seconds.

Group

Event

timeSinceLastInjectionMicroSeconds

[Eventbased] Time since the last injected bunch passed by the detector in micro seconds.

Group

Event

timeSincePrevTriggerClockTicks

[Eventbased] Time since the previous trigger in clock ticks (127MHz=RF/4 clock).

Group

Event

timeSincePrevTriggerMicroSeconds

[Eventbased] Time since the previous trigger in micro seconds.

Group

Event

trackFindingFailureFlag

[Eventbased] A flag set by the tracking if there is reason to assume there was a track in the event missed by the tracking, or the track finding was (partly) aborted for this event.

Group

Tracking