12. KLM (\(K_{L}^0\) and Muon Detector)

In the following we describe the klm package (documentation still under development).

12.1. Modules

This is a list of the klm modules. Some modules (in the klm/bklm and klm/eklm subfolders) that are currently used only for debugging or specific studies are omitted here.

KLMChannelStatusCollector

Module for KLM channel status calibration (data collection).

Package

klm

Library

libKLMChannelStatusCollector.so

Parameters
  • granularity (str, default=’run’)

    Granularity of data collection. Data is separated by runs (=run) or not separated at all (=all)

  • maxEventsPerRun (int, default=-1)

    Maximum number of events that will be collected per run. Effectively the code in the collect() function is only run for this number of events on each run. Then the collect() function is switched off until a new run that hasn’t collected the maximum yet begins. -1 is the default and means that the collector runs over all events.

    Note that this is useful for debugging and hard limiting the number of events passed to the collected. However you should be limiting the collected data yourself! Check if your collected data object has enough entries for an algorithm to complete and then stop filling. Controlling this limit via a module param is encouraged.

  • preScale (float, default=1.0)

    This controls the rate at which events are actually passed to the collect() function. An event passing through this module will only have the collect() function run on it it passes a random selection scaled by this parameter i.e. For preScale=1.0 all events are collected, but for preScale=0.5 only 50 percent will be. Since this is based on a random choice, you should set the random seed to a fixed value if you want repeatable results.

    Should be a float in range [0.0,1.0], default=1.0

KLMClusterEfficiency

Module for KLM cluster reconstruction efficiency studies.

Package

klm

Library

libKLMClusterEfficiency.so

Parameters
  • EventsClusterHistograms (int, default=0)

    Draw cluster histograms for this number of events.

  • OutputFile (str, default=’KLMClusterEfficiency.root’)

    Output file.

  • SaveClusterData (bool, default=False)

    Whether to save cluster data or not.

  • SaveReconstructionData (bool, default=True)

    Whether to save reconstruction data or not.

KLMClustersReconstructor

Unified BKLM/EKLM module for the reconstruction of KLMClusters.

Package

klm

Library

libKLMClustersReconstructor.so

Parameters
  • ClusterMode (str, default=’AnyHit’)

    Clusterization mode (‘AnyHit’ or ‘FirstHit’).

  • ClusteringAngle (float, default=0.26)

    Clustering angle (rad).

  • PositionMode (str, default=’FirstLayer’)

    Vertex position calculation mode (‘FullAverage’ or ‘FirstLayer’).

KLMDQM

KLM data quality monitor.

Package

klm

Library

libKLMDQM.so

Parameters
  • histogramDirectoryName (str, default=’KLM’)

    Directory for KLM DQM histograms in ROOT file.

KLMDigitizer

KLM digitization module: create KLMDigits from BKLMSimHits and EKLMSimHits.

Package

klm

Library

libKLMDigitizer.so

Parameters
  • Debug (bool, default=False)

    Debug mode (generates additional output files with histograms).

  • DigitizationInitialTime (int, default=-40)

    Initial digitization time in TDC periods.

  • Efficiency (str, default=’Plane’)

    Efficiency determination mode (“Strip” or “Plane”).

  • SaveFPGAFit (bool, default=False)

    Save FPGA fit data and set a relation with KLMDigits.

  • SimulationMode (str, default=’Generic’)

    Simulation mode (“Generic” or “ChannelSpecific”).

KLMPacker

KLM raw data packer (creates RawKLM from KLMDigits).

Package

klm

Library

libKLMPacker.so

KLMReconstructor

Create BKLMHit1ds from KLMDigits and then create BKLMHit2ds from BKLMHit1ds; create EKLMHit2ds from KLMDigits.

Package

klm

Library

libKLMReconstructor.so

Parameters
  • CheckSegmentIntersection (bool, default=True)

    Check if segments intersect.

  • IfAlign (bool, default=True)

    Perform alignment correction (true) or not (false).

  • IgnoreHotChannels (bool, default=True)

    Use only Normal and Dead (for debugging) channels during 2d hit reconstruction

  • IgnoreScintillators (bool, default=False)

    Ignore scintillators (to debug their electronics mapping).

KLMStripEfficiencyCollector

Module for KLM strip efficiency data collection.

Package

klm

Library

libKLMStripEfficiencyCollector.so

