CMS 3D CMS Logo

DDTrackerXYZPosAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
4 
5 using namespace std;
6 using namespace dd4hep;
7 using namespace cms;
8 
9 static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
10  cms::DDNamespace ns(ctxt, e, true);
11  DDAlgoArguments args(ctxt, e);
12  int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
13  int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
14  Volume mother = ns.volume(args.parentName());
15  Volume child = ns.volume(args.value<string>("ChildName"));
16  vector<double> xvec = args.value<vector<double> >("XPositions"); // X positions
17  vector<double> yvec = args.value<vector<double> >("YPositions"); // Y positions
18  vector<double> zvec = args.value<vector<double> >("ZPositions"); // Z positions
19  vector<string> rotMat = args.value<vector<string> >("Rotations"); // Names of rotation matrices
20 
21  edm::LogVerbatim("TrackerGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
22  << ns.name() << "\tCopyNo (Start/Increment) " << startCopyNo << ", " << incrCopyNo
23  << "\tNumber " << xvec.size() << ", " << yvec.size() << ", " << zvec.size();
24  for (int i = 0; i < (int)(zvec.size()); i++) {
25  edm::LogVerbatim("TrackerGeom") << "\t[" << i << "]\tX = " << xvec[i] << "\t[" << i << "]\tY = " << yvec[i] << "\t["
26  << i << "]\tZ = " << zvec[i] << ", Rot.Matrix = " << rotMat[i];
27  }
28 
29  for (int i = 0, copy = startCopyNo; i < (int)(zvec.size()); i++, copy += incrCopyNo) {
30  Position tran(xvec[i], yvec[i], zvec[i]);
31  Rotation3D rot;
32  /* PlacedVolume pv = */ rotMat[i] != "NULL"
33  ? mother.placeVolume(child, copy, Transform3D(ns.rotation(rotMat[i]), tran))
34  : mother.placeVolume(child, tran);
35  edm::LogVerbatim("TrackerGeom") << "test: " << child.name() << " number " << copy << " positioned in "
36  << mother.name() << " at " << tran << " with " << rot;
37  }
38  return 1;
39 }
40 
41 // first argument is the type from the xml file
42 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerXYZPosAlgo, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDParsingContext
Definition: DDParsingContext.h:14
cms::DDNamespace
Definition: DDNamespace.h:22
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:83
cms::DDNamespace::rotation
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:170
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
DDPlugins.h
createfilelist.int
int
Definition: createfilelist.py:10
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
align::Detector
Definition: StructureType.h:92
std
Definition: JetResolutionObject.h:76
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
dd4hep
Definition: DDPlugins.h:8
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
child
Definition: simpleInheritance.h:11
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:79
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:264
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
algorithm
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDTrackerXYZPosAlgo.cc:9
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37