7#ifndef TRIGGLOBALEFFICIENCYCORRECTION_TRIGGER_H
8#define TRIGGLOBALEFFICIENCYCORRECTION_TRIGGER_H 1
12#include <boost/container/flat_set.hpp>
17template <
typename Key>
18using flat_set = boost::container::flat_set<Key>;
81 template <
typename Array>
84 throw std::runtime_error(
87 std::fill(dest.begin(), dest.end(), 0);
135 template <
typename T>
229 template <
bool = true>
232 "this function is not meaningful for this type of trigger, "
233 "hence should not be used.");
239 template <
bool = true>
241 static_assert(
is1L(),
242 "this function is not meaningful for this type of trigger, "
243 "hence should not be used.");
247 explicit operator bool()
const {
248 return std::all_of(
legs.cbegin(),
legs.cend(),
249 [](std::size_t
x) ->
bool { return x; });
254 template <xAOD::Type::ObjectType obj =
object()>
259 template <xAOD::Type::ObjectType obj =
object()>
264 template <
typename Trig1L>
266 typename std::enable_if<Trig1L::is1L(),
bool>
::type {
267 static_assert(Trig1L::is1L(),
268 "this function is not meaningful for this type of trigger, "
269 "hence should not be used.");
270 constexpr auto obj = Trig1L::object();
274 template <
typename Trig1L>
276 typename std::enable_if<Trig1L::is1L(),
bool>
::type {
277 static_assert(Trig1L::is1L(),
278 "this function is not meaningful for this type of trigger, "
279 "hence should not be used.");
280 return std::any_of(trigs.cbegin(), trigs.cend(),
281 [&](Trig1L t) ->
bool { return hiddenBy(t); });
286 template <xAOD::Type::ObjectType obj,
bool anti = false>
287 auto side()
const ->
std::conditional_t<anti ^ (CastType1::
object() == obj),
288 CastType1, CastType2> {
289 static_assert(
mixed(),
290 "this function is not meaningful for this type of trigger, "
291 "hence should not be used.");
295 std::copy_n(this->
cbegin<CastType::object()>(),
301 template <
typename TrigX>
306 template <
typename TrigX>
314 template <
typename Trig1L>
316 -> std::enable_if_t<Trig1L::is1L() &&
319 static_assert(
mixed(),
320 "this function is not meaningful for this type of trigger, "
321 "hence should not be used.");
327 template <
typename Trig1L>
329 -> std::enable_if_t<
is1L() && tt == Trig1L::type(),
331 static_assert(
sizeof(Trig1L) ==
sizeof(std::size_t),
332 "invalid cast if the key sizes differ");
336 template <
bool = true>
338 static_assert(!std::is_same<CastType1, UnusedArg>::value,
339 "this function is not meaningful for this type of trigger, "
340 "hence should not be used.");
341 return std::all_of(
legs.cbegin() + 1,
legs.cend(),
342 [&](std::size_t l) ->
bool { return l == legs[0]; });
345 template <
bool = true>
347 static_assert(!std::is_same<CastType1, UnusedArg>::value,
348 "this function is not meaningful for this type of trigger, "
349 "hence should not be used.");
351 trig.legs[0] = this->legs[0];
355 template <
bool = true>
358 "this function is not meaningful for this type of trigger, "
359 "hence should not be used.");
363 template <
bool = true>
366 "this function is not meaningful for this type of trigger, "
367 "hence should not be used.");
372template <TriggerType, TriggerType = TT_UNKNOWN>
375template <TriggerType
object_flag>
382 struct T_1 :
public Trigger<addObjFlag(TT_SINGLELEPTON_FLAG)> {};
396template <TriggerType
object1_flag, TriggerType
object2_flag>
401 return static_cast<TriggerType>(tt | object1_flag | object2_flag);
406 struct T_1_1 :
public Trigger<addObjFlags(TT_DILEPTON_FLAG), typename A::T_1,
410 typename A::T_2sym, typename B::T_1> {};
413 typename A::T_2asym, typename B::T_1> {};
416 typename A::T_1, typename B::T_2sym> {};
419 typename A::T_1, typename B::T_2asym> {};
boost::container::flat_set< Key > flat_set
xAOD::Type::ObjectType type() const
constexpr TriggerType type() const
constexpr auto cbegin(xAOD::Type::ObjectType obj) const
constexpr int cbegin_offset(xAOD::Type::ObjectType obj) const
constexpr unsigned nDistinctLegs() const
TriggerProperties(const ImportData::TrigDef &def)
constexpr auto cend(xAOD::Type::ObjectType obj) const
std::array< std::size_t, 4 > m_legs
constexpr bool mixed() const
void loadLegs(const ImportData::TrigDef &src, Array &dest)
constexpr unsigned nDistinctLegs(xAOD::Type::ObjectType obj) const
constexpr TriggerProperties(TriggerType tt)
constexpr int cend_offset(xAOD::Type::ObjectType obj) const
constexpr bool valid() const
static bool irrelevantFor(const Lepton &lepton)
static constexpr unsigned nDistinctLegs(xAOD::Type::ObjectType obj)
static constexpr bool mixed()
std::array< std::size_t, nDistinctLegs()> legs
auto addTo(const flat_set< Trig1L > &trigs1L) const -> std::enable_if_t< Trig1L::is1L() &&nDistinctLegs(Trig1L::object())==1, flat_set< Trig1L > >
static constexpr xAOD::Type::ObjectType object1()
static constexpr bool is3Lhalfsym()
CastType1 to_symmetric() const
static constexpr xAOD::Type::ObjectType object2()
static constexpr bool is2Lmix()
static constexpr TriggerType type()
auto hiddenBy(const flat_set< Trig1L > &trigs) const -> typename std::enable_if< Trig1L::is1L(), bool >::type
auto hiddenBy(const Trig1L trig) const -> typename std::enable_if< Trig1L::is1L(), bool >::type
CastType1 side1() const
Returns a pseudo trigger of type CastType1/2.
auto side() const -> std::conditional_t< anti ^(CastType1::object()==obj), CastType1, CastType2 >
Returns a pseudo trigger built only from the legs of flavour 'obj' If anti==true, uses instead only l...
void setDefinition(const ImportData::TrigDef &def)
static constexpr bool is2Lsym()
static constexpr bool is2Lnomix()
std::size_t operator()(unsigned index) const
static constexpr bool is4Lsym()
std::size_t operator()(void) const
constexpr auto cbegin() const
static constexpr unsigned nDistinctLegs()
static constexpr bool is3Lmix()
auto antiside() const -> decltype(side< TrigX::object(), true >())
Complement to the previous function.
std::size_t asymLeg() const
constexpr auto cend() const
static auto anonymize(const flat_set< Trig1L > &triggers) -> std::enable_if_t< is1L() &&tt==Trig1L::type(), const flat_set< std::size_t > & >
static constexpr bool is1L()
static constexpr xAOD::Type::ObjectType object()
static constexpr bool is3Lsym()
std::size_t operator<(const Trigger &rhs) const
static constexpr bool is2Lasym()
static constexpr bool extraCheck(xAOD::Type::ObjectType obj)
bool operator==(const Trigger &rhs) const
auto side() const -> decltype(side< TrigX::object()>())
Returns a pseudo trigger built only from the legs of the same flavour as the trigger 'TrigX'.
std::size_t symLeg() const
static bool relevantFor(const Lepton &lepton)
static constexpr xAOD::Type::ObjectType object()
the template specializations below must be enclosed in this namespace
ObjectType
Type of objects that have a representation in the xAOD EDM.
@ Photon
The object is a photon.
@ Other
An object not falling into any of the other categories.
@ Muon
The object is a muon.
@ Electron
The object is an electron.
mixed-flavour dilepton trigger (e17_lhloose_nod0_mu14, e7_lhmedium_mu24, ...):
mixed-flavour trilepton trigger type x_y_y
mixed-flavour trilepton trigger type x_2y (e12_lhloose_2mu10, ...)
mixed-flavour trilepton trigger type x_x_y
mixed-flavour trilepton trigger type 2x_y (2e12_lhloose_mu10, ...)
single-lepton trigger (e24_lhmedium_L1EM20VH, mu24_imedium_OR_mu40...)
asymmetric dilepton trigger (mu18_mu8noL1, g35_loose_g25_loose, ...):
symmetric dilepton trigger (2e17_lhvloose_nod0, 2mu14...)
half-symmetric trilepton trigger (e17_lhloose_2e9_lhloose, mu6_2mu4, ...):
symmetric trilepton trigger (3mu6, ...):
symmetric tetralepton trigger (4mu4, ...):
static constexpr auto addObjFlag(int tt)
TriggerClass< object2_flag > B
static constexpr auto addObjFlags(int tt)
TriggerClass< object1_flag > A