ECCE @ 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 #include "DD4hep/DetFactoryHelper.h"
12 
13 using namespace std;
14 using namespace dd4hep;
15 
16 static Ref_t create_element(Detector& oddd, xml_h xml,
17  SensitiveDetector /*sens*/) {
18  xml_det_t x_det = xml;
19  string detName = x_det.nameStr();
20 
21  // Make Volume
22  xml_comp_t x_det_tubs = x_det.child(_U(tubs));
23 
24  // Make DetElement
25  DetElement cylinderElement(detName, x_det.id());
26 
27  // add Extension to Detlement for the RecoGeometry
28  Acts::ActsExtension* pcExtension = new Acts::ActsExtension();
29  bool isBeamPipe = x_det.hasChild(_U(beampipe));
30  pcExtension->addType("passive cylinder", "layer");
31  if (isBeamPipe) {
32  pcExtension->addType("beampipe", "layer");
33  }
34  // Add the proto layer material
35  for (xml_coll_t lmat(x_det_tubs, _Unicode(layer_material)); lmat; ++lmat) {
36  xml_comp_t x_layer_material = lmat;
37  xmlToProtoSurfaceMaterial(x_layer_material, *pcExtension, "layer_material");
38  }
39  cylinderElement.addExtension<Acts::ActsExtension>(pcExtension);
40 
41  string shapeName = x_det_tubs.nameStr();
42  Tube tubeShape(shapeName, x_det_tubs.rmin(), x_det_tubs.rmax(),
43  x_det_tubs.dz());
44  Volume tubeVolume(detName, tubeShape,
45  oddd.material(x_det_tubs.materialStr()));
46  tubeVolume.setVisAttributes(oddd, x_det.visStr());
47 
48  // Place it in the mother
49  Volume motherVolume = oddd.pickMotherVolume(cylinderElement);
50  PlacedVolume placedTube = motherVolume.placeVolume(tubeVolume);
51  placedTube.addPhysVolID(detName, cylinderElement.id());
52  cylinderElement.setPlacement(placedTube);
53 
54  // And return the element for further parsing
55  return cylinderElement;
56 }
57 
58 DECLARE_DETELEMENT(ODDCylinder, create_element)