ATLAS Offline Software
Loading...
Searching...
No Matches
DecayParser Class Reference

#include <DecayParser.h>

Collaboration diagram for DecayParser:

Public Member Functions

 DecayParser (const std::string &cmd)
 Constructor with parameters:
virtual ~DecayParser ()
 Destructor:
const std::vector< McUtils::Strings > & getParents () const
 I/O operators.
const std::vector< McUtils::Strings > & getChildren () const
void dump () const
 Const methods:
int pdgId (const std::string &pdgIdString) const
void parse (const std::string &cmd)
 Non-const methods:

Protected Member Functions

 DecayParser ()
 Default constructor:
 DecayParser (const DecayParser &rhs)
 Copy constructor:
DecayParseroperator= (const DecayParser &obj)
 Assignment operator:
void printMcUtilsStrings (const std::vector< McUtils::Strings > &list) const
 Print the content of a vector of McUtils::Strings to std::cout.

Protected Attributes

std::vector< McUtils::Stringsm_parents
 List of parents : each slot of the vector is a list of candidates So one could have something like : [ ["22","23"] ] to model a decay of a gamma or a Z0.
std::vector< McUtils::Stringsm_children
 List of children : each slot of the vector is a list of candidates So one could have something like : [ ["11","13"], ["-11","-13" ] ] to model a decay into a pair of electrons or muons.

Detailed Description

Definition at line 29 of file DecayParser.h.

Constructor & Destructor Documentation

◆ DecayParser() [1/3]

DecayParser::DecayParser ( const std::string & cmd)

Constructor with parameters:

Public methods:

Constructors

Definition at line 61 of file DecayParser.cxx.

61 :
62 m_parents ( ),
63 m_children ( )
64{
65 parse(cmd);
66}
std::vector< McUtils::Strings > m_parents
List of parents : each slot of the vector is a list of candidates So one could have something like : ...
Definition DecayParser.h:90
void parse(const std::string &cmd)
Non-const methods:
std::vector< McUtils::Strings > m_children
List of children : each slot of the vector is a list of candidates So one could have something like :...
Definition DecayParser.h:96

◆ ~DecayParser()

DecayParser::~DecayParser ( )
virtual

Destructor:

Destructor.

Definition at line 71 of file DecayParser.cxx.

72{
73}

◆ DecayParser() [2/3]

DecayParser::DecayParser ( )
protected

Default constructor:

◆ DecayParser() [3/3]

DecayParser::DecayParser ( const DecayParser & rhs)
protected

Copy constructor:

Member Function Documentation

◆ dump()

void DecayParser::dump ( ) const

Const methods:

Definition at line 78 of file DecayParser.cxx.

79{
80 std::cout << "--- Parents ---" << std::endl;
82
83 std::cout << "--- Children ---" << std::endl;
85}
void printMcUtilsStrings(const std::vector< McUtils::Strings > &list) const
Print the content of a vector of McUtils::Strings to std::cout.

◆ getChildren()

const std::vector< McUtils::Strings > & DecayParser::getChildren ( ) const
inline

Definition at line 117 of file DecayParser.h.

118{
119 return m_children;
120}

◆ getParents()

const std::vector< McUtils::Strings > & DecayParser::getParents ( ) const
inline

I/O operators.

Inline methods:

Definition at line 110 of file DecayParser.h.

111{
112 return m_parents;
113}

◆ operator=()

DecayParser & DecayParser::operator= ( const DecayParser & obj)
protected

Assignment operator:

Definition at line 172 of file DecayParser.cxx.

173{
174 if ( this != &rhs ) {
175 m_parents = rhs.m_parents;
176 m_children = rhs.m_children;
177 }
178 return *this;
179}

◆ parse()

void DecayParser::parse ( const std::string & cmd)

Non-const methods:

Definition at line 99 of file DecayParser.cxx.

100{
101 if ( inputCmd.empty() ) {
102 return;
103 }
104
105 std::string cmd;
106 cmd.reserve(inputCmd.size());
107 for (unsigned char c : inputCmd) {
108 if (!std::isspace(c)) {
109 cmd.push_back(c);
110 }
111 }
112 if (cmd.empty()) {
113 return;
114 }
115
116 // Reset the parents and children lists
117 m_parents.clear();
118 m_children.clear();
119
120 if (cmd == "->") {
121 return;
122 }
123
124 const std::size_t arrowPos = cmd.find("->");
125 if (arrowPos == std::string::npos) {
126 std::string error = "missing '->' in command [" + inputCmd + "]";
127 throw std::runtime_error(error);
128 }
129
130 if (cmd.find("->", arrowPos + 2) != std::string::npos) {
131 std::string error = "multiple '->' separators in command [" + inputCmd + "]";
132 throw std::runtime_error(error);
133 }
134
135 const std::string_view cmdView{cmd};
136 const auto parentsBlock = cmdView.substr(0, arrowPos);
137 const auto childrenBlock = cmdView.substr(arrowPos + 2);
138
139 m_parents = process_block(parentsBlock);
140 m_children = process_block(childrenBlock);
141}

◆ pdgId()

int DecayParser::pdgId ( const std::string & pdgIdString) const

Definition at line 87 of file DecayParser.cxx.

88{
89 int pdgID = 0;
90 int iPDG = 0;
91 std::stringstream( pdgIdString ) >> iPDG;
92 pdgID = iPDG;
93
94 return pdgID;
95}

◆ printMcUtilsStrings()

void DecayParser::printMcUtilsStrings ( const std::vector< McUtils::Strings > & list) const
protected

Print the content of a vector of McUtils::Strings to std::cout.

Definition at line 145 of file DecayParser.cxx.

146{
147 unsigned int iSlot = 0;
148 for( std::vector<McUtils::Strings>::const_iterator itr = list.begin();
149 itr != list.end();
150 ++itr,++iSlot ) {
151 std::stringstream iSlotStr;
152 iSlotStr << iSlot;
153 const McUtils::Strings::const_iterator candEnd = itr->end();
154 std::cout << "slot #" << iSlotStr.str() << ": candidates= [ ";
155 for( McUtils::Strings::const_iterator candidate = itr->begin();
156 candidate != candEnd;
157 ++candidate ) {
158 std::cout << *candidate;
159 if ( candidate+1 != candEnd ) {
160 std::cout << " | ";
161 }
162 }
163 std::cout << " ]" << std::endl;
164 }
165 return;
166}
list(name, path='/')
Definition histSizes.py:38

Member Data Documentation

◆ m_children

std::vector<McUtils::Strings> DecayParser::m_children
protected

List of children : each slot of the vector is a list of candidates So one could have something like : [ ["11","13"], ["-11","-13" ] ] to model a decay into a pair of electrons or muons.

Definition at line 96 of file DecayParser.h.

◆ m_parents

std::vector<McUtils::Strings> DecayParser::m_parents
protected

List of parents : each slot of the vector is a list of candidates So one could have something like : [ ["22","23"] ] to model a decay of a gamma or a Z0.

Definition at line 90 of file DecayParser.h.


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