Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:54

0001 #include "CylinderGeom_MvtxHelper.h"
0002 
0003 #include "SegmentationAlpide.h"
0004 
0005 #include <Acts/Definitions/Units.hpp>
0006 
0007 #include <TRotation.h>
0008 #include <TVector3.h>
0009 
0010 #include <cmath>
0011 #include <ostream>  // for operator<<, basic_ostream::operator<<, basic_...
0012 
0013 TVector3
0014 CylinderGeom_MvtxHelper::get_local_from_world_coords (
0015   const Surface& surface,
0016   ActsGeometry* tGeometry,
0017   TVector3 world
0018 ) {
0019   Acts::Vector3 global;
0020   global(0) = world[0];
0021   global(1) = world[1];
0022   global(2) = world[2];
0023 
0024   global *= Acts::UnitConstants::cm;
0025 
0026   Acts::Vector3 local = surface->transform(tGeometry->geometry().getGeoContext()).inverse() * global;
0027   local /= Acts::UnitConstants::cm;
0028 
0029   /// The Acts transform swaps a few of the coordinates
0030   return TVector3(local(0), local(2) * -1, local(1));
0031 }
0032 
0033 TVector3
0034 CylinderGeom_MvtxHelper::get_world_from_local_coords (
0035   const Surface& surface,
0036   ActsGeometry* tGeometry,
0037   const TVector2& local
0038 ) {
0039   Acts::Vector2 actslocal;
0040   actslocal(0) = local.X();
0041   actslocal(1) = local.Y();
0042   actslocal *= Acts::UnitConstants::cm;
0043 
0044   Acts::Vector3 global;
0045   /// Acts requires a dummy vector to be passed in the arg list
0046   global = surface->localToGlobal (
0047     tGeometry->geometry().getGeoContext(),
0048     actslocal,
0049     Acts::Vector3(1, 1, 1)
0050   );
0051   global /= Acts::UnitConstants::cm;
0052 
0053   TVector3 res;
0054   res[0] = global(0);
0055   res[1] = global(1);
0056   res[2] = global(2);
0057 
0058   return res;
0059 }
0060 
0061 TVector3
0062 CylinderGeom_MvtxHelper::get_world_from_local_coords (
0063   const Surface& surface,
0064   ActsGeometry* tGeometry,
0065   const TVector3& local
0066 ) {
0067   Acts::Vector3 loc(local.x(), local.y(), local.z());
0068   loc *= Acts::UnitConstants::cm;
0069 
0070   Acts::Vector3 glob = surface->transform(tGeometry->geometry().getGeoContext()) * loc;
0071   glob /= Acts::UnitConstants::cm;
0072 
0073   return TVector3(glob(0), glob(1), glob(2));
0074 }
0075 
0076 void CylinderGeom_MvtxHelper::find_sensor_center (
0077         const Surface& surface,
0078         ActsGeometry* tGeometry,
0079         double* location
0080 ) {
0081   TVector2 sensor_local(0.0, 0.0);
0082 
0083   TVector3 sensor_world = get_world_from_local_coords(surface, tGeometry, sensor_local);
0084 
0085   location[0] = sensor_world.X();
0086   location[1] = sensor_world.Y();
0087   location[2] = sensor_world.Z();
0088 
0089   return;
0090 }
0091