diff --git a/Detector/DetEcalMatrix/compact/det.xml b/Detector/DetEcalMatrix/compact/det.xml index 883478a8a6149933f3f84c3eb11d2696ac9738ef..462dbf7af0bd26384def4b8d9645386e71c2026c 100644 --- a/Detector/DetEcalMatrix/compact/det.xml +++ b/Detector/DetEcalMatrix/compact/det.xml @@ -39,11 +39,13 @@ <readouts> <readout name="CaloHitsCollection"> - <segmentation type="CartesianGridXYZ" - grid_size_x="1*cm" - grid_size_y="1*cm" + <!-- <segmentation type="NoSegmentation"/> --> + + <segmentation type="CartesianGridXYZ" + grid_size_x="1*cm" + grid_size_y="1*cm" grid_size_z="1*cm"/> - <id>system:8,x:-16,y:-16,z:-16</id> + <id>system:8,x:32:-6,y:-6,z:-6</id> </readout> </readouts> diff --git a/Detector/DetEcalMatrix/src/calorimeter/EcalMatrix.cpp b/Detector/DetEcalMatrix/src/calorimeter/EcalMatrix.cpp index a1ccded4be2c80dfe7ef14df71e451abcdef20d4..b835f023b3a84e9efd832207624dc33d691a5e70 100644 --- a/Detector/DetEcalMatrix/src/calorimeter/EcalMatrix.cpp +++ b/Detector/DetEcalMatrix/src/calorimeter/EcalMatrix.cpp @@ -59,23 +59,33 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, std::cout<<"rmin="<<caloData->extent[0]<<",rmax="<<caloData->extent[1]<<",zmin="<<caloData->extent[2]<<",zmax="<<caloData->extent[3]<<std::endl; dd4hep::Readout readout = sens.readout(); dd4hep::Segmentation seg = readout.segmentation(); - double cellSize_x = ::atof( seg.segmentation()->parameter("grid_size_x")->value().c_str() ) * 10;// from cm to mm - double cellSize_y = ::atof( seg.segmentation()->parameter("grid_size_y")->value().c_str() ) * 10;// from cm to mm - double cellSize_z = ::atof( seg.segmentation()->parameter("grid_size_z")->value().c_str() ) * 10;// from cm to mm - int n_layer = int(2*dim.dx()*10/cellSize_x) ; // here the calorimeter is placed in barrel, so x direaction is layer direction - std::cout<<"cellx="<<cellSize_x<<",celly="<<cellSize_y<<",cellz="<<cellSize_z<<",dx="<<dim.dx()*10<<"mm,n_layer="<<n_layer<<std::endl; - for(int i=1 ; i <= n_layer; i++) - { - LayeredCalorimeterData::Layer caloLayer ; - caloLayer.distance = caloData->extent[0] + (i-0.5)*cellSize_x; //NEED TO START FROM ORIGIN, to mm - caloLayer.sensitive_thickness = cellSize_x ; - caloLayer.inner_thickness = cellSize_x ; - caloLayer.outer_thickness = cellSize_x ; - caloLayer.absorberThickness = cellSize_x; - caloLayer.cellSize0 = cellSize_y; - caloLayer.cellSize1 = cellSize_z; - caloData->layers.push_back(caloLayer); - } + + std::cout << "TAO: " + << " field description: " << seg.segmentation()->fieldDescription() + // << " grid size x/y/z: " + // << seg.segmentation()->parameter("grid_size_x")->toString() + // << seg.segmentation()->parameter("grid_size_x")->toString() + // << seg.segmentation()->parameter("grid_size_x")->toString() + << std::endl; + + + // double cellSize_x = ::atof( seg.segmentation()->parameter("grid_size_x")->value().c_str() ) * 10;// from cm to mm + // double cellSize_y = ::atof( seg.segmentation()->parameter("grid_size_y")->value().c_str() ) * 10;// from cm to mm + // double cellSize_z = ::atof( seg.segmentation()->parameter("grid_size_z")->value().c_str() ) * 10;// from cm to mm + // int n_layer = int(2*dim.dx()*10/cellSize_x) ; // here the calorimeter is placed in barrel, so x direaction is layer direction + // std::cout<<"cellx="<<cellSize_x<<",celly="<<cellSize_y<<",cellz="<<cellSize_z<<",dx="<<dim.dx()*10<<"mm,n_layer="<<n_layer<<std::endl; + // for(int i=1 ; i <= n_layer; i++) + // { + // LayeredCalorimeterData::Layer caloLayer ; + // caloLayer.distance = caloData->extent[0] + (i-0.5)*cellSize_x; //NEED TO START FROM ORIGIN, to mm + // caloLayer.sensitive_thickness = cellSize_x ; + // caloLayer.inner_thickness = cellSize_x ; + // caloLayer.outer_thickness = cellSize_x ; + // caloLayer.absorberThickness = cellSize_x; + // caloLayer.cellSize0 = cellSize_y; + // caloLayer.cellSize1 = cellSize_z; + // caloData->layers.push_back(caloLayer); + // } if ( x_det.isSensitive() ) { dd4hep::SensitiveDetector sd = sens; @@ -86,7 +96,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, phv.addPhysVolID("system",x_det.id()); } sdet.setPlacement(phv); - sdet.addExtension< LayeredCalorimeterData >(caloData) ; + // sdet.addExtension< LayeredCalorimeterData >(caloData) ; MYDEBUG("create_detector DONE. "); return sdet; } diff --git a/Simulation/DetSimAna/CMakeLists.txt b/Simulation/DetSimAna/CMakeLists.txt index b43d75eb40e3f587d611d56d77d3072f282424fb..e0c9aca523f0e6f33ffc9b33c40a2d7aca33c971 100644 --- a/Simulation/DetSimAna/CMakeLists.txt +++ b/Simulation/DetSimAna/CMakeLists.txt @@ -36,6 +36,9 @@ gaudi_add_module(DetSimAna ${DetSimAna_srcs} ${DD4hep_COMPONENT_LIBRARIES} GaudiKernel # Geant4 + + -Wl,--no-as-needed EDM4HEP::edm4hep EDM4HEP::edm4hepDict + -Wl,--as-needed # ${podio_LIBRARIES} ) diff --git a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp index 8ba60b44292a86bf678bbfe650b1e44078bcbfb9..1df29b0c48d32f4762698845322e1ebabb16d4d6 100644 --- a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp +++ b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp @@ -96,7 +96,7 @@ AnExampleDetElemTool::ConstructSDandField() { if (g4sd == nullptr) { std::string tmp = typ; tmp[0] = ::toupper(tmp[0]); - typ = "Geant4" + tmp; + typ = "Geant4CEPC" + tmp; g4sd = dd4hep::PluginService::Create<G4VSensitiveDetector*>(typ, nam, lcdd); if (g4sd == nullptr) { dd4hep::PluginDebug dbg; diff --git a/Simulation/DetSimInterface/DetSimInterface/ISensDetTool.h b/Simulation/DetSimInterface/DetSimInterface/ISensDetTool.h new file mode 100644 index 0000000000000000000000000000000000000000..cb06d94000770797efc738f5720b73eda6568044 --- /dev/null +++ b/Simulation/DetSimInterface/DetSimInterface/ISensDetTool.h @@ -0,0 +1,28 @@ +#ifndef ISensDetTool_h +#define ISensDetTool_h +/* + * ISensDetTool is a tool to configure and create a Geant4's sensitive detector. + * After create the SD, the Geant4 will take ownership of the SD. + * + * This tool is used to replace the DDG4's Geant4SensitiveDetector. + * It will be invoked in ConstructSDandField(). + * + * -- 12 June 2020, Tao Lin <lintao@ihep.ac.cn> + */ + +#include "GaudiKernel/IAlgTool.h" + +class G4VSensitiveDetector; + +class ISensDetTool: virtual public IAlgTool { +public: + + DeclareInterfaceID(ISensDetTool, 0, 1); + + virtual ~ISensDetTool() {}; + + virtual G4VSensitiveDetector* createSD(const std::string& name); + +}; + +#endif