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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/G4ReplicatedSlice.cc (Version 11.3.0) and /geometry/divisions/src/G4ReplicatedSlice.cc (Version 8.0.p1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 // G4ReplicatedSlice implementation               
 27 //                                                
 28 // Author: M.Asai (SLAC), 20/04/2010 - Extende    
 29 // -------------------------------------------    
 30                                                   
 31 #include "G4ReplicatedSlice.hh"                   
 32 #include "G4LogicalVolume.hh"                     
 33 #include "G4VSolid.hh"                            
 34 #include "G4ReflectedSolid.hh"                    
 35 #include "G4ParameterisationBox.hh"               
 36 #include "G4ParameterisationTubs.hh"              
 37 #include "G4ParameterisationCons.hh"              
 38 #include "G4ParameterisationTrd.hh"               
 39 #include "G4ParameterisationPara.hh"              
 40 #include "G4ParameterisationPolycone.hh"          
 41 #include "G4ParameterisationPolyhedra.hh"         
 42                                                   
 43 //--------------------------------------------    
 44 G4ReplicatedSlice::G4ReplicatedSlice(const G4S    
 45                                            G4L    
 46                                            G4L    
 47                                      const EAx    
 48                                      const G4i    
 49                                      const G4d    
 50                                      const G4d    
 51                                      const G4d    
 52   : G4PVReplica(pName, nDivs, pAxis, pLogical,    
 53 {                                                 
 54   CheckAndSetParameters(pAxis, nDivs, width, h    
 55                         DivNDIVandWIDTH, pMoth    
 56 }                                                 
 57                                                   
 58 //--------------------------------------------    
 59 G4ReplicatedSlice::G4ReplicatedSlice(const G4S    
 60                                            G4L    
 61                                            G4L    
 62                                      const EAx    
 63                                      const G4i    
 64                                      const G4d    
 65                                      const G4d    
 66   : G4PVReplica(pName, nDivs, pAxis, pLogical,    
 67 {                                                 
 68   CheckAndSetParameters(pAxis, nDivs, 0., half    
 69                         DivNDIV, pMotherLogica    
 70 }                                                 
 71                                                   
 72 //--------------------------------------------    
 73 G4ReplicatedSlice::G4ReplicatedSlice(const G4S    
 74                                            G4L    
 75                                            G4L    
 76                                      const EAx    
 77                                      const G4d    
 78                                      const G4d    
 79                                      const G4d    
 80   : G4PVReplica(pName, 0, pAxis, pLogical, pMo    
 81 {                                                 
 82   CheckAndSetParameters(pAxis, 0, width, half_    
 83                         DivWIDTH, pMotherLogic    
 84 }                                                 
 85                                                   
 86 //--------------------------------------------    
 87 G4ReplicatedSlice::G4ReplicatedSlice(const G4S    
 88                                            G4L    
 89                                            G4V    
 90                                      const EAx    
 91                                      const G4i    
 92                                      const G4d    
 93                                      const G4d    
 94                                      const G4d    
 95   : G4PVReplica(pName, nDivs, pAxis, pLogical,    
 96                 pMotherPhysical != nullptr ? p    
 97 {                                                 
 98   if (pMotherPhysical == nullptr)                 
 99   {                                               
100     std::ostringstream message;                   
101     message << "Invalid setup." << G4endl         
102             << "NULL pointer specified as moth    
103     G4Exception("G4ReplicatedSlice::G4Replicat    
104                 FatalException, message);         
105     return;                                       
106   }                                               
107   CheckAndSetParameters(pAxis, nDivs, width, h    
108       DivNDIVandWIDTH, pMotherPhysical->GetLog    
109 }                                                 
110                                                   
111 //--------------------------------------------    
112 G4ReplicatedSlice::G4ReplicatedSlice(const G4S    
113                                            G4L    
114                                            G4V    
115                                      const EAx    
116                                      const G4i    
117                                      const G4d    
118                                      const G4d    
119   : G4PVReplica(pName, nDivs, pAxis, pLogical,    
120                 pMotherPhysical != nullptr ? p    
121 {                                                 
122   if (pMotherPhysical == nullptr)                 
123   {                                               
124     std::ostringstream message;                   
125     message << "Invalid setup." << G4endl         
126             << "NULL pointer specified as moth    
127     G4Exception("G4ReplicatedSlice::G4Replicat    
128                 FatalException, message);         
129     return;                                       
130   }                                               
131   CheckAndSetParameters(pAxis, nDivs, 0., half    
132       DivNDIV, pMotherPhysical->GetLogicalVolu    
133 }                                                 
134                                                   
135 //--------------------------------------------    
136 G4ReplicatedSlice::G4ReplicatedSlice(const G4S    
137                                            G4L    
138                                            G4V    
139                                      const EAx    
140                                      const G4d    
141                                      const G4d    
142                                      const G4d    
143   : G4PVReplica(pName, 0, pAxis, pLogical,        
144                 pMotherPhysical != nullptr ? p    
145 {                                                 
146   if (pMotherPhysical == nullptr)                 
147   {                                               
148     std::ostringstream message;                   
149     message << "Invalid setup." << G4endl         
150             << "NULL pointer specified as moth    
151     G4Exception("G4ReplicatedSlice::G4Replicat    
152                 FatalException, message);         
153     return;                                       
154   }                                               
155   CheckAndSetParameters(pAxis, 0, width, half_    
156       DivWIDTH, pMotherPhysical->GetLogicalVol    
157 }                                                 
158                                                   
159 //--------------------------------------------    
160 void                                              
161 G4ReplicatedSlice::CheckAndSetParameters( cons    
162                                           cons    
163                                           cons    
164                                           cons    
165                                           cons    
166                                                   
167                                                   
168                                           cons    
169 {                                                 
170   if(pMotherLogical == nullptr)                   
171   {                                               
172     std::ostringstream message;                   
173     message << "Invalid setup." << G4endl         
174             << "NULL pointer specified as moth    
175     G4Exception("G4ReplicatedSlice::CheckAndSe    
176                 FatalException, message);         
177   }                                               
178   if(pLogical == pMotherLogical)                  
179   {                                               
180     std::ostringstream message;                   
181     message << "Invalid setup." << G4endl         
182             << "Cannot place a volume inside i    
183     G4Exception("G4ReplicatedSlice::CheckAndSe    
184                 FatalException, message);         
185   }                                               
186                                                   
187   //----- Check that mother solid is of the sa    
188   //      daughter solid (otherwise, the corre    
189   //      Parameterisation::ComputeDimension()    
190   //                                              
191   G4String msolType = pMotherLogical->GetSolid    
192   G4String dsolType = pLogical->GetSolid()->Ge    
193   if( msolType != dsolType && ( msolType != "G    
194   {                                               
195     std::ostringstream message;                   
196     message << "Invalid setup." << G4endl         
197             << "Incorrect solid type for divis    
198             << GetName() << G4endl                
199             << "    It is: " << msolType          
200             << ", while it should be: " << dso    
201     G4Exception("G4ReplicatedSlice::CheckAndSe    
202                 "GeomDiv0002", FatalException,    
203   }                                               
204                                                   
205   pMotherLogical->AddDaughter(this);              
206   SetMotherLogical(pMotherLogical);               
207   SetParameterisation(pMotherLogical, pAxis, n    
208                       width, half_gap, offset,    
209                                                   
210   if( divType == DivWIDTH )                       
211   {                                               
212     fnReplicas = fparam->GetNoDiv();              
213   }                                               
214   else                                            
215   {                                               
216     fnReplicas = nDivs;                           
217   }                                               
218   if (fnReplicas < 1 )                            
219   {                                               
220     G4Exception("G4ReplicatedSlice::CheckAndSe    
221                 FatalException, "Illegal numbe    
222   }                                               
223   if( divType != DivNDIV)                         
224   {                                               
225     fwidth = fparam->GetWidth();                  
226   }                                               
227   else                                            
228   {                                               
229     fwidth = width;                               
230   }                                               
231   if( fwidth < 0 )                                
232   {                                               
233     G4Exception("G4ReplicatedSlice::CheckAndSe    
234                 FatalException, "Width must be    
235   }                                               
236   if( fwidth < 2.*half_gap )                      
237   {                                               
238     G4Exception("G4ReplicatedSlice::CheckAndSe    
239                 FatalException, "Half_gap is t    
240   }                                               
241                                                   
242   foffset = offset;                               
243   fdivAxis = pAxis;                               
244                                                   
245   //!!!!! axis has to be x/y/z in G4VoxelLimit    
246   //                                              
247   if( pAxis == kRho || pAxis == kRadial3D || p    
248   {                                               
249     faxis = kZAxis;                               
250   }                                               
251   else                                            
252   {                                               
253     faxis = pAxis;                                
254   }                                               
255                                                   
256   switch (faxis)                                  
257   {                                               
258     case kPhi:                                    
259     case kRho:                                    
260     case kXAxis:                                  
261     case kYAxis:                                  
262     case kZAxis:                                  
263       break;                                      
264     default:                                      
265       G4Exception("G4ReplicatedSlice::CheckAnd    
266                   FatalException, "Unknown axi    
267       break;                                      
268   }                                               
269                                                   
270   // Create rotation matrix: for phi axis it w    
271   // in G4VPVParameterisation::ComputeTransfor    
272   // it will stay the unity                       
273   //                                              
274   auto  pRMat = new G4RotationMatrix();           
275   SetRotation(pRMat);                             
276 }                                                 
277                                                   
278 //--------------------------------------------    
279 G4ReplicatedSlice::~G4ReplicatedSlice()           
280 {                                                 
281   delete GetRotation();                           
282 }                                                 
283                                                   
284 //--------------------------------------------    
285 EAxis G4ReplicatedSlice::GetDivisionAxis() con    
286 {                                                 
287   return fdivAxis;                                
288 }                                                 
289                                                   
290 //--------------------------------------------    
291 G4bool G4ReplicatedSlice::IsParameterised() co    
292 {                                                 
293   return true;                                    
294 }                                                 
295                                                   
296 //--------------------------------------------    
297 G4bool G4ReplicatedSlice::IsMany() const          
298 {                                                 
299   return false;                                   
300 }                                                 
301                                                   
302 //--------------------------------------------    
303 G4bool G4ReplicatedSlice::IsReplicated() const    
304 {                                                 
305   return true;                                    
306 }                                                 
307                                                   
308 //--------------------------------------------    
309 G4int G4ReplicatedSlice::GetMultiplicity() con    
310 {                                                 
311   return fnReplicas;                              
312 }                                                 
313                                                   
314 //--------------------------------------------    
315 G4VPVParameterisation* G4ReplicatedSlice::GetP    
316 {                                                 
317   return fparam;                                  
318 }                                                 
319                                                   
320 //--------------------------------------------    
321 EVolume G4ReplicatedSlice::VolumeType() const     
322 {                                                 
323   return kParameterised;                          
324 }                                                 
325                                                   
326 //--------------------------------------------    
327 void G4ReplicatedSlice::GetReplicationData(EAx    
328                                            G4i    
329                                            G4d    
330                                            G4d    
331                                            G4b    
332 {                                                 
333   axis = faxis;                                   
334   nDivs = fnReplicas;                             
335   width = fwidth;                                 
336   offset = foffset;                               
337   consuming = false;                              
338 }                                                 
339                                                   
340                                                   
341 //--------------------------------------------    
342 void G4ReplicatedSlice::SetParameterisation( G    
343                                        const E    
344                                        const G    
345                                        const G    
346                                        const G    
347                                        const G    
348                                              D    
349 {                                                 
350   G4VSolid* mSolid = motherLogical->GetSolid()    
351   G4String mSolidType = mSolid->GetEntityType(    
352   fparam = nullptr;                               
353                                                   
354   // If the solid is a reflected one, update t    
355   // real constituent solid.                      
356   //                                              
357   if (mSolidType == "G4ReflectedSolid")           
358   {                                               
359       mSolidType = ((G4ReflectedSolid*)mSolid)    
360                  ->GetEntityType();               
361   }                                               
362                                                   
363   // Parameterisation type depend of mother so    
364   //                                              
365   if( mSolidType == "G4Box" )                     
366   {                                               
367     switch( axis )                                
368     {                                             
369       case kXAxis:                                
370         fparam = new G4ParameterisationBoxX( a    
371                                              o    
372         break;                                    
373       case kYAxis:                                
374         fparam = new G4ParameterisationBoxY( a    
375                                              o    
376         break;                                    
377       case kZAxis:                                
378         fparam = new G4ParameterisationBoxZ( a    
379                                              o    
380         break;                                    
381       default:                                    
382         ErrorInAxis( axis, mSolid );              
383         break;                                    
384     }                                             
385   }                                               
386   else if( mSolidType == "G4Tubs" )               
387   {                                               
388     switch( axis )                                
389     {                                             
390       case kRho:                                  
391         fparam = new G4ParameterisationTubsRho    
392                                                   
393         break;                                    
394       case kPhi:                                  
395         fparam = new G4ParameterisationTubsPhi    
396                                                   
397         break;                                    
398       case kZAxis:                                
399         fparam = new G4ParameterisationTubsZ(     
400                                                   
401         break;                                    
402       default:                                    
403         ErrorInAxis( axis, mSolid );              
404         break;                                    
405     }                                             
406   }                                               
407   else if( mSolidType == "G4Cons" )               
408   {                                               
409     switch( axis )                                
410     {                                             
411       case kRho:                                  
412         fparam = new G4ParameterisationConsRho    
413                                                   
414         break;                                    
415       case kPhi:                                  
416         fparam = new G4ParameterisationConsPhi    
417                                                   
418         break;                                    
419       case kZAxis:                                
420         fparam = new G4ParameterisationConsZ(     
421                                                   
422         break;                                    
423       default:                                    
424         ErrorInAxis( axis, mSolid );              
425         break;                                    
426     }                                             
427   }                                               
428   else if( mSolidType == "G4Trd" )                
429   {                                               
430     switch( axis )                                
431     {                                             
432       case kXAxis:                                
433         fparam = new G4ParameterisationTrdX( a    
434                                              o    
435         break;                                    
436       case kYAxis:                                
437         fparam = new G4ParameterisationTrdY( a    
438                                              o    
439         break;                                    
440       case kZAxis:                                
441         fparam = new G4ParameterisationTrdZ( a    
442                                              o    
443         break;                                    
444       default:                                    
445         ErrorInAxis( axis, mSolid );              
446         break;                                    
447     }                                             
448   }                                               
449   else if( mSolidType == "G4Para" )               
450   {                                               
451     switch( axis )                                
452     {                                             
453       case kXAxis:                                
454         fparam = new G4ParameterisationParaX(     
455                                              o    
456         break;                                    
457       case kYAxis:                                
458         fparam = new G4ParameterisationParaY(     
459                                              o    
460         break;                                    
461       case kZAxis:                                
462         fparam = new G4ParameterisationParaZ(     
463                                              o    
464         break;                                    
465       default:                                    
466         ErrorInAxis( axis, mSolid );              
467         break;                                    
468     }                                             
469   }                                               
470 //  else if( mSolidType == "G4Trap" )             
471 //  {                                             
472 //  }                                             
473 //  else if( mSolidType == "G4Polycone" )         
474 //  {                                             
475 //    switch( axis )                              
476 //    {                                           
477 //      case kRho:                                
478 //        fparam = new G4ParameterisationPolyc    
479 //                                                
480 //        break;                                  
481 //      case kPhi:                                
482 //        fparam = new G4ParameterisationPolyc    
483 //                                                
484 //        break;                                  
485 //      case kZAxis:                              
486 //        fparam = new G4ParameterisationPolyc    
487 //                                                
488 //        break;                                  
489 //      default:                                  
490 //        ErrorInAxis( axis, mSolid );            
491 //      break;                                    
492 //    }                                           
493 //  }                                             
494 //  else if( mSolidType == "G4Polyhedra" )        
495 //  {                                             
496 //    switch( axis )                              
497 //    {                                           
498 //      case kRho:                                
499 //        fparam = new G4ParameterisationPolyh    
500 //                                                
501 //        break;                                  
502 //      case kPhi:                                
503 //        fparam = new G4ParameterisationPolyh    
504 //                                                
505 //        break;                                  
506 //      case kZAxis:                              
507 //        fparam = new G4ParameterisationPolyh    
508 //                                                
509 //        break;                                  
510 //      default:                                  
511 //        ErrorInAxis( axis, mSolid );            
512 //      break;                                    
513 //    }                                           
514 //  }                                             
515   else                                            
516   {                                               
517     std::ostringstream message;                   
518     message << "Solid type not supported: " <<    
519             << "Divisions for " << mSolidType     
520     G4Exception("G4ReplicatedSlice::SetParamet    
521                 FatalException, message);         
522   }                                               
523                                                   
524   fparam->SetHalfGap(half_gap);                   
525 }                                                 
526                                                   
527 //--------------------------------------------    
528 void G4ReplicatedSlice::ErrorInAxis( EAxis axi    
529 {                                                 
530   G4String error = "Trying to divide solid " +    
531                  + " of type " + solid->GetEnt    
532   switch( axis )                                  
533   {                                               
534     case kXAxis:                                  
535       error += "X.";                              
536       break;                                      
537     case kYAxis:                                  
538       error += "Y.";                              
539       break;                                      
540     case kZAxis:                                  
541       error += "Z.";                              
542       break;                                      
543     case kRho:                                    
544       error += "Rho.";                            
545       break;                                      
546     case kRadial3D:                               
547       error += "Radial3D.";                       
548       break;                                      
549     case kPhi:                                    
550       error += "Phi.";                            
551       break;                                      
552     default:                                      
553       break;                                      
554   }                                               
555   G4Exception("G4ReplicatedSlice::ErrorInAxis(    
556               FatalException, error);             
557 }                                                 
558                                                   
559 // The next methods are for specialised repeat    
560 // (replicas, parameterised vol.) which are co    
561 // Currently this is not applicable to divisio    
562                                                   
563 // -------------------------------------------    
564 // IsRegularStructure()                           
565 //                                                
566 G4bool G4ReplicatedSlice::IsRegularStructure()    
567 {                                                 
568   return false;                                   
569 }                                                 
570                                                   
571 // -------------------------------------------    
572 // GetRegularStructureId()                        
573 //                                                
574 G4int G4ReplicatedSlice::GetRegularStructureId    
575 {                                                 
576   return 0;                                       
577 }                                                 
578