Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement muon showers so that it is not based on an enum type in the ntuplizer #66

Merged
merged 2 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions rate-estimation/menu2lib/menu2lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@
tmEventSetup.MUSOOT1: 'muonShower'
}

# Muon showers: Add mapping for event setup types to L1Analysis types;
# it can be done for Centrality signals, as well
ANALYSIS_TYPES = {
tmEventSetup.MUS0: 'kOneNominal', # how to map these types?
tmEventSetup.MUS1: 'kOneTight',
tmEventSetup.MUSOOT0: 'kInvalid',
tmEventSetup.MUSOOT1: 'kInvalid'
}

###########
# Helpers #
###########
Expand Down Expand Up @@ -408,10 +399,6 @@ def warning(message):
print(message)
return ''

# Muon showers: add filter function to get analysis type for use in templates
def getAnalysisType(key):
return ANALYSIS_TYPES[key.getType()]

def render(menu, template):
module_dir = os.path.dirname(os.path.abspath(__file__))
templates_dir = os.path.join(module_dir, 'templates')
Expand Down Expand Up @@ -440,7 +427,6 @@ def render(menu, template):
j2_env.filters['getIndexCut'] = getIndexCut
j2_env.filters['getScale'] = getScale
j2_env.filters['getLookUpTable'] = getLookUpTable
j2_env.filters['getAnalysisType'] = getAnalysisType # Muon showers
data = {
"tmGrammar": tmGrammar,
"tmEventSetup": tmEventSetup,
Expand Down
3 changes: 1 addition & 2 deletions rate-estimation/menu2lib/templates/MenuTemplate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,8 @@ PermutationFactory::cache_t PermutationFactory::cache_ = {};
// Muon showers: associate the condition type and a given template;
// it can be done for Centrality signals, as well
#}
{# {% elif cond.getType() == tmEventSetup.MuonShower0, tmEventSetup.MuonShower1, tmEventSetup.MuonShowerOutOfTime0, tmEventSetup.MuonShowerOutOfTime1 %} #}
{% elif cond.getType() in ShowerSignalTypes %}
{% include 'SignalsTemplate.cc' %}
{% include 'MuonShowerTemplate.cc' %}

{% endif -%}
{% endfor %}
Expand Down
44 changes: 44 additions & 0 deletions rate-estimation/menu2lib/templates/MuonShowerTemplate.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{#
# @author: Sven Dildick (Rice University)
#}
{# Template for muon showers #}
{# See in: L1Trigger/L1TNtuples/interface/L1AnalysisL1UpgradeDataFormat.h #}

{% block MuonShowerTemplate scoped %}
{% import 'macros.jinja2' as macros %}
{% set object = cond.getObjects()[0] %}
{% set prefix = object | getPrefix %}

bool
{{ cond.getName() }}
(L1Analysis::L1AnalysisL1UpgradeDataFormat* data)
{
bool pass = false;

{# Is there at least one shower object? #}
if (data->nMuonShowers >= 1) {

{# Are signals in same bx? #}
if (data->{{ prefix }}Bx.at(0) == {{ object.getBxOffset() }})
{
{% if cond.getType() == tmEventSetup.MuonShower0 -%}
if (data->{{ prefix }}OneNominal.at(0))
{
pass = true;
}
{% elif cond.getType() == tmEventSetup.MuonShower1 -%}
if (data->{{ prefix }}OneTight.at(0))
{
pass = true;
}
{% elif cond.getType() == tmEventSetup.MuonShowerOutOfTime0 -%}
{# not implemented #}
{% elif cond.getType() == tmEventSetup.MuonShowerOutOfTime1 -%}
{# not implemented #}
{% endif -%}
}
}
return pass;
}
{% endblock MuonShowerTemplate %}
{# eof #}
3 changes: 1 addition & 2 deletions rate-estimation/menu2lib/templates/SignalsTemplate.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{# Template for signal type conditions like centrality or muon showers #}
{# MuonShowerType from L1TNtuples: kInvalid, kOneNominal,kOneTight, kTwoLoose #}
{# Template for signal type conditions like centrality #}
{# See in: L1Trigger/L1TNtuples/interface/L1AnalysisL1UpgradeDataFormat.h #}

{% block SignalsTemplate scoped %}
Expand Down