Skip to content
Snippets Groups Projects
Verified Commit 2be8d3ff authored by Tadej Novak's avatar Tadej Novak
Browse files

Remove old SLHC InDetServMat geometry

parent c699a8ef
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef InDetServMatBuilderToolSLHC_H
#define InDetServMatBuilderToolSLHC_H
#include "InDetGeoModelUtils/IInDetServMatBuilderTool.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ServiceHandle.h"
#include <string>
#include <list>
class GeoMaterial;
class PixelGeoModelAthenaComps;
class IGeoDbTagSvc;
class IRDBAccessSvc;
class IGeometryDBSvc;
class InDetServMatGeometryManager;
class ServiceVolume;
class InDetMaterialManager;
namespace InDetDD {
class AthenaComps;
}
/**
Service material for the inner tracker.
The number and type of services per stave is computed by ComputeStaveServices, except for the cooling, which can be
manifolded, and is computed later by ConvertStaveServices.
All services are converted to names known to the InDetMaterialManager (and to the DB) by ConvertStaveServices, the result
of which is a ServiceMaterial instance.
ServiceMaterial is a container of Entry items, each entry containing
- material name
- number of occurances (e.g. number of cables of the type given by "material name" that cross a service volume)
- the weight
- a flag specifying if the weight is per unit of length (in kg/m) or absolute (in kg)
There are two ways to specify service materials:
- materials present in the weight table of the MaterialManager, e.g. TwinaxCable. For these materials the weight
is taken from the weight table, and the weight specified in the ServiceMaterial::Entry _must_ be set to 1
- materials for which the weight is computed by ConvertStaveServices as a function of the pipe diameter or the
wire gauge. For these materials there should be no entry in the weight tables, and the name specified in
ServiceMaterial::Entry refers to a normal GeoMaterial. The density of this material is ignored, since the weight
is already computed, and only the chemical composition is used from the MaterialManager (and the DB)
*/
class InDetServMatBuilderToolSLHC : virtual public IInDetServMatBuilderTool, public AthAlgTool
{
public:
/// Constructor
InDetServMatBuilderToolSLHC(const std::string&,const std::string&,const IInterface*);
/// default destructor
virtual ~InDetServMatBuilderToolSLHC();
/// standard Athena-Algorithm method
virtual StatusCode initialize();
/// standard Athena-Algorithm method
virtual StatusCode finalize();
/// Get the services
virtual const std::vector<const InDetDD::ServiceVolume *> & getServices() const;
/// General service adding method.
void addService(InDetDD::ServiceVolume * param);
/// Add tube like service after creating material
void addService(const std::string & name, const GeoMaterial * material,
double rmin, double rmax, double zmin, double zmax, bool zsymm = true);
/// Add tube-like service with predefined material.
void addService(const std::string & name, const std::string & materialName,
double rmin, double rmax, double zmin, double zmax, bool zsymm = true);
void addServiceVolume( const ServiceVolume& vol);
private:
/// Build the geometry.
void build();
/// Initialization that must be done after geometry is known
void geoInit();
/// Properties
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc;
ServiceHandle< IRDBAccessSvc > m_rdbAccessSvc;
ServiceHandle< IGeometryDBSvc > m_geometryDBSvc;
bool m_init;
InDetDD::AthenaComps * m_athenaComps;
InDetServMatGeometryManager * m_geoMgr;
std::vector<const InDetDD::ServiceVolume *> m_services;
void printNewVolume( const ServiceVolume& vol, const GeoMaterial& mat,
const InDetDD::ServiceVolume& param) const;
//std::string getKnownName( const std::string& name, InDetMaterialManager* matMgr);
void fixMissingMaterials();
std::string addPrefix( const std::string& prefix, const std::string& name) const;
void addMissingMaterial( const std::string& name,
const std::vector<std::string>& comps, const std::vector<double>& fracs, double dens=1.0);
};
#endif //InDetServMatBuilderToolSLHC_H
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INDETSERVMATGEOMODEL_INDETSERVMATFACTORYSLHC_H
#define INDETSERVMATGEOMODEL_INDETSERVMATFACTORYSLHC_H
#include "GaudiKernel/ServiceHandle.h"
#include "InDetGeoModelUtils/InDetDetectorFactoryBase.h"
#include "InDetServMatGeoModel/InDetServMatManager.h"
#include "RDBAccessSvc/IRDBAccessSvc.h"
class InDetServMatAthenaComps;
class IRDBRecordset;
class InDetServMatFactorySLHC : public InDetDD::DetectorFactoryBase {
public:
// Constructor:
InDetServMatFactorySLHC(InDetServMatAthenaComps * athenaComps);
// Destructor:
~InDetServMatFactorySLHC();
// Creation of geometry:
virtual void create(GeoPhysVol *world);
// manager
virtual const InDetDD::InDetServMatManager* getDetectorManager () const;
private:
// Illegal operations:
const InDetServMatFactorySLHC & operator=(const InDetServMatFactorySLHC &right);
InDetServMatFactorySLHC(const InDetServMatFactorySLHC &right);
void fetchTables();
double envelopeLength() const;
bool simpleEnvelope() const;
bool oldEnvelope() const;
unsigned int envelopeNumPlanes() const;
double envelopeZ(int i = 0) const;
double envelopeRMin(int i = 0) const;
double envelopeRMax(int i = 0) const;
// Database tables (we name it same as table name):
IRDBRecordset_ptr m_InDetServGenEnvelope;
// Need acceess to derived version
InDetServMatAthenaComps * m_athenaComps;
// private data
InDetDD::InDetServMatManager *m_manager;
};
#endif // INDETSERVMATGEOMODEL_INDETSERVMATFACTORYSLHC_H
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "InDetServMatGeoModel/InDetServMatBuilderToolSLHC.h"
#include "InDetServMatGeoModel/InDetServMatGeometryManager.h"
#include "InDetGeoModelUtils/InDetDDAthenaComps.h"
#include "InDetGeoModelUtils/ServiceVolume.h"
#include "InDetGeoModelUtils/ServiceVolumeMaker.h"
#include "GeometryDBSvc/IGeometryDBSvc.h"
#include "GeoModelKernel/GeoMaterial.h"
#include "GeoModelInterfaces/IGeoDbTagSvc.h"
#include "RDBAccessSvc/IRDBAccessSvc.h"
#include "InDetGeoModelUtils/InDetMaterialManager.h"
#include "GeoModelKernel/Units.h"
#include "GaudiKernel/SystemOfUnits.h"
#include "InDetServMatGeoModel/ServicesTracker.h"
#include "InDetServMatGeoModel/ServicesTrackerBuilder.h"
#include "InDetServMatGeoModel/ServiceVolume.h"
#include "CxxUtils/checker_macros.h"
//================ Constructor =================================================
InDetServMatBuilderToolSLHC::InDetServMatBuilderToolSLHC(const std::string& t,
const std::string& name,
const IInterface* p )
: AthAlgTool(t,name,p),
m_geoDbTagSvc("GeoDbTagSvc",name),
m_rdbAccessSvc("RDBAccessSvc",name),
m_geometryDBSvc("InDetGeometryDBSvc",name),
m_init(false),
m_athenaComps(nullptr),
m_geoMgr(nullptr)
{
declareInterface<IInDetServMatBuilderTool>(this);
declareProperty("RDBAccessSvc", m_rdbAccessSvc);
declareProperty("GeometryDBSvc", m_geometryDBSvc);
declareProperty("GeoDbTagSvc", m_geoDbTagSvc);
}
//================ Destructor =================================================
InDetServMatBuilderToolSLHC::~InDetServMatBuilderToolSLHC()
{
delete m_athenaComps;
delete m_geoMgr;
for (std::vector<const InDetDD::ServiceVolume *>::iterator iter = m_services.begin(); iter != m_services.end(); ++iter) {
delete *iter;
}
}
//================ Initialize =================================================
StatusCode InDetServMatBuilderToolSLHC::initialize()
{
StatusCode sc = AlgTool::initialize();
if (sc.isFailure()) return sc;
// Get the detector configuration.
sc = m_geoDbTagSvc.retrieve();
if (sc.isFailure()) {
msg(MSG::FATAL) << "Could not locate GeoDbTagSvc" << endmsg;
return (StatusCode::FAILURE);
}
// Get RDBAcessSvc
sc = m_rdbAccessSvc.retrieve();
if (sc.isFailure()) {
msg(MSG::FATAL) << "Could not locate RDBAccessSvc" << endmsg;
return (StatusCode::FAILURE);
}
// Retrieve the Geometry DB Interface
sc = m_geometryDBSvc.retrieve();
if (sc.isFailure()) {
msg(MSG::FATAL) << "Could not locate Geometry DB Interface: " << m_geometryDBSvc.name() << endmsg;
return (StatusCode::FAILURE);
}
// Pass the Athena components to the geometry manager
//m_athenaComps = new InDetDD::AthenaComps(name());
m_athenaComps = new InDetDD::AthenaComps("InDetServMatGeoModel");
m_athenaComps->setDetStore(&*(detStore()));
m_athenaComps->setGeoDbTagSvc(&*m_geoDbTagSvc);
m_athenaComps->setRDBAccessSvc(&*m_rdbAccessSvc);
m_athenaComps->setGeometryDBSvc(&*m_geometryDBSvc);
build();
msg(MSG::INFO) << "initialize() successful in " << name() << endmsg;
return StatusCode::SUCCESS;
}
//================ Finalize =================================================
StatusCode InDetServMatBuilderToolSLHC::finalize()
{
StatusCode sc = AlgTool::finalize();
return sc;
}
const std::vector<const InDetDD::ServiceVolume *> & InDetServMatBuilderToolSLHC::getServices() const
{
return m_services;
}
void InDetServMatBuilderToolSLHC::geoInit()
{
m_geoMgr = new InDetServMatGeometryManager(m_athenaComps);
}
void InDetServMatBuilderToolSLHC::build()
{
// Do nothing if services are not to be built.
geoInit();
m_init = true;
if (!m_geoMgr->buildServices()) return;
// build the geometry
if (msgLvl(MSG::DEBUG)) {
msg(MSG::DEBUG) << "pixelNumLayers: " << m_geoMgr->pixelNumLayers() << endmsg;
for (int i = 0; i < m_geoMgr->pixelNumLayers(); i++) {
msg(MSG::DEBUG) << " pixelLayerRadius(" << i << ") : " << m_geoMgr->pixelLayerRadius(i) << endmsg;
msg(MSG::DEBUG) << " pixelLayerLength(" << i << ") : " << m_geoMgr->pixelLayerLength(i) << endmsg;
msg(MSG::DEBUG) << " pixelNumSectorsForLayer(" << i << ") : " << m_geoMgr->pixelNumSectorsForLayer(i) << endmsg;
}
msg(MSG::DEBUG) << "pixelNumDisk: " << m_geoMgr->pixelNumDisks() << endmsg;
for (int i = 0; i < m_geoMgr->pixelNumDisks(); i++) {
msg(MSG::DEBUG) << " pixelDiskZ(" << i << ") : " << m_geoMgr->pixelDiskZ(i) << endmsg;
msg(MSG::DEBUG) << " pixelDiskRMax(" << i << ") : " << m_geoMgr->pixelDiskRMax(i) << endmsg;
msg(MSG::DEBUG) << " pixelDiskSectors(" << i << ") : " << m_geoMgr->pixelEndcapNumSectorsForLayer(i) << endmsg;
msg(MSG::DEBUG) << " pixelModulesPerSectors(" << i << ") : " << m_geoMgr->pixelModulesPerEndcapSector(i) << endmsg;
msg(MSG::DEBUG) << " pixelChipsPerModuleForDisk(" << i << ") : " << m_geoMgr->pixelChipsPerModuleForDisk(i) << endmsg;
}
msg(MSG::DEBUG) << "sctNumLayers: " << m_geoMgr->sctNumLayers() << endmsg;
for (int i = 0; i < m_geoMgr->sctNumLayers(); i++) {
msg(MSG::DEBUG) << " sctLayerRadius(" << i << ") : " << m_geoMgr->sctLayerRadius(i) << endmsg;
msg(MSG::DEBUG) << " sctLayerLength(" << i << ") : " << m_geoMgr->sctLayerLength(i) << endmsg;
msg(MSG::DEBUG) << " sctLayerType(" << i << ") : " << m_geoMgr->sctLayerType(i) << endmsg;
msg(MSG::DEBUG) << " sctNumSectorsForLayer(" << i << ") : " << m_geoMgr->sctNumSectorsForLayer(i) << endmsg;
}
msg(MSG::DEBUG) << "sctNumDisk: " << m_geoMgr->sctNumDisks() << endmsg;
for (int i = 0; i < m_geoMgr->sctNumDisks(); i++) {
msg(MSG::DEBUG) << " sctDiskZ(" << i << ") : " << m_geoMgr->sctDiskZ(i) << endmsg;
msg(MSG::DEBUG) << " sctDiskRMax(" << i << ") : " << m_geoMgr->sctDiskRMax(i) << endmsg;
}
msg(MSG::DEBUG) << "sctInnerSupport radius: " << m_geoMgr->sctInnerSupport() << endmsg;
msg(MSG::DEBUG) << "PST inner radius: " << m_geoMgr->SupportTubeRMin("PST") << endmsg;
msg(MSG::DEBUG) << "Pixel Envelope radius: " << m_geoMgr->pixelEnvelopeRMax() << endmsg;
}
ServicesTracker* tracker = ServicesTrackerBuilder().buildGeometry( *m_geoMgr);
// compute the services for each layer
tracker->computeServicesPerLayer();
tracker->finaliseServices();
fixMissingMaterials();
typedef std::vector<ServiceVolume*>::const_iterator iter;
for (iter i=tracker->serviceVolumes().begin(); i!=tracker->serviceVolumes().end(); ++i) {
/*
msg(MSG::INFO) << "Calling ServiceVolume->dump() for the " << n++ << "th time" << endmsg;
(**i).dump(); // for DEBUG only
msg(MSG::INFO) << "Call to ServiceVolume->dump() returned" << endmsg;
*/
addServiceVolume( **i);
}
// Add services from table (if there are any)
InDetDD::ServiceVolumeSchema schema;
schema.setSimpleSchema();
InDetDD::ServiceVolumeMaker volMaker("ISM",m_geoMgr->simpleServiceTable(),schema,m_athenaComps);
for (unsigned int i = 0; i < volMaker.numElements(); ++i) {
addService(volMaker.make(i));
}
delete tracker;
// Some test volumes
/*
addService("Test1", "std::Carbon", 10, 1040, 410, 420, false);
addService("Test2", "std::Carbon", 10, 1040, 450, 455, true);
addService("Test3", "std::Carbon", 1041, 1048, 455, 3000, true);
addService("Test4", "std::Carbon", 1120, 1122, -4000, 4000, false);
addService("Test5", "std::Copper", 10, 1200, -1001, -1000, false);
addService("Test6", "std::Copper", 121, 139, -3120, 3120, false);
addService("Test7", "std::Copper", 10, 1200, 1200, 1201, true);
addService("Test8", "std::Copper", 10, 1040, 2000, 2005, true);
addService("Test9", "std::Copper", 800, 802, -3120, 3120, false);
*/
}
/// General service adding method.
void InDetServMatBuilderToolSLHC::addService(InDetDD::ServiceVolume * param)
{
int count = m_services.size() + 1;
param->setLabel("ISM",count);
m_services.push_back(param);
}
void InDetServMatBuilderToolSLHC::addServiceVolume( const ServiceVolume& vol)
{
msg(MSG::DEBUG) << "Entering InDetServMatBuilderToolSLHC::addServiceVolume for volume " << vol.name()
<< " with " << vol.materials().size() << " materials" << endmsg;
InDetDD::ServiceVolume * param = new InDetDD::ServiceVolume;
//std::unique_ptr<InDetDD::ServiceVolume> param (new InDetDD::ServiceVolume); This doesn't work for some reason...
std::vector<std::string> linearComponents;
std::vector<double> linWeights;
param->setVolName(vol.name());
param->setRmin(vol.rMin());
param->setRmax(vol.rMax());
param->setZmin(vol.zMin());
param->setZmax(vol.zMax());
param->setZsymm(true);
for (std::vector<ServiceMaterial>::const_iterator ism=vol.materials().begin(); ism!=vol.materials().end(); ++ism) {
for ( ServiceMaterial::EntryIter ient= ism->components().begin(); ient!=ism->components().end(); ++ient) {
/*
msg(MSG::INFO) << "Inside components loop, comp = " << ient->name
<< " number " << ient->number
<< " weight " << ient->weight
<< " linear " << ient->linear
<< endmsg;
*/
// if (ient->weight*ient->number > 0.00001) {
//std::string pre = "pix::";
std::string prefix = "indet::";
std::string prename = addPrefix( prefix, ient->name);
if (ient->linear) {
linearComponents.push_back( prename);
linWeights.push_back( fabs( ient->number * ient->weight));
}
else {
linearComponents.push_back( prename); // the distiction between linear and not is done in the
linWeights.push_back( fabs( ient->weight*ient->number)); // InDetMaterialmanager, based on the weight table flag
}
}
}
if ( !linearComponents.empty()) {
const GeoMaterial * newMat = m_geoMgr->matMgr()->getMaterialForVolumeLength( vol.name(),
linearComponents, linWeights,
param->volume(), vol.length());
printNewVolume( vol, *newMat, *param);
param->setMaterial(newMat);
addService(param);
// addService(param.release());
}
else delete param;
}
std::string InDetServMatBuilderToolSLHC::addPrefix( const std::string& prefix, const std::string& name) const
{
// only add prefix to names which don't have one
if ( name.find("::") == std::string::npos) return prefix+name;
else return name;
}
/// Add tube like service after creating material
void InDetServMatBuilderToolSLHC::addService(const std::string & name, const GeoMaterial * material,
double rmin, double rmax, double zmin, double zmax, bool zsymm)
{
InDetDD::ServiceVolume * param = new InDetDD::ServiceVolume;
param->setVolName(name);
param->setMaterial(material);
param->setRmin(rmin);
param->setRmax(rmax);
param->setZmin(zmin);
param->setZmax(zmax);
param->setZsymm(zsymm);
addService(param);
}
/// Add tube-like service with predefined material.
void InDetServMatBuilderToolSLHC::addService(const std::string & name, const std::string & materialName,
double rmin, double rmax, double zmin, double zmax, bool zsymm)
{
InDetDD::ServiceVolume * param = new InDetDD::ServiceVolume;
param->setVolName(name);
param->setMaterial(materialName);
param->setRmin(rmin);
param->setRmax(rmax);
param->setZmin(zmin);
param->setZmax(zmax);
param->setZsymm(zsymm);
addService(param);
}
void InDetServMatBuilderToolSLHC::printNewVolume( const ServiceVolume& vol,
const GeoMaterial& mat,
const InDetDD::ServiceVolume& param) const
{
double dens = mat.getDensity();
double weight = dens*param.volume();
if (msgLvl(MSG::DEBUG)) {
msg(MSG::DEBUG) << "Creating service volume with rmin " << vol.rMin()
<< " rmax " << vol.rMax()
<< " zmin " << vol.zMin()
<< " zmax " << vol.zMax() << endmsg;
msg(MSG::DEBUG) << "name " << vol.name() << " density " << dens * Gaudi::Units::cm3 / GeoModelKernelUnits::g
<< " [g/cm3] weight " << dens*param.volume()/Gaudi::Units::kg << " [kg]" << endmsg;
}
if (msgLvl(MSG::DEBUG)) { // FIXME: change to VERBOSE when done!
msg(MSG::DEBUG) << "Number of elements: " << mat.getNumElements() << endmsg;
for (unsigned int i=0; i< mat.getNumElements(); i++) {
msg(MSG::DEBUG) << "Element " << mat.getElement(i)->getName()
<< " weight " << mat.getFraction(i) * weight / GeoModelKernelUnits::g << endmsg;
}
}
}
void InDetServMatBuilderToolSLHC::fixMissingMaterials()
{
/*
m_geoMgr->matMgr()->addWeightEntry( "CoaxialHVCable", "indet::CoaxialHVCableBase", 0.0026*GeoModelKernelUnits::gram, true, "indet");
m_geoMgr->matMgr()->addWeightEntry( "TwistedPair_awg36", "indet::TwistedPair_awg36Base", 0.000381*GeoModelKernelUnits::gram, true, "indet");
m_geoMgr->matMgr()->addWeightEntry( "ScreenedTwistP_36", "indet::ScreenedTwistP_36Base", 0.000978*GeoModelKernelUnits::gram, true, "indet");
m_geoMgr->matMgr()->addWeightEntry( "Twinax", "indet::TwinaxBase", 0.00517*GeoModelKernelUnits::gram, true, "indet");
*/
//m_geoMgr->matMgr()->addWeightEntry( "ShieldingSleeve", "indet::ShieldingSleeveBase", 0.033*GeoModelKernelUnits::gram, true, "indet");
//m_geoMgr->matMgr()->addWeightEntry( "ProtectionSleeve", "indet::ProtectionSleeveBase", 0.004*GeoModelKernelUnits::gram, true, "indet");
/*
// the wight is 1, because the real weight is in ServiceMaterial NOT NEEDED
m_geoMgr->matMgr()->addWeightEntry( "CoolingPipe", "std::Titanium", 1*GeoModelKernelUnits::gram, true, "indet");
std::vector<std::string> comps(2);
std::vector<double> fracs(2);
comps[0] = "std::Aluminium"; fracs[0] = 0.731;
comps[1] = "std::Copper"; fracs[1] = 0.269;
const GeoMaterial* geomat = m_geoMgr->matMgr()->getMaterial( "indet::CCAW", comps, fracs, 3.33);
if (geomat) msg(MSG::INFO) << "Material with name name " << "CCAW" << " added" << endmsg;
else msg(MSG::INFO) << "Material with name name " << "CCAW" << " failed to be added" << endmsg;
comps[0] = "indet::Polyetherimide"; fracs[0] = 0.409;
comps[1] = "std::Copper"; fracs[1] = 0.591;
geomat = m_geoMgr->matMgr()->getMaterial( "indet::TwistedPair_awg36Base", comps, fracs, 1.);
if (geomat) msg(MSG::INFO) << "Material with name name " << "TwistedPair_awg36Base" << " added" << endmsg;
else msg(MSG::INFO) << "Material with name name " << "TwistedPair_awg36Base" << " failed to be added" << endmsg;
comps[0] = "std::Carbon"; fracs[0] = 0.27;
comps[1] = "Oxygen"; fracs[1] = 0.73;
geomat = m_geoMgr->matMgr()->getMaterial( "pix::CO2_Liquid", comps, fracs, 1.);
if (geomat) msg(MSG::INFO) << "Material with name name " << "pix::CO2_Liquid" << " added" << endmsg;
else msg(MSG::INFO) << "Material with name name " << "pix::CO2_Liquid" << " failed to be added" << endmsg;
comps.resize(3); fracs.resize(3);
comps[0] = "indet::Polyetherimide"; fracs[0] = 0.276;
comps[1] = "std::Copper"; fracs[1] = 0.346;
comps[2] = "std::Aluminium"; fracs[2] = 0.378;
geomat = m_geoMgr->matMgr()->getMaterial( "indet::ScreenedTwistP_36Base", comps, fracs, 1.);
if (geomat) msg(MSG::INFO) << "Material with name name " << "ScreenedTwistP_36Base" << " added" << endmsg;
else msg(MSG::INFO) << "Material with name name " << "ScreenedTwistP_36Base" << " failed to be added" << endmsg;
std::vector<std::string> comps(3);
std::vector<double> fracs(3);
comps[0] = "indet::CCAW"; fracs[0] = 0.104;
comps[1] = "std::Aluminium"; fracs[1] = 0.070;
comps[2] = "indet::Polyetherimide"; fracs[2] = 0.826;
const GeoMaterial* geomat = m_geoMgr->matMgr()->getMaterial( "indet::TwinaxBase", comps, fracs, 1.);
if (geomat) msg(MSG::INFO) << "Material with name name " << "TwinaxBase" << " added" << endmsg;
else msg(MSG::INFO) << "Material with name name " << "TwinaxBase" << " failed to be added" << endmsg;
std::vector<std::string> comps(1);
std::vector<double> fracs(1);
comps.resize(1); fracs.resize(1);
comps[0] = "std::Copper"; fracs[0] = 1.0;
addMissingMaterial( "indet::ShieldingSleeveBase", comps, fracs);
comps[0] = "std::Polyethylene"; fracs[0] = 1.0;
addMissingMaterial( "indet::ProtectionSleeveBase", comps, fracs);
*/
}
void InDetServMatBuilderToolSLHC::addMissingMaterial( const std::string& name,
const std::vector<std::string>& comps,
const std::vector<double>& fracs, double dens)
{
const GeoMaterial* geomat = m_geoMgr->matMgr()->getMaterial( name, comps, fracs, dens);
if (geomat) msg(MSG::DEBUG) << "Material with name name " << name << " added" << endmsg;
else msg(MSG::INFO) << "Material with name name " << name << " failed to be added" << endmsg;
}
/*
std::string InDetServMatBuilderToolSLHC::getKnownName( const std::string& name, InDetMaterialManager* matMgr)
{
std::string kname = name;
const GeoMaterial* geomat = matMgr->getMaterial(name);
if (geomat) {
msg(MSG::INFO) << "Material with name name " << name << " found" << endmsg;
return name;
}
else {
kname = "indet::"; kname += name;
geomat = matMgr->getMaterial(kname);
if (geomat) {
msg(MSG::INFO) << "Material with name name " << kname << " found" << endmsg;
return kname;
}
else {
if (name == "CCAW") {
std::vector<std::string> comps(2);
comps[0] = "std::Aluminium";
comps[1] = "std::Copper";
std::vector<double> fracs(2);
fracs[0] = 0.731;
fracs[1] = 0.269;
geomat = matMgr->getMaterial( name, comps, fracs, 3.33);
}
else if (name == "UnshieldedTwistedPair_awg36") {
std::vector<std::string> comps(2);
comps[0] = "indet::Polyetherimide";
comps[1] = "std::Copper";
std::vector<double> fracs(2);
fracs[0] = 0.4;
fracs[1] = 0.6;
geomat = matMgr->getMaterial( name, comps, fracs, 1.);
}
else {
msg(MSG::INFO) << "Error: Material with name name " << name << " or " << kname << " not found" << endmsg;
return "";
}
msg(MSG::INFO) << "Material with name name " << name << " created" << endmsg;
return name;
}
}
}
*/
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#include "InDetServMatGeoModel/InDetServMatFactorySLHC.h"
#include "InDetServMatGeoModel/InDetServMatAthenaComps.h"
#include "InDetGeoModelUtils/IInDetServMatBuilderTool.h"
// Extra material
//#include "InDetGeoModelUtils/DistortedMaterialManager.h"
//#include "InDetGeoModelUtils/ExtraMaterial.h"
// General Service Builder
#include "InDetGeoModelUtils/VolumeBuilder.h"
#include "InDetGeoModelUtils/VolumeSplitterUtils.h"
#include "InDetGeoModelUtils/ServiceVolume.h"
#include "InDetGeoModelUtils/InDetMaterialManager.h"
// GeoModel includes
#include "GeoModelKernel/GeoTube.h"
#include "GeoModelKernel/GeoNameTag.h"
#include "GeoModelKernel/GeoPhysVol.h"
#include "GeoModelKernel/GeoPcon.h"
#include "GeoModelKernel/GeoShapeUnion.h"
#include "GeoModelInterfaces/StoredMaterialManager.h"
#include "GeoModelInterfaces/IGeoDbTagSvc.h"
#include "GeoModelUtilities/DecodeVersionKey.h"
#include "GeometryDBSvc/IGeometryDBSvc.h"
// StoreGate includes
#include "StoreGate/StoreGateSvc.h"
#include "RDBAccessSvc/IRDBRecord.h"
#include "RDBAccessSvc/IRDBRecordset.h"
#include "RDBAccessSvc/IRDBAccessSvc.h"
#include "CxxUtils/checker_macros.h"
#include "GaudiKernel/PhysicalConstants.h"
#include <iostream>
InDetServMatFactorySLHC::InDetServMatFactorySLHC(InDetServMatAthenaComps * athenaComps)
: InDetDD::DetectorFactoryBase(athenaComps),
m_athenaComps(athenaComps),
m_manager(nullptr)
{
// create a new det manager
m_manager = new InDetDD::InDetServMatManager();
}
InDetServMatFactorySLHC::~InDetServMatFactorySLHC()
{
delete m_manager;
}
//## Other Operations (implementation)
void InDetServMatFactorySLHC::create(GeoPhysVol *world )
{
// Get the material manager:
InDetMaterialManager * materialManager = new InDetMaterialManager("InDetServMatMaterialManager",m_athenaComps);
fetchTables();
InDetDD::Zone * zone = nullptr;
const GeoShape * envelopeShape = nullptr;
if (simpleEnvelope() || oldEnvelope()) {
// tube
double innerRadius;
double outerRadius;
double cylLength;
if (oldEnvelope()) {
innerRadius = geomDB()->getDouble("","SERVICESINNERRADIUS") * Gaudi::Units::mm;
outerRadius = geomDB()->getDouble("","SERVICESOUTERRADIUS") * Gaudi::Units::mm;
cylLength = geomDB()->getDouble("","SERVICESCYLLENGTH") * Gaudi::Units::mm;
} else {
innerRadius = envelopeRMin();
outerRadius = envelopeRMax();
cylLength = envelopeLength();
}
envelopeShape = new GeoTube(innerRadius, outerRadius, 0.5*cylLength);
zone = new InDetDD::TubeZone("InDetServMat", -0.5*cylLength, 0.5*cylLength, innerRadius, outerRadius);
} else {
GeoPcon* envelopeShapeTmp = new GeoPcon(0.,2*Gaudi::Units::pi);
// table contains +ve z values only and envelope is assumed to be symmetric around z.
int numPlanes = envelopeNumPlanes();
for (int i = 0; i < numPlanes * 2; i++) {
int tableIndex = (i < numPlanes) ? numPlanes - 1 - i : i - numPlanes;
int sign = (i < numPlanes) ? -1 : 1;
double z = envelopeZ(tableIndex) * sign;
double rmin = envelopeRMin(tableIndex);
double rmax = envelopeRMax(tableIndex);
envelopeShapeTmp->addPlane(z, rmin, rmax);
}
envelopeShape = envelopeShapeTmp;
zone = new InDetDD::PconZone("InDetServMat",envelopeShapeTmp);
}
const GeoMaterial* air = materialManager->getMaterial("std::Air");
GeoLogVol* servLog = new GeoLogVol("ServLog", envelopeShape, air);
GeoPhysVol* servPhys = new GeoPhysVol(servLog);
// build general services
InDetDD::UnboundedZone topZone("");
topZone.add(zone);
if (m_athenaComps->builderTool()) {
const std::vector<const InDetDD::ServiceVolume *> & services = m_athenaComps->builderTool()->getServices();
InDetDD::VolumeBuilder builder(topZone, services);
builder.setMaterialManager(materialManager);
builder.buildAndPlace("InDetServMat", servPhys);
}
// Add this to the world and register it to the manager so GeoG4 will
// find it.
//
GeoNameTag *tag = new GeoNameTag("InDetServMat");
world->add(tag);
world->add(servPhys);
m_manager->addTreeTop(servPhys);
delete materialManager;
}
const InDetDD::InDetServMatManager* InDetServMatFactorySLHC::getDetectorManager () const {
return m_manager;
}
void
InDetServMatFactorySLHC::fetchTables()
{
DecodeVersionKey indetVersionKey(geoDbTagSvc(), "InnerDetector");
msg(MSG::INFO) << "Building InDet Service Material with InDet Version Tag: "
<< indetVersionKey.tag() << " at Node: " << indetVersionKey.node() << endmsg;
msg(MSG::INFO) << " InDetServices Version "
<< rdbAccessSvc()->getChildTag("InDetServices", indetVersionKey.tag(), indetVersionKey.node()) << endmsg;
m_InDetServGenEnvelope = rdbAccessSvc()->getRecordsetPtr("InDetServGenEnvelope", indetVersionKey.tag(), indetVersionKey.node());
msg(MSG::DEBUG) << "Table InDetServGenEnvelope Fetched" << endmsg;
}
double
InDetServMatFactorySLHC::envelopeLength() const
{
if (geomDB()->getTableSize(m_InDetServGenEnvelope)) {
// The table should contain only +ve z values.
return 2*envelopeZ(geomDB()->getTableSize(m_InDetServGenEnvelope) - 1);
} else {
msg(MSG::ERROR) << "Unexpected error. InDetServGenEnvelope has zero size" << endmsg;
return 0;
}
}
bool
InDetServMatFactorySLHC::simpleEnvelope() const
{
// Return true if the envelope can be built as a simple tube.
// otherwise it will be built as a PCON.
// True if size is 1.
return (geomDB()->getTableSize(m_InDetServGenEnvelope) == 1);
}
bool
InDetServMatFactorySLHC::oldEnvelope() const
{
// Return true if the envelope is not provided.
// True if size is 0.
return (geomDB()->getTableSize(m_InDetServGenEnvelope) == 0);
}
unsigned int
InDetServMatFactorySLHC::envelopeNumPlanes() const
{
return geomDB()->getTableSize(m_InDetServGenEnvelope);
}
double
InDetServMatFactorySLHC::envelopeZ(int i) const
{
double zmin = geomDB()->getDouble(m_InDetServGenEnvelope,"Z",i) * Gaudi::Units::mm;
if (zmin < 0) msg(MSG::ERROR) << "InDetServGenEnvelope table should only contain +ve z values" << endmsg;
return std::abs(zmin);
}
double
InDetServMatFactorySLHC::envelopeRMin(int i) const
{
return geomDB()->getDouble(m_InDetServGenEnvelope,"RMIN",i) * Gaudi::Units::mm;
}
double
InDetServMatFactorySLHC::envelopeRMax(int i) const
{
return geomDB()->getDouble(m_InDetServGenEnvelope,"RMAX",i) * Gaudi::Units::mm;
}
......@@ -7,7 +7,6 @@
#include "InDetServMatGeoModel/InDetServMatFactoryDC2.h"
#include "InDetServMatGeoModel/InDetServMatFactoryDC3.h"
#include "InDetServMatGeoModel/InDetServMatFactoryFS.h"
#include "InDetServMatGeoModel/InDetServMatFactorySLHC.h"
#include "InDetGeoModelUtils/IInDetServMatBuilderTool.h"
#include "InDetServMatGeoModel/InDetServMatAthenaComps.h"
......@@ -191,14 +190,6 @@ StatusCode InDetServMatTool::create()
InDetServMatFactory theIDSM(m_athenaComps);
theIDSM.create(world);
m_manager=theIDSM.getDetectorManager();
} else if (versionName == "SLHC") {
if(msgLvl(MSG::DEBUG)) msg() << " InDetServMat Factory SLHC version " << endmsg;
InDetServMatFactorySLHC theIDSM(m_athenaComps);
if(descrName.compare("TrackingGeometry")!=0)
theIDSM.create(world);
else
msg(MSG::INFO) << "InDetServices - TrackingGeometry tag - no geometry built" << endmsg;
m_manager=theIDSM.getDetectorManager();
} else {
// Unrecognized name.
msg(MSG::ERROR) << " Unrecognized VersionName: " << versionName << endmsg;
......
#include "InDetServMatGeoModel/InDetServMatTool.h"
#include "InDetServMatGeoModel/InDetServMatBuilderToolSLHC.h"
DECLARE_COMPONENT( InDetServMatTool )
DECLARE_COMPONENT( InDetServMatBuilderToolSLHC )
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