Parameters
  • AllowedDistance1D (float, default=8.0)

    Maximal distance in the units of strip number from ExtHit to matching KLMDigit.

  • Debug (bool, default=False)

    Debug mode.

  • DebugFileName (str, default=’matching.root’)

    Debug file name.

  • IgnoreBackwardPropagation (bool, default=False)

    Whether to ignore ExtHits with backward propagation.

  • MinimalMatchingDigits (int, default=0)

    Minimal number of matching digits.

  • MinimalMatchingDigitsOuterLayers (int, default=0)

    Minimal number of matching digits in outer layers.

  • MinimalMomentumNoOuterLayers (float, default=0.0)

    Minimal momentum in case there are no hits in outer layers.

  • MuonListName (str, default=’mu+:all’)

    Muon list name.

  • RemoveUnusedMuons (bool, default=False)

    Whether to remove unused muons.

  • granularity (str, default=’run’)

    Granularity of data collection. Data is separated by runs (=run) or not separated at all (=all)

  • maxEventsPerRun (int, default=-1)

    Maximum number of events that will be collected per run. Effectively the code in the collect() function is only run for this number of events on each run. Then the collect() function is switched off until a new run that hasn’t collected the maximum yet begins. -1 is the default and means that the collector runs over all events.

    Note that this is useful for debugging and hard limiting the number of events passed to the collected. However you should be limiting the collected data yourself! Check if your collected data object has enough entries for an algorithm to complete and then stop filling. Controlling this limit via a module param is encouraged.

  • preScale (float, default=1.0)

    This controls the rate at which events are actually passed to the collect() function. An event passing through this module will only have the collect() function run on it it passes a random selection scaled by this parameter i.e. For preScale=1.0 all events are collected, but for preScale=0.5 only 50 percent will be. Since this is based on a random choice, you should set the random seed to a fixed value if you want repeatable results.

    Should be a float in range [0.0,1.0], default=1.0

KLMUnpacker

KLM unpacker (creates KLMDigits from RawKLM).

Package

klm

Library

libKLMUnpacker.so

Parameters
  • DAQChannelBKLMScintillators (bool, default=False)

    Record DAQ channel for BKLM scintillators.

  • DAQChannelModule (int, default=-1)

    Record DAQ channel for specific module.

  • DebugElectronicsMap (bool, default=False)

    Debug electronics map (record DAQ channel instead of strip).

  • IgnoreStrip0 (bool, default=True)

    Ignore hits with strip = 0 (normally expected for certain firmware versions).

  • IgnoreWrongHits (bool, default=False)

    Ignore wrong hits (i.e. no B2ERROR).

  • SciThreshold (float, default=140.0)

    Scintillator strip hits with charge lower this value will be marked as bad.

  • WriteDigitRaws (bool, default=False)

    Record raw data in dataobject format (e.g. for debugging).

  • WriteWrongHits (bool, default=False)

    Record wrong hits (e.g. for debugging).

  • keepEvenPackages (bool, default=False)

    Keep packages that have even length normally indicating that data was corrupted

  • loadThresholdFromDB (bool, default=True)

    Load threshold from database (true) or not (false)

  • outputKLMDigitsName (str, default=’’)

    Name of KLMDigit store array.

MCMatcherKLMClusters

Module for MC matching for KLM clusters.

Package

klm

Library

libMCMatcherKLMClusters.so

Parameters
  • Hit2dRelations (bool, default=False)

    Add also relations for BKLMHit2d and EKLMHit2d.

12.2. Clusterization

Few words about how a KLMCluster is built starting from BKLMHit2d and EKLMHit2d are more than desiderable.

12.3. Muon identification

It would be veeery nice to document here the algorithm for the muon identification (and the MuidBuilder class).

12.4. Calibration

This seems the best place to cite our internal note KLM offline calibration.

12.5. Tools

Section for our beautiful tools.

12.5.1. b2klm-create-dqm: Create DQM reference plots

Tool used to generate the KLM DQM reference plots and to mask the (very) hot channels if necessary.

usage: b2klm-create-dqm [-h] -i FILE [FILE ...] [-n EVENTS]
                        [--prepend_gt [GT [GT ...]]]
                        [--append_gt [GT [GT ...]]] [--raw] [--no_mask]
                        [--output_dqm OUTPUT_DQM]

Optional Arguments

-i, --input

input file names; it is possible to use the wildcard “*” to pass multiple files in input

-n, --events

maximum number of events to be processed

--prepend_gt

Global Tags to be prepended

--append_gt

Global Tags to be appended

--raw

flag for raw input files; it must be used if data must be unpacked and reconstructed from scratch

--no_mask

flag for disable masking of (very) hot channels; the masking is disabled for .sroot files, please convert them to .root if this is necessary

--output_dqm

name of the output .root file containing plots with masked channels

12.5.2. b2klm-mask-dqm: Mask very hot channels in DQM reference plots

Tool used to mask the (very) hot channels in KLM DQM reference plots.

usage: b2klm-mask-dqm [-h] --exp EXP_NUMBER --run RUN_NUMBER [-i INPUT_FILE]
                      [-o OUTPUT_FILE] --globaltags GT [GT ...]

Optional Arguments

--exp

experiment number

--run

run number

-i, --input

input file name

-o, --output

output file name

--globaltags

Global Tags to be used