G4tgbPlaceParamLinear.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: G4tgbPlaceParamLinear.cc 69803 2013-05-15 15:24:50Z gcosmo $
00028 //
00029 //
00030 // class G4tgbPlaceParamLinear
00031 
00032 // History:
00033 // - Created.                                 P.Arce, CIEMAT (November 2007)
00034 // -------------------------------------------------------------------------
00035 
00036 #include "G4tgbPlaceParamLinear.hh"
00037 #include "G4RotationMatrix.hh"
00038 #include "G4VPhysicalVolume.hh"
00039 #include "G4tgrMessenger.hh"
00040 #include "G4tgrPlaceParameterisation.hh"
00041 
00042 // -------------------------------------------------------------------------
00043 G4tgbPlaceParamLinear::~G4tgbPlaceParamLinear()
00044 {
00045 }
00046 
00047 
00048 // -------------------------------------------------------------------------
00049 G4tgbPlaceParamLinear::
00050 G4tgbPlaceParamLinear( G4tgrPlaceParameterisation* tgrParam ) 
00051   : G4tgbPlaceParameterisation(tgrParam)
00052 {
00053   //---- Get translation and rotation 
00054   if( tgrParam->GetParamType() == "LINEAR" )
00055   {
00056     CheckNExtraData( tgrParam, 6, WLSIZE_EQ, "G4tgbPlaceParamLinear:");
00057     theDirection = G4ThreeVector( tgrParam->GetExtraData()[3],
00058                                   tgrParam->GetExtraData()[4],
00059                                   tgrParam->GetExtraData()[5] );
00060     theAxis = kZAxis;
00061   }
00062   else
00063   {
00064     CheckNExtraData( tgrParam, 3, WLSIZE_EQ, "G4tgbPlaceParamLinear:");
00065     if( tgrParam->GetParamType() == "LINEAR_X" ) {
00066       theDirection = G4ThreeVector(1.,0.,0.);
00067       theAxis = kXAxis;
00068     } else if( tgrParam->GetParamType() == "LINEAR_Y" ) {
00069       theDirection = G4ThreeVector(0.,1.,0.);
00070       theAxis = kYAxis;
00071     } else if( tgrParam->GetParamType() == "LINEAR_Z" ) {
00072       theDirection = G4ThreeVector(0.,0.,1.);
00073       theAxis = kZAxis;
00074     }
00075   }
00076 
00077   if( theDirection.mag() == 0. )
00078   {
00079     G4Exception("G4tgbPlaceParamLinear::G4tgbPlaceParamLinear()",
00080                 "InvalidSetup", FatalException, "Direction is zero !");
00081   }
00082   else
00083   {
00084     theDirection /= theDirection.mag();
00085   }
00086 
00087   theNCopies = G4int(tgrParam->GetExtraData()[0]);
00088   theStep = tgrParam->GetExtraData()[1];
00089   theOffset = tgrParam->GetExtraData()[2];
00090 
00091   theTranslation = G4ThreeVector(0.,0.,0.)+theOffset*theDirection;
00092     
00093 #ifdef G4VERBOSE
00094   if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00095   {
00096     G4cout << " G4tgbPlaceParamLinear::G4tgbPlaceParamLinear(): "
00097            << " param type " << tgrParam->GetParamType() << G4endl
00098            << "   N copies " << theNCopies << G4endl
00099            << "   step " << theStep << G4endl
00100            << "   offset " << theOffset  << G4endl
00101            << "   translation " << theTranslation << G4endl
00102            << "   direction " << theDirection << G4endl
00103            << "   axis " << theAxis << G4endl;
00104   } 
00105 #endif
00106 }
00107 
00108 
00109 // -------------------------------------------------------------------------
00110 void G4tgbPlaceParamLinear::
00111 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
00112 {
00113   G4ThreeVector origin = theTranslation + copyNo*theStep*theDirection;
00114 
00115 #ifdef G4VERBOSE
00116   if( G4tgrMessenger::GetVerboseLevel() >= 3 )
00117   { 
00118     G4cout << " G4tgbPlaceParamLinear::ComputeTransformation() -"
00119            << physVol->GetName() << G4endl
00120            << " copyNo " << copyNo << " pos " << origin << G4endl;
00121   }
00122 #endif
00123   //----- Set traslation and rotation
00124   physVol->SetTranslation(origin);
00125   physVol->SetCopyNo( copyNo );
00126   physVol->SetRotation( theRotationMatrix );
00127 }

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