ATLAS Offline Software
Loading...
Searching...
No Matches
MuonVal::ScatteringBranch Class Reference

Utility branch to collect all the scatteres from the associated Trk::Track. More...

#include <TrackDetailBranches.h>

Inheritance diagram for MuonVal::ScatteringBranch:
Collaboration diagram for MuonVal::ScatteringBranch:

Public Types

using Base_t = MatrixBranch<float>
using DataDependency

Public Member Functions

 ScatteringBranch (IParticleFourMomBranch &parent)
void push_back (const xAOD::IParticle *p) override
 Similar to the IAuxElementDecoration branch but only accepting IParticles.
void push_back (const xAOD::IParticle &p) override
void operator+= (const xAOD::IParticle *p) override
void operator+= (const xAOD::IParticle &p) override
void push_back (size_t i, const float &value)
float & get (size_t i, size_t j)
 Returns the j-th element of the i-th inner vector.
bool & get (size_t idx)
void push_back (const float &value)
 Adds a new element at the end of the vector.
void push_back (const T &value)
 Adds a new element at the end of the vector.
size_t nrows () const
 Size of the outer vector.
size_t ncols (size_t row) const
 Size of the i-th inner vector.
const float & getDefault () const
 Get the default value to fill the empty fields in the vector.
void setDefault (const float &def)
void setDefault (const T &def)
bool fill (const EventContext &ctx) override
 Clears vector in cases that it has not been updated in this event Retursn falls if the vector has not been initialized yet.
bool init () override
 Initialized the Branch.
size_t size () const
 Returns the number of actual saved elements.
void operator+= (const float &value)
void operator+= (const T &value)
float & operator[] (size_t idx)
 Accesses the idx-th element.
bool isUpdated () const
bool hasDefault () const
std::string name () const override final
 Returns the name of the branch.
bool initialized () const
 Returns whether the object has been initialized or not The outcome of the variable is bound to a successful call of the addToTree method.
TTree * tree () override final
 Returns the underlying TTree object.
const TTree * tree () const override final
std::vector< DataDependencydata_dependencies () override final
 Returns the data dependencies needed by the MuonTesterBranch.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Static Public Member Functions

static std::string eraseWhiteSpaces (const std::string &In)

Protected Member Functions

bool addToTree (float &variable)
 Connects the Memory buffer with the TTree.
bool declare_dependency (Key &key)
 Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
MuonTesterTreeparent ()
 Returns the reference to the MuonTesterTree parent.

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

std::shared_ptr< Base_tm_deltaTheta {}
std::shared_ptr< Base_tm_sigmaPhi {}
std::shared_ptr< Base_tm_sigmaTheta {}
std::shared_ptr< VectorBranch< std::uint8_t > > m_nScat {}
float m_default
std::vector< float > m_variable
bool m_hasDefault
bool m_updated
TTree * m_tree
MuonTesterTreem_parent
std::string m_name
bool m_init
std::vector< DataDependencym_dependencies
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels).
std::atomic< IMessageSvc * > m_imsg
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE
 Messaging initialized (initMessaging).

Detailed Description

Utility branch to collect all the scatteres from the associated Trk::Track.

Definition at line 42 of file TrackDetailBranches.h.

Member Typedef Documentation

◆ Base_t

Definition at line 45 of file TrackDetailBranches.h.

◆ DataDependency

Definition at line 39 of file IMuonTesterBranch.h.

Constructor & Destructor Documentation

◆ ScatteringBranch()

MuonVal::ScatteringBranch::ScatteringBranch ( IParticleFourMomBranch & parent)

Definition at line 86 of file TrackDetailBranches.cxx.

