2 #include <DD4hep/Path.h> 3 #include <DD4hep/Printout.h> 4 #include <DD4hep/Detector.h> 5 #include <DD4hep/Filter.h> 6 #include <DD4hep/Grammar.h> 40 double check = (
x.Cross(y)).Dot(z);
42 except(
"DD4CMS",
"+++ FAILED to construct Rotation is not LEFT-handed!");
45 dd4hep::Rotation3D
rotation(
x.x(), y.x(), z.x(),
x.y(), y.y(), z.y(),
x.z(), y.z(), z.z());
62 throw std::runtime_error(
"Axis is not valid.");
90 res.append(ts).append(
",");
93 res.erase(
res.find_last_of(
','));
107 string val =
n.realName(xml_dim_t(
e.child(
DD_CMU(rParent))).nameStr());
114 return n.realName(value<string>(
"ChildName"));
119 for (xml_coll_t
p(
element, _U(star));
p; ++
p) {
120 string n =
p.attr<
string>(_U(
name));
130 for (xml_coll_t
p(
element, _U(star));
p; ++
p) {
131 string n =
p.attr<
string>(_U(
name));
136 except(
"DD4CMS",
"+++ Attempt to access non-existing algorithm option %s[%s]",
name.c_str(), nam.c_str());
137 throw runtime_error(
"DDCMS: Attempt to access non-existing algorithm option.");
150 string value(aValue);
152 if (
idx == string::npos) {
156 while (
idx != string::npos) {
160 if (idp == string::npos || idp > idq)
162 else if (idp != string::npos && idp < idq)
170 for (
idx =
v.find(
'[', 0);
idx != string::npos;
idx =
v.find(
'[',
idx + 1)) {
171 idq =
v.find(
']',
idx + 1);
175 rep =
"(" + r->second->type +
")";
189 string val = xp.text();
190 string nam = xp.nameStr();
191 string typ = xp.typeStr();
192 string numValue = xp.attr<
string>(
DD_CMU(nEntries));
193 int num = _toDouble(numValue);
194 const BasicGrammar& gr = BasicGrammar::instance<vector<string> >();
196 val = trimSVecWhitespace(
val);
197 val =
'[' + ns.realName(
val) +
']';
201 "DD4CMS",
"+++ VectorParam<%s>: %s -> %s [Invalid conversion:%d]", typ.c_str(), nam.c_str(),
val.c_str(),
res);
202 }
else if (
num != (
int)
data.size()) {
204 "+++ VectorParam<%s>: %s -> %s [Invalid entry count: %d <> %ld]",
211 printout(
a->context.debug_algorithms ? ALWAYS :
DEBUG,
213 "+++ VectorParam<%s>: ret=%d %s -> %s",
217 gr.str(&
data).c_str());
221 template <
typename T>
222 T __cnv(
const string&) {
226 double __cnv<double>(
const string&
arg) {
227 return _toDouble(
arg);
230 float __cnv<float>(
const string&
arg) {
231 return _toFloat(
arg);
234 long __cnv<long>(
const string&
arg) {
238 int __cnv<int>(
const string&
arg) {
242 string __cnv<string>(
const string&
arg) {
246 template <
typename T>
247 vector<T> __cnvVect(
const DDAlgoArguments*
a,
const char* req_typ, xml_h xp) {
250 string nam = xp.attr<
string>(_U(
name));
251 string typ = xp.hasAttr(_U(
type)) ? xp.attr<
string>(_U(
type)) :
"numeric";
252 string val = xp.text();
253 string nValues =
a->resolveValue(xp.attr<
string>(
DD_CMU(nEntries)));
254 int num = _toInt(nValues);
255 if (typ != req_typ) {
257 "+++ VectorParam<%s | %s>: %s -> <%s> %s [Incompatible vector-type]",
269 for (
size_t idx = 0, idq =
val.find(
',',
idx);
idx != string::npos && idq != string::npos;
271 piece = ns.realName(
val.substr(
idx, idq -
idx));
272 T d = __cnv<T>(piece);
275 printout(
a->context.debug_algorithms ? ALWAYS :
DEBUG,
277 "+++ VectorParam<%s>: %s[%d] -> %s",
290 template <
typename T>
295 template double DDAlgoArguments::value<double>(
const string& nam)
const;
296 template float DDAlgoArguments::value<float>(
const string& nam)
const;
297 template long DDAlgoArguments::value<long>(
const string& nam)
const;
298 template int DDAlgoArguments::value<int>(
const string& nam)
const;
299 template string DDAlgoArguments::value<string>(
const string& nam)
const;
303 vector<string> DDAlgoArguments::value<vector<string> >(
const string& nam)
const {
304 return raw_vector(
this, rawArgument(nam));
309 vector<double> DDAlgoArguments::value<vector<double> >(
const string& nam)
const {
310 return __cnvVect<double>(
this,
"numeric", rawArgument(nam));
315 vector<float> DDAlgoArguments::value<vector<float> >(
const string& nam)
const {
316 return __cnvVect<float>(
this,
"numeric", rawArgument(nam));
321 vector<long> DDAlgoArguments::value<vector<long> >(
const string& nam)
const {
322 return __cnvVect<long>(
this,
"numeric", rawArgument(nam));
327 vector<int> DDAlgoArguments::value<vector<int> >(
const string& nam)
const {
328 return __cnvVect<int>(
this,
"numeric", rawArgument(nam));
T value(const std::string &name) const
std::string childName() const
Access value of child'name from the xml element.
Sin< T >::type sin(const T &t)
std::string realName(const std::string &) const
DDParsingContext *const context() const
xml_h rawArgument(const std::string &name) const
Access raw argument as a string by name.
double dble(const std::string &nam) const
Shortcut to access double arguments.
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
static void ltrim(std::string &s)
std::string resolveValue(const std::string &value) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
ROOT::VecOps::RVec< UChar_t > chars
std::string parentName() const
Access value of rParent child node.
std::string_view name() const
DDRotationMatrix makeRotReflect(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
std::vector< double > vecDble(const std::string &nam) const
Shortcut to access vector<double> arguments.
Namespace of DDCMS conversion namespace.
def split(sequence, size)
static void rtrim(std::string &s)
std::vector< int > vecInt(const std::string &nam) const
Shortcut to access vector<int> arguments.
std::vector< float > vecFloat(const std::string &nam) const
Shortcut to access vector<float> arguments.
char data[epos_bytes_allocation]
dd4hep::Detector & description
void remove_whitespace(std::string &s)
cms::DDParsingContext & context
int integer(const std::string &nam) const
Shortcut to access integer arguments.
bool find(const std::string &name) const
Check the existence of an argument by name.
std::string resolved_scalar_arg(const std::string &name) const
Access namespace resolved argument as a string by name.
std::vector< std::string > vecStr(const std::string &nam) const
Shortcut to access vector<string> arguments.
T angle(T x1, T y1, T z1, T x2, T y2, T z2)