7#ifndef TRIGGLOBALEFFICIENCYCORRECTION_TRIGGER_H
8#define TRIGGLOBALEFFICIENCYCORRECTION_TRIGGER_H 1
79 template <
typename Array>
82 throw std::runtime_error(
85 std::fill(dest.begin(), dest.end(), 0);
133 template <
typename T>
233 template <
bool = true>
236 "this function is not meaningful for this type of trigger, "
237 "hence should not be used.");
243 template <
bool = true>
245 static_assert(
is1L(),
246 "this function is not meaningful for this type of trigger, "
247 "hence should not be used.");
251 explicit operator bool()
const {
252 return std::all_of(
legs.cbegin(),
legs.cend(),
253 [](std::size_t
x) ->
bool { return x; });
258 template <xAOD::Type::ObjectType obj =
object()>
263 template <xAOD::Type::ObjectType obj =
object()>
268 template <
typename Trig1L>
270 typename std::enable_if<Trig1L::is1L(),
bool>
::type {
271 static_assert(Trig1L::is1L(),
272 "this function is not meaningful for this type of trigger, "
273 "hence should not be used.");
274 constexpr auto obj = Trig1L::object();
278 template <
typename Trig1L>
279 auto hiddenBy(
const std::flat_set<Trig1L>& trigs)
const ->
280 typename std::enable_if<Trig1L::is1L(),
bool>
::type {
281 static_assert(Trig1L::is1L(),
282 "this function is not meaningful for this type of trigger, "
283 "hence should not be used.");
284 return std::any_of(trigs.cbegin(), trigs.cend(),
285 [&](Trig1L t) ->
bool { return hiddenBy(t); });
290 template <xAOD::Type::ObjectType obj,
bool anti = false>
291 auto side()
const ->
std::conditional_t<anti ^ (CastType1::
object() == obj),
292 CastType1, CastType2> {
293 static_assert(
mixed(),
294 "this function is not meaningful for this type of trigger, "
295 "hence should not be used.");
299 std::copy_n(this->
cbegin<CastType::object()>(),
305 template <
typename TrigX>
310 template <
typename TrigX>
318 template <
typename Trig1L>
319 auto addTo(
const std::flat_set<Trig1L>& trigs1L)
const
320 -> std::enable_if_t<Trig1L::is1L() &&
322 std::flat_set<Trig1L>> {
323 static_assert(
mixed(),
324 "this function is not meaningful for this type of trigger, "
325 "hence should not be used.");
326 std::flat_set<Trig1L> trigs(trigs1L);
331 template <
typename Trig1L>
332 static auto anonymize(
const std::flat_set<Trig1L>& triggers)
333 -> std::enable_if_t<
is1L() && tt == Trig1L::type(),
334 const std::flat_set<std::size_t>&> {
335 static_assert(
sizeof(Trig1L) ==
sizeof(std::size_t),
336 "invalid cast if the key sizes differ");
337 return reinterpret_cast<const std::flat_set<std::size_t>&
>(triggers);
340 template <
bool = true>
342 static_assert(!std::is_same<CastType1, UnusedArg>::value,
343 "this function is not meaningful for this type of trigger, "
344 "hence should not be used.");
345 return std::all_of(
legs.cbegin() + 1,
legs.cend(),
346 [&](std::size_t l) ->
bool { return l == legs[0]; });
349 template <
bool = true>
351 static_assert(!std::is_same<CastType1, UnusedArg>::value,
352 "this function is not meaningful for this type of trigger, "
353 "hence should not be used.");
355 trig.legs[0] = this->legs[0];
359 template <
bool = true>
362 "this function is not meaningful for this type of trigger, "
363 "hence should not be used.");
367 template <
bool = true>
370 "this function is not meaningful for this type of trigger, "
371 "hence should not be used.");
376template <TriggerType, TriggerType = TT_UNKNOWN>
379template <TriggerType
object_flag>
386 struct T_1 :
public Trigger<addObjFlag(TT_SINGLELEPTON_FLAG)> {};
400template <TriggerType
object1_flag, TriggerType
object2_flag>
405 return static_cast<TriggerType>(tt | object1_flag | object2_flag);
410 struct T_1_1 :
public Trigger<addObjFlags(TT_DILEPTON_FLAG), typename A::T_1,
414 typename A::T_2sym, typename B::T_1> {};
417 typename A::T_2asym, typename B::T_1> {};
420 typename A::T_1, typename B::T_2sym> {};
423 typename A::T_1, typename B::T_2asym> {};
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
static constexpr xAOD::Type::ObjectType object1()
auto addTo(const std::flat_set< Trig1L > &trigs1L) const -> std::enable_if_t< Trig1L::is1L() &&nDistinctLegs(Trig1L::object())==1, std::flat_set< Trig1L > >
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 std::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 auto anonymize(const std::flat_set< Trig1L > &triggers) -> std::enable_if_t< is1L() &&tt==Trig1L::type(), const std::flat_set< std::size_t > & >
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
Trigger(const ImportData::TrigDef &def)
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