86 :
87 Base_t{parent.tree(), std::format("{:}_scatPhi", parent.name())},
88 m_deltaTheta{std::make_unique<Base_t>(parent.tree(), std::format("{:}_scatTheta", parent.name()))},
89 m_sigmaPhi{std::make_unique<Base_t>(parent.tree(), std::format("{:}_scatSigmaPhi", parent.name()))},
90 m_sigmaTheta{std::make_unique<Base_t>(parent.tree(),std::format("{:}_scatSigmaTheta", parent.name()))},
91 m_nScat{std::make_unique<VectorBranch<std::uint8_t>>(parent.tree(), std::format("{:}_nScatters", parent.name()))}{
92 parent.getTree().addBranch(m_deltaTheta);
93 parent.getTree().addBranch(m_sigmaPhi);
94 parent.getTree().addBranch(m_sigmaTheta);
95 parent.getTree().addBranch(m_nScat);
96 m_deltaTheta = parent.getTree().getBranch<Base_t>(m_deltaTheta->name());
97 m_sigmaPhi = parent.getTree().getBranch<Base_t>(m_sigmaPhi->name());
98 m_sigmaTheta = parent.getTree().getBranch<Base_t>(m_sigmaTheta->name());
99 m_nScat = parent.getTree().getBranch<VectorBranch<std::uint8_t>>(m_nScat->name());
100 }
MuonTesterTree & parent()
Returns the reference to the MuonTesterTree parent.
std::shared_ptr< VectorBranch< std::uint8_t > > m_nScat
std::shared_ptr< Base_t > m_sigmaTheta
std::shared_ptr< Base_t > m_deltaTheta
std::shared_ptr< Base_t > m_sigmaPhi
MatrixBranch< float > Base_t
VectorBranch(TTree *tree, const std::string &name)
Standard constructor.

Member Function Documentation

◆ addToTree()

bool MuonVal::MuonTesterBranch::addToTree ( float & variable)
protectedinherited

Connects the Memory buffer with the TTree.

◆ data_dependencies()

Returns the data dependencies needed by the MuonTesterBranch.

Definition at line 40 of file MuonTesterBranch.cxx.

◆ declare_dependency()

bool MuonVal::MuonTesterBranch::declare_dependency ( Key & key)
protectedinherited

Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.

◆ eraseWhiteSpaces()

std::string MuonVal::MuonTesterBranch::eraseWhiteSpaces ( const std::string & In)
staticinherited

Definition at line 42 of file MuonTesterBranch.cxx.

56 {
58 out.erase(std::remove_if(out.begin(), out.end(), isspace), out.end());
59 return out;
60}

◆ fill()

bool MuonVal::VectorBranch< float >::fill ( const EventContext & ctx)
overrideinherited

Clears vector in cases that it has not been updated in this event Retursn falls if the vector has not been initialized yet.

◆ get() [1/2]

float & MuonVal::MatrixBranch< float >::get ( size_t i,
size_t j )
inlineinherited

Returns the j-th element of the i-th inner vector.

◆ get() [2/2]

bool & MuonVal::VectorBranch< bool >::get ( size_t idx)
inherited

◆ getDefault()

const float & MuonVal::MatrixBranch< float >::getDefault ( ) const
inlineinherited

Get the default value to fill the empty fields in the vector.

◆ hasDefault()

bool MuonVal::VectorBranch< float >::hasDefault ( ) const
inlineinherited

◆ init()

bool MuonVal::VectorBranch< float >::init ( )
overrideinherited

Initialized the Branch.

◆ initialized()

bool MuonVal::MuonTesterBranch::initialized ( ) const
inherited

Returns whether the object has been initialized or not The outcome of the variable is bound to a successful call of the addToTree method.

Definition at line 35 of file MuonTesterBranch.cxx.

52{ return m_init; }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 121 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
IMessageSvc * getMessageSvc(bool quiet=false)

◆ isUpdated()

bool MuonVal::VectorBranch< float >::isUpdated ( ) const
inlineinherited

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 92 of file AthMessaging.h.

