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 9.2.p3)


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