ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Interfaces
TriggerAnalysisInterfaces
TriggerAnalysisInterfaces
ITrigGlobalEfficiencyCorrectionTool.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// contact: jmaurer@cern.ch
6
7
#ifndef TRIGGERANALYSISINTERFACES_ITRIGGLOBALEFFICIENCYCORRECTIONTOOL_H
8
#define TRIGGERANALYSISINTERFACES_ITRIGGLOBALEFFICIENCYCORRECTIONTOOL_H 1
9
10
#include "
PATInterfaces/ISystematicsTool.h
"
11
#include "
PATInterfaces/CorrectionCode.h
"
12
#include "
xAODEgamma/Electron.h
"
13
#include "
xAODMuon/Muon.h
"
14
#include "
xAODEgamma/Photon.h
"
15
16
#include <vector>
17
#include <type_traits>
18
#include <string_view>
19
20
class
ITrigGlobalEfficiencyCorrectionTool
:
public
virtual
CP::ISystematicsTool
21
{
22
public
:
23
ASG_TOOL_INTERFACE
(
ITrigGlobalEfficiencyCorrectionTool
)
24
25
template
<
typename
Arg>
static
constexpr
bool
validArgs
(
unsigned
nTrailingDoubles);
26
template
<
typename
Arg1,
typename
Arg2,
typename
... OtherArgs>
static
constexpr
bool
validArgs
(
unsigned
nTrailingDoubles);
27
28
virtual
CP::CorrectionCode
getEfficiencyScaleFactor
(
const
std::vector<const xAOD::IParticle*>& particles,
double
& efficiencyScaleFactor) = 0;
29
virtual
CP::CorrectionCode
getEfficiency
(
const
std::vector<const xAOD::IParticle*>& particles,
double
& efficiencyData,
double
& efficiencyMc) = 0;
30
virtual
CP::CorrectionCode
checkTriggerMatching
(
bool
& matched,
const
std::vector<const xAOD::IParticle*>& particles) = 0;
31
virtual
CP::CorrectionCode
checkTriggerMatching
(std::unordered_map<std::string, bool>& matched_per_trigger,
const
std::vector<const xAOD::IParticle*>& particles) = 0;
32
39
template
<
typename
...
Args
>
40
auto
getEfficiencyScaleFactor
(
Args
&... args) -> std::enable_if_t<
validArgs
<
Args
...>(1),
CP::CorrectionCode
>;
41
template
<
typename
...
Args
>
42
auto
getEfficiency
(
Args
&... args) -> std::enable_if_t<
validArgs
<
Args
...>(2),
CP::CorrectionCode
>;
43
template
<
typename
BoolOrMap,
typename
...
Args
>
44
auto
checkTriggerMatching
(BoolOrMap& matched,
Args
&... args) -> std::enable_if_t<
validArgs
<
Args
...>(0),
CP::CorrectionCode
>;
45
47
virtual
CP::CorrectionCode
getRelevantTriggers
(std::vector<std::string>& triggers) = 0;
48
50
virtual
CP::CorrectionCode
countTriggerLegs
(
const
std::string& trigger, std::size_t& numberOfLegs) = 0;
51
53
virtual
CP::CorrectionCode
getEfficiencyScaleFactor
(
unsigned
runNumber,
const
std::vector<const xAOD::IParticle*>& particles,
double
& efficiencyScaleFactor) = 0;
54
virtual
CP::CorrectionCode
getEfficiency
(
unsigned
runNumber,
const
std::vector<const xAOD::IParticle*>& particles,
double
& efficiencyData,
double
& efficiencyMc) = 0;
55
57
static
std::string
toolnameForDefaultScaleFactor
() {
return
"RETURN_DEFAULT_SCALE_FACTOR"
; }
58
protected
:
59
double
*
handleArg
(
double
& arg, std::vector<const xAOD::IParticle*>&) {
return
&arg; }
60
template
<
typename
P>
double
*
handleArg
(
const
std::vector<P>& arg, std::vector<const xAOD::IParticle*>& particles)
61
{
62
for
(
auto
ptr : arg) particles.push_back(
static_cast<
const
xAOD::IParticle
*
>
(ptr));
63
return
nullptr
;
64
}
65
};
66
67
template
<
typename
Arg>
68
constexpr
bool
ITrigGlobalEfficiencyCorrectionTool::validArgs
(
unsigned
nTrailingDoubles)
69
{
70
if
(std::is_same<double, Arg>::value)
return
(nTrailingDoubles==1);
71
using
P
= std::remove_cv_t<Arg>;
72
return
std::is_same<P, std::vector<xAOD::Electron*>>::value
73
|| std::is_same<P, std::vector<const xAOD::Electron*>>::value
74
|| std::is_same<P, std::vector<xAOD::Muon*>>::value
75
|| std::is_same<P, std::vector<const xAOD::Muon*>>::value
76
|| std::is_same<P, std::vector<xAOD::Photon*>>::value
77
|| std::is_same<P, std::vector<const xAOD::Photon*>>::value;
78
}
79
80
template
<
typename
Arg1,
typename
Arg2,
typename
... OtherArgs>
81
constexpr
bool
ITrigGlobalEfficiencyCorrectionTool::validArgs
(
unsigned
nTrailingDoubles)
82
{
83
bool
xs [] = { std::is_same<OtherArgs, double>::value...,
true
};
84
for
(
bool
x
: xs)
if
(!
x
)
return
validArgs<Arg1>
(0) &&
validArgs
<Arg2, OtherArgs...>(nTrailingDoubles);
85
unsigned
nTD =
sizeof
...(OtherArgs);
86
if
(nTD == nTrailingDoubles)
return
validArgs<Arg1>
(0) &&
validArgs<Arg2>
(0);
87
if
(nTD == nTrailingDoubles-1)
return
validArgs<Arg1>
(0) && std::is_same<Arg2, double>::value;
88
if
(nTD == nTrailingDoubles-2)
return
std::is_same<Arg1, double>::value && std::is_same<Arg2, double>::value;
89
return
false
;
90
}
91
92
template
<
typename
...
Args
>
93
auto
ITrigGlobalEfficiencyCorrectionTool::getEfficiencyScaleFactor
(
Args
&... args)
94
-> std::enable_if_t<
validArgs
<
Args
...>(1),
CP::CorrectionCode
>
95
{
96
std::vector<const xAOD::IParticle*> particles;
97
double
* sf[] = {
nullptr
,
handleArg
(args, particles)... };
98
return
getEfficiencyScaleFactor
(particles, *sf[
sizeof
...(
Args
)]);
99
}
100
101
template
<
typename
...
Args
>
102
auto
ITrigGlobalEfficiencyCorrectionTool::getEfficiency
(
Args
&... args)
103
-> std::enable_if_t<
validArgs
<
Args
...>(2),
CP::CorrectionCode
>
104
{
105
std::vector<const xAOD::IParticle*> particles;
106
double
* eff[] = {
nullptr
,
handleArg
(args, particles)... };
107
return
getEfficiency
(particles, *eff[
sizeof
...(
Args
)-1], *eff[
sizeof
...(
Args
)]);
108
}
109
110
template
<
typename
BoolOrMap,
typename
...
Args
>
111
auto
ITrigGlobalEfficiencyCorrectionTool::checkTriggerMatching
(BoolOrMap& matched,
Args
&... args)
112
-> std::enable_if_t<
validArgs
<
Args
...>(0),
CP::CorrectionCode
>
113
{
114
std::vector<const xAOD::IParticle*> particles;
115
double
* eff[]
__attribute__
((
unused
)) = {
nullptr
,
handleArg
(args, particles)... };
116
return
checkTriggerMatching
(matched, particles);
117
}
118
119
#endif
//> !TRIGGERANALYSISINTERFACES_ITRIGGLOBALEFFICIENCYCORRECTIONTOOL_H
ASG_TOOL_INTERFACE
#define ASG_TOOL_INTERFACE(CLASSNAME)
Definition
AsgToolMacros.h:40
CorrectionCode.h
Electron.h
Photon.h
Muon.h
ISystematicsTool.h
P
static Double_t P(Double_t *tt, Double_t *par)
Definition
LArPhysWaveHECTool.cxx:280
__attribute__
__attribute__((always_inline)) inline uint16_t TileCalibDrawerBase
Definition
TileCalibDrawerBase.h:192
x
#define x
unused
void unused(Args &&...)
Definition
VP1ExpertSettings.cxx:39
CP::CorrectionCode
Return value from object correction CP tools.
Definition
CorrectionCode.h:31
CP::ISystematicsTool
Interface for all CP tools supporting systematic variations.
Definition
ISystematicsTool.h:32
ITrigGlobalEfficiencyCorrectionTool
Definition
ITrigGlobalEfficiencyCorrectionTool.h:21
ITrigGlobalEfficiencyCorrectionTool::handleArg
double * handleArg(const std::vector< P > &arg, std::vector< const xAOD::IParticle * > &particles)
Definition
ITrigGlobalEfficiencyCorrectionTool.h:60
ITrigGlobalEfficiencyCorrectionTool::getEfficiency
virtual CP::CorrectionCode getEfficiency(const std::vector< const xAOD::IParticle * > &particles, double &efficiencyData, double &efficiencyMc)=0
ITrigGlobalEfficiencyCorrectionTool::countTriggerLegs
virtual CP::CorrectionCode countTriggerLegs(const std::string &trigger, std::size_t &numberOfLegs)=0
This utility function provides the number of legs for the specified trigger.
ITrigGlobalEfficiencyCorrectionTool::checkTriggerMatching
virtual CP::CorrectionCode checkTriggerMatching(bool &matched, const std::vector< const xAOD::IParticle * > &particles)=0
ITrigGlobalEfficiencyCorrectionTool::getEfficiencyScaleFactor
virtual CP::CorrectionCode getEfficiencyScaleFactor(unsigned runNumber, const std::vector< const xAOD::IParticle * > &particles, double &efficiencyScaleFactor)=0
These should in principle not be used (except by unit tests), as the CP tools require the EventInfo d...
ITrigGlobalEfficiencyCorrectionTool::checkTriggerMatching
virtual CP::CorrectionCode checkTriggerMatching(std::unordered_map< std::string, bool > &matched_per_trigger, const std::vector< const xAOD::IParticle * > &particles)=0
ITrigGlobalEfficiencyCorrectionTool::handleArg
double * handleArg(double &arg, std::vector< const xAOD::IParticle * > &)
Definition
ITrigGlobalEfficiencyCorrectionTool.h:59
ITrigGlobalEfficiencyCorrectionTool::toolnameForDefaultScaleFactor
static std::string toolnameForDefaultScaleFactor()
To be used with the ListOfLegsPerTool property:
Definition
ITrigGlobalEfficiencyCorrectionTool.h:57
ITrigGlobalEfficiencyCorrectionTool::getRelevantTriggers
virtual CP::CorrectionCode getRelevantTriggers(std::vector< std::string > &triggers)=0
This will fill the 'triggers' argument with the names of the triggers relevant for the current run nu...
ITrigGlobalEfficiencyCorrectionTool::getEfficiencyScaleFactor
virtual CP::CorrectionCode getEfficiencyScaleFactor(const std::vector< const xAOD::IParticle * > &particles, double &efficiencyScaleFactor)=0
ITrigGlobalEfficiencyCorrectionTool::validArgs
static constexpr bool validArgs(unsigned nTrailingDoubles)
Definition
ITrigGlobalEfficiencyCorrectionTool.h:68
ITrigGlobalEfficiencyCorrectionTool::getEfficiency
virtual CP::CorrectionCode getEfficiency(unsigned runNumber, const std::vector< const xAOD::IParticle * > &particles, double &efficiencyData, double &efficiencyMc)=0
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
Args
Definition
test_lwtnn_fastgraph.cxx:12
Generated on
for ATLAS Offline Software by
1.17.0