ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::EGTransverseMassTool Class Reference

#include <EGTransverseMassTool.h>

Inheritance diagram for DerivationFramework::EGTransverseMassTool:
Collaboration diagram for DerivationFramework::EGTransverseMassTool:

Public Member Functions

virtual StatusCode initialize () override final
virtual StatusCode addBranches (const EventContext &ctx) const override final

Private Member Functions

StatusCode getTransverseMasses (const EventContext &ctx, std::vector< float > &) const

Private Attributes

Gaudi::Property< std::string > m_expression1 {this, "ObjectRequirements", "true"}
Gaudi::Property< float > m_METmin {this, "METmin", -999.f}
Gaudi::Property< float > m_mass1Hypothesis {this, "ObjectMassHypothesis", 0.f}
SG::WriteHandleKey< std::vector< float > > m_sgName
SG::ReadHandleKey< xAOD::IParticleContainerm_container1Name
SG::ReadHandleKey< xAOD::MissingETContainerm_container2Name
SG::ReadHandleKey< std::vector< float > > m_pt1BranchName
SG::ReadHandleKey< std::vector< float > > m_phi1BranchName
SG::ReadHandleKey< std::vector< float > > m_pt2BranchName
SG::ReadHandleKey< std::vector< float > > m_phi2BranchName

Detailed Description

Definition at line 27 of file EGTransverseMassTool.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::EGTransverseMassTool::addBranches ( const EventContext & ctx) const
finaloverridevirtual

Definition at line 70 of file EGTransverseMassTool.cxx.

71{
72 SG::WriteHandle<std::vector<float>> writeHandle{ m_sgName, ctx };
73
74 // create the vector which will hold the values invariant masses
75 auto masses = std::make_unique<std::vector<float>>();
76 // compute the invariant mass values
77 ATH_CHECK(getTransverseMasses(ctx, *masses));
78
79 ATH_CHECK(writeHandle.record(std::move(masses)));
80
81 return StatusCode::SUCCESS;
82}
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::WriteHandleKey< std::vector< float > > m_sgName
StatusCode getTransverseMasses(const EventContext &ctx, std::vector< float > &) const
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.

◆ getTransverseMasses()

StatusCode DerivationFramework::EGTransverseMassTool::getTransverseMasses ( const EventContext & ctx,
std::vector< float > & masses ) const
private

Definition at line 85 of file EGTransverseMassTool.cxx.

