52 printout(dd4hep::DEBUG,
"DD4hep_Mask",
"Creating Mask" ) ;
56 const std::string name = xmlMask.nameStr();
59 Assembly envelope( name +
"_assembly" ) ;
64 bool rotationX=
false;
67 dd4hep::xml::Component xmlParameter = xmlMask.child(
_Unicode(parameter));
68 const double crossingAngle = xmlParameter.attr<
double >(
_Unicode(crossingangle))*0.5;
70 if (xmlParameter.hasAttr(
_Unicode(rotationX)))
71 rotationX = xmlParameter.attr<
bool >(
_Unicode(rotationX));
77 bool isSensitive =
false;
79 const double zStart = xmlSection.attr<
double > (
_Unicode(start));
80 const double zEnd = xmlSection.attr<
double > (
_Unicode(end));
81 const double rInnerStart = xmlSection.attr<
double > (
_Unicode(rMin1));
82 const double rInnerEnd = xmlSection.attr<
double > (
_Unicode(rMin2));
83 const double rOuterStart = xmlSection.attr<
double > (
_Unicode(rMax1));
84 const double rOuterEnd = xmlSection.attr<
double > (
_Unicode(rMax2));
85 const double thickness = rOuterStart - rInnerStart;
87 const std::string volName =
"tube_" + xmlSection.nameStr();
90 double phi2 = 360.0*units::degree;
91 if (xmlSection.hasAttr(
_U(phi1)))
92 phi1 = xmlSection.attr<
double > (
_U(phi1));
93 if (xmlSection.hasAttr(
_U(phi2)))
94 phi2 = xmlSection.attr<
double > (
_U(phi2));
96 std::string ssensitive =
"none";
97 if (xmlSection.hasAttr(
_U(sensitive))){
99 ssensitive = xmlSection.attr< std::string > (
_U(sensitive));
100 sens.
setType( xmlSection.attr< std::string > (
_U(sensitive)) );
101 printout(dd4hep::DEBUG,
"sensitive in sens ", ssensitive);
105 std::stringstream pipeInfo;
106 pipeInfo << std::setw(8) << zStart /units::mm
107 << std::setw(8) << zEnd /units::mm
108 << std::setw(8) << rInnerStart /units::mm
109 << std::setw(8) << rInnerEnd /units::mm
110 << std::setw(8) << rOuterStart /units::mm
111 << std::setw(8) << rOuterEnd /units::mm
112 << std::setw(8) << thickness /units::mm
113 << std::setw(8) << crossType
114 << std::setw(35) << volName
115 << std::setw(15) << sectionMat.
name()
116 << std::setw(8) << phi1
117 << std::setw(8) << phi2
118 << std::setw(8) << ssensitive;
120 printout(dd4hep::INFO,
"DD4hep_Mask", pipeInfo.str() );
123 const double zHalf = fabs(zEnd - zStart) * 0.5;
124 const double zPosition = fabs(zEnd + zStart) * 0.5;
128 if (not ODH::checkForSensibleGeometry(crossingAngle, crossType)){
129 throw std::runtime_error(
" Mask_o1_v01_geo.cpp : checkForSensibleGeometry() failed " ) ;
132 const double rotateAngle = getCurrentAngle(crossingAngle, crossType);
133 const double mirrorAngle =
M_PI - rotateAngle;
144 if( rotationX ==
true) {
155 ConeSegment tubeSolid( zHalf, rInnerStart, rOuterStart, rInnerEnd, rOuterEnd , phi1, phi2);
158 Volume tubeLog0( volName, tubeSolid, material ) ;
159 Volume tubeLog1( volName, tubeSolid, material ) ;
161 tubeLog0.setSensitiveDetector(sens);
162 tubeLog1.setSensitiveDetector(sens);
164 tubeLog0.setVisAttributes(description, xmlMask.visStr() );
165 tubeLog1.setVisAttributes(description, xmlMask.visStr() );
168 PlacedVolume placed0 = envelope.placeVolume( tubeLog0, transformer );
169 PlacedVolume placed1 = envelope.placeVolume( tubeLog1, transmirror );
182 const double rUpstreamPunch = rInnerStart;
183 const double rDnstreamPunch = rInnerEnd;
194 ConeSegment wholeSolid( zHalf, 0, rOuterStart, 0, rOuterEnd, phi1, phi2 );
195 Solid tmpSolid0, tmpSolid1, finalSolid0, finalSolid1;
201 if ( rUpstreamPunch > 1e-6 ) {
202 Tube upstreamPunch( 0, rUpstreamPunch, 5 * zHalf, phi1, phi2);
203 tmpSolid0 =
SubtractionSolid( wholeSolid, upstreamPunch, upstreamTransformer);
204 tmpSolid1 =
SubtractionSolid( wholeSolid, upstreamPunch, dnstreamTransformer);
206 tmpSolid0 = wholeSolid;
207 tmpSolid1 = wholeSolid;
210 if (rDnstreamPunch > 1e-6 ) {
211 Tube dnstreamPunch( 0, rDnstreamPunch, 5 * zHalf, phi1, phi2);
212 finalSolid0 =
SubtractionSolid( tmpSolid0, dnstreamPunch, dnstreamTransformer);
213 finalSolid1 =
SubtractionSolid( tmpSolid1, dnstreamPunch, upstreamTransformer);
215 finalSolid0 = tmpSolid0;
216 finalSolid1 = tmpSolid1;
220 Volume tubeLog0( volName +
"_0", finalSolid0, material );
221 Volume tubeLog1( volName +
"_1", finalSolid1, material );
223 tubeLog0.setSensitiveDetector(sens);
224 tubeLog1.setSensitiveDetector(sens);
226 tubeLog0.setVisAttributes(description, xmlMask.visStr() );
227 tubeLog1.setVisAttributes(description, xmlMask.visStr() );
230 PlacedVolume placed0 = envelope.placeVolume( tubeLog0, placementTransformer );
231 PlacedVolume placed1 = envelope.placeVolume( tubeLog1, placementTransmirror );
258 ConeSegment wholeSolid( zHalf, rCenterPunch , rOuterStart, rCenterPunch, rOuterEnd, phi1, phi2);
259 Tube punchSolid( 0, rOffsetPunch, 5 * zHalf, phi1, phi2);
268 Volume tubeLog0( volName +
"_0", finalSolid0, material );
269 Volume tubeLog1( volName +
"_1", finalSolid1, material );
271 tubeLog0.setSensitiveDetector(sens);
272 tubeLog1.setSensitiveDetector(sens);
274 tubeLog0.setVisAttributes(description, xmlMask.visStr() );
275 tubeLog1.setVisAttributes(description, xmlMask.visStr() );
278 PlacedVolume placed0 = envelope.placeVolume( tubeLog0, placementTransformer );
279 PlacedVolume placed1 = envelope.placeVolume( tubeLog1, placementTransmirror );
291 if (xmlSection.hasAttr(
_Unicode(side))) {
292 maskSide = xmlSection.attr<
int>(
_Unicode(side));
295 double extraThick = 0.0;
296 if (xmlSection.hasAttr(
_Unicode(extra_thickness))) {
297 extraThick = xmlSection.attr<
double>(
_Unicode(extra_thickness));
301 const double origBaseHalf = zHalf;
302 const double maskWidthHalf = rInnerStart;
303 const double offset = rInnerEnd;
304 const double maskTopHalf = rOuterStart;
305 const double origHeightHalf = rOuterEnd;
309 const double maskHeightHalf = origHeightHalf + (extraThick / 2.0);
310 const double maskBaseHalf = maskTopHalf + (origBaseHalf - maskTopHalf) * (maskHeightHalf / origHeightHalf);
312 Trd2 oversizedMask(maskBaseHalf, maskTopHalf, maskWidthHalf, maskWidthHalf, maskHeightHalf);
321 maskLocalPos =
Position(offset + maskHeightHalf, 0.0, 0.0);
325 maskLocalPos =
Position(-(offset + maskHeightHalf), 0.0, 0.0);
329 Transform3D maskTransform(maskOrientation, maskLocalPos);
333 Tube outerTube(rInnerStart, rInnerStart + extraThick + 10.0 * units::mm, zHalf * 2.0);
337 Transform3D tubeInMaskFrame = maskTransform.Inverse();
342 Volume maskVol(volName, finalMaskSolid, material);
344 maskVol.setSensitiveDetector(sens);
346 maskVol.setVisAttributes(description, xmlMask.visStr());
359 Transform3D transformFwd = transformer * maskTransform;
360 PlacedVolume placedFwd = envelope.placeVolume(maskVol, transformFwd);
362 Transform3D transformBwd = transmirror * maskTransform;
363 PlacedVolume placedBwd = envelope.placeVolume(maskVol, transformBwd);
373 throw std::runtime_error(
" Mask_o1_v01_geo.cpp : fatal failure !! ?? " ) ;
383 pv.addPhysVolID(
"system", xmlMask.id() ) ;
385 tube.setVisAttributes( description, xmlMask.visStr(), envelope );
387 tube.setPlacement(pv);