ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
LeptonTaggers
LeptonTaggers
PromptUtils.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef PROMPT_PROMPTUTILS_H
6
#define PROMPT_PROMPTUTILS_H
7
8
/**********************************************************************************
9
* @Package: LeptonTaggers
10
* @Class : PromptUtils
11
* @Author : Rustem Ospanov
12
* @Author : Rhys Roberts
13
*
14
* @Brief :
15
*
16
* Helper functions
17
*
18
**********************************************************************************/
19
20
// Local
21
#include "
VarHolder.h
"
22
23
// Athena
24
#include "
AthContainers/AuxElement.h
"
25
#include "GaudiKernel/MsgStream.h"
26
#include "
xAODTracking/TrackParticle.h
"
27
#include "
xAODTracking/Vertex.h
"
28
29
// ROOT
30
#include "TStopwatch.h"
31
#include "TH1.h"
32
33
// C/C++
34
#include <string>
35
36
namespace
Prompt
37
{
38
//=============================================================================
39
double
getVertexFitProb
(
const
xAOD::Vertex
*vtx);
40
41
std::string
vtxAsStr
(
const
xAOD::Vertex
*vtx,
bool
print_tracks=
false
);
42
std::string
trkAsStr
(
const
xAOD::TrackParticle
*trk);
43
44
std::string
truthAsStr
(
const
xAOD::IParticle &particle);
45
46
double
getDistance
(
const
xAOD::Vertex
*vtx1,
const
xAOD::Vertex
*vtx2);
47
double
getDistance
(
const
Amg::Vector3D
&vtx1,
const
Amg::Vector3D
&vtx2);
48
49
double
getNormDist
(
const
Amg::Vector3D
&PrimVtx,
const
Amg::Vector3D
&SecVtx,
const
std::vector<float> &ErrorMatrix, MsgStream &
msg
);
50
51
void
fillTH1
(TH1 *h,
double
val,
double
weight = 1.0);
52
53
std::string
printPromptVertexAsStr
(
const
xAOD::Vertex
*vtx, MsgStream &
msg
);
54
55
//=============================================================================
56
struct
SortByIDTrackPt
57
{
58
bool
operator()
(
const
xAOD::TrackParticle
*lhs,
const
xAOD::TrackParticle
*rhs) {
return
lhs->
pt
() > rhs->
pt
(); }
59
};
60
61
//=============================================================================
62
template
<
class
T1,
class
T2>
bool
getVar
(T1 &obj, T2 &value,
const
std::string &var_name)
63
{
64
if
(!obj) {
65
std::cerr <<
"getVar - received a null object"
<< std::endl;
66
return
false
;
67
}
68
69
//
70
// get the int aux-variable
71
//
72
typename
SG::AuxElement::Accessor<T2> acc(var_name);
73
74
if
(!acc.isAvailable(*obj)) {
75
return
false
;
76
}
77
78
value = acc(*obj);
79
return
true
;
80
}
81
82
//=============================================================================
83
template
<
class
T1,
class
T2>
bool
GetAuxVar
(
const
T1 &obj, T2 &value,
const
std::string &var_name)
84
{
85
//
86
// get the int aux-variable
87
//
88
typename
SG::AuxElement::Accessor<T2> acc(var_name);
89
90
if
(!acc.isAvailable(obj)) {
91
return
false
;
92
}
93
94
value = acc(obj);
95
return
true
;
96
}
97
98
//=============================================================================
99
std::string
PrintResetStopWatch
(TStopwatch &watch);
100
101
class
TimerScopeHelper
102
{
103
public
:
104
105
explicit
TimerScopeHelper
(TStopwatch &timer)
106
:
m_fTimer
(timer) {
m_fTimer
.Start(
false
); }
107
~TimerScopeHelper
() {
m_fTimer
.Stop(); }
108
109
private
:
110
111
TStopwatch &
m_fTimer
;
112
};
113
114
115
//======================================================================================================
116
struct
SortObjectByVar
117
{
118
explicit
SortObjectByVar
(
const
unsigned
v, MsgStream &m,
bool
inverse=
false
):
m_var
(v),
m_inv
(inverse),
m_msg
(m) {}
119
120
template
<
class
T>
bool
operator()
(
const
T &lhs,
const
T &rhs)
121
{
122
double
val_rhs = 0.0;
123
double
val_lhs = 0.0;
124
125
if
(!lhs.getVar(
m_var
, val_lhs) || !rhs.getVar(
m_var
, val_rhs)) {
126
m_msg
<< MSG::WARNING <<
"SortObjectByVar - missing var"
<< std::endl;
127
}
128
129
if
(
m_inv
) {
130
return
val_lhs > val_rhs;
131
}
132
133
return
val_lhs < val_rhs;
134
}
135
136
private
:
137
138
SortObjectByVar
();
139
140
unsigned
m_var
;
141
bool
m_inv
;
142
MsgStream &
m_msg
;
143
144
};
145
}
146
147
#endif
//PROMPT_PROMPTUTILS_H
AuxElement.h
Base class for elements of a container that can have aux data.
TrackParticle.h
Vertex.h
VarHolder.h
Prompt::TimerScopeHelper::TimerScopeHelper
TimerScopeHelper(TStopwatch &timer)
Definition
PromptUtils.h:105
Prompt::TimerScopeHelper::~TimerScopeHelper
~TimerScopeHelper()
Definition
PromptUtils.h:107
Prompt::TimerScopeHelper::m_fTimer
TStopwatch & m_fTimer
Definition
PromptUtils.h:111
xAOD::TrackParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition
TrackParticle_v1.cxx:75
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
Prompt
Definition
DecoratePLIT.h:29
Prompt::GetAuxVar
bool GetAuxVar(const T1 &obj, T2 &value, const std::string &var_name)
Definition
PromptUtils.h:83
Prompt::PrintResetStopWatch
std::string PrintResetStopWatch(TStopwatch &watch)
Definition
PromptUtils.cxx:244
Prompt::fillTH1
void fillTH1(TH1 *h, double val, double weight=1.0)
Definition
PromptUtils.cxx:104
Prompt::trkAsStr
std::string trkAsStr(const xAOD::TrackParticle *trk)
Definition
PromptUtils.cxx:228
Prompt::printPromptVertexAsStr
std::string printPromptVertexAsStr(const xAOD::Vertex *vtx, MsgStream &msg)
Definition
PromptUtils.cxx:127
Prompt::getVertexFitProb
double getVertexFitProb(const xAOD::Vertex *vtx)
Definition
PromptUtils.cxx:21
Prompt::truthAsStr
std::string truthAsStr(const xAOD::IParticle &particle)
Definition
PromptUtils.cxx:213
Prompt::getVar
bool getVar(T1 &obj, T2 &value, const std::string &var_name)
Definition
PromptUtils.h:62
Prompt::vtxAsStr
std::string vtxAsStr(const xAOD::Vertex *vtx, bool print_tracks=false)
Definition
PromptUtils.cxx:172
Prompt::getNormDist
double getNormDist(const Amg::Vector3D &PrimVtx, const Amg::Vector3D &SecVtx, const std::vector< float > &ErrorMatrix, MsgStream &msg)
Definition
PromptUtils.cxx:57
Prompt::getDistance
double getDistance(const xAOD::Vertex *vtx1, const xAOD::Vertex *vtx2)
Definition
PromptUtils.cxx:41
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition
Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
Prompt::SortByIDTrackPt
Definition
PromptUtils.h:57
Prompt::SortByIDTrackPt::operator()
bool operator()(const xAOD::TrackParticle *lhs, const xAOD::TrackParticle *rhs)
Definition
PromptUtils.h:58
Prompt::SortObjectByVar::m_msg
MsgStream & m_msg
Definition
PromptUtils.h:142
Prompt::SortObjectByVar::operator()
bool operator()(const T &lhs, const T &rhs)
Definition
PromptUtils.h:120
Prompt::SortObjectByVar::SortObjectByVar
SortObjectByVar(const unsigned v, MsgStream &m, bool inverse=false)
Definition
PromptUtils.h:118
Prompt::SortObjectByVar::m_var
unsigned m_var
Definition
PromptUtils.h:140
Prompt::SortObjectByVar::SortObjectByVar
SortObjectByVar()
Prompt::SortObjectByVar::m_inv
bool m_inv
Definition
PromptUtils.h:141
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0