168{
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
void setLevel(MSG::Level lvl)
Change the current logging level.
T & get(size_t i, size_t j)
Returns the j-th element of the i-th inner vector.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 99 of file AthMessaging.h.

183{ return msg() << lvl; }

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 86 of file AthMessaging.h.

152{
153 // If user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ name()

std::string MuonVal::MuonTesterBranch::name ( ) const
finaloverrideinherited

Returns the name of the branch.

Definition at line 31 of file MuonTesterBranch.cxx.

51{ return m_name; }

◆ ncols()

size_t MuonVal::MatrixBranch< float >::ncols ( size_t row) const
inlineinherited

Size of the i-th inner vector.

◆ nrows()

size_t MuonVal::MatrixBranch< float >::nrows ( ) const
inlineinherited

Size of the outer vector.

◆ operator+=() [1/4]

void MuonVal::VectorBranch< float >::operator+= ( const float & value)
inlineinherited

◆ operator+=() [2/4]

void MuonVal::ScatteringBranch::operator+= ( const xAOD::IParticle & p)
overridevirtual

Implements MuonVal::IParticleDecorationBranch.

Definition at line 103 of file TrackDetailBranches.cxx.

103{ push_back(p); }
void push_back(const xAOD::IParticle *p) override
Similar to the IAuxElementDecoration branch but only accepting IParticles.

◆ operator+=() [3/4]

void MuonVal::ScatteringBranch::operator+= ( const xAOD::IParticle * p)
overridevirtual

Implements MuonVal::IParticleDecorationBranch.

Definition at line 102 of file TrackDetailBranches.cxx.

102{ push_back(p); }

◆ operator+=() [4/4]

template<class T>
void MuonVal::VectorBranch< T >::operator+= ( const T & value)
inlineinherited

◆ operator[]()

float & MuonVal::VectorBranch< float >::operator[] ( size_t idx)
inlineinherited

Accesses the idx-th element.

If the index is larger than the size of the vector it is then enlarged with the default_value

◆ parent()

Returns the reference to the MuonTesterTree parent.

Definition at line 52 of file MuonTesterBranch.cxx.

38 {
39 if (!m_parent) {
40 ATH_MSG_WARNING("The parent of " << name() << " is null.");
41 }
42 return *m_parent;
43}
#define ATH_MSG_WARNING(x)
std::string name() const override final

◆ push_back() [1/5]

void MuonVal::VectorBranch< float >::push_back ( const float & value)
inlineinherited

Adds a new element at the end of the vector.

◆ push_back() [2/5]

void MuonVal::ScatteringBranch::push_back ( const xAOD::IParticle & p)
overridevirtual

Implements MuonVal::IParticleDecorationBranch.

Definition at line 101 of file TrackDetailBranches.cxx.

101{ push_back(&p); }

◆ push_back() [3/5]

void MuonVal::ScatteringBranch::push_back ( const xAOD::IParticle * p)
overridevirtual

Similar to the IAuxElementDecoration branch but only accepting IParticles.

Implements MuonVal::IParticleDecorationBranch.

Definition at line 105 of file TrackDetailBranches.cxx.

105 {
106 const xAOD::TrackParticle* trk = nullptr;
108 trk = static_cast<const xAOD::TrackParticle*>(p);
109 } else if (p->type() == xAOD::Type::ObjectType::Muon) {
110 trk = static_cast<const xAOD::Muon*>(p)->trackParticle(xAOD::Muon::TrackParticleType::Primary);
111 } else {
112 THROW_EXCEPTION("No track particle object has been given to " <<name());
113 }
114 std::vector<float> dPhi{}, dTheta{}, sigPhi{}, sigTheta{};
115 if (const Trk::Track* track = trk->track(); track != nullptr) {
116 for (const Trk::TrackStateOnSurface* tsos : *track->trackStateOnSurfaces()) {
117 const auto* angles = dynamic_cast<const Trk::ScatteringAngles*>(tsos->materialEffectsOnTrack());
118 if (!angles) {
119 continue;
120 }
121 dPhi.push_back(angles->deltaPhi());
122 dTheta.push_back(angles->deltaTheta());
123 sigPhi.push_back(angles->sigmaDeltaPhi());
124 sigTheta.push_back(angles->sigmaDeltaTheta());
125 }
126 }
127 push_back(std::move(dPhi));
128 m_deltaTheta->push_back(std::move(dTheta));
129 m_sigmaPhi->push_back(std::move(sigPhi));
130 m_sigmaTheta->push_back(std::move(sigTheta));
131 }
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
bool dPhi(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
@ TrackParticle
The object is a charged track particle.
Definition ObjectType.h:43
@ Muon
The object is a muon.
Definition ObjectType.h:48
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Muon_v1 Muon
Reference the current persistent version:
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ push_back() [4/5]

void MuonVal::MatrixBranch< float >::push_back ( size_t i,
const float & value )
inline

◆ push_back() [5/5]

template<class T>
void MuonVal::VectorBranch< T >::push_back ( const T & value)
inlineinherited

Adds a new element at the end of the vector.

◆ setDefault() [1/2]

void MuonVal::MatrixBranch< float >::setDefault ( const float & def)
inherited

◆ setDefault() [2/2]

template<class T>
void MuonVal::VectorBranch< T >::setDefault ( const T & def)
inherited

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 108 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ size()

size_t MuonVal::VectorBranch< float >::size ( ) const
inlineinherited

Returns the number of actual saved elements.

◆ tree() [1/2]

const TTree * MuonVal::MuonTesterBranch::tree ( ) const
finaloverrideinherited

Definition at line 38 of file MuonTesterBranch.cxx.

54{ return m_tree; }

◆ tree() [2/2]

TTree * MuonVal::MuonTesterBranch::tree ( )
finaloverrideinherited

Returns the underlying TTree object.

Definition at line 37 of file MuonTesterBranch.cxx.

53{ return m_tree; }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE
mutableprivateinherited

Messaging initialized (initMessaging).

Definition at line 141 of file AthMessaging.h.

◆ m_default

float MuonVal::MatrixBranch< float >::m_default
privateinherited

Definition at line 48 of file MatrixBranch.h.

48{};

◆ m_deltaTheta

std::shared_ptr<Base_t> MuonVal::ScatteringBranch::m_deltaTheta {}
private

Definition at line 55 of file TrackDetailBranches.h.

55{};

◆ m_dependencies

Definition at line 62 of file MuonTesterBranch.h.

62{};

◆ m_hasDefault

bool MuonVal::VectorBranch< float >::m_hasDefault
privateinherited

Definition at line 64 of file VectorBranch.h.

64{false};

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_init

bool MuonVal::MuonTesterBranch::m_init
privateinherited

Definition at line 61 of file MuonTesterBranch.h.

61{false};

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels).

Definition at line 132 of file AthMessaging.h.

◆ m_name

std::string MuonVal::MuonTesterBranch::m_name
privateinherited

Definition at line 60 of file MuonTesterBranch.h.

60{};

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_nScat

std::shared_ptr<VectorBranch<std::uint8_t> > MuonVal::ScatteringBranch::m_nScat {}
private

Definition at line 58 of file TrackDetailBranches.h.

58{};

◆ m_parent

Definition at line 59 of file MuonTesterBranch.h.

59{nullptr};

◆ m_sigmaPhi

std::shared_ptr<Base_t> MuonVal::ScatteringBranch::m_sigmaPhi {}
private

Definition at line 56 of file TrackDetailBranches.h.

56{};

◆ m_sigmaTheta

std::shared_ptr<Base_t> MuonVal::ScatteringBranch::m_sigmaTheta {}
private

Definition at line 57 of file TrackDetailBranches.h.

57{};

◆ m_tree

TTree* MuonVal::MuonTesterBranch::m_tree
privateinherited

Definition at line 58 of file MuonTesterBranch.h.

58{nullptr};

◆ m_updated

bool MuonVal::VectorBranch< float >::m_updated
privateinherited

Definition at line 65 of file VectorBranch.h.

65{false};

◆ m_variable

std::vector<float> MuonVal::VectorBranch< float >::m_variable
privateinherited

Definition at line 62 of file VectorBranch.h.

62{};

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