Skip to content
Snippets Groups Projects
Commit 7dad4f1d authored by Ross John Hunter's avatar Ross John Hunter Committed by Rosen Matev
Browse files

New Hlt{1,2}MCTrueSimEff functors for HltEfficiencyChecker FunTuple migration

parent 2cbc7bfb
No related branches found
No related tags found
1 merge request!985New Hlt{1,2}MCTrueSimEff functors for HltEfficiencyChecker FunTuple migration
......@@ -29,10 +29,10 @@ from GaudiKernel import SystemOfUnits
from GaudiConf.LbExec import HltSourceID
import Functors as F
from PyConf.reading import get_odin, get_decreports, get_hlt1_selreports
from PyConf.application import default_raw_event
from PyConf.application import default_raw_event, make_data_with_FetchDataFromFile
from PyConf.dataflow import DataHandle
from PyConf.components import Algorithm
from PyConf.Algorithms import HltTisTosAlg
from PyConf.Algorithms import HltTisTosAlg, Hlt1TrueSimEffAlg, Hlt2TrueSimEffAlg
import DaVinciMCTools # for MCReconstructible, MCReconstructed and MCTruthAndBkgCat helper classes
from DecayTreeFitter import DecayTreeFitter
from .FunctorCollection import FunctorCollection
......@@ -121,6 +121,72 @@ def SelectionInfo(*, selection_type: HltSourceID,
return trigger_info
def _HltMCTrueSimEff(
*,
selection_type: HltSourceID,
trigger_lines: List[str],
mcp_data: DataHandle,
dec_reports: DataHandle,
mc2IDLink: DataHandle,
sel_reports: DataHandle = make_data_with_FetchDataFromFile(
"dummy_sel_rep_location"),
cand_locations: List[str] = ['dummy_line_name_Decision_loc']):
"""
Candidate-level collection to store TrueSim efficiencies for HltEfficiencyChecker
Configured in MooreAnalysis/HltEfficiencyChecker/python/HltEfficiencyChecker/config.py
*Only* intended for usage in HltEfficienyChecker.
These efficiencies are described in the HltEfficiencyChecker documentation:
https://lhcbdoc.web.cern.ch/lhcbdoc/moore/master/tutorials/hltefficiencychecker.html
Note that for HLT1, this is not configured by HltEfficiencyChecker due to MooreAnalysis#41.
Use of this in HltEfficiencyChecker will currently crash.
Args:
selection_type (HltSourceID): Name of the selection type i.e. "Hlt1" or "Hlt2".
Used as branch name prefix when tupling and as source ID to get decision reports.
trigger_lines (list(str)): List of Hlt1/Hlt2 decision names for computing TrueSim efficiencies.
Should be post-fixed with 'Decision'.
mcp_data (DataHandle): TES location of MC particles e.g. output of
`get_mc_particles("/Event/MC/Particles")
dec_reports (DataHandle): TES location of DecReports.
mc2IDLink (DataHandle): TES location of linker between MC particles and MC LHCbIDs of
their tracks. Output of e.g. make_links_lhcbids_mcparticles_tracking_system()
sel_reports (DataHandle, optional): TES location of Hlt1 SelReports. Only relevant for HLT1,
so has a dummy default value.
cand_locations (list(str), optional): List of TES locations to the reconstructed candidates
of each line. Only relevant for HLT2, so has a dummy default value.
Example:
Only intended usage is in MooreAnalysis/HltEfficiencyChecker/python/HltEfficiencyChecker/config.py.
"""
if selection_type == HltSourceID.Hlt1:
true_sim_relns = Hlt1TrueSimEffAlg(
name="Hlt1TrueSimEffAlgName_{hash}",
InputMCParticles=mcp_data,
DecReports=dec_reports,
MC2IDLink=mc2IDLink,
SelReports=sel_reports,
TriggerLines=trigger_lines).P2TrueSimEffTable
elif selection_type == HltSourceID.Hlt2:
true_sim_relns = Hlt2TrueSimEffAlg(
name="Hlt2TrueSimEffAlgName_{hash}",
InputMCParticles=mcp_data,
DecReports=dec_reports,
MC2IDLink=mc2IDLink,
TriggerLines=trigger_lines,
CandidateLocations=cand_locations).P2TrueSimEffTable
else:
raise ValueError(
f'selection_type "{selection_type}" is not supported in _HltMCTrueSimEff functor collection.'
)
return FunctorCollection({
f"{line}TrueSim": F.VALUE_OR(False) @ F.VALUE_FROM_DICT(line)
@ F.MAP_TO_RELATED(true_sim_relns)
for line in trigger_lines
})
def HltTisTos(*, selection_type: HltSourceID, trigger_lines: List[str],
data: DataHandle) -> FunctorCollection:
"""
......@@ -966,12 +1032,12 @@ def ParticleID(extra_info: bool = False) -> FunctorCollection:
def __print_collection(coll_name):
"""Nicely print out the contents of a collection."""
from PyConf.Algorithms import WeightedRelTableAlg
from PyConf.application import make_data_with_FetchDataFromFile
from Functors.grammar import BoundFunctor
from PyConf.reading import get_tes_root, upfront_decoder
_truth_mathing_excluded = [
"MCReconstructible", "MCReconstructed", "MCPrimaries"
_truth_matching_excluded = [
"_HltMCTrueSimEff", "MCReconstructible", "MCReconstructed",
"MCPrimaries"
]
print(f"{coll_name}:")
......@@ -986,7 +1052,7 @@ def __print_collection(coll_name):
f_dict = coll(
selection_type=HltSourceID.Hlt2,
trigger_lines=['dummy_line_name_Decision']).functor_dict
elif 'MC' in coll_name and coll_name not in _truth_mathing_excluded:
elif 'MC' in coll_name and coll_name not in _truth_matching_excluded:
with default_raw_event.bind(raw_event_format=0.5),\
get_tes_root.bind(input_process="Hlt2"),\
upfront_decoder.bind(source ="Hlt2" ):
......@@ -1036,6 +1102,19 @@ def __print_collection(coll_name):
decay_origin=True,
with_lifetime=True,
with_kinematics=True).functor_dict
elif coll_name == '_HltMCTrueSimEff':
dummy_dh1 = make_data_with_FetchDataFromFile("dummy12")
dummy_dh2 = make_data_with_FetchDataFromFile("dummy13")
dummy_dh3 = make_data_with_FetchDataFromFile("dummy14")
dummy_dh4 = make_data_with_FetchDataFromFile("dummy15")
f_dict = coll(
selection_type=HltSourceID.Hlt2,
trigger_lines=['dummy_line_name_Decision'],
mcp_data=dummy_dh1,
dec_reports=dummy_dh2,
mc2IDLink=dummy_dh3,
sel_reports=dummy_dh4,
cand_locations=['dummy_line_name_Decision_loc']).functor_dict
else:
f_dict = coll().functor_dict
......
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