87{
88 // Get optional payload
89 const std::vector<float>* pt1 = nullptr;
90 if (!m_pt1BranchName.key().empty()) {
91 SG::ReadHandle<std::vector<float>> readHandle{ m_pt1BranchName, ctx };
92 pt1 = readHandle.ptr();
93 }
94 const std::vector<float>* pt2 = nullptr;
95 if (!m_pt2BranchName.key().empty()) {
96 SG::ReadHandle<std::vector<float>> readHandle{ m_pt2BranchName, ctx };
97 pt2 = readHandle.ptr();
98 }
99
100 const std::vector<float>* phi1 = nullptr;
101 if (!m_phi1BranchName.key().empty()) {
102 SG::ReadHandle<std::vector<float>> readHandle{ m_phi1BranchName, ctx };
103 phi1 = readHandle.ptr();
104 }
105 const std::vector<float>* phi2 = nullptr;
106 if (!m_phi2BranchName.key().empty()) {
107 SG::ReadHandle<std::vector<float>> readHandle{ m_phi2BranchName, ctx };
108 phi2 = readHandle.ptr();
109 }
110
111 // Get the input particle and MET
112 SG::ReadHandle<xAOD::IParticleContainer> inputParticles1{ m_container1Name,
113 ctx };
114 SG::ReadHandle<xAOD::MissingETContainer> inputParticles2{ m_container2Name,
115 ctx };
116 const xAOD::IParticleContainer* particles1 = inputParticles1.ptr();
117 const xAOD::MissingETContainer* particles2 = inputParticles2.ptr();
118
119 // compute MET
120 if (particles2->empty()) {
121 if (!pt2) {
122 ATH_MSG_WARNING("No MET info found");
123 return StatusCode::SUCCESS;
124 }
125 if (pt2->empty()) {
126 ATH_MSG_WARNING("No MET info found");
127 return StatusCode::SUCCESS;
128 }
129 }
130
131 float MET = pt2 ? (*pt2)[0] : particles2->at(0)->met();
132 float MET_phi = phi2 ? (*phi2)[0] : particles2->at(0)->phi();
133
134 // apply MET requirement
135 if (MET < m_METmin)
136 return StatusCode::SUCCESS;
137
138 // get the positions of the particles which pass the requirement
139 std::vector<int> entries1 = m_parser->evaluateAsVector();
140 unsigned int nEntries1 = entries1.size();
141
142 // if there are no particles in one of the two lists to combine, just leave
143 // function
144 if (nEntries1 == 0)
145 return StatusCode::SUCCESS;
146
147 // check that the sizes are compatible
148 if (particles1->size() != nEntries1) {
149 ATH_MSG_ERROR("Branch sizes incompatible - returning zero");
150 return StatusCode::FAILURE;
151 }
152 if ((pt1 && pt1->size() != nEntries1) ||
153 (phi1 && phi1->size() != nEntries1)) {
154 ATH_MSG_ERROR("Branch sizes incompatible - returning zero");
155 return StatusCode::FAILURE;
156 }
157
158 // Loop over the objects and calculate the transverse mass
159 unsigned int iter;
160 for (iter = 0; iter < nEntries1; ++iter) {
161 if (entries1[iter] != 1)
162 continue;
163 float apt1 = pt1 ? (*pt1)[iter] : ((*particles1)[iter])->p4().Pt();
164 float aphi1 = phi1 ? (*phi1)[iter] : ((*particles1)[iter])->p4().Phi();
165
166 TLorentzVector v1, v2;
167 v1.SetPtEtaPhiM(apt1, 0., aphi1, m_mass1Hypothesis);
168 v2.SetPtEtaPhiM(MET, 0., MET_phi, 0.);
169 float mass = (v1 + v2).M();
170 masses.push_back(mass);
171 }
172 return StatusCode::SUCCESS;
173}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
SG::ReadHandleKey< std::vector< float > > m_phi1BranchName
SG::ReadHandleKey< std::vector< float > > m_phi2BranchName
SG::ReadHandleKey< std::vector< float > > m_pt1BranchName
SG::ReadHandleKey< std::vector< float > > m_pt2BranchName
SG::ReadHandleKey< xAOD::IParticleContainer > m_container1Name
SG::ReadHandleKey< xAOD::MissingETContainer > m_container2Name
const_pointer_type ptr()
Dereference the pointer.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.

◆ initialize()

StatusCode DerivationFramework::EGTransverseMassTool::initialize ( )
finaloverridevirtual

Definition at line 36 of file EGTransverseMassTool.cxx.

37{
38 if (m_sgName.key().empty()) {
40 "No SG name provided for the output of the transverse mass tool!");
41 return StatusCode::FAILURE;
42 }
43 ATH_CHECK(m_sgName.initialize());
44
45 if (!m_container1Name.key().empty()) {
46 ATH_CHECK(m_container1Name.initialize());
47 }
48 if (!m_container2Name.key().empty()) {
49 ATH_CHECK(m_container2Name.initialize());
50 }
51 if (!m_pt1BranchName.key().empty()) {
52 ATH_CHECK(m_pt1BranchName.initialize());
53 }
54 if (!m_phi1BranchName.key().empty()) {
55 ATH_CHECK(m_phi1BranchName.initialize());
56 }
57 if (!m_pt2BranchName.key().empty()) {
58 ATH_CHECK(m_pt2BranchName.initialize());
59 }
60 if (!m_phi2BranchName.key().empty()) {
61 ATH_CHECK(m_phi2BranchName.initialize());
62 }
63
64 ATH_CHECK(initializeParser(m_expression1));
65
66 return StatusCode::SUCCESS;
67}
Gaudi::Property< std::string > m_expression1

