CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Private Attributes
DDCutTubsFromPoints Class Reference
Inheritance diagram for DDCutTubsFromPoints:

Classes

struct  Section
 

Public Member Functions

 DDCutTubsFromPoints ()
 
void execute (DDCompactView &cpv) override
 
void initialize (const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
 
 ~DDCutTubsFromPoints () override
 

Private Attributes

DDMaterial material
 
double r_max
 
double r_min
 
std::vector< Sectionsections
 
DDName solidOutput
 
double z_pos
 

Detailed Description

Definition at line 25 of file DDCutTubsFromPoints.cc.

Constructor & Destructor Documentation

DDCutTubsFromPoints::DDCutTubsFromPoints ( )

Definition at line 60 of file DDCutTubsFromPoints.cc.

References LogDebug.

60  {
61  LogDebug("TrackerGeom") << "DDCutTubsFromPoints info: Creating an instance";
62 }
#define LogDebug(id)
DDCutTubsFromPoints::~DDCutTubsFromPoints ( )
override

Definition at line 64 of file DDCutTubsFromPoints.cc.

64 {}

Member Function Documentation

void DDCutTubsFromPoints::execute ( DDCompactView cpv)
override

Definition at line 102 of file DDCutTubsFromPoints.cc.

References cms::cuda::assert(), funct::cos(), DDSolidFactory::cuttubs(), PVValHelper::dz, mps_fire::i, material, DDName::name(), DDName::ns(), hltrates_dqm_sourceclient-live_cfg::offset, upgradeWorkflowComponents::offsets, SpecificationBuilder_cfi::parent(), DDCutTubsFromPoints::Section::phi, DDCompactView::position(), alignCSCRings::r, r_max, r_min, sections, edm::shift, funct::sin(), solidOutput, mathSSE::sqrt(), square(), DDEnums::support, cond::impl::to_string(), DDSolidFactory::unionSolid(), DDCutTubsFromPoints::Section::z_l, z_pos, and DDCutTubsFromPoints::Section::z_t.

102  {
103  // radius for plane calculations
104  // We use r_max here, since P3 later has a Z that is always more inside
105  // than the extreme points. This means the cutting planes have outwards
106  // slopes in r-Z, and the corner at r_max could stick out of the bounding
107  // volume otherwise.
108  double r = r_max;
109 
110  // min and max z for the placement in the end
111  double min_z = 1e9;
112  double max_z = -1e9;
113 
114  // counter of actually produced segments (excluding skipped ones)
115  int segment = 0;
116 
117  // the segments and their corresponding offset (absolute, as in the input)
118  std::vector<DDSolid> segments;
119  std::vector<double> offsets;
120 
121  Section s1 = sections[0];
122  for (Section s2 : sections) {
123  if (s1.phi != s2.phi) {
124  segment++;
125  // produce segment s1-s2.
126  DDName segname(solidOutput.name() + "_seg_" + std::to_string(segment), solidOutput.ns());
127 
128  double phi1 = s1.phi;
129  double phi2 = s2.phi;
130 
131  // track the min/max to properly place&align later
132  if (s2.z_l < min_z)
133  min_z = s2.z_l;
134  if (s2.z_t > max_z)
135  max_z = s2.z_t;
136 
137  double P1_z_l = s1.z_l;
138  double P1_z_t = s1.z_t;
139  double P2_z_l = s2.z_l;
140  double P2_z_t = s2.z_t;
141 
142  double P1_x_t = cos(phi1) * r;
143  double P1_x_l = cos(phi1) * r;
144  double P1_y_t = sin(phi1) * r;
145  double P1_y_l = sin(phi1) * r;
146 
147  double P2_x_t = cos(phi2) * r;
148  double P2_x_l = cos(phi2) * r;
149  double P2_y_t = sin(phi2) * r;
150  double P2_y_l = sin(phi2) * r;
151 
152  // each cutting plane is defined by P1-3. P1-2 are corners of the
153  // segment, P3 is at r=0 with the "average" z to get a nice cut.
154  double P3_z_l = (P1_z_l + P2_z_l) / 2;
155  double P3_z_t = (P1_z_t + P2_z_t) / 2;
156 
157  // we only have one dz to position both planes. The anchor is implicitly
158  // between the P3's, we have to use an offset later to make the segments
159  // line up correctly.
160  double dz = (P3_z_t - P3_z_l) / 2;
161  double offset = (P3_z_t + P3_z_l) / 2;
162 
163  // the plane is defined by P1-P3 and P2-P3; since P3 is at r=0 we
164  // only need the z.
165  double D1_z_l = P1_z_l - P3_z_l;
166  double D2_z_l = P2_z_l - P3_z_l;
167 
168  // the normal is then the cross product...
169  double n_x_l = (P1_y_l * D2_z_l) - (D1_z_l * P2_y_l);
170  double n_y_l = (D1_z_l * P2_x_l) - (P1_x_l * D2_z_l);
171  double n_z_l = (P1_x_l * P2_y_l) - (P1_y_l * P2_x_l);
172 
173  // ... normalized.
174  // flip the sign here (but not for t) since root wants it like that.
175  double norm = -sqrt(square(n_x_l) + square(n_y_l) + square(n_z_l));
176  n_x_l /= norm;
177  n_y_l /= norm;
178  n_z_l /= norm;
179 
180  // same game for the t side.
181  double D1_z_t = P1_z_t - P3_z_t;
182  double D2_z_t = P2_z_t - P3_z_t;
183 
184  double n_x_t = (P1_y_t * D2_z_t) - (D1_z_t * P2_y_t);
185  double n_y_t = (D1_z_t * P2_x_t) - (P1_x_t * D2_z_t);
186  double n_z_t = (P1_x_t * P2_y_t) - (P1_y_t * P2_x_t);
187 
188  norm = sqrt(square(n_x_t) + square(n_y_t) + square(n_z_t));
189  n_x_t /= norm;
190  n_y_t /= norm;
191  n_z_t /= norm;
192 
193  // the cuttubs wants a delta phi
194  double dphi = phi2 - phi1;
195 
196  DDSolid seg =
197  DDSolidFactory::cuttubs(segname, dz, r_min, r_max, phi1, dphi, n_x_l, n_y_l, n_z_l, n_x_t, n_y_t, n_z_t);
198  segments.emplace_back(seg);
199  offsets.emplace_back(offset);
200  }
201  s1 = s2;
202  }
203 
204  assert(segments.size() >= 2); // less would be special cases
205 
206  DDSolid solid = segments[0];
207  // placment happens relative to the first member of the union
208  double shift = offsets[0];
209 
210  for (unsigned i = 1; i < segments.size() - 1; i++) {
211  // each sub-union needs a name. Well.
212  DDName unionname(solidOutput.name() + "_uni_" + std::to_string(i + 1), solidOutput.ns());
214  unionname, solid, segments[i], DDTranslation(0, 0, offsets[i] - shift), DDRotation());
215  }
216 
218  solid,
219  segments[segments.size() - 1],
220  DDTranslation(0, 0, offsets[segments.size() - 1] - shift),
221  DDRotation());
222 
223  // remove the common offset from the input, to get sth. aligned at z=0.
224  double offset = -shift + (min_z + (max_z - min_z) / 2);
225 
227 
228  // This is not as generic as the name promises, but it is hard to make a
229  // solid w/o placing it.
230  DDRotation rot180("pixfwdCommon:Z180");
231  cpv.position(logical, parent(), 1, DDTranslation(0, 0, z_pos - offset), DDRotation());
232  cpv.position(logical, parent(), 2, DDTranslation(0, 0, z_pos - offset), rot180);
233 }
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
std::vector< Section > sections
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::string to_string(const V &value)
Definition: OMSAccess.h:71
assert(be >=bs)
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
static DDSolid cuttubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi, double lx, double ly, double lz, double tx, double ty, double tz)
Definition: DDSolid.cc:672
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
static double square(double x)
static unsigned int const shift
static DDSolid unionSolid(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:594
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
void DDCutTubsFromPoints::initialize ( const DDNumericArguments nArgs,
const DDVectorArguments vArgs,
const DDMapArguments mArgs,
const DDStringArguments sArgs,
const DDStringVectorArguments vsArgs 
)
override

Definition at line 66 of file DDCutTubsFromPoints.cc.

References cms::cuda::assert(), mps_fire::i, LogDebug, material, DDCurrentNamespace::ns(), SpecificationBuilder_cfi::parent(), r_max, r_min, alignCSCRings::s, sections, DDVector::size(), solidOutput, AlCaHLTBitMon_QueryRunRegistry::string, and z_pos.

70  {
71  r_min = nArgs["rMin"];
72  r_max = nArgs["rMax"];
73  z_pos = nArgs["zPos"];
74  material = DDMaterial(sArgs["Material"]);
75 
76  auto phis_name = DDName(sArgs["Phi"]);
77  auto z_ls_name = DDName(sArgs["z_l"]);
78  auto z_ts_name = DDName(sArgs["z_t"]);
79  DDVector phis(phis_name);
80  DDVector z_ls(z_ls_name);
81  DDVector z_ts(z_ts_name);
82 
83  assert(phis.size() == z_ls.size());
84  assert(phis.size() == z_ts.size());
85 
86  for (unsigned i = 0; i < phis.size(); i++) {
87  Section s = {phis[i], z_ls[i], z_ts[i]};
88  sections.emplace_back(s);
89  }
90  assert(!sections.empty());
91 
92  solidOutput = DDName(sArgs["SolidName"]);
93 
94  std::string idNameSpace = DDCurrentNamespace::ns();
95  DDName parentName = parent().name();
96  LogDebug("TrackerGeom") << "DDCutTubsFromPoints debug: Parent " << parentName << "\tSolid " << solidOutput
97  << " NameSpace " << idNameSpace << "\tnumber of sections " << sections.size();
98 }
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
std::vector< Section > sections
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
static std::string & ns()
assert(be >=bs)
a named constant corresponding to the DDL-XML tag &lt;Constant&gt; and &lt;ConstantsVector&gt; ...
Definition: DDVector.h:18
#define LogDebug(id)

Member Data Documentation

DDMaterial DDCutTubsFromPoints::material
private

Definition at line 50 of file DDCutTubsFromPoints.cc.

Referenced by execute(), and initialize().

double DDCutTubsFromPoints::r_max
private

Definition at line 48 of file DDCutTubsFromPoints.cc.

Referenced by execute(), and initialize().

double DDCutTubsFromPoints::r_min
private

Definition at line 47 of file DDCutTubsFromPoints.cc.

Referenced by execute(), and initialize().

std::vector<Section> DDCutTubsFromPoints::sections
private
DDName DDCutTubsFromPoints::solidOutput
private

Definition at line 57 of file DDCutTubsFromPoints.cc.

Referenced by execute(), and initialize().

double DDCutTubsFromPoints::z_pos
private

Definition at line 49 of file DDCutTubsFromPoints.cc.

Referenced by execute(), and initialize().