GEMTrackerDisc_geo.cpp
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
2 #include "DD4hep/Printout.h"
3 #include "TMath.h"
4 #include "DDRec/Surface.h"
5 #include "DDRec/DetectorData.h"
6 
7 #include "Acts/Plugins/DD4hep/ActsExtension.hpp"
8 
9 using namespace std;
10 using namespace dd4hep;
11 using namespace dd4hep::rec;
12 
29 static Ref_t create_detector(Detector& lcdd, xml_h e, SensitiveDetector sens)
30 {
31  typedef vector<PlacedVolume> Placements;
32 
33  xml_det_t x_det = e;
34  Material air = lcdd.air();
35  Material carbon = lcdd.material("CarbonFiber");
36  Material silicon = lcdd.material("SiliconOxide");
37  int det_id = x_det.id();
38  string det_name = x_det.nameStr();
39  PlacedVolume pv;
40 
41  DetElement sdet(det_name, det_id);
42  Assembly assembly(det_name+"_assembly");
43 Acts::ActsExtension* ecapDetExt = new Acts::ActsExtension();
44  ecapDetExt->addType("barrel", "detector");
45  sdet.addExtension<Acts::ActsExtension>(ecapDetExt);
46 
47  sens.setType("tracker");
48  string module_name = "GEM";
49 
50  double thickness = 0.01*dd4hep::cm;
51 
52  int N_layers = 0;
53 
54  for(xml_coll_t lay( x_det, _U(layer) ); lay; ++lay, ++N_layers) {
55 
56  xml_comp_t x_layer = lay;
57  double inner_r = x_layer.attr<double>( _Unicode(inner_r) ) ;
58  double outer_r = x_layer.attr<double>( _Unicode(outer_r) ) ;
59  double phi0_offset = x_layer.attr<double>( _Unicode(phi0_offset) ) ;
60  double z = x_layer.attr<double>( _Unicode(z) ) ;
61  int layer_id = x_layer.id();//attr<double>( _Unicode(z) ) ;
62 
63  string layer_name = std::string("gem_layer") + std::to_string(layer_id) ;
64 
65  Tube gem_layer(inner_r, outer_r, thickness/2.0);
66  Volume gem_layer_vol("gem_layer_vol", gem_layer, carbon);
67 
68  // -------- create a measurement plane for the tracking surface attched to the sensitive volume -----
69  Vector3D u( 1. , 0. , 0. ) ;
70  Vector3D v( 0. , 1. , 0. ) ;
71  Vector3D n( 0. , 0. , 1. ) ;
72  Vector3D o( 0. , 0. , 0. ) ;
73  double inner_thickness = thickness/2.0;
74  double outer_thickness = thickness/2.0;
75  SurfaceType type( SurfaceType::Sensitive ) ;
76  VolPlane surf( gem_layer_vol, type, inner_thickness , outer_thickness , u,v,n,o ) ;
77 
78  gem_layer_vol.setSensitiveDetector(sens);
79 
80  DetElement layer_DE( sdet, _toString(layer_id,"layer%d"), layer_id );
81 
82  Acts::ActsExtension* detlayer = new Acts::ActsExtension();
83  detlayer->addType("sensitive disk", "layer");
84  // the local coordinate systems of modules in dd4hep and acts differ
85  // see http://acts.web.cern.ch/ACTS/latest/doc/group__DD4hepPlugins.html
86  detlayer->addType("axes", "definitions", "XYZ");
87  layer_DE.addExtension<Acts::ActsExtension>(detlayer);
88 
89  //Assembly layer_assembly( layer_name+"_assembly" );
90  pv = assembly.placeVolume( gem_layer_vol, Transform3D(RotationZ(phi0_offset),Position(0.0,0.0,z)) );
91  pv.addPhysVolID( "layer", layer_id );
92  layer_DE.setPlacement(pv);
93  //layer_DE.setAttributes(lcdd, layer_assembly, "", "", "SiVertexLayerVis");
94 
95  }
96 
97  sdet.setAttributes(lcdd, assembly,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
98  //assembly.setVisAttributes(lcdd.invisible());
99 
100  pv = lcdd.pickMotherVolume(sdet).placeVolume(assembly);
101  pv.addPhysVolID("system", det_id); // Set the subdetector system ID.
102  sdet.setPlacement(pv);
103 
104  assembly->GetShape()->ComputeBBox() ;
105  return sdet;
106 }
108 DECLARE_DETELEMENT(GEMTrackerDisc, create_detector)
static Ref_t create_detector(Detector &lcdd, xml_h e, SensitiveDetector sens)
Detector
Definition: DDG4.py:69
Namespace for the AIDA detector description toolkit.