8 #include "GeoModelKernel/GeoFullPhysVol.h" 
    9 #include "GeoModelKernel/GeoIdentifierTag.h" 
   10 #include "GeoModelKernel/GeoLogVol.h" 
   11 #include "GeoModelKernel/GeoMaterial.h" 
   12 #include "GeoModelKernel/GeoNameTag.h" 
   13 #include "GeoModelKernel/GeoPhysVol.h" 
   14 #include "GeoModelKernel/GeoSerialDenominator.h" 
   15 #include "GeoModelKernel/GeoSerialIdentifier.h" 
   16 #include "GeoModelKernel/GeoTransform.h" 
   17 #include "GeoModelKernel/GeoTrd.h" 
   18 #include "GeoModelKernel/GeoTube.h" 
   25 #include "GaudiKernel/SystemOfUnits.h" 
   26 #include "GeoModelKernel/GeoShapeIntersection.h" 
   27 #include "GeoModelKernel/GeoShapeShift.h" 
   28 #include "GeoModelKernel/GeoShapeSubtraction.h" 
   32 #define skip_tgc false 
   49         std::vector<Cutout *> vcutdef;
 
   51         return build(matManager, mysql, minimalgeo, cutoutson, vcutdef);
 
   56                                int minimalgeo, 
int cutoutson,
 
   57                                const std::vector<Cutout *>& vcutdef) {
 
   63         if (cutoutson && !vcutdef.empty()) {
 
   65             GeoShape *cutoutShape = 
nullptr;
 
   67             for (
unsigned i = 0; 
i < vcutdef.size(); 
i++) {
 
   70                 cutTrans = GeoTrf::Translate3D(0.0, 
cut->dx, -
length / 2 + 
cut->dy + 
cut->lengthY / 2.);
 
   71                 strd = &(strd->subtract((*cutoutShape) << cutTrans));
 
   75         const GeoMaterial *mtrd = matManager.
getMaterial(
"std::G10");
 
   76         GeoLogVol *ltrd = 
new GeoLogVol(
logVolName, strd, mtrd);
 
   77         GeoFullPhysVol *ptrd = 
new GeoFullPhysVol(ltrd);
 
   84             ptrd->add(
new GeoSerialIdentifier(0));
 
   90         for (
int i = 0; 
i < 
t->nlayers; 
i++) {
 
   92             double longWidthActive;
 
   95             if (
t->materials[
i] == 
"muo::TGCGas") {
 
   99                     ptrd->add(
new GeoIdentifierTag(igl));
 
  101                 widthActive = 
width - (
t->frame_ab) * 2;
 
  102                 longWidthActive = 
longWidth - (
t->frame_ab) * 2;
 
  103                 lengthActive = 
length - (
t->frame_h) * 2;
 
  105                 const GeoShape *sGasVolume = 
new GeoTrd(
t->tck[
i] / 2, 
t->tck[
i] / 2, widthActive / 2, longWidthActive / 2, lengthActive / 2);
 
  107                 if (
t->widthWireSupport != 0. && 
t->radiusButton != 0.) {
 
  112                     GeoTrd *strdsup = 
new GeoTrd(
t->tck[
i] / 2, 
t->tck[
i] / 2, 
t->widthWireSupport / 2, 
t->widthWireSupport / 2, lengthActive / 2 - 0.1 * 
Gaudi::Units::mm);
 
  114                     GeoTube *stubesup = 
new GeoTube(0., 
t->radiusButton, 
t->tck[
i] / 2. + 0.005 * 
Gaudi::Units::mm);
 
  117                     int iymin = 
int(-(widthActive / 2. + lengthActive * 
tan(
t->angleTilt) - 
t->widthWireSupport / 2. + 
t->offsetWireSupport[iSenLyr]) / 
t->distanceWireSupport);
 
  118                     int iymax = 
int((widthActive / 2. + lengthActive * 
tan(
t->angleTilt) - 
t->widthWireSupport / 2. - 
t->offsetWireSupport[iSenLyr]) / 
t->distanceWireSupport);
 
  120                     for (
int isup = iymin; isup <= iymax; isup++) { 
 
  123                         if (
t->offsetWireSupport[iSenLyr] + 
t->distanceWireSupport * isup > 0.) {
 
  125                         } 
else if (
t->offsetWireSupport[iSenLyr] + 
t->distanceWireSupport * isup == 0.) {
 
  128                         GeoTrf::RotateX3D rotX(
sign * 
t->angleTilt);
 
  129                         GeoTrf::Translate3D vtransWS(0., 
t->offsetWireSupport[iSenLyr] + 
t->distanceWireSupport * isup + lengthActive / 2. * 
tan(
sign * 
t->angleTilt), 0.);
 
  135                         izmax = 
int((lengthActive / 2. - 
t->radiusButton) / (
t->pitchButton[1] / 2.));
 
  139                         double yposCentre[2], angleTiltButton[2];
 
  141                             double yLongBase, yShortBase;
 
  143                                 ((
t->offsetWireSupport[iSenLyr] + 
t->distanceWireSupport * (isup + 1)) + (
t->offsetWireSupport[iSenLyr] + 
t->distanceWireSupport * isup)) / 2.;
 
  144                             if (
t->offsetWireSupport[iSenLyr] + 
t->distanceWireSupport * (isup + 1) < 0.) {
 
  145                                 yShortBase = yLongBase + lengthActive * 
tan(
t->angleTilt);
 
  146                             } 
else if (
t->offsetWireSupport[iSenLyr] + 
t->distanceWireSupport * (isup) > 0.) {
 
  147                                 yShortBase = yLongBase + lengthActive * 
tan(-
t->angleTilt);
 
  149                                 yShortBase = yLongBase;
 
  153                             yposCentre[0] = yLongBase;
 
  154                             angleTiltButton[0] = 
atan((yShortBase - yLongBase) / lengthActive);
 
  156                         } 
else if (isup == iymax) {
 
  158                             if (
name == 
"TGC01" || 
name == 
"TGC06" || 
name == 
"TGC12") {
 
  159                                 for (
int iside = 0; iside < 2; iside++) {
 
  168                                     double lengthWireSupportEx;
 
  169                                     lengthWireSupportEx = lengthActive / (longWidthActive / 2. - widthActive / 2.) *
 
  170                                                           (longWidthActive / 2. - fabs(
t->distanceWireSupport * isupy + 
t->offsetWireSupport[iSenLyr]));
 
  171                                     GeoTrd *strdsupex = 
new GeoTrd(
t->tck[
i] / 2, 
t->tck[
i] / 2, 
t->widthWireSupport / 2, 
t->widthWireSupport / 2,
 
  173                                     GeoTrf::Translate3D vtrans(0., 
t->offsetWireSupport[iSenLyr] + 
t->distanceWireSupport * isupy + lengthActive / 2. * 
tan(
sign * 
t->angleTilt),
 
  174                                                                (lengthActive - lengthWireSupportEx) / 2.);
 
  181                             double widthLeftTrd = (
t->distanceWireSupport * iymin + 
t->offsetWireSupport[iSenLyr] + lengthActive * 
tan(
t->angleTilt)) - (-widthActive / 2.);
 
  184                                 if ((
name == 
"TGC01" || 
name == 
"TGC06" || 
name == 
"TGC12") &&
 
  185                                     t->distanceWireSupport * (iymin - 1) + 
t->offsetWireSupport[iSenLyr] > -longWidthActive / 2.) {
 
  186                                     yLongBase = ((
t->distanceWireSupport * (iymin - 1) + 
t->offsetWireSupport[iSenLyr]) +
 
  187                                                  (
t->distanceWireSupport * iymin + 
t->offsetWireSupport[iSenLyr])) /
 
  190                                     yLongBase = ((
t->distanceWireSupport * iymin + 
t->offsetWireSupport[iSenLyr]) + (-longWidthActive / 2.)) / 2.;
 
  193                                     ((
t->distanceWireSupport * iymin + 
t->offsetWireSupport[iSenLyr] + lengthActive * 
tan(
t->angleTilt)) + (-widthActive / 2.)) / 2.;
 
  194                                 yposCentre[nBS] = yLongBase;
 
  195                                 angleTiltButton[nBS] = 
atan((yShortBase - yLongBase) / lengthActive);
 
  199                             double widthRightTrd = widthActive / 2. - (
t->distanceWireSupport * iymax + 
t->offsetWireSupport[iSenLyr] + lengthActive * 
tan(-
t->angleTilt));
 
  203                                 if ((
name == 
"TGC01" || 
name == 
"TGC06" || 
name == 
"TGC12") &&
 
  204                                     t->distanceWireSupport * (iymax + 1) + 
t->offsetWireSupport[iSenLyr] < longWidthActive / 2.) {
 
  205                                     yLongBase = ((
t->distanceWireSupport * (iymax + 1) + 
t->offsetWireSupport[iSenLyr]) +
 
  206                                                  (
t->distanceWireSupport * iymax + 
t->offsetWireSupport[iSenLyr])) /
 
  209                                     yLongBase = ((
t->distanceWireSupport * iymax + 
t->offsetWireSupport[iSenLyr]) + longWidthActive / 2.) / 2.;
 
  211                                 double yShortBase = ((
t->distanceWireSupport * iymax + 
t->offsetWireSupport[iSenLyr] + lengthActive * 
tan(-
t->angleTilt)) + widthActive / 2.) / 2.;
 
  212                                 yposCentre[nBS] = yLongBase;
 
  213                                 angleTiltButton[nBS] = 
atan((yShortBase - yLongBase) / lengthActive);
 
  221                         for (
int iBS = 0; iBS < nBS; iBS++) {
 
  222                             for (
int isupz = izmin; isupz <= izmax; isupz++) {
 
  223                                 double yposleft = yposCentre[iBS] - 
t->pitchButton[0] / 2. + (lengthActive / 2. - 
t->pitchButton[1] / 2. * isupz) * 
tan(angleTiltButton[iBS]);
 
  224                                 GeoTrf::Translate3D vtransBS(0., yposleft + 
t->pitchButton[0] * std::abs(isupz % 2), 
t->pitchButton[1] / 2. * isupz);
 
  231                 if (cutoutson && !vcutdef.empty()) {
 
  235                     GeoShape *cutoutShape = 
nullptr;
 
  237                     for (
unsigned i = 0; 
i < vcutdef.size(); 
i++) {
 
  239                         cutoutShape = 
new GeoTrd(
thickness / 2. + 1., 
thickness / 2. + 1., 
cut->widthXs / 2. + 
t->frame_ab / 2., 
cut->widthXl / 2. + 
t->frame_ab / 2.,
 
  240                                                  cut->lengthY / 2. + 
t->frame_h / 2.);
 
  241                         cutTrans = GeoTrf::Translate3D(0.0, 
cut->dx, -
length / 2 + 
cut->dy + 
cut->lengthY / 2.);
 
  242                         sGasVolume = &(sGasVolume->subtract((*cutoutShape) << cutTrans));
 
  246                 GeoLogVol *ltrdtmp = 
new GeoLogVol(
t->materials[
i], sGasVolume, matManager.
getMaterial(
t->materials[
i]));
 
  247                 GeoPhysVol *ptrdtmp = 
new GeoPhysVol(ltrdtmp);
 
  248                 GeoNameTag *ntrdtmp = 
new GeoNameTag(
name + 
t->materials[
i]);
 
  249                 GeoTransform *ttrdtmp = 
new GeoTransform(GeoTrf::TranslateX3D(newpos + (
t->tck[
i] / 2)));
 
  261             } 
else if (
t->materials[
i] != 
"std:G10") {
 
  265                 if (cutoutson && !vcutdef.empty()) {
 
  267                     GeoShape *cutoutShape = 
nullptr;
 
  269                     for (
unsigned i = 0; 
i < vcutdef.size(); 
i++) {
 
  272                         cutTrans = GeoTrf::Translate3D(0.0, 
cut->dx, -
length / 2 + 
cut->dy + 
cut->lengthY / 2.);
 
  273                         strdtmp = &(strdtmp->subtract((*cutoutShape) << cutTrans));
 
  276                 GeoLogVol *ltrdtmp = 
new GeoLogVol(
t->materials[
i], strdtmp, matManager.
getMaterial(
t->materials[
i]));
 
  277                 GeoPhysVol *ptrdtmp = 
new GeoPhysVol(ltrdtmp);
 
  278                 GeoNameTag *ntrdtmp = 
new GeoNameTag(
name + 
t->materials[
i]);
 
  279                 GeoTransform *ttrdtmp = 
new GeoTransform(GeoTrf::TranslateX3D(newpos + (
t->tck[
i] / 2)));