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 10.7.p2)


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