G4tgbPlaceParamSquare.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: G4tgbPlaceParamSquare.cc 69803 2013-05-15 15:24:50Z gcosmo $
00028 //
00029 //
00030 // class G4tgbPlaceParamSquare
00031 
00032 // History:
00033 // - Created.                                 P.Arce, CIEMAT (November 2007)
00034 // -------------------------------------------------------------------------
00035 
00036 #include "G4tgbPlaceParamSquare.hh"
00037 #include "G4RotationMatrix.hh"
00038 #include "G4VPhysicalVolume.hh"
00039 #include "G4tgrMessenger.hh"
00040 #include "G4tgrPlaceParameterisation.hh"
00041 
00042 // -------------------------------------------------------------------------
00043 G4tgbPlaceParamSquare::~G4tgbPlaceParamSquare()
00044 {
00045 }
00046 
00047 
00048 // -------------------------------------------------------------------------
00049 G4tgbPlaceParamSquare::
00050 G4tgbPlaceParamSquare( G4tgrPlaceParameterisation* tgrParam )
00051   : G4tgbPlaceParameterisation(tgrParam)
00052 {
00053   //---- Get translation and rotation 
00054   if( tgrParam->GetParamType() == "SQUARE" )
00055   {
00056     CheckNExtraData( tgrParam, 12, WLSIZE_EQ, "G4tgbPlaceParamSquare:");
00057     theDirection1 = G4ThreeVector( tgrParam->GetExtraData()[6],
00058                                    tgrParam->GetExtraData()[7],
00059                                    tgrParam->GetExtraData()[8] );
00060     theDirection2 = G4ThreeVector( tgrParam->GetExtraData()[9],
00061                                    tgrParam->GetExtraData()[10],
00062                                    tgrParam->GetExtraData()[11] );
00063     theAxis = kZAxis;
00064   }
00065   else
00066   {
00067     CheckNExtraData( tgrParam, 6, WLSIZE_EQ, "G4tgbPlaceParamSquare:");
00068     if( tgrParam->GetParamType() == "SQUARE_XY" )
00069     {
00070       theDirection1 = G4ThreeVector(1.,0.,0.);
00071       theDirection2 = G4ThreeVector(0.,1.,0.);
00072       theAxis = kZAxis;
00073     }
00074     else if( tgrParam->GetParamType() == "SQUARE_YZ" )
00075     {
00076       theDirection1 = G4ThreeVector(0.,1.,0.);
00077       theDirection2 = G4ThreeVector(0.,0.,1.);
00078       theAxis = kXAxis;
00079     }
00080     else if( tgrParam->GetParamType() == "SQUARE_XZ" )
00081     {
00082       theDirection1 = G4ThreeVector(1.,0.,0.);
00083       theDirection2 = G4ThreeVector(0.,0.,1.);
00084       theAxis = kYAxis;
00085     }
00086   }
00087 
00088   if( theDirection1.mag() == 0. )
00089   {
00090     G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()",
00091                 "InvalidSetup", FatalException, "Direction1 is zero !");
00092   }
00093   else
00094   {
00095     theDirection1 /= theDirection1.mag();
00096   }
00097   if( theDirection2.mag() == 0. )
00098   {
00099     G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()",
00100                 "InvalidSetup", FatalException, "Direction2 is zero !");
00101   }
00102   else
00103   {
00104     theDirection2 /= theDirection2.mag();
00105   }
00106   
00107   theNCopies1 = G4int(tgrParam->GetExtraData()[0]);
00108   theNCopies2 = G4int(tgrParam->GetExtraData()[1]);
00109   theStep1 = tgrParam->GetExtraData()[2];
00110   theStep2 = tgrParam->GetExtraData()[3];
00111   theOffset1 = tgrParam->GetExtraData()[4];
00112   theOffset2 = tgrParam->GetExtraData()[5];
00113 
00114   theNCopies = theNCopies1 * theNCopies2;
00115   theTranslation = theOffset1*theDirection1 + theOffset2*theDirection2;
00116   
00117 #ifdef G4VERBOSE
00118   if( G4tgrMessenger::GetVerboseLevel() >= 2 ) 
00119     G4cout << "G4tgbPlaceParamSquare: no copies "
00120            << theNCopies << " = " << theNCopies1
00121            << " X " << theNCopies2 << G4endl
00122            << " offset1 " << theOffset1 << G4endl
00123            << " offset2 " << theOffset1 << G4endl
00124            << " step1 " << theStep1 << G4endl
00125            << " step2 " << theStep2 << G4endl
00126            << " direction1 " << theDirection1 << G4endl
00127            << " direction2 " << theDirection2 << G4endl
00128            << " translation " << theTranslation << G4endl;
00129 #endif
00130 }
00131 
00132 
00133 // -------------------------------------------------------------------------
00134 void G4tgbPlaceParamSquare::
00135 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
00136 {
00137 #ifdef G4VERBOSE
00138   if( G4tgrMessenger::GetVerboseLevel() >= 3 )
00139   {
00140     G4cout << " G4tgbPlaceParamSquare::ComputeTransformation():" 
00141            << physVol->GetName() << G4endl
00142            << "   no copies " << theNCopies << G4endl
00143            << "   offset1 " << theOffset1 << G4endl
00144            << "   offset2 " << theOffset2 << G4endl
00145            << "   step1 " << theStep1 << G4endl
00146            << "   step2 " << theStep2 << G4endl;
00147   }
00148 #endif
00149 
00150   G4int copyNo1 = copyNo%theNCopies1;
00151   G4int copyNo2 = G4int(copyNo/theNCopies1);
00152   G4double posi1 = copyNo1*theStep1;
00153   G4double posi2 = copyNo2*theStep2;
00154   G4ThreeVector origin = posi1*theDirection1+ posi2*theDirection2;
00155   origin += theTranslation;
00156 
00157 #ifdef G4VERBOSE
00158   if( G4tgrMessenger::GetVerboseLevel() >= 3 )
00159   {
00160     G4cout << " G4tgbPlaceParamSquare::ComputeTransformation() - "
00161            << copyNo << " = " << copyNo1 << ", X " << copyNo2 << G4endl
00162            << " pos: " << origin << ", axis: " << theAxis << G4endl;
00163   }
00164 #endif
00165   //----- Set traslation and rotation
00166   physVol->SetTranslation(origin);
00167   physVol->SetCopyNo( copyNo );
00168   physVol->SetRotation( theRotationMatrix );
00169 }

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