Skip to content
Snippets Groups Projects
Commit 35886f24 authored by Patrick Koppenburg's avatar Patrick Koppenburg :leaves: Committed by Eduardo Rodrigues
Browse files

New test on raw data

parent 08e05500
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!818New test on raw data
input_files:
- mdf:root://eoslhcb.cern.ch//eos/lhcb/point8/lhcb/data/2022/RAW/TURBO/LHCb/COLLISION22/255620/255620_00150000_0000.raw
- mdf:root://eoslhcb.cern.ch//eos/lhcb/point8/lhcb/data/2022/RAW/TURBO/LHCb/COLLISION22/255620/255620_00150000_0001.raw
- mdf:root://eoslhcb.cern.ch//eos/lhcb/point8/lhcb/data/2022/RAW/TURBO/LHCb/COLLISION22/255620/255620_00150000_0002.raw
- mdf:root://eoslhcb.cern.ch//eos/lhcb/point8/lhcb/data/2022/RAW/TURBO/LHCb/COLLISION22/255620/255620_00150000_0003.raw
- mdf:root://eoslhcb.cern.ch//eos/lhcb/point8/lhcb/data/2022/RAW/TURBO/LHCb/COLLISION22/255620/255620_00150011_0001.raw
data_type: 'Upgrade'
input_type: 'RAW'
simulation: False
evt_max : 10000
ntuple_file: "Raw_DV_Ks_example.root"
input_raw_format: 0.5
input_process: 'Hlt2'
dddb_tag : 'master'
conddb_tag : '2022_12_HLT2Processing'
python_logging_level: 3
output_level: 3
print_freq: 1000
###############################################################################
# (c) Copyright 2023 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
from PyConf.reading import get_particles, get_pvs
import Functors as F
from FunTuple import FunctorCollection
from FunTuple import FunTuple_Particles as Funtuple
import FunTuple.functorcollections as FC
from DaVinci.algorithms import add_filter
from DaVinci import Options, make_config
from PyConf.application import metainfo_repos
metainfo_repos.global_bind(extra_central_tags=['commissioning'])
def main(options: Options):
#
# Input line
#
line_KS2PiPi = "Hlt2Commissioning_KsToPimPip_LL"
particles_KS2PiPi = get_particles(f"/Event/HLT2/{line_KS2PiPi}/Particles")
fields_KS2PiPi = {
'KS': "KS0 -> pi+ pi-",
'pip': "KS0 -> ^pi+ pi-",
'pim': "KS0 -> pi+ ^pi-"
}
v2_pvs = get_pvs()
#
# Variables for Ks.
# BPVLTIME sometimes gets the right solution, sometimes nan and sometimes nonsense.
# Reported as Rec#421.
#
variables = FunctorCollection({
"BPVFDCHI2": F.BPVFDCHI2(v2_pvs),
"BPVFD": F.BPVFD(v2_pvs),
'BPVLTIME': F.BPVLTIME(v2_pvs),
'BPVIP': F.BPVIP(v2_pvs),
'BPVIPCHI2': F.BPVIPCHI2(v2_pvs),
'CHI2': F.CHI2,
'END_VX': F.END_VX,
'END_VY': F.END_VY,
'END_VZ': F.END_VZ,
'BPVX': F.BPVX(v2_pvs),
'BPVY': F.BPVY(v2_pvs),
'BPVZ': F.BPVZ(v2_pvs),
})
#FunTuple: make functor collection from the imported functor library Kinematics
variables_all = FC.Kinematics()
#
# Variables for pions. Just a technical test of functors.
# PID is uncalibrated and many PID variables return 0.
# PROBNN_D and PROBNN_MU presently returns nan.
#
all_vars = {}
all_vars['PID_E'] = F.PID_E
all_vars['PID_K'] = F.PID_K
all_vars['PID_MU'] = F.PID_MU
all_vars['PID_P'] = F.PID_P
all_vars['PID_PI'] = F.PID_PI
# POD
all_vars['PROBNN_D'] = F.PROBNN_D
all_vars['PROBNN_E'] = F.PROBNN_E
all_vars['PROBNN_GHOST'] = F.PROBNN_GHOST
all_vars['PROBNN_K'] = F.PROBNN_K
all_vars['PROBNN_MU'] = F.PROBNN_MU
all_vars['PROBNN_P'] = F.PROBNN_P
all_vars['PROBNN_PI'] = F.PROBNN_PI
variables_extra = FunctorCollection(all_vars)
#FunTuple: associate functor collections to field (branch) name
variables_KS2PiPi = {
'ALL': variables_all, #adds variables to all fields
'KS': variables,
'pip': variables_extra,
'pim': variables_extra
}
#
# Event variables
#
evt_vars = FC.EventInfo()
evt_vars['PV_SIZE'] = F.SIZE(v2_pvs)
tuple_KS2PiPi = Funtuple(
name="Tuple_KS2PiPi",
tuple_name="DecayTree",
fields=fields_KS2PiPi,
variables=variables_KS2PiPi,
event_variables=evt_vars,
inputs=particles_KS2PiPi)
filter_KS2PiPi = add_filter("HDRFilter_KS2PiPi",
f"HLT_PASS('{line_KS2PiPi}')")
algs = {"KS2PiPi": [filter_KS2PiPi, tuple_KS2PiPi]}
return make_config(options, algs)
"""
./run lbexec DaVinciExamples.tupling.option_davinci_tupling_from_raw_data:main DaVinciExamples/example_data/Spruce_Run251342.yaml
"""
<?xml version="1.0" ?>
<!--
###############################################################################
# (c) Copyright 2023 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
-->
<!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<extension class="GaudiTest.GaudiExeTest" kind="test">
<argument name="program"><text>lbexec</text></argument>
<argument name="args"><set>
<text>DaVinciExamples.tupling.option_davinci_tupling_from_raw_data:main</text>
</set></argument>
<argument name="options_yaml_fn"><text>$DAVINCIEXAMPLESROOT/example_data/Run255620.yaml</text></argument>
<argument name="reference"><text>../refs/test_davinci_tupling_from_raw_data.ref</text></argument>
<argument name="error_reference"><text>../refs/empty.ref</text></argument>
<argument name="validator"><text>
from DaVinciTests.QMTest.DaVinciExclusions import preprocessor, counter_preprocessor
validateWithReference(preproc = preprocessor, counter_preproc = counter_preprocessor)
countErrorLines({"FATAL":0, "ERROR":0})
</text></argument>
<argument name="validator"><text>
findReferenceBlock("""Tuple_KS2PiPi SUCCESS Booked 1 N-Tuples and 0 Event Tag Collections"""
, stdout, result, causes, signature_offset = 0)
import sys, os, glob
from ROOT import TFile
#open the TFile and TTree
ntuple = './Raw_DV_Ks_example.root'
if not os.path.isfile(ntuple): raise Exception(f"File: {ntuple} does not exist!")
f = TFile.Open(ntuple)
t_B = f.Get('Tuple_KS2PiPi/DecayTree')
b_names= [b.GetName() for b in t_B.GetListOfLeaves()]
if not b_names: raise Exception(f"File: {ntuple} does not contain any branches. Please check.")
f.Close()
print('Test successfully completed!')
os.system(f"rm {ntuple}")
countErrorLines({"FATAL":0, "ERROR":0})
</text></argument>
<argument name="unsupported_platforms"><set><text>^((?!dd4hep).)*$</text></set></argument>
</extension>
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment