Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DD4hep: Numeric vector units parsing #27725

Merged
merged 3 commits into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions DetectorDescription/DDCMS/plugins/DDCutTubsFromPoints.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ static long algorithm(dd4hep::Detector& /* description */,

for (unsigned i = 0; i < phis.size(); i++) {
Section s = {phis[i], z_ls[i], z_ts[i]};

edm::LogVerbatim("TrackerGeom") << "DDCutTubsFromPoints: Sections :" << phis[i] << " , " << z_ls[i] << " , "
<< z_ts[i];
sections.emplace_back(s);
}

Expand All @@ -49,8 +52,9 @@ static long algorithm(dd4hep::Detector& /* description */,
// non-zero phi distance. Sections with zero phi distance can be used to
// create sharp jumps.

LogDebug("TrackerGeom") << "DDCutTubsFromPoints debug: Parent " << args.parentName() << "\tSolid " << solidOutput
<< " NameSpace " << ns.name() << "\tnumber of sections " << sections.size();
edm::LogVerbatim("TrackerGeom") << "DDCutTubsFromPoints debug: Parent " << args.parentName() << "\tSolid "
<< solidOutput << " NameSpace " << ns.name() << "\tnumber of sections "
<< sections.size();

// radius for plane calculations
// We use r_max here, since P3 later has a Z that is always more inside
Expand Down Expand Up @@ -107,6 +111,16 @@ static long algorithm(dd4hep::Detector& /* description */,
double P3_z_l = (P1_z_l + P2_z_l) / 2;
double P3_z_t = (P1_z_t + P2_z_t) / 2;

edm::LogVerbatim("TrackerGeom") << "DDCutTubsFromPoints: P1 l: " << segname << P1_x_l << " , " << P1_y_l << " , "
<< P1_z_l;
edm::LogVerbatim("TrackerGeom") << "DDCutTubsFromPoints: P1 t: " << segname << P1_x_t << " , " << P1_y_t << " , "
<< P1_z_t;

edm::LogVerbatim("TrackerGeom") << "DDCutTubsFromPoints: P2 l: " << segname << P2_x_l << " , " << P2_y_l << " , "
<< P2_z_l;
edm::LogVerbatim("TrackerGeom") << "DDCutTubsFromPoints: P2 t: " << segname << P2_x_t << " , " << P2_y_t << " , "
<< P2_z_t;

// we only have one dz to position both planes. The anchor is implicitly
// between the P3's, we have to use an offset later to make the segments
// line up correctly.
Expand All @@ -123,13 +137,17 @@ static long algorithm(dd4hep::Detector& /* description */,
double n_y_l = (D1_z_l * P2_x_l) - (P1_x_l * D2_z_l);
double n_z_l = (P1_x_l * P2_y_l) - (P1_y_l * P2_x_l);

edm::LogVerbatim("TrackerGeom") << "DDCutTubsFromPoints: l_Pos (" << n_x_l << "," << n_y_l << "," << n_z_l << ")";

// ... normalized.
// flip the sign here (but not for t) since root wants it like that.
double norm = -sqrt(n_x_l * n_x_l + n_y_l * n_y_l + n_z_l * n_z_l);
n_x_l /= norm;
n_y_l /= norm;
n_z_l /= norm;

edm::LogVerbatim("TrackerGeom") << "DDCutTubsFromPoints: l_norm " << norm;

// same game for the t side.
double D1_z_t = P1_z_t - P3_z_t;
double D2_z_t = P2_z_t - P3_z_t;
Expand All @@ -138,7 +156,12 @@ static long algorithm(dd4hep::Detector& /* description */,
double n_y_t = (D1_z_t * P2_x_t) - (P1_x_t * D2_z_t);
double n_z_t = (P1_x_t * P2_y_t) - (P1_y_t * P2_x_t);

edm::LogVerbatim("TrackerGeom") << "DDCutTubsFromPoints: t_Pos (" << n_x_t << "," << n_y_t << "," << n_z_t << ")";

norm = sqrt(n_x_t * n_x_t + n_y_t * n_y_t + n_z_t * n_z_t);

edm::LogVerbatim("TrackerGeom") << "DDCutTubsFromPoints: t_norm " << norm;

n_x_t /= norm;
n_y_t /= norm;
n_z_t /= norm;
Expand All @@ -148,6 +171,10 @@ static long algorithm(dd4hep::Detector& /* description */,

auto seg = dd4hep::CutTube(r_min, r_max, dz, phi1, dphi, n_x_l, n_y_l, n_z_l, n_x_t, n_y_t, n_z_t);

edm::LogVerbatim("TrackerGeom") << "DDCutTubsFromPoints: CutTube(" << r_min << "," << r_max << "," << dz << ","
<< phi1 << "," << dphi << "," << n_x_l << "," << n_y_l << "," << n_z_l << ","
<< n_x_t << "," << n_y_t << "," << n_z_t << ")";

segments.emplace_back(seg);
offsets.emplace_back(offset);
}
Expand Down
6 changes: 3 additions & 3 deletions DetectorDescription/DDCMS/plugins/DDDefinitions2Objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "XML/Utilities.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
#include "DataFormats/Math/interface/GeantUnits.h"
#include "DataFormats/Math/interface/CMSUnits.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vargasa @ianna for the use that is done so far of this include this update should be irrelevant, but it brings full consistency with all the rest of the package

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiocos. It is for consistency sake. The function used here cms_units::operators::convertRadToDeg points to angle_units::operators::convertRadToDeg(here) which is the same endpoint used by geant_units (here).

#include "DetectorDescription/DDCMS/interface/DDAlgoArguments.h"
#include "DetectorDescription/DDCMS/interface/DDNamespace.h"
#include "DetectorDescription/DDCMS/interface/DDParsingContext.h"
Expand All @@ -32,7 +32,7 @@
using namespace std;
using namespace dd4hep;
using namespace cms;
using namespace geant_units::operators;
using namespace cms_units::operators;

namespace dd4hep {

Expand Down Expand Up @@ -1640,7 +1640,7 @@ namespace {

for_each_token(cbegin(str), cend(str), cbegin(delims), cend(delims), [&output](auto first, auto second) {
if (first != second) {
output.emplace_back(stod(string(first, second)));
output.emplace_back(dd4hep::_toDouble(string(first, second)));
}
});
return output;
Expand Down
22 changes: 11 additions & 11 deletions DetectorDescription/DDCMS/plugins/DDTrackerAngular.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt,
delta = rangeAngle / double(n - 1);
}

LogDebug("TrackerGeom") << "debug: Parameters for positioning:: n " << n << " Start, Range, Delta "
<< convertRadToDeg(startAngle) << " " << convertRadToDeg(rangeAngle) << " "
<< convertRadToDeg(delta) << " Radius " << radius << " Centre " << center[0] << ", "
<< center[1] << ", " << center[2];
LogDebug("TrackerGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
<< ns.name();
edm::LogVerbatim("TrackerGeom") << "debug: Parameters for positioning:: n " << n << " Start, Range, Delta "
<< convertRadToDeg(startAngle) << " " << convertRadToDeg(rangeAngle) << " "
<< convertRadToDeg(delta) << " Radius " << radius << " Centre " << center[0] << ", "
<< center[1] << ", " << center[2];
edm::LogVerbatim("TrackerGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
<< ns.name();

double theta = 90._deg;
int copy = startCopyNo;
Expand All @@ -52,9 +52,9 @@ static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt,
if (irot != ctxt.rotations.end()) {
rotation = ns.rotation(ns.prepend(rotstr));
} else {
LogDebug("TrackerGeom") << "Creating a new "
<< "rotation: " << rotstr << "\t90., " << convertRadToDeg(phix) << ", 90.,"
<< convertRadToDeg(phiy) << ", 0, 0";
edm::LogVerbatim("TrackerGeom") << "Creating a new "
<< "rotation: " << rotstr << "\t90., " << convertRadToDeg(phix) << ", 90.,"
<< convertRadToDeg(phiy) << ", 0, 0";
RotationZYX rot;
rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
}
Expand All @@ -65,8 +65,8 @@ static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt,
double zpos = center[2];
Position tran(xpos, ypos, zpos);
mother.placeVolume(child, copy, Transform3D(rotation, tran));
LogDebug("TrackerGeom") << "test " << child.name() << " number " << copy << " positioned in " << mother.name()
<< " at " << tran << " with " << rotation;
edm::LogVerbatim("TrackerGeom") << "test " << child.name() << " number " << copy << " positioned in "
<< mother.name() << " at " << tran << " with " << rotation;
copy += incrCopyNo;
phi += delta;
}
Expand Down