EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ODDCylinder_geo.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ODDCylinder_geo.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
11 
12 #include "DD4hep/DetFactoryHelper.h"
13 
14 using namespace std;
15 using namespace dd4hep;
16 
17 static Ref_t create_element(Detector& oddd, xml_h xml,
18  SensitiveDetector /*sens*/) {
19  xml_det_t x_det = xml;
20  string detName = x_det.nameStr();
21 
22  // Make Volume
23  xml_comp_t x_det_tubs = x_det.child(_U(tubs));
24 
25  // Make DetElement
26  DetElement cylinderElement(detName, x_det.id());
27 
28  // add Extension to Detlement for the RecoGeometry
29  Acts::ActsExtension* pcExtension = new Acts::ActsExtension();
30  bool isBeamPipe = x_det.hasChild(_U(beampipe));
31  pcExtension->addType("passive cylinder", "layer");
32  if (isBeamPipe) {
33  pcExtension->addType("beampipe", "layer");
34  }
35  // Add the proto layer material
36  for (xml_coll_t lmat(x_det_tubs, _Unicode(layer_material)); lmat; ++lmat) {
37  xml_comp_t x_layer_material = lmat;
38  xmlToProtoSurfaceMaterial(x_layer_material, *pcExtension, "layer_material");
39  }
40  cylinderElement.addExtension<Acts::ActsExtension>(pcExtension);
41 
42  string shapeName = x_det_tubs.nameStr();
43  Tube tubeShape(shapeName, x_det_tubs.rmin(), x_det_tubs.rmax(),
44  x_det_tubs.dz());
45  Volume tubeVolume(detName, tubeShape,
46  oddd.material(x_det_tubs.materialStr()));
47  tubeVolume.setVisAttributes(oddd, x_det.visStr());
48 
49  // Place it in the mother
50  Volume motherVolume = oddd.pickMotherVolume(cylinderElement);
51  PlacedVolume placedTube = motherVolume.placeVolume(tubeVolume);
52  placedTube.addPhysVolID(detName, cylinderElement.id());
53  cylinderElement.setPlacement(placedTube);
54 
55  // And return the element for further parsing
56  return cylinderElement;
57 }
58 
59 DECLARE_DETELEMENT(ODDCylinder, create_element)