6.5.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.

Ecms

[Eventbased] CMS energy

Group

Event

EventType

[Eventbased] EventType (0 MC, 1 Data)

Group

Event

HighLevelTrigger

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

Group

Software Trigger

IPCov(i, j)

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

Group

Event

IPY

[Eventbased] y coordinate of the measured interaction point

Group

Event

IPZ

[Eventbased] 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

L1TimType

[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

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!

Group

Software Trigger

SoftwareTriggerResult(triggerIdentifier)

[Eventbased] [Expert] returns the SoftwareTriggerCutResult, 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.

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.

Group

Software Trigger

aplanarity

[Eventbased] Event aplanarity, defined as the 3/2 of the third sphericity eigenvalue.

Group

EventShape

backwardHemisphereEnergy

[Eventbased] Total energy the particles flying in the direction opposite to the thrust axis.

Group

EventShape

backwardHemisphereMass

[Eventbased] Invariant mass of the particles flying in the direction opposite to the thrust axis.

Group

EventShape

backwardHemisphereMomentum

[Eventbased] Total momentum the particles flying in the direction opposite to the thrust axis.

Group

EventShape

backwardHemisphereX

[Eventbased] X component of the total momentum of the particles flying in the direciton opposite to the thrust axis

Group

EventShape

backwardHemisphereY

[Eventbased] Y component of the total momentum of the particles flying in the direction opposite to the thrust axis

Group

EventShape

backwardHemisphereZ

[Eventbased] Z component of the total momentum of the particles flying in the direction opposite to the thrust axis

Group

EventShape

beamE

[Eventbased] Beam energy (lab)

Group

Event

beamPx

[Eventbased] Beam momentum Px (lab)

Group

Event

beamPy

[Eventbased] Beam momentum Py (lab)

Group

Event

beamPz

[Eventbased] Beam momentum Pz (lab)

Group

Event

belleECLEnergy

[Eventbased] legacy total energy in ECL in the event as used in Belle 1 analyses. For Belle II consider totalEnergyOfParticlesInList(gamma:all) instead

Group

Event

cleoCone(i, axisName)

[Eventbased] i-th order cleoCone, calculated respect to the axis axisName. The order can go up to 9th., the axisName can be either ‘thrust’ or ‘collision’

Group

EventShape

cleoConeThrust0

[Eventbased] 0th Cleo cone calculated respect to the thrust axis.

Group

EventShape

cleoConeThrust1

[Eventbased] 1st Cleo cone calculated respect to the thrust axis.

Group

EventShape

cleoConeThrust2

[Eventbased] 2nd Cleo cone calculated respect to the thrust axis.

Group

EventShape

cleoConeThrust3

[Eventbased] 3rd Cleo cone calculated respect to the thrust axis.

Group

EventShape

cleoConeThrust4

[Eventbased] 4th Cleo cone calculated respect to the thrust axis.

Group

EventShape

cleoConeThrust5

[Eventbased] 5th Cleo cone calculated respect to the thrust axis.

Group

EventShape

cleoConeThrust6

[Eventbased] 6th Cleo cone calculated respect to the thrust axis.

Group

EventShape

cleoConeThrust7

[Eventbased] 7th Cleo cone calculated respect to the thrust axis.

Group

EventShape

cleoConeThrust8

[Eventbased] 8th Cleo cone calculated respect to the thrust axis.

Group

EventShape

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

date
[Eventbased] Returns the date when the event was recorded, a number of the form YYYYMMDD (in UTC).

See also eventYear, provided for convenience. For more precise eventTime, see eventTimeSeconds and eventTimeSecondsFractionRemainder.

Group

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

eventT0

[Eventbased][Calibration] The Event t0, measured in ns, is the time of the event relative to the trigger time. The event time can be measured by several sub-detectors including the CDC, ECL, and TOP. This Event t0 variable is the final combined value of all the event time measurements. (Currently only the CDC and ECL are used in this combination.)

Group

Event (cDST only)

eventTimeSeconds

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

Group

Event

eventTimeSecondsFractionRemainder

[Eventbased] Remainder of the event time in fractions of a second. Use eventTimeSeconds + eventTimeSecondsFractionRemainder to get the total event time in seconds.

Group

Event

evtNum

[Eventbased] event number

Group

Event

expNum

[Eventbased] experiment number

Group

Event

forwardHemisphereEnergy

[Eventbased] Total energy the particles flying in the same direction of the thrust axis.

Group

EventShape

forwardHemisphereMass

[Eventbased] Invariant mass of the particles flying in the same direction of the thrust axis.

Group

EventShape

forwardHemisphereMomentum

[Eventbased] Total momentum the particles flying in the same direction of the thrust axis.

Group

EventShape

forwardHemisphereX

[Eventbased] X component of the total momentum of the particles flying in the same direction of the thrust axis

Group

EventShape

forwardHemisphereY

[Eventbased] Y component of the total momentum of the particles flying in the same direction of the thrust axis

Group

EventShape

forwardHemisphereZ

[Eventbased] Z component of the total momentum of the particles flying in the same direction of the thrust axis

Group

EventShape

foxWolframH(i)

[Eventbased] i-th order Fox Wolfram moment. The order can go up to 8th.

Group

EventShape

foxWolframR(i)

[Eventbased] ratio of the i-th to the 0-th order Fox Wolfram moments. The order can go up to 8th.

Group

EventShape

foxWolframR1

[Eventbased] ratio of the 1-st to the 0-th order Fox Wolfram moments. This is just an alias of foxWolframR(1) defined for the user’s covenience.

Group

EventShape

foxWolframR2

[Eventbased] ratio of the 2-nd to the 0-th order Fox Wolfram moments. This is just an alias of foxWolframR(2) defined for the user’s covenience.

Group

EventShape

foxWolframR3

[Eventbased] ratio of the 3-rd to the 0-th order Fox Wolfram moments. This is just an alias of foxWolframR(3) defined for the user’s covenience.

Group

EventShape

foxWolframR4

[Eventbased] ratio of the 4-th to the 0-th order Fox Wolfram moments. This is just an alias of foxWolframR(4) defined for the user’s covenience.

Group

EventShape

generatorEventWeight

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

Group

MC matching and MC truth

harmonicMoment(i, axisName)

[Eventbased] i-th order harmonic moment, calculated respect to the axis axisName. The order can go up to 8th., the axisName can be either ‘thrust’ or ‘collision’

Group

EventShape

harmonicMomentThrust0

[Eventbased] Harmonic moment of the 0th order calculated respect to the thrust axis.

Group

EventShape

harmonicMomentThrust1

[Eventbased] Harmonic moment of the 1st order calculated respect to the thrust axis.

Group

EventShape

harmonicMomentThrust2

[Eventbased] Harmonic moment of the 2nd order calculated respect to the thrust axis.

Group

EventShape

harmonicMomentThrust3

[Eventbased] Harmonic moment of the 3rd order calculated respect to the thrust axis.

Group

EventShape

harmonicMomentThrust4

[Eventbased] Harmonic moment of the 4th order calculated respect to the thrust axis.

Group

EventShape

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

isChargedBEvent

[Eventbased] true if event contains a charged B-meson

Group

Event

isContinuumEvent

[Eventbased] true if event doesn’t contain an Y(4S)

Group

Event

isMC

[Eventbased] Returns 1 if run on MC and 0 for data.

Group

MC Matching for ECLClusters

isMajorityInRestOfEventFromB0

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

Group

Flavor Tagger Variables

isMajorityInRestOfEventFromB0bar

[Eventbased] Check if the majority of the tracks in the current RestOfEvent are from a B0bar.

Group

Flavor Tagger Variables

isNotContinuumEvent

[Eventbased] 1.0 if event does contain an Y(4S) and therefore is not a continuum Event

Group

Event

isUnmixedBEvent

[Eventbased] true if event contains opposite flavor neutral B-mesons, false in case of same flavor B-mesons and NaN if an event has no generated neutral B

Group

Event

missingEnergyOfEventCMS

[Eventbased] The missing energy in CMS obtained with EventKinematics module

Group

EventKinematics

missingMass2OfEvent

[Eventbased] The missing mass squared obtained with EventKinematics module

Group

EventKinematics

missingMomentumOfEvent

[Eventbased] The magnitude of the missing momentum in lab obtained with EventKinematics module

Group

EventKinematics

missingMomentumOfEventCMS

[Eventbased] The magnitude of the missing momentum in CMS obtained with EventKinematics module

Group

EventKinematics

missingMomentumOfEventCMS_Px

[Eventbased] The x component of the missing momentum in CMS obtained with EventKinematics module

Group

EventKinematics

missingMomentumOfEventCMS_Py

[Eventbased] The y component of the missing momentum in CMS obtained with EventKinematics module

Group

EventKinematics

missingMomentumOfEventCMS_Pz

[Eventbased] The z component of the missing momentum in CMS obtained with EventKinematics module

Group

EventKinematics

missingMomentumOfEventCMS_theta

[Eventbased] The theta angle of the missing momentum in CMS obtained with EventKinematics module

Group

EventKinematics

missingMomentumOfEvent_Px

[Eventbased] The x component of the missing momentum in lab obtained with EventKinematics module

Group

EventKinematics

missingMomentumOfEvent_Py

[Eventbased] The y component of the missing momentum in lab obtained with EventKinematics module

Group

EventKinematics

missingMomentumOfEvent_Pz

[Eventbased] The z component of the missing momentum in lab obtained with EventKinematics module

Group

EventKinematics

missingMomentumOfEvent_theta

[Eventbased] The theta angle of the missing momentum of the event in lab obtained with EventKinematics module

Group

EventKinematics

nChargeZeroTrackFits

[Eventbased] number of track fits with a zero charge.Sometimes this can happen if background or non IP originating tracks (for example) are fit from the IP. These tracks are removed from particle lists but a large number charge zero fits them may indicate problems with whole event constraints or abnominally high beam backgrounds and/or noisy events.

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] number of KLM in the event

