File indexing completed on 2025-01-30 09:17:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "DD4hep/DetFactoryHelper.h"
0016 #include "DD4hep/DD4hepUnits.h"
0017
0018 using namespace std;
0019 using namespace dd4hep;
0020 using namespace dd4hep::detail;
0021
0022 static Ref_t create_element(Detector& description, xml_h e, SensitiveDetector sd) {
0023 Box box;
0024 Volume vol;
0025 PlacedVolume phv;
0026 xml_det_t x_det = e;
0027 double small = 1e-3*dd4hep::mm;
0028 string name = x_det.nameStr();
0029 Material air = description.material("Air");
0030 Material mat_pcb = description.material("Epoxy");
0031 Material mat_silicon = description.material("Si");
0032 DetElement det (name,x_det.id());
0033 Assembly envVol (name+"_envelope");
0034
0035 sd.setType("tracker");
0036 for(xml_coll_t im(x_det,_U(module)); im; ++im) {
0037 xml_dim_t mod = im;
0038 xml_dim_t sens = mod.child(_U(sensor));
0039 xml_dim_t chip = mod.child(_Unicode(chip));
0040 xml_dim_t pcb = mod.child(_Unicode(PCB));
0041 int noPixX = sens.attr<int>(_Unicode(NoOfPixX));
0042 int noPixY = sens.attr<int>(_Unicode(NoOfPixY));
0043 double pitch = sens.attr<double>(_Unicode(pitch));
0044 double mod_thick = sens.thickness()+chip.thickness()+pcb.thickness();
0045 DetElement mod_det(det,_toString(mod.id(),"module_%d"),x_det.id());
0046
0047
0048 box = Box(pitch*noPixX/2e0+small, pitch*noPixY/2e0+small, mod_thick/2e0+small);
0049 Volume modvol(_toString(mod.id(),"module_%d"), box, air);
0050 modvol.setVisAttributes(description.visAttributes(mod.visStr()));
0051
0052 DetElement sens_det(mod_det,"sensor",x_det.id());
0053 box = Box(pitch*noPixX/2e0, pitch*noPixY/2e0, sens.thickness()/2e0);
0054 vol = Volume(_toString(mod.id(),"sensor_%d"), box, mat_silicon);
0055 vol.setSensitiveDetector(sd);
0056 vol.setVisAttributes(description.visAttributes(sens.visStr()));
0057 phv = modvol.placeVolume(vol, Position(0, 0, -mod_thick/2e0+sens.thickness()/2e0));
0058 phv.addPhysVolID("sensor",1);
0059 sens_det.setPlacement(phv);
0060
0061 box = Box(pitch*noPixX/2e0, pitch*noPixY/2e0, chip.thickness()/2e0);
0062 vol = Volume(_toString(mod.id(),"chip_%d"), box, mat_silicon);
0063 vol.setVisAttributes(description.visAttributes(chip.visStr()));
0064 phv = modvol.placeVolume(vol, Position(0, 0, -mod_thick/2e0+sens.thickness()+chip.thickness()/2e0));
0065 phv.addPhysVolID("sensor",2);
0066
0067 box = Box(pitch*noPixX/2e0, pitch*noPixY/2e0, pcb.thickness()/2e0);
0068 vol = Volume(_toString(mod.id(),"PCB_%d"), box, mat_pcb);
0069 vol.setVisAttributes(description.visAttributes(pcb.visStr()));
0070 phv = modvol.placeVolume(vol, Position(0, 0, -mod_thick/2e0+sens.thickness()+chip.thickness()+pcb.thickness()/2e0));
0071 phv.addPhysVolID("sensor",3);
0072
0073 phv = envVol.placeVolume(modvol,Position(0e0, 0e0, mod.z()));
0074 phv.addPhysVolID("module",mod.id());
0075 mod_det.setPlacement(phv);
0076 }
0077 envVol.setVisAttributes(description.visAttributes(x_det.visStr()));
0078 phv = description.pickMotherVolume(det).placeVolume(envVol,Position(0,0,0));
0079 phv.addPhysVolID("system",x_det.id());
0080 det.setPlacement(phv);
0081 return det;
0082 }
0083
0084
0085 DECLARE_DETELEMENT(DD4hep_Example_Telescope,create_element)