diff --git a/Detector/DetCRD/compact/CRD_common_v01/Lumical_o1_v01.xml b/Detector/DetCRD/compact/CRD_common_v01/Lumical_o1_v01.xml index 2d2bc818c5b93009f13385b1269b2f1971a7cd7f..e6023ac239a7997ba5ab2f4dda7111a7ee3b0126 100644 --- a/Detector/DetCRD/compact/CRD_common_v01/Lumical_o1_v01.xml +++ b/Detector/DetCRD/compact/CRD_common_v01/Lumical_o1_v01.xml @@ -44,31 +44,31 @@ </slice> </layer> <layer name = "Flange"> - <slice type="Tubs" rmin="19.5*mm" rmax="100*mm" z="30*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> + <slice type="Tubs" rmin="17.5*mm" rmax="100*mm" z="30*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="FlangeVis"> <position x="0" y="0*mm" z="685*mm"/> </slice> - <slice type="Tubs" rmin="19.5*mm" rmax="95*mm" z="20*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> + <slice type="Tubs" rmin="17.5*mm" rmax="95*mm" z="20*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> <position x="0" y="0*mm" z="710*mm"/> </slice> - <slice type="Tubs" rmin="19.5*mm" rmax="98*mm" z="20*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> + <slice type="Tubs" rmin="17.5*mm" rmax="98*mm" z="20*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> <position x="0" y="0*mm" z="730*mm"/> </slice> - <slice type="Tubs" rmin="19.5*mm" rmax="95*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> + <slice type="Tubs" rmin="17.5*mm" rmax="95*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> <position x="0" y="0*mm" z="750*mm"/> </slice> - <slice type="Tubs" rmin="19.5*mm" rmax="95*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> + <slice type="Tubs" rmin="17.5*mm" rmax="95*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> <position x="0" y="0*mm" z="755*mm"/> </slice> - <slice type="Tubs" rmin="19.5*mm" rmax="95*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> + <slice type="Tubs" rmin="17.5*mm" rmax="95*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> <position x="0" y="0*mm" z="760*mm"/> </slice> - <slice type="Tubs" rmin="19.5*mm" rmax="95*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> + <slice type="Tubs" rmin="17.5*mm" rmax="95*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> <position x="0" y="0*mm" z="765*mm"/> </slice> - <slice type="Tubs" rmin="19.5*mm" rmax="95*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> + <slice type="Tubs" rmin="17.5*mm" rmax="95*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> <position x="0" y="0*mm" z="770*mm"/> </slice> - <slice type="Tubs" rmin="19.5*mm" rmax="90*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> + <slice type="Tubs" rmin="17.5*mm" rmax="95*mm" z="1*mm" phi1="0*deg" phi2="360*deg" material="stainless_steel" vis="LumicalFlangeVis"> <position x="0" y="0*mm" z="775*mm"/> </slice> </layer> @@ -84,7 +84,13 @@ <rotation x="0" y="0" z="0" /> </slice> </layer> - + <layer name = "LYSO_out_W"> + <slice dx = "10*mm" dy="10*mm" dz="200*mm" material="G4_W" vis="LumicalFlangeVis" + sensitive = "no" limits = "5*mm"> + <position x="0" y="-12" z="1000*mm"/> + <rotation x="0" y="0" z="0"/> + </slice> + </layer> </detector> @@ -98,7 +104,6 @@ <segmentation name="RPCgrid_Si_2nd" type="CartesianGridXY" key_value="2" grid_size_x="0.1*mm" grid_size_y="0.1*mm" /> <segmentation name="RPCgrid_LYSO_1st" type="CartesianGridXY" key_value="3" grid_size_x="3*mm" grid_size_y="3*mm" /> <segmentation name="RPCgrid_LYSO_2nd" type="CartesianGridXY" key_value="5" grid_size_x="10*mm" grid_size_y="10*mm" /> - </segmentation> @@ -107,11 +112,10 @@ <hits_collection name="LumicalCollection" key="module" key_value="2"/> <hits_collection name="LumicalCollection" key="module" key_value="3"/> <hits_collection name="LumicalCollection" key="module" key_value="5"/> - </hits_collections> <id>system:5,side:-2,stave:-2,module:6,layer:8,slice:8,x:32:-16,y:-16</id> </readout> </readouts> -</lccdd> +</lccdd> \ No newline at end of file diff --git a/Detector/DetCRD/src/Calorimeter/Lumical_v01_geo.cpp b/Detector/DetCRD/src/Calorimeter/Lumical_v01_geo.cpp index 9c72bcdc75e70ac6ca9a22f1c609033e27b0461c..0e5ca69680263dbcb1db524cd24c2aab99f9d306 100644 --- a/Detector/DetCRD/src/Calorimeter/Lumical_v01_geo.cpp +++ b/Detector/DetCRD/src/Calorimeter/Lumical_v01_geo.cpp @@ -15,7 +15,7 @@ #include <vector> #include <iostream> #include "XML/Layering.h" - +#include "DD4hep/Printout.h" using namespace std; using namespace dd4hep; @@ -51,10 +51,13 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s int loop = 0; xml_coll_t LYSO_layer(x_det,_U(layer)); xml_coll_t second_LYSO_layer(x_det,_U(layer)); + xml_coll_t W_LYSO_layer(x_det,_U(layer)); for(xml_coll_t c(x_det,_U(layer));c;c++){ if(loop == 3){LYSO_layer = c;} else if(loop == 4){second_LYSO_layer=c; - break;} + } + else if(loop ==5){W_LYSO_layer =c; + break;} loop++; } //get the define information of the first LYSO crystal @@ -178,6 +181,11 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s //loop in order to build symmetry geo for(int kz=1;kz>=-1;kz-=2){ + dd4hep::PrintLevel printLevel = dd4hep::ERROR; + if (x_det.hasAttr(_Unicode(printLevel))) { + printLevel = dd4hep::printLevel(x_det.attr<std::string>(_Unicode(printLevel))); + } + ///////////////////////////////////////////////////////////////// //build Disk and flange std::vector<double> cellSizeVector = seg.cellDimensions( encoder.getValue() ); //Assume uniform cell sizes, provide dummy cellID @@ -211,7 +219,8 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s PlacedVolume slice_phv = envelope.placeVolume(slice_vol,Position(0*mm,0*mm,kz*x_slice.position().z())); slice_phv.addPhysVolID("side",kz).addPhysVolID("module",4).addPhysVolID("layer",0 ).addPhysVolID("slice",layer_num); if(ky==1 && kz==1){ - std::cout<<"Flange"<<layer_num<<":"<<"zStart = "<<x_slice.position().z()-x_slice.z()/2 << " zEnd = "<<x_slice.position().z()+x_slice.z()/2 <<" rmin ="<<x_slice.rmin()<<" rmax = "<<x_slice.rmax()<<"position of circle center = "<<x_slice.position().x()<<" "<<x_slice.position().y()<<" material = "<<x_slice.materialStr()<<"\n"; + + dd4hep::printout(dd4hep::INFO, "Construct", "Flange ->layer: r0 = %f r1 = %f mat = %s", x_slice.rmin()/dd4hep::mm, x_slice.rmax()/dd4hep::mm,"stainless_steel"); } slice.setPlacement(slice_phv); @@ -234,7 +243,8 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s slice_phv.addPhysVolID("side",kz).addPhysVolID("stave",ky).addPhysVolID("module",l+1).addPhysVolID("layer",layer_num ).addPhysVolID("slice",slice_number); if(ky==1 && kz==1){ - std::cout<<"Disk_Box:"<<"zStart = "<<x_slice.position().z()-x_slice.dz()/2 << " zEnd = "<<x_slice.position().z()+x_slice.dz()/2 <<" dy = "<<x_slice.dy()<<" dx = "<<x_slice.dx()<<" position of mass center = "<<x_slice.position().x()<<" "<<x_slice.position().y()<<" material = "<<x_slice.materialStr()<<"\n"; + + dd4hep::printout(dd4hep::INFO, "Construct", "Disk ->layer: y0 = %f y1 = %f mat = %s", (x_slice.position().y()-x_slice.dy()/2)/dd4hep::mm, (x_slice.position().y()+x_slice.dy()/2)/dd4hep::mm, "G4_Si"); } slice.setPlacement(slice_phv); @@ -256,7 +266,8 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s slice_phv.addPhysVolID("side",kz).addPhysVolID("stave",ky).addPhysVolID("module",l+1).addPhysVolID("layer",layer_num ).addPhysVolID("slice",slice_number); slice.setPlacement(slice_phv); if(ky==1 && kz==1){ - std::cout<<"Disk_tube:"<<"zStart = "<<x_slice.position().z()-x_slice.z()/2 << " zEnd = "<<x_slice.position().z()+x_slice.z()/2 <<" r = "<<x_slice.rmax()<<"position of circle center = "<<x_slice.position().x()<<" "<<x_slice.position().y()<<" material = "<<x_slice.materialStr()<<"\n"; + + dd4hep::printout(dd4hep::INFO, "Construct", "Disk ->layer: r0 = %f r1 = %f mat = %s", (x_slice.position().y())/dd4hep::mm, (x_slice.position().y()+x_slice.rmax())/dd4hep::mm, "G4_Si"); } slice_number++; @@ -312,9 +323,7 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s if (x_det.hasAttr(_U(id))) LYSO_phv.addPhysVolID("system", x_det.id()); LYSO_phv.addPhysVolID("side",kz).addPhysVolID("stave",ky).addPhysVolID("module",3).addPhysVolID("layer",i+1 ).addPhysVolID("slice",crystal_id); - if(ky==1 && kz==1){ - std::cout << "LYSO_pixel:" << "zStart = " << z - dz / 2 << " zEnd = "<< z + dz / 2 <<" dy = "<< dy << " dx = "<< dx << " position of mass center = "<< x + j * dx <<" "<< ky * (y - 0.5*dy-i * dy)<<"\n"; - } + crystalDE.setPlacement(LYSO_phv); j++; crystal_id++; @@ -338,15 +347,17 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s if (x_det.hasAttr(_U(id))) LYSO_phv.addPhysVolID("system", x_det.id()); LYSO_phv.addPhysVolID("side",kz).addPhysVolID("stave",ky).addPhysVolID("module",3).addPhysVolID("layer",i+1 ).addPhysVolID("slice",crystal_id); - if(ky==1 && kz==1){ - std::cout<<"LYSO_pixel:"<<"zStart = "<<z-dz/2<< " zEnd = "<<z+dz/2 <<" dy = "<< dy <<" dx = "<<dx<<" position of mass center = "<<x + j * dx<<" "<<ky*(y - 0.5*dy-i * dy)<<"\n"; - } + crystalDE.setPlacement(LYSO_phv); j++; crystal_id++; crystal_num++; } } + if(ky==-1 && kz==1){ + + dd4hep::printout(dd4hep::INFO, "Construct", "1st_LYSO ->layer %d : crystal number =%d y = %f x0 = %f x1 =%f mat = %s",(i+1),crystal_id,ky*(y - 0.5*dy-i * dy)/dd4hep::mm, (x-half*dx)/dd4hep::mm,(x+half*dx)/dd4hep::mm, "LYSO"); + } } } @@ -362,11 +373,15 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s double x2 = pos_second.x(); double y2 = pos_second.y(); double z2 = pos_second.z(); + + xml_coll_t W_second(W_LYSO_layer,_U(slice)); + xml_comp_t component_W = W_second; + Material mat_W = description.material(component_W.materialStr()); for(int ky=-1;ky<=1;ky=ky+2) { string module_name = _toString(5,"_module%d")+_toString(ky,"_stave%d"); - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 12; i++) { encoder["layer"] = 4 ; cellSizeVector = seg.segmentation()->cellDimensions( encoder.getValue() ); int num = 0;//calculate the number of crystals allowed to be placed in each line @@ -374,64 +389,111 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s double yc =12.0+ dy2/mm * (i+1); double xc = dx2 / mm; num = (int) 2 * ((std::sqrt(100.0*100.0 - yc * yc) / xc) - 1); - + int num_W = (int) 2 * ((std::sqrt(120.0*120.0 - yc * yc) / xc) - 1); string layer_name = det_name+ module_name+_toString(kz*(i+1),"_layer%d"); int j = 0; - int half = 0; + int half = 0,tot_half=0; if (num % 2 == 1) { half = (num - 1) / 2; - j = -half; - while (j <= half) { - string crystal_name = layer_name +_toString(crystal_id,"_slice%d"); - DetElement crystalDE(layer_name, _toString(crystal_num,"_slice%d"), x_det.id()); - Box crystalBox(0.5*dx2, 0.5*dy2, 0.5*dz2); - Volume crystalVol(crystal_name, crystalBox, mat2); + tot_half = (num_W - 1)/2; + j = -tot_half; + while (j <= tot_half) { + if(j>=-half&&j<=half){ + string crystal_name = layer_name +_toString(crystal_id,"_slice%d"); + DetElement crystalDE(layer_name, _toString(crystal_num,"_slice%d"), x_det.id()); + Box crystalBox(0.5*dx2, 0.5*dy2, 0.5*dz2); + Volume crystalVol(crystal_name, crystalBox, mat2); - crystalVol.setVisAttributes(description, component_second.visStr()); + crystalVol.setVisAttributes(description, component_second.visStr()); - crystalVol.setSensitiveDetector(sens); - Transform3D transform(RotationZYX(0, 0, 0), Translation3D(x2 + j * dx2, ky*(y2 -0.5*dy2- i * dy2), kz*z2)); - PlacedVolume LYSO_phv =envelope.placeVolume(crystalVol, transform); + crystalVol.setSensitiveDetector(sens); + Transform3D transform(RotationZYX(0, 0, 0), Translation3D(x2 + j * dx2, ky*(y2 -0.5*dy2- i * dy2), kz*z2)); + PlacedVolume LYSO_phv =envelope.placeVolume(crystalVol, transform); - if (x_det.hasAttr(_U(id))) LYSO_phv.addPhysVolID("system", x_det.id()); - LYSO_phv.addPhysVolID("side",kz).addPhysVolID("stave",ky).addPhysVolID("module",5).addPhysVolID("layer",i+1 ).addPhysVolID("slice",crystal_id); - if(ky==1 && kz==1){ - std::cout<<"LYSO_pixel:"<<"zStart = "<<z2-dz2/2<< " zEnd = "<<z2+dz2/2 <<" dy = "<< dy2 <<" dx = "<<dx2<<" position of mass center = "<<x2 + j * dx2<<" "<<ky*(y2 - 0.5*dy2-i * dy2)<<"\n"; - } - crystalDE.setPlacement(LYSO_phv); - j++; - crystal_id++; - crystal_num++; + if (x_det.hasAttr(_U(id))) LYSO_phv.addPhysVolID("system", x_det.id()); + LYSO_phv.addPhysVolID("side",kz).addPhysVolID("stave",ky).addPhysVolID("module",5).addPhysVolID("layer",i+1 ).addPhysVolID("slice",crystal_id); + + crystalDE.setPlacement(LYSO_phv); + j++; + crystal_id++; + crystal_num++; + } + else{ + string crystal_name = layer_name +_toString(crystal_id,"_slice%d"); + DetElement crystalDE(layer_name, _toString(crystal_num,"_slice%d"), x_det.id()); + Box crystalBox(0.5*dx2, 0.5*dy2, 0.5*dz2); + Volume crystalVol(crystal_name, crystalBox, mat_W); + + crystalVol.setVisAttributes(description, component_W.visStr()); + + Transform3D transform(RotationZYX(0, 0, 0), Translation3D(x2 + j * dx2, ky*(y2 -0.5*dy2- i * dy2), kz*z2)); + PlacedVolume LYSO_phv =envelope.placeVolume(crystalVol, transform); + + if (x_det.hasAttr(_U(id))) LYSO_phv.addPhysVolID("system", x_det.id()); + LYSO_phv.addPhysVolID("side",kz).addPhysVolID("stave",ky).addPhysVolID("module",6).addPhysVolID("layer",i+1 ).addPhysVolID("slice",crystal_id); + + crystalDE.setPlacement(LYSO_phv); + j++; + crystal_id++; + crystal_num++; + } } } else { half = num / 2; - j = -half; - while (j < half) { - string crystal_name = layer_name+_toString(crystal_id,"_slice%d"); - DetElement crystalDE(layer_name, _toString(crystal_num,"_slice%d"), x_det.id()); - - Box crystalBox(0.5*dx2, 0.5*dy2, 0.5*dz2); - Volume crystalVol(crystal_name, crystalBox, mat2); - - crystalVol.setVisAttributes(description, component_second.visStr()); - crystalVol.setSensitiveDetector(sens); - Transform3D transform(RotationZYX(0, 0, 0), - Translation3D(x2 + (j + 0.5) * dx2, ky*(y2 -0.5*dy2- i * dy2), kz*z2)); - PlacedVolume LYSO_phv = envelope.placeVolume(crystalVol, transform); + tot_half = num_W/2; + j = -tot_half; + while (j < tot_half) { + if(j>=-half&&j<half){ + string crystal_name = layer_name +_toString(crystal_id,"_slice%d"); + DetElement crystalDE(layer_name, _toString(crystal_num,"_slice%d"), x_det.id()); + Box crystalBox(0.5*dx2, 0.5*dy2, 0.5*dz2); + Volume crystalVol(crystal_name, crystalBox, mat2); + + crystalVol.setVisAttributes(description, component_second.visStr()); - if (x_det.hasAttr(_U(id))) LYSO_phv.addPhysVolID("system", x_det.id()); - LYSO_phv.addPhysVolID("side",kz).addPhysVolID("stave",ky).addPhysVolID("module",5).addPhysVolID("layer",i+1 ).addPhysVolID("slice",crystal_id); - if(ky==1 && kz==1){ - std::cout<<"LYSO_pixel:"<<"zStart = "<<z2-dz2/2<< " zEnd = "<<z2+dz2/2 <<" dy = "<< dy2 <<" dx = "<<dx2<<" position of mass center = "<<x2 + j * dx2<<" "<<ky*(y2 - 0.5*dy2-i * dy2)<<"\n"; - } - crystalDE.setPlacement(LYSO_phv); - j++; - crystal_id++; - crystal_num++; + crystalVol.setSensitiveDetector(sens); + Transform3D transform(RotationZYX(0, 0, 0), Translation3D(x2 + j * dx2, ky*(y2 -0.5*dy2- i * dy2), kz*z2)); + PlacedVolume LYSO_phv =envelope.placeVolume(crystalVol, transform); + + if (x_det.hasAttr(_U(id))) LYSO_phv.addPhysVolID("system", x_det.id()); + LYSO_phv.addPhysVolID("side",kz).addPhysVolID("stave",ky).addPhysVolID("module",5).addPhysVolID("layer",i+1 ).addPhysVolID("slice",crystal_id); + + crystalDE.setPlacement(LYSO_phv); + j++; + crystal_id++; + crystal_num++; + } + else{ + string crystal_name = layer_name +_toString(crystal_id,"_slice%d"); + DetElement crystalDE(layer_name, _toString(crystal_num,"_slice%d"), x_det.id()); + Box crystalBox(0.5*dx2, 0.5*dy2, 0.5*dz2); + Volume crystalVol(crystal_name, crystalBox, mat_W); + + crystalVol.setVisAttributes(description, component_W.visStr()); + + Transform3D transform(RotationZYX(0, 0, 0), Translation3D(x2 + j * dx2, ky*(y2 -0.5*dy2- i * dy2), kz*z2)); + PlacedVolume LYSO_phv =envelope.placeVolume(crystalVol, transform); + + if (x_det.hasAttr(_U(id))) LYSO_phv.addPhysVolID("system", x_det.id()); + LYSO_phv.addPhysVolID("side",kz).addPhysVolID("stave",ky).addPhysVolID("module",6).addPhysVolID("layer",i+1 ).addPhysVolID("slice",crystal_id); + + crystalDE.setPlacement(LYSO_phv); + j++; + crystal_id++; + crystal_num++; + } } } + if(ky==1 && kz==1){ + + dd4hep::printout(dd4hep::INFO, "Construct", "2nd_LYSO ->layer %d : crystal number =%d y = %f x_W_0 = %f x0 = %f x1 =%f x_W_1=%f mat_1 = %s mat_2 = %s",i+1,crystal_id,ky*(y2 - 0.5*dy2-i * dy2)/dd4hep::mm,(x2-tot_half*dx2)/dd4hep::mm, (x2-half*dx2)/dd4hep::mm,(x2+half*dx2)/dd4hep::mm,(x2+tot_half*dx2)/dd4hep::mm, "LYSO","G4_W"); + } } } + dd4hep::PrintLevel oldLevel = dd4hep::setPrintLevel(printLevel); + + dd4hep::setPrintLevel(oldLevel); + } cal.addExtension< LayeredCalorimeterData >( caloData ) ; return cal;