Skip to content
Snippets Groups Projects
Commit 78cfd999 authored by Abhijit Mathad's avatar Abhijit Mathad Committed by Rosen Matev
Browse files

Storing event info (trigger and odin) with FunTuple

parent 152b9749
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!654Storing event info (trigger and odin) with FunTuple
Showing
with 190 additions and 52 deletions
......@@ -91,7 +91,7 @@ def all_variables(pvs, DTFR, ptype):
all_vars['MAXPT'] = F.MAX(F.PT)
all_vars['CHILD'] = F.CHILD(1, F.PT)
#all_vars['SUBCOMB'] = F.SUBCOMB
all_vars['MASSWITHHYPOTHESES'] = F.MASSWITHHYPOTHESES([939., 939.])
all_vars['MASSWITHHYPOTHESES'] = F.MASSWITHHYPOTHESES((939., 939.))
all_vars['END_VX'] = F.END_VX
all_vars['END_VY'] = F.END_VY
all_vars['END_VZ'] = F.END_VZ
......
......@@ -44,7 +44,7 @@ variables_jpsi = FunctorCollection({
'PX': F.PX,
'PY': F.PY,
'PZ': F.PZ,
'PE': F.ENERGY,
'ENERGY': F.ENERGY,
'FourMom_P': F.FOURMOMENTUM,
'MAXPT': 'TRACK_MAX_PT',
})
......@@ -54,10 +54,10 @@ variables_jpsi.update({
'PT': F.PT
}) #OR like dictionaries can do variables_jpsi['LOKI_PT'] = 'PT'
#FunTuple: Remove from collection given the list of variable names
variables_jpsi.pop(['PT', 'PE'])
variables_jpsi.pop(['PT', 'ENERGY'])
#FunTuple: Join two functor
#If entries already exist user is warned about picking entries from the base instance.
variables_extra = FunctorCollection({'E': F.ENERGY, 'P': F.P})
variables_extra = FunctorCollection({'ENERGY': F.ENERGY, 'P': F.P})
variables_jpsi += variables_extra
#FunTuple: Can also subtract two FunctorCollection to get unique entries like below
#variables_unique = variables_jpsi - variables_extra
......
......@@ -18,6 +18,7 @@ from FunTuple import FunTuple_Particles as Funtuple
from DaVinci.algorithms import add_filter
from DaVinci import options
from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg
from DaVinci.algorithms import get_odin, get_decreports
d02kpi_data = make_data_with_FetchDataFromFile(
"/Event/HLT2/Hlt2CharmD0ToKmPipLine/Particles")
......@@ -25,6 +26,12 @@ d02kpi_data = make_data_with_FetchDataFromFile(
#get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output
mctruth = configured_MCTruthAndBkgCatAlg(inputs=d02kpi_data)
#get location to odin
odin = get_odin(options)
#get location to hlt2 dec report
dec = get_decreports("Hlt2", options)
# use functorcollections to add variables, please expand when there's new collections :)
collections = [
functorcollections.Kinematics(),
......@@ -33,13 +40,23 @@ collections = [
functorcollections.MCVertexInfo(mctruth)
]
assert len(collections) == len(
hlt2_line_names = ['Hlt2CharmD0ToKmPipLineDecision']
evt_collections = [
functorcollections.EventInfo(odin),
functorcollections.SelectionInfo("Hlt2", dec, hlt2_line_names)
]
assert len(collections) + len(evt_collections) == len(
functorcollections.
__all__), "Oh no! Did you forget to add a new collection to this test?"
variable_collection = FunctorCollection()
field_vars = FunctorCollection()
for coll in collections:
variable_collection += coll
field_vars += coll
evt_vars = FunctorCollection()
for coll in evt_collections:
evt_vars += coll
fields = {
"D0": "[D0 -> K- pi+]CC",
......@@ -47,10 +64,16 @@ fields = {
"piplus": "[D0 -> K- ^pi+]CC",
}
#For now remove: The 'Hlt2' line decision tuples fine but breaks unit test with an error. (Why?)
#see linked issue here: https://gitlab.cern.ch/lhcb/DaVinci/-/merge_requests/654#note_5320732
print(evt_vars.pop(['Hlt2']))
variables = {
"D0": variable_collection,
"Kminus": variable_collection,
"piplus": variable_collection
"D0": field_vars,
"Kminus": field_vars,
"piplus": field_vars,
#special field name "EVENT" (like "ALL")
"EVENT": evt_vars,
}
my_tuple = Funtuple(
......@@ -62,11 +85,6 @@ my_tuple = Funtuple(
def main():
options.ntuple_file = "tuple_D0_Kpi_10evts.root"
options.annsvc_config = "root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/NovemberFEST/hlt2_D0_Kpi_10evts.tck.json"
options.process = "Hlt2"
options.input_raw_format = 0.3
my_filter = add_filter("HDRFilter_D0Kpi",
"HLT_PASS('Hlt2CharmD0ToKmPipLineDecision')")
......
###############################################################################
# (c) Copyright 2022 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. #
###############################################################################
annsvc_config: 'root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/NovemberFEST/hlt2_D0_Kpi_10evts.tck.json'
evt_max: -1
histo_file: 'tuple_D0_Kpi_10evts_collections.root'
input_raw_format: 0.3
lumi: false
ntuple_file: 'tuple_D0_Kpi_10evts_collections.root'
print_freq: 1
skip_events: 0
process: 'Hlt2'
stream: 'default'
\ No newline at end of file
......@@ -19,6 +19,7 @@ from DaVinci.reco_objects import make_pvs_for
from DaVinci.algorithms import add_filter
from DaVinci import options
from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg
from DaVinci.algorithms import get_odin, get_decreports
fields = {
"D0": "[D0 -> K- pi+]CC",
......@@ -62,11 +63,6 @@ variables = {
def main():
options.ntuple_file = "tuple_D0_Kpi_10evts.root"
options.annsvc_config = "root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/NovemberFEST/hlt2_D0_Kpi_10evts.tck.json"
options.process = "Hlt2"
options.input_raw_format = 0.3
d02kpi_data = make_data_with_FetchDataFromFile(
"/Event/HLT2/Hlt2CharmD0ToKmPipLine/Particles")
......@@ -101,6 +97,33 @@ def main():
for field in variables.keys():
variables[field] += FunctorCollection(trueid_bkgcat_info)
#get ODIN and DecReports location
odin = get_odin(options)
hlt2_dec = get_decreports("Hlt2", options)
#Since input is from this line should return 1 for decisions
hlt2_lines = ['Hlt2CharmD0ToKmPipLineDecision']
#define event level variables
evt_variables = FunctorCollection({
"RUNNUMBER":
F.RUNNUMBER(odin),
"EVENTNUMBER":
F.EVENTNUMBER(odin),
"Hlt2_TCK":
F.TCK(hlt2_dec),
"Sel":
F.DECISIONS(Lines=hlt2_lines, DecReports=hlt2_dec),
})
#For now remove: The 'Hlt2' line decision tuples fine but breaks unit test with an error. (Why?)
#see linked issue here: https://gitlab.cern.ch/lhcb/DaVinci/-/merge_requests/654#note_5320732
evt_variables.pop('Sel')
#Add them to a special branch called "EVENT"
# (currently two special branches exist: "EVENT" and "ALL")
variables["EVENT"] = evt_variables
#define FunTuple instance
my_tuple = Funtuple(
name="Tuple",
tuple_name="DecayTree",
......
###############################################################################
# (c) Copyright 2022 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. #
###############################################################################
annsvc_config: 'root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/NovemberFEST/hlt2_D0_Kpi_10evts.tck.json'
evt_max: -1
histo_file: 'tuple_D0_Kpi_10evts.root'
input_raw_format: 0.3
lumi: false
ntuple_file: 'tuple_D0_Kpi_10evts.root'
print_freq: 1
skip_events: 0
process: 'Hlt2'
stream: 'default'
\ No newline at end of file
......@@ -38,37 +38,37 @@ import sys, os, glob
from ROOT import TFile
Jpsi_vars_stored = ['Jpsi_MAXPT',
'Jpsi_E',
'Jpsi_FourMom_PE',
'Jpsi_FourMom_PX',
'Jpsi_FourMom_PY',
'Jpsi_FourMom_PZ',
'Jpsi_M',
'Jpsi_P',
'Jpsi_PT',
'Jpsi_PX',
'Jpsi_PY',
'Jpsi_PZ',
'MuPlus_E',
'MuPlus_M',
'MuPlus_P',
'MuPlus_PT',
'MuPlus_PX',
'MuPlus_PY',
'MuPlus_PZ']
'Jpsi_PX',
'Jpsi_PY',
'Jpsi_PZ',
'Jpsi_FourMom_PE',
'Jpsi_FourMom_PX',
'Jpsi_FourMom_PY',
'Jpsi_FourMom_PZ',
'Jpsi_ENERGY',
'Jpsi_P',
'Jpsi_M',
'Jpsi_PT',
'MuPlus_ENERGY',
'MuPlus_P',
'MuPlus_M',
'MuPlus_PT',
'MuPlus_PX',
'MuPlus_PY',
'MuPlus_PZ']
Ks_vars_stored = ['KS_MAXPT',
'KS_E',
'KS_FourMom_PE',
'KS_FourMom_PX',
'KS_FourMom_PY',
'KS_FourMom_PZ',
'KS_M',
'KS_P',
'KS_PT',
'KS_PX',
'KS_PY',
'KS_PZ']
'KS_PX',
'KS_PY',
'KS_PZ',
'KS_FourMom_PE',
'KS_FourMom_PX',
'KS_FourMom_PY',
'KS_FourMom_PZ',
'KS_ENERGY',
'KS_P',
'KS_M',
'KS_PT']
#sort the expected vars
Jpsi_vars_stored = sorted(Jpsi_vars_stored)
......
......@@ -30,6 +30,8 @@
<text>--inputfiledb</text>
<text>FEST_November_2021_dst</text>
<text>$DAVINCIROOT/options/DaVinciDB-Example.yaml</text>
<text>--joboptfile</text>
<text>../../python/DaVinciExamples/tupling/option_davinci_tupling_from_collections.yaml</text>
<text>--user_algorithms</text>
<text>../../python/DaVinciExamples/tupling/option_davinci_tupling_from_collections:main</text>
</set></argument>
......
......@@ -30,6 +30,8 @@
<text>--inputfiledb</text>
<text>FEST_November_2021_dst</text>
<text>$DAVINCIROOT/options/DaVinciDB-Example.yaml</text>
<text>--joboptfile</text>
<text>../../python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.yaml</text>
<text>--user_algorithms</text>
<text>../../python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2:main</text>
</set></argument>
......@@ -116,7 +118,10 @@ B_vars_stored =['D0_BKGCAT',
'D0_KEY',
'D0_TRUEKEY',
'Kminus_TRUEKEY',
'piplus_TRUEKEY']
'piplus_TRUEKEY',
'RUNNUMBER',
'EVENTNUMBER',
'Hlt2_TCK']
#sort the expected vars
B_vars_stored = sorted(B_vars_stored)
......
......@@ -22,20 +22,37 @@ EventSelector SUCCESS Reading Event record 1. Record numbe
MCTruthAndBkgCatAlg#1.DaVinciSma... WARNING BackgroundCategory:: Common mother is stable. StatusCode=FAILURE
MCTruthAndBkgCatAlg#1.Background... WARNING BackgroundCategory:: Common mother is stable. StatusCode=FAILURE
RFileCnv INFO opening Root file "tuple_D0_Kpi_10evts.root" for writing
Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long'
RCWNTupleCnv INFO Booked TTree with ID: DecayTree "DecayTree" in directory tuple_D0_Kpi_10evts.root:/Tuple
Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long'
Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long'
EventSelector SUCCESS Reading Event record 2. Record number within stream 1: 2
Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long'
Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long'
Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long'
Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long'
Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long'
Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long'
Tuple WARNING FunTupleBase<Gaudi::NamedRange_<std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> >,__gnu_cxx::__normal_iterator<LHCb::Particle const* const*,std::vector<LHCb::Particle const*,std::allocator<LHCb::Particle const*> > > > >:: The WARNING message is suppressed : 'Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long''
EventSelector SUCCESS Reading Event record 3. Record number within stream 1: 3
EventSelector SUCCESS Reading Event record 4. Record number within stream 1: 4
EventSelector SUCCESS Reading Event record 5. Record number within stream 1: 5
EventSelector SUCCESS Reading Event record 6. Record number within stream 1: 6
EventSelector SUCCESS Reading Event record 7. Record number within stream 1: 7
ApplicationMgr INFO Application Manager Stopped successfully
FSROutputStreamDstWriter INFO Set up File Summary Record
FSROutputStreamDstWriter INFO Events output: 1
Tuple SUCCESS Booked 1 N-Tuples and 0 Event Tag Collections
Tuple SUCCESS List of booked N-Tuples in directory "FILE1/Tuple"
Tuple SUCCESS ID=DecayTree Title="DecayTree" #items=76 {D0_ID,D0_KEY,D0_PT,D0_PX,D0_PY,D0_PZ,D0_ENERGY,D0_P,D0_FOURMOMENTUME,D0_FOURMOMEN}
Tuple SUCCESS ID=DecayTree Title="DecayTree" #items=79 {EVENTNUMBER,Hlt2_TCK,RUNNUMBER,D0_ID,D0_KEY,D0_PT,D0_PX,D0_PY,D0_PZ,D0_ENERGY,D0_}
Tuple SUCCESS #WARNINGS = 93 Message = 'Tuple 'DecayTree' 'unsigned long' has different sizes on 32/64 bit systems. Casting 'EVENTNUMBER' to 'unsigned long long''
LAZY_AND: DaVinci #=7 Sum=7 Eff=|( 100.0000 +- 0.00000 )%|
NONLAZY_OR: FileSummaryRecords #=7 Sum=7 Eff=|( 100.0000 +- 0.00000 )%|
LAZY_AND: GenFSR #=7 Sum=7 Eff=|( 100.0000 +- 0.00000 )%|
RecordStream/FSROutputStreamDstWriter #=7 Sum=7 Eff=|( 100.0000 +- 0.00000 )%|
NONLAZY_OR: UserAnalysis #=7 Sum=7 Eff=|( 100.0000 +- 0.00000 )%|
LAZY_AND: UserAlgs #=7 Sum=7 Eff=|( 100.0000 +- 0.00000 )%|
LHCb__UnpackRawEvent/LHCb__UnpackRawEvent #=7 Sum=7 Eff=|( 100.0000 +- 0.00000 )%|
LHCb__UnpackRawEvent/LHCb__UnpackRawEvent#1 #=7 Sum=7 Eff=|( 100.0000 +- 0.00000 )%|
HltPackedDataDecoder/HltPackedDataDecoder #=7 Sum=7 Eff=|( 100.0000 +- 0.00000 )%|
UnpackMCParticle/UnpackMCParticle #=7 Sum=7 Eff=|( 100.0000 +- 0.00000 )%|
UnpackMCVertex/UnpackMCVertex #=7 Sum=7 Eff=|( 100.0000 +- 0.00000 )%|
......
......@@ -14,6 +14,7 @@ from GaudiKernel.ProcessJobOptions import importOptions
from PyConf.Algorithms import (LoKi__HDRFilter as HDRFilter, LoKi__VoidFilter
as VoidFilter)
from DaVinci.optionChecker import DVImportError, log_click
from PyConf.application import default_raw_event, make_odin
def setup_algorithms(options):
......@@ -350,3 +351,33 @@ def configured_FunTuple(config):
dictAlgs[key].append(funTuple)
return dictAlgs
def get_odin(dv_options):
"""
Function to get the LHCb::ODIN location
Args:
dv_options: Configured DaVinci.options object
Returns:
odin_loc: Location of the LHCb::ODIN
"""
with default_raw_event.bind(raw_event_format=dv_options.input_raw_format):
odin_loc = make_odin()
return odin_loc
def get_decreports(sel_stage, dv_options):
"""
Function to get the LHCb::DecReports for HLT1 or Hlt2 or Spruce
Args:
sel_state (str): Selction stage can be "Hlt1" or "Hlt2" or "Spruce" (There does not seem to be a decoder for Hlt1 currently)
dv_options: Configured DaVinci.options object
Returns:
dec_loc: Location of the LHCb::DecReports for HLT1 or Hlt2 or Spruce
"""
dec_loc = get_hlt_reports(
dv_options, source=sel_stage).OutputHltDecReportsLocation
return dec_loc
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