Group

Event

nMCParticles

[Eventbased] number of MCParticles in the event

Group

Event

nParticlesInList(particleListName)

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

Group

MetaFunctions

nTracks

[Eventbased] number of tracks in the event

Group

Event

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

productionIdentifier

[Eventbased] production identifier

Group

Event

qrCombined

[Eventbased] -1 (1) if current RestOfEvent is related to a B0bar (B0). The MCError bit of Breco has to be 0, 1, 2, 16 or 1024. The output of the variable is 0 otherwise. If one Particle in the Rest of Event is found to belong the reconstructed B0, the output is -2(2) for a B0bar (B0) on the reco side.

Group

Flavor Tagger Variables

runNum

[Eventbased] run number

Group

Event

sphericity

[Eventbased] Event sphericity, defined as the linear combination of the sphericity eigenvlaues S = (3/2)(lambda2+lambda3)

Group

EventShape

thrust

[Eventbased] Event thrust.

Group

EventShape

thrustAxisCosTheta

[Eventbased] Cosine of the polar angle component of the thrust axis.

Group

EventShape

thrustAxisX

[Eventbased] X component of the thrust axis.

Group

EventShape

thrustAxisY

[Eventbased] Y component of the thrust axis.

Group

EventShape

thrustAxisZ

[Eventbased] Z component of the thrust axis.

Group

EventShape

totalPhotonsEnergyOfEvent

[Eventbased] The energy in lab of all the photons obtained with EventKinematics module

Group

EventKinematics

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

visibleEnergyOfEventCMS

[Eventbased] The visible energy in CMS obtained with EventKinematics module

Group

EventKinematics

year

[Eventbased] Returns the year when the event was recorded (in UTC). For more precise eventTime, see eventTimeSeconds and eventTimeSecondsFractionRemainder.

Group

Event