Skip to content

Commit

Permalink
Error to Warning
Browse files Browse the repository at this point in the history
  • Loading branch information
fucd committed Apr 1, 2024
1 parent 949853d commit 548a99f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 13 deletions.
40 changes: 34 additions & 6 deletions Service/GearSvc/src/GearSvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ StatusCode GearSvc::initialize()
info() << "Fill GEAR data from GeomSvc" << endmsg;
m_gearMgr->setDetectorName("CRD_o1_v01");

const dd4hep::Direction& field = geomSvc->lcdd()->field().magneticField(dd4hep::Position(0,0,0));
gear::ConstantBField* b = new gear::ConstantBField(gear::Vector3D(field.x()/dd4hep::tesla, field.y()/dd4hep::tesla, field.z()/dd4hep::tesla));
m_gearMgr->setBField(b);
if (m_field.value()==0) {
const dd4hep::Direction& field = geomSvc->lcdd()->field().magneticField(dd4hep::Position(0,0,0));
gear::ConstantBField* b = new gear::ConstantBField(gear::Vector3D(field.x()/dd4hep::tesla, field.y()/dd4hep::tesla, field.z()/dd4hep::tesla));
m_gearMgr->setBField(b);
}
else {
gear::ConstantBField* b = new gear::ConstantBField(gear::Vector3D(0, 0, m_field.value()));
m_gearMgr->setBField(b);
}

dd4hep::DetElement world = geomSvc->getDD4HepGeo();
const std::map<std::string, dd4hep::DetElement>& subs = world.children();
Expand Down Expand Up @@ -211,8 +217,11 @@ StatusCode GearSvc::convertVXD(dd4hep::DetElement& vxd){

dd4hep::rec::MaterialManager matMgr( dd4hep::Detector::getInstance().world().volume() ) ;
const dd4hep::rec::ZPlanarData::LayerLayout& l = vxdData->layers[0] ;
dd4hep::rec::Vector3D a( l.distanceSensitive + l.thicknessSensitive, l.phi0 , 0. , dd4hep::rec::Vector3D::cylindrical ) ;
dd4hep::rec::Vector3D b( l.distanceSupport + l.thicknessSupport, l.phi0 , 0. , dd4hep::rec::Vector3D::cylindrical ) ;
double offset = l.offsetSupport;
//dd4hep::rec::Vector3D a( l.distanceSensitive + l.thicknessSensitive, l.phi0 , 0. , dd4hep::rec::Vector3D::cylindrical ) ;
//dd4hep::rec::Vector3D b( l.distanceSupport + l.thicknessSupport, l.phi0 , 0. , dd4hep::rec::Vector3D::cylindrical ) ;
dd4hep::rec::Vector3D a( l.distanceSensitive + l.thicknessSensitive, l.offsetSupport, 2.*dd4hep::mm);
dd4hep::rec::Vector3D b( l.distanceSupport + l.thicknessSupport, l.offsetSupport, 2.*dd4hep::mm);
const dd4hep::rec::MaterialVec& materials = matMgr.materialsBetween( a , b ) ;
dd4hep::rec::MaterialData mat = ( materials.size() > 1 ? matMgr.createAveragedMaterial( materials ) : materials[0].first ) ;

Expand All @@ -228,6 +237,25 @@ StatusCode GearSvc::convertVXD(dd4hep::DetElement& vxd){
mat.interactionLength()/dd4hep::mm);
m_gearMgr->registerSimpleMaterial(VXDSupportMaterial);

if (vxdData->rOuterShell>vxdData->rInnerShell) {
dd4hep::rec::Vector3D a1( vxdData->rInnerShell, 0, 2.*dd4hep::mm);
dd4hep::rec::Vector3D b1( vxdData->rOuterShell, 0, 2.*dd4hep::mm);
const dd4hep::rec::MaterialVec& materials1 = matMgr.materialsBetween( a1 , b1 ) ;
dd4hep::rec::MaterialData mat1 = ( materials1.size() > 1 ? matMgr.createAveragedMaterial( materials1 ) : materials1[0].first ) ;

std::cout << " ####### found materials between points : " << a1 << " and " << b1 << " : " ;
for( unsigned i=0,n=materials1.size();i<n;++i){
std::cout << materials1[i].first.name() << "[" << materials1[i].second << "], " ;
}
std::cout << std::endl ;
std::cout << " averaged material : " << mat1 << std::endl ;
gear::SimpleMaterialImpl* VXDShellMaterial = new gear::SimpleMaterialImpl("VXDShellMaterial", mat1.A(), mat1.Z(),
mat1.density()/(dd4hep::kg/(dd4hep::g*dd4hep::m3)),
mat1.radiationLength()/dd4hep::mm,
mat1.interactionLength()/dd4hep::mm);
m_gearMgr->registerSimpleMaterial(VXDShellMaterial);
}

info() << vxdData->rInnerShell << " " << vxdData->rOuterShell << " " << vxdData->zHalfShell << " " << vxdData->gapShell << endmsg;
for(int i=0,n=vxdData->layers.size(); i<n; i++){
const dd4hep::rec::ZPlanarData::LayerLayout& thisLayer = vxdData->layers[i];
Expand Down Expand Up @@ -702,7 +730,7 @@ StatusCode GearSvc::convertFTD(dd4hep::DetElement& ftd){
senRinner, senThickness, senLengthMin, senLengthMax, senWidth, 0);
}
m_gearMgr->setFTDParameters(ftdParam);

info() << "nftd = " << nLayers << endmsg;
return StatusCode::SUCCESS;
}

