G4tgbPlaceParamCircle.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4tgbPlaceParamCircle.cc 69803 2013-05-15 15:24:50Z gcosmo $
00028 //
00029 //
00030 // class G4tgbPlaceParamCircle
00031 
00032 // History:
00033 // - Created.                                 P.Arce, CIEMAT (November 2007)
00034 // -------------------------------------------------------------------------
00035 
00036 #include "G4tgbPlaceParamCircle.hh"
00037 #include "G4tgrPlaceParameterisation.hh"
00038 #include "G4ThreeVector.hh"
00039 #include "G4RotationMatrix.hh"
00040 #include "G4VPhysicalVolume.hh"
00041 #include "G4tgrUtils.hh"
00042 #include "G4tgrMessenger.hh"
00043 
00044 // -------------------------------------------------------------------------
00045 G4tgbPlaceParamCircle::~G4tgbPlaceParamCircle()
00046 {
00047 }
00048 
00049 
00050 // -------------------------------------------------------------------------
00051 G4tgbPlaceParamCircle::
00052 G4tgbPlaceParamCircle( G4tgrPlaceParameterisation* tgrParam )
00053   : G4tgbPlaceParameterisation(tgrParam)
00054 {
00055   //---- Get translation and rotation 
00056   if( tgrParam->GetParamType() == "CIRCLE" )
00057   {
00058     CheckNExtraData( tgrParam, 7, WLSIZE_EQ, "G4tgbPlaceParamCircle:");
00059     theCircleAxis = G4ThreeVector( tgrParam->GetExtraData()[4],
00060                                    tgrParam->GetExtraData()[5],
00061                                    tgrParam->GetExtraData()[6] );
00062 
00063     G4ThreeVector zaxis(0.,0.,-1.);
00064     if( zaxis.cross(theCircleAxis).mag() > 1.E-6 )
00065     {
00066       theDirInPlane = zaxis.cross(theCircleAxis);
00067     }
00068     else
00069     { 
00070       theDirInPlane = theCircleAxis.cross(G4ThreeVector(0.,-1.,0.));
00071     }
00072     theAxis = kZAxis;
00073   }
00074   else
00075   {
00076     CheckNExtraData( tgrParam, 4, WLSIZE_EQ, "G4tgbPlaceParamCircle:");
00077     if( tgrParam->GetParamType() == "CIRCLE_XY" ) {
00078       theCircleAxis = G4ThreeVector(0.,0.,1.);
00079       theDirInPlane = G4ThreeVector(1.,0.,0.);
00080       theAxis = kZAxis;
00081     } else if( tgrParam->GetParamType() == "CIRCLE_XZ" ) {
00082       theCircleAxis = G4ThreeVector(0.,1.,0.);
00083       theDirInPlane = G4ThreeVector(1.,0.,0.);
00084       theAxis = kYAxis;
00085     } else if( tgrParam->GetParamType() == "CIRCLE_YZ" ) {
00086       theCircleAxis = G4ThreeVector(1.,0.,0.);
00087       theDirInPlane = G4ThreeVector(0.,1.,0.);
00088       theAxis = kXAxis;
00089     }
00090   }
00091 
00092   if( theCircleAxis.mag() == 0. )
00093   {
00094     G4Exception("G4tgbPlaceParamCircle::G4tgbPlaceParamCircle()",
00095                 "InvalidSetup", FatalException, "Circle axis is zero !");
00096   }
00097   theCircleAxis /= theCircleAxis.mag();
00098 
00099   theAxis = kZAxis;
00100 
00101   theNCopies = G4int(tgrParam->GetExtraData()[0]);
00102   theStep = tgrParam->GetExtraData()[1];
00103   theOffset = tgrParam->GetExtraData()[2];
00104   theRadius = tgrParam->GetExtraData()[3];
00105 
00106 #ifdef G4VERBOSE
00107   if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00108   {
00109     G4cout << " G4tgbPlaceParamCircle::G4tgbPlaceParamCircle():" << G4endl
00110            << " param type " << tgrParam->GetParamType() << G4endl
00111            << "   no copies - " << theNCopies << G4endl
00112            << "   step - " << theStep << G4endl
00113            << "   offset - " << theOffset << G4endl
00114            << "   radius - " << theRadius << G4endl
00115            << "   circle axis - " << theCircleAxis << G4endl
00116            << "   dir in plane - " << theDirInPlane << G4endl;
00117   }
00118 #endif
00119 }
00120 
00121 
00122 // -------------------------------------------------------------------------
00123 void G4tgbPlaceParamCircle::
00124 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
00125 { 
00126   G4double posi = theOffset + copyNo*theStep;
00127   G4ThreeVector origin = theDirInPlane * theRadius;
00128   origin.rotate( posi, theCircleAxis );
00129 
00130   //----- Calculate rotation matrix (so that all volumes point to the centre)
00131   G4RotationMatrix rm;
00132   rm.rotate( -posi, theCircleAxis );
00133 
00134   //----- Set translation and rotation
00135   physVol->SetTranslation(origin);
00136   G4RotationMatrix* pvRm = physVol->GetRotation();
00137   if( pvRm == 0 )
00138   {
00139     pvRm = new G4RotationMatrix;
00140   }
00141   *pvRm  = *theRotationMatrix * rm;
00142   physVol->SetRotation(pvRm);
00143   physVol->SetCopyNo( copyNo );
00144 
00145 #ifdef G4VERBOSE
00146   if( G4tgrMessenger::GetVerboseLevel() >= 3 )
00147   {
00148     G4cout << " G4tgbPlaceParamCircle::ComputeTransformation():" 
00149            << physVol->GetName() << G4endl
00150            << "   no copies - " << theNCopies  << G4endl
00151            << "   centre - " << origin << G4endl
00152            << "   rotation-matrix - " << *pvRm << G4endl;
00153   }
00154 #endif
00155 }

Generated on Mon May 27 17:49:58 2013 for Geant4 by  doxygen 1.4.7