// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // // #include "IElementField.hxx" #include "IFieldManager.hxx" namespace COMET { IElementField::IElementField(TVector3 translation, TRotation rotation) { fTranslation=translation; SetRotation(rotation); IFieldManager::getObject()->addElementField(this); } void IElementField::GlobalToLocal(const Double_t GlobalPoint[4], Double_t LocalPoint[4]) const{ //Apply translation and rotation of the element to go from global coord //to local coord TVector3 local(GlobalPoint[0],GlobalPoint[1],GlobalPoint[2]); GlobalToLocal(local); LocalPoint[0]=local[0]; LocalPoint[1]=local[1]; LocalPoint[2]=local[2]; LocalPoint[3]=GlobalPoint[3]; } void IElementField::addFieldValue(const Double_t GlobalPoint[4], Double_t field[6]) const{ Double_t LocalPoint[4]; GlobalToLocal(GlobalPoint,LocalPoint); if(!isInBoundingBox(LocalPoint)) return; Double_t f[6]; f[0] = f[1] = f[2] = f[3] = f[4] = f[5] = 0.0; // get the field f in local coords getFieldValue(LocalPoint,f); //Rotate the fields and add to field[] TVector3 B(f[0],f[1],f[2]); TVector3 E(f[3],f[4],f[5]); B = fLocalToGlobalRotation * B; E = fLocalToGlobalRotation * E; field[0] += B[0]; field[1] += B[1]; field[2] += B[2]; field[3] += E[0]; field[4] += E[1]; field[5] += E[2]; } }