diff --git a/Detector/DetCRD/CMakeLists.txt b/Detector/DetCRD/CMakeLists.txt index de22c5023717faaafc4938d5bc6876b780cf8261..f735b3d189c294a1307da7795f063988c104523f 100644 --- a/Detector/DetCRD/CMakeLists.txt +++ b/Detector/DetCRD/CMakeLists.txt @@ -17,6 +17,7 @@ find_package(ROOT COMPONENTS MathCore GenVector Geom REQUIRED) gaudi_add_module(DetCRD SOURCES src/Calorimeter/CRDEcal_v01.cpp + src/Calorimeter/LongCrystalBarBarrelCalorimeter32Polygon_v01.cpp src/Calorimeter/RotatedPolyhedraBarrelCalorimeter_v01_geo.cpp src/Calorimeter/RotatedCrystalCalorimeter_v01_geo.cpp src/Other/CRDBeamPipe_v01_geo.cpp diff --git a/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Barrel_v01_02.xml b/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Barrel_v01_02.xml new file mode 100755 index 0000000000000000000000000000000000000000..e969095d19972baaa03cde91e773c9d77f8eee3f --- /dev/null +++ b/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Barrel_v01_02.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<lccdd> + <define> + <constant name="ecalbarrel_inner_radius" value="Ecal_barrel_inner_radius"/> + <constant name="ecalbarrel_outer_radius" value="Ecal_barrel_outer_radius"/> + <constant name="ecalbarrel_zlength" value="Ecal_barrel_half_length*2"/> + + <constant name="ecalbarrel_layer" value="28" /> + <constant name="ecalbarrel_phimodule_number" value="32" /> + <constant name="ecalbarrel_Zmodule_number" value="15"/> + <constant name="ecalbarrel_module_ratation" value="12.*degree" /> + <constant name="ecalbarrel_width_crystal" value="10.2*mm"/> + + <constant name="ecalbarrel_crystal_wrapping" value="0.1*mm"/> + <constant name="ecalbarrel_length_photoelectronic" value="0.7*mm"/> + <constant name="ecalbarrel_width_photoelectronic" value="3*mm"/> + + <constant name="ecalbarrel_length_carbon" value="5.*mm"/> + <constant name="ecalbarrel_length_cable" value="0.*mm"/> + <constant name="ecalbarrel_length_cooling" value="1.*mm"/> + <constant name="ecalbarrel_length_pcb" value="1.2*mm"/> + <constant name="ecalbarrel_length_asic" value="1.*mm"/> + <constant name="ecalbarrel_length_back" value="10.*mm"/> + + </define> + + <regions> + <region name="EcalBarrelRegion"> + </region> + </regions> + + <detectors> + <detector id="DetID_ECAL" name="CaloDetector" type="LongCrystalBarBarrelCalorimeter32Polygon_v01" readout="EcalBarrelCollection" vis="Invisible" sensitive="true" region="EcalBarrelRegion"> + <!-- Use cm as unit if you want to use Pandora for reconstruction --> + </detector> + </detectors> + + <readouts> + <readout name="EcalBarrelCollection"> + <segmentation type="NoSegmentation"/> + <!--segmentation type="CartesianGridXYZ" + grid_size_x="1*cm" + grid_size_y="1*cm" + grid_size_z="1*cm"/--> + <id>system:5,module:5,stave:4,dlayer:5,slayer:6,bar:15</id> + </readout> + </readouts> + +</lccdd> diff --git a/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Barrel_v04_01.xml b/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Barrel_v04_01.xml new file mode 100644 index 0000000000000000000000000000000000000000..be7ef3f18f86766d19a2b415119563846479ce59 --- /dev/null +++ b/Detector/DetCRD/compact/CRD_common_v01/SHcalGlass_Barrel_v04_01.xml @@ -0,0 +1,85 @@ +<!-- comment>Calorimeters</comment --> + +<lccdd> + <define> + <constant name="Hcal_cell_size" value="40*mm"/> + <constant name="Hcal_inner_radius" value="Hcal_barrel_inner_radius"/> + <constant name="Hcal_half_length" value="Hcal_barrel_half_length"/> + <constant name="Hcal_inner_symmetry" value="Hcal_barrel_symmetry"/> + <constant name="Hcal_nlayers" value="48"/> + <constant name="Hcal_radiator_thickness" value="13.8*mm"/> + <constant name="Hcal_chamber_thickness" value="16.7*mm"/> + <constant name="Hcal_back_plate_thickness" value="0.*mm"/> + <!-- 15. --> + <constant name="Hcal_lateral_structure_thickness" value="10*mm"/> + <!-- only the middle has the steel plate --> + <constant name="Hcal_stave_gaps" value="0*mm"/> + <!-- Break in phi staves --> + <constant name="Hcal_middle_stave_gaps" value="0*mm"/> + <!-- ??? --> + <constant name="Hcal_modules_gap" value="2*mm"/> + <!-- Break size in Z modules --> + <constant name="Hcal_layer_air_gap" value="0*mm"/> + <!-- ??? --> + <!-- <constant name="HcalSD_glass_anode_thickness" value="0.7*mm"/> + <constant name="HcalSD_sensitive_gas_gap" value="1.2*mm"/> + <constant name="HcalSD_glass_cathode_thickness" value="1.1*mm"/> --> + + <constant name="Hcal_scintillator_thickness" value="10.*mm"/> + <constant name="Hcal_pcb_thickness" value="6.5*mm"/> + <constant name="Hcal_esr_thickness" value="0.2*mm"/> + + <constant name="Ecal_outer_radius" value="Ecal_barrel_outer_radius"/> + <!-- <constant name="Hcal_readout_segmentation_slice" value="3"/> --> + </define> + <detectors> + <detector name="HcalBarrel" type="SHcalSc04_Barrel_v04" id="DetID_HCAL" readout="HcalBarrelCollection" vis="CyanVis" insideTrackingVolume="false" > + <comment>Hadron Calorimeter Barrel</comment> + + <envelope vis="CyanVis"> + <shape type="BooleanShape" operation="Subtraction" material="Air" > + <shape type="Cone" rmin1="0.0" rmax1="Hcal_outer_radius + env_safety" rmin2="0.0" rmax2="Hcal_outer_radius + env_safety" z="Hcal_half_length + env_safety/2.0"/> + <shape type="PolyhedraRegular" numsides="Hcal_inner_symmetry" rmin="0.0" + rmax="Hcal_inner_radius - env_safety" dz="2*(Hcal_half_length + env_safety)"/> + </shape> + <rotation x="0" y="0" z="90*deg-180*deg/Hcal_inner_symmetry"/> + </envelope> + + <type_flags type=" DetType_CALORIMETER + DetType_BARREL + DetType_HADRONIC " /> + + <staves material = "Steel235" vis="BlueVis"/> + + + <!-- select which subsegmentation will be used to fill the DDRec:LayeredCalorimeterData cell dimensions --> + <!-- <subsegmentation key="slice" value="Hcal_readout_segmentation_slice"/> --> + + <layer repeat="Hcal_nlayers" vis="CyanVis"> + <!-- <slice material="FloatGlass" thickness="HcalSD_glass_anode_thickness" vis="Invisible"/> + <slice material="RPCGAS2" thickness="HcalSD_sensitive_gas_gap" sensitive="yes" limits="cal_limits" vis="YellowVis"/> + <slice material="FloatGlass" thickness="HcalSD_glass_cathode_thickness" vis="Invisible"/> --> + <!-- <slice material="Air" thickness="Hcal_chamber_thickness - ( HcalSD_glass_anode_thickness + HcalSD_sensitive_gas_gap + HcalSD_glass_cathode_thickness + Hcal_scintillator_thickness)" vis="Invisible" /> --> + <slice material="G4_GlassHCAL" thickness = "Hcal_scintillator_thickness" sensitive = "yes" limits="cal_limits" vis="CyanVis" /> + <slice material="PCB" thickness = "Hcal_pcb_thickness" vis="CyanVis" /> + <slice material="PCB" thickness = "Hcal_esr_thickness" vis="CyanVis" /> + + </layer> + </detector> + </detectors> + + <readouts> + <readout name="HcalBarrelCollection"> + <!-- <segmentation type="MultiSegmentation" key="slice"> + <segmentation name="RPCgrid" type="CartesianGridXY" key_value="1" grid_size_x="Hcal_cell_size" grid_size_y="Hcal_cell_size" /> + <segmentation name="Scigrid" type="TiledLayerGridXY" key_value="3" grid_size_x="Hcal_cell_size" grid_size_y="Hcal_cell_size"/> + </segmentation> + <hits_collections> + <hits_collection name="HCalBarrelRPCHits" key="slice" key_value="1"/> + <hits_collection name="HcalBarrelRegCollection" key="slice" key_value="3"/> + </hits_collections> --> + <segmentation type="TiledLayerGridXY" grid_size_x="Hcal_cell_size" grid_size_y="Hcal_cell_size"/> + <id>system:5,module:3,stave:4,tower:5,layer:6,slice:4,x:32:-16,y:-16</id> + </readout> + </readouts> + + +</lccdd> diff --git a/Detector/DetCRD/compact/CRD_common_v01/TPC_CEPCv4.xml b/Detector/DetCRD/compact/CRD_common_v01/TPC_CEPCv4.xml new file mode 100644 index 0000000000000000000000000000000000000000..75cc684bc9bdd6efb759743c9a470e95fe2a11c1 --- /dev/null +++ b/Detector/DetCRD/compact/CRD_common_v01/TPC_CEPCv4.xml @@ -0,0 +1,95 @@ +<!-- + TPC parameters for ILD_o1_v5 + --> + +<lccdd> + + <detectors> + + <detector name="TPC" type="TPC10" vis="TPCVis" id="DetID_TPC" limits="tracker_limits" readout="TPCCollection" insideTrackingVolume="true"> + + + <envelope vis="ILD_TPCVis"> + <shape type="Tube" rmin="TPC_inner_radius" rmax="TPC_outer_radius" + dz="TPC_half_length" material = "Air" /> + </envelope> + + <type_flags type="DetType_TRACKER + DetType_BARREL + DetType_GASEOUS "/> + + <!-- database : tpc10_01 --> + <!-- SQL command: "SELECT * FROM `global`;" --> + + <!-- ORIGINAL : dr_InnerServiceArea="30*mm" dr_OuterServiceArea="30*mm" DANIEL REDUCED TO FIT THICK ECAL --> + <!-- dr_InnerServiceArea="18.1*mm" dr_OuterServiceArea="18.1*mm" recover to tpc10_01 matching CEPC_v4, by fucd--> + <global TPC_pad_height="6*mm" TPC_pad_width="1*mm" TPC_max_step_length="5*mm" dr_InnerWall="25*mm" + dr_InnerServiceArea="30*mm" dr_OuterServiceArea="30*mm" + dr_OuterWall="60*mm" dz_Cathode="0.06*mm" dz_Readout="25*mm" dz_Endplate="100*mm" + chamber_Gas="TDR_gas" sensitive_threshold_eV="32*eV" /> + + <!-- updates from Dimitra 4/7/17 --> + <!--cathode dz_Cathode_Insulator="0.046*mm" dz_Cathode_Conductor="0.004*mm" material_Cathode_Insulator="G4_KAPTON" + material_Cathode_Conductor="G4_Cu" dr_Cathode_Grip="18*mm" dz_Cathode_Grip="15*mm" material_Cathode_Grip="SiC_foam" /--> + <!-- recover to tpc10_01 matching CEPC_v4, by fucd--> + <cathode dz_Cathode_Insulator="0.0275*mm" dz_Cathode_Conductor="0.0025*mm" material_Cathode_Insulator="G4_KAPTON" + material_Cathode_Conductor="G4_Cu" dr_Cathode_Grip="20*mm" dz_Cathode_Grip="15*mm" material_Cathode_Grip="SiC_foam" /> + + + <!-- SQL command: "SELECT * FROM `innerWall`;" --> + <innerWall> + <!-- updates from Dimitra 4/7/17 --> + <row dr="0.01*mm" material="G4_Al" /> + <row dr="0.05*mm" material="G4_KAPTON" /> + <row dr="0.3*mm" material="g10" /> + <row dr="24.22*mm" material="G4_AIR" /> + <row dr="0.3*mm" material="g10" /> + <row dr="0.05*mm" material="G4_KAPTON" /> + <row dr="0.07*mm" material="G4_Cu" /> + </innerWall> + <!-- SQL command: "SELECT * FROM `outerWall`;" --> + <outerWall> + <!-- updates from Dimitra 4/7/17 --> <!--recover to tpc10_01 matching CEPC_v4, by fucd--> + <row dr="0.07*mm" material="G4_Cu" /> + <row dr="0.05*mm" material="G4_KAPTON" /> + <row dr="0.3*mm" material="g10" /> + <!-- row dr="57.66*mm" material="G4_AIR" / --> + <row dr="59.22*mm" material="G4_AIR" /> <!-- removed 5 mm to accomadate fat ecal: to be finalised when numbers available --> + <row dr="0.3*mm" material="g10" /> + <row dr="0.05*mm" material="G4_KAPTON" /> + <row dr="0.01*mm" material="G4_Al" /> + </outerWall> + <!-- SQL command: "SELECT * FROM `readout`;" --> + <readout> + <row dz="0.003*mm" material="G4_Cu" comment="gating" /> + <row dz="0.03*mm" material="G4_KAPTON" comment="gating" /> + <row dz="0.003*mm" material="G4_Cu" comment="gating" /> + <row dz="4.447*mm" material="TDR_gas" comment="gating" /> + <row dz="0.003*mm" material="G4_Cu" comment="mpgd" /> + <row dz="0.03*mm" material="G4_KAPTON" comment="mpgd" /> + <row dz="0.003*mm" material="G4_Cu" comment="mpgd" /> + <row dz="4.447*mm" material="TDR_gas" comment="mpgd" /> + <row dz="0.003*mm" material="G4_Cu" comment="mpgd" /> + <row dz="0.03*mm" material="G4_KAPTON" comment="mpgd" /> + <row dz="0.003*mm" material="G4_Cu" comment="mpgd" /> + <row dz="4.447*mm" material="TDR_gas" comment="mpgd" /> + <row dz="0.05*mm" material="G4_Cu" comment="pads" /> + <row dz="2*mm" material="g10" comment="structural" /> + <row dz="0.5*mm" material="G4_Si" comment="electronics" /> + <row dz="2*mm" material="epoxy" comment="structural" /> + <row dz="1*mm" material="G4_KAPTON" comment="structural" /> + <row dz="2*mm" material="G4_Al" comment="Cooling" /> + <row dz="1*mm" material="G4_KAPTON" comment="structural" /> + <row dz="3*mm" material="CarbonFiber" comment="structural" /> + </readout> + </detector> + + </detectors> + + <readouts> + <readout name="TPCCollection"> + <id>system:5,side:-2,layer:9,module:8,sensor:8</id> + </readout> + </readouts> + + +</lccdd> + diff --git a/Detector/DetCRD/compact/CRD_common_v01/materials.xml b/Detector/DetCRD/compact/CRD_common_v01/materials.xml index ee48236f87579faa19bdfac3ccd926b583c39094..dfeceea695e5ca9fb92db9b55d9dc534df1cd11d 100644 --- a/Detector/DetCRD/compact/CRD_common_v01/materials.xml +++ b/Detector/DetCRD/compact/CRD_common_v01/materials.xml @@ -384,14 +384,14 @@ <fraction n="1" ref="Al27"/> </element> -<!-- + <!-- <material name="TPC_endplate_mix"> <! D value="1.7" unit="g/cm3"/ > <composite n="74" ref="G4_AIR"/> <composite n="12" ref="g10"/> <composite n="14" ref="G4_Al"/> </material> ---> + --> <material name="TPC_endplate_mix" state="solid"> <MEE unit="eV" value="97.0754229107761"/> @@ -483,7 +483,7 @@ </material> <material name="FloatGlass" > -<!-- <D value="2.44" unit="g/cm3" /> --> + <!-- <D value="2.44" unit="g/cm3" /> --> <D value="2.49" unit="g/cm3" /> <fraction n="0.46645" ref="O"/> <fraction n="0.34125" ref="Si"/> @@ -501,7 +501,7 @@ <material name="Nylon" > <!-- Nylon-6-6 --> -<!-- <MEE unit="eV" value="63.9"/> --> + <!-- <MEE unit="eV" value="63.9"/> --> <D value="1.14" unit="g/cm3" /> <fraction n="0.097976" ref="H"/> <fraction n="0.636856" ref="C"/> @@ -518,7 +518,7 @@ </material> <material name="g10-RPC"> -<!-- <MEE unit="eV" value="114.378463512112"/> --> + <!-- <MEE unit="eV" value="114.378463512112"/> --> <D value="1.80" unit="g/cm3" /> <fraction n="0.07868" ref="C"/> <fraction n="0.46056" ref="O"/> @@ -562,6 +562,39 @@ <fraction n="0.671054" ref="Bi" /> </material> + <material name="G4_GlassHCAL" state="solid"> + <!-- <MEE unit="eV" value="534.1"/> --> + <D value="6." unit="g/cm3" /> + <fraction n="0.0270234" ref="B"/> + <fraction n="0.00700559" ref="Ce" /> + <fraction n="0.0883374" ref="F" /> + <fraction n="0.69186" ref="Gd" /> + <fraction n="0.0181464" ref="Ge" /> + <fraction n="0.153585" ref="O" /> + <fraction n="0.0140419" ref="Si" /> + </material> + + <!-- // VM2000 + G4Material* C10H8O4 = new G4Material("C10H8O4", 1.38*g/cm3, 3); + C10H8O4->AddElement(elements->getElement("C"), 10); + C10H8O4->AddElement(elements->getElement("H"), 8); + C10H8O4->AddElement(elements->getElement("O"), 4); + fMaterialsList.push_back(C10H8O4); --> + + + <material name="G4_ESR" state="solid"> + <D value="0.90" unit="g/cm3" /> + <composite n="2" ref="C"/> + <composite n="4" ref="H" /> + </material> + + <material name="G4_ECAL_electronics" state="solid"> + <D value="3.5537349300000005" unit="g/cm3" /> + <fraction n="0.1595" ref="PCB"/> + <fraction n="0.0001" ref="G4_AIR"/> + <fraction n="0.8404" ref="G4_Cu"/> + </material> + <!-- Driftchamber: material for the drift chamber --> <material name="GasHe_90Isob_10"> <D value="0.0003983999999999999" unit="g/cm3" /> @@ -581,4 +614,6 @@ <fraction n="1" ref="N" /> </material> - </materials> +</materials> + + diff --git a/Detector/DetCRD/compact/CRD_o1_v05/Br.csv b/Detector/DetCRD/compact/CRD_o1_v05/Br.csv new file mode 100644 index 0000000000000000000000000000000000000000..093e9af359158fdaca67e469b41eb7761fcc7c13 --- /dev/null +++ b/Detector/DetCRD/compact/CRD_o1_v05/Br.csv @@ -0,0 +1,25 @@ +,0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8 +0,0,0.00072238,0.00141836,0.00207148,0.00267135,0.00321527,0.00370693,0.00415367,0.00456403,0.00494571,0.00530457,0.00564426,0.00596631,0.0062705,0.00655513,0.00681818,0.00705771,0.00732861,0.00810929 +0.1,0,0.00146197,0.00286741,0.00418194,0.00538432,0.00647049,0.00744939,0.00833756,0.00915321,0.00991255,0.01062748,0.01130531,0.01194895,0.01255775,0.01312817,0.01365485,0.0141346,0.01459255,0.01554511 +0.2,0,0.00299748,0.00586624,0.00852836,0.01094282,0.01310558,0.01504385,0.01679673,0.01840687,0.0199088,0.02132748,0.02267685,0.02396242,0.02518188,0.02632737,0.02738665,0.02834344,0.02917975,0.0297083 +0.3,0,0.00470406,0.00916282,0.01324734,0.01687741,0.02009235,0.02293873,0.02550271,0.02785864,0.03007062,0.03216839,0.03417707,0.03610186,0.03793614,0.03966636,0.04127328,0.0427277,0.0439612,0.04473902 +0.4,-0.00000647,0.00664673,0.01294727,0.01853694,0.02342833,0.02766724,0.03135658,0.0346236,0.03762847,0.04046865,0.04320808,0.0458611,0.04842299,0.05087912,0.05320893,0.05538617,0.05738196,0.05915243,0.06079397 +0.5,-0.00000753,0.0093127,0.01763368,0.02493902,0.03105909,0.03608541,0.04029972,0.04410349,0.04768399,0.05113054,0.05449101,0.05777605,0.06097232,0.0640623,0.06701241,0.06978611,0.07235239,0.07473295,0.0768376 +0.6,-0.00000589,0.01285906,0.02432863,0.03345808,0.04053062,0.04591404,0.05036601,0.05437551,0.05823045,0.06212425,0.06603374,0.06993371,0.07378217,0.07753199,0.0811289,0.08452695,0.08768658,0.09055379,0.09345266 +0.7,-0.00001818,0.01897127,0.03418009,0.04560011,0.05281641,0.05740905,0.06123209,0.06509765,0.06921145,0.07346395,0.07789282,0.08238071,0.0868928,0.09132841,0.09560674,0.0996668,0.10344551,0.10688772,0.1094982 +0.8,0.00017943,0.02721068,0.05488351,0.06640383,0.06919675,0.07087947,0.07329664,0.07650002,0.08044778,0.08499199,0.0898992,0.09508866,0.10031511,0.1054739,0.11049698,0.11526844,0.1197168,0.12378965,0.12742038 +0.9,0.01131628,0.09964188,0.10956434,0.09523256,0.08783426,0.08543011,0.08570056,0.08801099,0.09185151,0.09665147,0.10215635,0.1080128,0.11402253,0.12001919,0.12585215,0.13140119,0.13657321,0.14130417,0.14599683 +1,0.0123671,0.30322555,0.21825395,0.13134489,0.11117667,0.10138317,0.09856821,0.09950552,0.10304793,0.1082858,0.11448423,0.12115218,0.12806483,0.13499432,0.14172577,0.14814184,0.15410985,0.15952363,0.16392705 +1.1,-0.0130006,0.81867829,0.31323294,0.17470945,0.14281412,0.1172797,0.11038319,0.11012807,0.11366068,0.11965809,0.12674095,0.13453239,0.1424621,0.15041161,0.15816834,0.16556992,0.17246392,0.17863443,0.18396849 +1.2,-0.0229895,0.93538797,0.46957454,0.23912773,0.16118861,0.12885932,0.11926629,0.11930251,0.12397495,0.13088178,0.13917771,0.14794117,0.15714058,0.1663046,0.17522892,0.18375358,0.19173635,0.19902265,0.20514923 +1.3,-0.01855092,0.48878047,0.39570774,0.21783572,0.14628804,0.12719277,0.1244525,0.12673939,0.13266682,0.14132752,0.1509941,0.16155572,0.17221989,0.18271251,0.19296685,0.20274364,0.21194262,0.22056561,0.22852649 +1.4,0.0001534,0.61056539,0.22481189,0.15686994,0.12208722,0.12103158,0.12341572,0.1312666,0.14044614,0.15121053,0.16330192,0.17541998,0.18760352,0.19975484,0.211436,0.22260322,0.23308339,0.24285057,0.25312152 +1.5,0.00007495,0.22857647,0.11926743,0.12824678,0.10299139,0.1138839,0.12406379,0.13519351,0.14790416,0.16150443,0.17522457,0.1894441,0.20354108,0.21735608,0.23071957,0.24344031,0.25529341,0.26606367,0.27585775 +1.6,-0.00010149,-0.02566563,0.13180144,0.09216303,0.09393796,0.10978737,0.12344628,0.13875879,0.15454946,0.17083052,0.18742221,0.20381937,0.2201136,0.23576992,0.25099247,0.26534345,0.27884519,0.2909712,0.30117348 +1.7,-0.00023463,0.03542866,0.00826892,0.0293468,0.07075312,0.10064326,0.12197606,0.14230222,0.16183629,0.18109952,0.20002048,0.21870015,0.23677882,0.25481145,0.27194845,0.28851309,0.3038795,0.3181035,0.33064435 +1.8,0.00266113,-0.1083805,-0.04846637,-0.00185282,0.05428142,0.09184384,0.12142219,0.14631224,0.16958781,0.1915702,0.21306046,0.23400751,0.25476344,0.27460806,0.29417531,0.31269297,0.33038118,0.34699276,0.36319102 +1.9,0.00866707,-0.75826116,-0.16385417,-0.02638878,0.03737719,0.08554504,0.12285399,0.15138835,0.17764276,0.20246647,0.22648528,0.24987969,0.27268593,0.29528103,0.31704459,0.33821854,0.35836124,0.37715912,0.39453256 +2,-0.01028629,-0.84166325,-0.27516465,-0.04932607,0.03169354,0.09161905,0.12744717,0.15835233,0.18706874,0.21441486,0.24039237,0.26605301,0.29141355,0.31634381,0.34090269,0.36472764,0.38763394,0.40901008,0.42806931 +2.1,-0.02345212,-0.71040417,-0.12480799,-0.01011505,0.04757865,0.10347055,0.13577915,0.16723645,0.19733806,0.22620832,0.25454209,0.28241604,0.31023706,0.33793591,0.36537642,0.39210751,0.41815286,0.44323329,0.46554539 +2.2,0.04080456,0.04226858,-0.00078258,0.01048593,0.05762617,0.11188833,0.14459982,0.17659737,0.20787331,0.23848516,0.26902316,0.29876896,0.32841727,0.36007475,0.39038007,0.42062969,0.44952508,0.47982482,0.51122804 +2.3,-0.00060695,0.00780579,0.03477412,0.03449414,0.04893474,0.10802297,0.14912835,0.18036347,0.21372361,0.24592588,0.27777672,0.31122163,0.34693402,0.37919576,0.41359103,0.44954674,0.48620949,0.516638,0.55516713 diff --git a/Detector/DetCRD/compact/CRD_o1_v05/Bz.csv b/Detector/DetCRD/compact/CRD_o1_v05/Bz.csv new file mode 100644 index 0000000000000000000000000000000000000000..3bcbdca0c9c212075ef7617e929717a4fdb854ae --- /dev/null +++ b/Detector/DetCRD/compact/CRD_o1_v05/Bz.csv @@ -0,0 +1,25 @@ +,0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8 +0,2.98254375,2.98318937,2.98547167,2.98899442,2.99374132,2.99961886,3.00652732,3.01437409,3.02307982,3.03257973,3.0428217,3.05376278,3.06536515,3.07759241,3.09040663,3.10376663,3.11764635,3.1322132,3.14750674 +0.1,2.98109899,2.98175883,2.9840892,2.98767855,2.99250257,2.99845884,3.00544098,3.01335272,3.02211376,3.0316603,3.04194227,3.05291904,3.06455505,3.07681584,3.08966473,3.10306094,3.11695014,3.13125837,3.14695687 +0.2,2.97669588,2.97740238,2.97988968,2.98369431,2.98876474,2.99496905,3.00217997,3.01029042,3.0192184,3.02890417,3.03930467,3.05038681,3.06212207,3.07448198,3.08743474,3.10094015,3.11494236,3.12912079,3.14515215 +0.3,2.96910905,2.96990752,2.97270436,2.97692716,2.98246308,2.98912314,2.99674135,3.00519553,3.01440385,3.02431862,3.03491123,3.0461631,3.05805801,3.07057825,3.08370024,3.09739453,3.11161525,3.12652478,3.14114769 +0.4,2.95790006,2.95886479,2.96221313,2.96717546,2.97349577,2.98087865,2.98913349,2.99809283,3.00769228,3.01791665,3.02876844,3.04024247,3.05234864,3.06508339,3.07843296,3.09237751,3.1069152,3.12198926,3.1366115 +0.5,2.94243158,2.94347691,2.94786359,2.95411488,2.96176669,2.97015463,2.97940277,2.98902944,2.99913374,3.00971108,3.02088486,3.03261413,3.04497303,3.05796775,3.07159454,3.08583906,3.10067846,3.1161207,3.13094287 +0.6,2.92094761,2.92246038,2.92872698,2.9372441,2.94699778,2.95714022,2.96764351,2.97814264,2.98880074,2.99976326,3.01127211,3.02326221,3.0359063,3.04919134,3.06313922,3.07773566,3.09292699,3.10868421,3.1244398 +0.7,2.89064164,2.89309777,2.9030216,2.91587173,2.92916445,2.94201055,2.95415218,2.96563002,2.9767351,2.98808544,2.9999004,3.01215538,3.02512561,3.03869621,3.05301365,3.06801461,3.083694,3.09974359,3.11559875 +0.8,2.84359314,2.84976659,2.86839028,2.88886517,2.90865565,2.92572711,2.93949461,2.95160087,2.96318284,2.97471894,2.98673052,2.99929833,3.0125135,3.02643358,3.04114725,3.05661202,3.0727791,3.09005281,3.10558271 +0.9,2.79377195,2.79484734,2.81169347,2.8555578,2.88918856,2.90960141,2.9241453,2.93657548,2.94802672,2.95977126,2.97171818,2.98454606,2.99799764,3.01233191,3.02743736,3.04343022,3.06021239,3.07737665,3.09574487 +1,2.0535586,2.54472074,2.74173407,2.84947422,2.876516,2.89449246,2.90861048,2.92050954,2.9315521,2.94296308,2.95492102,2.96770859,2.98154662,2.99619258,3.01179073,3.02837584,3.04580913,3.06404436,3.08274544 +1.1,-0.03347429,2.28387737,2.78580819,2.85570683,2.87165377,2.8817725,2.89303944,2.90344406,2.91357043,2.92442137,2.93585694,2.94880619,2.96290759,2.97791834,2.99404928,3.01129936,3.029572,3.04881589,3.06767787 +1.2,-2.83937519,2.87734798,3.02485748,2.86942174,2.86874145,2.87052332,2.87716174,2.88513562,2.89372698,2.90345868,2.91473407,2.9275138,2.94197698,2.95729219,2.97404537,2.99201004,3.01119216,3.03151131,3.05153552 +1.3,-3.69765888,2.58057627,3.02821863,2.88738109,2.86932003,2.86205042,2.86000272,2.86499069,2.87163865,2.87983486,2.89089361,2.90376024,2.91837852,2.93421113,2.95157652,2.97029736,2.99034153,3.01198579,3.03418575 +1.4,-3.79899166,-0.47892673,3.13566838,2.91113876,2.88664502,2.84969876,2.84019214,2.83916989,2.84528126,2.85343453,2.86393496,2.87724142,2.89200306,2.90843409,2.92645823,2.94600774,2.966883,2.98897154,3.01568605 +1.5,-3.81052656,-0.60812881,2.98139683,2.91195237,2.87195812,2.82828197,2.8136639,2.81063727,2.81562642,2.82350832,2.83437979,2.84756355,2.86266308,2.87963631,2.89854369,2.91897372,2.94096453,2.96348955,2.99259771 +1.6,-3.96050739,-0.7731603,3.12235101,2.8808503,2.84101603,2.80294502,2.78022688,2.77826142,2.78243026,2.79018237,2.80103121,2.81463616,2.83007497,2.84771231,2.86750718,2.88898777,2.91235399,2.93780291,2.96061481 +1.7,-4.02599445,-0.93592331,2.89647078,2.82089094,2.76282035,2.75353776,2.74261542,2.74084514,2.74476447,2.75288815,2.76418066,2.77796882,2.79422958,2.81248555,2.83298022,2.8557321,2.88049262,2.90786297,2.93134384 +1.8,-3.87968428,-0.83325284,2.86203808,2.75420373,2.70226483,2.70221165,2.69862684,2.6982541,2.70294435,2.71170193,2.72341528,2.73781958,2.75460121,2.77361869,2.79494731,2.8186598,2.84476997,2.87308853,2.9021298 +1.9,-3.14971335,-0.35968446,2.82790469,2.67604145,2.64888583,2.6528447,2.64851541,2.6516181,2.65730121,2.66681706,2.67899248,2.69393163,2.71110006,2.73084567,2.75300787,2.7776393,2.80500933,2.83419274,2.86793361 +2,-2.3023104,-0.22353596,2.61967494,2.5937405,2.59182482,2.59859145,2.59510427,2.60018043,2.60797762,2.61842573,2.63083054,2.64615837,2.66375681,2.68386971,2.70678236,2.73242961,2.76091048,2.79267313,2.82456839 +2.1,0.32933266,0.44186465,2.46969787,2.50079108,2.52435322,2.54190753,2.53942484,2.54601671,2.55516344,2.56649507,2.57916145,2.59453011,2.61225552,2.63264638,2.65596904,2.68241859,2.71217202,2.74579311,2.77807088 +2.2,0.19143149,0.203763,2.4800973,2.4492233,2.46665427,2.48551649,2.4810036,2.48932808,2.49926241,2.51088011,2.52425068,2.53911646,2.55651669,2.5767344,2.60032566,2.62728555,2.65755481,2.69306386,2.73026936 +2.3,0.02797829,0.28282052,2.44391037,2.41509089,2.41246836,2.41538895,2.42029371,2.42996001,2.44075216,2.45197615,2.46501328,2.48036927,2.49567035,2.51567342,2.53957983,2.56657511,2.59683019,2.6306168,2.67158842 diff --git a/Detector/DetCRD/compact/CRD_o1_v05/CRD_Dimensions_v01_05.xml b/Detector/DetCRD/compact/CRD_o1_v05/CRD_Dimensions_v01_05.xml new file mode 100644 index 0000000000000000000000000000000000000000..33cf4731477ec287c89f679e0078cbb55766ca90 --- /dev/null +++ b/Detector/DetCRD/compact/CRD_o1_v05/CRD_Dimensions_v01_05.xml @@ -0,0 +1,282 @@ +<?xml version="1.0" encoding="UTF-8"?> +<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> + + <info name="CRDDimensions" + title="master file with includes and world dimension" + author="C.D.Fu, Mengyao Liu" + url="no" + status="development" + version="1.0"> + <comment> + undeterminded parameters + </comment> + </info> + + <define> + <constant name="CrossingAngle" value="0.033*rad"/> + + <constant name="Global_endcap_costheta" value="0.99"/> + + <constant name="GlobalTrackerReadoutID_DCH" type="string" value="system:8,chamber:1,layer:7,phi:16"/> + <constant name="GlobalTrackerReadoutID" type="string" value="system:5,side:-2,layer:9,module:8,sensor:8,barrelside:-2"/> + + <constant name="Field_nominal_value" value="3*tesla"/> + <constant name="Field_outer_nominal_value" value="-1.3*tesla"/> + + <constant name="env_safety" value="0.1*mm"/> + + <constant name="DetID_NOTUSED" value=" 0"/> + <constant name="DetID_VXD" value=" 1"/> + <constant name="DetID_SIT" value=" 2"/> + <constant name="DetID_FTD" value=" 3"/> + <constant name="DetID_TPC" value=" 4"/> + <constant name="DetID_SET" value=" 5"/> + <constant name="DetID_ETD" value=" 6"/> + <constant name="DetID_DC" value=" 4"/> <!--in order to cheat Clupatra, same as TPC--> + + <constant name="DetID_ECAL" value=" 20"/> + <constant name="DetID_ECAL_PLUG" value=" 21"/> + <constant name="DetID_HCAL" value=" 22"/> + <constant name="DetID_HCAL_RING" value=" 23"/> + <constant name="DetID_LCAL" value=" 24"/> + <constant name="DetID_BCAL" value=" 25"/> + <constant name="DetID_LHCAL" value=" 26"/> + <constant name="DetID_YOKE" value=" 27"/> + <constant name="DetID_COIL" value=" 28"/> + <constant name="DetID_ECAL_ENDCAP" value=" 29"/> + <constant name="DetID_HCAL_ENDCAP" value=" 30"/> + <constant name="DetID_YOKE_ENDCAP" value=" 31"/> + + <constant name="DetID_bwd" value="-1"/> + <constant name="DetID_barrel" value=" 0"/> + <constant name="DetID_fwd" value="+1"/> + + <constant name="BeamPipe_Be_inner_thickness" value="0.5*mm"/> + <constant name="BeamPipe_Cooling_thickness" value="0.5*mm"/> + <constant name="BeamPipe_Be_outer_thickness" value="0.3*mm"/> + <constant name="BeamPipe_Be_total_thickness" value="BeamPipe_Be_inner_thickness+BeamPipe_Cooling_thickness+BeamPipe_Be_outer_thickness"/> + <constant name="BeamPipe_Al_thickness" value="BeamPipe_Be_total_thickness"/> + <constant name="BeamPipe_Cu_thickness" value="2.0*mm"/> + + <constant name="BeamPipe_CentralBe_zmax" value="120*mm"/> + <constant name="BeamPipe_CentralAl_zmax" value="205*mm"/> + <constant name="BeamPipe_ConeAl_zmax" value="655*mm"/> + <constant name="BeamPipe_LinkerAl_zmax" value="700*mm"/> + <constant name="BeamPipe_LinkerCu_zmax" value="780*mm"/> + <constant name="BeamPipe_Waist_zmax" value="805*mm"/> + <constant name="BeamPipe_Crotch_zmax" value="855*mm"/> + <constant name="BeamPipe_FirstSeparated_zmax" value="1110*mm"/> + <constant name="BeamPipe_SecondSeparated_zmax" value="2200*mm"/> + <constant name="BeamPipe_end_z" value="12*m"/> + + <constant name="BeamPipe_Central_inner_radius" value="14*mm"/> + <constant name="BeamPipe_Expanded_inner_radius" value="20*mm"/> + <constant name="BeamPipe_Upstream_inner_radius" value="6*mm"/> + <constant name="BeamPipe_Dnstream_inner_radius" value="10*mm"/> + <constant name="BeamPipe_Crotch_hole_height" value="30.67*mm"/> + <constant name="BeamPipe_VertexRegion_rmax" value="BeamPipe_Central_inner_radius+BeamPipe_Al_thickness"/> + <constant name="BeamPipe_ForwardRegion_rmax" value="BeamPipe_Expanded_inner_radius+BeamPipe_Cu_thickness"/> + + <constant name="Vertex_inner_radius" value="BeamPipe_Central_inner_radius+BeamPipe_Be_total_thickness"/> + <constant name="Vertex_outer_radius" value="101*mm"/> + <constant name="Vertex_half_length" value="200*mm"/> + <constant name="Vertex_Side_rmin" value="BeamPipe_VertexRegion_rmax"/> + + <constant name="DC_Endcap_dz" value="0.1*mm"/> + <constant name="DC_half_length" value="2980*mm" /> + <constant name="DC_safe_distance" value="0.02*mm"/> + <constant name="SDT_inner_wall_thickness" value="0.2*mm"/> + <constant name="SDT_outer_wall_thickness" value="2.8*mm"/> + <constant name="MainTracker_half_length" value="DC_half_length+DC_Endcap_dz" /> + + <!--obselete for single drift chamber--> + <constant name="InnerTracker_half_length" value="DC_half_length" /> + <constant name="InnerTracker_inner_radius" value="234*mm"/> + <constant name="InnerTracker_outer_radius" value="909*mm"/> + <constant name="OuterTracker_half_length" value="DC_half_length"/> + <constant name="OuterTracker_inner_radius" value="1082.18*mm"/> + <constant name="OuterTracker_outer_radius" value="1723*mm"/> + + <!-- Parameters of single drift chamber --> + <!-- Disable DC > + <constant name="DC_chamber_layer_rbegin" value="800*mm"/> + <constant name="DC_chamber_layer_rend" value="1800*mm"/> + + <constant name="DC_inner_radius" value="DC_chamber_layer_rbegin-SDT_inner_wall_thickness-DC_safe_distance"/> + <constant name="DC_outer_radius" value="DC_chamber_layer_rend+SDT_outer_wall_thickness+DC_safe_distance"/--> + + <!-- Enable TPC to replace DC --> + <constant name="TPC_half_length" value="MainTracker_half_length"/> + <constant name="TPC_Ecal_Hcal_barrel_halfZ" value="MainTracker_half_length"/> + <constant name="TPC_inner_radius" value="800*mm"/> + <constant name="TPC_outer_radius" value="1800*mm"/> + <constant name="Ecal_Tpc_gap" value="35*mm"/> + + <constant name="SIT1_inner_radius" value="230*mm"/> + <constant name="SIT2_inner_radius" value="410*mm"/> + <constant name="SIT3_inner_radius" value="590*mm"/> + <constant name="SIT4_inner_radius" value="770*mm"/> + <constant name="SIT1_half_length" value="461*mm"/> + <constant name="SIT2_half_length" value="691*mm"/> + <constant name="SIT3_half_length" value="1013*mm"/> + <constant name="SIT4_half_length" value="1335*mm"/> + + <constant name="SET_inner_radius" value="1815*mm"/> + + <constant name="SiTracker_barrel_endcap_gap" value="5*mm"/> + <constant name="SiTracker_DC_endcap_gap" value="10*mm"/> + <constant name="SiTracker_endcap_z1" value="SIT1_half_length+SiTracker_barrel_endcap_gap"/> + <constant name="SiTracker_endcap_z2" value="SIT2_half_length+SiTracker_barrel_endcap_gap"/> + <constant name="SiTracker_endcap_z3" value="SIT3_half_length+SiTracker_barrel_endcap_gap"/> + <constant name="SiTracker_endcap_z4" value="SIT4_half_length+SiTracker_barrel_endcap_gap"/> + <constant name="SiTracker_endcap_z5" value="MainTracker_half_length+SiTracker_DC_endcap_gap"/> + <constant name="SiTracker_endcap_outer_radius1" value="SIT1_inner_radius+SiTracker_barrel_endcap_gap"/> + <constant name="SiTracker_endcap_outer_radius2" value="SIT2_inner_radius+SiTracker_barrel_endcap_gap"/> + <constant name="SiTracker_endcap_outer_radius3" value="SIT3_inner_radius+SiTracker_barrel_endcap_gap"/> + <constant name="SiTracker_endcap_outer_radius4" value="SIT4_inner_radius+SiTracker_barrel_endcap_gap"/> + <constant name="SiTracker_endcap_outer_radius5" value="SET_inner_radius+SiTracker_barrel_endcap_gap"/> + <!--obseleted --> + <constant name="FTD_BeamPipe_cable_clearance" value="10*mm"/> + <constant name="FTD_BeamPipe_gap" value="15*mm"/> + <constant name="FTD_InnerTracker_gap" value="5*mm"/> + + <!--obseleted constance, used by old construct, should be removed while creating new constrcut--> + <!--constant name="TPC_Ecal_Hcal_barrel_halfZ" value="MainTracker_half_length"/> + <constant name="TPC_inner_radius" value="InnerTracker_inner_radius"/> + <constant name="TPC_outer_radius" value="OuterTracker_outer_radius"/--> + <constant name="SIT1_Radius" value="SIT1_inner_radius"/> + <constant name="SIT1_Half_Length_Z" value="SIT1_half_length"/> + <constant name="SIT2_Radius" value="InnerTracker_inner_radius"/> <!--fake, used by FTD_Simple_Staggered and FTD_cepc, now should be determined by inner tracker--> + <constant name="SIT2_Half_Length_Z" value="SIT2_half_length"/> + <constant name="TUBE_IPOuterTube_end_z" value="BeamPipe_CentralAl_zmax"/> + <constant name="TUBE_IPOuterTube_end_radius" value="BeamPipe_Central_inner_radius+BeamPipe_Al_thickness"/> + <constant name="TUBE_IPOuterBulge_end_z" value="BeamPipe_Crotch_zmax"/><!--"BeamPipe_ConeAl_zmax"/--> + <constant name="TUBE_IPOuterBulge_end_radius" value="BeamPipe_Crotch_zmax*tan(CrossingAngle/2)+BeamPipe_Dnstream_inner_radius+BeamPipe_Cu_thickness"/> + <!--"BeamPipe_Expanded_inner_radius+BeamPipe_Al_thickness+5*mm"/--> + + <constant name="Ecal_barrel_inner_radius" value="1900*mm"/> + <constant name="Ecal_barrel_outer_radius" value="2200*mm"/> + <constant name="Ecal_barrel_half_length" value="2950*mm"/> + + <constant name="Ecal_endcap_inner_radius" value="350*mm"/> + <!-- <constant name="Ecal_endcap_outer_radius" value="Ecal_barrel_inner_radius+Ecal_barrel_thickness"/> --> + <constant name="Ecal_endcap_zmin" value="3050*mm"/> + <constant name="Ecal_endcap_zmax" value="3300*mm"/> + <constant name="Ecal_endcap_symmetry" value="8"/> + <!--obseleted constance, used by old construct, should be removed while creating new constrcut--> + <constant name="EcalEndcap_outer_radius" value="Ecal_barrel_outer_radius"/> + + <constant name="Solenoid_inner_radius" value="2330*mm"/> + <constant name="Solenoid_outer_radius" value="2480*mm"/> + <constant name="Solenoid_half_length" value="3830*mm"/> + <constant name="SolenoidCoil_half_length" value="3800*mm"/> + <constant name="SolenoidCoil_radius" value="2351*mm"/> + <constant name="SolenoidCoil_center_radius" value="(Solenoid_inner_radius+Solenoid_outer_radius)/2"/> + + <constant name="Hcal_barrel_inner_radius" value="2250.00*mm"/> + <constant name="Hcal_barrel_outer_radius" value="3793.00*mm"/> + <constant name="Hcal_barrel_half_length" value="3300.00*mm"/> + <constant name="Hcal_barrel_symmetry" value="16"/> + + <constant name="Hcal_endcap_inner_radius" value="400*mm"/> + <constant name="Hcal_endcap_outer_radius" value="Ecal_barrel_outer_radius"/> + <constant name="Hcal_endcap_zmin" value="3400*mm"/> + <constant name="Hcal_endcap_zmax" value="4480*mm"/> + <constant name="Hcal_endcap_symmetry" value="12"/> + <!--obseleted constance, used by old construct, should be removed while creating new constrcut--> + <constant name="HcalEndcap_max_z" value="Hcal_endcap_zmax"/> + <constant name="Hcal_endcap_outer_symmetry" value="Hcal_endcap_symmetry"/> + <constant name="Hcal_outer_radius" value="Hcal_barrel_outer_radius"/> + + <!--constant name="Hcal_ring_inner_radius" value="Hcal_endcap_inner_radius"/> + <constant name="Hcal_ring_outer_radius" value="Solenoid_inner_radius"/> + <constant name="Hcal_ring_zmin" value="2600*mm"/> + <constant name="Hcal_ring_zmax" value="Hcal_endcap_zmin-10*mm"/> + <constant name="Hcal_ring_symmetry" value="8"/--> + + <constant name="Yoke_barrel_inner_radius" value="3660*mm"/> + <constant name="Yoke_barrel_outer_radius" value="4260*mm"/> + <constant name="Yoke_barrel_half_length" value="Hcal_endcap_zmax"/> + <constant name="Yoke_barrel_symmetry" value="12"/> + + <constant name="Yoke_endcap_inner_radius" value="400*mm"/> + <constant name="Yoke_endcap_outer_radius" value="Yoke_barrel_outer_radius"/> + <constant name="Yoke_endcap_zmin" value="4660*mm"/> + <constant name="Yoke_endcap_zmax" value="5460*mm"/> + <constant name="Yoke_endcap_outer_symmetry" value="Yoke_barrel_symmetry"/> + <constant name="Yoke_endcap_inner_symmetry" value="0"/> + <!--obseleted constance, used by old construct, should be removed while creating new constrcut--> + <constant name="Yoke_Z_start_endcaps" value="Yoke_endcap_zmin"/> + + <!--constant name="LumiCal_zmax" value="805*mm" /> + <constant name="LumiCal_zmin" value="700*mm"/> + <constant name="LumiCal_thickness" value="(LumiCal_zmax-LumiCal_zmin)/2.0"/> + <constant name="LumiCal_inner_radius" value="35.0*mm"/> + <constant name="LumiCal_outer_radius" value="100.0*mm- env_safety"/--> + + <constant name="tracker_region_zmax" value="OuterTracker_half_length"/> + <constant name="tracker_region_rmax" value="OuterTracker_outer_radius"/> + + </define> + + <limits> + <limitset name="cal_limits"> + <limit name="step_length_max" particles="*" value="0.01" unit="mm" /> + </limitset> + <limitset name="dc_limits"> + <limit name="step_length_max" particles="*" value="10.0" unit="mm" /> + </limitset> + <limitset name="tracker_limits"> + <limit name="step_length_max" particles="*" value="5.0" unit="mm" /> + </limitset> + </limits> + + <regions> + <region name="BeampipeRegion"/> + <region name="VertexRegion"/> + <region name="ForwardRegion"/> + </regions> + + <display> + <vis name="VXDVis" alpha="0.1" r="0.1" g=".5" b=".5" showDaughters="true" visible="true"/> + <vis name="VXDLayerVis" alpha="1.0" r="0.1" g=".5" b=".5" showDaughters="true" visible="true"/> + <vis name="VXDSupportVis" alpha="1.0" r="0.0" g="1.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="FTDVis" alpha="1.0" r="0.5" g="0.87" b="0.11" showDaughters="true" visible="true"/> + <vis name="FTDSupportVis" alpha="1.0" r="0.3" g="0.3" b="1.0" showDaughters="true" visible="true"/> + <vis name="FTDSensitiveVis" alpha="1.0" r="0.3" g="0.5" b="1.0" showDaughters="true" visible="true"/> + <vis name="DCVis" alpha="1.0" r="0.96" g="0.64" b="0.90" showDaughters="true" visible="true"/> + <vis name="DCLayerVis" alpha="1.0" r="0.96" g="0.64" b="0.90" showDaughters="false" visible="true"/> + <vis name="SITVis" alpha="0.0" r="0.54" g="0.59" b="0.93" showDaughters="true" visible="false"/> + <vis name="SITSupportVis" alpha="1.0" r="0.0" g="0.0" b="1.0" showDaughters="false" visible="true"/> + <vis name="SITSensitiveVis" alpha="1.0" r="0.67" g="0.99" b="0.78" showDaughters="false" visible="true"/> + <vis name="SETVis" alpha="0.0" r="0.8" g="0.8" b="0.4" showDaughters="true" visible="false"/> + <vis name="SETSupportVis" alpha="1.0" r="1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="SETSensitiveVis" alpha="1.0" r="0.0" g="0.0" b="1.0" showDaughters="true" visible="true"/> + <vis name="ECALVis" alpha="1.0" r="0.2" g="0.6" b="0" showDaughters="true" visible="true"/> + <vis name="HCALVis" alpha="1.0" r="0.95" g="0.78" b="0.69" showDaughters="true" visible="true"/> + <vis name="SOLVis" alpha="1.0" r="0.4" g="0.4" b="0.4" showDaughters="true" visible="true"/> + <vis name="YOKEVis" alpha="1.0" r="0.64" g="0.75" b="0.99" showDaughters="false" visible="true"/> + <vis name="LCALVis" alpha="1.0" r="0.25" g="0.88" b="0.81" showDaughters="true" visible="true"/> + <vis name="SupportVis" alpha="1.0" r="0.2" g="0.2" b="0.2" showDaughters="true" visible="true"/> + <vis name="ShellVis" alpha="1.0" r="0.83" g="0.55" b="0.89" showDaughters="false" visible="true"/> + + <vis name="WhiteVis" alpha="0.0" r=".96" g=".96" b=".96" showDaughters="true" visible="true"/> + <vis name="LightGrayVis" alpha="0.0" r=".75" g=".75" b=".75" showDaughters="true" visible="true"/> + <vis name="Invisible" alpha="0.0" r="0.0" g="0.0" b="0.0" showDaughters="false" visible="false"/> + <vis name="SeeThrough" alpha="0.0" r="0.0" g="0.0" b="0.0" showDaughters="true" visible="false"/> + <vis name="RedVis" alpha="1.0" r="1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="GreenVis" alpha="1.0" r="0.0" g="1.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="BlueVis" alpha="1.0" r="0.0" g="0.0" b="1.0" showDaughters="true" visible="true"/> + <vis name="CyanVis" alpha="1.0" r="0.0" g="1.0" b="1.0" showDaughters="true" visible="true"/> + <vis name="MagentaVis" alpha="1.0" r="1.0" g="0.0" b="1.0" showDaughters="true" visible="true"/> + <vis name="YellowVis" alpha="1.0" r="1.0" g="1.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="BlackVis" alpha="1.0" r="0.0" g="0.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="GrayVis" alpha="1.0" r="0.5" g="0.5" b="0.5" showDaughters="true" visible="true"/> + <!-- <vis name="EcalBarrelVis" alpha="1.0" r="0.5" g="0.5" b="0.5" showDaughters="true" visible="true"/> --> + <vis name="EcalBarrelVis" alpha="1.0" r="0.90" g="0.88" b="0.84" showDaughters="true" visible="true"/> + <!-- <vis name="EcalBarrelVis" alpha="1.0" r="0.63" g="0.67" b="0.71" showDaughters="true" visible="true"/> --> + </display> + +</lccdd> diff --git a/Detector/DetCRD/compact/CRD_o1_v05/CRD_o1_v05.xml b/Detector/DetCRD/compact/CRD_o1_v05/CRD_o1_v05.xml new file mode 100755 index 0000000000000000000000000000000000000000..84a20fd312355439b91b7a2187d30b8e539b7baf --- /dev/null +++ b/Detector/DetCRD/compact/CRD_o1_v05/CRD_o1_v05.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> + <info name="CRD_o1_v05" + title="CepC reference detctor" + author="C.D.Fu, F.Y.Guo" + url="http://cepc.ihep.ac.cn" + status="developing" + version="v05"> + <comment>CepC reference detector simulation models used for detector study </comment> + </info> + + <includes> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> + <gdmlFile ref="../CRD_common_v01/materials.xml"/> + </includes> + + <define> + <constant name="world_size" value="25*m"/> + <constant name="world_x" value="world_size"/> + <constant name="world_y" value="world_size"/> + <constant name="world_z" value="world_size"/> + + <include ref="${DD4hepINSTALL}/DDDetectors/compact/detector_types.xml"/> + </define> + + <include ref="./CRD_Dimensions_v01_05.xml"/> + + <include ref="../CRD_common_v01/Beampipe_v01_01.xml"/> + <include ref="../CRD_common_v01/VXD_v01_01.xml"/> + <include ref="../CRD_common_v01/FTD_SkewRing_v01_01.xml"/> + <include ref="../CRD_common_v01/SIT_SimplePixel_v01_01.xml"/> + <include ref="../CRD_common_v01/TPC_CEPCv4.xml"/> + <include ref="../CRD_common_v01/SET_SimplePixel_v01_01.xml"/> + <include ref="../CRD_common_v01/Ecal_Crystal_Barrel_v01_02.xml"/> + + <!-- <include ref="../CRD_common_v01/Coil_Simple_v01_01.xml"/> --> + <include ref="../CRD_common_v01/SHcalGlass_Barrel_v04_01.xml"/> + <!-- <include ref="../CRD_common_v01/SHcalSc04_Endcaps_v01_01.xml"/> --> + <!-- <include ref="../CRD_common_v01/Yoke_Barrel_v01_01.xml"/> --> + <!-- <include ref="../CRD_common_v01/Yoke_Endcaps_v01_01.xml"/> --> + <!--include ref="../CRD_common_v01/Lcal_v01_01.xml"/--> + + <fields> + <field name="InnerSolenoid" type="solenoid" + inner_field="Field_nominal_value" + outer_field="0" + zmax="SolenoidCoil_half_length" + inner_radius="SolenoidCoil_center_radius" + outer_radius="Solenoid_outer_radius"> + </field> + <field name="OuterSolenoid" type="solenoid" + inner_field="0" + outer_field="Field_outer_nominal_value" + zmax="SolenoidCoil_half_length" + inner_radius="Solenoid_outer_radius" + outer_radius="Yoke_barrel_inner_radius"> + </field> + </fields> + +</lccdd> diff --git a/Detector/DetCRD/compact/README.md b/Detector/DetCRD/compact/README.md index 0ef4c00fa60d35c805202947751e8a82338f343c..7a7cac749e8acfbc764d08cef3ef13fedbd1726e 100644 --- a/Detector/DetCRD/compact/README.md +++ b/Detector/DetCRD/compact/README.md @@ -8,6 +8,7 @@ The following CRD detector models are available in CEPCSW | CRD_o1_v02 | strip SET | SIT+DC+SET | crystal | RPC | developing | | CRD_o1_v03 | MOST2 vertex | SIT+DC+SET | crystal | RPC | developing | | CRD_o1_v04 | smaller center beam pipe | SIT+DC+SET | crystal | RPC | developing | +| CRD_o1_v05 | Use Ref-Det ECAL and HCAL | SIT+TPC+SET | crystal | Glass| developing | | ------------- | -----------------------------|-------------|---------|------|----------------| ## Details @@ -61,3 +62,15 @@ The following CRD detector models are available in CEPCSW - smaller center beam pipe & new MDI: inner radius = 10mm, flat at y direction - compact files: - [./CRD_o1_v04/CRD_o1_v04.xml](./CRD_o1_v04/CRD_o1_v04.xml) + + +### CRD_o1_v05 (towarding TDR Ref-Detector) + - based on CRD_o1_v01 + - Main tracker: Replace DC with CEPC_v4 TPC for preliminary performance study. + - ECAL barrel: 32-polygon crystal bar ECAL. + - HCAL barrel: 16-polygon glass HCAL, based on SHcalSc04_barrel geometry. + - compact files: + - [./CRD_o1_v05/CRD_o1_v05.xml] + + + diff --git a/Detector/DetCRD/scripts/CRD_o1_v05-Sim.py b/Detector/DetCRD/scripts/CRD_o1_v05-Sim.py new file mode 100644 index 0000000000000000000000000000000000000000..0be7a76f061bee6561794b7024a8ee630a2f73d2 --- /dev/null +++ b/Detector/DetCRD/scripts/CRD_o1_v05-Sim.py @@ -0,0 +1,306 @@ +#!/usr/bin/env python +import os, sys +from Gaudi.Configuration import * + +from Configurables import k4DataSvc +dsvc = k4DataSvc("EventDataSvc") + +from Configurables import RndmGenSvc, HepRndm__Engine_CLHEP__RanluxEngine_ + +seed = [90] +# rndmengine = HepRndm__Engine_CLHEP__RanluxEngine_() # The default engine in Gaudi +rndmengine = HepRndm__Engine_CLHEP__HepJamesRandom_("RndmGenSvc.Engine") # The default engine in Geant4 +rndmengine.SetSingleton = True +rndmengine.Seeds = seed + +rndmgensvc = RndmGenSvc("RndmGenSvc") +rndmgensvc.Engine = rndmengine.name() + +#geometry_option = "CRD_o1_v01/CRD_o1_v01.xml" +geometry_option = "CRD_o1_v05/CRD_o1_v05.xml" +#... + +if not os.getenv("DETCRDROOT"): + print("Can't find the geometry. Please setup envvar DETCRDROOT." ) + sys.exit(-1) + +geometry_path = os.path.join(os.getenv("DETCRDROOT"), "compact", geometry_option) +if not os.path.exists(geometry_path): + print("Can't find the compact geometry file: %s"%geometry_path) + sys.exit(-1) + +from Configurables import GeomSvc +geosvc = GeomSvc("GeomSvc") +geosvc.compact = geometry_path + +from Configurables import NTupleSvc +ntsvc = NTupleSvc("NTupleSvc") +#ntsvc.Output = ["MyTuples DATAFILE='result.root' OPT='NEW' TYP='ROOT'"] + +############################################################################## +# Physics Generator +############################################################################## +from Configurables import GenAlgo +from Configurables import GtGunTool +from Configurables import StdHepRdr +from Configurables import SLCIORdr +from Configurables import HepMCRdr +from Configurables import GenPrinter + +gun = GtGunTool("GtGunTool") +gun.Particles = ["mu-"] +#gun.Particles = ["nu_e"] +gun.PositionXs = [0.] +gun.PositionYs = [0.] +gun.PositionZs = [0.] +gun.EnergyMins = [10.] # GeV +gun.EnergyMaxs = [10.] # GeV +gun.ThetaMins = [45.] # deg +gun.ThetaMaxs = [135.] # deg +gun.PhiMins = [0.] # deg +gun.PhiMaxs = [360.] # deg + + +# stdheprdr = StdHepRdr("StdHepRdr") +# stdheprdr.Input = "/cefs/data/stdhep/CEPC240/higgs/exclusive/E240.Pnnh_bb.e0.p0.whizard195/nnh_bb.e0.p0.00001.stdhep" + +# lciordr = SLCIORdr("SLCIORdr") +# lciordr.Input = "/cefs/data/stdhep/lcio250/signal/Higgs/E250.Pbbh.whizard195/E250.Pbbh_X.e0.p0.whizard195/Pbbh_X.e0.p0.00001.slcio" +# hepmcrdr = HepMCRdr("HepMCRdr") +# hepmcrdr.Input = "example_UsingIterators.txt" + +genprinter = GenPrinter("GenPrinter") + +genalg = GenAlgo("GenAlgo") +genalg.GenTools = ["GtGunTool"] +# genalg.GenTools = ["StdHepRdr"] +# genalg.GenTools = ["StdHepRdr", "GenPrinter"] +# genalg.GenTools = ["SLCIORdr", "GenPrinter"] +# genalg.GenTools = ["HepMCRdr", "GenPrinter"] + +############################################################################## +# Detector Simulation +############################################################################## +from Configurables import DetSimSvc +detsimsvc = DetSimSvc("DetSimSvc") + +from Configurables import DetSimAlg +detsimalg = DetSimAlg("DetSimAlg") +detsimalg.RandomSeeds = seed +# detsimalg.VisMacs = ["vis.mac"] +detsimalg.RunCmds = [ +# "/tracking/verbose 1", +] +detsimalg.AnaElems = [ + # example_anatool.name() +# "ExampleAnaElemTool", + "Edm4hepWriterAnaElemTool" +] +detsimalg.RootDetElem = "WorldDetElemTool" +detsimalg.PhysicsList = "QGSP_BERT_EMV" + +from Configurables import MarlinEvtSeeder +evtseeder = MarlinEvtSeeder("EventSeeder") + +from Configurables import GearSvc +gearsvc = GearSvc("GearSvc") +#gearsvc.GearXMLFile = "../../Detector/DetCEPCv4/compact/FullDetGear.xml" + +from Configurables import TrackSystemSvc +tracksystemsvc = TrackSystemSvc("TrackSystemSvc") + +from Configurables import AnExampleDetElemTool +example_dettool = AnExampleDetElemTool("AnExampleDetElemTool") + +from Configurables import TimeProjectionChamberSensDetTool +tpc_sensdettool = TimeProjectionChamberSensDetTool("TimeProjectionChamberSensDetTool") +tpc_sensdettool.TypeOption = 1 + + +from Configurables import CalorimeterSensDetTool +from Configurables import DriftChamberSensDetTool +cal_sensdettool = CalorimeterSensDetTool("CalorimeterSensDetTool") +cal_sensdettool.CalNamesMergeDisable = ["CaloDetector"] +cal_sensdettool.CalNamesApplyBirks = ["HcalBarrel"] + +# digitization +vxdhitname = "VXDTrackerHits" +sithitname = "SITTrackerHits" +tpchitname = "TPCTrackerHits" +sethitname = "SETTrackerHits" +setspname = "SETSpacePoints" +ftdhitname = "FTDTrackerHits" +ftdspname = "FTDSpacePoints" +from Configurables import PlanarDigiAlg +digiVXD = PlanarDigiAlg("VXDDigi") +digiVXD.SimTrackHitCollection = "VXDCollection" +digiVXD.TrackerHitCollection = vxdhitname +digiVXD.TrackerHitAssociationCollection = "VXDTrackerHitAssociation" +digiVXD.ResolutionU = [0.0028, 0.006, 0.004, 0.004, 0.004, 0.004] +digiVXD.ResolutionV = [0.0028, 0.006, 0.004, 0.004, 0.004, 0.004] +digiVXD.UsePlanarTag = True +#digiVXD.OutputLevel = DEBUG + +digiSIT = PlanarDigiAlg("SITDigi") +digiSIT.IsStrip = False +digiSIT.SimTrackHitCollection = "SITCollection" +digiSIT.TrackerHitCollection = sithitname +digiSIT.TrackerHitAssociationCollection = "SITTrackerHitAssociation" +digiSIT.ResolutionU = [0.0072] +digiSIT.ResolutionV = [0.086] +digiSIT.UsePlanarTag = True +#digiSIT.OutputLevel = DEBUG + +digiSET = PlanarDigiAlg("SETDigi") +digiSET.IsStrip = False +digiSET.SimTrackHitCollection = "SETCollection" +digiSET.TrackerHitCollection = sethitname +digiSET.TrackerHitAssociationCollection = "SETTrackerHitAssociation" +digiSET.ResolutionU = [0.0072] +digiSET.ResolutionV = [0.086] +digiSET.UsePlanarTag = True +#digiSET.OutputLevel = DEBUG + +# two strip tracker hits -> one space point +from Configurables import SpacePointBuilderAlg +spSET = SpacePointBuilderAlg("SETBuilder") +spSET.TrackerHitCollection = sethitname +spSET.TrackerHitAssociationCollection = "SETTrackerHitAssociation" +spSET.SpacePointCollection = setspname +spSET.SpacePointAssociationCollection = "SETSpacePointAssociation" +#spSET.OutputLevel = DEBUG + + +digiFTD = PlanarDigiAlg("FTDDigi") +digiFTD.IsStrip = False +digiFTD.SimTrackHitCollection = "FTDCollection" +digiFTD.TrackerHitCollection = ftdhitname +digiFTD.TrackerHitAssociationCollection = "FTDTrackerHitAssociation" +digiFTD.ResolutionU = [0.003, 0.003, 0.0072, 0.0072, 0.0072, 0.0072, 0.0072] +digiFTD.ResolutionV = [0.003, 0.003, 0.0072, 0.0072, 0.0072, 0.0072, 0.0072] +digiFTD.UsePlanarTag = True +#digiFTD.OutputLevel = DEBUG + +# two strip tracker hits -> one space point +from Configurables import SpacePointBuilderAlg +spFTD = SpacePointBuilderAlg("FTDBuilder") +spFTD.TrackerHitCollection = ftdhitname +spFTD.TrackerHitAssociationCollection = "FTDTrackerHitAssociation" +spFTD.SpacePointCollection = ftdspname +spFTD.SpacePointAssociationCollection = "FTDSpacePointAssociation" +#spFTD.OutputLevel = DEBUG + +from Configurables import TPCDigiAlg +digiTPC = TPCDigiAlg("TPCDigi") +digiTPC.TPCCollection = "TPCCollection" +digiTPC.TPCLowPtCollection = "TPCLowPtCollection" +digiTPC.TPCTrackerHitsCol = tpchitname +digiTPC.TPCTrackerHitAssCol = "TPCTrackerHitAssociation" +#digiTPC.OutputLevel = DEBUG + +# tracking +from Configurables import SiliconTrackingAlg +tracking = SiliconTrackingAlg("SiliconTracking") +tracking.HeaderCol = "EventHeader" +tracking.VTXHitCollection = vxdhitname +tracking.SITHitCollection = sithitname +tracking.FTDPixelHitCollection = ftdhitname +tracking.FTDSpacePointCollection = ftdspname +tracking.SITRawHitCollection = sithitname +tracking.FTDRawHitCollection = ftdhitname +tracking.UseSIT = True +tracking.SmoothOn = False +tracking.DumpTime = False +tracking.NDivisionsInTheta = 10 +#tracking.OutputLevel = DEBUG + +from Configurables import ForwardTrackingAlg +forward = ForwardTrackingAlg("ForwardTracking") +forward.FTDPixelHitCollection = ftdhitname +forward.FTDSpacePointCollection = ftdspname +forward.FTDRawHitCollection = ftdhitname +forward.Chi2ProbCut = 0.0 +forward.HitsPerTrackMin = 3 +forward.BestSubsetFinder = "SubsetSimple" +forward.Criteria = ["Crit2_DeltaPhi","Crit2_StraightTrackRatio","Crit3_3DAngle","Crit3_ChangeRZRatio","Crit3_IPCircleDist","Crit4_3DAngleChange","Crit4_DistToExtrapolation", + "Crit2_DeltaRho","Crit2_RZRatio","Crit3_PT"] +forward.CriteriaMin = [0, 0.9, 0, 0.995, 0, 0.8, 0, 20, 1.002, 0.1, 0, 0.99, 0, 0.999, 0, 0.99, 0] +forward.CriteriaMax = [30, 1.02, 10, 1.015, 20, 1.3, 1.0, 150, 1.08, 99999999, 0.8, 1.01, 0.35, 1.001, 1.5, 1.01, 0.05] +forward.DumpTime = False +#forward.OutputLevel = DEBUG + +from Configurables import TrackSubsetAlg +subset = TrackSubsetAlg("TrackSubset") +subset.TrackInputCollections = ["ForwardTracks", "SiTracks"] +subset.RawTrackerHitCollections = [vxdhitname, sithitname, ftdhitname, ftdspname] +subset.TrackSubsetCollection = "SubsetTracks" +subset.DumpTime = False +#subset.OutputLevel = DEBUG + +#TODO: DC reconstruction, as preliminary, use Clupatra like as TPC +from Configurables import ClupatraAlg +clupatra = ClupatraAlg("Clupatra") +clupatra.TPCHitCollection = tpchitname +#clupatra.DistanceCut = 100. +#clupatra.MaxDeltaChi2 = 100. +#clupatra.Chi2Cut = 150. +#clupatra.OutputLevel = DEBUG + +from Configurables import FullLDCTrackingAlg +full = FullLDCTrackingAlg("FullTracking") +full.VTXTrackerHits = vxdhitname +full.SITTrackerHits = sithitname +full.TPCTrackerHits = tpchitname # add TPC or DC tracker hit here, if TPC or DC track is set by full.TPCTracks +full.SETTrackerHits = sethitname +full.FTDPixelTrackerHits = ftdhitname +full.FTDSpacePoints = ftdspname +full.SITRawHits = sithitname +full.SETRawHits = sethitname +full.FTDRawHits = ftdhitname +#full.VTXHitRelCol = "VXDTrackerHitAssociation" +#full.SITHitRelCol = "SITTrackerHitAssociation" +#full.SETHitRelCol = "SETSpacePointAssociation" +#full.FTDHitRelCol = "FTDTrackerHitAssociation" +#full.TPCHitRelCol = "TPCTrackerHitAssociation" +full.TPCTracks = "ClupatraTracks" # add standalone TPC or DC track here +full.SiTracks = "SubsetTracks" +full.OutputTracks = "MarlinTrkTracks" +full.DumpTime = False +full.SITHitToTrackDistance = 3. +full.SETHitToTrackDistance = 5. +full.MinChi2ProbForSiliconTracks = 0 +#full.OutputLevel = DEBUG + +dedxoption = "BetheBlochEquationDedxSimTool" +from Configurables import DriftChamberSensDetTool +dc_sensdettool = DriftChamberSensDetTool("DriftChamberSensDetTool") +dc_sensdettool.DedxSimTool = dedxoption + +from Configurables import DummyDedxSimTool +from Configurables import BetheBlochEquationDedxSimTool + +if dedxoption == "DummyDedxSimTool": + dedx_simtool = DummyDedxSimTool("DummyDedxSimTool") +elif dedxoption == "BetheBlochEquationDedxSimTool": + dedx_simtool = BetheBlochEquationDedxSimTool("BetheBlochEquationDedxSimTool") + dedx_simtool.material_Z = 2 + dedx_simtool.material_A = 4 + dedx_simtool.scale = 10 + dedx_simtool.resolution = 0.0001 + +# output +from Configurables import PodioOutput +out = PodioOutput("outputalg") +out.filename = "Simu_RefDet_Mu_10GeV.root" +out.outputCommands = ["keep *"] + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( + TopAlg = [genalg, detsimalg, digiVXD, digiSIT, digiSET, digiFTD, spSET, digiTPC, out], + EvtSel = 'NONE', + EvtMax = 10, + ExtSvc = [rndmengine, rndmgensvc, dsvc, evtseeder, geosvc, gearsvc, tracksystemsvc], + #ExtSvc = [rndmengine, rndmgensvc, dsvc, geosvc], + OutputLevel=INFO +) diff --git a/Detector/DetCRD/src/Calorimeter/LongCrystalBarBarrelCalorimeter32Polygon_v01.cpp b/Detector/DetCRD/src/Calorimeter/LongCrystalBarBarrelCalorimeter32Polygon_v01.cpp new file mode 100755 index 0000000000000000000000000000000000000000..afd688810285a6e951c755ba97a125606952d77a --- /dev/null +++ b/Detector/DetCRD/src/Calorimeter/LongCrystalBarBarrelCalorimeter32Polygon_v01.cpp @@ -0,0 +1,1228 @@ +//========================================================================== +// LongCrystalBarBarrelCalorimeter32Polygon_v01 implementation +//-------------------------------------------------------------------------- +// Author: Song Weizheng, IHEP +//-------------------------------------------------------------------------- +// Data: 2024.4.16 +//========================================================================== + +#include "DD4hep/DetFactoryHelper.h" +#include "XML/Layering.h" +#include "XML/Utilities.h" +#include "DDRec/DetectorData.h" +#include "DDSegmentation/Segmentation.h" + +#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; +using namespace dd4hep; +using namespace std; + +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); + int detid = x_det.id(); + + // ###################################### + // ### detector description parameter ### + // ###################################### + + double radius_inner = theDetector.constant<double>("ecalbarrel_inner_radius"); + double radius_outer = theDetector.constant<double>("ecalbarrel_outer_radius"); + double length_z = theDetector.constant<double>("ecalbarrel_zlength"); + + int Nlayers = theDetector.constant<double>("ecalbarrel_layer"); + int n_module = theDetector.constant<double>("ecalbarrel_phimodule_number"); + int Nblock_z = theDetector.constant<double>("ecalbarrel_Zmodule_number"); + double rotation_angle = theDetector.constant<double>("ecalbarrel_module_ratation"); + + double width_crystal = theDetector.constant<double>("ecalbarrel_width_crystal"); + double crystal_wrapping = theDetector.constant<double>("ecalbarrel_crystal_wrapping"); + double photoelectronic = theDetector.constant<double>("ecalbarrel_length_photoelectronic"); + double photoelectronic_width = theDetector.constant<double>("ecalbarrel_width_photoelectronic"); + + double dead_material = theDetector.constant<double>("ecalbarrel_length_carbon"); + double cable = theDetector.constant<double>("ecalbarrel_length_cable"); + double pcb = theDetector.constant<double>("ecalbarrel_length_pcb"); + double asic = theDetector.constant<double>("ecalbarrel_length_asic"); + double cooling = theDetector.constant<double>("ecalbarrel_length_cooling"); + double back_plate = theDetector.constant<double>("ecalbarrel_length_back"); + + // ########################### + // ### general measurement ### + // ########################### + + // Z direction + double pZ = length_z/Nblock_z; // length of module in z + double length_crystal_z = pZ - 2*dead_material - 2*cable - 2*pcb - 2*asic - 2*cooling; // length of crystal wrap sipm in z + int Nbar_phi = floor(length_crystal_z/width_crystal); // number of crystal in phi + + // R - phi direction + double angle = 360./n_module*degree; + + double trap_depth = radius_outer*cos(angle/2.) - radius_inner; + double trap_line = trap_depth/cos(angle/2.); + double alice_angle = 0.5*angle + rotation_angle; // angle of "|/" in inner<outer trapozoid (positive梯形) + double alice_1 = 0.5*trap_depth/tan(90*degree-alice_angle); + double alice_2 = 0.5*trap_line*sin(angle/2.); + double deviation_positive = alice_1 - alice_2; + double bob_angle = 90*degree - angle; + double deviation_bob = tan(bob_angle)/(tan(alice_angle)+tan(bob_angle))*deviation_positive; + double deviation_negative = deviation_bob/cos(angle); + double height_layer1 = deviation_bob*tan(angle); + double deviation_layer1 = height_layer1*tan(alice_angle); + double copper_angle = 180*degree - alice_angle - bob_angle; + + //Half-length of the trapezoid + double dim_x1 = radius_inner*tan(angle/2.)-deviation_positive+deviation_layer1; + double dim_x3 = radius_inner*tan(angle/2.)+deviation_negative; + + double m_bottom_length = dim_x1; + double m_tan_a = tan(alice_angle); + double m_bottom_height = radius_inner + height_layer1; + double m_a = m_tan_a*m_tan_a + 1; + double m_b = 2*m_bottom_length*m_tan_a + 2*m_bottom_height; + double m_c = m_bottom_length*m_bottom_length + m_bottom_height*m_bottom_height - radius_outer*radius_outer; + double m_delta = m_b*m_b - 4*m_a*m_c; + double m_x1 = (-m_b + sqrt(m_delta))/(2*m_a); + double m_x2 = (-m_b - sqrt(m_delta))/(2*m_a); + + double m_bottom_length1 = dim_x3; + double m_tan_a1 = 1./tan(copper_angle); + double m_bottom_height1 = radius_inner; + double m_a1 = m_tan_a1*m_tan_a1 + 1; + double m_b1 = 2*m_bottom_height1 - 2*m_bottom_length1*m_tan_a1; + double m_c1 = m_bottom_length1*m_bottom_length1 + m_bottom_height1*m_bottom_height1 - radius_outer*radius_outer; + double m_delta1 = m_b1*m_b1 - 4*m_a1*m_c1; + double m_x3 = (-m_b1 + sqrt(m_delta1))/(2*m_a1); + double m_x4 = (-m_b1 - sqrt(m_delta1))/(2*m_a1); + + // Thickness of the trapezoid + double depth_longitudinal_p = m_x1; + double depth_longitudinal_n = m_x3; + + double plus = depth_longitudinal_p*tan(alice_angle); + double minus = depth_longitudinal_n/tan(copper_angle); + double dim_x2 = dim_x1+plus; + double dim_x4 = dim_x3-minus; + + double dim_z_p = depth_longitudinal_p/2.; + double dim_z_n = depth_longitudinal_n/2.; + + double size_crystal = (depth_longitudinal_n-back_plate)/Nlayers; + double size_posi_crystal = (depth_longitudinal_p-back_plate)/Nlayers; //Crystal thickness in positive trapezoid + + // #################### + // ### World Volume ### + // #################### + + dd4hep::DetElement ECAL(det_name, detid); + dd4hep::Volume motherVol = theDetector.pickMotherVolume(ECAL); + + dd4hep::PolyhedraRegular envelope(n_module, angle/2., radius_inner, radius_outer, length_z); + dd4hep::Material air(theDetector.material("Air")); + dd4hep::Material vacuum(theDetector.material("Vacuum")); + dd4hep::Volume envelopeVol(det_name, envelope, air); + dd4hep::PlacedVolume envelopePlv = motherVol.placeVolume(envelopeVol, Position(0,0,0)); + envelopePlv.addPhysVolID("system",x_det.id()); + envelopeVol.setVisAttributes(theDetector, "SeeThrough" ); + ECAL.setPlacement(envelopePlv); + + dd4hep::Material mat_BGO(theDetector.material("G4_BGO")); + dd4hep::Material mat_CF(theDetector.material("CarbonFiber")); + dd4hep::Material mat_Cu(theDetector.material("G4_Cu")); + dd4hep::Material mat_ESR(theDetector.material("G4_ESR")); + dd4hep::Material mat_Si(theDetector.material("G4_Si")); + dd4hep::Material mat_PCB(theDetector.material("PCB")); + + dd4hep::Trapezoid trap_positive(dim_x1, dim_x2, length_z/2, length_z/2, dim_z_p); + dd4hep::Volume trap_positive_vol("trap_positive_vol", trap_positive, air); + trap_positive_vol.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::Trapezoid trap_negative(dim_x3, dim_x4, length_z/2, length_z/2, dim_z_n); + dd4hep::Volume trap_negative_vol("trap_negative_vol", trap_negative, air); + trap_negative_vol.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::Trapezoid subtrap_positive(dim_x1, dim_x2, length_z/2/Nblock_z, length_z/2/Nblock_z, dim_z_p); + dd4hep::Volume subtrap_positive_vol("subtrap_positive_vol", subtrap_positive, air); + subtrap_positive_vol.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::Trapezoid subtrap_negative(dim_x3, dim_x4, length_z/2/Nblock_z, length_z/2/Nblock_z, dim_z_n); + dd4hep::Volume subtrap_negative_vol("subtrap_negative_vol", subtrap_negative, air); + subtrap_negative_vol.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::DetElement stavedet(ECAL, "trap",detid); + + // ################################## + // ### SiPM PCB ASIC Cable Carbon ### + // ################################## + + double electronics = cable + pcb + asic + cooling; // + photoelectronic + + double dead_material_p = dead_material/cos(alice_angle); + double dead_material_n = dead_material/sin(copper_angle); + + double dead_material_l = dead_material_p + electronics; + double dead_material_r = dead_material_n + electronics; + double dead_material_z = dead_material + electronics; + + dd4hep::Trap left_trap(pZ, size_posi_crystal, dead_material_p + size_posi_crystal*tan(alice_angle), (dead_material_p)); + dd4hep::Volume left("left_vol", left_trap, mat_CF); + left.setVisAttributes(theDetector, "GrayVis"); + + dd4hep::Trap left_trap2(pZ, size_posi_crystal, dead_material_p + 2*size_posi_crystal*tan(alice_angle), dead_material_p + size_posi_crystal*tan(alice_angle)); + dd4hep::Volume left2("left_vol2", left_trap2, mat_CF); + left2.setVisAttributes(theDetector, "GrayVis"); + + dd4hep::Trap right_trap(pZ, size_crystal, (dead_material_n + size_crystal/tan(copper_angle)), dead_material_n); //Dead material in each layer in positive trapezoid + dd4hep::Volume right("right_vol", right_trap, mat_CF); + right.setVisAttributes(theDetector, "GrayVis"); + + dd4hep::Trap right_trap2(pZ, size_crystal, (dead_material_n + 2*size_crystal/tan(copper_angle)), dead_material_n + size_crystal/tan(copper_angle)); //Dead material in negative trapezoid + dd4hep::Volume right2("right_vol2", right_trap2, mat_CF); + right2.setVisAttributes(theDetector, "GrayVis"); + + // #################### + // ### Print Volume ### + // #################### + + std::cout << "dim_x1" << " : " << dim_x1*2 << std::endl; + std::cout << "dim_x2" << " : " << dim_x2*2 << std::endl; + std::cout << "dim_x3" << " : " << dim_x3*2 << std::endl; + std::cout << "dim_x4" << " : " << dim_x4*2 << std::endl; + std::cout << "depth_longitudinal_p" << " : " << depth_longitudinal_p << std::endl; + std::cout << "depth_longitudinal_n" << " : " << depth_longitudinal_n << std::endl; + + std::cout << "radius outer" << " : " << sqrt((radius_inner+depth_longitudinal_n)*(radius_inner+depth_longitudinal_n)+dim_x4*dim_x4) << std::endl; + std::cout << "radius outer" << " : " << sqrt((radius_inner+height_layer1+depth_longitudinal_p)*(radius_inner+height_layer1+depth_longitudinal_p)+dim_x2*dim_x2) << std::endl; + + std::cout << "size_crystal" << " : " << size_crystal << std::endl; + std::cout << "size_posi_crystal" << " : " << size_posi_crystal << std::endl; + + std::cout << "dead_material_p" << " : " << dead_material_p << std::endl; + std::cout << "dead_material_plus" << " : " << size_posi_crystal*tan(alice_angle) << std::endl; + + std::cout << "dead_material_n" << " : " << dead_material_n << std::endl; + std::cout << "dead_material_minus" << " : " << size_crystal/tan(copper_angle) << std::endl; + + std::cout << "area_1" << " : " << dead_material_p*2*size_posi_crystal << std::endl; + std::cout << "area_2" << " : " << (dead_material_p+dead_material_p+size_posi_crystal*tan(alice_angle))*size_posi_crystal << std::endl; + std::cout << "area_3" << " : " << (dead_material_p+dead_material_p+2*size_posi_crystal*tan(alice_angle))*size_posi_crystal << std::endl; + + std::cout << "area_4" << " : " << dead_material_n*2*size_crystal << std::endl; + std::cout << "area_5" << " : " << (dead_material_n+dead_material_n+size_crystal/tan(copper_angle))*size_crystal << std::endl; + std::cout << "area_6" << " : " << (dead_material_n+dead_material_n+2*size_crystal/tan(copper_angle))*size_crystal << std::endl; + + double area_posi = (2*dim_x1+2*dim_x2)*depth_longitudinal_p/2; + double area_nega = (2*dim_x3+2*dim_x4)*depth_longitudinal_n/2; + + double area_1 = dead_material_p*2*size_posi_crystal; + double area_2 = (dead_material_p+dead_material_p+size_posi_crystal*tan(alice_angle))*size_posi_crystal; + double area_3 = (dead_material_p+dead_material_p+2*size_posi_crystal*tan(alice_angle))*size_posi_crystal; + + double area_4 = dead_material_n*2*size_crystal; + double area_5 = (dead_material_n+dead_material_n+size_crystal/tan(copper_angle))*size_crystal; + double area_6 = (dead_material_n+dead_material_n+2*size_crystal/tan(copper_angle))*size_crystal; + + std::cout << "area_1_ratio" << " : " << (area_1+area_4)*2*14/(area_posi+area_nega) << std::endl; + std::cout << "area_2_ratio" << " : " << (area_2+area_5)*2*14/(area_posi+area_nega) << std::endl; + std::cout << "area_3_ratio" << " : " << (area_3+area_6)*2*14/(area_posi+area_nega) << std::endl; + + std::cout << "pZ" << " : " << pZ << std::endl; + std::cout << "Nbar_phi" << " : " << Nbar_phi << std::endl; + + // #################################### + // ### placement of all the volumes ### + // #################################### + + double length_posi; // bottom lenght + double length_nega; // + double length_posi_1; // + double length_nega_1; // + + int Nbar_z; + double last_bar; // + double last_bar_z; + + int Tot_Z = 0; + int Tot_Phi = 0; + + double Tot_length_Z_posi = 0; + double Tot_length_Z_nega = 0; + double Tot_length_Phi_posi = 0; + double Tot_length_Phi_nega = 0; + + // ########################## + // ### positive trapezoid ### + // ########################## + + dd4hep::Volume backPlate("back_plate", dd4hep::Box(back_plate*15, back_plate*15, back_plate*0.5), mat_PCB); + backPlate.setVisAttributes(theDetector, "GrayVis"); + std::string blockname = "back_plate_positive"; + dd4hep::DetElement sd(stavedet, blockname, detid); + dd4hep::PlacedVolume plv = subtrap_positive_vol.placeVolume(backPlate, Position(0, 0, dim_z_p-back_plate*0.5)); + sd.setPlacement(plv); + + for(int ilayer=0; ilayer<Nlayers; ilayer=ilayer+1){ + + // Break size + if(ilayer%2 ==0){ + length_posi = dim_x1 - dead_material_l + ilayer*size_posi_crystal*tan(alice_angle); + length_posi_1 = dim_x1 - dead_material_l + (ilayer+1)*size_posi_crystal*tan(alice_angle); + } + else{ + length_posi = dim_x1 - dead_material_l + (ilayer-1)*size_posi_crystal*tan(alice_angle); + length_posi_1 = dim_x1 - dead_material_l + ilayer*size_posi_crystal*tan(alice_angle); + } + + //Trapezoid in layer + dd4hep::Volume block("block", dd4hep::Trapezoid( dim_x1+ilayer*size_posi_crystal*tan(alice_angle), dim_x1+(ilayer+1)*size_posi_crystal*tan(alice_angle), pZ/2, pZ/2, size_posi_crystal/2), air); + block.setVisAttributes(theDetector, "SeeThrough"); + std::string blockname = "Block_positive_"+std::to_string(ilayer+1); + dd4hep::DetElement sd(stavedet, blockname, detid); + + //Carbon fiber supporting + dd4hep::Volume CarbonFiber0("CarbonFiber0", dd4hep::Box(length_posi+electronics, dead_material*0.5, size_posi_crystal*0.5), mat_CF); //phi + CarbonFiber0.setVisAttributes(theDetector, "GrayVis"); + + dd4hep::PlacedVolume plv_cf0 = block.placeVolume(CarbonFiber0, Position(0, pZ/2-dead_material/2, 0)); + std::string cfname0 = "Deadzone_s4_"+std::to_string(ilayer+1); + dd4hep::DetElement cfdet0(sd, cfname0, detid); + cfdet0.setPlacement(plv_cf0); + + dd4hep::PlacedVolume plv_cf1 = block.placeVolume(CarbonFiber0, Position(0, -pZ/2+dead_material/2, 0)); + std::string cfname1 = "Deadzone_s5_"+std::to_string(ilayer+1); + dd4hep::DetElement cfdet1(sd, cfname1, detid); + cfdet1.setPlacement(plv_cf1); + + if(ilayer%2 ==0){ + dd4hep::Transform3D transform(dd4hep::RotationZ(180*degree)*dd4hep::RotationX(-90*degree), dd4hep::Position(-length_posi-electronics-(dead_material_p)/2-(((dead_material_p) + size_posi_crystal*tan(alice_angle))/2-(dead_material_p)/2)/2, 0., 0.)); + dd4hep::PlacedVolume plv_bar2 = block.placeVolume(left, transform); + std::string barname2 = "Deadzone_s2_"+std::to_string(ilayer+1); + dd4hep::DetElement bardet2(sd, barname2, detid); + bardet2.setPlacement(plv_bar2); + + dd4hep::Transform3D transform2(dd4hep::RotationX(-90*degree), dd4hep::Position(length_posi+electronics+(dead_material_p)/2+(((dead_material_p) + size_posi_crystal*tan(alice_angle))/2-(dead_material_p)/2)/2, 0., 0.)); + dd4hep::PlacedVolume plv_bar3= block.placeVolume(left, transform2); + std::string barname3 = "Deadzone_s3_"+std::to_string(ilayer+1); + dd4hep::DetElement bardet3(sd, barname3, detid); + bardet3.setPlacement(plv_bar3); + } + else{ + dd4hep::Transform3D transform(dd4hep::RotationZ(180*degree)*dd4hep::RotationX(-90*degree), dd4hep::Position(-length_posi-electronics-(dead_material_p+size_posi_crystal*tan(alice_angle))/2-(((dead_material_p) + 2*size_posi_crystal*tan(alice_angle))/2-(dead_material_p+size_posi_crystal*tan(alice_angle))/2)/2, 0., 0.)); + dd4hep::PlacedVolume plv_bar2 = block.placeVolume(left2, transform); + std::string barname2 = "Deadzone_s2_"+std::to_string(ilayer+1); + dd4hep::DetElement bardet2(sd, barname2, detid); + bardet2.setPlacement(plv_bar2); + + dd4hep::Transform3D transform2(dd4hep::RotationX(-90*degree), dd4hep::Position(length_posi+electronics+(dead_material_p+size_posi_crystal*tan(alice_angle))/2+(((dead_material_p) + 2*size_posi_crystal*tan(alice_angle))/2-(dead_material_p+size_posi_crystal*tan(alice_angle))/2)/2, 0., 0.)); + dd4hep::PlacedVolume plv_bar3= block.placeVolume(left2, transform2); + std::string barname3 = "Deadzone_s3_"+std::to_string(ilayer+1); + dd4hep::DetElement bardet3(sd, barname3, detid); + bardet3.setPlacement(plv_bar3); + } + + // Electronics + + dd4hep::Volume electronics_phi0("electronics_phi0", dd4hep::Box(length_posi+electronics, (electronics-cooling)*0.5, size_posi_crystal*0.5), mat_PCB); //phi + electronics_phi0.setVisAttributes(theDetector, "YellowVis"); + + dd4hep::PlacedVolume plv_elec0 = block.placeVolume(electronics_phi0, Position(0, -length_crystal_z/2-(electronics-cooling)/2, 0)); + std::string elecname0 = "electronics_positive_phi_u_"+std::to_string(ilayer+1); + dd4hep::DetElement elecdet0(sd, elecname0, detid); + elecdet0.setPlacement(plv_elec0); + + dd4hep::PlacedVolume plv_elec1 = block.placeVolume(electronics_phi0, Position(0, length_crystal_z/2+(electronics-cooling)/2, 0)); + std::string elecname1 = "electronics_positive_phi_d_"+std::to_string(ilayer+1); + dd4hep::DetElement elecdet1(sd, elecname1, detid); + elecdet1.setPlacement(plv_elec1); + + dd4hep::Volume electronics_phi_l("electronics_phi_l", dd4hep::Box((electronics-cooling)/2, length_crystal_z/2, size_posi_crystal*0.5), mat_PCB); //phi + electronics_phi_l.setVisAttributes(theDetector, "YellowVis"); + + dd4hep::PlacedVolume plv_elec2 = block.placeVolume(electronics_phi_l, Position(-length_posi-(electronics-cooling)/2, 0, 0)); + std::string elecname2 = "electronics_positive_phi_l_"+std::to_string(ilayer+1); + dd4hep::DetElement elecdet2(sd, elecname2, detid); + elecdet2.setPlacement(plv_elec2); + + dd4hep::PlacedVolume plv_elec3 = block.placeVolume(electronics_phi_l, Position(length_posi+(electronics-cooling)/2, 0, 0)); + std::string elecname3 = "electronics_positive_phi_r_"+std::to_string(ilayer+1); + dd4hep::DetElement elecdet3(sd, elecname3, detid); + elecdet3.setPlacement(plv_elec3); + + //Cooling copper + + dd4hep::Volume copper_phi0("copper_phi0", dd4hep::Box(length_posi+electronics, cooling*0.5, size_posi_crystal*0.5), mat_Cu); //phi + copper_phi0.setVisAttributes(theDetector, "RedVis"); + + dd4hep::PlacedVolume plv_copper0 = block.placeVolume(copper_phi0, Position(0, -length_crystal_z/2-electronics+cooling/2, 0)); + std::string coppername0 = "copper_positive_phi_u_"+std::to_string(ilayer+1); + dd4hep::DetElement copperdet0(sd, coppername0, detid); + copperdet0.setPlacement(plv_copper0); + + dd4hep::PlacedVolume plv_copper1 = block.placeVolume(copper_phi0, Position(0, length_crystal_z/2+electronics-cooling/2, 0)); + std::string coppername1 = "copper_positive_phi_d_"+std::to_string(ilayer+1); + dd4hep::DetElement copperdet1(sd, coppername1, detid); + copperdet1.setPlacement(plv_copper1); + + dd4hep::Volume copper_phi_l("copper_phi_l", dd4hep::Box(cooling/2, length_crystal_z/2, size_posi_crystal*0.5), mat_Cu); //phi + copper_phi_l.setVisAttributes(theDetector, "RedVis"); + + dd4hep::PlacedVolume plv_copper2 = block.placeVolume(copper_phi_l, Position(-length_posi-electronics+cooling/2, 0, 0)); + std::string coppername2 = "copper_positive_phi_l_"+std::to_string(ilayer+1); + dd4hep::DetElement copperdet2(sd, coppername2, detid); + copperdet2.setPlacement(plv_copper2); + + dd4hep::PlacedVolume plv_copper3 = block.placeVolume(copper_phi_l, Position(length_posi+electronics-cooling/2, 0, 0)); + std::string coppername3 = "copper_positive_phi_r_"+std::to_string(ilayer+1); + dd4hep::DetElement copperdet3(sd, coppername3, detid); + copperdet3.setPlacement(plv_copper3); + + // ################################### + // ####### Phi direction place ####### + // ################################### + + if(ilayer%2==0){ + Tot_Phi = Tot_Phi + Nbar_phi; + Tot_length_Phi_posi = Tot_length_Phi_posi + (length_posi-photoelectronic-crystal_wrapping)*2*(size_posi_crystal*0.5-crystal_wrapping)*2*(length_crystal_z-crystal_wrapping*2*Nbar_phi); + + cout<<"length_crystal_phi "<<(dim_x1 - dead_material_l-photoelectronic-crystal_wrapping)*2 <<" "<<size_posi_crystal*tan(alice_angle)*2<<endl; + + dd4hep::Volume sipm_s0("sipm_s0", dd4hep::Box(photoelectronic/2, photoelectronic_width/2, photoelectronic_width/2), mat_Si); + sipm_s0.setVisAttributes(theDetector, "BlueVis"); + + dd4hep::Volume sipm_s1("sipm_s1", dd4hep::Box(crystal_wrapping/2, photoelectronic_width/2, photoelectronic_width/2), mat_Si); + sipm_s1.setVisAttributes(theDetector, "BlueVis"); + + last_bar_z = length_crystal_z - (Nbar_phi-1)*width_crystal; + + dd4hep::Volume bar_s0("bar_s0", dd4hep::Box(length_posi-photoelectronic-crystal_wrapping, width_crystal*0.5-crystal_wrapping, size_posi_crystal*0.5-crystal_wrapping), mat_BGO); + bar_s0.setVisAttributes(theDetector, "EcalBarrelVis"); + bar_s0.setSensitiveDetector(sens); + + dd4hep::Volume bar_s1("bar_s1", dd4hep::Box(length_posi-photoelectronic-crystal_wrapping, last_bar_z*0.5-crystal_wrapping, size_posi_crystal*0.5-crystal_wrapping), mat_BGO); + bar_s1.setVisAttributes(theDetector, "EcalBarrelVis"); + bar_s1.setSensitiveDetector(sens); + + for(int ibar0=0;ibar0<Nbar_phi;ibar0++){ + if(ibar0 == Nbar_phi-1){ + dd4hep::Volume hardware_s1("hardware_s1", dd4hep::Box(length_posi, last_bar_z*0.5, size_posi_crystal*0.5), air); + hardware_s1.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::Volume crystal_s1("crystal_s1", dd4hep::Box(length_posi-photoelectronic, last_bar_z*0.5, size_posi_crystal*0.5), mat_ESR); + crystal_s1.setVisAttributes(theDetector, "CyanVis"); + + dd4hep::PlacedVolume plv_bar0 = crystal_s1.placeVolume(bar_s1, Position(0, 0, 0)); + std::string barname0 = "CrystalBar_positive_s0_"+std::to_string(ibar0); + dd4hep::DetElement bardet0(sd, barname0, detid); + bardet0.setPlacement(plv_bar0); + + dd4hep::PlacedVolume plv_sipm4 = crystal_s1.placeVolume(sipm_s1, Position(-length_posi+photoelectronic+crystal_wrapping/2, 0, -photoelectronic_width/2)); + std::string sipmname4 = "SiPM_positive_s8_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet4(sd, sipmname4, detid); + sipmdet4.setPlacement(plv_sipm4); + + dd4hep::PlacedVolume plv_sipm5 = crystal_s1.placeVolume(sipm_s1, Position(length_posi-photoelectronic-crystal_wrapping/2, 0, photoelectronic_width/2)); + std::string sipmname5 = "SiPM_positive_s9_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet5(sd, sipmname5, detid); + sipmdet5.setPlacement(plv_sipm5); + + dd4hep::PlacedVolume plv_sipm6 = crystal_s1.placeVolume(sipm_s1, Position(-length_posi+photoelectronic+crystal_wrapping/2, 0, photoelectronic_width/2)); + std::string sipmname6 = "SiPM_positive_s10_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet6(sd, sipmname6, detid); + sipmdet6.setPlacement(plv_sipm6); + + dd4hep::PlacedVolume plv_sipm7 = crystal_s1.placeVolume(sipm_s1, Position(length_posi-photoelectronic-crystal_wrapping/2, 0, -photoelectronic_width/2)); + std::string sipmname7 = "SiPM_positive_s11_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet7(sd, sipmname7, detid); + sipmdet7.setPlacement(plv_sipm7); + + dd4hep::PlacedVolume plv_sipm0 = hardware_s1.placeVolume(sipm_s0, Position(-length_posi+photoelectronic/2, 0, -photoelectronic_width/2)); + std::string sipmname0 = "SiPM_positive_s0_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet0(sd, sipmname0, detid); + sipmdet0.setPlacement(plv_sipm0); + + dd4hep::PlacedVolume plv_sipm1 = hardware_s1.placeVolume(sipm_s0, Position(length_posi-photoelectronic/2, 0, photoelectronic_width/2)); + std::string sipmname1 = "SiPM_positive_s1_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet1(sd, sipmname1, detid); + sipmdet1.setPlacement(plv_sipm1); + + dd4hep::PlacedVolume plv_sipm2 = hardware_s1.placeVolume(sipm_s0, Position(-length_posi+photoelectronic/2, 0, photoelectronic_width/2)); + std::string sipmname2 = "SiPM_positive_s2_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet2(sd, sipmname2, detid); + sipmdet2.setPlacement(plv_sipm2); + + dd4hep::PlacedVolume plv_sipm3 = hardware_s1.placeVolume(sipm_s0, Position(length_posi-photoelectronic/2, 0, -photoelectronic_width/2)); + std::string sipmname3 = "SiPM_positive_s3_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet3(sd, sipmname3, detid); + sipmdet3.setPlacement(plv_sipm3); + + dd4hep::PlacedVolume plv_cry0 = hardware_s1.placeVolume(crystal_s1, Position(0, 0, 0)); + std::string cryname0 = "Crystal_positive_s0_"+std::to_string(ibar0); + dd4hep::DetElement crydet0(sd, cryname0, detid); + crydet0.setPlacement(plv_cry0); + + dd4hep::PlacedVolume plv_hard0 = block.placeVolume(hardware_s1, Position(0, -length_crystal_z/2+last_bar_z*0.5, 0)); + plv_hard0.addPhysVolID("slayer",0).addPhysVolID("bar",ibar0); + std::string hardname0 = "Hardware_positive_s0_"+std::to_string(ibar0); + dd4hep::DetElement harddet0(sd, hardname0, detid); + harddet0.setPlacement(plv_hard0); + } + else{ + + dd4hep::Volume hardware_s0("hardware_s0", dd4hep::Box(length_posi, width_crystal*0.5, size_posi_crystal*0.5), air); + hardware_s0.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::Volume crystal_s0("crystal_s0", dd4hep::Box(length_posi-photoelectronic, width_crystal*0.5, size_posi_crystal*0.5), mat_ESR); + crystal_s0.setVisAttributes(theDetector, "CyanVis"); + + dd4hep::PlacedVolume plv_bar0 = crystal_s0.placeVolume(bar_s0, Position(0, 0, 0)); + std::string barname0 = "CrystalBar_positive_s0_"+std::to_string(ibar0); + dd4hep::DetElement bardet0(sd, barname0, detid); + bardet0.setPlacement(plv_bar0); + + dd4hep::PlacedVolume plv_sipm4 = crystal_s0.placeVolume(sipm_s1, Position(-length_posi+photoelectronic+crystal_wrapping/2, 0, -photoelectronic_width/2)); + std::string sipmname4 = "SiPM_positive_s8_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet4(sd, sipmname4, detid); + sipmdet4.setPlacement(plv_sipm4); + + dd4hep::PlacedVolume plv_sipm5 = crystal_s0.placeVolume(sipm_s1, Position(length_posi-photoelectronic-crystal_wrapping/2, 0, photoelectronic_width/2)); + std::string sipmname5 = "SiPM_positive_s9_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet5(sd, sipmname5, detid); + sipmdet5.setPlacement(plv_sipm5); + + dd4hep::PlacedVolume plv_sipm6 = crystal_s0.placeVolume(sipm_s1, Position(-length_posi+photoelectronic+crystal_wrapping/2, 0, photoelectronic_width/2)); + std::string sipmname6 = "SiPM_positive_s10_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet6(sd, sipmname6, detid); + sipmdet6.setPlacement(plv_sipm6); + + dd4hep::PlacedVolume plv_sipm7 = crystal_s0.placeVolume(sipm_s1, Position(length_posi-photoelectronic-crystal_wrapping/2, 0, -photoelectronic_width/2)); + std::string sipmname7 = "SiPM_positive_s11_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet7(sd, sipmname7, detid); + sipmdet7.setPlacement(plv_sipm7); + + dd4hep::PlacedVolume plv_sipm0 = hardware_s0.placeVolume(sipm_s0, Position(-length_posi+photoelectronic/2, 0, -photoelectronic_width/2)); + std::string sipmname0 = "SiPM_positive_s0_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet0(sd, sipmname0, detid); + sipmdet0.setPlacement(plv_sipm0); + + dd4hep::PlacedVolume plv_sipm1 = hardware_s0.placeVolume(sipm_s0, Position(length_posi-photoelectronic/2, 0, photoelectronic_width/2)); + std::string sipmname1 = "SiPM_positive_s1_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet1(sd, sipmname1, detid); + sipmdet1.setPlacement(plv_sipm1); + + dd4hep::PlacedVolume plv_sipm2 = hardware_s0.placeVolume(sipm_s0, Position(-length_posi+photoelectronic/2, 0, photoelectronic_width/2)); + std::string sipmname2 = "SiPM_positive_s2_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet2(sd, sipmname2, detid); + sipmdet2.setPlacement(plv_sipm2); + + dd4hep::PlacedVolume plv_sipm3 = hardware_s0.placeVolume(sipm_s0, Position(length_posi-photoelectronic/2, 0, -photoelectronic_width/2)); + std::string sipmname3 = "SiPM_positive_s3_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet3(sd, sipmname3, detid); + sipmdet3.setPlacement(plv_sipm3); + + dd4hep::PlacedVolume plv_cry0 = hardware_s0.placeVolume(crystal_s0, Position(0, 0, 0)); + std::string cryname0 = "Crystal_positive_s0_"+std::to_string(ibar0); + dd4hep::DetElement crydet0(sd, cryname0, detid); + crydet0.setPlacement(plv_cry0); + + dd4hep::PlacedVolume plv_hard0 = block.placeVolume(hardware_s0, Position(0, length_crystal_z/2-(2*ibar0+1)*width_crystal/2, 0)); + std::string hardname0 = "Hardware_positive_s0_"+std::to_string(ibar0); + dd4hep::DetElement harddet0(sd, hardname0, detid); + plv_hard0.addPhysVolID("slayer",0).addPhysVolID("bar",ibar0); + harddet0.setPlacement(plv_hard0); + } + } + } + + // ################################# + // ####### Z direction place ####### + // ################################# + + else{ + + Nbar_z = int((length_posi-0.5*width_crystal)/width_crystal); + last_bar = length_posi-0.5*width_crystal - (Nbar_z-1)*width_crystal; + + Tot_Z = Tot_Z + 2*Nbar_z+1; + Tot_length_Z_posi = Tot_length_Z_posi + (2*length_posi-(2*Nbar_z+1)*crystal_wrapping*2)*(length_crystal_z/2-photoelectronic-crystal_wrapping)*2*(size_posi_crystal*0.5-crystal_wrapping)*2; + cout<<"layer: "<< ilayer+1 <<" Nbar_z: "<< 2*Nbar_z+1 <<endl; + cout<<"length_crystal_z "<<(length_crystal_z/2-photoelectronic-crystal_wrapping)*2 <<endl; + + dd4hep::Volume sipm_s0("sipm_s0", dd4hep::Box(photoelectronic_width/2, photoelectronic/2, photoelectronic_width/2), mat_Si); + sipm_s0.setVisAttributes(theDetector, "BlueVis"); + + dd4hep::Volume sipm_s1("sipm_s1", dd4hep::Box(photoelectronic_width/2, crystal_wrapping/2, photoelectronic_width/2), mat_Si); + sipm_s1.setVisAttributes(theDetector, "BlueVis"); + + dd4hep::Volume bar_s0("bar_s0", dd4hep::Box(width_crystal*0.5-crystal_wrapping, length_crystal_z/2-photoelectronic-crystal_wrapping, size_posi_crystal*0.5-crystal_wrapping), mat_BGO); + bar_s0.setVisAttributes(theDetector, "EcalBarrelVis"); + bar_s0.setSensitiveDetector(sens); + + dd4hep::Volume bar_s1("bar_s1", dd4hep::Box(last_bar*0.5-crystal_wrapping, length_crystal_z/2-photoelectronic-crystal_wrapping, size_posi_crystal*0.5-crystal_wrapping), mat_BGO); + bar_s1.setVisAttributes(theDetector, "EcalBarrelVis"); + bar_s1.setSensitiveDetector(sens); + + for(int ibar0=0;ibar0<2*Nbar_z+1;ibar0++){ + if( (ibar0 == 0) || (ibar0 == 2*Nbar_z)){ + dd4hep::Volume hardware_s1("hardware_s1", dd4hep::Box(last_bar*0.5, length_crystal_z/2, size_posi_crystal*0.5), air); + hardware_s1.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::Volume crystal_s1("crystal_s1", dd4hep::Box(last_bar*0.5, length_crystal_z/2-photoelectronic, size_posi_crystal*0.5), mat_ESR); + crystal_s1.setVisAttributes(theDetector, "CyanVis"); + + dd4hep::PlacedVolume plv_bar0 = crystal_s1.placeVolume(bar_s1, Position(0, 0, 0)); + std::string barname0 = "CrystalBar_positive_s1_"+std::to_string(ibar0); + dd4hep::DetElement bardet0(sd, barname0, detid); + bardet0.setPlacement(plv_bar0); + + dd4hep::PlacedVolume plv_sipm4 = crystal_s1.placeVolume(sipm_s1, Position(0, -length_crystal_z/2+photoelectronic+crystal_wrapping/2, -photoelectronic_width/2)); + std::string sipmname4 = "SiPM_positive_s12_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet4(sd, sipmname4, detid); + sipmdet4.setPlacement(plv_sipm4); + + dd4hep::PlacedVolume plv_sipm5 = crystal_s1.placeVolume(sipm_s1, Position(0, length_crystal_z/2-photoelectronic-crystal_wrapping/2, photoelectronic_width/2)); + std::string sipmname5 = "SiPM_positive_s13_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet5(sd, sipmname5, detid); + sipmdet5.setPlacement(plv_sipm5); + + dd4hep::PlacedVolume plv_sipm6 = crystal_s1.placeVolume(sipm_s1, Position(0, -length_crystal_z/2+photoelectronic+crystal_wrapping/2, photoelectronic_width/2)); + std::string sipmname6 = "SiPM_positive_s14_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet6(sd, sipmname6, detid); + sipmdet6.setPlacement(plv_sipm6); + + dd4hep::PlacedVolume plv_sipm7 = crystal_s1.placeVolume(sipm_s1, Position(0, length_crystal_z/2-photoelectronic-crystal_wrapping/2, -photoelectronic_width/2)); + std::string sipmname7 = "SiPM_positive_s15_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet7(sd, sipmname7, detid); + sipmdet7.setPlacement(plv_sipm7); + + dd4hep::PlacedVolume plv_sipm0 = hardware_s1.placeVolume(sipm_s0, Position(0, -length_crystal_z/2+photoelectronic/2, -photoelectronic_width/2)); + std::string sipmname0 = "SiPM_positive_s4_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet0(sd, sipmname0, detid); + sipmdet0.setPlacement(plv_sipm0); + + dd4hep::PlacedVolume plv_sipm1 = hardware_s1.placeVolume(sipm_s0, Position(0, length_crystal_z/2-photoelectronic/2, photoelectronic_width/2)); + std::string sipmname1 = "SiPM_positive_s5_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet1(sd, sipmname1, detid); + sipmdet1.setPlacement(plv_sipm1); + + dd4hep::PlacedVolume plv_sipm2 = hardware_s1.placeVolume(sipm_s0, Position(0, -length_crystal_z/2+photoelectronic/2, photoelectronic_width/2)); + std::string sipmname2 = "SiPM_positive_s6_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet2(sd, sipmname2, detid); + sipmdet2.setPlacement(plv_sipm2); + + dd4hep::PlacedVolume plv_sipm3 = hardware_s1.placeVolume(sipm_s0, Position(0, length_crystal_z/2-photoelectronic/2, -photoelectronic_width/2)); + std::string sipmname3 = "SiPM_positive_s7_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet3(sd, sipmname3, detid); + sipmdet3.setPlacement(plv_sipm3); + + dd4hep::PlacedVolume plv_cry0 = hardware_s1.placeVolume(crystal_s1, Position(0, 0, 0)); + std::string cryname0 = "Crystal_positive_s1_"+std::to_string(ibar0); + dd4hep::DetElement crydet0(sd, cryname0, detid); + crydet0.setPlacement(plv_cry0); + + dd4hep::PlacedVolume plv_hard0; + if(ibar0==0){ + plv_hard0 = block.placeVolume(hardware_s1, Position(0.5*width_crystal + (Nbar_z-1)*width_crystal + 0.5*last_bar, 0, 0)); + } + else{ + plv_hard0 = block.placeVolume(hardware_s1, Position(-0.5*width_crystal - (Nbar_z-1)*width_crystal - 0.5*last_bar, 0, 0)); + } + plv_hard0.addPhysVolID("slayer",1).addPhysVolID("bar",ibar0); + std::string hardname0 = "Hardware_positive_s1_"+std::to_string(ibar0); + dd4hep::DetElement harddet0(sd, hardname0, detid); + harddet0.setPlacement(plv_hard0); + } + else{ + dd4hep::Volume hardware_s0("hardware_s0", dd4hep::Box(width_crystal*0.5, length_crystal_z/2, size_posi_crystal*0.5), air); + hardware_s0.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::Volume crystal_s0("crystal_s0", dd4hep::Box(width_crystal*0.5, length_crystal_z/2-photoelectronic, size_posi_crystal*0.5), mat_ESR); + crystal_s0.setVisAttributes(theDetector, "CyanVis"); + + dd4hep::PlacedVolume plv_bar0 = crystal_s0.placeVolume(bar_s0, Position(0, 0, 0)); + std::string barname0 = "CrystalBar_positive_s1_"+std::to_string(ibar0); + dd4hep::DetElement bardet0(sd, barname0, detid); + bardet0.setPlacement(plv_bar0); + + dd4hep::PlacedVolume plv_sipm4 = crystal_s0.placeVolume(sipm_s1, Position(0, -length_crystal_z/2+photoelectronic+crystal_wrapping/2, -photoelectronic_width/2)); + std::string sipmname4 = "SiPM_positive_s12_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet4(sd, sipmname4, detid); + sipmdet4.setPlacement(plv_sipm4); + + dd4hep::PlacedVolume plv_sipm5 = crystal_s0.placeVolume(sipm_s1, Position(0, length_crystal_z/2-photoelectronic-crystal_wrapping/2, photoelectronic_width/2)); + std::string sipmname5 = "SiPM_positive_s13_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet5(sd, sipmname5, detid); + sipmdet5.setPlacement(plv_sipm5); + + dd4hep::PlacedVolume plv_sipm6 = crystal_s0.placeVolume(sipm_s1, Position(0, -length_crystal_z/2+photoelectronic+crystal_wrapping/2, photoelectronic_width/2)); + std::string sipmname6 = "SiPM_positive_s14_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet6(sd, sipmname6, detid); + sipmdet6.setPlacement(plv_sipm6); + + dd4hep::PlacedVolume plv_sipm7 = crystal_s0.placeVolume(sipm_s1, Position(0, length_crystal_z/2-photoelectronic-crystal_wrapping/2, -photoelectronic_width/2)); + std::string sipmname7 = "SiPM_positive_s15_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet7(sd, sipmname7, detid); + sipmdet7.setPlacement(plv_sipm7); + + dd4hep::PlacedVolume plv_sipm0 = hardware_s0.placeVolume(sipm_s0, Position(0, -length_crystal_z/2+photoelectronic/2, -photoelectronic_width/2)); + std::string sipmname0 = "SiPM_positive_s4_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet0(sd, sipmname0, detid); + sipmdet0.setPlacement(plv_sipm0); + + dd4hep::PlacedVolume plv_sipm1 = hardware_s0.placeVolume(sipm_s0, Position(0, length_crystal_z/2-photoelectronic/2, photoelectronic_width/2)); + std::string sipmname1 = "SiPM_positive_s5_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet1(sd, sipmname1, detid); + sipmdet1.setPlacement(plv_sipm1); + + dd4hep::PlacedVolume plv_sipm2 = hardware_s0.placeVolume(sipm_s0, Position(0, -length_crystal_z/2+photoelectronic/2, photoelectronic_width/2)); + std::string sipmname2 = "SiPM_positive_s6_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet2(sd, sipmname2, detid); + sipmdet2.setPlacement(plv_sipm2); + + dd4hep::PlacedVolume plv_sipm3 = hardware_s0.placeVolume(sipm_s0, Position(0, length_crystal_z/2-photoelectronic/2, -photoelectronic_width/2)); + std::string sipmname3 = "SiPM_positive_s7_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet3(sd, sipmname3, detid); + sipmdet3.setPlacement(plv_sipm3); + + dd4hep::PlacedVolume plv_cry0 = hardware_s0.placeVolume(crystal_s0, Position(0, 0, 0)); + std::string cryname0 = "Crystal_positive_s1_"+std::to_string(ibar0); + dd4hep::DetElement crydet0(sd, cryname0, detid); + crydet0.setPlacement(plv_cry0); + + dd4hep::PlacedVolume plv_hard0 = block.placeVolume(hardware_s0, Position(length_posi - last_bar - (ibar0-1)*width_crystal - width_crystal/2, 0, 0)); + std::string hardname0 = "Hardware_positive_s1_"+std::to_string(ibar0); + plv_hard0.addPhysVolID("slayer",1).addPhysVolID("bar",ibar0); + dd4hep::DetElement harddet0(sd, hardname0, detid); + harddet0.setPlacement(plv_hard0); + } + } + } + + dd4hep::PlacedVolume plv = subtrap_positive_vol.placeVolume(block, Position(0, 0, 0.5*size_posi_crystal+ilayer*size_posi_crystal-dim_z_p)); + plv.addPhysVolID("dlayer", floor(ilayer/2+1)); + cout<<"*****layer: "<<floor(ilayer/2+1)<<endl; + sd.setPlacement(plv); + } + + // ########################## + // ### negative trapezoid ### + // ########################## + + dd4hep::Volume backPlate1("back_plate_negative", dd4hep::Box(back_plate*15, back_plate*15, back_plate*0.5), mat_PCB); + backPlate1.setVisAttributes(theDetector, "GrayVis"); + std::string blockname1 = "back_plate_negative"; + dd4hep::DetElement sd1(stavedet, blockname1, detid); + dd4hep::PlacedVolume plv1 = subtrap_negative_vol.placeVolume(backPlate1, Position(0, 0, dim_z_n-back_plate*0.5)); + sd1.setPlacement(plv1); + + for(int ilayer=0; ilayer<Nlayers; ilayer=ilayer+1){ + + // Break size + if(ilayer%2 == 0){ + length_nega = dim_x3 - dead_material_r - (ilayer+2)*size_crystal/tan(copper_angle); + length_nega_1 = dim_x3 - dead_material_r - (ilayer+1)*size_crystal/tan(copper_angle); + } + else{ + length_nega = dim_x3 - dead_material_r - (ilayer+1)*size_crystal/tan(copper_angle); + length_nega_1 = dim_x3 - dead_material_r - ilayer*size_crystal/tan(copper_angle); + } + + //Trapezoid in layer + dd4hep::Volume block("block", dd4hep::Trapezoid( dim_x3-ilayer*size_crystal/tan(copper_angle), dim_x3-(ilayer+1)*size_crystal/tan(copper_angle), pZ/2, pZ/2, size_crystal*0.5), air); + block.setVisAttributes(theDetector, "SeeThrough"); + std::string blockname = "Block_nagative_"+std::to_string(ilayer+1); + dd4hep::DetElement sd(stavedet, blockname, detid); + + //Carbon fiber supporting + dd4hep::Volume CarbonFiber0("CarbonFiber0", dd4hep::Box(length_nega+electronics, dead_material*0.5, size_crystal*0.5), mat_CF); //phi + CarbonFiber0.setVisAttributes(theDetector, "GrayVis"); + + dd4hep::PlacedVolume plv_cf0 = block.placeVolume(CarbonFiber0, Position(0, pZ/2-dead_material/2, 0)); + std::string cfname0 = "Deadzone_s4_"+std::to_string(ilayer+1); + dd4hep::DetElement cfdet0(sd, cfname0, detid); + cfdet0.setPlacement(plv_cf0); + + dd4hep::PlacedVolume plv_cf1 = block.placeVolume(CarbonFiber0, Position(0, -pZ/2+dead_material/2, 0)); + std::string cfname1 = "Deadzone_s5_"+std::to_string(ilayer+1); + dd4hep::DetElement cfdet1(sd, cfname1, detid); + cfdet1.setPlacement(plv_cf1); + + if(ilayer%2 != 0) + { + dd4hep::Transform3D transform(dd4hep::RotationX(-90*degree)*dd4hep::RotationZ(180*degree), dd4hep::Position(-length_nega-electronics-dead_material_n/2-((dead_material_n + size_crystal/tan(copper_angle))/2-dead_material_n/2)/2, 0., 0.) ); + dd4hep::PlacedVolume plv_bar2 = block.placeVolume(right, transform); + std::string barname2 = "Deadzone_s2_"+std::to_string(ilayer+1); + dd4hep::DetElement bardet2(sd, barname2, detid); + bardet2.setPlacement(plv_bar2); + + dd4hep::Transform3D transform2(dd4hep::RotationX(90*degree), dd4hep::Position(length_nega+electronics+dead_material_n/2+((dead_material_n + size_crystal/tan(copper_angle))/2-dead_material_n/2)/2, 0., 0.) ); + dd4hep::PlacedVolume plv_bar3= block.placeVolume(right, transform2); + std::string barname3 = "Deadzone_s3_"+std::to_string(ilayer+1); + dd4hep::DetElement bardet3(sd, barname3, detid); + bardet3.setPlacement(plv_bar3); + } + else{ + dd4hep::Transform3D transform(dd4hep::RotationX(-90*degree)*dd4hep::RotationZ(180*degree), dd4hep::Position(-length_nega-electronics-(dead_material_n+size_crystal/tan(copper_angle))/2-((dead_material_n + 2*size_crystal/tan(copper_angle))/2-(dead_material_n+size_crystal/tan(copper_angle))/2)/2, 0., 0.) ); + dd4hep::PlacedVolume plv_bar2 = block.placeVolume(right2, transform); + std::string barname2 = "Deadzone_s2_"+std::to_string(ilayer+1); + dd4hep::DetElement bardet2(sd, barname2, detid); + bardet2.setPlacement(plv_bar2); + + dd4hep::Transform3D transform2(dd4hep::RotationX(90*degree), dd4hep::Position(length_nega+electronics+(dead_material_n+size_crystal/tan(copper_angle))/2+((dead_material_n + 2*size_crystal/tan(copper_angle))/2-(dead_material_n+size_crystal/tan(copper_angle))/2)/2, 0., 0.) ); + dd4hep::PlacedVolume plv_bar3= block.placeVolume(right2, transform2); + std::string barname3 = "Deadzone_s3_"+std::to_string(ilayer+1); + dd4hep::DetElement bardet3(sd, barname3, detid); + bardet3.setPlacement(plv_bar3); + } + + //Electronics + dd4hep::Volume electronics_phi0("electronics_phi0", dd4hep::Box(length_nega+electronics, (electronics-cooling)*0.5, size_crystal*0.5), mat_PCB); //phi + electronics_phi0.setVisAttributes(theDetector, "YellowVis"); + + dd4hep::PlacedVolume plv_elec0 = block.placeVolume(electronics_phi0, Position(0, -length_crystal_z/2-(electronics-cooling)/2, 0)); + std::string elecname0 = "electronics_nega_phi_u_"+std::to_string(ilayer+1); + dd4hep::DetElement elecdet0(sd, elecname0, detid); + elecdet0.setPlacement(plv_elec0); + + dd4hep::PlacedVolume plv_elec1 = block.placeVolume(electronics_phi0, Position(0, length_crystal_z/2+(electronics-cooling)/2, 0)); + std::string elecname1 = "electronics_nega_phi_d_"+std::to_string(ilayer+1); + dd4hep::DetElement elecdet1(sd, elecname1, detid); + elecdet1.setPlacement(plv_elec1); + + dd4hep::Volume electronics_phi_l("electronics_phi_l", dd4hep::Box((electronics-cooling)/2, length_crystal_z/2, size_crystal*0.5), mat_PCB); //phi + electronics_phi_l.setVisAttributes(theDetector, "YellowVis"); + + dd4hep::PlacedVolume plv_elec2 = block.placeVolume(electronics_phi_l, Position(-length_nega-(electronics-cooling)/2, 0, 0)); + std::string elecname2 = "electronics_nega_phi_l_"+std::to_string(ilayer+1); + dd4hep::DetElement elecdet2(sd, elecname2, detid); + elecdet2.setPlacement(plv_elec2); + + dd4hep::PlacedVolume plv_elec3 = block.placeVolume(electronics_phi_l, Position(length_nega+(electronics-cooling)/2, 0, 0)); + std::string elecname3 = "electronics_nega_phi_r_"+std::to_string(ilayer+1); + dd4hep::DetElement elecdet3(sd, elecname3, detid); + elecdet3.setPlacement(plv_elec3); + + //Cooling copper + + dd4hep::Volume copper_phi0("copper_phi0", dd4hep::Box(length_nega+electronics, cooling*0.5, size_crystal*0.5), mat_Cu); //phi + copper_phi0.setVisAttributes(theDetector, "RedVis"); + + dd4hep::PlacedVolume plv_copper0 = block.placeVolume(copper_phi0, Position(0, -length_crystal_z/2-electronics+cooling/2, 0)); + std::string coppername0 = "cooling_nega_phi_u_"+std::to_string(ilayer+1); + dd4hep::DetElement copperdet0(sd, coppername0, detid); + copperdet0.setPlacement(plv_copper0); + + dd4hep::PlacedVolume plv_copper1 = block.placeVolume(copper_phi0, Position(0, length_crystal_z/2+electronics-cooling/2, 0)); + std::string coppername1 = "cooling_nega_phi_d_"+std::to_string(ilayer+1); + dd4hep::DetElement copperdet1(sd, coppername1, detid); + copperdet1.setPlacement(plv_copper1); + + dd4hep::Volume copper_phi_l("copper_phi_l", dd4hep::Box(cooling*0.5, length_crystal_z/2, size_crystal*0.5), mat_Cu); //phi + copper_phi_l.setVisAttributes(theDetector, "RedVis"); + + dd4hep::PlacedVolume plv_copper2 = block.placeVolume(copper_phi_l, Position(-length_nega-electronics+cooling/2, 0, 0)); + std::string coppername2 = "cooling_nega_phi_l_"+std::to_string(ilayer+1); + dd4hep::DetElement copperdet2(sd, coppername2, detid); + copperdet2.setPlacement(plv_copper2); + + dd4hep::PlacedVolume plv_copper3 = block.placeVolume(copper_phi_l, Position(length_nega+electronics-cooling/2, 0, 0)); + std::string coppername3 = "cooling_nega_phi_r_"+std::to_string(ilayer+1); + dd4hep::DetElement copperdet3(sd, coppername3, detid); + copperdet3.setPlacement(plv_copper3); + + // ################################### + // ####### Phi direction place ####### + // ################################### + + if(ilayer%2==0){ + Tot_Phi = Tot_Phi + Nbar_phi; + Tot_length_Phi_nega = Tot_length_Phi_nega + (length_nega-photoelectronic-crystal_wrapping)*2*(length_crystal_z-Nbar_phi*crystal_wrapping*2)*(size_crystal*0.5-crystal_wrapping)*2; + + cout<<"length_crystal_phi "<<(dim_x3 - dead_material_r-photoelectronic-crystal_wrapping)*2 <<" "<<size_crystal/tan(copper_angle)*2<<endl; + + dd4hep::Volume sipm_s0("sipm_s0", dd4hep::Box(photoelectronic/2, photoelectronic_width/2, photoelectronic_width/2), mat_Si); + sipm_s0.setVisAttributes(theDetector, "BlueVis"); + + dd4hep::Volume sipm_s1("sipm_s1", dd4hep::Box(crystal_wrapping/2, photoelectronic_width/2, photoelectronic_width/2), mat_Si); + sipm_s1.setVisAttributes(theDetector, "BlueVis"); + + last_bar_z = length_crystal_z - (Nbar_phi-1)*width_crystal; + + dd4hep::Volume bar_s0("bar_s0", dd4hep::Box(length_nega-photoelectronic-crystal_wrapping, width_crystal*0.5-crystal_wrapping, size_crystal*0.5-crystal_wrapping), mat_BGO); + bar_s0.setVisAttributes(theDetector, "EcalBarrelVis"); + bar_s0.setSensitiveDetector(sens); + + dd4hep::Volume bar_s1("bar_s1", dd4hep::Box(length_nega-photoelectronic-crystal_wrapping, last_bar_z*0.5-crystal_wrapping, size_crystal*0.5-crystal_wrapping), mat_BGO); + bar_s1.setVisAttributes(theDetector, "EcalBarrelVis"); + bar_s1.setSensitiveDetector(sens); + + for(int ibar0=0;ibar0<Nbar_phi;ibar0++){ + if(ibar0 == (Nbar_phi-1)){ + + dd4hep::Volume hardware_s1("hardware_s1", dd4hep::Box(length_nega, last_bar_z*0.5, size_crystal*0.5), air); + hardware_s1.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::Volume crystal_s1("crystal_s1", dd4hep::Box(length_nega-photoelectronic, last_bar_z*0.5, size_crystal*0.5), mat_ESR); + crystal_s1.setVisAttributes(theDetector, "CyanVis"); + + dd4hep::PlacedVolume plv_bar0 = crystal_s1.placeVolume(bar_s1, Position(0, 0, 0)); + std::string barname0 = "CrystalBar_negative_s0_"+std::to_string(ibar0); + dd4hep::DetElement bardet0(sd, barname0, detid); + bardet0.setPlacement(plv_bar0); + + dd4hep::PlacedVolume plv_sipm4 = crystal_s1.placeVolume(sipm_s1, Position(-length_nega+photoelectronic+crystal_wrapping/2, 0, -photoelectronic_width/2)); + std::string sipmname4 = "SiPM_negative_s8_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet4(sd, sipmname4, detid); + sipmdet4.setPlacement(plv_sipm4); + + dd4hep::PlacedVolume plv_sipm5 = crystal_s1.placeVolume(sipm_s1, Position(length_nega-photoelectronic-crystal_wrapping/2, 0, photoelectronic_width/2)); + std::string sipmname5 = "SiPM_negative_s9_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet5(sd, sipmname5, detid); + sipmdet5.setPlacement(plv_sipm5); + + dd4hep::PlacedVolume plv_sipm6 = crystal_s1.placeVolume(sipm_s1, Position(-length_nega+photoelectronic+crystal_wrapping/2, 0, photoelectronic_width/2)); + std::string sipmname6 = "SiPM_negative_s10_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet6(sd, sipmname6, detid); + sipmdet6.setPlacement(plv_sipm6); + + dd4hep::PlacedVolume plv_sipm7 = crystal_s1.placeVolume(sipm_s1, Position(length_nega-photoelectronic-crystal_wrapping/2, 0, -photoelectronic_width/2)); + std::string sipmname7 = "SiPM_negative_s11_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet7(sd, sipmname7, detid); + sipmdet7.setPlacement(plv_sipm7); + + dd4hep::PlacedVolume plv_sipm0 = hardware_s1.placeVolume(sipm_s0, Position(-length_nega+photoelectronic/2, 0, -photoelectronic_width/2)); + std::string sipmname0 = "SiPM_negative_s0_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet0(sd, sipmname0, detid); + sipmdet0.setPlacement(plv_sipm0); + + dd4hep::PlacedVolume plv_sipm1 = hardware_s1.placeVolume(sipm_s0, Position(length_nega-photoelectronic/2, 0, photoelectronic_width/2)); + std::string sipmname1 = "SiPM_negative_s1_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet1(sd, sipmname1, detid); + sipmdet1.setPlacement(plv_sipm1); + + dd4hep::PlacedVolume plv_sipm2 = hardware_s1.placeVolume(sipm_s0, Position(-length_nega+photoelectronic/2, 0, photoelectronic_width/2)); + std::string sipmname2 = "SiPM_negative_s2_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet2(sd, sipmname2, detid); + sipmdet2.setPlacement(plv_sipm2); + + dd4hep::PlacedVolume plv_sipm3 = hardware_s1.placeVolume(sipm_s0, Position(length_nega-photoelectronic/2, 0, -photoelectronic_width/2)); + std::string sipmname3 = "SiPM_negative_s3_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet3(sd, sipmname3, detid); + sipmdet3.setPlacement(plv_sipm3); + + dd4hep::PlacedVolume plv_cry0 = hardware_s1.placeVolume(crystal_s1, Position(0, 0, 0)); + std::string cryname0 = "Crystal_negative_s0_"+std::to_string(ibar0); + dd4hep::DetElement crydet0(sd, cryname0, detid); + crydet0.setPlacement(plv_cry0); + + dd4hep::PlacedVolume plv_hard0 = block.placeVolume(hardware_s1, Position(0, -length_crystal_z/2+last_bar_z*0.5, 0)); + plv_hard0.addPhysVolID("slayer",0).addPhysVolID("bar",ibar0); + std::string hardname0 = "Hardware_negative_s0_"+std::to_string(ibar0); + dd4hep::DetElement harddet0(sd, hardname0, detid); + harddet0.setPlacement(plv_hard0); + } + else{ + dd4hep::Volume hardware_s0("hardware_s0", dd4hep::Box(length_nega, width_crystal*0.5, size_crystal*0.5), air); + hardware_s0.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::Volume crystal_s0("crystal_s0", dd4hep::Box(length_nega-photoelectronic, width_crystal*0.5, size_crystal*0.5), mat_ESR); + crystal_s0.setVisAttributes(theDetector, "CyanVis"); + + dd4hep::PlacedVolume plv_bar0 = crystal_s0.placeVolume(bar_s0, Position(0, 0, 0)); + std::string barname0 = "CrystalBar_negative_s0_"+std::to_string(ibar0); + dd4hep::DetElement bardet0(sd, barname0, detid); + bardet0.setPlacement(plv_bar0); + + dd4hep::PlacedVolume plv_sipm4 = crystal_s0.placeVolume(sipm_s1, Position(-length_nega+photoelectronic+crystal_wrapping/2, 0, -photoelectronic_width/2)); + std::string sipmname4 = "SiPM_negative_s8_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet4(sd, sipmname4, detid); + sipmdet4.setPlacement(plv_sipm4); + + dd4hep::PlacedVolume plv_sipm5 = crystal_s0.placeVolume(sipm_s1, Position(length_nega-photoelectronic-crystal_wrapping/2, 0, photoelectronic_width/2)); + std::string sipmname5 = "SiPM_negative_s9_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet5(sd, sipmname5, detid); + sipmdet5.setPlacement(plv_sipm5); + + dd4hep::PlacedVolume plv_sipm6 = crystal_s0.placeVolume(sipm_s1, Position(-length_nega+photoelectronic+crystal_wrapping/2, 0, photoelectronic_width/2)); + std::string sipmname6 = "SiPM_negative_s10_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet6(sd, sipmname6, detid); + sipmdet6.setPlacement(plv_sipm6); + + dd4hep::PlacedVolume plv_sipm7 = crystal_s0.placeVolume(sipm_s1, Position(length_nega-photoelectronic-crystal_wrapping/2, 0, -photoelectronic_width/2)); + std::string sipmname7 = "SiPM_negative_s11_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet7(sd, sipmname7, detid); + sipmdet7.setPlacement(plv_sipm7); + + dd4hep::PlacedVolume plv_sipm0 = hardware_s0.placeVolume(sipm_s0, Position(-length_nega+photoelectronic/2, 0, -photoelectronic_width/2)); + std::string sipmname0 = "SiPM_negative_s0_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet0(sd, sipmname0, detid); + sipmdet0.setPlacement(plv_sipm0); + + dd4hep::PlacedVolume plv_sipm1 = hardware_s0.placeVolume(sipm_s0, Position(length_nega-photoelectronic/2, 0, photoelectronic_width/2)); + std::string sipmname1 = "SiPM_negative_s1_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet1(sd, sipmname1, detid); + sipmdet1.setPlacement(plv_sipm1); + + dd4hep::PlacedVolume plv_sipm2 = hardware_s0.placeVolume(sipm_s0, Position(-length_nega+photoelectronic/2, 0, photoelectronic_width/2)); + std::string sipmname2 = "SiPM_negative_s2_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet2(sd, sipmname2, detid); + sipmdet2.setPlacement(plv_sipm2); + + dd4hep::PlacedVolume plv_sipm3 = hardware_s0.placeVolume(sipm_s0, Position(length_nega-photoelectronic/2, 0, -photoelectronic_width/2)); + std::string sipmname3 = "SiPM_negative_s3_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet3(sd, sipmname3, detid); + sipmdet3.setPlacement(plv_sipm3); + + dd4hep::PlacedVolume plv_cry0 = hardware_s0.placeVolume(crystal_s0, Position(0, 0, 0)); + std::string cryname0 = "Crystal_negative_s0_"+std::to_string(ibar0); + dd4hep::DetElement crydet0(sd, cryname0, detid); + crydet0.setPlacement(plv_cry0); + + dd4hep::PlacedVolume plv_hard0 = block.placeVolume(hardware_s0, Position(0, length_crystal_z/2-(2*ibar0+1)*width_crystal/2, 0)); + plv_hard0.addPhysVolID("slayer",0).addPhysVolID("bar",ibar0); + std::string hardname0 = "Hardware_negative_s0_"+std::to_string(ibar0); + dd4hep::DetElement harddet0(sd, hardname0, detid); + harddet0.setPlacement(plv_hard0); + } + } + } + + // ################################# + // ####### Z direction place ####### + // ################################# + + else{ + + Nbar_z = int((length_nega-0.5*width_crystal)/width_crystal); + last_bar = length_nega-0.5*width_crystal - (Nbar_z-1)*width_crystal; + + Tot_Z = Tot_Z + 2*Nbar_z+1; + Tot_length_Z_nega = Tot_length_Z_nega + (2*length_nega-(2*Nbar_z+1)*crystal_wrapping*2)*(size_crystal*0.5-crystal_wrapping)*2*(length_crystal_z/2-photoelectronic-crystal_wrapping)*2; + + cout<<"layer: "<< ilayer+1 <<" Nbar_z: "<< 2*Nbar_z+1 <<endl; + cout<<"length_crystal_z "<<(length_crystal_z/2-photoelectronic-crystal_wrapping)*2 <<endl; + + dd4hep::Volume sipm_s0("sipm_s0", dd4hep::Box(photoelectronic_width/2, photoelectronic/2, photoelectronic_width/2), mat_Si); + sipm_s0.setVisAttributes(theDetector, "BlueVis"); + + dd4hep::Volume sipm_s1("sipm_s1", dd4hep::Box(photoelectronic_width/2, crystal_wrapping/2, photoelectronic_width/2), mat_Si); + sipm_s1.setVisAttributes(theDetector, "BlueVis"); + + dd4hep::Volume bar_s0("bar_s0", dd4hep::Box(width_crystal*0.5-crystal_wrapping, length_crystal_z/2-photoelectronic-crystal_wrapping, size_crystal*0.5-crystal_wrapping), mat_BGO); + bar_s0.setVisAttributes(theDetector, "EcalBarrelVis"); + bar_s0.setSensitiveDetector(sens); + + dd4hep::Volume bar_s1("bar_s1", dd4hep::Box(last_bar*0.5-crystal_wrapping, length_crystal_z/2-photoelectronic-crystal_wrapping, size_crystal*0.5-crystal_wrapping), mat_BGO); + bar_s1.setVisAttributes(theDetector, "EcalBarrelVis"); + bar_s1.setSensitiveDetector(sens); + + for(int ibar0=0;ibar0<2*Nbar_z+1;ibar0++){ + if( (ibar0 == 0) || (ibar0 == 2*Nbar_z)){ + + dd4hep::Volume hardware_s1("hardware_s1", dd4hep::Box(last_bar*0.5, length_crystal_z/2, size_crystal*0.5), air); + hardware_s1.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::Volume crystal_s1("crystal_s1", dd4hep::Box(last_bar*0.5, length_crystal_z/2-photoelectronic, size_crystal*0.5), mat_ESR); + crystal_s1.setVisAttributes(theDetector, "CyanVis"); + + dd4hep::PlacedVolume plv_bar0 = crystal_s1.placeVolume(bar_s1, Position(0, 0, 0)); + std::string barname0 = "CrystalBar_negative_s1_"+std::to_string(ibar0); + dd4hep::DetElement bardet0(sd, barname0, detid); + bardet0.setPlacement(plv_bar0); + + dd4hep::PlacedVolume plv_sipm4 = crystal_s1.placeVolume(sipm_s1, Position(0, -length_crystal_z/2+photoelectronic+crystal_wrapping/2, -photoelectronic_width/2)); + std::string sipmname4 = "SiPM_negative_s12_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet4(sd, sipmname4, detid); + sipmdet4.setPlacement(plv_sipm4); + + dd4hep::PlacedVolume plv_sipm5 = crystal_s1.placeVolume(sipm_s1, Position(0, length_crystal_z/2-photoelectronic-crystal_wrapping/2, photoelectronic_width/2)); + std::string sipmname5 = "SiPM_negative_s13_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet5(sd, sipmname5, detid); + sipmdet5.setPlacement(plv_sipm5); + + dd4hep::PlacedVolume plv_sipm6 = crystal_s1.placeVolume(sipm_s1, Position(0, -length_crystal_z/2+photoelectronic+crystal_wrapping/2, photoelectronic_width/2)); + std::string sipmname6 = "SiPM_negative_s14_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet6(sd, sipmname6, detid); + sipmdet6.setPlacement(plv_sipm6); + + dd4hep::PlacedVolume plv_sipm7 = crystal_s1.placeVolume(sipm_s1, Position(0, length_crystal_z/2-photoelectronic-crystal_wrapping/2, -photoelectronic_width/2)); + std::string sipmname7 = "SiPM_negative_s15_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet7(sd, sipmname7, detid); + sipmdet7.setPlacement(plv_sipm7); + + dd4hep::PlacedVolume plv_sipm0 = hardware_s1.placeVolume(sipm_s0, Position(0, -length_crystal_z/2+photoelectronic/2, -photoelectronic_width/2)); + std::string sipmname0 = "SiPM_negative_s4_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet0(sd, sipmname0, detid); + sipmdet0.setPlacement(plv_sipm0); + + dd4hep::PlacedVolume plv_sipm1 = hardware_s1.placeVolume(sipm_s0, Position(0, length_crystal_z/2-photoelectronic/2, photoelectronic_width/2)); + std::string sipmname1 = "SiPM_negative_s5_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet1(sd, sipmname1, detid); + sipmdet1.setPlacement(plv_sipm1); + + dd4hep::PlacedVolume plv_sipm2 = hardware_s1.placeVolume(sipm_s0, Position(0, -length_crystal_z/2+photoelectronic/2, photoelectronic_width/2)); + std::string sipmname2 = "SiPM_negative_s6_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet2(sd, sipmname2, detid); + sipmdet2.setPlacement(plv_sipm2); + + dd4hep::PlacedVolume plv_sipm3 = hardware_s1.placeVolume(sipm_s0, Position(0, length_crystal_z/2-photoelectronic/2, -photoelectronic_width/2)); + std::string sipmname3 = "SiPM_negative_s7_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet3(sd, sipmname3, detid); + sipmdet3.setPlacement(plv_sipm3); + + dd4hep::PlacedVolume plv_cry0 = hardware_s1.placeVolume(crystal_s1, Position(0, 0, 0)); + std::string cryname0 = "Crystal_negative_s1_"+std::to_string(ibar0); + dd4hep::DetElement crydet0(sd, cryname0, detid); + crydet0.setPlacement(plv_cry0); + + dd4hep::PlacedVolume plv_hard0; + if(ibar0==0){ + plv_hard0 = block.placeVolume(hardware_s1, Position(length_nega - 0.5*last_bar, 0, 0)); + } + else{ + plv_hard0 = block.placeVolume(hardware_s1, Position(-length_nega + 0.5*last_bar, 0, 0)); + } + plv_hard0.addPhysVolID("slayer",1).addPhysVolID("bar",ibar0); + std::string hardname0 = "Hardware_negative_s1_"+std::to_string(ibar0); + dd4hep::DetElement harddet0(sd, hardname0, detid); + harddet0.setPlacement(plv_hard0); + } + else{ + + dd4hep::Volume hardware_s0("hardware_s0", dd4hep::Box(width_crystal*0.5, length_crystal_z/2, size_crystal*0.5), air); + hardware_s0.setVisAttributes(theDetector, "SeeThrough"); + + dd4hep::Volume crystal_s0("crystal_s0", dd4hep::Box(width_crystal*0.5, length_crystal_z/2-photoelectronic, size_crystal*0.5), mat_ESR); + crystal_s0.setVisAttributes(theDetector, "CyanVis"); + + dd4hep::PlacedVolume plv_bar0 = crystal_s0.placeVolume(bar_s0, Position(0, 0, 0)); + std::string barname0 = "CrystalBar_negative_s1_"+std::to_string(ibar0); + dd4hep::DetElement bardet0(sd, barname0, detid); + bardet0.setPlacement(plv_bar0); + + dd4hep::PlacedVolume plv_sipm4 = crystal_s0.placeVolume(sipm_s1, Position(0, -length_crystal_z/2+photoelectronic+crystal_wrapping/2, -photoelectronic_width/2)); + std::string sipmname4 = "SiPM_negative_s12_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet4(sd, sipmname4, detid); + sipmdet4.setPlacement(plv_sipm4); + + dd4hep::PlacedVolume plv_sipm5 = crystal_s0.placeVolume(sipm_s1, Position(0, length_crystal_z/2-photoelectronic-crystal_wrapping/2, photoelectronic_width/2)); + std::string sipmname5 = "SiPM_negative_s13_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet5(sd, sipmname5, detid); + sipmdet5.setPlacement(plv_sipm5); + + dd4hep::PlacedVolume plv_sipm6 = crystal_s0.placeVolume(sipm_s1, Position(0, -length_crystal_z/2+photoelectronic+crystal_wrapping/2, photoelectronic_width/2)); + std::string sipmname6 = "SiPM_negative_s14_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet6(sd, sipmname6, detid); + sipmdet6.setPlacement(plv_sipm6); + + dd4hep::PlacedVolume plv_sipm7 = crystal_s0.placeVolume(sipm_s1, Position(0, length_crystal_z/2-photoelectronic-crystal_wrapping/2, -photoelectronic_width/2)); + std::string sipmname7 = "SiPM_negative_s15_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet7(sd, sipmname7, detid); + sipmdet7.setPlacement(plv_sipm7); + + dd4hep::PlacedVolume plv_sipm0 = hardware_s0.placeVolume(sipm_s0, Position(0, -length_crystal_z/2+photoelectronic/2, -photoelectronic_width/2)); + std::string sipmname0 = "SiPM_negative_s4_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet0(sd, sipmname0, detid); + sipmdet0.setPlacement(plv_sipm0); + + dd4hep::PlacedVolume plv_sipm1 = hardware_s0.placeVolume(sipm_s0, Position(0, length_crystal_z/2-photoelectronic/2, photoelectronic_width/2)); + std::string sipmname1 = "SiPM_negative_s5_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet1(sd, sipmname1, detid); + sipmdet1.setPlacement(plv_sipm1); + + dd4hep::PlacedVolume plv_sipm2 = hardware_s0.placeVolume(sipm_s0, Position(0, -length_crystal_z/2+photoelectronic/2, photoelectronic_width/2)); + std::string sipmname2 = "SiPM_negative_s6_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet2(sd, sipmname2, detid); + sipmdet2.setPlacement(plv_sipm2); + + dd4hep::PlacedVolume plv_sipm3 = hardware_s0.placeVolume(sipm_s0, Position(0, length_crystal_z/2-photoelectronic/2, -photoelectronic_width/2)); + std::string sipmname3 = "SiPM_negative_s7_"+std::to_string(ibar0); + dd4hep::DetElement sipmdet3(sd, sipmname3, detid); + sipmdet3.setPlacement(plv_sipm3); + + dd4hep::PlacedVolume plv_cry0 = hardware_s0.placeVolume(crystal_s0, Position(0, 0, 0)); + std::string cryname0 = "Crystal_negative_s1_"+std::to_string(ibar0); + dd4hep::DetElement crydet0(sd, cryname0, detid); + crydet0.setPlacement(plv_cry0); + + dd4hep::PlacedVolume plv_hard0 = block.placeVolume(hardware_s0, Position(length_nega - last_bar - (ibar0-1)*width_crystal - width_crystal/2, 0, 0)); + plv_hard0.addPhysVolID("slayer",1).addPhysVolID("bar",ibar0); + std::string hardname0 = "Hardware_negative_s1_"+std::to_string(ibar0); + dd4hep::DetElement harddet0(sd, hardname0, detid); + harddet0.setPlacement(plv_hard0); + } + } + } + + dd4hep::PlacedVolume plv = subtrap_negative_vol.placeVolume(block, Position(0, 0, 0.5*size_crystal+ilayer*size_crystal-dim_z_n)); + plv.addPhysVolID("dlayer", floor(ilayer/2+1)); + cout<<"*****layer: "<<floor(ilayer/2+1)<<endl; + sd.setPlacement(plv); + } + + + cout<<"Tot_Phi: "<<Tot_Phi<<" Tot_Z: "<<Tot_Z<<endl; + cout<<"Tot_Phi: "<<Tot_Phi*15*16<<" Tot_Z: "<<Tot_Z*15*16<<endl; + + // ########################### + // ### Z modules placement ### + // ########################### + + for(int iz=0; iz<Nblock_z; iz=iz+1){ //1 Nblock_z + dd4hep::PlacedVolume plv = trap_positive_vol.placeVolume(subtrap_positive_vol, Position(0, 0.5*length_z-(2*iz-1)*pZ/2,0) ); + plv.addPhysVolID("stave", iz); + DetElement sd(stavedet, _toString(iz,"stave_posi_%3d"), detid); + sd.setPlacement(plv); + } + + for(int iz=0; iz<Nblock_z; iz=iz+1){ + dd4hep::PlacedVolume plv = trap_negative_vol.placeVolume(subtrap_negative_vol, Position(0, 0.5*length_z-(2*iz-1)*pZ/2,0) ); + plv.addPhysVolID("stave", iz); + DetElement sd(stavedet, _toString(iz,"stave_nega_%3d"), detid); + sd.setPlacement(plv); + } + + // ############################# + // ### phi modules placement ### + // ############################# + + double r0 = radius_inner + height_layer1 + depth_longitudinal_p/2; //Phi-module rotation + double r1 = radius_inner + depth_longitudinal_n/2; + + for(int i=0;i<n_module;i=i+2){ //n_module + double m_rot = angle*i; + double posx = -r0*sin(m_rot); + double posy = r0*cos(m_rot); + dd4hep::Transform3D transform(dd4hep::RotationZ(m_rot)*dd4hep::RotationX(-90*degree), dd4hep::Position(posx, posy, 0.)); + dd4hep::PlacedVolume plv = envelopeVol.placeVolume(trap_positive_vol, transform); + plv.addPhysVolID("module", i); + DetElement sd(ECAL, _toString(i,"trap_posi_%3d"), detid); + sd.setPlacement(plv); + } + + for(int i=1;i<n_module;i=i+2){ + double m_rot = angle*i; + double posx = -r1*sin(m_rot); + double posy = r1*cos(m_rot); + dd4hep::Transform3D transform(dd4hep::RotationZ(m_rot)*dd4hep::RotationX(-90*degree), dd4hep::Position(posx, posy, 0.)); + dd4hep::PlacedVolume plv = envelopeVol.placeVolume(trap_negative_vol, transform); + plv.addPhysVolID("module", i); + DetElement sd(ECAL, _toString(i,"trap_nega_%3d"), detid); + sd.setPlacement(plv); + } + + sens.setType("calorimeter"); + + MYDEBUG("create_detector DONE. "); + return ECAL; +} + +DECLARE_DETELEMENT(LongCrystalBarBarrelCalorimeter32Polygon_v01, create_detector)