Expand Down
12 changes: 10 additions & 2 deletions Utilities/KalDet/src/ild/common/MaterialDataBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ void MaterialDataBase::createMaterials(const gear::GearMgr& gearMgr, IGeomSvc* g
TMaterial &ftdsupport = *new TMaterial(name.c_str(), "", A, Z, density, radlen, 0.) ;
this->addMaterial(&ftdsupport, name);


// VXD Support Material
if(geoSvc){
//obselete
Expand All @@ -222,9 +221,18 @@ void MaterialDataBase::createMaterials(const gear::GearMgr& gearMgr, IGeomSvc* g
name = vxd_sup_mat.getName() ;
TMaterial &vxdsupport = *new TMaterial(name.c_str(), "", A, Z, density, radlen, 0.);
this->addMaterial(&vxdsupport, name);

const gear::SimpleMaterial& vxd_shell_mat = gearMgr.getSimpleMaterial("VXDShellMaterial");
A = vxd_shell_mat.getA();
Z = vxd_shell_mat.getZ();
density = vxd_shell_mat.getDensity() * (1000.0/ 1000000.0); // kg/m^3 -> g/cm^3
radlen = vxd_shell_mat.getRadLength() / 10.0 ; // mm -> cm
name = vxd_shell_mat.getName() ;
TMaterial &vxdshell = *new TMaterial(name.c_str(), "", A, Z, density, radlen, 0.);
this->addMaterial(&vxdshell, name);
}
catch( gear::UnknownParameterException& e){
std::cout << "Error while read material from GeomSvc!" << std::endl;
std::cout << "Warning! cannot get material VXDSupportMaterial and VXDShellMaterial from GeomSvc! GearMgr=" << &gearMgr << std::endl;
}
}
}
Expand Down
20 changes: 15 additions & 5 deletions Utilities/KalDet/src/ild/vxd/ILDVXDKalDetector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ ILDVXDKalDetector::ILDVXDKalDetector( const gear::GearMgr& gearMgr, IGeomSvc* ge
TMaterial & beryllium = *MaterialDataBase::Instance().getMaterial("beryllium");

// needed for cryostat

TMaterial & aluminium = *MaterialDataBase::Instance().getMaterial("aluminium");

_vxd_Cryostat.exists = false;
Expand Down Expand Up @@ -215,6 +214,12 @@ ILDVXDKalDetector::ILDVXDKalDetector( const gear::GearMgr& gearMgr, IGeomSvc* ge
}
}

