diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index 3f0c7dc0773d3553c35827be571f5300d1c06b52..d527513bfa8ddcc72b8d24088e28938bb40d4c97 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -70,7 +70,7 @@ dd4hep_add_test_reg( ClientTests_volume_scanner COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" EXEC_ARGS geoPluginRun -input ${ClientTestsEx_INSTALL}/compact/MiniTel.xml -destroy -plugin DD4hep_PlacedVolumeScannerTest -detector /world - REGEX_PASS "Visited a total of 31 placed volumes" + REGEX_PASS "Visited a total of 51 placed volumes" REGEX_FAIL "Exception" REGEX_FAIL "FAILED" ) diff --git a/examples/ClientTests/compact/MiniTel.xml b/examples/ClientTests/compact/MiniTel.xml index fef30f56688c525c40f8ac3ed3d55575a3dc1931..d2f251f3ac42200415e0aba1030b004e304b5513 100644 --- a/examples/ClientTests/compact/MiniTel.xml +++ b/examples/ClientTests/compact/MiniTel.xml @@ -49,7 +49,7 @@ <detector name="MyLHCBdetector1" type="MiniTelPixel" material="Silicon" vis="DetVis" id ="1" sensitive="true" readout="MyLHCBdetector1Hits" limits="minitel_limits_1" region="minitel_region_1"> <dimensions z="1*mm" y="10*cm" x="10*cm" /> - <position z="10*mm" y="0*cm" x="0*cm" /> + <module_position z="30*mm" y="0*cm" x="0*cm" /> <module name="pixel" type="MiniTelPixel" material="Silicon" x="6*mm" y="6*mm" z="1*mm" vis="ModVis" alpha="-2.*radian" beta="-2.*radian" gamma="-0.*radian" /> <reflect/> </detector> @@ -57,7 +57,7 @@ <detector name="MyLHCBdetector2" type="MiniTelPixel" material="Silicon" vis="DetVis" id ="2" sensitive="true" readout="MyLHCBdetector2Hits" limits="minitel_limits" region="minitel_region"> <dimensions z="1*mm" y="10*cm" x="10*cm" /> - <position z="20*mm" y="0*cm" x="0*cm" /> + <module_position z="40*mm" y="0*cm" x="0*cm" /> <module name="pixel" type="MiniTelPixel" material="Silicon" x="6*mm" y="6*mm" z="1*mm" vis="ModVis" alpha="-2.*radian" beta="-2.*radian" gamma="-0.*radian" /> <reflect/> </detector> @@ -65,7 +65,7 @@ <detector name="MyLHCBdetector3" type="MiniTelPixel" material="Silicon" vis="DetVis" id ="3" sensitive="true" readout="MyLHCBdetector3Hits" limits="minitel_limits" region="minitel_region"> <dimensions z="1*mm" y="10*cm" x="10*cm" /> - <position z="30*mm" y="0*cm" x="0*cm" /> + <module_position z="50*mm" y="0*cm" x="0*cm" /> <module name="pixel" type="MiniTelPixel" material="Silicon" x="6*mm" y="6*mm" z="5*mm" vis="ModVis" alpha="-2.*radian" beta="-2.*radian" gamma="-0.*radian" /> <reflect/> </detector> @@ -74,7 +74,7 @@ <detector name="MyLHCBdetector4" type="MiniTelPixel" material="Silicon" vis="DetVis" id ="4" sensitive="true" readout="MyLHCBdetector4Hits" limits="minitel_limits" region="minitel_region"> <dimensions z="1*mm" y="10*cm" x="10*cm"/> - <position z="40*mm" y="0*cm" x="0*cm" /> + <module_position z="60*mm" y="0*cm" x="0*cm" /> <module name="pixel" type="MiniTelPixel" material="Silicon" x="6*mm" y="6*mm" z="21*mm" vis="ModVis" alpha="-2.*radian" beta="-2.*radian" gamma="-0.*radian" /> <reflect/> </detector> @@ -83,7 +83,7 @@ <detector name="MyLHCBdetector5" type="MiniTelPixel" material="Silicon" vis="DetVis" id ="5" sensitive="true" readout="MyLHCBdetector5Hits" limits="minitel_limits" region="minitel_region"> <dimensions z="1*mm" y="10*cm" x="10*cm"/> - <position z="50*mm" y="0*cm" x="0*cm" /> + <module_position z="70*mm" y="0*cm" x="0*cm" /> <module name="pixel" type="MiniTelPixel" material="Silicon" x="6*mm" y="6*mm" z="10*mm" vis="ModVis" alpha="-2.*radian" beta="-2.*radian" gamma="-0.*radian" /> <reflect/> </detector> @@ -92,7 +92,7 @@ <detector name="MyLHCBdetector6" type="MiniTelPixel" material="Silicon" vis="DetVis" id ="6" sensitive="true" readout="MyLHCBdetector6Hits" limits="minitel_limits" region="minitel_region"> <dimensions z="1*mm" y="10*cm" x="10*cm" /> - <position z="60*mm" y="0*cm" x="0*cm" /> + <module_position z="80*mm" y="0*cm" x="0*cm" /> <module name="pixel" type="MiniTelPixel" material="Silicon" x="6*mm" y="6*mm" z="1*mm" vis="ModVis" alpha="-2.*radian" beta="-2.*radian" gamma="-0.*radian" /> <reflect/> </detector> @@ -101,7 +101,7 @@ <detector name="MyLHCBdetector7" type="MiniTelPixel" material="Silicon" vis="DetVis" id ="7" sensitive="true" readout="MyLHCBdetector7Hits" limits="minitel_limits" region="minitel_region"> <dimensions z="1*mm" y="10*cm" x="10*cm" /> - <position z="70*mm" y="0*cm" x="0*cm" /> + <module_position z="90*mm" y="0*cm" x="0*cm" /> <module name="pixel" type="MiniTelPixel" material="Silicon" x="6*mm" y="6*mm" z="1*mm" vis="ModVis" alpha="-2.*radian" beta="-2.*radian" gamma="-0.*radian" /> <reflect/> </detector> @@ -110,7 +110,7 @@ <detector name="MyLHCBdetector8" type="MiniTelPixel" material="Silicon" vis="DetVis" id ="8" sensitive="true" readout="MyLHCBdetector8Hits" limits="minitel_limits" region="minitel_region"> <dimensions z="1*mm" y="10*cm" x="10*cm" /> - <position z="80*mm" y="0*cm" x="0*cm" /> + <module_position z="100*mm" y="0*cm" x="0*cm" /> <module name="pixel" type="MiniTelPixel" material="Silicon" x="6*mm" y="6*mm" z="1*mm" vis="ModVis" alpha="-2.*radian" beta="-2.*radian" gamma="-0.*radian" /> <reflect/> </detector> @@ -118,7 +118,7 @@ <detector name="MyLHCBdetector9" type="MiniTelPixel" material="Silicon" vis="DetVis" id ="9" sensitive="true" readout="MyLHCBdetector9Hits" limits="minitel_limits" region="minitel_region"> <dimensions z="1*mm" y="10*cm" x="10*cm" /> - <position z="90*mm" y="0*cm" x="0*cm" /> + <module_position z="110*mm" y="0*cm" x="0*cm" /> <module name="pixel" type="MiniTelPixel" material="Silicon" x="6*mm" y="6*mm" z="1*mm" vis="ModVis" alpha="-2.*radian" beta="-2.*radian" gamma="-0.*radian" /> <reflect/> </detector> @@ -126,7 +126,7 @@ <detector name="MyLHCBdetector10" type="MiniTelPixel" material="Silicon" vis="DetVis" id ="10" sensitive="true" readout="MyLHCBdetector10Hits" limits="minitel_limits" region="minitel_region"> <dimensions z="1*mm" y="10*cm" x="10*cm" /> - <position z="100*mm" y="0*cm" x="0*cm" /> + <module_position z="120*mm" y="0*cm" x="0*cm" /> <module name="pixel" type="MiniTelPixel" material="Silicon" x="6*mm" y="6*mm" z="1*mm" vis="ModVis" alpha="-2.*radian" beta="-2.*radian" gamma="-0.*radian" /> <reflect/> </detector> @@ -164,43 +164,43 @@ <readouts> <readout name="MyLHCBdetector1Hits"> <segmentation type="CartesianGridXY" grid_size_x="6*mm" grid_size_y="6*mm" /> - <id>system:6,side:2,x:12:-6,y:24:-6</id> + <id>system:6,side:2,module:8,x:28:-12,y:52:-12</id> </readout> <readout name="MyLHCBdetector2Hits"> <segmentation type="CartesianGridXY" grid_size_x="6*mm" grid_size_y="6*mm" /> - <id>system:6,side:2,x:12:-6,y:24:-6</id> + <id>system:6,side:2,module:8,x:28:-12,y:52:-12</id> </readout> <readout name="MyLHCBdetector3Hits"> <segmentation type="CartesianGridXY" grid_size_x="6*mm" grid_size_y="6*mm" /> - <id>system:6,side:2,x:12:-6,y:24:-6</id> + <id>system:6,side:2,module:8,x:28:-12,y:52:-12</id> </readout> <readout name="MyLHCBdetector4Hits"> <segmentation type="CartesianGridXY" grid_size_x="6*mm" grid_size_y="6*mm" /> - <id>system:6,side:2,x:12:-6,y:24:-6</id> + <id>system:6,side:2,module:8,x:28:-12,y:52:-12</id> </readout> <readout name="MyLHCBdetector5Hits"> <segmentation type="CartesianGridXY" grid_size_x="6*mm" grid_size_y="6*mm" /> - <id>system:6,side:2,x:12:-6,y:24:-6</id> + <id>system:6,side:2,module:8,x:28:-12,y:52:-12</id> </readout> <readout name="MyLHCBdetector6Hits"> <segmentation type="CartesianGridXY" grid_size_x="6*mm" grid_size_y="6*mm" /> - <id>system:6,side:2,x:12:-6,y:24:-6</id> + <id>system:6,side:2,module:8,x:28:-12,y:52:-12</id> </readout> <readout name="MyLHCBdetector7Hits"> <segmentation type="CartesianGridXY" grid_size_x="6*mm" grid_size_y="6*mm" /> - <id>system:6,side:2,x:12:-6,y:24:-6</id> + <id>system:6,side:2,module:8,x:28:-12,y:52:-12</id> </readout> <readout name="MyLHCBdetector8Hits"> <segmentation type="CartesianGridXY" grid_size_x="6*mm" grid_size_y="6*mm" /> - <id>system:6,side:2,x:12:-6,y:24:-6</id> + <id>system:6,side:2,module:8,x:28:-12,y:52:-12</id> </readout> <readout name="MyLHCBdetector9Hits"> <segmentation type="CartesianGridXY" grid_size_x="6*mm" grid_size_y="6*mm" /> - <id>system:6,side:2,x:12:-6,y:24:-6</id> + <id>system:6,side:2,module:8,x:28:-12,y:52:-12</id> </readout> <readout name="MyLHCBdetector10Hits"> <segmentation type="CartesianGridXY" grid_size_x="6*mm" grid_size_y="6*mm" /> - <id>system:6,side:2,x:12:-6,y:24:-6</id> + <id>system:6,side:2,module:8,x:28:-12,y:52:-12</id> </readout> </readouts> diff --git a/examples/ClientTests/src/MiniTel.cpp b/examples/ClientTests/src/MiniTel.cpp index 2c3b9279f3aa21a38bedcc013a46c3a9d173e826..e222275235605efa6570b6ddfea8f97b3b7b6ab4 100644 --- a/examples/ClientTests/src/MiniTel.cpp +++ b/examples/ClientTests/src/MiniTel.cpp @@ -26,18 +26,15 @@ using namespace dd4hep::detail; namespace { struct MyDetExtension { int idD, Ni, Nj; - double posDX, posDY, posDZ; double dimDX, dimDY, dimDZ; double pixelX, pixelY, pixelZ; DetElement detector; MyDetExtension(DetElement e) : idD(0), Ni(0), Nj(0), - posDX(0.0), posDY(0.0), posDZ(0.0), dimDX(0.0), dimDY(0.0), dimDZ(0.0), pixelX(0.0), pixelY(0.0), pixelZ(0.0), detector(e) {} MyDetExtension(const MyDetExtension& e, DetElement d) : idD(e.idD), Ni(e.Ni), Nj(e.Nj), - posDX(e.posDX), posDY(e.posDY), posDZ(e.posDZ), dimDX(e.dimDX), dimDY(e.dimDY), dimDZ(e.dimDZ), pixelX(e.pixelX), pixelY(e.pixelY), pixelZ(e.pixelZ), detector(d) @@ -48,94 +45,73 @@ namespace { typedef MyDetExtension DetectorExtension; static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector sens) { - xml_det_t x_det = e; //xml-detelemnt of the detector taken as an argument - string det_name = x_det.nameStr(); //det_name is the name of the xml-detelement - Assembly assembly (det_name); - int detectors_id = x_det.id(); - + xml_det_t x_det = e; //xml-detelemnt of the detector taken as an argument + xml_comp_t det_dim = x_det.child(_U(dimensions)); + xml_comp_t dtc_mod = x_det.child(_U(module)); // considering the module-pixel of the detector + string det_name = x_det.nameStr(); //det_name is the name of the xml-detelement + Assembly assembly (det_name); DetElement sdet(det_name,x_det.id()); //sdet is the detelement of the detector!!(actually is a Handle,already a pointer to m_element) + Volume motherVol = description.pickMotherVolume(sdet); //the mothers volume of our detector + Material mat = description.material("Silicon"); + DetectorExtension* ext = new MyDetExtension(sdet); sdet.addExtension<MyDetExtension>(ext); - ext->idD= detectors_id; - - - xml_coll_t mip(x_det, _U(position)); - xml_comp_t det_po = mip; - - double det_y = det_po.y(); // det_y is the y dimension of the xml-detelement - double det_x = det_po.x(); // det_x is the x dimension of the xml-detelement - double det_z = det_po.z(); // det_z is the z dimension of the xml-detelement - ext->posDY = det_y; - ext->posDX = det_x; - ext->posDZ = det_z; - - xml_coll_t dim(x_det, _U(dimensions)); - xml_comp_t det_dim = dim; - double dim_x = det_dim.x(); // det_x is the x dimension of the xml-detelement - double dim_y = det_dim.y(); // det_y is the y dimension of the xml-detelement - double dim_z = det_dim.z(); // det_z is the z dimension of the xml-detelement - - Material mat = description.material("Silicon"); - - Volume motherVol = description.pickMotherVolume(sdet); //the mothers volume of our detector - - xml_coll_t mi(x_det, _U(module)); - xml_comp_t dtc_mod = mi; // considering the module-pixel of the detector - double pixelX = dtc_mod.x(); // The x dimension of the module - double pixelY = dtc_mod.y(); // The y dimension of the module - double pixelZ = dtc_mod.z(); // The z dimension of the module - - int Ni = dim_x/pixelX; // how many pixels in the x dimension - int Nj = dim_y/pixelY; - - ext->dimDX = dim_x; - ext->dimDY = dim_y; - ext->dimDZ = dim_z; - ext->pixelX = pixelX; - ext->pixelY = pixelY; - ext->pixelZ = pixelZ; - ext->Ni= Ni; - ext->Nj= Nj; - + ext->idD = x_det.id(); + ext->dimDX = det_dim.x(); // det_x is the x dimension of the xml-detelement + ext->dimDY = det_dim.y(); // det_y is the y dimension of the xml-detelement + ext->dimDZ = det_dim.z(); // det_z is the z dimension of the xml-detelement + ext->pixelX = dtc_mod.x(); // The x dimension of the module + ext->pixelY = dtc_mod.y(); // The y dimension of the module + ext->pixelZ = dtc_mod.z(); // The z dimension of the module + ext->Ni = int(det_dim.x()/dtc_mod.x()); + ext->Nj = int(det_dim.y()/dtc_mod.y()); + + Volume sensor_vol(det_name, Box(det_dim.x(),det_dim.y(),det_dim.z()), mat); + sensor_vol.setVisAttributes(description.visAttributes(x_det.visStr())); + sensor_vol.setLimitSet(description, x_det.limitsStr()); + sensor_vol.setRegion(description, x_det.regionStr()); + sensor_vol.setSensitiveDetector(sens); + if ( x_det.isSensitive() ) { + sens.setType("tracker"); + } - for (int i= 0; i<Ni; i++){ //lets start from 100 and when getting the x dimensions of the detector, use num_pixels - for (int j= 0; j<Nj; j++){ - //Position ppxl = Position(pixelX*i, pixelY*j, pixelZ); //The local position of its pixel - //mi_id = i+j +(Nj-1)*j ; //finding the id of the pixel according to its' position - //printout(INFO,det_name,"Giving to this pixel with position (%7.3f, %7.3f, %7.3f) id:%d",ppxl.x(),ppxl.y(),ppxl.z(),mi_id); - } + int count = 0; + PlacedVolume pv; + DetElement side_det; + Assembly side_vol; + Position side_pos(0,0,3*dd4hep::cm); + + side_det = DetElement(sdet,"side_0", x_det.id()); + side_vol = Assembly("side_0"); + if ( x_det.hasChild(_U(side_position)) ) { + xml_comp_t x_pos = x_det.child(_U(side_position)); + side_pos = Position(x_pos.x(0), x_pos.y(0), x_pos.z(3*dd4hep::cm)); + } + pv = assembly.placeVolume(side_vol, side_pos); + pv.addPhysVolID("side",0); + side_det.setPlacement(pv); + for( xml_coll_t m(x_det, _U(module_position)); m; m++ ) { + xml_comp_t x_pos = m; + DetElement module(side_det, _toString(count, "module_%d"), count); + pv = side_vol.placeVolume(sensor_vol,Transform3D(Position(x_pos.x(),x_pos.y(),x_pos.z()))); + pv.addPhysVolID("module", ++count); + module.setPlacement(pv); } - Volume m_volume(det_name, Box(dim_x, dim_y, dim_z), mat); //as parameters it needs name,solid,material - m_volume.setVisAttributes(description.visAttributes(x_det.visStr())); //I DONT MIND ABOUT THIS! - m_volume.setLimitSet(description,x_det.limitsStr()); - m_volume.setRegion(description,x_det.regionStr()); - m_volume.setSensitiveDetector(sens); - PlacedVolume pv1, pv2; - // det_x,det_y,det_z are the dimensions of the detector in space - pv1 = assembly.placeVolume(m_volume,Transform3D(Position(det_x,det_y,det_z))); if ( x_det.hasChild(_U(reflect)) ) { - /// Reflect in XY-plane - pv2 = assembly.placeVolume(m_volume,Transform3D(Rotation3D(1., 0., 0., 0., 1., 0., 0., 0., -1.), - Position(det_x,det_y,-det_z))); + xml_comp_t x_pos = x_det.child(_U(reflect)); + side_pos = Position(x_pos.x(-side_pos.x()), x_pos.y(-side_pos.y()), x_pos.z(-side_pos.z())); + auto [det, vol] = side_det.reflect("side_1", x_det.id(), sens); + pv = assembly.placeVolume(vol, Transform3D(RotationZ(M_PI),side_pos)); + pv.addPhysVolID("side",1); + det.setPlacement(pv); + sdet.add(det); } - if ( x_det.isSensitive() ) { - DetElement side_0(sdet,"side_0",x_det.id()); - // Set volume attributes - sens.setType("tracker"); - pv1.addPhysVolID("side",0); - side_0.setPlacement(pv1); - if ( pv2.isValid() ) { - DetElement side_1(sdet,"side_1",x_det.id()); - side_1.setPlacement(pv2); - pv2.addPhysVolID("side",1); - } - } - auto pv = motherVol.placeVolume(assembly); - pv.addPhysVolID("system",detectors_id); + + pv = motherVol.placeVolume(assembly); + pv.addPhysVolID("system", x_det.id()); sdet.setPlacement(pv); - // Support additional test if Detector_InhibitConstants is set to TRUE - description.constant<double>("world_side"); return sdet; } + DECLARE_DETELEMENT(MiniTelPixel,create_detector) diff --git a/examples/Persistency/CMakeLists.txt b/examples/Persistency/CMakeLists.txt index 5873ed722128938e79115e5c2e0157f881ab3ea8..b6089d6141af38f7112fa7377318a3b9d503de86 100644 --- a/examples/Persistency/CMakeLists.txt +++ b/examples/Persistency/CMakeLists.txt @@ -78,7 +78,7 @@ dd4hep_add_test_reg( Persist_MiniTel_Restore_VolMgr1_LONGTEST -plugin DD4hep_RootLoader MiniTel_geometry.root -plugin DD4hep_CheckVolumeManager DEPENDS Persist_MiniTel_Save_LONGTEST - REGEX_PASS "\\+\\+\\+ PASSED Checked 20 VolumeManager contexts. Num.Errors: 0" + REGEX_PASS "\\+\\+\\+ PASSED Checked 40 VolumeManager contexts. Num.Errors: 0" REGEX_FAIL " ERROR ;EXCEPTION;Exception;FAILED;TStreamerInfo" ) #