CMS 3D CMS Logo

Typedefs | Functions
DDAngular.cc File Reference
#include "DD4hep/DetFactoryHelper.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <Math/Rotation3D.h>
#include <Math/AxisAngle.h>
#include <Math/DisplacementVector3D.h>

Go to the source code of this file.

Typedefs

using DD3Vector = ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > >
 
using DDAxisAngle = ROOT::Math::AxisAngle
 

Functions

static long algorithm (Detector &, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_global_DDAngular)
 

Typedef Documentation

using DD3Vector = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double> >

Definition at line 12 of file DDAngular.cc.

using DDAxisAngle = ROOT::Math::AxisAngle

Definition at line 13 of file DDAngular.cc.

Function Documentation

static long algorithm ( Detector &  ,
cms::DDParsingContext ctxt,
xml_h  e,
SensitiveDetector  
)
static

Definition at line 25 of file DDAngular.cc.

References createfilelist::args, ConvertTo, popcon2dropbox::copy(), funct::cos(), delta, cms::DDAlgoArguments::find(), mps_fire::i, LogDebug, cms::makeRotation3D(), gen::n, cms::DDNamespace::name(), NAMESPACE_SEP, cms::DDNamespace::nsName(), cms::DDAlgoArguments::parentName(), cms::DDNamespace::prepend(), TCMET_cfi::radius, idealTransformation::rotation, cms::DDNamespace::rotation(), cms::DDParsingContext::rotations, funct::sin(), groupFilesInBlocks::temp, theta(), cms::DDAlgoArguments::value(), cms::DDNamespace::volume(), and g4SimHits_cfi::Volume.

29 {
30  cms::DDNamespace ns( ctxt, e, true );
31  DDAlgoArguments args( ctxt, e );
32 
33  int n = args.value<int>("N");
34  int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
35  int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
36  double rangeAngle = args.value<double>("RangeAngle");
37  double startAngle = args.value<double>("StartAngle");
38  double radius = args.value<double>("Radius");
39  vector<double> center = args.value<vector<double> >("Center");
40  vector<double> rotateSolid = args.value<vector<double> >("RotateSolid");
41  Volume mother = ns.volume(args.parentName());
42  string childName = args.value<string>("ChildName");
43  if( strchr( childName.c_str(), NAMESPACE_SEP ) == nullptr )
44  childName = ns.name() + childName;
45  Volume child = ns.volume( childName );
46 
47  double delta = 0e0;
48 
49  if( fabs( rangeAngle - 360.0_deg ) < 0.001_deg ) {
50  delta = rangeAngle/double( n );
51  } else if( n > 1 ) {
52  delta = rangeAngle/double( n - 1 );
53  }
54 
55  LogDebug("DDAlgorithm") << "debug: Parameters for positioning:: n "
56  << n << " Start, Range, Delta "
57  << ConvertTo( startAngle, deg ) << " "
58  << ConvertTo( rangeAngle, deg ) << " " << ConvertTo( delta, deg )
59  << " Radius " << radius << " Centre " << center[0]
60  << ", " << center[1] << ", " << center[2]
61  << ", Rotate solid " << rotateSolid[0] << ", " << rotateSolid[1]
62  << ", " << rotateSolid[2];
63  LogDebug("DDAlgorithm") << "debug: Parent " << mother.name()
64  << "\tChild " << child.name() << " NameSpace "
65  << ns.name();
66 
67  Rotation3D solidRot = Rotation3D(); // Identity rotation
68  auto sz = rotateSolid.size();
69  if( sz%3 )
70  {
71  LogDebug( "DDAlgorithm" ) << "\trotateSolid must occur 3*n times (defining n subsequent rotations)\n"
72  << "\t currently it appears " << sz << " times!\n";
73  }
74  for( unsigned int i = 0; i < sz; i += 3 )
75  {
76  if(( i > 180._deg ) || ( i < 0._deg ))
77  {
78  LogDebug( "DDAlgorithm" ) << "\trotateSolid \'theta\' must be in range [0,180*deg]\n"
79  << "\t currently it is " << ConvertTo( i, deg )
80  << "*deg in rotateSolid[" << double(i) << "]!\n";
81  }
82  DDAxisAngle temp( fUnitVector( rotateSolid[i], rotateSolid[i + 1] ),
83  rotateSolid[i + 2] );
84  LogDebug( "DDAlgorithm" ) << " rotsolid[" << i << "] axis=" << temp.Axis() << " rot.angle=" << ConvertTo( temp.Angle(), deg );
85  solidRot = temp * solidRot;
86  }
87 
88  double theta = 90._deg;
89  int copy = startCopyNo;
90  double phi = startAngle;
91  for( int i = 0; i < n; ++i )
92  {
93  double phix = phi;
94  double phiy = phix + 90._deg;
95  double phideg = ConvertTo( phix, deg );
96 
97  Rotation3D rotation = makeRotation3D( theta, phix, theta, phiy, 0., 0. ) * solidRot;
98  string rotstr = ns.nsName( child.name()) + std::to_string( phideg * 10. );
99  auto irot = ctxt.rotations.find( ns.prepend( rotstr ));
100  if( irot != ctxt.rotations.end()) {
101  rotation = ns.rotation( ns.prepend( rotstr ));
102  }
103 
104  double xpos = radius * cos( phi ) + center[0];
105  double ypos = radius * sin( phi ) + center[1];
106  double zpos = center[2];
107  Position tran( xpos, ypos, zpos );
108  mother.placeVolume( child, copy, Transform3D( rotation, tran ));
109  LogDebug("DDAlgorithm") << "test " << child.name() << " number "
110  << copy << " positioned in " << mother.name() << " at "
111  << tran << " with " << rotstr << ": " << rotation;
112  copy += incrCopyNo;
113  phi += delta;
114  }
115  return 1;
116 }
#define LogDebug(id)
dbl * delta
Definition: mlp_gen.cc:36
def copy(args, dbName)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define ConvertTo(_x, _y)
Definition: DDUnits.h:6
ROOT::Math::AxisAngle DDAxisAngle
#define NAMESPACE_SEP
Definition: DDNamespace.h:78
DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_global_DDAngular   
)

Definition at line 119 of file DDAngular.cc.