diff --git a/Detector/DetCRD/CMakeLists.txt b/Detector/DetCRD/CMakeLists.txt index b6e71ca3e315306d16608371171e9448573e596c..af67f2244e54c33950998ac8b82d552144141e92 100644 --- a/Detector/DetCRD/CMakeLists.txt +++ b/Detector/DetCRD/CMakeLists.txt @@ -15,7 +15,7 @@ gaudi_add_module(DetCRD src/Other/Lumical_v01_geo_beampipe.cpp src/Other/CRDBeamPipe_v01_geo.cpp src/Muon/Muon_Barrel_v01_01.cpp - src/Muon/Muon_Endcap_v01_01.cpp + src/Muon/Muon_Endcap_v01_02.cpp src/Tracker/SiTrackerSkewRing_v01_geo.cpp src/Tracker/SiTrackerStaggeredLadder_v01_geo.cpp src/Tracker/TPC_Simple_o1_v01.cpp diff --git a/Detector/DetCRD/compact/CRD_common_v01/Muon_Barrel_v01_01.xml b/Detector/DetCRD/compact/CRD_common_v01/Muon_Barrel_v01_01.xml index 586074a3d04ab48b3a70520b60f5d0f7854846d4..5afc3dd9e15237c80ece17397fa6b9a48bd78b91 100644 --- a/Detector/DetCRD/compact/CRD_common_v01/Muon_Barrel_v01_01.xml +++ b/Detector/DetCRD/compact/CRD_common_v01/Muon_Barrel_v01_01.xml @@ -12,39 +12,44 @@ <define> <!--Muon Barrel--> - <constant name="Muon_barrel_superlayer_num" value="6"/> - <constant name="Muon_barrel_strip_num_0" value="40"/> - <constant name="Muon_barrel_strip_num_1" value="48"/> - <constant name="Muon_barrel_strip_num_2" value="62"/> - <constant name="Muon_barrel_strip_num_3" value="74"/> - <constant name="Muon_barrel_strip_num_4" value="84"/> - <constant name="Muon_barrel_strip_num_5" value="96"/> - <constant name="Muon_barrel_strip_num" value="100"/> + <constant name="Muon_barrel_superlayer_num" value="8"/> + <constant name="Muon_barrel_strip_num_0" value="17"/> + <constant name="Muon_barrel_strip_num_1" value="29"/> + <constant name="Muon_barrel_strip_num_2" value="41"/> + <constant name="Muon_barrel_strip_num_3" value="53"/> + <constant name="Muon_barrel_strip_num_4" value="65"/> + <constant name="Muon_barrel_strip_num_5" value="77"/> + <constant name="Muon_barrel_strip_num_6" value="89"/> + <constant name="Muon_barrel_strip_num_7" value="101"/> + <constant name="Muon_barrel_strip_num_fixed_0" value="106"/> + <constant name="Muon_barrel_strip_num_fixed_1" value="115"/> - <constant name="Muon_barrel_iron_x1" value="Muon_standard_scale"/> - <constant name="Muon_barrel_iron_y" value="Muon_strip_z+2*Muon_strip_surf+Muon_Iron_gap_z"/> + <!--constant name="Muon_barrel_iron_x1" value="Muon_standard_scale"/--> + <constant name="Muon_barrel_iron_y" value="Muon_total_length"/> <constant name="Muon_barrel_iron_z" value="Muon_standard_scale"/> <constant name="Muon_barrel_iron_posx" value="-1*Muon_standard_scale"/> <constant name="Muon_barrel_barrel_y" value="Muon_barrel_iron_y"/> <constant name="Muon_barrel_barrel_posy" value="0.5*Muon_barrel_barrel_y"/> - <constant name="Muon_barrel_superlayer_init" value="-21.5*cm"/> - <constant name="Muon_barrel_superlayer_gap" value="12.5*cm"/> - <constant name="Muon_barrel_superlayer_air_gap" value="0.5*cm"/> + <constant name="Muon_barrel_superlayer_init" value="-48*cm"/> + <constant name="Muon_barrel_superlayer_gap" value="14*cm"/> + <constant name="Muon_barrel_superlayer_endcap_gap" value="10*cm"/> + <constant name="Muon_barrel_superlayer_air_gap" value="1*cm"/> <constant name="Muon_barrel_superlayer_aluminum_gap" value="0.5*Muon_barrel_superlayer_air_gap"/> - <constant name="Muon_barrel_superlayer_y" value="2*Muon_strip_y+2*Muon_barrel_superlayer_air_gap"/> - <constant name="Muon_barrel_superlayer_z" value="Muon_strip_z+2*Muon_strip_surf+2*Muon_barrel_superlayer_air_gap"/> + <constant name="Muon_barrel_superlayer_y" value="2*Muon_strip_y+Muon_barrel_superlayer_air_gap"/> + <!--constant name="Muon_barrel_superlayer_z" value="Muon_strip_z+2*Muon_strip_surf+2*Muon_barrel_superlayer_air_gap"/--> + <!--Checkout--> - <constant name="Muon_barrel_inner_radius" value="483*cm"/> + <constant name="Muon_barrel_inner_radius" value="4245*mm"/> <constant name="Muon_barrel_barrel_num" value="2"/> <constant name="Muon_barrel_iron_part_num" value="12"/> </define> <detectors> - <detector id="201" name="Muon_Barrel_v01_01" type="Muon_Barrel_v01_01" readout="MuonBarrelCollection" vis="WhiteVis"> + <detector id="201" name="MuonBarrel" type="Muon_Barrel_v01_01" readout="MuonBarrelCollection" vis="WhiteVis"> <position x="0" y="0" z="0"/> <barrel id="Muon_barrel_iron_part_num" name="Muon_barrel_barrel" type="Muon_barrel_barrel" vis="SeeThrough"> <position x="0" y="Muon_barrel_barrel_posy" z="0"/> @@ -52,8 +57,8 @@ <material name="Iron"/> <position x="Muon_barrel_iron_posx" y="0"/> <dimensions x1="0.5*Muon_barrel_iron_x1" y1="0.5*Muon_barrel_iron_y" y2="0.5*Muon_barrel_iron_y" dz="0.5*Muon_barrel_iron_z"/> - <superlayer id="Muon_barrel_superlayer_num" name="Muon_barrel_superlayer" type="Muon_barrel_superlayer" vis="GreenVis" material="Air"> - <aluminum id="0" name="Muon_barrel_superlayer_aluminum" type="Muon_barrel_superlayer_aluminum" vis="GrayVis" material="Aluminum"> + <superlayer id="Muon_barrel_superlayer_num" name="Muon_barrel_superlayer" type="Muon_barrel_superlayer" vis="BlueVis" material="Air"> + <aluminum id="0" name="Muon_barrel_superlayer_aluminum" type="Muon_barrel_superlayer_aluminum" vis="RedVis" material="Aluminum"> <material name="Aluminum"/> <position x="0" y="0" z="0"/> <stripe id="0" name="Muon_stripe" type="Muon_stripe" vis="GreenVis" material="Air"> diff --git a/Detector/DetCRD/compact/CRD_common_v01/Muon_Endcap_v01_01.xml b/Detector/DetCRD/compact/CRD_common_v01/Muon_Endcap_v01_01.xml index 926795539a9ea72732b84186749a27ad90a27fc0..f4ab0c7c7b4ee72ad749ca901c4c55f58fc6099d 100644 --- a/Detector/DetCRD/compact/CRD_common_v01/Muon_Endcap_v01_01.xml +++ b/Detector/DetCRD/compact/CRD_common_v01/Muon_Endcap_v01_01.xml @@ -23,7 +23,7 @@ <constant name="Muon_endcap_iron_gap" value="12.5*cm"/> <constant name="Muon_endcap_endcap_z" value="Muon_endcap_iron_gap_num*Muon_endcap_iron_gap+2*Muon_endcap_superlayer_num*Muon_strip_y"/> - <constant name="Muon_endcap_endcap_posy" value="Muon_strip_z+2*Muon_strip_surf+Muon_Iron_gap_z+0.5*Muon_endcap_endcap_z"/> + <constant name="Muon_endcap_endcap_posy" value="0.5*Muon_total_length+0.5*Muon_endcap_endcap_z"/> </define> <detectors> diff --git a/Detector/DetCRD/compact/CRD_common_v01/Muon_Endcap_v01_02.xml b/Detector/DetCRD/compact/CRD_common_v01/Muon_Endcap_v01_02.xml new file mode 100644 index 0000000000000000000000000000000000000000..6cc84482c585fcaba6f76b04a9d8d16f907391bb --- /dev/null +++ b/Detector/DetCRD/compact/CRD_common_v01/Muon_Endcap_v01_02.xml @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8"?> +<lccdd> + + <info name="Muon_Endcap" + title="Test with Two Single Muon Endcap" + author="Zibing Bai" + url="http://cepcgit.ihep.ac.cn" + status="development" + version="v01_02"> + <comment>Test with Two Single Muon Endcap</comment> + </info> + + <define> + <!--Muon Endcap--> + <constant name="Muon_endcap_part_num" value="4"/> + <constant name="Muon_endcap_superlayer_num" value="6"/> + <constant name="Muon_endcap_layer_num" value="2"/> + <constant name="Muon_endcap_strip_num_1" value="72"/> + <constant name="Muon_endcap_strip_num_2" value="128"/> + <constant name="Muon_endcap_strip_num_cut_1" value="17"/> + <constant name="Muon_endcap_strip_num_cut_2" value="74"/> + <constant name="Muon_endcap_endcap_rmin" value="68*cm"/> + <constant name="Muon_endcap_length_cut_1" value="288*cm"/> + <constant name="Muon_endcap_length_cut_gap" value="296*cm"/> + <constant name="Muon_endcap_length_cut_2" value="512*cm"/> + <constant name="Muon_endcap_gap" value="5*cm"/> + + <constant name="Muon_endcap_iron_gap" value="14*cm"/> + <constant name="Muon_endcap_iron_init" value="-60*cm"/> + <constant name="Muon_endcap_endcap_z" value="Muon_standard_scale"/> + <constant name="Muon_endcap_endcap_posy" value="0.5*Muon_total_length+0.5*Muon_endcap_endcap_z"/> + </define> + + <detectors> + <detector id="20211" name="MuonEndcap" type="Muon_Endcap_v01_02" readout="MuonEndcapCollection" vis="GrayVis" material="Iron"> + <material name="Iron"/> + <position x="0" y="Muon_endcap_endcap_posy" z="0"/> + <dimensions rmin="Muon_endcap_endcap_rmin" dz="0.5*Muon_endcap_endcap_z"/> + <stripe id="0" name="Muon_stripe" type="Muon_stripe" vis="GreenVis" material="Air"> + <material name="Air"/> + <dimensions dx="0.5*Muon_strip_x" dy="0.5*Muon_strip_y" dz="0.5*Muon_strip_z+Muon_strip_SiPM_z"/> + <component id="0" type="Muon_strip_surface" name="Muon_strip_surface" vis="GreenVis" material="BC420"> + <position x="0" y="0" z="0"/> + <dimensions dx="0.5*Muon_strip_surface_x" dy="0.5*Muon_strip_surface_y" dz="0.5*Muon_strip_surface_z"/> + <!--cut name="Muon_strip_cut1" vis="GreenVis" material="Air"> + <position x="Muon_strip_cut1_posx" y="Muon_strip_cut1_posy" z="Muon_strip_cut1_posz"/> + <dimensions dx="0.5*Muon_strip_cut1_x" dy="0.5*Muon_strip_cut1_y" dz="0.5*Muon_strip_cut1_z"/> + </cut--> + </component> + <component id="1" type="Muon_strip_scintillator" name="Muon_strip_scintillator" vis="GreenVis" material="BC420"> + <position x="0" y="0" z="0"/> + <dimensions dx="0.5*Muon_strip_scintillator_x" dy="0.5*Muon_strip_scintillator_y" dz="0.5*Muon_strip_scintillator_z"/> + <cut name="Muon_strip_cut3" vis="GreenVis" material="Air"> + <!--position x="Muon_strip_cut3_posx" y="Muon_strip_cut3_posy" z="Muon_strip_cut3_posz"/--> + <position x="0" y="0" z="0"/> + <dimensions rmin="0" rmax="Muon_strip_cut3_rmax" dz="0.5*Muon_strip_cut3_z"/> + <!--comb name="Muon_strip_cut2" vis="GreenVis" material="Air"> + <position x="Muon_strip_cut2_posx" y="Muon_strip_cut2_posy" z="Muon_strip_cut2_posz"/> + <dimensions dx="0.5*Muon_strip_cut2_x" dy="0.5*Muon_strip_cut2_y" dz="0.5*Muon_strip_cut2_z"/> + </comb--> + </cut> + </component> + <fiber id="0" type="Muon_fiber_cladding" name="Muon_fiber_cladding" vis="GreenVis" material="Pethylene1"> + <position x="0" y="0" z="0"/> + <dimensions rmin="Muon_fiber_cladding_rmin" rmax="Muon_fiber_cladding_rmax" dz="0.5*Muon_fiber_cladding_z"/> + </fiber> + <fiber id="1" type="Muon_fiber_core" name="Muon_fiber_core" vis="GreenVis" material="Pethylene2"> + <position x="0" y="0" z="0"/> + <dimensions rmin="0" rmax="Muon_fiber_core_rmax" dz="0.5*Muon_fiber_core_z"/> + </fiber> + <component id="2" type="Muon_strip_SiPM" name="Muon_strip_SiPM" vis="GreenVis" material="Air"> + <position x="Muon_strip_SiPM_posx" y="Muon_strip_SiPM_posy" z="Muon_strip_SiPM_posz"/> + <dimensions dx="0.5*Muon_strip_SiPM_x" dy="0.5*Muon_strip_SiPM_y" dz="0.5*Muon_strip_SiPM_z"/> + </component> + </stripe> + </detector> + </detectors> + + + <readouts> + <readout name="MuonEndcapCollection"> + <id>system:5,Env:5,Endcap:2,Superlayer:15:4,Layer:2,Stripe:9,SiPM:2</id> + <!--id>Endcap:2,Superlayer:2,Env:2,Layer:2,Stripe:10:3,SiPM:2</id--> + </readout> + </readouts> + +</lccdd> diff --git a/Detector/DetCRD/compact/TDR_o1_v01/TDR_Dimensions_v01_01.xml b/Detector/DetCRD/compact/TDR_o1_v01/TDR_Dimensions_v01_01.xml index 9bc5cbbc7e0689e3356326e85583ef2dd48feb43..e6237140bf59455e600afedf6567029f6391b499 100644 --- a/Detector/DetCRD/compact/TDR_o1_v01/TDR_Dimensions_v01_01.xml +++ b/Detector/DetCRD/compact/TDR_o1_v01/TDR_Dimensions_v01_01.xml @@ -206,7 +206,7 @@ <!--strip & fiber dimensions--> <constant name="Muon_strip_x" value="4*cm"/> <constant name="Muon_strip_y" value="1*cm"/> - <constant name="Muon_strip_z" value="4*m"/> + <constant name="Muon_strip_z" value="4.4*m"/> <constant name="Muon_strip_surf" value="1*mm"/> <constant name="Muon_strip_surface_x" value="Muon_strip_x"/> @@ -253,8 +253,8 @@ <constant name="Muon_strip_cut2_posz" value="0"/> <!--standard scale--> - <constant name="Muon_standard_scale" value="105*cm"/> - <constant name="Muon_Iron_gap_z" value="100*cm"/> + <constant name="Muon_standard_scale" value="124*cm"/> + <constant name="Muon_total_length" value="8950*mm"/> <!--Muon Barrel> <constant name="Muon_barrel_barrel_num" value="2"/> diff --git a/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01-onlyMuon.xml b/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01-onlyMuon.xml index ffc849124d9264b633ec80b164f56064947d9dfd..2f602d4aa20aa345999effb948c455a6c178092f 100644 --- a/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01-onlyMuon.xml +++ b/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01-onlyMuon.xml @@ -35,7 +35,7 @@ <!--include ref="../CRD_common_v01/Ecal_Crystal_Barrel_v01_01.xml"/--> <!--include ref="../CRD_common_v01/Ecal_Crystal_Endcap_v01_01.xml"/--> <include ref="../CRD_common_v01/Muon_Endcap_v01_01.xml"/> - <include ref="../CRD_common_v01/Muon_Barrel_v01_01.xml"/> + <include ref="../CRD_common_v01/Muon_Barrel_v01_02.xml"/> <fields> <field name="InnerSolenoid" type="solenoid" diff --git a/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml b/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml index 48b9e4567c27c0c75dcb805aae02a2f857f0d4e5..8d0ca52d5601f1db442f615613d600beaac16d04 100644 --- a/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml +++ b/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml @@ -55,7 +55,7 @@ <!--muon detector--> <include ref="../CRD_common_v01/Muon_Barrel_v01_01.xml"/> - <include ref="../CRD_common_v01/Muon_Endcap_v01_01.xml"/> + <include ref="../CRD_common_v01/Muon_Endcap_v01_02.xml"/> <fields> <field name="InnerSolenoid" type="solenoid" diff --git a/Detector/DetCRD/src/Muon/Muon_Barrel_v01_01.cpp b/Detector/DetCRD/src/Muon/Muon_Barrel_v01_01.cpp index 6515e9769b8a5c39d98955a3012950b11528cecc..90b785921aaac17c46ce057a30d87610154e3862 100644 --- a/Detector/DetCRD/src/Muon/Muon_Barrel_v01_01.cpp +++ b/Detector/DetCRD/src/Muon/Muon_Barrel_v01_01.cpp @@ -44,53 +44,57 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, // dd4hep::Segmentation seg = readout.segmentation(); xml_coll_t dcEnv(x_det,Unicode("barrel")); xml_comp_t x_env = dcEnv; - for(int i0 = 0; i0 < theDetector.constant<int>("Muon_barrel_barrel_num"); i0++) + for(int i0 = 0; i0 < x_env.id(); i0++) { - for(int i1 = 0; i1 < x_env.id(); i1++ ) + std::string env_name = x_env.nameStr() + dd4hep::_toString(i0,"_%d"); + xml_dim_t env_pos(x_env.child(_U(position))); + + xml_coll_t dcFe(x_env,Unicode("iron")); + xml_comp_t x_Fe = dcFe; + std::string Fe_name = x_Fe.nameStr() + dd4hep::_toString(i0,"_%d"); + dd4hep::Material Fe_mat(theDetector.material(x_Fe.materialStr())); + xml_dim_t Fe_pos(x_Fe.child(_U(position))); + xml_dim_t Fe_dim(x_Fe.child(_U(dimensions))); + + double Fe_halfX1 = (theDetector.constant<double>("Muon_barrel_inner_radius") + theDetector.constant<double>("Muon_barrel_iron_z")) / ( 2 + std::sqrt(3) ) - theDetector.constant<double>("Muon_barrel_iron_z"); + double Fe_halfX2 = Fe_halfX1 + theDetector.constant<double>("Muon_barrel_iron_z") * std::sqrt(3); + //double Fe_halfX1 = 0.5 * 459.403*dd4hep::mm; + //double Fe_halfX2 = 0.5 * 4754.889 * dd4hep::mm; + //double Fe_posZ = -1 * theDetector.constant<double>("Muon_barrel_iron_x1") * ( 2.5 + 1.5 * std::sqrt(3) ); + double Fe_posZ = -1 * ( theDetector.constant<double>("Muon_barrel_inner_radius") + 0.5 * theDetector.constant<double>("Muon_barrel_iron_z") ); + dd4hep::Assembly env_vol(env_name); + double env_rot = i0 * 360 * dd4hep::degree / x_env.id(); + dd4hep::Transform3D env_transform(dd4hep::Rotation3D(dd4hep::RotationY(env_rot)),dd4hep::Position(env_pos.x(), 0,env_pos.z())); + + dd4hep::Trd2 Fe_solid(Fe_halfX1,Fe_halfX2,Fe_dim.y1(),Fe_dim.y2(),Fe_dim.dz()); + dd4hep::Volume Fe_vol(Fe_name, Fe_solid, Fe_mat); + Fe_vol.setVisAttributes(theDetector.visAttributes(x_Fe.visStr())); + dd4hep::Transform3D Fe_transform(dd4hep::Rotation3D(),dd4hep::Position(Fe_pos.x(),Fe_pos.y(),Fe_posZ)); + for(int i1 = 0; i1 < theDetector.constant<int>("Muon_barrel_barrel_num"); i1++ ) { - std::string env_name = x_env.nameStr() + dd4hep::_toString(i1,"_%d"); - xml_dim_t env_pos(x_env.child(_U(position))); - - xml_coll_t dcFe(x_env,Unicode("iron")); - xml_comp_t x_Fe = dcFe; - std::string Fe_name = x_Fe.nameStr() + dd4hep::_toString(i1,"_%d"); - dd4hep::Material Fe_mat(theDetector.material(x_Fe.materialStr())); - xml_dim_t Fe_pos(x_Fe.child(_U(position))); - xml_dim_t Fe_dim(x_Fe.child(_U(dimensions))); - - double Fe_halfX2 = theDetector.constant<double>("Muon_barrel_iron_x1") * ( 0.5 + std::sqrt(3)); - //double Fe_posZ = -1 * theDetector.constant<double>("Muon_barrel_iron_x1") * ( 2.5 + 1.5 * std::sqrt(3) ); - double Fe_posZ = -1 * ( theDetector.constant<double>("Muon_barrel_inner_radius") + 0.5 * theDetector.constant<double>("Muon_barrel_iron_z") ); - double env_halfX = 2 * theDetector.constant<double>("Muon_barrel_iron_x1") * ( 1 + std::sqrt(3) ); - double env_halfZ = 2 * theDetector.constant<double>("Muon_barrel_iron_x1") * ( 3 + 1.5 * std::sqrt(3) ); - dd4hep::Assembly env_vol(env_name); - double env_rot = i1 * 360 * dd4hep::degree / x_env.id(); - dd4hep::Transform3D env_transform(dd4hep::Rotation3D(dd4hep::RotationY(env_rot)),dd4hep::Position(env_pos.x(), ( 2 * i0 - 1 ) * env_pos.y(),env_pos.z())); - - dd4hep::Trd2 Fe_solid(Fe_dim.x1(),Fe_halfX2,Fe_dim.y1(),Fe_dim.y2(),Fe_dim.dz()); - dd4hep::Volume Fe_vol(Fe_name, Fe_solid, Fe_mat); - Fe_vol.setVisAttributes(theDetector.visAttributes(x_Fe.visStr())); - dd4hep::Transform3D Fe_transform(dd4hep::Rotation3D(),dd4hep::Position(Fe_pos.x(),Fe_pos.y(),Fe_posZ)); - xml_coll_t dcSuperlayer(x_Fe,Unicode("superlayer")); xml_comp_t x_superlayer = dcSuperlayer; for(int i2 = 0; i2 < x_superlayer.id(); i2++) { - std::string superlayer_name = x_superlayer.nameStr() + dd4hep::_toString(i2,"_%d"); + std::string superlayer_name = x_superlayer.nameStr() + dd4hep::_toString(i1,"_%d") + dd4hep::_toString(i2,"_%d"); std::string num_name = "Muon_barrel_strip_num" + dd4hep::_toString(i2,"_%d"); int strip_num = theDetector.constant<int>(num_name); + int superlayer_posy_num = ( (2 * i1 - 1 ) * (2 * ( i2 % 2 ) - 1 ) + 1 ) / 2; + std::string superlayer_posy_name = "Muon_barrel_strip_num_fixed" + dd4hep::_toString( superlayer_posy_num, "_%d"); + double superlayer_halfX = 0.5 * strip_num * theDetector.constant<double>("Muon_strip_x") + theDetector.constant<double>("Muon_barrel_superlayer_air_gap"); double superlayer_halfY = 0.5 * theDetector.constant<double>("Muon_barrel_superlayer_y"); - double superlayer_halfZ = 0.5 * theDetector.constant<double>("Muon_barrel_superlayer_z"); - + double superlayer_halfZ = 0.5 * theDetector.constant<int>(superlayer_posy_name) * theDetector.constant<double>("Muon_strip_x") + theDetector.constant<double>("Muon_barrel_superlayer_air_gap"); + + double superlayer_posy = ( 2 * i1 - 1 ) * ( 0.5 * theDetector.constant<double>("Muon_total_length") - theDetector.constant<double>("Muon_barrel_superlayer_endcap_gap") - superlayer_halfZ); double superlayer_posZ = i2 * theDetector.constant<double>("Muon_barrel_superlayer_gap") + theDetector.constant<double>("Muon_barrel_superlayer_init"); dd4hep::Material superlayer_mat(theDetector.material(x_superlayer.materialStr())); dd4hep::Box superlayer_solid(superlayer_halfX, superlayer_halfY, superlayer_halfZ); dd4hep::Volume superlayer_vol(superlayer_name, superlayer_solid, superlayer_mat); superlayer_vol.setVisAttributes(theDetector.visAttributes(x_superlayer.visStr())); - dd4hep::Transform3D superlayer_transform(dd4hep::Rotation3D(dd4hep::RotationX(90*dd4hep::degree)),dd4hep::Position(0, 0, superlayer_posZ)); + dd4hep::Transform3D superlayer_transform(dd4hep::Rotation3D(dd4hep::RotationX(90*dd4hep::degree)),dd4hep::Position(0, superlayer_posy, superlayer_posZ)); xml_coll_t dcAl(x_superlayer,Unicode("aluminum")); xml_comp_t x_Al = dcAl; @@ -114,7 +118,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, } if ( i3 == 1 ) { - num = theDetector.constant<int>("Muon_barrel_strip_num"); + num = theDetector.constant<int>(superlayer_posy_name); } for ( int i4 = 0; i4 < num; i4++ ) { @@ -122,7 +126,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, dd4hep::Rotation3D strip_rot; if ( i3 == 0 ) { - strip_halfZ = 0.5 * theDetector.constant<double>("Muon_strip_z") + theDetector.constant<double>("Muon_strip_surf"); + strip_halfZ = 0.5 * theDetector.constant<int>(superlayer_posy_name) * theDetector.constant<double>("Muon_strip_x") + theDetector.constant<double>("Muon_strip_surf"); strip_posX = theDetector.constant<double>("Muon_strip_x") * ( i4 + 0.5 * (1 - strip_num)); strip_posY = 0.5 * theDetector.constant<double>("Muon_strip_y"); strip_posZ = 0; @@ -133,7 +137,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, strip_halfZ = 0.5 * strip_num * theDetector.constant<double>("Muon_strip_x") + theDetector.constant<double>("Muon_strip_surf"); strip_posX = 0; strip_posY = -0.5 * theDetector.constant<double>("Muon_strip_y"); - strip_posZ = theDetector.constant<double>("Muon_strip_x") * ( i4 + 0.5 ) - 0.5 * theDetector.constant<double>("Muon_strip_z"); + strip_posZ = theDetector.constant<double>("Muon_strip_x") * ( i4 + 0.5 ) - 0.5 * theDetector.constant<int>(superlayer_posy_name) * theDetector.constant<double>("Muon_strip_x"); } double surface_halfZ, BC420_halfZ, fiber_halfZ, cut_halfZ; double SiPM_posZ = strip_halfZ - 0.5 * theDetector.constant<double>("Muon_strip_surf"); @@ -253,10 +257,11 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, dd4hep::Volume BC420_vol(BC420_name,BC420_solid,BC420_mat); BC420_vol.setVisAttributes(theDetector.visAttributes(BC420_vis)); + BC420_vol.setSensitiveDetector(sens); dd4hep::Volume SiPM_vol(SiPM_name, SiPM_solid, SiPM_mat); SiPM_vol.setVisAttributes(theDetector.visAttributes(SiPM_vis)); - SiPM_vol.setSensitiveDetector(sens); + //SiPM_vol.setSensitiveDetector(sens); //BC420_vol.placeVolume(cut2_vol,cut2_transform); BC420_vol.placeVolume(cut3_vol,cut3_transform); @@ -291,12 +296,10 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, //BC420_place.addPhysVolID("Stripe",i4+1); dd4hep::PlacedVolume surf_place = strip_vol.placeVolume(surface_vol,surface_transform); //surf_place.addPhysVolID("Layer",i3+1); - //surf_place.addPhysVolID("SiPM",0); + surf_place.addPhysVolID("SiPM",0); dd4hep::PlacedVolume SiPM_place0 = strip_vol.placeVolume(SiPM_vol,SiPM_transform0); - SiPM_place0.addPhysVolID("SiPM",1); dd4hep::PlacedVolume SiPM_place1 = strip_vol.placeVolume(SiPM_vol,SiPM_transform1); - SiPM_place1.addPhysVolID("SiPM",2); dd4hep::PlacedVolume strip_place = Al_vol.placeVolume(strip_vol,strip_transform); strip_place.addPhysVolID("Stripe",i4+1).addPhysVolID("Layer",i3+1); dd4hep::OpticalSurfaceManager surfMgr = theDetector.surfaceManager(); @@ -310,13 +313,13 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, } dd4hep::PlacedVolume Al_place = superlayer_vol.placeVolume(Al_vol,Al_transform); Al_place.addPhysVolID("Superlayer",i2+1); - Fe_vol.placeVolume(superlayer_vol,superlayer_transform); + dd4hep::PlacedVolume Superlayer_place = Fe_vol.placeVolume(superlayer_vol,superlayer_transform); + Superlayer_place.addPhysVolID("Env",i1+1); } - dd4hep::PlacedVolume Fe_place = env_vol.placeVolume(Fe_vol,Fe_transform); - Fe_place.addPhysVolID("Fe",i1+1); - dd4hep::PlacedVolume env_place = envelope.placeVolume(env_vol,env_transform); - env_place.addPhysVolID("Env",i0+1); } + dd4hep::PlacedVolume Fe_place = env_vol.placeVolume(Fe_vol,Fe_transform); + Fe_place.addPhysVolID("Fe",i0+1); + envelope.placeVolume(env_vol,env_transform); } dd4hep::Transform3D pv(dd4hep::Rotation3D(dd4hep::RotationX(90*dd4hep::degree)),dd4hep::Position(0,0,0)); dd4hep::PlacedVolume phv = motherVol.placeVolume(envelope,pv); diff --git a/Detector/DetCRD/src/Muon/Muon_Endcap_v01_01.cpp b/Detector/DetCRD/src/Muon/Muon_Endcap_v01_01.cpp index 7631b5377206d63f0570a6ddb41702b224791eb7..2cac3e049dcf5590549dde5e91004d58bb88402a 100644 --- a/Detector/DetCRD/src/Muon/Muon_Endcap_v01_01.cpp +++ b/Detector/DetCRD/src/Muon/Muon_Endcap_v01_01.cpp @@ -278,8 +278,8 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, superlayer_place.addPhysVolID("Superlayer",i+1); } dd4hep::PlacedVolume pv; - dd4hep::DetElement both_endcaps(det_name,2000); - dd4hep::Volume motherVol = theDetector.pickMotherVolume(both_endcaps); + dd4hep::DetElement both_endcap(det_name,2000); + dd4hep::Volume motherVol = theDetector.pickMotherVolume(both_endcap); dd4hep::DetElement sdetA = sdet; dd4hep::Ref_t(sdetA)->SetName((det_name+"_A").c_str()); dd4hep::DetElement sdetB = sdet.clone(det_name+"_B",2002); @@ -295,12 +295,12 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, pv = motherVol.placeVolume(assembly); pv.addPhysVolID("system",x_det.id()); - both_endcaps.setPlacement(pv); - both_endcaps.add(sdetA); - both_endcaps.add(sdetB); + both_endcap.setPlacement(pv); + both_endcap.add(sdetA); + both_endcap.add(sdetB); MYDEBUG("create_detector DONE. "); - return both_endcaps; + return both_endcap; } DECLARE_DETELEMENT(Muon_Endcap_v01_01, create_detector) diff --git a/Detector/DetCRD/src/Muon/Muon_Endcap_v01_02.cpp b/Detector/DetCRD/src/Muon/Muon_Endcap_v01_02.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8639d3157b2148c604d2ab6942548bdaeee972c5 --- /dev/null +++ b/Detector/DetCRD/src/Muon/Muon_Endcap_v01_02.cpp @@ -0,0 +1,497 @@ +//==================================================================== +// Detector description implementation for Chunxiu Liu's EcalMatrix +//-------------------------------------------------------------------- +// +// Author : Tao Lin +// Examples from lcgeo +// lcgeo/detector/calorimeter/ +// +//==================================================================== +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/OpticalSurfaces.h" +#include "XML/Utilities.h" +#include "DDRec/DetectorData.h" +#include "DDSegmentation/Segmentation.h" +#include <cmath> + +#define MYDEBUG(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << x << std::endl; +#define MYDEBUGVAL(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << #x << ": " << x << std::endl; + +using dd4hep::rec::LayeredCalorimeterData; +static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, + xml_h e, + dd4hep::SensitiveDetector sens) { + + xml_det_t x_det = e; + + std::string det_name = x_det.nameStr(); + std::string det_type = x_det.typeStr(); + MYDEBUGVAL(det_name); + MYDEBUGVAL(det_type); + xml_dim_t pos (x_det.child(_U(position))); + xml_dim_t dim (x_det.child(_U(dimensions))); + + double env_rmax = theDetector.constant<double>("Muon_standard_scale") * std::sqrt( ( 1.5 * 1.5 + ( 3 + 1.5 * std::sqrt(3) ) * ( 3 + 1.5 * std::sqrt(3) ) ) ); + + double r1 = theDetector.constant<double>("Muon_endcap_length_cut_1"); + double r2 = theDetector.constant<double>("Muon_endcap_length_cut_2"); + double r_gap = theDetector.constant<double>("Muon_endcap_length_cut_gap"); + double gap = theDetector.constant<double>("Muon_endcap_gap"); + + dd4hep::Material det_mat(theDetector.material(x_det.materialStr())); + + dd4hep::Assembly assembly(det_name); + + dd4hep::DetElement sdet("envelope", 1); + + dd4hep::Volume envelope( "Muon_endcap_envelope", dd4hep::Tube( dim.rmin(), env_rmax, dim.dz() ), det_mat); + envelope.setVisAttributes(theDetector.visAttributes(x_det.visStr())); + + sens.setType("muonendcap"); + +// dd4hep::Readout readout = sens.readout(); +// dd4hep::Segmentation seg = readout.segmentation(); + for (int i = 0; i < theDetector.constant<int>("Muon_endcap_superlayer_num"); i++) + { + std::string superlayer_name = "superlayer_1" + dd4hep::_toString(i,"_%d"); + dd4hep::Assembly superlayer_vol(superlayer_name); + dd4hep::Transform3D superlayer_transform(dd4hep::Rotation3D(),dd4hep::Position(0,0,theDetector.constant<double>("Muon_endcap_iron_init") + theDetector.constant<double>("Muon_endcap_iron_gap") * ( i + 1 ) + theDetector.constant<double>("Muon_strip_y") * ( i + 0.5 ))); + for (int i0 = 0; i0 < theDetector.constant<int>("Muon_endcap_part_num"); i0++) + { + std::string env_name = "part_1" + dd4hep::_toString(i0,"_%d"); + int test1 = (i0+1) / 3; + int test2 = (i0+1) / 2; + int test3 = 1 - 2 * test1; + int test4 = 2 * ( test2 - 1 ) * ( test2 - 1 ) - 1; + //dd4hep::Tube env_solid( dim.rmin(), theDetector.constant<double>( "Muon_endcap_magnification" ) * env_rmax, dim.dz(), 0, 90 * dd4hep::degree); + //dd4hep::Volume env_vol( env_name, env_solid, det_mat); + //env_vol.setVisAttributes(theDetector.visAttributes(x_det.visStr())); + dd4hep::Assembly env_vol( env_name ); + dd4hep::Transform3D env_transform(dd4hep::Rotation3D(dd4hep::RotationZ(i0 * 90 * dd4hep::degree)),dd4hep::Position(test4 * gap,test3 * gap,0)); + for (int i1 = 0; i1 < theDetector.constant<int>("Muon_endcap_layer_num"); i1++ ) + { + for ( int i2 = 0; i2 < theDetector.constant<int>("Muon_endcap_strip_num_1"); i2++) + { + double strip_posX, strip_posY, strip_posZ; + double strip_sizeZ, surface_halfZ, BC420_halfZ, fiber_halfZ, cut_halfZ; + dd4hep::Rotation3D strip_rot; + if ( i1 == 1 ) + { + strip_rot = dd4hep::Rotation3D( dd4hep::RotationX( 90 * dd4hep::degree ) ); + strip_posX = theDetector.constant<double>("Muon_strip_x") * ( i2 + 0.5 ); + strip_posZ = 0.5 * ( 1 - 2 * ( i0 % 2 ) ) * theDetector.constant<double>("Muon_strip_y"); + if ( i2 < theDetector.constant<int>("Muon_endcap_strip_num_cut_1") ) + { + strip_sizeZ = std::sqrt( r1 * r1 - i2 * theDetector.constant<double>("Muon_strip_x") * i2 * theDetector.constant<double>("Muon_strip_x") ) - std::sqrt( dim.rmin() * dim.rmin() - i2 * theDetector.constant<double>("Muon_strip_x") * i2 * theDetector.constant<double>("Muon_strip_x") ); + strip_posY = std::sqrt( r1 * r1 - i2 * theDetector.constant<double>("Muon_strip_x") * i2 * theDetector.constant<double>("Muon_strip_x") ) - 0.5 * strip_sizeZ; + } + if ( i2 >= theDetector.constant<int>("Muon_endcap_strip_num_cut_1") ) + { + strip_sizeZ = std::sqrt( r1 * r1 - i2 * theDetector.constant<double>("Muon_strip_x") * i2 * theDetector.constant<double>("Muon_strip_x") ); + strip_posY = 0.5 * strip_sizeZ; + } + } + if ( i1 == 0 ) + { + strip_rot = dd4hep::Rotation3D( dd4hep::RotationX( 90 * dd4hep::degree ) * dd4hep::RotationY( 90 * dd4hep::degree ) ); + strip_posY = theDetector.constant<double>("Muon_strip_x") * ( i2 + 0.5 ); + strip_posZ = 0.5 * ( 2 * ( i0 % 2 ) - 1 ) * theDetector.constant<double>("Muon_strip_y"); + if ( i2 < theDetector.constant<int>("Muon_endcap_strip_num_cut_1") ) + { + strip_sizeZ = std::sqrt( r1 * r1 - i2 * theDetector.constant<double>("Muon_strip_x") * i2 * theDetector.constant<double>("Muon_strip_x") ) - std::sqrt( dim.rmin() * dim.rmin() - i2 * theDetector.constant<double>("Muon_strip_x") * i2 * theDetector.constant<double>("Muon_strip_x") ); + strip_posX = std::sqrt( r1 * r1 - i2 * theDetector.constant<double>("Muon_strip_x") * i2 * theDetector.constant<double>("Muon_strip_x") ) - 0.5 * strip_sizeZ; + } + if ( i2 >= theDetector.constant<int>("Muon_endcap_strip_num_cut_1") ) + { + strip_sizeZ = std::sqrt( r1 * r1 - i2 * theDetector.constant<double>("Muon_strip_x") * i2 * theDetector.constant<double>("Muon_strip_x") ); + strip_posX = 0.5 * strip_sizeZ; + } + } + double strip_halfZ = 0.5 * strip_sizeZ; + double SiPM_posZ = strip_halfZ - 0.5 * theDetector.constant<double>("Muon_strip_surf"); + surface_halfZ = BC420_halfZ = fiber_halfZ = cut_halfZ = strip_halfZ - theDetector.constant<double>("Muon_strip_surf"); + xml_coll_t dcStrip(x_det,Unicode("stripe")); + xml_comp_t x_strip = dcStrip; + std::string strip_name = x_strip.nameStr() + dd4hep::_toString(1,"_%d") + dd4hep::_toString(i,"_%d") + dd4hep::_toString(i0,"_%d") + dd4hep::_toString(i1,"_%d") + dd4hep::_toString(i2,"_%d"); + dd4hep::Material strip_mat(theDetector.material(x_strip.materialStr())); + xml_dim_t strip_dim(x_strip.child(_U(dimensions))); + + dd4hep::Box strip_solid(strip_dim.dx(),strip_dim.dy(),strip_halfZ); + dd4hep::Volume strip_vol(strip_name,strip_solid,strip_mat); + strip_vol.setVisAttributes(theDetector.visAttributes(x_strip.visStr())); + dd4hep::Transform3D strip_transform(strip_rot,dd4hep::Position(strip_posX,strip_posY,strip_posZ)); + + std::string surface_name, BC420_name, cut1_name, cut2_name, cut3_name, SiPM_name; + std::string surface_vis, BC420_vis, cut1_vis, cut2_vis, cut3_vis, SiPM_vis; + dd4hep::Material surface_mat, BC420_mat, cut1_mat, cut2_mat, cut3_mat, SiPM_mat; + xml_dim_t surface_pos, cut1_pos, BC420_pos, cut3_pos, cut2_pos, SiPM_pos; + xml_dim_t surface_dim, cut1_dim, BC420_dim, cut3_dim, cut2_dim, SiPM_dim; + for(xml_coll_t dcModule(x_strip,Unicode("component")); dcModule; dcModule++) + { + xml_comp_t x_module = dcModule; + + xml_dim_t module_pos(x_module.child(_U(position))); + xml_dim_t module_dim(x_module.child(_U(dimensions))); + + dd4hep::Box module_solid(module_dim.dx(),module_dim.dy(),module_dim.dz()); + if(x_module.id()==0) + { + surface_name = x_module.nameStr(); + surface_vis = x_module.visStr(); + surface_mat = theDetector.material(x_module.materialStr()); + xml_dim_t s_pos(x_module.child(_U(position))); + xml_dim_t s_dim(x_module.child(_U(dimensions))); + surface_pos = s_pos; + surface_dim = s_dim; +/* + xml_coll_t dcCut1(x_module,Unicode("cut")); + xml_comp_t x_cut1 = dcCut1; + cut1_name = x_cut1.nameStr(); + cut1_vis = x_cut1.visStr(); + cut1_mat = theDetector.material(x_cut1.materialStr()); + xml_dim_t c1_pos(x_cut1.child(_U(position))); + xml_dim_t c1_dim(x_cut1.child(_U(dimensions))); + cut1_pos = c1_pos; + cut1_dim = c1_dim;*/ + } + if(x_module.id()==1) + { + BC420_name = x_module.nameStr(); + BC420_vis = x_module.visStr(); + BC420_mat = theDetector.material(x_module.materialStr()); + xml_dim_t b_pos(x_module.child(_U(position))); + xml_dim_t b_dim(x_module.child(_U(dimensions))); + BC420_pos = b_pos; + BC420_dim = b_dim; + + xml_coll_t dcCut3(x_module,Unicode("cut")); + xml_comp_t x_cut3 = dcCut3; + cut3_name = x_cut3.nameStr(); + cut3_vis = x_cut3.visStr(); + cut3_mat = theDetector.material(x_cut3.materialStr()); + xml_dim_t c3_pos(x_cut3.child(_U(position))); + xml_dim_t c3_dim(x_cut3.child(_U(dimensions))); + cut3_pos = c3_pos; + cut3_dim = c3_dim; +/* + xml_coll_t dcCut2(x_cut3,Unicode("comb")); + xml_comp_t x_cut2 = dcCut2; + cut2_name = x_cut2.nameStr(); + cut2_vis = x_cut2.visStr(); + cut2_mat = theDetector.material(x_cut2.materialStr()); + xml_dim_t c2_pos(x_cut2.child(_U(position))); + xml_dim_t c2_dim(x_cut2.child(_U(dimensions))); + cut2_pos = c2_pos; + cut2_dim = c2_dim;*/ + } + if(x_module.id()==2) + { + SiPM_name = x_module.nameStr(); + SiPM_vis = x_module.visStr(); + SiPM_mat = theDetector.material(x_module.materialStr()); + xml_dim_t S_pos(x_module.child(_U(position))); + xml_dim_t S_dim(x_module.child(_U(dimensions))); + SiPM_pos = S_pos; + SiPM_dim = S_dim; + } + } + dd4hep::Box surface_solid(surface_dim.dx(),surface_dim.dy(),surface_halfZ); + //dd4hep::Box cut1_solid(cut1_dim.dx(),cut1_dim.dy(),cut_halfZ); + dd4hep::Box BC420_solid(BC420_dim.dx(),BC420_dim.dy(),BC420_halfZ); + dd4hep::Tube cut3_solid(cut3_dim.rmin(),cut3_dim.rmax(),cut_halfZ); + //dd4hep::Box cut2_solid(cut2_dim.dx(),cut2_dim.dy(),cut_halfZ); + dd4hep::Box SiPM_solid(SiPM_dim.dx(),SiPM_dim.dy(),SiPM_dim.dz()); + + dd4hep::Transform3D surface_transform(dd4hep::Rotation3D(),dd4hep::Position(surface_pos.x(),surface_pos.y(),surface_pos.z())); + //dd4hep::Transform3D cut1_transform(dd4hep::Rotation3D(),dd4hep::Position(cut1_pos.x(),cut1_pos.y(),cut1_pos.z())); + dd4hep::Transform3D BC420_transform(dd4hep::Rotation3D(),dd4hep::Position(BC420_pos.x(),BC420_pos.y(),BC420_pos.z())); + //dd4hep::Transform3D cut2_transform(dd4hep::Rotation3D(),dd4hep::Position(cut2_pos.x(),cut2_pos.y(),cut2_pos.z())); + dd4hep::Transform3D cut3_transform(dd4hep::Rotation3D(),dd4hep::Position(cut3_pos.x(),cut3_pos.y(),cut3_pos.z())); + dd4hep::Transform3D SiPM_transform1(dd4hep::Rotation3D(),dd4hep::Position(SiPM_pos.x(),SiPM_pos.y(),SiPM_posZ)); + dd4hep::Transform3D SiPM_transform2(dd4hep::Rotation3D(),dd4hep::Position(SiPM_pos.x(),SiPM_pos.y(), -1 * SiPM_posZ)); + + dd4hep::Volume surface_vol(surface_name, surface_solid, surface_mat); + surface_vol.setVisAttributes(theDetector.visAttributes(surface_vis)); + //surface_vol.setSensitiveDetector(sens); +/* + dd4hep::Volume cut1_vol(cut1_name, cut1_solid, cut1_mat); + cut1_vol.setVisAttributes(theDetector.visAttributes(cut1_vis)); + + dd4hep::Volume cut2_vol(cut2_name, cut2_solid, cut2_mat); + cut2_vol.setVisAttributes(theDetector.visAttributes(cut2_vis)); +*/ + dd4hep::Volume cut3_vol(cut3_name, cut3_solid, cut3_mat); + cut3_vol.setVisAttributes(theDetector.visAttributes(cut3_vis)); + + dd4hep::Volume BC420_vol(BC420_name,BC420_solid,BC420_mat); + BC420_vol.setVisAttributes(theDetector.visAttributes(BC420_vis)); + BC420_vol.setSensitiveDetector(sens); + + dd4hep::Volume SiPM_vol(SiPM_name, SiPM_solid, SiPM_mat); + SiPM_vol.setVisAttributes(theDetector.visAttributes(SiPM_vis)); + //SiPM_vol.setSensitiveDetector(sens); + + //BC420_vol.placeVolume(cut2_vol,cut2_transform); + BC420_vol.placeVolume(cut3_vol,cut3_transform); + dd4hep::PlacedVolume cladding_place, core_place; + for(xml_coll_t dcSection(x_strip,Unicode("fiber")); dcSection; dcSection++) + { + xml_comp_t x_section = dcSection; + std::string section_name = x_section.nameStr(); + dd4hep::Material section_mat = theDetector.material(x_section.materialStr()); + + xml_dim_t section_pos(x_section.child(_U(position))); + xml_dim_t section_dim(x_section.child(_U(dimensions))); + + dd4hep::Tube section_solid(section_dim.rmin(),section_dim.rmax(),fiber_halfZ); + dd4hep::Volume section_vol(section_name,section_solid,section_mat); + section_vol.setVisAttributes(theDetector.visAttributes(x_section.visStr())); + + dd4hep::Transform3D section_transform(dd4hep::Rotation3D(),dd4hep::Position(section_pos.x(),section_pos.y(),section_pos.z())); + if (x_section.id() == 0) + { + cladding_place = cut3_vol.placeVolume(section_vol,section_transform); + //cladding_place = BC420_vol.placeVolume(section_vol,section_transform); + } + if (x_section.id() == 1) + { + core_place = cut3_vol.placeVolume(section_vol,section_transform); + //core_place = BC420_vol.placeVolume(section_vol,section_transform); + } + } + //surface_vol.placeVolume(cut1_vol,cut1_transform); + dd4hep::PlacedVolume BC420_place = surface_vol.placeVolume(BC420_vol,BC420_transform); + //BC420_place.addPhysVolID("Stripe",i2+1); + dd4hep::PlacedVolume surf_place = strip_vol.placeVolume(surface_vol,surface_transform); + int lnum = ( ( 2 * ( i0 % 2 ) - 1 ) * ( 2 * i1 - 1 ) + 1 ) / 2; + //surf_place.addPhysVolID("Layer", lnum+1); + //surf_place.addPhysVolID("SiPM",0); + dd4hep::PlacedVolume SiPM_place1 = strip_vol.placeVolume(SiPM_vol,SiPM_transform1); + SiPM_place1.addPhysVolID("SiPM",1); + dd4hep::PlacedVolume SiPM_place2 = strip_vol.placeVolume(SiPM_vol,SiPM_transform2); + SiPM_place2.addPhysVolID("SiPM",2); + dd4hep::PlacedVolume strip_place = env_vol.placeVolume(strip_vol,strip_transform); + strip_place.addPhysVolID("Stripe", i2+1).addPhysVolID("Layer", lnum+1); + dd4hep::OpticalSurfaceManager surfMgr = theDetector.surfaceManager(); + std::string optical_surf = strip_name + "_surf"; + std::string optical_fiber = strip_name + "_fiber"; + dd4hep::OpticalSurface Surf_stripe = surfMgr.opticalSurface("Muon_surf_stripe"); + dd4hep::OpticalSurface Surf_fiber = surfMgr.opticalSurface("Muon_surf_fiber"); + dd4hep::BorderSurface surface_stripe( theDetector, sdet, optical_surf, Surf_stripe, BC420_place, surf_place); + dd4hep::BorderSurface surface_fiber( theDetector, sdet, optical_fiber, Surf_fiber, core_place, cladding_place); + } + for ( int i3 = 0; i3 < theDetector.constant<int>("Muon_endcap_strip_num_2"); i3++ ) + { + double strip_posX, strip_posY, strip_posZ; + double strip_sizeZ, surface_halfZ, BC420_halfZ, fiber_halfZ, cut_halfZ; + dd4hep::Rotation3D strip_rot; + if ( i1 == 1 ) + { + strip_rot = dd4hep::Rotation3D( dd4hep::RotationX( 90 * dd4hep::degree ) ); + strip_posX = theDetector.constant<double>("Muon_strip_x") * ( i3 + 0.5 ); + strip_posZ = 0.5 * ( 1 - 2 * ( i0 % 2 ) ) * theDetector.constant<double>("Muon_strip_y"); + if ( i3 < theDetector.constant<int>("Muon_endcap_strip_num_cut_2") ) + { + strip_sizeZ = std::sqrt( r2 * r2 - i3 * theDetector.constant<double>("Muon_strip_x") * i3 * theDetector.constant<double>("Muon_strip_x") ) - std::sqrt( r_gap * r_gap - i3 * theDetector.constant<double>("Muon_strip_x") * i3 * theDetector.constant<double>("Muon_strip_x") ); + strip_posY = std::sqrt( r2 * r2 - i3 * theDetector.constant<double>("Muon_strip_x") * i3 * theDetector.constant<double>("Muon_strip_x") ) - 0.5 * strip_sizeZ; + } + if ( i3 >= theDetector.constant<int>("Muon_endcap_strip_num_cut_2") ) + { + strip_sizeZ = std::sqrt( r2 * r2 - i3 * theDetector.constant<double>("Muon_strip_x") * i3 * theDetector.constant<double>("Muon_strip_x") ); + strip_posY = 0.5 * strip_sizeZ; + } + + } + if ( i1 == 0 ) + { + strip_rot = dd4hep::Rotation3D( dd4hep::RotationX( 90 * dd4hep::degree ) * dd4hep::RotationY( 90 * dd4hep::degree ) ); + strip_posY = theDetector.constant<double>("Muon_strip_x") * ( i3 + 0.5 ); + strip_posZ = 0.5 * ( 2 * ( i0 % 2 ) - 1 ) * theDetector.constant<double>("Muon_strip_y"); + if ( i3 < theDetector.constant<int>("Muon_endcap_strip_num_cut_2") ) + { + strip_sizeZ = std::sqrt( r2 * r2 - i3 * theDetector.constant<double>("Muon_strip_x") * i3 * theDetector.constant<double>("Muon_strip_x") ) - std::sqrt( r_gap * r_gap - i3 * theDetector.constant<double>("Muon_strip_x") * i3 * theDetector.constant<double>("Muon_strip_x") ); + strip_posX = std::sqrt( r2 * r2 - i3 * theDetector.constant<double>("Muon_strip_x") * i3 * theDetector.constant<double>("Muon_strip_x") ) - 0.5 * strip_sizeZ; + } + if ( i3 >= theDetector.constant<int>("Muon_endcap_strip_num_cut_2") ) + { + strip_sizeZ = std::sqrt( r2 * r2 - i3 * theDetector.constant<double>("Muon_strip_x") * i3 * theDetector.constant<double>("Muon_strip_x") ); + strip_posX = 0.5 * strip_sizeZ; + } + + } + double strip_halfZ = 0.5 * strip_sizeZ; + double SiPM_posZ = strip_halfZ - 0.5 * theDetector.constant<double>("Muon_strip_surf"); + surface_halfZ = BC420_halfZ = fiber_halfZ = cut_halfZ = strip_halfZ - theDetector.constant<double>("Muon_strip_surf"); + xml_coll_t dcStrip(x_det,Unicode("stripe")); + xml_comp_t x_strip = dcStrip; + std::string strip_name = x_strip.nameStr() + dd4hep::_toString(2,"_%d") + dd4hep::_toString(i,"_%d") + dd4hep::_toString(i0,"_%d") + dd4hep::_toString(i1,"_%d") + dd4hep::_toString(i3,"_%d"); + dd4hep::Material strip_mat(theDetector.material(x_strip.materialStr())); + xml_dim_t strip_dim(x_strip.child(_U(dimensions))); + + dd4hep::Box strip_solid(strip_dim.dx(),strip_dim.dy(),strip_halfZ); + dd4hep::Volume strip_vol(strip_name,strip_solid,strip_mat); + strip_vol.setVisAttributes(theDetector.visAttributes(x_strip.visStr())); + dd4hep::Transform3D strip_transform(strip_rot,dd4hep::Position(strip_posX,strip_posY,strip_posZ)); + + std::string surface_name, BC420_name, cut1_name, cut2_name, cut3_name, SiPM_name; + std::string surface_vis, BC420_vis, cut1_vis, cut2_vis, cut3_vis, SiPM_vis; + dd4hep::Material surface_mat, BC420_mat, cut1_mat, cut2_mat, cut3_mat, SiPM_mat; + xml_dim_t surface_pos, cut1_pos, BC420_pos, cut3_pos, cut2_pos, SiPM_pos; + xml_dim_t surface_dim, cut1_dim, BC420_dim, cut3_dim, cut2_dim, SiPM_dim; + for(xml_coll_t dcModule(x_strip,Unicode("component")); dcModule; dcModule++) + { + xml_comp_t x_module = dcModule; + + xml_dim_t module_pos(x_module.child(_U(position))); + xml_dim_t module_dim(x_module.child(_U(dimensions))); + + dd4hep::Box module_solid(module_dim.dx(),module_dim.dy(),module_dim.dz()); + if(x_module.id()==0) + { + surface_name = x_module.nameStr(); + surface_vis = x_module.visStr(); + surface_mat = theDetector.material(x_module.materialStr()); + xml_dim_t s_pos(x_module.child(_U(position))); + xml_dim_t s_dim(x_module.child(_U(dimensions))); + surface_pos = s_pos; + surface_dim = s_dim; + + } + if(x_module.id()==1) + { + BC420_name = x_module.nameStr(); + BC420_vis = x_module.visStr(); + BC420_mat = theDetector.material(x_module.materialStr()); + xml_dim_t b_pos(x_module.child(_U(position))); + xml_dim_t b_dim(x_module.child(_U(dimensions))); + BC420_pos = b_pos; + BC420_dim = b_dim; + + xml_coll_t dcCut3(x_module,Unicode("cut")); + xml_comp_t x_cut3 = dcCut3; + cut3_name = x_cut3.nameStr(); + cut3_vis = x_cut3.visStr(); + cut3_mat = theDetector.material(x_cut3.materialStr()); + xml_dim_t c3_pos(x_cut3.child(_U(position))); + xml_dim_t c3_dim(x_cut3.child(_U(dimensions))); + cut3_pos = c3_pos; + cut3_dim = c3_dim; + + } + if(x_module.id()==2) + { + SiPM_name = x_module.nameStr(); + SiPM_vis = x_module.visStr(); + SiPM_mat = theDetector.material(x_module.materialStr()); + xml_dim_t S_pos(x_module.child(_U(position))); + xml_dim_t S_dim(x_module.child(_U(dimensions))); + SiPM_pos = S_pos; + SiPM_dim = S_dim; + } + } + dd4hep::Box surface_solid(surface_dim.dx(),surface_dim.dy(),surface_halfZ); + dd4hep::Box BC420_solid(BC420_dim.dx(),BC420_dim.dy(),BC420_halfZ); + dd4hep::Tube cut3_solid(cut3_dim.rmin(),cut3_dim.rmax(),cut_halfZ); + dd4hep::Box SiPM_solid(SiPM_dim.dx(),SiPM_dim.dy(),SiPM_dim.dz()); + + dd4hep::Transform3D surface_transform(dd4hep::Rotation3D(),dd4hep::Position(surface_pos.x(),surface_pos.y(),surface_pos.z())); + dd4hep::Transform3D BC420_transform(dd4hep::Rotation3D(),dd4hep::Position(BC420_pos.x(),BC420_pos.y(),BC420_pos.z())); + dd4hep::Transform3D cut3_transform(dd4hep::Rotation3D(),dd4hep::Position(cut3_pos.x(),cut3_pos.y(),cut3_pos.z())); + dd4hep::Transform3D SiPM_transform1(dd4hep::Rotation3D(),dd4hep::Position(SiPM_pos.x(),SiPM_pos.y(),SiPM_posZ)); + dd4hep::Transform3D SiPM_transform2(dd4hep::Rotation3D(),dd4hep::Position(SiPM_pos.x(),SiPM_pos.y(), -1 * SiPM_posZ)); + + dd4hep::Volume surface_vol(surface_name, surface_solid, surface_mat); + surface_vol.setVisAttributes(theDetector.visAttributes(surface_vis)); + + dd4hep::Volume cut3_vol(cut3_name, cut3_solid, cut3_mat); + cut3_vol.setVisAttributes(theDetector.visAttributes(cut3_vis)); + + dd4hep::Volume BC420_vol(BC420_name,BC420_solid,BC420_mat); + BC420_vol.setVisAttributes(theDetector.visAttributes(BC420_vis)); + BC420_vol.setSensitiveDetector(sens); + + dd4hep::Volume SiPM_vol(SiPM_name, SiPM_solid, SiPM_mat); + SiPM_vol.setVisAttributes(theDetector.visAttributes(SiPM_vis)); + //SiPM_vol.setSensitiveDetector(sens); + + BC420_vol.placeVolume(cut3_vol,cut3_transform); + dd4hep::PlacedVolume cladding_place, core_place; + for(xml_coll_t dcSection(x_strip,Unicode("fiber")); dcSection; dcSection++) + { + xml_comp_t x_section = dcSection; + std::string section_name = x_section.nameStr(); + dd4hep::Material section_mat = theDetector.material(x_section.materialStr()); + + xml_dim_t section_pos(x_section.child(_U(position))); + xml_dim_t section_dim(x_section.child(_U(dimensions))); + + dd4hep::Tube section_solid(section_dim.rmin(),section_dim.rmax(),fiber_halfZ); + dd4hep::Volume section_vol(section_name,section_solid,section_mat); + section_vol.setVisAttributes(theDetector.visAttributes(x_section.visStr())); + + dd4hep::Transform3D section_transform(dd4hep::Rotation3D(),dd4hep::Position(section_pos.x(),section_pos.y(),section_pos.z())); + if (x_section.id() == 0) + { + cladding_place = cut3_vol.placeVolume(section_vol,section_transform); + + } + if (x_section.id() == 1) + { + core_place = cut3_vol.placeVolume(section_vol,section_transform); + + } + } + + dd4hep::PlacedVolume BC420_place = surface_vol.placeVolume(BC420_vol,BC420_transform); + + dd4hep::PlacedVolume surf_place = strip_vol.placeVolume(surface_vol,surface_transform); + int lnum = ( ( 2 * ( i0 % 2 ) - 1 ) * ( 2 * i1 - 1 ) + 1 ) / 2; + + dd4hep::PlacedVolume SiPM_place1 = strip_vol.placeVolume(SiPM_vol,SiPM_transform1); + // SiPM_place1.addPhysVolID("SiPM",1); + dd4hep::PlacedVolume SiPM_place2 = strip_vol.placeVolume(SiPM_vol,SiPM_transform2); + // SiPM_place2.addPhysVolID("SiPM",2); + dd4hep::PlacedVolume strip_place = env_vol.placeVolume(strip_vol,strip_transform); + strip_place.addPhysVolID("Stripe", theDetector.constant<int>("Muon_endcap_strip_num_1")+i3+1).addPhysVolID("Layer", lnum+1); + dd4hep::OpticalSurfaceManager surfMgr = theDetector.surfaceManager(); + std::string optical_surf = strip_name + "_surf"; + std::string optical_fiber = strip_name + "_fiber"; + dd4hep::OpticalSurface Surf_stripe = surfMgr.opticalSurface("Muon_surf_stripe"); + dd4hep::OpticalSurface Surf_fiber = surfMgr.opticalSurface("Muon_surf_fiber"); + dd4hep::BorderSurface surface_stripe( theDetector, sdet, optical_surf, Surf_stripe, BC420_place, surf_place); + dd4hep::BorderSurface surface_fiber( theDetector, sdet, optical_fiber, Surf_fiber, core_place, cladding_place); + } + } + dd4hep::PlacedVolume env_place = superlayer_vol.placeVolume(env_vol,env_transform); + env_place.addPhysVolID("Env",i0+1); + } + dd4hep::PlacedVolume superlayer_place = envelope.placeVolume(superlayer_vol,superlayer_transform); + superlayer_place.addPhysVolID("Superlayer",i+1); + } + dd4hep::PlacedVolume pv; + dd4hep::DetElement both_endcap(det_name,2000); + dd4hep::Volume motherVol = theDetector.pickMotherVolume(both_endcap); + dd4hep::DetElement sdetA = sdet; + dd4hep::Ref_t(sdetA)->SetName((det_name+"_A").c_str()); + dd4hep::DetElement sdetB = sdet.clone(det_name+"_B",2002); + pv = assembly.placeVolume(envelope,dd4hep::Transform3D(dd4hep::Rotation3D(dd4hep::RotationZ(90*dd4hep::degree)),dd4hep::Position(0,0,pos.y()))); + pv.addPhysVolID("Endcap",1); + + sdetA.setPlacement(pv); + + pv = assembly.placeVolume(envelope,dd4hep::Transform3D(dd4hep::Rotation3D(dd4hep::RotationZ(90*dd4hep::degree) * dd4hep::RotationY(180*dd4hep::degree)),dd4hep::Position(0,0,-1 * pos.y()))); + pv.addPhysVolID("Endcap",2); + + sdetB.setPlacement(pv); + + pv = motherVol.placeVolume(assembly); + pv.addPhysVolID("system",x_det.id()); + both_endcap.setPlacement(pv); + both_endcap.add(sdetA); + both_endcap.add(sdetB); + + MYDEBUG("create_detector DONE. "); + return both_endcap; +} + +DECLARE_DETELEMENT(Muon_Endcap_v01_02, create_detector) diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp index ade2b4a5597d1e6815f20e9701c9642c1f9b0b1b..76abc3debf126d30058108f51c1548a2921deef3 100644 --- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp +++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp @@ -137,8 +137,8 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) { auto muonbarrelcol = m_MuonBarrelCol.createAndPut(); auto muonbarrelcontribcols = m_MuonBarrelContributionCol.createAndPut(); - auto muonendcapscol = m_MuonEndcapsCol.createAndPut(); - auto muonendcapscontribcols = m_MuonEndcapsContributionCol.createAndPut(); + auto muonendcapcol = m_MuonEndcapCol.createAndPut(); + auto muonendcapcontribcols = m_MuonEndcapContributionCol.createAndPut(); auto driftchamberhitscol = m_DriftChamberHitsCol.createAndPut(); @@ -221,11 +221,11 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) { } else if (collect->GetName() == "COILCollection") { tracker_col_ptr = coilcols; } else if (collect->GetName() == "MuonBarrelCollection") { - calo_col_ptr = muonbarrelcol; + tracker_col_ptr = muonbarrelcol; calo_contrib_col_ptr = muonbarrelcontribcols; - } else if (collect->GetName() == "MuonEndcapsCollection") { - calo_col_ptr = muonendcapscol; - calo_contrib_col_ptr = muonendcapscontribcols; + } else if (collect->GetName() == "MuonEndcapCollection") { + tracker_col_ptr = muonendcapcol; + calo_contrib_col_ptr = muonendcapcontribcols; } else if (collect->GetName() == "DriftChamberHitsCollection") { tracker_col_ptr = driftchamberhitscol; } else { diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h index cfc0839470e4e89b135a96111458bf51fb1d9634..c4e5bce57a7dd1d969a2688b2a682121744d047b 100644 --- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h +++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h @@ -121,15 +121,15 @@ private: Gaudi::DataHandle::Writer, this}; // Muon - DataHandle<edm4hep::SimCalorimeterHitCollection> m_MuonBarrelCol{"MuonBarrelCollection", + DataHandle<edm4hep::SimTrackerHitCollection> m_MuonBarrelCol{"MuonBarrelCollection", Gaudi::DataHandle::Writer, this}; DataHandle<edm4hep::CaloHitContributionCollection> m_MuonBarrelContributionCol{ "MuonBarrelContributionCollection", Gaudi::DataHandle::Writer, this}; - DataHandle<edm4hep::SimCalorimeterHitCollection> m_MuonEndcapsCol{"MuonEndcapsCollection", + DataHandle<edm4hep::SimTrackerHitCollection> m_MuonEndcapCol{"MuonEndcapCollection", Gaudi::DataHandle::Writer, this}; - DataHandle<edm4hep::CaloHitContributionCollection> m_MuonEndcapsContributionCol{ - "MuonEndcapsContributionCollection", + DataHandle<edm4hep::CaloHitContributionCollection> m_MuonEndcapContributionCol{ + "MuonEndcapContributionCollection", Gaudi::DataHandle::Writer, this}; // Drift Chamber diff --git a/Simulation/DetSimSD/src/MuonBarrelSensitiveDetector.cpp b/Simulation/DetSimSD/src/MuonBarrelSensitiveDetector.cpp index b386d132d15a534d6f7e4f167b94173df13592ad..0c57f1ddf470be331c04031bc88ab8f20143eee1 100644 --- a/Simulation/DetSimSD/src/MuonBarrelSensitiveDetector.cpp +++ b/Simulation/DetSimSD/src/MuonBarrelSensitiveDetector.cpp @@ -24,31 +24,16 @@ void MuonBarrelSensitiveDetector::Initialize(G4HCofThisEvent* HCE){ G4bool MuonBarrelSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*){ G4TouchableHandle touchPost = step->GetPostStepPoint()->GetTouchableHandle(); - G4TouchableHandle touchPre = step->GetPreStepPoint()->GetTouchableHandle(); - auto currentTrack = step->GetTrack(); - auto pname = currentTrack->GetParticleDefinition()->GetParticleName(); - auto touchable = step->GetPreStepPoint()->GetTouchable(); - auto physical = touchable->GetVolume(); -/* if ( physical->GetName() == "surface" ) - { - if ( pname == "opticalphoton" ) - { - G4double random = G4UniformRand(); - if(random < 0.1) - { - currentTrack->SetTrackStatus(fStopAndKill); - } - } - } */ + G4TouchableHandle touchPre = step->GetPreStepPoint()->GetTouchableHandle(); dd4hep::sim::Geant4StepHandler h(step); - if (fabs(h.trackDef()->GetPDGCharge()) < 0.01) return true; + //if (fabs(h.trackDef()->GetPDGCharge()) < 0.01) return true; dd4hep::Position prePos = h.prePos(); dd4hep::Position postPos = h.postPos(); dd4hep::Position direction = postPos - prePos; dd4hep::Position position = mean_direction(prePos,postPos); double hit_len = direction.R(); - if (hit_len < 1E-9) return true; + //if (hit_len < 1E-9) return true; if (hit_len > 0) { double new_len = mean_length(h.preMom(),h.postMom())/hit_len; direction *= new_len/hit_len; @@ -67,10 +52,6 @@ G4bool MuonBarrelSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory hit->momentum = direction; hit->length = hit_len; m_hc->insert(hit); - if ( physical->GetName() == "SiPM" ) - { - currentTrack->SetTrackStatus(fStopAndKill); - } return true; } throw std::runtime_error("new() failed: Cannot allocate hit object"); diff --git a/Simulation/DetSimSD/src/MuonEndcapSensitiveDetector.cpp b/Simulation/DetSimSD/src/MuonEndcapSensitiveDetector.cpp index 03904cc875f75b9d593a8e9830a4a750e33a8d61..fa6d0e7bdf8fb2fde13cedca3fc03cb132e4b7fa 100644 --- a/Simulation/DetSimSD/src/MuonEndcapSensitiveDetector.cpp +++ b/Simulation/DetSimSD/src/MuonEndcapSensitiveDetector.cpp @@ -7,6 +7,7 @@ //#include "UserTrackInformation.hh" #include "DD4hep/DD4hepUnits.h" + MuonEndcapSensitiveDetector::MuonEndcapSensitiveDetector(const std::string& name, dd4hep::Detector& description) : DDG4SensitiveDetector(name, description), @@ -24,31 +25,16 @@ void MuonEndcapSensitiveDetector::Initialize(G4HCofThisEvent* HCE){ G4bool MuonEndcapSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*){ G4TouchableHandle touchPost = step->GetPostStepPoint()->GetTouchableHandle(); - G4TouchableHandle touchPre = step->GetPreStepPoint()->GetTouchableHandle(); - auto currentTrack = step->GetTrack(); - auto pname = currentTrack->GetParticleDefinition()->GetParticleName(); - auto touchable = step->GetPreStepPoint()->GetTouchable(); - auto physical = touchable->GetVolume(); -/* if ( physical->GetName() == "surface" ) - { - if ( pname == "opticalphoton" ) - { - G4double random = G4UniformRand(); - if(random < 0.1) - { - currentTrack->SetTrackStatus(fStopAndKill); - } - } - }*/ + G4TouchableHandle touchPre = step->GetPreStepPoint()->GetTouchableHandle(); dd4hep::sim::Geant4StepHandler h(step); - if (fabs(h.trackDef()->GetPDGCharge()) < 0.01) return true; + //if (fabs(h.trackDef()->GetPDGCharge()) < 0.01) return true; dd4hep::Position prePos = h.prePos(); dd4hep::Position postPos = h.postPos(); dd4hep::Position direction = postPos - prePos; dd4hep::Position position = mean_direction(prePos,postPos); double hit_len = direction.R(); - if (hit_len < 1E-9) return true; + //if (hit_len < 1E-9) return true; if (hit_len > 0) { double new_len = mean_length(h.preMom(),h.postMom())/hit_len; direction *= new_len/hit_len; @@ -67,10 +53,6 @@ G4bool MuonEndcapSensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory hit->momentum = direction; hit->length = hit_len; m_hc->insert(hit); - if ( physical->GetName() == "SiPM" ) - { - currentTrack->SetTrackStatus(fStopAndKill); - } return true; } throw std::runtime_error("new() failed: Cannot allocate hit object");