Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/divisions/src/G4ParameterisationTrd.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/divisions/src/G4ParameterisationTrd.cc (Version 11.3.0) and /geometry/divisions/src/G4ParameterisationTrd.cc (Version 7.1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 // G4ParameterisationTrd[X/Y/Z] implementation <<  23 //
                                                   >>  24 // $Id: G4ParameterisationTrd.cc,v 1.11 2004/12/02 09:31:22 gcosmo Exp $
                                                   >>  25 // GEANT4 tag $Name: geant4-07-01 $
                                                   >>  26 //
                                                   >>  27 // class G4ParameterisationTrd Implementation file
 27 //                                                 28 //
 28 // 26.05.03 - P.Arce, Initial version              29 // 26.05.03 - P.Arce, Initial version
 29 // 08.04.04 - I.Hrivnacova, Implemented reflec     30 // 08.04.04 - I.Hrivnacova, Implemented reflection
 30 // 21.04.10 - M.Asai, Added gaps               << 
 31 // -------------------------------------------     31 // --------------------------------------------------------------------
 32                                                    32 
 33 #include "G4ParameterisationTrd.hh"                33 #include "G4ParameterisationTrd.hh"
 34                                                    34 
 35 #include <iomanip>                                 35 #include <iomanip>
 36 #include "G4ThreeVector.hh"                        36 #include "G4ThreeVector.hh"
 37 #include "G4RotationMatrix.hh"                     37 #include "G4RotationMatrix.hh"
 38 #include "G4VPhysicalVolume.hh"                    38 #include "G4VPhysicalVolume.hh"
 39 #include "G4LogicalVolume.hh"                      39 #include "G4LogicalVolume.hh"
 40 #include "G4ReflectedSolid.hh"                     40 #include "G4ReflectedSolid.hh"
 41 #include "G4Trd.hh"                                41 #include "G4Trd.hh"
 42 #include "G4Trap.hh"                               42 #include "G4Trap.hh"
 43                                                    43 
 44 //--------------------------------------------     44 //--------------------------------------------------------------------------
 45 G4VParameterisationTrd::                           45 G4VParameterisationTrd::
 46 G4VParameterisationTrd( EAxis axis, G4int nDiv     46 G4VParameterisationTrd( EAxis axis, G4int nDiv, G4double width,
 47                         G4double offset, G4VSo     47                         G4double offset, G4VSolid* msolid,
 48                         DivisionType divType )     48                         DivisionType divType )
 49   :  G4VDivisionParameterisation( axis, nDiv,      49   :  G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid )
 50 {                                                  50 {
 51   auto msol = (G4Trd*)(msolid);                <<  51   G4Trd* msol = (G4Trd*)(msolid);
 52   if (msolid->GetEntityType() == "G4ReflectedS     52   if (msolid->GetEntityType() == "G4ReflectedSolid")
 53   {                                                53   {
 54     // Get constituent solid                       54     // Get constituent solid  
 55     G4VSolid* mConstituentSolid                    55     G4VSolid* mConstituentSolid 
 56        = ((G4ReflectedSolid*)msolid)->GetConst     56        = ((G4ReflectedSolid*)msolid)->GetConstituentMovedSolid();
 57     msol = (G4Trd*)(mConstituentSolid);            57     msol = (G4Trd*)(mConstituentSolid);
 58                                                    58   
 59     // Create a new solid with inversed parame     59     // Create a new solid with inversed parameters
 60     auto newSolid                              <<  60     G4Trd* newSolid
 61       = new G4Trd(msol->GetName(),                 61       = new G4Trd(msol->GetName(),
 62                   msol->GetXHalfLength2(), mso     62                   msol->GetXHalfLength2(), msol->GetXHalfLength1(),
 63                   msol->GetYHalfLength2(), mso     63                   msol->GetYHalfLength2(), msol->GetYHalfLength1(),
 64                   msol->GetZHalfLength());         64                   msol->GetZHalfLength());
 65     msol = newSolid;                               65     msol = newSolid;
 66     fmotherSolid = newSolid;                       66     fmotherSolid = newSolid;
 67     fReflectedSolid = true;                        67     fReflectedSolid = true;
 68     fDeleteSolid = true;                           68     fDeleteSolid = true;
 69   }                                                69   }    
 70 }                                                  70 }
 71                                                    71 
 72 //--------------------------------------------     72 //------------------------------------------------------------------------
 73 G4VParameterisationTrd::~G4VParameterisationTr <<  73 G4VParameterisationTrd::~G4VParameterisationTrd()
                                                   >>  74 {
                                                   >>  75 }
 74                                                    76 
 75 //--------------------------------------------     77 //------------------------------------------------------------------------
 76 G4ParameterisationTrdX::                           78 G4ParameterisationTrdX::
 77 G4ParameterisationTrdX( EAxis axis, G4int nDiv     79 G4ParameterisationTrdX( EAxis axis, G4int nDiv,
 78                         G4double width, G4doub     80                         G4double width, G4double offset,
 79                         G4VSolid* msolid, Divi     81                         G4VSolid* msolid, DivisionType divType )
 80   :  G4VParameterisationTrd( axis, nDiv, width     82   :  G4VParameterisationTrd( axis, nDiv, width, offset, msolid, divType )
 81 {                                                  83 {
 82   CheckParametersValidity();                       84   CheckParametersValidity();
 83   SetType( "DivisionTrdX" );                       85   SetType( "DivisionTrdX" );
 84                                                    86 
 85   auto msol = (G4Trd*)(fmotherSolid);          <<  87   G4Trd* msol = (G4Trd*)(fmotherSolid);
 86   if( divType == DivWIDTH )                        88   if( divType == DivWIDTH )
 87   {                                                89   {
 88     fnDiv = CalculateNDiv( msol->GetXHalfLengt <<  90     fnDiv = CalculateNDiv( 2*msol->GetXHalfLength1(),
 89                            width, offset );        91                            width, offset );
 90   }                                                92   }
 91   else if( divType == DivNDIV )                    93   else if( divType == DivNDIV )
 92   {                                                94   {
 93     fwidth = CalculateWidth( msol->GetXHalfLen <<  95     fwidth = CalculateWidth( 2*msol->GetXHalfLength1(), nDiv, offset );
 94                              nDiv, offset );   << 
 95   }                                                96   }
 96                                                    97 
 97 #ifdef G4DIVDEBUG                                  98 #ifdef G4DIVDEBUG
 98   if( verbose >= 1 )                           <<  99   if( verbose >= -1 )
 99   {                                               100   {
100     G4cout << " G4ParameterisationTrdX - ## di    101     G4cout << " G4ParameterisationTrdX - ## divisions " << fnDiv << " = "
101            << nDiv << G4endl                      102            << nDiv << G4endl
102            << " Offset " << foffset << " = " <    103            << " Offset " << foffset << " = " << offset << G4endl
103            << " Width " << fwidth << " = " <<     104            << " Width " << fwidth << " = " << width << G4endl;
104   }                                               105   }
105 #endif                                            106 #endif
106                                                << 
107   G4double mpDx1 = msol->GetXHalfLength1();    << 
108   G4double mpDx2 = msol->GetXHalfLength2();    << 
109   if( std::fabs(mpDx1 - mpDx2) > kCarTolerance << 
110   {                                            << 
111     bDivInTrap = true;                         << 
112   }                                            << 
113 }                                                 107 }
114                                                   108 
115 //--------------------------------------------    109 //------------------------------------------------------------------------
116 G4ParameterisationTrdX::~G4ParameterisationTrd    110 G4ParameterisationTrdX::~G4ParameterisationTrdX()
117 = default;                                     << 111 {
                                                   >> 112 }
118                                                   113 
119 //--------------------------------------------    114 //------------------------------------------------------------------------
120 G4double G4ParameterisationTrdX::GetMaxParamet    115 G4double G4ParameterisationTrdX::GetMaxParameter() const
121 {                                                 116 {
122   auto msol = (G4Trd*)(fmotherSolid);          << 117   G4Trd* msol = (G4Trd*)(fmotherSolid);
123   return (msol->GetXHalfLength1()+msol->GetXHa << 118   return 2*msol->GetXHalfLength1();
124 }                                                 119 }
125                                                   120 
126 //--------------------------------------------    121 //------------------------------------------------------------------------
127 void                                              122 void
128 G4ParameterisationTrdX::                          123 G4ParameterisationTrdX::
129 ComputeTransformation( const G4int copyNo,        124 ComputeTransformation( const G4int copyNo,
130                        G4VPhysicalVolume *phys    125                        G4VPhysicalVolume *physVol ) const
131 {                                                 126 {
132   auto msol = (G4Trd*)(fmotherSolid );         << 127   G4Trd* msol = (G4Trd*)(fmotherSolid );
133   G4double mdx = ( msol->GetXHalfLength1() + m << 128   G4double mdx = msol->GetXHalfLength1();
                                                   >> 129 
134   //----- translation                             130   //----- translation 
135   G4ThreeVector origin(0.,0.,0.);                 131   G4ThreeVector origin(0.,0.,0.); 
136   G4double posi;                               << 132   G4double posi = -mdx + foffset + (copyNo+0.5)*fwidth;
137   posi = -mdx + foffset + (copyNo+0.5)*fwidth; << 
138   if( faxis == kXAxis )                           133   if( faxis == kXAxis )
139   {                                               134   {
140     origin.setX( posi );                          135     origin.setX( posi ); 
141   }                                               136   }
142   else                                            137   else
143   {                                               138   { 
144     std::ostringstream message;                << 139     G4cerr << "ERROR - G4ParameterisationTrdX::ComputeTransformation()"
145     message << "Only axes along X are allowed  << 140            << G4endl
                                                   >> 141            << "        Axis is along " << faxis << " !" << G4endl;
146     G4Exception("G4ParameterisationTrdX::Compu    142     G4Exception("G4ParameterisationTrdX::ComputeTransformation()",
147                 "GeomDiv0002", FatalException, << 143                 "IllegalConstruct", FatalException,
                                                   >> 144                 "Only axes along X are allowed !");
148   }                                               145   }
149                                                   146 
150 #ifdef G4DIVDEBUG                                 147 #ifdef G4DIVDEBUG
151   if( verbose >= 2 )                           << 148   if( verbose >= -2 )
152   {                                               149   {
153     G4cout << std::setprecision(8)             << 150     G4cout << std::setprecision(8) << " G4ParameterisationTrdX: "
154            << " G4ParameterisationTrdX::Comput << 
155            << copyNo << G4endl                    151            << copyNo << G4endl
156            << " Position: " << origin << " - A    152            << " Position: " << origin << " - Axis: " << faxis << G4endl;
157   }                                               153   }
158 #endif                                            154 #endif
159                                                   155 
160    //----- set translation                        156    //----- set translation 
161   physVol->SetTranslation( origin );              157   physVol->SetTranslation( origin );
162 }                                                 158 }
163                                                   159 
164 //--------------------------------------------    160 //--------------------------------------------------------------------------
165 void                                              161 void
166 G4ParameterisationTrdX::                          162 G4ParameterisationTrdX::
167 ComputeDimensions( G4Trd& trd, [[maybe_unused] << 163 ComputeDimensions( G4Trd& trd, const G4int, const G4VPhysicalVolume* ) const
168 {                                              << 164 {
169   auto msol = (G4Trd*)(fmotherSolid);          << 165   G4Trd* msol = (G4Trd*)(fmotherSolid);
                                                   >> 166 
170   G4double pDy1 = msol->GetYHalfLength1();        167   G4double pDy1 = msol->GetYHalfLength1();
171   G4double pDy2 = msol->GetYHalfLength2();        168   G4double pDy2 = msol->GetYHalfLength2();
172   G4double pDz = msol->GetZHalfLength();          169   G4double pDz = msol->GetZHalfLength();
173   G4double pDx = fwidth/2. - fhgap;            << 170   G4double pDx = fwidth/2.;
174                                                << 171  
175   trd.SetAllParameters ( pDx, pDx, pDy1, pDy2,    172   trd.SetAllParameters ( pDx, pDx, pDy1, pDy2, pDz );
176                                                   173 
177 #ifdef G4DIVDEBUG                                 174 #ifdef G4DIVDEBUG
178   if( verbose >= 2 )                           << 175   if( verbose >= -2 )
179   {                                               176   {
180     G4cout << " G4ParameterisationTrdX::Comput << 177      G4cout << " G4ParameterisationTrdX::ComputeDimensions():" << G4endl;
181            << copyNo << G4endl;                << 178      trd.DumpInfo();
182     trd.DumpInfo();                            << 
183   }                                               179   }
184 #endif                                            180 #endif
185 }                                                 181 }
186                                                   182 
187 //--------------------------------------------    183 //--------------------------------------------------------------------------
188 void                                           << 184 void G4ParameterisationTrdX::CheckParametersValidity()
189 G4ParameterisationTrdX::ComputeDimensions( G4T << 
190                                            con << 
191 {                                                 185 {
192   auto msol = (G4Trd*)(fmotherSolid);          << 186   G4VDivisionParameterisation::CheckParametersValidity();
193   G4double pDy1 = msol->GetYHalfLength1();     << 
194   G4double pDy2 = msol->GetYHalfLength2();     << 
195   G4double pDz = msol->GetZHalfLength();       << 
196   //fwidth is at Z=0                           << 
197   G4double pDx1 = msol->GetXHalfLength1();     << 
198   G4double pDx2 = msol->GetXHalfLength2();     << 
199   //  G4double pDxAVE = (pDx1+pDx2)/2.;        << 
200   G4double xChangeRatio = (pDx2-pDx1) / (pDx2+ << 
201   G4double fWidChange = xChangeRatio*fwidth;   << 
202   G4double fWid1 = fwidth - fWidChange;        << 
203   G4double fWid2 = fwidth + fWidChange;        << 
204   G4double fOffsetChange = xChangeRatio*foffse << 
205   G4double fOffset1 = foffset - fOffsetChange; << 
206   G4double fOffset2 = foffset + fOffsetChange; << 
207   G4double cxy1 = -pDx1+fOffset1 + (copyNo+0.5 << 
208   G4double cxy2 = -pDx2+fOffset2 + (copyNo+0.5 << 
209   G4double alp = std::atan( (cxy2-cxy1)/(pDz*2 << 
210                                                << 
211   pDx1 = fwidth/2. - fWidChange/2.;            << 
212   pDx2 = fwidth/2. + fWidChange/2.;            << 
213                                                << 
214                                                << 
215   trap.SetAllParameters ( pDz,                 << 
216         alp,                                   << 
217         0.,                                    << 
218         pDy1,                                  << 
219         pDx1,                                  << 
220         pDx1,                                  << 
221         0.,                                    << 
222         pDy2,                                  << 
223         pDx2 - fhgap,                          << 
224         pDx2 - fhgap * pDx2/pDx1,              << 
225         0.);                                   << 
226                                                   187 
227 #ifdef G4DIVDEBUG                              << 188   G4Trd* msol = (G4Trd*)(fmotherSolid);
228   if( verbose >= 2 )                           << 189 
                                                   >> 190   G4double mpDx1 = msol->GetXHalfLength1();
                                                   >> 191   G4double mpDx2 = msol->GetXHalfLength2();
                                                   >> 192 
                                                   >> 193   if( std::fabs(mpDx1 - mpDx2) > kCarTolerance )
229   {                                               194   {
230     G4cout << " G4ParameterisationTrdX::Comput << 195     G4cerr << "ERROR - G4ParameterisationTrdX::CheckParametersValidity()"
231            << copyNo << G4endl;                << 196            << G4endl
232     trap.DumpInfo();                           << 197            << "        Making a division of a TRD along axis X," << G4endl
                                                   >> 198            << "        while the X half lengths are not equal," << G4endl
                                                   >> 199            << "        is not (yet) supported. It will result" << G4endl
                                                   >> 200            << "        in non-equal division solids." << G4endl;
                                                   >> 201     G4Exception("G4ParameterisationTrdX::CheckParametersValidity()",
                                                   >> 202                 "IllegalConstruct", FatalException,
                                                   >> 203                 "Invalid solid specification. NOT supported.");
233   }                                               204   }
234 #endif                                         << 
235 }                                                 205 }
236                                                   206 
237                                                << 
238 //--------------------------------------------    207 //--------------------------------------------------------------------------
239 G4ParameterisationTrdY::                          208 G4ParameterisationTrdY::
240 G4ParameterisationTrdY( EAxis axis, G4int nDiv    209 G4ParameterisationTrdY( EAxis axis, G4int nDiv,
241                         G4double width, G4doub    210                         G4double width, G4double offset,
242                         G4VSolid* msolid, Divi    211                         G4VSolid* msolid, DivisionType divType)
243   : G4VParameterisationTrd( axis, nDiv, width,    212   : G4VParameterisationTrd( axis, nDiv, width, offset, msolid, divType )
244 {                                                 213 {
245   CheckParametersValidity();                      214   CheckParametersValidity();
246   SetType( "DivisionTrdY" );                      215   SetType( "DivisionTrdY" );
247                                                   216 
248   auto msol = (G4Trd*)(fmotherSolid);          << 217   G4Trd* msol = (G4Trd*)(fmotherSolid);
249   if( divType == DivWIDTH )                       218   if( divType == DivWIDTH )
250   {                                               219   {
251     fnDiv = CalculateNDiv( 2*msol->GetYHalfLen    220     fnDiv = CalculateNDiv( 2*msol->GetYHalfLength1(),
252                            width, offset );       221                            width, offset );
253   }                                               222   }
254   else if( divType == DivNDIV )                   223   else if( divType == DivNDIV )
255   {                                               224   {
256     fwidth = CalculateWidth( 2*msol->GetYHalfL    225     fwidth = CalculateWidth( 2*msol->GetYHalfLength1(),
257                              nDiv, offset );      226                              nDiv, offset );
258   }                                               227   }
259                                                   228 
260 #ifdef G4DIVDEBUG                                 229 #ifdef G4DIVDEBUG
261   if( verbose >= 1 )                              230   if( verbose >= 1 )
262   {                                               231   {
263      G4cout << " G4ParameterisationTrdY no div    232      G4cout << " G4ParameterisationTrdY no divisions " << fnDiv
264             << " = " << nDiv << G4endl            233             << " = " << nDiv << G4endl
265             << " Offset " << foffset << " = "     234             << " Offset " << foffset << " = " << offset << G4endl
266             << " width " << fwidth << " = " <<    235             << " width " << fwidth << " = " << width << G4endl;
267   }                                               236   }
268 #endif                                            237 #endif
269 }                                                 238 }
270                                                   239 
271 //--------------------------------------------    240 //------------------------------------------------------------------------
272 G4ParameterisationTrdY::~G4ParameterisationTrd << 241 G4ParameterisationTrdY::~G4ParameterisationTrdY()
                                                   >> 242 {
                                                   >> 243 }
273                                                   244 
274 //--------------------------------------------    245 //------------------------------------------------------------------------
275 G4double G4ParameterisationTrdY::GetMaxParamet    246 G4double G4ParameterisationTrdY::GetMaxParameter() const
276 {                                                 247 {
277   auto msol = (G4Trd*)(fmotherSolid);          << 248   G4Trd* msol = (G4Trd*)(fmotherSolid);
278   return (msol->GetYHalfLength1()+msol->GetYHa << 249   return 2*msol->GetYHalfLength1();
279 }                                                 250 }
280                                                   251 
281 //--------------------------------------------    252 //--------------------------------------------------------------------------
282 void                                              253 void
283 G4ParameterisationTrdY::                          254 G4ParameterisationTrdY::
284 ComputeTransformation( const G4int copyNo, G4V    255 ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const
285 {                                                 256 {
286   auto msol = (G4Trd*)(fmotherSolid );         << 257   G4Trd* msol = (G4Trd*)(fmotherSolid );
287   G4double mdy =  ( msol->GetYHalfLength1() +  << 258   G4double mdy = msol->GetYHalfLength1();
288                                                   259 
289   //----- translation                             260   //----- translation 
290   G4ThreeVector origin(0.,0.,0.);                 261   G4ThreeVector origin(0.,0.,0.); 
291   G4double posi = -mdy + foffset + (copyNo+0.5    262   G4double posi = -mdy + foffset + (copyNo+0.5)*fwidth;
292                                                << 
293   if( faxis == kYAxis )                           263   if( faxis == kYAxis )
294   {                                               264   {
295     origin.setY( posi );                          265     origin.setY( posi ); 
296   }                                               266   }
297   else                                            267   else
298   {                                               268   { 
299     std::ostringstream message;                << 
300     message << "Only axes along Y are allowed  << 
301     G4Exception("G4ParameterisationTrdY::Compu    269     G4Exception("G4ParameterisationTrdY::ComputeTransformation()",
302                 "GeomDiv0002", FatalException, << 270                 "IllegalConstruct", FatalException,
                                                   >> 271                 "Only axes along Y are allowed !");
303   }                                               272   }
304                                                   273 
305 #ifdef G4DIVDEBUG                                 274 #ifdef G4DIVDEBUG
306   if( verbose >= 2 )                              275   if( verbose >= 2 )
307   {                                               276   {
308     G4cout << std::setprecision(8)             << 277     G4cout << std::setprecision(8) << " G4ParameterisationTrdY " << copyNo
309            << " G4ParameterisationTrdY::Comput << 
310            << " pos " << origin << " rot mat "    278            << " pos " << origin << " rot mat " << " axis " << faxis << G4endl;
311   }                                               279   }
312 #endif                                            280 #endif
313                                                   281 
314    //----- set translation                        282    //----- set translation 
315   physVol->SetTranslation( origin );              283   physVol->SetTranslation( origin );
316 }                                                 284 }
317                                                   285 
318 //--------------------------------------------    286 //--------------------------------------------------------------------------
319 void                                              287 void
320 G4ParameterisationTrdY::                          288 G4ParameterisationTrdY::
321 ComputeDimensions(G4Trd& trd, const G4int, con    289 ComputeDimensions(G4Trd& trd, const G4int, const G4VPhysicalVolume*) const
322 {                                                 290 {
323   //---- The division along Y of a Trd will re    291   //---- The division along Y of a Trd will result a Trd, only 
324   //--- if Y at -Z and +Z are equal, else use     292   //--- if Y at -Z and +Z are equal, else use the G4Trap version
325   auto msol = (G4Trd*)(fmotherSolid);          << 293   G4Trd* msol = (G4Trd*)(fmotherSolid);
326                                                   294   
327   G4double pDx1 = msol->GetXHalfLength1();        295   G4double pDx1 = msol->GetXHalfLength1();
328   G4double pDx2 = msol->GetXHalfLength2();        296   G4double pDx2 = msol->GetXHalfLength2();
329   G4double pDz = msol->GetZHalfLength();          297   G4double pDz = msol->GetZHalfLength();
330   G4double pDy = fwidth/2. - fhgap;            << 298   G4double pDy = fwidth/2.;
331                                                   299  
332   trd.SetAllParameters ( pDx1, pDx2, pDy, pDy,    300   trd.SetAllParameters ( pDx1, pDx2, pDy, pDy, pDz );
333                                                   301 
334 #ifdef G4DIVDEBUG                                 302 #ifdef G4DIVDEBUG
335   if( verbose >= 2 )                              303   if( verbose >= 2 )
336   {                                               304   {
337     G4cout << " G4ParameterisationTrdY::Comput    305     G4cout << " G4ParameterisationTrdY::ComputeDimensions():" << G4endl;
338     trd.DumpInfo();                               306     trd.DumpInfo();
339   }                                               307   }
340 #endif                                            308 #endif
341 }                                                 309 }
342                                                   310 
343 //--------------------------------------------    311 //--------------------------------------------------------------------------
344 void                                           << 312 void G4ParameterisationTrdY::CheckParametersValidity()
345 G4ParameterisationTrdY::ComputeDimensions( G4T << 
346                                            con << 
347 {                                                 313 {
348   auto msol = (G4Trd*)(fmotherSolid);          << 314   G4VDivisionParameterisation::CheckParametersValidity();
349   G4double pDx1 = msol->GetXHalfLength1();     << 
350   G4double pDx2 = msol->GetXHalfLength2();     << 
351   G4double pDz = msol->GetZHalfLength();       << 
352   //fwidth is at Z=0                           << 
353   G4double pDy1 = msol->GetYHalfLength1();     << 
354   G4double pDy2 = msol->GetYHalfLength2();     << 
355   //  G4double pDxAVE = (pDy1+pDy2)/2.;        << 
356   G4double yChangeRatio = (pDy2-pDy1) / (pDy2+ << 
357   G4double fWidChange = yChangeRatio*fwidth;   << 
358   G4double fWid1 = fwidth - fWidChange;        << 
359   G4double fWid2 = fwidth + fWidChange;        << 
360   G4double fOffsetChange = yChangeRatio*foffse << 
361   G4double fOffset1 = foffset - fOffsetChange; << 
362   G4double fOffset2 = foffset + fOffsetChange; << 
363   G4double cyx1 = -pDy1+fOffset1 + (copyNo+0.5 << 
364   G4double cyx2 = -pDy2+fOffset2 + (copyNo+0.5 << 
365   G4double alp = std::atan( (cyx2-cyx1)/(pDz*2 << 
366                                                << 
367   pDy1 = fwidth/2. - fWidChange/2.;            << 
368   pDy2 = fwidth/2. + fWidChange/2.;            << 
369                                                << 
370                                                << 
371   trap.SetAllParameters ( pDz,                 << 
372         alp,                                   << 
373         90*CLHEP::deg,                         << 
374         pDy1,                                  << 
375         pDx1,                                  << 
376         pDx1,                                  << 
377         0.,                                    << 
378         pDy2,                                  << 
379         pDx2 - fhgap,                          << 
380         pDx2 - fhgap * pDx2/pDx1,              << 
381         0.);                                   << 
382                                                   315 
383 #ifdef G4DIVDEBUG                              << 316   G4Trd* msol = (G4Trd*)(fmotherSolid);
384   if( verbose >= 2 )                           << 317 
385   {                                            << 318   G4double mpDy1 = msol->GetYHalfLength1();
386     G4cout << " G4ParameterisationTrdY::Comput << 319   G4double mpDy2 = msol->GetYHalfLength2();
387            << copyNo << G4endl;                << 320 
388     trap.DumpInfo();                           << 321   if( std::fabs(mpDy1 - mpDy2) > kCarTolerance )
                                                   >> 322   {
                                                   >> 323     G4cerr << "ERROR - G4ParameterisationTrdY::CheckParametersValidity()"
                                                   >> 324            << G4endl
                                                   >> 325            << "        Making a division of a TRD along axis Y while" << G4endl
                                                   >> 326            << "        the Y half lengths are not equal is not (yet)" << G4endl
                                                   >> 327            << "        supported. It will result in non-equal" << G4endl
                                                   >> 328            << "        division solids." << G4endl;
                                                   >> 329     G4Exception("G4ParameterisationTrdY::CheckParametersValidity()",
                                                   >> 330                 "IllegalConstruct", FatalException,
                                                   >> 331                 "Invalid solid specification. NOT supported.");
389   }                                               332   }
390 #endif                                         << 
391 }                                                 333 }
392                                                   334 
393 //--------------------------------------------    335 //--------------------------------------------------------------------------
394 G4ParameterisationTrdZ::                          336 G4ParameterisationTrdZ::
395 G4ParameterisationTrdZ( EAxis axis, G4int nDiv    337 G4ParameterisationTrdZ( EAxis axis, G4int nDiv,
396                         G4double width, G4doub    338                         G4double width, G4double offset,
397                         G4VSolid* msolid, Divi    339                         G4VSolid* msolid, DivisionType divType )
398   : G4VParameterisationTrd( axis, nDiv, width,    340   : G4VParameterisationTrd( axis, nDiv, width, offset, msolid, divType )
399 {                                                 341 { 
400   CheckParametersValidity();                      342   CheckParametersValidity();
401   SetType( "DivTrdZ" );                           343   SetType( "DivTrdZ" );
402                                                   344 
403   auto msol = (G4Trd*)(fmotherSolid);          << 345   G4Trd* msol = (G4Trd*)(fmotherSolid);
404   if( divType == DivWIDTH )                       346   if( divType == DivWIDTH )
405   {                                               347   {
406     fnDiv = CalculateNDiv( 2*msol->GetZHalfLen    348     fnDiv = CalculateNDiv( 2*msol->GetZHalfLength(),
407                            width, offset );       349                            width, offset );
408   }                                               350   }
409   else if( divType == DivNDIV )                   351   else if( divType == DivNDIV )
410   {                                               352   {
411     fwidth = CalculateWidth( 2*msol->GetZHalfL    353     fwidth = CalculateWidth( 2*msol->GetZHalfLength(),
412                              nDiv, offset );      354                              nDiv, offset );
413   }                                               355   }
414                                                   356 
415 #ifdef G4DIVDEBUG                                 357 #ifdef G4DIVDEBUG
416   if( verbose >= 1 )                              358   if( verbose >= 1 )
417   {                                               359   {
418     G4cout << " G4ParameterisationTrdZ no divi    360     G4cout << " G4ParameterisationTrdZ no divisions " << fnDiv
419            << " = " << nDiv << G4endl             361            << " = " << nDiv << G4endl
420            << " Offset " << foffset << " = " <    362            << " Offset " << foffset << " = " << offset << G4endl
421            << " Width " << fwidth << " = " <<     363            << " Width " << fwidth << " = " << width << G4endl;
422   }                                               364   }
423 #endif                                            365 #endif
424 }                                                 366 }
425                                                   367 
426 //--------------------------------------------    368 //------------------------------------------------------------------------
427 G4ParameterisationTrdZ::~G4ParameterisationTrd << 369 G4ParameterisationTrdZ::~G4ParameterisationTrdZ()
                                                   >> 370 {
                                                   >> 371 }
428                                                   372 
429 //--------------------------------------------    373 //------------------------------------------------------------------------
430 G4double G4ParameterisationTrdZ::GetMaxParamet    374 G4double G4ParameterisationTrdZ::GetMaxParameter() const
431 {                                                 375 {
432   auto msol = (G4Trd*)(fmotherSolid);          << 376   G4Trd* msol = (G4Trd*)(fmotherSolid);
433   return 2*msol->GetZHalfLength();                377   return 2*msol->GetZHalfLength();
434 }                                                 378 }
435                                                   379 
436 //--------------------------------------------    380 //--------------------------------------------------------------------------
437 void                                              381 void
438 G4ParameterisationTrdZ::                          382 G4ParameterisationTrdZ::
439 ComputeTransformation(const G4int copyNo, G4VP    383 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
440 {                                                 384 {
441   auto msol = (G4Trd*)(fmotherSolid );         << 385   G4Trd* msol = (G4Trd*)(fmotherSolid );
442   G4double mdz = msol->GetZHalfLength();          386   G4double mdz = msol->GetZHalfLength();
443                                                   387 
444   //----- translation                             388   //----- translation 
445   G4ThreeVector origin(0.,0.,0.);                 389   G4ThreeVector origin(0.,0.,0.); 
446   G4double posi = -mdz + OffsetZ() + (copyNo+0    390   G4double posi = -mdz + OffsetZ() + (copyNo+0.5)*fwidth;
447   if( faxis == kZAxis )                           391   if( faxis == kZAxis )
448   {                                               392   {
449     origin.setZ( posi );                          393     origin.setZ( posi ); 
450   }                                               394   }
451   else                                            395   else
452   {                                               396   { 
453     std::ostringstream message;                << 
454     message << "Only axes along Z are allowed  << 
455     G4Exception("G4ParameterisationTrdZ::Compu    397     G4Exception("G4ParameterisationTrdZ::ComputeTransformation()",
456                 "GeomDiv0002", FatalException, << 398                 "IllegalConstruct", FatalException,
                                                   >> 399                 "Only axes along Z are allowed !");
457   }                                               400   }
458                                                   401 
459 #ifdef G4DIVDEBUG                                 402 #ifdef G4DIVDEBUG
460   if( verbose >= 1 )                              403   if( verbose >= 1 )
461   {                                               404   {
462     G4cout << std::setprecision(8) << " G4Para    405     G4cout << std::setprecision(8) << " G4ParameterisationTrdZ: "
463            << copyNo << G4endl                    406            << copyNo << G4endl
464            << " Position: " << origin << " - O    407            << " Position: " << origin << " - Offset: " << foffset 
465            << " - Width: " << fwidth << " Axis    408            << " - Width: " << fwidth << " Axis " << faxis << G4endl;
466   }                                               409   }
467 #endif                                            410 #endif
468                                                   411 
469    //----- set translation                        412    //----- set translation 
470   physVol->SetTranslation( origin );              413   physVol->SetTranslation( origin );
471 }                                                 414 }
472                                                   415 
473 //--------------------------------------------    416 //--------------------------------------------------------------------------
474 void                                              417 void
475 G4ParameterisationTrdZ::                          418 G4ParameterisationTrdZ::
476 ComputeDimensions(G4Trd& trd, const G4int copy    419 ComputeDimensions(G4Trd& trd, const G4int copyNo,
477                   const G4VPhysicalVolume*) co    420                   const G4VPhysicalVolume*) const
478 {                                                 421 {
479   //---- The division along Z of a Trd will re    422   //---- The division along Z of a Trd will result a Trd
480   auto msol = (G4Trd*)(fmotherSolid);          << 423   G4Trd* msol = (G4Trd*)(fmotherSolid);
481                                                   424 
482   G4double pDx1 = msol->GetXHalfLength1();        425   G4double pDx1 = msol->GetXHalfLength1();
483   G4double DDx = (msol->GetXHalfLength2() - ms    426   G4double DDx = (msol->GetXHalfLength2() - msol->GetXHalfLength1() );
484   G4double pDy1 = msol->GetYHalfLength1();        427   G4double pDy1 = msol->GetYHalfLength1();
485   G4double DDy = (msol->GetYHalfLength2() - ms    428   G4double DDy = (msol->GetYHalfLength2() - msol->GetYHalfLength1() );
486   G4double pDz = fwidth/2. - fhgap;            << 429   G4double pDz = fwidth/2.;
487   G4double zLength = 2*msol->GetZHalfLength();    430   G4double zLength = 2*msol->GetZHalfLength();
488                                                   431  
489   trd.SetAllParameters( pDx1+DDx*(OffsetZ()+co << 432   trd.SetAllParameters( pDx1+DDx*(OffsetZ()+copyNo*fwidth)/zLength,
490                         pDx1+DDx*(OffsetZ()+(c << 433                         pDx1+DDx*(OffsetZ()+(copyNo+1)*fwidth)/zLength, 
491                         pDy1+DDy*(OffsetZ()+co << 434                         pDy1+DDy*(OffsetZ()+copyNo*fwidth)/zLength,
492                         pDy1+DDy*(OffsetZ()+(c << 435                         pDy1+DDy*(OffsetZ()+(copyNo+1)*fwidth)/zLength, pDz );
493                         pDz );                 << 
494                                                   436 
495 #ifdef G4DIVDEBUG                                 437 #ifdef G4DIVDEBUG
496   if( verbose >= 1 )                              438   if( verbose >= 1 )
497   {                                               439   {
498     G4cout << " G4ParameterisationTrdZ::Comput    440     G4cout << " G4ParameterisationTrdZ::ComputeDimensions()"
499            << " - Mother TRD " << G4endl;         441            << " - Mother TRD " << G4endl;
500     msol->DumpInfo();                             442     msol->DumpInfo();
501     G4cout << " - Parameterised TRD: "            443     G4cout << " - Parameterised TRD: "
502            << copyNo << G4endl;                   444            << copyNo << G4endl;
503     trd.DumpInfo();                               445     trd.DumpInfo();
504   }                                               446   }
505 #endif                                            447 #endif
506 }                                                 448 }
507                                                   449