if (_vxd_Cryostat.shellInnerR>0&&_vxd_Cryostat.shellThickness>0) {
TMaterial & shell = *MaterialDataBase::Instance().getMaterial("VXDShellMaterial");
Add( new ILDCylinderMeasLayer(air, shell , _vxd_Cryostat.shellInnerR, _vxd_Cryostat.shelllHalfZ, 0, 0, 0, _bZ, dummy,-1,"VXDShellInnerWall" ) );
Add( new ILDCylinderMeasLayer(shell, air , _vxd_Cryostat.shellInnerR+_vxd_Cryostat.shellThickness, _vxd_Cryostat.shelllHalfZ, 0, 0, 0, _bZ, dummy,-1,"VXDShellOuterWall" ) );
}

if (_vxd_Cryostat.exists) {
// build Cryostat according to mokka driver vxd04.cc

Expand Down Expand Up @@ -357,6 +362,11 @@ void ILDVXDKalDetector::setupGearGeom( const gear::GearMgr& gearMgr ){
_relative_position_of_measurement_surface = pVXDDetMain.getDoubleVal( "relative_position_of_measurement_surface" );
}
catch (gear::UnknownParameterException& e) {}

_vxd_Cryostat.shellInnerR = pVXDDetMain.getShellInnerRadius();
_vxd_Cryostat.shellThickness = pVXDDetMain.getShellOuterRadius() - pVXDDetMain.getShellInnerRadius();
_vxd_Cryostat.shelllHalfZ = pVXDDetMain.getShellHalfLength();

try {
const gear::GearParameters& pVXDInfra = gearMgr.getGearParameters("VXDInfra");
_vxd_Cryostat.alRadius = pVXDInfra.getDoubleVal( "CryostatAlRadius" );
Expand All @@ -365,16 +375,16 @@ void ILDVXDKalDetector::setupGearGeom( const gear::GearMgr& gearMgr ){
_vxd_Cryostat.alZEndCap = pVXDInfra.getDoubleVal( "CryostatAlZEndCap" );
_vxd_Cryostat.alHalfZ = pVXDInfra.getDoubleVal( "CryostatAlHalfZ" );

_vxd_Cryostat.shellInnerR = pVXDDetMain.getShellInnerRadius();
_vxd_Cryostat.shellThickness = pVXDDetMain.getShellOuterRadius() - _vxd_Cryostat.shellInnerR;
_vxd_Cryostat.shelllHalfZ = pVXDDetMain.getShellHalfLength();
//_vxd_Cryostat.shellInnerR = pVXDDetMain.getShellInnerRadius();
//_vxd_Cryostat.shellThickness = pVXDDetMain.getShellOuterRadius() - _vxd_Cryostat.shellInnerR;
//_vxd_Cryostat.shelllHalfZ = pVXDDetMain.getShellHalfLength();

_vxd_Cryostat.exists = true;
//std::cout << "VXDInfra: " << _vxd_Cryostat.alRadius << " " << _vxd_Cryostat.alThickness << " " << _vxd_Cryostat.alInnerR << " " << _vxd_Cryostat.alZEndCap << " "
// << _vxd_Cryostat.alHalfZ << " " << _vxd_Cryostat.shellInnerR << " " << _vxd_Cryostat.shellThickness << " " << _vxd_Cryostat.shelllHalfZ << std::endl;
}
catch (gear::UnknownParameterException& e) {
std::cout << e.what() << std::endl ;
//std::cout << "ILDVXDKalDetector: " << e.what() << ", will not be built" << std::endl ;
_vxd_Cryostat.exists = false;

}
Expand Down

0 comments on commit 548a99f

Please sign in to comment.