Member Data Documentation

◆ m_container1Name

SG::ReadHandleKey<xAOD::IParticleContainer> DerivationFramework::EGTransverseMassTool::m_container1Name
private
Initial value:
{
this,
"ObjectContainerName",
"",
"SG key of first container"
}

Definition at line 48 of file EGTransverseMassTool.h.

48 {
49 this,
50 "ObjectContainerName",
51 "",
52 "SG key of first container"
53 };

◆ m_container2Name

SG::ReadHandleKey<xAOD::MissingETContainer> DerivationFramework::EGTransverseMassTool::m_container2Name
private
Initial value:
{
this,
"METContainerName",
"MET_LocHadTopo",
"SG key of second container"
}

Definition at line 54 of file EGTransverseMassTool.h.

54 {
55 this,
56 "METContainerName",
57 "MET_LocHadTopo",
58 "SG key of second container"
59 };

◆ m_expression1

Gaudi::Property<std::string> DerivationFramework::EGTransverseMassTool::m_expression1 {this, "ObjectRequirements", "true"}
private

Definition at line 39 of file EGTransverseMassTool.h.

39{this, "ObjectRequirements", "true"};

◆ m_mass1Hypothesis

Gaudi::Property<float> DerivationFramework::EGTransverseMassTool::m_mass1Hypothesis {this, "ObjectMassHypothesis", 0.f}
private

Definition at line 41 of file EGTransverseMassTool.h.

41{this, "ObjectMassHypothesis", 0.f};

◆ m_METmin

Gaudi::Property<float> DerivationFramework::EGTransverseMassTool::m_METmin {this, "METmin", -999.f}
private

Definition at line 40 of file EGTransverseMassTool.h.

40{this, "METmin", -999.f};

◆ m_phi1BranchName

SG::ReadHandleKey<std::vector<float> > DerivationFramework::EGTransverseMassTool::m_phi1BranchName
private
Initial value:
{
this,
"ObjectPhiBranchName",
"",
"Phi1 if different than default"
}

Definition at line 68 of file EGTransverseMassTool.h.

68 {
69 this,
70 "ObjectPhiBranchName",
71 "",
72 "Phi1 if different than default"
73 };

◆ m_phi2BranchName

SG::ReadHandleKey<std::vector<float> > DerivationFramework::EGTransverseMassTool::m_phi2BranchName
private
Initial value:
{
this,
"METPhiBranchName",
"",
"Phi2 if different than default"
}

Definition at line 82 of file EGTransverseMassTool.h.

82 {
83 this,
84 "METPhiBranchName",
85 "",
86 "Phi2 if different than default"
87 };

◆ m_pt1BranchName

SG::ReadHandleKey<std::vector<float> > DerivationFramework::EGTransverseMassTool::m_pt1BranchName
private
Initial value:
{
this,
"ObjectPtBranchName",
"",
"Pt1 if different than default"
}

Definition at line 61 of file EGTransverseMassTool.h.

61 {
62 this,
63 "ObjectPtBranchName",
64 "",
65 "Pt1 if different than default"
66 };

◆ m_pt2BranchName

SG::ReadHandleKey<std::vector<float> > DerivationFramework::EGTransverseMassTool::m_pt2BranchName
private
Initial value:
{
this,
"METPtBranchName",
"",
"Pt2 if different than default"
}

Definition at line 75 of file EGTransverseMassTool.h.

75 {
76 this,
77 "METPtBranchName",
78 "",
79 "Pt2 if different than default"
80 };

◆ m_sgName

SG::WriteHandleKey<std::vector<float> > DerivationFramework::EGTransverseMassTool::m_sgName
private
Initial value:
{ this,
"StoreGateEntryName",
"",
"SG key of output object" }

Definition at line 43 of file EGTransverseMassTool.h.

43 { this,
44 "StoreGateEntryName",
45 "",
46 "SG key of output object" };

The documentation for this class was generated from the following files: