Skip to content
Snippets Groups Projects
Commit f56be666 authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn
Browse files

WIP: create ISensDetTool.h

parent 0e55f64e
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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;
}
......
......@@ -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}
)
......@@ -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;
......
#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment