From 21ba75d21c31921c7648f627cb97d2c764435717 Mon Sep 17 00:00:00 2001 From: Dave Casper <dcasper@localhost.localdomain> Date: Thu, 29 Aug 2019 23:12:19 -0700 Subject: [PATCH] Work in progress: veto detector with geometry --- .../DistortedMaterialManager.h | 28 + .../ScintGeoModelUtils/ExtraMaterial.h | 37 + .../ScintGeoModelUtils/GenericTubeMaker.h | 55 + .../ScintGeoModelUtils/ScintMaterialManager.h | 244 ++++ .../ScintGeoModelUtils/TopLevelPlacements.h | 47 + .../ScintGeoModelUtils/TubeVolData.h | 59 + .../src/DistortedMaterialManager.cxx | 46 + .../ScintGeoModelUtils/src/ExtraMaterial.cxx | 75 ++ .../src/GenericTubeMaker.cxx | 164 +++ .../src/ScintMaterialManager.cxx | 1042 +++++++++++++++++ .../src/TopLevelPlacements.cxx | 123 ++ .../ScintGeoModelUtils/src/TubeVolData.cxx | 101 ++ .../ScintDetectorManager.h | 11 +- .../ScintReadoutGeometry/ScintNumerology.h | 31 +- .../ScintReadoutGeometry/ScintNumerology.icc | 25 +- .../VetoDetectorManager.h | 2 +- .../src/ScintDetectorManager.cxx | 17 +- .../src/ScintNumerology.cxx | 30 +- .../src/VetoDetectorManager.cxx | 4 +- .../VetoGeoModel/VetoComponentFactory.h | 89 ++ .../VetoGeoModel/VetoGeoModel/VetoDataBase.h | 151 +++ .../VetoGeoModel/VetoDetectorFactory.h | 2 +- .../VetoGeoModel/VetoGeneralParameters.h | 45 + .../VetoGeoModel/VetoGeometryManager.h | 66 ++ .../VetoGeoModel/VetoIdentifier.h | 41 + .../VetoGeoModel/VetoMaterialManager.h | 48 + .../VetoGeoModel/VetoGeoModel/VetoStation.h | 53 + .../VetoGeoModel/VetoStationParameters.h | 190 +++ .../VetoGeoModel/src/VetoComponentFactory.cxx | 40 + .../VetoGeoModel/src/VetoDataBase.cxx | 267 +++++ .../VetoGeoModel/src/VetoDetectorFactory.cxx | 32 +- .../src/VetoGeneralParameters.cxx | 88 ++ .../VetoGeoModel/src/VetoGeometryManager.cxx | 112 ++ .../VetoGeoModel/src/VetoIdentifier.cxx | 23 + .../VetoGeoModel/src/VetoMaterialManager.cxx | 83 ++ .../VetoGeoModel/src/VetoStation.cxx | 286 +++++ .../src/VetoStationParameters.cxx | 866 ++++++++++++++ 37 files changed, 4524 insertions(+), 99 deletions(-) create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/DistortedMaterialManager.h create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/ExtraMaterial.h create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/GenericTubeMaker.h create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/ScintMaterialManager.h create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/TopLevelPlacements.h create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/TubeVolData.h create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/src/DistortedMaterialManager.cxx create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/src/ExtraMaterial.cxx create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/src/GenericTubeMaker.cxx create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/src/ScintMaterialManager.cxx create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/src/TopLevelPlacements.cxx create mode 100644 Scintillator/ScintDetDescr/ScintGeoModelUtils/src/TubeVolData.cxx create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoComponentFactory.h create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDataBase.h create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeneralParameters.h create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeometryManager.h create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoIdentifier.h create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoMaterialManager.h create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStation.h create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStationParameters.h create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/src/VetoComponentFactory.cxx create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDataBase.cxx create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeneralParameters.cxx create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeometryManager.cxx create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/src/VetoIdentifier.cxx create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/src/VetoMaterialManager.cxx create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStation.cxx create mode 100644 Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStationParameters.cxx diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/DistortedMaterialManager.h b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/DistortedMaterialManager.h new file mode 100644 index 000000000..0697b959a --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/DistortedMaterialManager.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ScintGeoModelUtils_DistortedMaterialManager_h +#define ScintGeoModelUtils_DistortedMaterialManager_h + +class AbsMaterialManager; +#include "RDBAccessSvc/IRDBAccessSvc.h" + +namespace ScintDD { + +class DistortedMaterialManager +{ +public: + DistortedMaterialManager(); + IRDBRecordset_ptr extraMaterialTable() const {return m_xMatTable;} + const AbsMaterialManager * materialManager() const {return m_materialManager;} + +private: + const AbsMaterialManager * m_materialManager; + IRDBRecordset_ptr m_xMatTable; +}; + + +} // endnamespace + +#endif // ScintGeoModelUtils_DistortedMaterialManager_h diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/ExtraMaterial.h b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/ExtraMaterial.h new file mode 100644 index 000000000..8f18b6214 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/ExtraMaterial.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ScintGeoModelUtils_ExtraMaterial +#define ScintGeoModelUtils_ExtraMaterial + +#include <cmath> +#include <string> +#include <sstream> +#include "RDBAccessSvc/IRDBAccessSvc.h" + +class GeoPhysVol; +class GeoFullPhysVol; +class AbsMaterialManager; + +namespace ScintDD { + +class DistortedMaterialManager; + +class ExtraMaterial +{ +public: + ExtraMaterial(IRDBRecordset_ptr xMatTable, const AbsMaterialManager * matManager); + ExtraMaterial(const ScintDD::DistortedMaterialManager * manager); + void add(GeoPhysVol * parent, const std::string & parentName, double zPos = 0); + void add(GeoFullPhysVol * parent, const std::string & parentName, double zPos = 0); + +private: + void add(GeoPhysVol * parent, GeoFullPhysVol * fullparent, const std::string & parentName, double zPos); + IRDBRecordset_ptr m_xMatTable; + const AbsMaterialManager * m_matManager; +}; + +} // end namespace + +#endif // ScintGeoModelUtils_ExtraMaterial diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/GenericTubeMaker.h b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/GenericTubeMaker.h new file mode 100644 index 000000000..eb243ea1b --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/GenericTubeMaker.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ScintGeoModelUtils_GenericTubeMaker_h +#define ScintGeoModelUtils_GenericTubeMaker_h + +#include "ScintGeoModelUtils/TubeVolData.h" +#include <string> + +class GeoVPhysVol; +class GeoPhysVol; +class GeoFullPhysVol; +class GeoShape; +class IRDBRecord; + +/// Helper class to make general tubes used mainly for services. +/// Takes as input a DB table which has the following columns +/// Handles numberouse cases +/// Simple tubes: Rmin2, Rmax2 <=0. +/// Cones: Uses Rmin2 and Rmax2. +/// Tube and cone sectors: Uses phi start and phi delta. +/// If RadialDiv > 0 then simulates the CLHEP::radial dependence of tubes/cables going outward CLHEP::radially. +/// + +namespace ScintDD { + +class GenericTubeMaker +{ +public: + GenericTubeMaker(const IRDBRecord *); + const TubeVolData & volData() const {return m_volData;} + std::string name() const; + std::string materialName() const; + const GeoShape * buildShape(); + void placeVolume(GeoPhysVol * parent, GeoVPhysVol * child, double zParent = 0); + void placeVolume(GeoFullPhysVol * fullparent, GeoVPhysVol * child, double zParent = 0); + void placeVolTwoSide(GeoPhysVol * parentPos, GeoPhysVol * parentNeg, GeoVPhysVol * child, double zParent = 0); + void placeVolTwoSide(GeoFullPhysVol * fullparentPos, GeoFullPhysVol * fullparentNeg, GeoVPhysVol * child, double zParent = 0); + + +private: + + void placeVolume(GeoPhysVol * parent, GeoFullPhysVol * fullparent, GeoVPhysVol * child, double zParent); + void placeVolTwoSide(GeoPhysVol * parentPos, GeoPhysVol * parentNeg, + GeoFullPhysVol * fullparentPos, GeoFullPhysVol * fullparentNeg, + GeoVPhysVol * child, double zParent); + + const IRDBRecord * m_record; + TubeVolData m_volData; +}; + +} // end namespace + +#endif // ScintGeoModelUtils_GenericTubeMaker_h diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/ScintMaterialManager.h b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/ScintMaterialManager.h new file mode 100644 index 000000000..123b08d2b --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/ScintMaterialManager.h @@ -0,0 +1,244 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCINTMATERIALMANAGER_H +#define SCINTMATERIALMANAGER_H + +// Message Stream Member +#include "AthenaKernel/MsgStreamMember.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" + +class GeoMaterial; +class GeoElement; +class AbsMaterialManager; +class StoreGateSvc; +class IGeometryDBSvc; + +namespace ScintDD +{ + class AthenaComps; +} + +#include <string> +#include <map> + +/// ScintMaterialManager. This provides an interface to the GeoModel Material Manager +/// as well as allowing additional materials to be defined or standard ones redefined. +/// It also allows creating new materials based on existing ones but with a different +/// density. It is also possible to specify a weight table and this is used to create +/// materials with a density such that the the total weight is correct. + + +class ScintMaterialManager +{ + +public: + + ScintMaterialManager(const std::string & managerName, StoreGateSvc* detStore); + ScintMaterialManager(const std::string & managerName, StoreGateSvc* detStore, + IRDBRecordset_ptr weightTable, + const std::string & space = "", + bool extraFunctionality = false); + ScintMaterialManager(const std::string & managerName, StoreGateSvc* detStore, + IRDBRecordset_ptr weightTable, + IRDBRecordset_ptr compositionTable, + const std::string & space = ""); + ScintMaterialManager(const std::string & managerName, + const ScintDD::AthenaComps *); + ~ScintMaterialManager(); + + void addWeightTable(IRDBRecordset_ptr weightTable, const std::string & space = ""); + void addWeightMaterial(std::string materialName, std::string materialBase, double weight, int linearWeightFlag); + void addCompositionTable(IRDBRecordset_ptr compositionTable, const std::string & space = ""); + void addScalingTable(IRDBRecordset_ptr scalingTable); + + + bool hasMaterial(const std::string &materialName) const; + + /// Get material. First looks for locally defined material and if not found looks in GeoModel material manager. + const GeoMaterial* getMaterial(const std::string & materialName); + + /// Get element from GeoModel material manager + const GeoElement* getElement(const std::string & elementName) const; + + /// Create and get material with a specified density based on an existing material. + /// If a newName is supplied it creates the new material even if the orginal material + /// has the same density. It however first checks if the material with NewName exists. + /// If no newName is supplied then it checks the density of + /// the existing material. If it is consistent it returns the material. + /// If it is different it creates a material with the string "Modified" added to the + /// name. + const GeoMaterial* getMaterial(const std::string & origMaterialName, + double density, + const std::string & newName = ""); + + // Creates a new material based on origMaterialName but with denisty scaled + // by scaleFactor. If no newName then will add the string containing the scale + // factor. Eg if scale 12.345678 "Silicon" -> "Silicon12_3456" + // If the scale factor is 1 and there is no newName then it just returns the + // original material. + // scaleFactor must be between 0.001 and 1000. + const GeoMaterial* getMaterialScaled(const std::string & origMaterialName, + double scaleFactor, + const std::string & newName = ""); + + /// Create and get material with a density calculated to give weight in predefined weight table. + const GeoMaterial * getMaterialForVolume(const std::string & materialName, + double volume, + const std::string & newName = ""); + + // Similar to getMaterialForVolume but if weight table uses linear weight, then determine weight + // using length. First looks in special table of material compositions which can specify several + // components and their count. + const GeoMaterial * getMaterialForVolumeLength(const std::string & materialName, + double volume, + double length, + const std::string & newName = ""); + + // As above but rather than using the special table of material compositions, the compositions is specified + // in the arguments as a vector of materials and multiplictive factors. + const GeoMaterial * getMaterialForVolumeLength(const std::string & name, + const std::vector<std::string> & materialComponents, + const std::vector<double> factors, + double volume, + double length); + + // As above but only one material making up the composition. + const GeoMaterial * getMaterialForVolumeLength(const std::string & name, + const std::string & materialComponent, + double factor, + double volume, + double length); + + // Define composite material : function used to create dynamically a new composite material by adding + // a defined volume of glue/grease to an already existing material (IBL stave) + const GeoMaterial * getCompositeMaterialForVolume(const std::string & newMatName, + const double volumeTot, + const double volume1, const std::string & matName1, + const double volume2, const std::string & matName2 + ); + + // Define a new material composition. + const GeoMaterial * getMaterial(const std::string & name, + const std::vector<std::string> & materialComponents, + const std::vector<double> & fractWeights, + double density); + + + /// Add material + void addMaterial(GeoMaterial *material); + + //Declaring the Message method for further use + MsgStream& msg (MSG::Level lvl) const { return m_msg << lvl; } + + //Declaring the Method providing Verbosity Level + bool msgLvl (MSG::Level lvl){ return m_msg.get().level() <= lvl; } + + +private: + + class MaterialByWeight { + public: + MaterialByWeight() : weight(0), linearWeightFlag(false) {} + MaterialByWeight(const std::string & name_in, double weight_in, bool linearWeightFlag_in) + : name(name_in), weight(weight_in), linearWeightFlag(linearWeightFlag_in) {} + MaterialByWeight(double weight_in) + : weight(weight_in), linearWeightFlag(false) {} + std::string name; + double weight; + bool linearWeightFlag; + }; + + class MaterialComponent { + public: + MaterialComponent() : factor(1), actualLength(-1) {} + MaterialComponent(const std::string & name_in, double factor_in = 1, bool actualLength_in = -1) + : name(name_in), factor(factor_in), actualLength(actualLength_in) {} + std::string name; + double factor; + double actualLength; + }; + + /// Class to hold information need to create a material + class MaterialDef { + public: + MaterialDef(); + MaterialDef(const std::string & name, double density); + void addComponent(const std::string & compName, double fraction); + void setCreated() {m_created = true;} + unsigned int numComponents() const {return m_components.size();} + bool isCreated() const {return m_created;} + const std::string & name() const {return m_name;} + double density() const {return m_density;} + const std::string & compName(unsigned int i) const {return m_components[i];} + double fraction(unsigned int i) const {return m_fractions[i];} + double totalFraction() const; + + private: + std::string m_name; + double m_density; + std::vector<std::string> m_components; + std::vector<double> m_fractions; + bool m_created; + }; + + + const AbsMaterialManager * retrieveManager(StoreGateSvc* detStore); + const GeoMaterial* getAdditionalMaterial(const std::string & materialName) const; + bool compareDensity(double d1, double d2) const; + void addWeightTableOld(IRDBRecordset_ptr weightTable, const std::string & space); + + // Internal versions. The public versions allow materials to be have extra scaling. + const GeoMaterial* getMaterialInternal(const std::string & materialName) const; + const GeoMaterial* getMaterialInternal(const std::string & origMaterialName, + double density, + const std::string & newName = ""); + const GeoMaterial* getMaterialScaledInternal(const std::string & origMaterialName, + double scaleFactor, + const std::string & newName = ""); + const GeoMaterial * getMaterialInternal(const std::string & name, + const std::vector<std::string> & materialComponents, + const std::vector<double> & fractWeights, + double density); + + // Methods to return material with extra scaling. + const GeoMaterial * extraScaledMaterial(const std::string & materialName, + const std::string & newName, + const GeoMaterial * origMaterial); + + const GeoMaterial * extraScaledMaterial(const std::string & materialName, + const GeoMaterial * origMaterial); + + const IGeometryDBSvc * db(); + void addTextFileMaterials(); + void createMaterial(const MaterialDef & material); + double getExtraScaleFactor(const std::string & materialName); + + const AbsMaterialManager *m_materialManager; + std::string m_managerName; + + typedef std::map<std::string, const GeoMaterial *> MaterialStore; + MaterialStore m_store; + + typedef std::map<std::string, MaterialByWeight > MaterialWeightMap; + MaterialWeightMap m_weightMap; + + typedef std::map<std::string, MaterialComponent > MaterialCompositionMap; + MaterialCompositionMap m_matCompositionMap; + + typedef std::map<std::string, double > ExtraScaleFactorMap; + ExtraScaleFactorMap m_scalingMap; + + //Declaring private message stream member. + mutable Athena::MsgStreamMember m_msg; + + // Has linear weight flag. + bool m_extraFunctionality; + + const ScintDD::AthenaComps * m_athenaComps; + +}; + + +#endif // SCINTMATERIALMANAGER_H diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/TopLevelPlacements.h b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/TopLevelPlacements.h new file mode 100644 index 000000000..53d45c5b5 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/TopLevelPlacements.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef SCINTGEOMODELUTILS_TOPLEVELPLACEMENTS_H +#define SCINTGEOMODELUTILS_TOPLEVELPLACEMENTS_H + +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "GeoPrimitives/GeoPrimitives.h" +#include "GeoModelKernel/GeoDefinitions.h" + +#include <map> +#include <string> + +class IRDBRecord; + +class TopLevelPlacements +{ + +public: + + TopLevelPlacements(IRDBRecordset_ptr topLevelTable); + ~TopLevelPlacements(); + + bool present(const std::string & partName) const; + const GeoTrf::Transform3D & transform(const std::string & partName) const; + + +private: + + class Part { + public: + std::string label; + GeoTrf::Transform3D transform; + }; + + void fillPlacements(IRDBRecordset_ptr topLevelTable); + GeoTrf::Transform3D partTransform(const IRDBRecord* record) const; + Part * getPart(const std::string & partName) const; + + std::map<std::string, Part *> m_parts; + bool m_noTopLevelTable; + + static GeoTrf::Transform3D s_identityTransform; +}; + +#endif // SCINTGEOMODELUTILS_TOPLEVELPLACEMENTS_H diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/TubeVolData.h b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/TubeVolData.h new file mode 100644 index 000000000..15e421072 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/ScintGeoModelUtils/TubeVolData.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ScintGeoModelUtils_TubeVolData_h +#define ScintGeoModelUtils_TubeVolData_h + +class IRDBRecord; +#include <string> + +namespace ScintDD { + + +/// Helper class to read in generic TUBE, TUBS, CONS or PCON type volumes. + +class TubeVolData +{ + public: + enum VolShape {TUBE, TUBS, CONS, RADIAL}; + + TubeVolData(const IRDBRecord *); + double rmin() const {return m_rmin1;} + double rmax() const {return m_rmax1;} + double rmin2() const {return m_rmin2;} + double rmax2() const {return m_rmax2;} + double length() const {return m_length;} + double zMid() const {return m_zMid;} + double phiStart() const {return m_phiStart;} + double phiDelta() const {return m_phiDelta;} + double phiStep() const {return m_phiStep;} + int nRepeat() const {return m_nRepeat;} + int radialDivisions() const {return m_radialDiv;} + bool bothZ() const {return m_bothZ;} + + VolShape shape() const {return m_shape;} + std::string material() const; + + double maxRadius() const; + + private: + const IRDBRecord * m_record; + bool m_bothZ; + int m_nRepeat; + int m_radialDiv; + double m_phiStart; + double m_phiDelta; + double m_phiStep; + double m_rmin1; + double m_rmin2; + double m_rmax1; + double m_rmax2; + double m_length; + double m_zMid; + VolShape m_shape{CONS}; +}; + +} // end namespace + +#endif // ScintGeoModelUtils_TubeVolData diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/DistortedMaterialManager.cxx b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/DistortedMaterialManager.cxx new file mode 100644 index 000000000..6de4154f5 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/DistortedMaterialManager.cxx @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + */ + + +#include "ScintGeoModelUtils/DistortedMaterialManager.h" +#include "GeoModelInterfaces/StoredMaterialManager.h" +#include "GeoModelUtilities/DecodeVersionKey.h" +#include "AthenaKernel/MsgStreamMember.h" +#include "StoreGate/StoreGate.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/Bootstrap.h" + +namespace ScintDD { + DistortedMaterialManager::DistortedMaterialManager() { + ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap + + Athena::MsgStreamMember log("ExtraMaterialManager"); + log << MSG::DEBUG << "Initialized Scint Distorted Material Manager" << endmsg; + + StoreGateSvc* detStore; + StatusCode sc; + sc = svcLocator->service("DetectorStore", detStore); + if (sc.isFailure()) log << MSG::FATAL << "Could not locate DetectorStore" << endmsg; + + IRDBAccessSvc* rdbSvc; + sc = svcLocator->service("RDBAccessSvc", rdbSvc); + if (sc.isFailure()) log << MSG::FATAL << "Could not locate RDBAccessSvc" << endmsg; + + // Get version tag and node for InDet. + DecodeVersionKey versionKey("Scintillator"); + std::string detectorKey = versionKey.tag(); + std::string detectorNode = versionKey.node(); + + log << MSG::DEBUG << "Retrieving Record Sets from database ..." << endmsg; + log << MSG::DEBUG << "Key = " << detectorKey << " Node = " << detectorNode << endmsg; + + m_xMatTable = rdbSvc->getRecordsetPtr("ScintExtraMaterial", detectorKey, detectorNode); + + const StoredMaterialManager* theGeoMaterialManager = 0; + sc = detStore->retrieve(theGeoMaterialManager, "MATERIALS"); + if (sc.isFailure()) log << MSG::FATAL << "Could not locate GeoModel Material manager" << endmsg; + m_materialManager = theGeoMaterialManager; + } +} // end namespace diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/ExtraMaterial.cxx b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/ExtraMaterial.cxx new file mode 100644 index 000000000..9f8a385a1 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/ExtraMaterial.cxx @@ -0,0 +1,75 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + */ + +#include "ScintGeoModelUtils/ExtraMaterial.h" +#include "ScintGeoModelUtils/GenericTubeMaker.h" +#include "ScintGeoModelUtils/TubeVolData.h" +#include "ScintGeoModelUtils/DistortedMaterialManager.h" +//#include "ScintGeoModelUtils/InDetMaterialManager.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "GeoPrimitives/GeoPrimitives.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoFullPhysVol.h" +#include "GeoModelKernel/GeoTube.h" +#include "GeoModelKernel/GeoTubs.h" +#include "GeoModelKernel/GeoCons.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoMaterial.h" + +#include "GeoModelInterfaces/AbsMaterialManager.h" + +#include <string> +#include <sstream> +#include <iostream> + +namespace ScintDD { + ExtraMaterial::ExtraMaterial(IRDBRecordset_ptr xMatTable, const AbsMaterialManager* matManager) + : m_xMatTable(xMatTable), + m_matManager(matManager) + {} + + ExtraMaterial::ExtraMaterial(const DistortedMaterialManager* manager) + : m_xMatTable(manager->extraMaterialTable()), + m_matManager(manager->materialManager()) + {} + + void + ExtraMaterial::add(GeoPhysVol* parent, const std::string& region, double zParent) { + add(parent, 0, region, zParent); + } + + void + ExtraMaterial::add(GeoFullPhysVol* parent, const std::string& region, double zParent) { + add(0, parent, region, zParent); + } + + void + ExtraMaterial::add(GeoPhysVol* parent, GeoFullPhysVol* fullparent, const std::string& region, double zParent) { + //std::cout << "Adding Extra material for region: " << region << ", zParent = " << zParent << std::endl; + + for (unsigned int i = 0; i < m_xMatTable->size(); i++) { + std::ostringstream volnamestr; + volnamestr << "ExtraMaterial" << i; + + //std::cout << "In Extra material " << i << std::endl; + + if ((*m_xMatTable)[i]->getString("REGION") == region) { + //std::cout << "Extra material Match " << i << std::endl; + + GenericTubeMaker tubeHelper((*m_xMatTable)[i]); + const GeoMaterial* material = m_matManager->getMaterial(tubeHelper.volData().material()); + const GeoShape* shape = tubeHelper.buildShape(); + GeoLogVol* logVol = new GeoLogVol(volnamestr.str(), shape, material); + GeoPhysVol* physVol = new GeoPhysVol(logVol); + + if (parent) { + tubeHelper.placeVolume(parent, physVol, zParent); + } else { + tubeHelper.placeVolume(fullparent, physVol, zParent); + } + } + } + } +} // end namespace diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/GenericTubeMaker.cxx b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/GenericTubeMaker.cxx new file mode 100644 index 000000000..5699ed121 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/GenericTubeMaker.cxx @@ -0,0 +1,164 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + */ + +#include "ScintGeoModelUtils/GenericTubeMaker.h" +#include "ScintGeoModelUtils/TubeVolData.h" + +#include "GeoModelKernel/GeoTube.h" +#include "GeoModelKernel/GeoTubs.h" +#include "GeoModelKernel/GeoCons.h" +#include "GeoModelKernel/GeoPcon.h" +#include "GeoModelKernel/GeoTransform.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoFullPhysVol.h" +#include "GeoModelKernel/GeoDefinitions.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include "RDBAccessSvc/IRDBRecord.h" + +namespace ScintDD { + GenericTubeMaker::GenericTubeMaker(const IRDBRecord* record) + : m_record(record), + m_volData(record) + {} + + std::string + GenericTubeMaker::materialName() const { + return m_record->getString("MATERIAL"); + } + + std::string + GenericTubeMaker::name() const { + return m_record->getString("NAME"); + } + + const GeoShape* + GenericTubeMaker::buildShape() { + const GeoShape* shape = 0; + + switch (m_volData.shape()) { + case TubeVolData::TUBE: + shape = new GeoTube(m_volData.rmin(), m_volData.rmax(), 0.5 * m_volData.length()); + break; + + case TubeVolData::TUBS: + shape = new GeoTubs(m_volData.rmin(), m_volData.rmax(), 0.5 * m_volData.length(), + m_volData.phiStart(), m_volData.phiDelta()); + break; + + case TubeVolData::CONS: + shape = new GeoCons(m_volData.rmin(), m_volData.rmin2(), m_volData.rmax(), m_volData.rmax2(), + 0.5 * m_volData.length(), m_volData.phiStart(), m_volData.phiDelta()); + break; + + case TubeVolData::RADIAL: + // This simulates the radial decrease in density. + double zstart = -0.5 * m_volData.length(); + GeoPcon* shapeTmp = new GeoPcon(m_volData.phiStart(), m_volData.phiDelta()); + shapeTmp->addPlane(zstart, m_volData.rmin(), m_volData.rmax()); + double radialDelta = (m_volData.rmax() - m_volData.rmin()) / m_volData.radialDivisions(); + for (int i = 0; i < m_volData.radialDivisions(); i++) { + double rIntermediate = m_volData.rmax() - i * radialDelta; + double reductionFactor = m_volData.rmin() / rIntermediate; + shapeTmp->addPlane(zstart + reductionFactor * m_volData.length(), m_volData.rmin(), rIntermediate); + } + shapeTmp->addPlane(zstart + m_volData.length(), m_volData.rmin(), m_volData.rmin()); + shape = shapeTmp; + break; + } + + return shape; + } + + void + GenericTubeMaker::placeVolume(GeoPhysVol* parent, GeoVPhysVol* child, double zParent) { + placeVolume(parent, 0, child, zParent); + } + + void + GenericTubeMaker::placeVolume(GeoFullPhysVol* fullparent, GeoVPhysVol* child, double zParent) { + placeVolume(0, fullparent, child, zParent); + } + + void + GenericTubeMaker::placeVolTwoSide(GeoPhysVol* parentPos, GeoPhysVol* parentNeg, GeoVPhysVol* child, double zParent) { + placeVolTwoSide(parentPos, parentNeg, 0, 0, child, zParent); + } + + void + GenericTubeMaker::placeVolTwoSide(GeoFullPhysVol* fullparentPos, GeoFullPhysVol* fullparentNeg, GeoVPhysVol* child, + double zParent) { + placeVolTwoSide(0, 0, fullparentPos, fullparentNeg, child, zParent); + } + + void + GenericTubeMaker::placeVolume(GeoPhysVol* parent, GeoFullPhysVol* fullparent, GeoVPhysVol* child, double zParent) { + for (int iRepeat = 0; iRepeat < m_volData.nRepeat(); iRepeat++) { + double phi = m_volData.phiStep() * iRepeat; + + GeoTransform* xform = 0; + double zOffset = m_volData.zMid() - zParent; + if (zOffset != 0 || iRepeat > 0) { + xform = new GeoTransform(GeoTrf::TranslateZ3D(zOffset) * GeoTrf::RotateZ3D(phi)); + } + + if (parent) { + if (xform) parent->add(xform); + parent->add(child); + } else { + if (xform) fullparent->add(xform); + fullparent->add(child); + } + + // Place in negative z as well. + if (m_volData.bothZ()) { + GeoTransform* xformNeg = new GeoTransform(GeoTrf::RotateY3D(180 * Gaudi::Units::deg) * GeoTrf::TranslateZ3D( + zOffset) * GeoTrf::RotateZ3D(phi)); + if (parent) { + parent->add(xformNeg); + parent->add(child); + } else { + fullparent->add(xformNeg); + fullparent->add(child); + } + } + } // iRepeat loop + } + + void + GenericTubeMaker::placeVolTwoSide(GeoPhysVol* parentPos, GeoPhysVol* parentNeg, + GeoFullPhysVol* fullparentPos, GeoFullPhysVol* fullparentNeg, + GeoVPhysVol* child, double zParent) { + for (int iRepeat = 0; iRepeat < m_volData.nRepeat(); iRepeat++) { + double phi = m_volData.phiStep() * iRepeat; + double zOffset = m_volData.zMid() - zParent; + const bool newXform((zOffset != 0)or(iRepeat > 0)); + + if (parentPos) { + if (newXform) { + parentPos->add(new GeoTransform(GeoTrf::TranslateZ3D(zOffset) * GeoTrf::RotateZ3D(phi))); + } + parentPos->add(child); + } else if (fullparentPos) { + if (newXform) { + fullparentPos->add(new GeoTransform(GeoTrf::TranslateZ3D(zOffset) * GeoTrf::RotateZ3D(phi))); + } + fullparentPos->add(child); + } + + // Place in negative z as well. + if (m_volData.bothZ()) { + GeoTransform* xformNeg = new GeoTransform(GeoTrf::RotateY3D(180 * Gaudi::Units::deg) * GeoTrf::TranslateZ3D( + zOffset) * GeoTrf::RotateZ3D(phi)); + if (parentNeg) { + parentNeg->add(xformNeg); + parentNeg->add(child); + } else { + fullparentNeg->add(xformNeg); + fullparentNeg->add(child); + } + } + } // iRepeat loop + } +}// end namespace diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/ScintMaterialManager.cxx b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/ScintMaterialManager.cxx new file mode 100644 index 000000000..6dbf8c62c --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/ScintMaterialManager.cxx @@ -0,0 +1,1042 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + */ + +#include "ScintGeoModelUtils/ScintMaterialManager.h" +#include "ScintGeoModelUtils/ScintDDAthenaComps.h" +#include "GeoModelInterfaces/AbsMaterialManager.h" +#include "GeoModelInterfaces/StoredMaterialManager.h" +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoElement.h" +#include "GeoModelKernel/Units.h" +#include "GaudiKernel/SystemOfUnits.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "GeometryDBSvc/IGeometryDBSvc.h" +#include "StoreGate/StoreGateSvc.h" + +#include <iostream> +#include <iomanip> +#include <cmath> +#include <stdexcept> + +// Constructor +ScintMaterialManager::ScintMaterialManager(const std::string& managerName, + StoreGateSvc* detStore) + : m_managerName(managerName), + m_msg(managerName), + m_extraFunctionality(false), + m_athenaComps(0) { + m_materialManager = retrieveManager(detStore); +} + +// Constructor +ScintMaterialManager::ScintMaterialManager(const std::string& managerName, + StoreGateSvc* detStore, + IRDBRecordset_ptr weightTable, + const std::string& space, + bool extraFunctionality) + : m_managerName(managerName), + m_msg(managerName), + m_extraFunctionality(extraFunctionality), + m_athenaComps(0) { + m_materialManager = retrieveManager(detStore); + + if (weightTable) addWeightTable(weightTable, space); + + // For testing we add a few materials. + //m_weightMap["veto::CoolingBlock"] = MaterialByWeight(2.418*CLHEP::gram); + //m_weightMap["veto::CoolingBlock"] = MaterialByWeight(2*CLHEP::gram); + //m_weightMap["veto::BrlHybrid"] = MaterialByWeight("veto::Hybrid", 8*CLHEP::gram); + //m_weightMap["veto::FwdHybrid"] = MaterialByWeight("std::Carbon", 7.662*CLHEP::gram); +} + +ScintMaterialManager::ScintMaterialManager(const std::string& managerName, StoreGateSvc* detStore, + IRDBRecordset_ptr weightTable, + IRDBRecordset_ptr compositionTable, + const std::string& space) + : m_managerName(managerName), + m_msg(managerName), + m_extraFunctionality(true), + m_athenaComps(0) { + m_materialManager = retrieveManager(detStore); + + if (weightTable) addWeightTable(weightTable, space); + if (compositionTable) addCompositionTable(compositionTable, space); +} + +ScintMaterialManager::ScintMaterialManager(const std::string& managerName, + const ScintDD::AthenaComps* athenaComps) + : m_managerName(managerName), + m_msg(managerName), + m_extraFunctionality(true), + m_athenaComps(athenaComps) { + m_materialManager = retrieveManager(athenaComps->detStore()); + addTextFileMaterials(); +} + +ScintMaterialManager::~ScintMaterialManager() { + // Dereference the materials. + MaterialStore::const_iterator iter; + for (iter = m_store.begin(); iter != m_store.end(); ++iter) { + iter->second->unref(); + } +} + +const AbsMaterialManager* +ScintMaterialManager::retrieveManager(StoreGateSvc* detStore) { + const StoredMaterialManager* theGeoMaterialManager = nullptr; + + if (StatusCode::SUCCESS != detStore->retrieve(theGeoMaterialManager, "MATERIALS")) { + msg(MSG::FATAL) << "Cannot locate Materials"; + } + + return theGeoMaterialManager; +} + +const GeoElement* +ScintMaterialManager::getElement(const std::string& elementName) const { + return m_materialManager->getElement(elementName); +} + +const GeoMaterial* +ScintMaterialManager::getMaterial(const std::string& materialName) { + return extraScaledMaterial(materialName, getMaterialInternal(materialName)); +} + +bool +ScintMaterialManager::hasMaterial(const std::string& materialName) const { + return m_store.find(materialName) != m_store.end(); +} + +const GeoMaterial* +ScintMaterialManager::getMaterialInternal(const std::string& materialName) const { + // First check local store of materials. If not found then get it from the GeoModel + // manager. + const GeoMaterial* material = getAdditionalMaterial(materialName); + + if (!material) { + // This prints error message if not found. + material = m_materialManager->getMaterial(materialName); + } + return material; +} + +const GeoMaterial* +ScintMaterialManager::getAdditionalMaterial(const std::string& materialName) const { + MaterialStore::const_iterator iter; + if ((iter = m_store.find(materialName)) != m_store.end()) { + return iter->second; + } else { + return 0; + } +} + +const GeoMaterial* +ScintMaterialManager::getCompositeMaterialForVolume(const std::string& newMatName, + const double volumeTot, + const double volume1, const std::string& matName1, + const double volume2, const std::string& matName2 + ) { + std::vector<std::string> baseMaterials; + std::vector<double> fracWeight; + baseMaterials.reserve(2); + fracWeight.reserve(2); + + msg(MSG::DEBUG) << "Composite material : " << volumeTot / Gaudi::Units::cm3 << " = " << volume1 / Gaudi::Units::cm3 << " + " << + volume2 / Gaudi::Units::cm3 << endmsg; + msg(MSG::DEBUG) << "Composite material : " << matName1 << " " << matName2 << endmsg; + + double density1, density2; + + MaterialWeightMap::const_iterator iter; + if ((iter = m_weightMap.find(matName1)) != m_weightMap.end()) { + const GeoMaterial* mat1 = getMaterialForVolume(matName1, volume1); + density1 = mat1->getDensity(); + msg(MSG::DEBUG) << "Composite material 1 - weight : " << density1 / (GeoModelKernelUnits::gram / Gaudi::Units::cm3) << endmsg; + } else { + const GeoMaterial* mat1 = getMaterial(matName1); + density1 = mat1->getDensity(); + msg(MSG::DEBUG) << "Composite material 1 - standard : " << density1 / (GeoModelKernelUnits::gram / Gaudi::Units::cm3) << endmsg; + } + + if ((iter = m_weightMap.find(matName2)) != m_weightMap.end()) { + const GeoMaterial* mat2 = getMaterialForVolume(matName2, volume2); + density2 = mat2->getDensity(); + msg(MSG::DEBUG) << "Composite material 2 - weight : " << density2 / (GeoModelKernelUnits::gram / Gaudi::Units::cm3) << endmsg; + } else { + const GeoMaterial* mat2 = getMaterial(matName2); + density2 = mat2->getDensity(); + msg(MSG::DEBUG) << "Composite material 2 - standard : " << density2 / (GeoModelKernelUnits::gram / Gaudi::Units::cm3) << endmsg; + } + + double weight1 = density1 * volume1; + double weight2 = density2 * volume2; + double invWeightTot = 1.0 / (weight1 + weight2); + + double density = (weight1 + weight2) / volumeTot; + + double frac1 = weight1 / (weight1 + weight2); + double frac2 = weight2 / (weight1 + weight2); + double density_2 = 1.0 / (frac1 / density1 + frac2 / density2); + double density_3 = (weight1 + weight2) / (volume1 + volume2); + msg(MSG::DEBUG) << "-> weights : " << weight1 / (GeoModelKernelUnits::gram) << " " << weight2 / (GeoModelKernelUnits::gram) << endmsg; + msg(MSG::DEBUG) << "-> density : " << density / (GeoModelKernelUnits::gram / Gaudi::Units::cm3) << " " << density_2 / + (GeoModelKernelUnits::gram / Gaudi::Units::cm3) << " " << density_3 / (GeoModelKernelUnits::gram / Gaudi::Units::cm3) << endmsg; + + + baseMaterials.push_back(matName1); + baseMaterials.push_back(matName2); + fracWeight.push_back(weight1 * invWeightTot); + fracWeight.push_back(weight2 * invWeightTot); + + return getMaterial(newMatName, baseMaterials, fracWeight, density); +} + +// This creates a new material with specified density. + +// If a newName is supplied it creates the new material even if the orginal material +// has the same density. It however first checks if the material with NewName exists. + +// If no new name is supplied then it checks the density of +// the existing material. If it is consistent it returns the material. +// If it is different it creates a material with the string "Modified" added to the +// name. + + +const GeoMaterial* +ScintMaterialManager::getMaterial(const std::string& origMaterialName, + double density, + const std::string& newName) { + return extraScaledMaterial(origMaterialName, newName, + getMaterialInternal(origMaterialName, density, newName)); +} + +const GeoMaterial* +ScintMaterialManager::getMaterialInternal(const std::string& origMaterialName, + double density, + const std::string& newName) { + std::string newName2 = newName; + bool newNameProvided = !newName2.empty(); + if (!newNameProvided) { + newName2 = origMaterialName + "Modified"; + } + + const GeoMaterial* newMaterial = 0; + + // First see if we already have the modified material + const GeoMaterial* material = getAdditionalMaterial(newName2); + if (material) { + if (!compareDensity(material->getDensity(), density)) { + msg(MSG::WARNING) << "Density is not consistent for material " << newName2 + << " " << material->getDensity() / (GeoModelKernelUnits::gram / Gaudi::Units::cm3) + << " / " << density / (GeoModelKernelUnits::gram / Gaudi::Units::cm3) << endmsg; + } + newMaterial = material; + } else { + const GeoMaterial* origMaterial = getMaterialInternal(origMaterialName); + newMaterial = origMaterial; + if (origMaterial) { + // If no new name was provided we check if the density is compatible + // and if so we return the original material. + if (newNameProvided || !compareDensity(origMaterial->getDensity(), density)) { + // create new material + GeoMaterial* newMaterialTmp = new GeoMaterial(newName2, density); + newMaterialTmp->add(const_cast<GeoMaterial*>(origMaterial), 1.); + addMaterial(newMaterialTmp); + newMaterial = newMaterialTmp; + } + } + } + return newMaterial; +} + +const GeoMaterial* +ScintMaterialManager::getMaterialScaled(const std::string& origMaterialName, + double scaleFactor, + const std::string& newName) { + return extraScaledMaterial(origMaterialName, newName, + getMaterialScaledInternal(origMaterialName, scaleFactor, newName)); +} + +const GeoMaterial* +ScintMaterialManager::getMaterialScaledInternal(const std::string& origMaterialName, + double scaleFactor, + const std::string& newName) { + // Don't allow large scale factors + if (scaleFactor > 1000 || scaleFactor < 0.001) { + msg(MSG::ERROR) << "Scale factor must be between 0.001 and 1000." << endmsg; + return 0; + } + + const GeoMaterial* origMaterial = getMaterialInternal(origMaterialName); + + // If scalefactor is 1 and no new name is requested + // then just return the orginal material + if (newName.empty() && scaleFactor == 1.) return origMaterial; + + const GeoMaterial* newMaterial = 0; + + if (origMaterial) { + double density = origMaterial->getDensity() * scaleFactor; + std::string newName2 = newName; + if (newName2.empty()) { + // Create name using the scale factor. + int scaleInt = static_cast<int>(scaleFactor * 10000); + int scale1 = scaleInt / 10000; + int scale2 = scaleInt % 10000; + + std::ostringstream os; + os << origMaterialName << scale1 << "_" << std::setw(4) << std::setfill('0') << scale2; + newName2 = os.str(); + } + + newMaterial = getMaterialInternal(origMaterialName, density, newName2); + } + + return newMaterial; +} + +void +ScintMaterialManager::addMaterial(GeoMaterial* material) { + std::string name(material->getName()); + if (m_store.find(name) != m_store.end()) { + msg(MSG::WARNING) << "Ignoring attempt to redefine an existing material: " << name << endmsg; + // Delete the material if it is not already ref counted. + material->ref(); + material->unref(); + //std::cout << m_store[name] << std::endl; + } else { + material->lock(); + material->ref(); + m_store[name] = material; + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Created new material: " << name << ", " << material->getDensity() / + (Gaudi::Units::g / Gaudi::Units::cm3) << " g/cm3" << endmsg; + } +} + +bool +ScintMaterialManager::compareDensity(double d1, double d2) const { + return(std::abs(d1 / d2 - 1.) < 1e-5); +} + +void +ScintMaterialManager::addWeightTable(IRDBRecordset_ptr weightTable, const std::string& space) { + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Reading in weight table: " << weightTable->nodeName() << endmsg; + // If not using geometryDBSvc revert to old version + if (!db()) { + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "GeometryDBSvc not available. Using old version." << endmsg; + addWeightTableOld(weightTable, space); + return; + } + for (unsigned int i = 0; i < db()->getTableSize(weightTable); i++) { + std::string materialName = db()->getString(weightTable, "MATERIAL", i); + if (!space.empty()) { + materialName = space + "::" + materialName; + } + std::string materialBase; + if (db()->testField(weightTable, "BASEMATERIAL", i)) { + materialBase = db()->getString(weightTable, "BASEMATERIAL", i); + } + double weight = db()->getDouble(weightTable, "WEIGHT", i) * GeoModelKernelUnits::gram; + //std::cout << materialName << " " << materialBase << " " << weight/CLHEP::g << std::endl; + + bool linearWeightFlag = false; + if (m_extraFunctionality && db()->testField(weightTable, "LINWEIGHTFLAG", i)) { + linearWeightFlag = db()->getInt(weightTable, "LINWEIGHTFLAG", i); + } + + if (m_weightMap.find(materialName) != m_weightMap.end()) { + msg(MSG::WARNING) << "Material: " << materialName << " already exists in weight table" << endmsg; + } else { + msg(MSG::DEBUG) << "Adding " << materialName + << " weight " << weight + << " linearWeightFlag " << linearWeightFlag + << " raw weight " << db()->getDouble(weightTable, "WEIGHT", i) + << " m_extraFunctionality " << m_extraFunctionality + << " to weight table" << endmsg; + m_weightMap[materialName] = MaterialByWeight(materialBase, weight, linearWeightFlag); + } + } +} + +void +ScintMaterialManager::addWeightMaterial(std::string materialName, std::string materialBase, double weight, + int linearWeightFlag) { + // Weight in gr + weight = weight * GeoModelKernelUnits::gram; + + if (m_weightMap.find(materialName) != m_weightMap.end()) { + msg(MSG::WARNING) << "Material: " << materialName << " already exists in weight table" << endmsg; + } else { + msg(MSG::DEBUG) << "Adding " << materialName + << " weight " << weight + << " linearWeightFlag " << linearWeightFlag + << " to weight table" << endmsg; + m_weightMap[materialName] = MaterialByWeight(materialBase, weight, linearWeightFlag); + } +} + +void +ScintMaterialManager::addWeightTableOld(IRDBRecordset_ptr weightTable, const std::string& space) { + for (unsigned int i = 0; i < weightTable->size(); i++) { + const IRDBRecord* record = (*weightTable)[i]; + std::string materialName = record->getString("MATERIAL"); + if (!space.empty()) { + materialName = space + "::" + materialName; + } + std::string materialBase; + if (!record->isFieldNull("BASEMATERIAL")) { + materialBase = record->getString("BASEMATERIAL"); + } + double weight = record->getDouble("WEIGHT") * GeoModelKernelUnits::gram; + //std::cout << materialName << " " << materialBase << " " << weight/CLHEP::g << std::endl; + + bool linearWeightFlag = false; + if (m_extraFunctionality) { + linearWeightFlag = record->getInt("LINWEIGHTFLAG"); + } + + if (m_weightMap.find(materialName) != m_weightMap.end()) { + msg(MSG::WARNING) << "Material: " << materialName << " already exists in weight table" << endmsg; + } else { + m_weightMap[materialName] = MaterialByWeight(materialBase, weight, linearWeightFlag); + } + } +} + +void +ScintMaterialManager::addCompositionTable(IRDBRecordset_ptr compositionTable, const std::string& space) { + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Reading in composition table: " << compositionTable->nodeName() << endmsg; + + if (!db()) { + msg(MSG::ERROR) << "GeometryDBSvc not available. Unable to read in composition table." << endmsg; + } + for (unsigned int i = 0; i < db()->getTableSize(compositionTable); i++) { + std::string materialName = db()->getString(compositionTable, "MATERIAL", i); + if (!space.empty()) { + materialName = space + "::" + materialName; + } + + std::string componentName = db()->getString(compositionTable, "COMPONENT", i); + int count = db()->getInt(compositionTable, "COUNT", i); + double factor = db()->getDouble(compositionTable, "FACTOR", i); + double actualLength = db()->getDouble(compositionTable, "ACTUALLENGTH", i); + + m_matCompositionMap.insert(std::pair<std::string, MaterialComponent>(materialName, + MaterialComponent(componentName, + count * factor, + actualLength))); + } +} + +void +ScintMaterialManager::addScalingTable(IRDBRecordset_ptr scalingTable) { + if (!scalingTable) return; + + if (db()->getTableSize(scalingTable) == 0) return; + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Reading in extra material scaling table: " << scalingTable->nodeName() << + endmsg; + if (!db()) { + msg(MSG::ERROR) << "GeometryDBSvc not available. Unable to read in scaling table." << endmsg; + } + for (unsigned int i = 0; i < db()->getTableSize(scalingTable); i++) { + std::string materialName = db()->getString(scalingTable, "MATERIAL", i); + double scalingFactor = db()->getDouble(scalingTable, "FACTOR", i); + + if (msgLvl(MSG::DEBUG)) { + if (scalingFactor >= 0 || scalingFactor == 1) { + msg(MSG::DEBUG) << "Material " << materialName << " will be scaled by: " << scalingFactor << endmsg; + } else { + // -ve or scalefactor = 1 means will not be scaled. + msg(MSG::DEBUG) << "Material " << materialName << " will be NOT be scaled." << endmsg; + } + } + if (m_scalingMap.find(materialName) != m_scalingMap.end()) { + msg(MSG::WARNING) << "Overriding material: " << materialName << " which already exists in scaling table" << + endmsg; + } + m_scalingMap[materialName] = scalingFactor; + } +} + +const GeoMaterial* +ScintMaterialManager::getMaterialForVolume(const std::string& materialName, double volume, const std::string& newName) { + // Make sure we have a valid volume size. + if (volume <= 0) { + msg(MSG::ERROR) << "Invalid volume : " << volume << endmsg; + return 0; + } + + // Find if material is in the weight table. + // If so we use the information to create a material with the + // density calculated from the volume and weight. If a base material + // is specified in the weight table, then a new material is made + // which is the same as the base material but with the new + // density. If no base material is specified then there should be a + // material already existing with that name. If the existing material already has the + // correct density it is used, otherwise a new material is created + // with the string "Modified" added to the material name. + + MaterialWeightMap::const_iterator iter; + if ((iter = m_weightMap.find(materialName)) != m_weightMap.end()) { + const std::string& materialBase = iter->second.name; + double weight = iter->second.weight; + double density = weight / volume; + if (iter->second.linearWeightFlag) { + msg(MSG::ERROR) << "Material defined by linear weight cannot be created with getMaterialForVolume method: " << + materialName << endmsg; + } + + if (msgLvl(MSG::VERBOSE)) { + msg(MSG::VERBOSE) + << + "Found material in weight table - name, base, weight(g), volume(cm3), density(g/cm3): " + << materialName << ", " + << materialBase << ", " + << weight / GeoModelKernelUnits::gram << ", " + << volume / Gaudi::Units::cm3 << ", " + << density / (Gaudi::Units::g / Gaudi::Units::cm3) << endmsg; + } + + if (materialBase.empty()) { + return getMaterial(materialName, density, newName); + } else { + if (newName.empty()) { + return getMaterial(materialBase, density, materialName); + } else { + return getMaterial(materialBase, density, newName); + } + } + } else { + // If not in the weight table we just return the material. + // This is not an error. + if (msgLvl(MSG::VERBOSE)) + msg(MSG::VERBOSE) + << "Material not in weight table, using standard material: " + << materialName + << ", volume(cm3) = " << volume / Gaudi::Units::cm3 + << endmsg; + return getMaterial(materialName); + } +} + +const GeoMaterial* +ScintMaterialManager::getMaterialForVolumeLength(const std::string& materialName, double volume, double length, + const std::string& newName) { + // In the case there is no material composition table (MaterialCompositionMap) and no linear weights are used this + // will + // behave the same way as getMaterialForVolume. + // If the material is in the MaterialCompositionMap it will build a material using the components + // from that table. If any components are defined as a linear weight the length is used to calculate the + // weight (ie linear weight * length). + + + std::string name; + if (newName.empty()) { + name = materialName; + } else { + name = newName; + } + + // Make sure we have a valid volume size. + if (volume <= 0 || length <= 0) { + msg(MSG::ERROR) << "Invalid volume or length : " << volume << ", " << length << endmsg; + return 0; + } + + // First look in the predefinded collections + std::pair<MaterialCompositionMap::const_iterator, MaterialCompositionMap::const_iterator> iterRange; + iterRange = m_matCompositionMap.equal_range(materialName); + if (iterRange.first != m_matCompositionMap.end()) { + if (msgLvl(MSG::VERBOSE)) { + msg(MSG::VERBOSE) + << "Found material in material composition table:" << materialName << endmsg; + } + + std::vector<double> factors; + std::vector<std::string> components; + for (MaterialCompositionMap::const_iterator iter = iterRange.first; iter != iterRange.second; iter++) { + double factorTmp = iter->second.factor; + if (iter->second.actualLength > 0) factorTmp *= iter->second.actualLength / length; + factors.push_back(factorTmp); + components.push_back(iter->second.name); + } + return getMaterialForVolumeLength(name, components, factors, volume, length); + } + + // Next look in weight table + MaterialWeightMap::const_iterator iter; + if ((iter = m_weightMap.find(materialName)) != m_weightMap.end()) { + const std::string& materialBase = iter->second.name; + double weight = iter->second.weight; + double density = weight / volume; + if (iter->second.linearWeightFlag) weight *= length; + + if (materialBase.empty()) { + return getMaterial(materialName, density, newName); + } else { + return getMaterial(materialBase, density, name); + } + } else { + // Otherwise we just return the material. + // This is not an error. + if (msgLvl(MSG::VERBOSE)) + msg(MSG::VERBOSE) + << "Material not in weight table, using standard material: " + << materialName + << ", volume(cm3) = " << volume / Gaudi::Units::cm3 + << endmsg; + return getMaterial(materialName); + } +} + +const GeoMaterial* +ScintMaterialManager::getMaterialForVolumeLength(const std::string& name, + const std::string& materialComponent, + double factor, + double volume, + double length) { + std::vector<std::string> tmpMaterialComponents(1, materialComponent); + std::vector<double> tmpFactors(1, factor); + return getMaterialForVolumeLength(name, tmpMaterialComponents, tmpFactors, volume, length); +} + +const GeoMaterial* +ScintMaterialManager::getMaterialForVolumeLength(const std::string& name, + const std::vector<std::string>& materialComponents, + const std::vector<double> factors, + double volume, + double length) { + // Make sure we have a valid volume size. + if (volume <= 0 || length <= 0) { + msg(MSG::ERROR) << "Invalid volume or length : " << volume << ", " << length << endmsg; + return 0; + } + + if (!factors.empty() && factors.size() < materialComponents.size()) { + msg(MSG::WARNING) << "getMaterialForVolumeLength: factor vector size too small. Setting remaining factors to 1." << + endmsg; + } + + std::vector<std::string> baseMaterials; + std::vector<double> fracWeight; + baseMaterials.reserve(materialComponents.size()); + fracWeight.reserve(materialComponents.size()); + + double totWeight = 0; + for (unsigned int iComp = 0; iComp < materialComponents.size(); ++iComp) { + const std::string& materialName = materialComponents[iComp]; + + // First search in MaterialWeightMap + MaterialWeightMap::const_iterator iter; + if ((iter = m_weightMap.find(materialName)) != m_weightMap.end()) { + const std::string& materialBase = iter->second.name; + double weight = iter->second.weight; + + if (iComp < factors.size()) { + weight *= factors[iComp]; + } + msg(MSG::DEBUG) << "Material " << materialName + << " found in weight table, weight " << iter->second.weight / GeoModelKernelUnits::gram + << " factor " << factors[iComp] + << " w*fac*len " << weight * length / GeoModelKernelUnits::gram + << " basMat " << materialBase + << " linear? " << iter->second.linearWeightFlag << endmsg; + + if (iter->second.linearWeightFlag) weight *= length; + if (materialBase.empty()) { + // If no base material then name should refer to an already defined material + baseMaterials.push_back(materialName); + } else { + baseMaterials.push_back(materialBase); + } + fracWeight.push_back(weight); // Will be normalized later. + totWeight += weight; + } else { + // If not in the weight table we look for a regular material. + // I don't think this would normally be intentional so we give a warning message. + /* + if (msgLvl(MSG::WARNING)) + msg(MSG::WARNING) + << "Component material not in weight table, using standard material: " + << materialName << " with weight= " + << factors.at(iComp) * length + << endmsg; + const GeoMaterial * material = getMaterialInternal(materialName); + */ + + // In this case the factor should correspond to the linear weight + double weight = factors.at(iComp) * length * GeoModelKernelUnits::gram; + + // If material not found, will get error message when attempting to make the material. So carry on here. + baseMaterials.push_back(materialName); + fracWeight.push_back(weight); + totWeight += weight; + } + } + + if (msgLvl(MSG::VERBOSE)) { + msg(MSG::VERBOSE) << "Creating material from multiple components: " << name << endmsg; + for (unsigned int i = 0; i < materialComponents.size(); ++i) { + msg(MSG::VERBOSE) << " Component " << i << ": Name = " << baseMaterials[i] + << " Weight(g) = " << fracWeight[i] / Gaudi::Units::g << endmsg; + } + } + + for (unsigned int i = 0; i < fracWeight.size(); ++i) { + fracWeight[i] /= totWeight; + } + double density = totWeight / volume; + + return getMaterial(name, baseMaterials, fracWeight, density); +} + +// Add materials assuming they simply occupy the same volume. +/* + const GeoMaterial* + ScintMaterialManager::getMaterial(const std::vector<const GeoMaterial *> & materialComponents, + const std::string & newName) + { + const GeoMaterial * newMaterial = 0; + std::vector<double> fracWeight; + fracWeight.reserve(materialComponents.size()); + + for (unsigned int i = 0; i < materialComponents.size(); i++) { + const GeoMaterial * origMaterial = materialComponents[i]; + double weight = origMaterial->getDensity(); + fracWeight.push_back(weight); + totWeight += weight; + } + for (unsigned int i = 0; i < fracWeight.size(); ++i) { + fracWeight[i] /= totWeight; + } + return getMaterial(materialComponents, fracWeight, totWeight, newName); + } + + const GeoMaterial* + ScintMaterialManager::getMaterial(const std::vector<std::string> & materialComponents, + const std::string & newName) + { + const GeoMaterial * newMaterial = 0; + + // First see if we already have the modified material + const GeoMaterial* material = getAdditionalMaterial(newName); + + for (unsigned int i = 0; i < materialComponents.size(); i++) { + const GeoMaterial * origMaterial = getMaterial(materialComponents[i]); + components.push_back(origMaterial); + } + return getMaterial(components, newName); + } + */ + + +const GeoMaterial* +ScintMaterialManager::getMaterial(const std::string& name, + const std::vector<std::string>& materialComponents, + const std::vector<double>& fracWeight, + double density) { + return extraScaledMaterial(name, getMaterialInternal(name, materialComponents, fracWeight, density)); +} + +const GeoMaterial* +ScintMaterialManager::getMaterialInternal(const std::string& name, + const std::vector<std::string>& materialComponents, + const std::vector<double>& fracWeight, + double density) { + const GeoMaterial* newMaterial = 0; + + // First see if we already have the material + const GeoMaterial* material = getAdditionalMaterial(name); + + if (material) { + if (!compareDensity(material->getDensity(), density)) { + msg(MSG::WARNING) << "Density is not consistent for material " << name << endmsg; + } + newMaterial = material; + } else { + GeoMaterial* newMaterialTmp = new GeoMaterial(name, density); + for (unsigned int i = 0; i < materialComponents.size(); i++) { + const GeoMaterial* origMaterial = getMaterialInternal(materialComponents[i]); + if (origMaterial) { + newMaterialTmp->add(const_cast<GeoMaterial*>(origMaterial), fracWeight[i]); + } else { + msg(MSG::ERROR) << "Material component missing " << materialComponents[i] << endmsg; + } + } + addMaterial(newMaterialTmp); + newMaterial = newMaterialTmp; + } + return newMaterial; +} + +const IGeometryDBSvc* +ScintMaterialManager::db() { + if (m_athenaComps) return m_athenaComps->geomDB(); + + return 0; +} + +void +ScintMaterialManager::addTextFileMaterials() { + const std::string materialTable = "ExtraMaterials"; + const std::string componentsTable = "ExtraMatComponents"; + + // Look for tables ExtraMaterials and ExtraMatComponents. + // These are text file only tables where extra materials are desired or + // one wants to override some database ones. + if (!db() || !db()->testField("", "TableSize:" + materialTable) || !db()->getTableSize(materialTable) + || !db()->testField("", "TableSize:" + componentsTable) || !db()->getTableSize(componentsTable)) return; + + + msg(MSG::INFO) << "Extra materials being read in from text file." << endmsg; + + typedef std::map<std::string, MaterialDef> MatMap; + MatMap materials; + + // read in material table + for (unsigned int iMat = 0; iMat < db()->getTableSize(materialTable); iMat++) { + std::string materialName = db()->getString(materialTable, "NAME", iMat); + double density = db()->getDouble(materialTable, "DENSITY", iMat) * Gaudi::Units::g / Gaudi::Units::cm3; + materials[materialName] = MaterialDef(materialName, density); + } + + // read in material component table + for (unsigned int iComp = 0; iComp < db()->getTableSize(componentsTable); iComp++) { + std::string materialName = db()->getString(componentsTable, "NAME", iComp); + std::string compName = db()->getString(componentsTable, "COMPNAME", iComp); + double fracWeight = db()->getDouble(componentsTable, "FRACTION", iComp); + MatMap::iterator iter = materials.find(materialName); + if (iter != materials.end()) { + iter->second.addComponent(compName, fracWeight); + } else { + msg(MSG::ERROR) << "Attemp to add material component, " << compName << ", to non-existing material: " << + materialName << endmsg; + } + } + + //Now create the materials + int matCount = 0; + int matCountLast = -1; + bool someUndefined = true; + // While there are still undefined materials keep creating materials. + // Check also that the matCount had change to avoid endless loop due to cyclicly + // defined materials. + while (someUndefined && matCount != matCountLast) { + matCountLast = matCount; + someUndefined = false; + for (MatMap::iterator iter = materials.begin(); iter != materials.end(); ++iter) { + MaterialDef& tmpMat = iter->second; + if (!tmpMat.isCreated()) { + // Check if any components are materials in this table and if they are defined. + // If not flag that there are undefined materials and go to next material + bool compsDefined = true; + for (unsigned int iComp = 0; iComp < tmpMat.numComponents(); ++iComp) { + std::string compName = tmpMat.compName(iComp); + MatMap::iterator iter2 = materials.find(compName); + if (iter2 != materials.end()) { + if (!iter2->second.isCreated()) { + compsDefined = false; + break; + } + } + } + if (compsDefined) { + createMaterial(tmpMat); + tmpMat.setCreated(); + matCount++; + } else { + someUndefined = true; + } + } + } + } + + + if (someUndefined) { + msg(MSG::ERROR) << "Not all materials could be defined due to cyclic definitions" << endmsg; + } +} + +void +ScintMaterialManager::createMaterial(const MaterialDef& material) { + if (material.numComponents() == 0) { + msg(MSG::ERROR) << "Material has no components: " << material.name() << endmsg; + return; + } + + // If total of fractions is greater than 1.1 then assume material is define by ratio of atoms. + double totWeight = material.totalFraction(); + bool byAtomicRatio = false; + if (totWeight > 1.1) { + byAtomicRatio = true; + for (unsigned int i = 0; i < material.numComponents(); i++) { + if (material.compName(i).find("::") != std::string::npos) { + // If component name has "::" in it then its not an element. + msg(MSG::ERROR) << "Material, " << material.name() + << + ", is assumed to be defined by atomic ratio (due to total fraction > 1) but component is not an element: " + << material.compName(i) << endmsg; + return; + } + const GeoElement* element = getElement(material.compName(i)); + if (!element) { + msg(MSG::ERROR) << "Error making material " << material.name() << ". Element not found: " << + material.compName(i) << endmsg; + return; + } + totWeight += material.fraction(i) * element->getA(); + } + } else { + // Check if total fraction is close to 1. + if (std::abs(totWeight - 1) > 0.01) { + msg(MSG::WARNING) << "Total fractional weight does not sum to 1. Will renormalize. Total = " << totWeight << + endmsg; + } + } + // Now build the material + GeoMaterial* newMaterial = new GeoMaterial(material.name(), material.density()); + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "Creating material: " << material.name() + << " with density: " << material.density() / (Gaudi::Units::g / Gaudi::Units::cm3) << + endmsg; + for (unsigned int i = 0; i < material.numComponents(); i++) { + double fracWeight = material.fraction(i) / totWeight; + if (material.compName(i).find("::") == std::string::npos) { + const GeoElement* element = getElement(material.compName(i)); + if (!element) { + msg(MSG::ERROR) << "Error making material " << material.name() << ". Element not found: " << + material.compName(i) << endmsg; + // delete the partially created material + newMaterial->ref(); + newMaterial->unref(); + return; + } + if (byAtomicRatio) { + fracWeight = material.fraction(i) * element->getA() / totWeight; + } + newMaterial->add(const_cast<GeoElement*>(element), fracWeight); + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Component: " << material.compName(i) << " " << fracWeight << endmsg; + } else { + const GeoMaterial* materialTmp = getMaterialInternal(material.compName(i)); + if (!materialTmp) { + msg(MSG::ERROR) << "Error making material " << material.name() << ". Component not found: " << + material.compName(i) << endmsg; + // delete the partially created material + newMaterial->ref(); + newMaterial->unref(); + return; + } + if (byAtomicRatio) { + // Should not happen as already checked that all components were elements. + msg(MSG::ERROR) << "Unexpected Error" << endmsg; + } + newMaterial->add(const_cast<GeoMaterial*>(materialTmp), fracWeight); + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Component: " << material.compName(i) << " " << fracWeight << endmsg; + } + } + newMaterial->lock(); + addMaterial(newMaterial); +} + +ScintMaterialManager::MaterialDef::MaterialDef() + : m_density(0), + m_created(false) +{} + +ScintMaterialManager::MaterialDef::MaterialDef(const std::string& name, double density) + : m_name(name), + m_density(density), + m_created(false) +{} + +void +ScintMaterialManager::MaterialDef::addComponent(const std::string& compName, double fraction) { + m_components.push_back(compName); + m_fractions.push_back(fraction); +} + +double +ScintMaterialManager::MaterialDef::totalFraction() const { + double sum = 0; + + for (unsigned int i = 0; i < m_fractions.size(); i++) { + sum += m_fractions[i]; + } + return sum; +} + +// We need the original name as the GeoMaterial from the standard +// material manager has its namespace dropped. We have two versions +// of extraScaledMaterial. One where two names are provided. In this +// version if newName is not empty that is used, otherwise +// materialName is used. The other just has one name and that is the +// one that is used. + +const GeoMaterial* +ScintMaterialManager::extraScaledMaterial(const std::string& materialName, + const std::string& newName, + const GeoMaterial* origMaterial) { + if (newName.empty()) { + return extraScaledMaterial(materialName, origMaterial); + } else { + return extraScaledMaterial(newName, origMaterial); + } +} + +const GeoMaterial* +ScintMaterialManager::extraScaledMaterial(const std::string& materialName, const GeoMaterial* origMaterial) { + if (!origMaterial) throw std::runtime_error(std::string("Invalid material: ") + materialName); + + double scaleFactor = getExtraScaleFactor(materialName); + // -1 (or any -ve number) indicates material is not scaled. And if the scale factor + // is 1 then there is no need to create a new material. + if (scaleFactor < 0 || scaleFactor == 1 || materialName.find("Ether") != std::string::npos) return origMaterial; + + if (scaleFactor == 0) return getMaterialInternal("std::Vacuum"); + + std::string newName = materialName + "_ExtraScaling"; + + // Check if it is already made. + const GeoMaterial* newMaterial = getAdditionalMaterial(newName); + + // Already made so we return it. + if (newMaterial) return newMaterial; + + // Otherwise we need to make it. + double density = origMaterial->getDensity() * scaleFactor; + + // create new material + GeoMaterial* newMaterialTmp = new GeoMaterial(newName, density); + newMaterialTmp->add(const_cast<GeoMaterial*>(origMaterial), 1.); + addMaterial(newMaterialTmp); + newMaterial = newMaterialTmp; + + return newMaterial; +} + +double +ScintMaterialManager::getExtraScaleFactor(const std::string& materialName) { + // If name is found in map we return the corresponding scale factor. + // The special name "ALL" indicates all materials are scaled. + // Individual materials can be excluded from scaling by giving either + // a -ve scaling factor or just specifying a scaling factor of 1. + // A scaling factor of 0 means the material will be replaced by vacuum. + + ExtraScaleFactorMap::const_iterator iter = m_scalingMap.find(materialName); + if (iter != m_scalingMap.end()) { + return iter->second; + } else { + // Check for special names + // ALL means everything scaled. Do not scale air or vacuum (unless explicity requested) + iter = m_scalingMap.find("ALL"); + if (iter != m_scalingMap.end() && materialName != "std::Air" && materialName != "std::Vacuum") { + return iter->second; + } + } + + // If not found then return -1 to indicate material is not to be scaled. + return -1; +} diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/TopLevelPlacements.cxx b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/TopLevelPlacements.cxx new file mode 100644 index 000000000..8ea12a691 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/TopLevelPlacements.cxx @@ -0,0 +1,123 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + */ + +#include "ScintGeoModelUtils/TopLevelPlacements.h" +#include "GaudiKernel/SystemOfUnits.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include <iostream> + +GeoTrf::Transform3D TopLevelPlacements::s_identityTransform = GeoTrf::Transform3D::Identity(); + +TopLevelPlacements::TopLevelPlacements(IRDBRecordset_ptr topLevelTable) + : m_noTopLevelTable(true) { + fillPlacements(topLevelTable); +} + +TopLevelPlacements::~TopLevelPlacements() { + std::map<std::string, Part*>::const_iterator iter; + for (iter = m_parts.begin(); iter != m_parts.end(); ++iter) delete iter->second; +} + +const GeoTrf::Transform3D& +TopLevelPlacements::transform(const std::string& partName) const { + Part* part = getPart(partName); + + if (part) return part->transform; + + return s_identityTransform; +} + +bool +TopLevelPlacements::present(const std::string& partName) const { + // If no table present assume everything is present. + if (m_noTopLevelTable) return true; + + return(getPart(partName) != 0); +} + +void +TopLevelPlacements::fillPlacements(IRDBRecordset_ptr topLevelTable) { + if (topLevelTable.get() == 0) { + m_noTopLevelTable = true; + return; + } + m_noTopLevelTable = false; + int numParts = topLevelTable->size(); + for (int i = 0; i < numParts; i++) { + const IRDBRecord* record = (*topLevelTable)[i]; + std::string label = record->getString("LABEL"); + + Part* part = new Part; + part->label = label; + part->transform = partTransform(record); + + m_parts[label] = part; + } +} + +GeoTrf::Transform3D +TopLevelPlacements::partTransform(const IRDBRecord* record) const { + double posX = record->getDouble("POSX") * Gaudi::Units::mm; + double posY = record->getDouble("POSY") * Gaudi::Units::mm; + double posZ = record->getDouble("POSZ") * Gaudi::Units::mm; + double rotX = record->getDouble("ROTX") * Gaudi::Units::degree; + double rotY = record->getDouble("ROTY") * Gaudi::Units::degree; + double rotZ = record->getDouble("ROTZ") * Gaudi::Units::degree; + int rotOrder = record->getInt("ROTORDER"); + + // Translation part + GeoTrf::Translate3D transform(posX, posY, posZ); + + // If rotation is zero return translation + if (rotX == 0 && rotY == 0 && rotZ == 0) { + return transform; + } + + // For rotation have to look at order. + // 123 means rotate around X, then Y , then Z. + // 312 means rotate around Z, then X , then Y. + // etc + + int ixyz1 = rotOrder / 100 - 1; + int ixyz2 = (rotOrder % 100) / 10 - 1; + int ixyz3 = (rotOrder % 10) - 1; + + if (ixyz1 < 0 || ixyz1 > 2 || + ixyz2 < 0 || ixyz2 > 2 || + ixyz3 < 0 || ixyz3 > 2) { + std::cout << "ERROR: Invalid rotation order:" << rotOrder << std::endl; + ixyz1 = 0; + ixyz2 = 1; + ixyz3 = 2; + } + + // List of the three transforms + GeoTrf::Transform3D* xformList[3] = { + 0, 0, 0 + }; + if (rotX != 0) xformList[0] = new GeoTrf::RotateX3D(rotX); + if (rotY != 0) xformList[1] = new GeoTrf::RotateY3D(rotY); + if (rotZ != 0) xformList[2] = new GeoTrf::RotateZ3D(rotZ); + + GeoTrf::Transform3D rotation(GeoTrf::Transform3D::Identity()); + if (xformList[ixyz1]) rotation = *(xformList[ixyz1]) * rotation; + if (xformList[ixyz2]) rotation = *(xformList[ixyz2]) * rotation; + if (xformList[ixyz3]) rotation = *(xformList[ixyz3]) * rotation; + + delete xformList[0]; + delete xformList[1]; + delete xformList[2]; + + return transform * rotation; +} + +TopLevelPlacements::Part* +TopLevelPlacements::getPart(const std::string& partName) const { + std::map<std::string, Part*>::const_iterator iter; + iter = m_parts.find(partName); + if (iter == m_parts.end()) return 0; + + return iter->second; +} diff --git a/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/TubeVolData.cxx b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/TubeVolData.cxx new file mode 100644 index 000000000..9277bcb88 --- /dev/null +++ b/Scintillator/ScintDetDescr/ScintGeoModelUtils/src/TubeVolData.cxx @@ -0,0 +1,101 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + */ + +#include "ScintGeoModelUtils/TubeVolData.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <cmath> +#include <string> +#include <iostream> + +namespace ScintDD { + std::string + TubeVolData::material() const { + return m_record->getString("MATERIAL"); + } + + double + TubeVolData::maxRadius() const { + return std::max(m_rmax1, m_rmax2); + } + + TubeVolData::TubeVolData(const IRDBRecord* record) + : m_record(record), + m_bothZ(false), + m_nRepeat(0), + m_radialDiv(0), + m_phiStart(0.), + m_phiDelta(0.), + m_phiStep(0.), + m_rmin1(0.), + m_rmin2(0.), + m_rmax1(0.), + m_rmax2(0.), + m_length(0.), + m_zMid(0.) { + // add an 2*epsilon gap between phi sectors. + const double phiepsilon = 0.001 * Gaudi::Units::degree; + + bool fullPhiSector = false; + + + // Get the parameters which we need to do some preprocessing with. + // The rest are obtained directly from RDB. + + if (m_record) { + m_phiStart = m_record->getDouble("PHISTART") * Gaudi::Units::degree; + m_phiDelta = m_record->getDouble("PHIDELTA") * Gaudi::Units::degree; + m_phiStep = m_record->getDouble("PHISTEP") * Gaudi::Units::degree; + m_nRepeat = m_record->getInt("NREPEAT"); + m_rmin1 = m_record->getDouble("RMIN") * Gaudi::Units::mm; + m_rmax1 = m_record->getDouble("RMAX") * Gaudi::Units::mm; + m_rmin2 = m_record->getDouble("RMIN2") * Gaudi::Units::mm; + m_rmax2 = m_record->getDouble("RMAX2") * Gaudi::Units::mm; + m_radialDiv = 0; + if (!m_record->isFieldNull("RADIAL")) { + m_radialDiv = m_record->getInt("RADIAL"); + } + m_bothZ = 0; + if (!m_record->isFieldNull("ZSYMM")) { + m_bothZ = m_record->getInt("ZSYMM"); + } + + double zmin = m_record->getDouble("ZMIN") * Gaudi::Units::mm; + double zmax = m_record->getDouble("ZMAX") * Gaudi::Units::mm; + m_length = std::abs(zmax - zmin); + m_zMid = 0.5 * (zmin + zmax); + + if (m_phiDelta == 0 || m_phiDelta >= 359.9 * Gaudi::Units::degree) { + m_phiDelta = 360 * Gaudi::Units::degree; + fullPhiSector = true; + } else { + m_phiDelta -= 2 * phiepsilon; + m_phiStart += phiepsilon; + } + + // Force nRepeat to be >= 1; + if (m_nRepeat <= 0) m_nRepeat = 1; + // if PHISTEP==0 then set it to be equi-distant steps filling up phi. + if (m_phiStep == 0) { + m_phiStep = 360 * Gaudi::Units::degree / m_nRepeat; + } + + if (m_rmin2 <= 0) m_rmin2 = m_rmin1; + if (m_rmax2 <= 0) m_rmax2 = m_rmax1; + + if (m_radialDiv > 0) { + m_shape = TubeVolData::RADIAL; + } else if (m_rmin1 == m_rmin2 && m_rmax1 == m_rmax2) { + if (fullPhiSector) { + m_shape = TubeVolData::TUBE; + } else { + m_shape = TubeVolData::TUBS; + } + } else { + m_shape = TubeVolData::CONS; + } + } else std::cout << "Unexpected ERROR in ExtraMaterial!" << std::endl; + } +} // end namespace diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintDetectorManager.h b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintDetectorManager.h index b372bdd0b..f5be56816 100644 --- a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintDetectorManager.h +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintDetectorManager.h @@ -114,10 +114,13 @@ class ScintNumerology; GeoVAlignmentStore* alignStore=nullptr) const; /** Access to module design */ - void addDesign(const ScintDetectorDesign *); - int numDesigns() const; - const ScintDetectorDesign * getDesign(int i) const; + // void addDesign(const ScintDetectorDesign *); + // int numDesigns() const; + // const ScintDetectorDesign * getDesign(int i) const; + void setDesign(const ScintDetectorDesign*); + const ScintDetectorDesign* getDesign() const; + /** Access Numerology */ const ScintNumerology & numerology() const {return m_numerology;} ScintNumerology & numerology() {return m_numerology;} @@ -138,7 +141,7 @@ class ScintNumerology; std::string m_tag; ScintNumerology m_numerology; - std::vector< const ScintDetectorDesign *> m_designs; + const ScintDetectorDesign * m_design; }; diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintNumerology.h b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintNumerology.h index 9d2560818..05883b0f5 100644 --- a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintNumerology.h +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintNumerology.h @@ -12,7 +12,7 @@ #ifndef SCINTREADOUTGEOMETRY_SCINTNUMEROLOGY_H #define SCINTREADOUTGEOMETRY_SCINTNUMEROLOGY_H -#include <vector> +#include <set> namespace ScintDD { @@ -38,39 +38,28 @@ namespace ScintDD { int numStations() const; /** Number of plates in a station */ - int numPlatesForStation(int station) const; + int numPlatesPerStation() const; /** Number of pmts for plate */ - int numPmtsForPlate(int station, int plate) const; + int numPmtsPerPlate() const; + + const std::set<int>& stationIds() const; // Check presence of station /** Check if station exists */ bool useStation(int station) const; - // Maximums - /** Maximum number of plates in a station */ - int maxNumPlates() const; - - /** Maximum number of pmts on a plate */ - int maxNumPmts() const; // Modifiers: void addStation(int id); - // void setNumStations(int nStations); - void setNumPlatesForStation(int station, int nPlates); - void setNumPmtsForPlate(int station, int plate, int nPmts); - void setMaxNumPmts(int nPmts); + void setNumPlatesPerStation(int plates); + void setNumPmtsPerPlate(int pmts); private: - int m_numStations; - int m_maxNumStationPlates; - int m_maxNumPlatePmts; - - std::vector<int> m_stationIds; - std::vector<int> m_platesForStation; - std::vector<std::vector<int> > m_pmtsForPlate; - + int m_numPlatesPerStation; + int m_numPmtsPerPlate; + std::set<int> m_stationIds; }; }// End namespace diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintNumerology.icc b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintNumerology.icc index 4aa49c0f4..15c18d9bb 100644 --- a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintNumerology.icc +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/ScintNumerology.icc @@ -7,34 +7,27 @@ namespace ScintDD { inline int ScintNumerology::numStations() const { - return m_numStations; + return m_stationIds.size(); } -inline int ScintNumerology::numPlatesForStation(int station) const +inline int ScintNumerology::numPlatesPerStation() const { - return m_platesForStation[station]; + return m_numPlatesPerStation; } -inline int ScintNumerology::numPmtsForPlate(int station, int plate) const +inline int ScintNumerology::numPmtsPerPlate() const { - return m_pmtsForPlate[station][plate]; + return m_numPmtsPerPlate; } -inline int ScintNumerology::maxNumPlates() const -{ - return m_maxNumStationPlates; -} - -inline int ScintNumerology::maxNumPmts() const +inline bool ScintNumerology::useStation(int station) const { - return m_maxNumPlatePmts; + return (m_stationIds.count(station) > 0); } - - -inline bool ScintNumerology::useStation(int station) const +inline const std::set<int>& ScintNumerology::stationIds() const { - return (m_platesForStation[station] != 0); + return m_stationIds; } } // End namespace diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/VetoDetectorManager.h b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/VetoDetectorManager.h index 2cdeabff2..748ad5a49 100644 --- a/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/VetoDetectorManager.h +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/ScintReadoutGeometry/VetoDetectorManager.h @@ -109,7 +109,7 @@ namespace ScintDD { virtual bool identifierBelongs(const Identifier & id) const override; /** Access to module design, casts to VetoDetectorDesign */ - const ScintDetectorDesign * getVetoDesign(int i) const; + const ScintDetectorDesign * getVetoDesign() const; /** Process new global DB folders for L1 and L2 **/ virtual diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorManager.cxx b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorManager.cxx index 4e4c5229c..048dcbbe4 100644 --- a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorManager.cxx +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintDetectorManager.cxx @@ -24,7 +24,8 @@ namespace ScintDD { ScintDetectorManager::ScintDetectorManager(StoreGateSvc * detStore, const std::string & name) - : ScintDetectorManagerBase(detStore, name) + : ScintDetectorManagerBase(detStore, name), + m_design {nullptr} { // Add default folder addFolder("/Scint/Align"); @@ -130,20 +131,14 @@ namespace ScintDD } } - void ScintDetectorManager::addDesign(const ScintDetectorDesign * design) + void ScintDetectorManager::setDesign(const ScintDetectorDesign * design) { - m_designs.push_back(design); + m_design = design; } - int ScintDetectorManager::numDesigns() const + const ScintDetectorDesign* ScintDetectorManager::getDesign() const { - return m_designs.size(); - } - - - const ScintDetectorDesign* ScintDetectorManager::getDesign(int i) const - { - return m_designs[i]; + return m_design; } }// namespace ScintDD diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintNumerology.cxx b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintNumerology.cxx index 53820f9c6..e1f4f7112 100644 --- a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintNumerology.cxx +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/ScintNumerology.cxx @@ -8,39 +8,23 @@ namespace ScintDD { ScintNumerology::ScintNumerology() - : m_numStations(0), - m_maxNumStationPlates(0), - m_maxNumPlatePmts(0) + : m_numPlatesPerStation(0), + m_numPmtsPerPlate(0) {} void ScintNumerology::addStation(int id) { - m_stationIds.push_back(id); - m_platesForStation.push_back(0); + m_stationIds.insert(id); } -// void ScintNumerology::setNumStations(int nStations) -// { -// m_platesForStation.resize(nStations); -// m_numStations = nStations; -// } - -void ScintNumerology::setNumPlatesForStation(int station, int nPlates) +void ScintNumerology::setNumPlatesPerStation(int nPlates) { - m_platesForStation[station] = nPlates; - m_pmtsForPlate[station].resize(nPlates); - m_maxNumStationPlates = std::max(m_maxNumStationPlates, nPlates); -} - -void ScintNumerology::setNumPmtsForPlate(int station, int plate, int nPmts) -{ - m_pmtsForPlate[station][plate] = nPmts; - m_maxNumPlatePmts = std::max(m_maxNumPlatePmts, nPmts); + m_numPlatesPerStation = nPlates; } -void ScintNumerology::setMaxNumPmts(int nPmts) +void ScintNumerology::setNumPmtsPerPlate(int nPmts) { - m_maxNumPlatePmts = std::max(m_maxNumPlatePmts, nPmts); + m_numPmtsPerPlate = nPmts; } diff --git a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/VetoDetectorManager.cxx b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/VetoDetectorManager.cxx index a5f61b013..ac0b1acab 100644 --- a/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/VetoDetectorManager.cxx +++ b/Scintillator/ScintDetDescr/ScintReadoutGeometry/src/VetoDetectorManager.cxx @@ -323,9 +323,9 @@ namespace ScintDD { } - const ScintDetectorDesign* VetoDetectorManager::getVetoDesign(int i) const + const ScintDetectorDesign* VetoDetectorManager::getVetoDesign() const { - return dynamic_cast<const ScintDetectorDesign *>(getDesign(i)); + return dynamic_cast<const ScintDetectorDesign *>(getDesign()); } // New global alignment folders diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoComponentFactory.h b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoComponentFactory.h new file mode 100644 index 000000000..4f2ea7453 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoComponentFactory.h @@ -0,0 +1,89 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETOGEOMODEL_VETOCOMPONENTFACTORY_H +#define VETOGEOMODEL_VETOCOMPONENTFACTORY_H + +#include "VetoGeoModel/VetoIdentifier.h" +#include <string> + +namespace ScintDD{class VetoDetectorManager;} +class VetoGeometryManager; +class VetoMaterialManager; + +class GeoLogVol; +class GeoVPhysVol; + + +class VetoComponentFactory +{ + +public: + VetoComponentFactory(const std::string & name, + ScintDD::VetoDetectorManager* detectorManager, + const VetoGeometryManager* geometryManager, + VetoMaterialManager* materials); + + const std::string & getName() const {return m_name;} + + // utility function to covert int to string + std::string intToString(int i) const; + +protected: + ScintDD::VetoDetectorManager* m_detectorManager; + const VetoGeometryManager* m_geometryManager; + VetoMaterialManager* m_materials; + + double epsilon() const; + virtual ~VetoComponentFactory(); + +private: + std::string m_name; + static const double s_epsilon; + +}; + + +class VetoSharedComponentFactory : public VetoComponentFactory +{ + +public: + VetoSharedComponentFactory(const std::string & name, + ScintDD::VetoDetectorManager* detectorManager, + const VetoGeometryManager* geometryManager, + VetoMaterialManager* materials=nullptr) : + VetoComponentFactory(name, detectorManager, geometryManager, materials), + m_physVolume(nullptr) + {}; + + GeoVPhysVol * getVolume() {return m_physVolume;} + +protected: + GeoVPhysVol * m_physVolume; + virtual GeoVPhysVol * build() = 0; + +}; + +class VetoUniqueComponentFactory : public VetoComponentFactory +{ + +public: + VetoUniqueComponentFactory(const std::string & name, + ScintDD::VetoDetectorManager* detectorManager, + const VetoGeometryManager* geometryManager, + VetoMaterialManager* materials=nullptr) : + VetoComponentFactory(name, detectorManager, geometryManager, materials), + m_logVolume{nullptr} + {}; + + virtual GeoVPhysVol * build(VetoIdentifier id) = 0; + +protected: + const GeoLogVol * m_logVolume; + + virtual const GeoLogVol * preBuild() = 0; + +}; + +#endif // VETOGEOMODEL_VETOCOMPONENTFACTORY_H diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDataBase.h b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDataBase.h new file mode 100644 index 000000000..92ed63172 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDataBase.h @@ -0,0 +1,151 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoGeoModel_VetoDataBase_H +#define VetoGeoModel_VetoDataBase_H + +#include "VetoGeoModel/VetoGeoModelAthenaComps.h" +#include <string> + +#include "RDBAccessSvc/IRDBAccessSvc.h" +class IRDBRecord; + + +class VetoDataBase +{ + + +public: + + VetoDataBase(const VetoGeoModelAthenaComps* athenaComps); + + const VetoGeoModelAthenaComps* athenaComps() const; + + IRDBRecordset_ptr weightTable() const; + IRDBRecordset_ptr scalingTable() const; + IRDBRecordset_ptr topLevelTable() const; + + IRDBRecordset_ptr conditionsTable() const; + const IRDBRecord* conditions() const; + +// const IRDBRecord* brlSensor() const; +// const IRDBRecord* brlModule() const; + +// const IRDBRecord* brlSki() const; +// const IRDBRecord* brlSkiZ(int i) const; +// int brlSkiZSize() const; +// const IRDBRecord* brlLayer(int i) const; +// const IRDBRecord* brlServices() const; +// const IRDBRecord* brlServPerLayer(int i) const; +// const IRDBRecord* brlThermalShield() const; + const IRDBRecord* stationGeneral() const; +// const IRDBRecord* brlFSI() const; +// int brlFSISize() const; +// const IRDBRecord* brlFSILocation(int i) const; + +// const IRDBRecord* fwdSensor(int i) const; +// const IRDBRecord* fwdHybrid() const; +// const IRDBRecord* fwdSpine(int i) const; +// const IRDBRecord* fwdModule(int i) const; +// int fwdModuleSize() const; +// IRDBRecordset_ptr fwdModuleConnectorTable() const; +// const IRDBRecord* fwdModuleConnector() const; + +// const IRDBRecord* fwdRing(int i) const; +// int fwdRingSize() const; +// const IRDBRecord* fwdWheel(int i) const; +// const IRDBRecord* fwdWheelRingMap(int i) const; +// int fwdWheelRingMapSize() const; +// const IRDBRecord* fwdDiscSupport() const; +// const IRDBRecord* fwdPatchPanelLoc(int i) const; +// int fwdPatchPanelLocSize() const; +// const IRDBRecord* fwdPatchPanel(int i) const; +// int fwdPatchPanelSize() const; +// const IRDBRecord* fwdPPConnector() const; +// int fwdPPConnectorSize() const; +// const IRDBRecord* fwdPPCooling() const; +// int fwdPPCoolingSize() const; +// const IRDBRecord* fwdCoolingBlock(int i) const; +// const IRDBRecord* fwdRingServices(int i) const; +// const IRDBRecord* fwdServices() const; +// const IRDBRecord* fwdFSILocation(int i) const; +// int fwdFSILocationSize() const; +// const IRDBRecord* fwdFSIType(int i) const; +// int fwdFSITypeSize() const; +// const IRDBRecord* fwdFSI(int i) const; +// int fwdFSISize() const; +// const IRDBRecord* fwdThermalShield(int i) const; +// int fwdThermalShieldSize() const; +// const IRDBRecord* fwdGeneral() const; +// IRDBRecordset_ptr fwdOptoHarnessTable() const; +// const IRDBRecord* fwdOptoHarness(int i) const; +// IRDBRecordset_ptr fwdDiscFixationTable() const; +// const IRDBRecord* fwdDiscFixation() const; +// const IRDBRecord* fwdCylServ(int i) const; +// int fwdCylServSize() const; +// const IRDBRecord* fwdCylServLoc(int i) const; +// int fwdCylServLocSize() const; + + // Return the Veto version tag. + const std::string & versionTag() const; + + MsgStream& msg (MSG::Level lvl) const; + +private: + + VetoDataBase(const VetoDataBase &); + VetoDataBase& operator= (const VetoDataBase &); + +private: + + const VetoGeoModelAthenaComps* m_athenaComps; + + std::string m_vetoVersionTag; + + IRDBRecordset_ptr m_weightTable; + IRDBRecordset_ptr m_scalingTable; + IRDBRecordset_ptr m_topLevel; + IRDBRecordset_ptr m_conditions; + +// IRDBRecordset_ptr m_brlSensor; +// IRDBRecordset_ptr m_brlModule; +// IRDBRecordset_ptr m_brlSki; +// IRDBRecordset_ptr m_brlSkiZ; +// IRDBRecordset_ptr m_brlLayer; +// IRDBRecordset_ptr m_brlServices; +// IRDBRecordset_ptr m_brlServPerLayer; +// IRDBRecordset_ptr m_brlThermalShield; + IRDBRecordset_ptr m_stationGeneral; +// IRDBRecordset_ptr m_brlFSI; +// IRDBRecordset_ptr m_brlFSILocation; +// IRDBRecordset_ptr m_fwdSensor; +// IRDBRecordset_ptr m_fwdHybrid; +// IRDBRecordset_ptr m_fwdSpine; +// IRDBRecordset_ptr m_fwdModule; +// IRDBRecordset_ptr m_fwdModuleConnector; +// IRDBRecordset_ptr m_fwdRing; +// IRDBRecordset_ptr m_fwdWheel; +// IRDBRecordset_ptr m_fwdWheelRingMap; +// IRDBRecordset_ptr m_fwdDiscSupport; +// IRDBRecordset_ptr m_fwdPatchPanelLoc; +// IRDBRecordset_ptr m_fwdPatchPanel; +// IRDBRecordset_ptr m_fwdPPConnector; +// IRDBRecordset_ptr m_fwdPPCooling; +// IRDBRecordset_ptr m_fwdCoolingBlock; +// IRDBRecordset_ptr m_fwdRingServices; +// IRDBRecordset_ptr m_fwdServices; +// IRDBRecordset_ptr m_fwdFSILocation; +// IRDBRecordset_ptr m_fwdFSIType; +// IRDBRecordset_ptr m_fwdFSI; +// IRDBRecordset_ptr m_fwdThermalShield; +// IRDBRecordset_ptr m_fwdGeneral; +// IRDBRecordset_ptr m_fwdOptoHarness; +// IRDBRecordset_ptr m_fwdDiscFixation; +// IRDBRecordset_ptr m_fwdCylServ; +// IRDBRecordset_ptr m_fwdCylServLoc; + + +}; + +#endif //VetoGeoModel_VetoDataBase_H diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDetectorFactory.h b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDetectorFactory.h index 7b27f3619..498e02114 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDetectorFactory.h +++ b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoDetectorFactory.h @@ -5,7 +5,7 @@ #ifndef VETOGEOMODEL_VETODETECTORFACTORY_H #define VETOGEOMODEL_VETODETECTORFACTORY_H -#include "ScintGeoModelUtils/InDetDetectorFactoryBase.h" +#include "ScintGeoModelUtils/DetectorFactoryBase.h" #include "ScintReadoutGeometry/VetoDetectorManager.h" #include "ScintReadoutGeometry/ScintDD_Defs.h" diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeneralParameters.h b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeneralParameters.h new file mode 100644 index 000000000..e4343af88 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeneralParameters.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoGeoModel_VetoGeneralParameters_H +#define VetoGeoModel_VetoGeneralParameters_H + +#include "GeoModelKernel/GeoDefinitions.h" + +#include <map> +#include <string> + +class VetoDataBase; +class TopLevelPlacements; + +class VetoGeneralParameters { + +public: + + VetoGeneralParameters(VetoDataBase* rdb); + ~VetoGeneralParameters(); + //Explicitly disallow copy, assignment to appease coverity + VetoGeneralParameters(const VetoGeneralParameters &) = delete; + VetoGeneralParameters & operator=(const VetoGeneralParameters &) = delete; + + // General + double safety() const; + + //Default conditions. + double temperature() const; +// double biasVoltage() const; +// double depletionVoltage() const; + + const GeoTrf::Transform3D & partTransform(const std::string & partName) const; + bool partPresent(const std::string & partName) const; + +private: + + VetoDataBase * m_rdb; + TopLevelPlacements * m_placements; + +}; + + +#endif // SCT_GeoModel_SCT_GeneralParameters_H diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeometryManager.h b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeometryManager.h new file mode 100644 index 000000000..f113d1f1b --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoGeometryManager.h @@ -0,0 +1,66 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoGeoModel_VetoGeometryManager_H +#define VetoGeoModel_VetoGeometryManager_H + +#include "VetoGeoModel/VetoOptions.h" + +#include <memory> + +namespace ScintDD { + class ScintCommonItems; + class DistortedMaterialManager; +} + +class VetoStationParameters; +// class VetoPlateParameters; +class VetoDataBase; +class VetoGeneralParameters; +class VetoGeoModelAthenaComps; + +class VetoGeometryManager { + +public: + + // Constructor + VetoGeometryManager(VetoDataBase* rdb); + + // Destructor + ~VetoGeometryManager(); + + // Access to run time options + const VetoOptions & options() const; + void setOptions(const VetoOptions & options); + + // Access to athena components + const VetoGeoModelAthenaComps * athenaComps() const; + + // To be passed to detector element. + const ScintDD::ScintCommonItems * commonItems() const; + + const VetoStationParameters* stationParameters() const; +// const VetoPlateParameters* plateParameters() const; + const VetoGeneralParameters* generalParameters() const; + const ScintDD::DistortedMaterialManager* distortedMatManager() const; + + VetoGeometryManager& operator=(const VetoGeometryManager& right); + VetoGeometryManager(const VetoGeometryManager& right); + +private: + + VetoOptions m_options; + const VetoGeoModelAthenaComps * m_athenaComps; + ScintDD::ScintCommonItems * m_commonItems; + VetoDataBase* m_rdb; + + std::unique_ptr<VetoStationParameters> m_stationParameters; +// std::unique_ptr<VetoPlateParameters> m_plateParameters; + std::unique_ptr<VetoGeneralParameters> m_generalParameters; + std::unique_ptr<ScintDD::DistortedMaterialManager> m_distortedMatManager; + +}; + + +#endif // VetoGeoModel_VetoGeometryManager_H diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoIdentifier.h b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoIdentifier.h new file mode 100644 index 000000000..b5ba596c3 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoIdentifier.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETOGEOMODEL_VETOIDENTIFIER_H +#define VETOGEOMODEL_VETOIDENTIFIER_H + +class Identifier; +class VetoID; + +class VetoIdentifier +{ +public: + + VetoIdentifier( const VetoID* idHelper, + int station = 0, + int plate = 0 ) + : m_idHelper{idHelper}, + m_station{station}, + m_plate{plate} + {}; + + + void setStation(int i) {m_station = i;} + int getStation() const {return m_station;} + + void setPlate(int i) {m_plate = i;} + int getPlate() const {return m_plate;} + + Identifier getPlateId(); + + // For debugging purposes. + void print(); + +private: + const VetoID* m_idHelper; + int m_station; + int m_plate; +}; + +#endif // VETOGEOMODEL_VETOIDENTIFIER_H diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoMaterialManager.h b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoMaterialManager.h new file mode 100644 index 000000000..9fad943ae --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoMaterialManager.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETOMATERIALMANAGER_H +#define VETOMATERIALMANAGER_H + +// SCT_MaterialManager. This provides an interface to the InDetMaterialManager which in turn +// is an interface to GeoModel Material Manager with some additional functionality. +#include "ScintGeoModelUtils/ScintMaterialManager.h" + +#include <memory> +#include <string> + +class GeoMaterial; +class GeoElement; +class ScintMaterialManager; +class VetoDataBase; + +class VetoMaterialManager +{ + +public: + + VetoMaterialManager(VetoDataBase* db); + + const GeoMaterial* getMaterial(const std::string & materialName) const; + const GeoElement* getElement(const std::string & elementName) const; + + const GeoMaterial* getMaterial(const std::string & originalMaterial, + double density, + const std::string & newName = ""); + const GeoMaterial *getMaterialForVolume(const std::string & materialName, double volume); + + // Default gas material + const GeoMaterial* gasMaterial() const; + +private: + void loadMaterials(); + void addMaterial(GeoMaterial* material); + + std::unique_ptr<ScintMaterialManager> m_materialManager; + const GeoMaterial* m_gasMaterial; + +}; + + +#endif // VETOMATERIALMANAGER_H diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStation.h b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStation.h new file mode 100644 index 000000000..41c70fa31 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStation.h @@ -0,0 +1,53 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VETOGEOMODEL_VETOSTATION_H +#define VETOGEOMODEL_VETOSTATION_H + +#include "VetoGeoModel/VetoComponentFactory.h" + +class GeoVPhysVol; +class GeoFullPhysVol; +class GeoLogVol; +class VetoIdentifier; + +class VetoStation : public VetoUniqueComponentFactory +{ + +public: + VetoStation(const std::string & name, + ScintDD::VetoDetectorManager* detectorManager, + const VetoGeometryManager* geometryManager, + VetoMaterialManager* materials); + virtual GeoVPhysVol * build(VetoIdentifier id); + +public: + int numPlates() const {return m_numPlates;} + double thickness() const {return m_thickness;} + double width() const {return m_width;} + double length() const {return m_length;} + +private: + void getParameters(); + virtual const GeoLogVol * preBuild(); + +// void buildThermalShield(GeoFullPhysVol * parent) const; +// void buildEMIShield(GeoFullPhysVol * parent) const; + + + int m_numPlates; + + double m_thickness; + double m_width; + double m_length; + +// double m_thermalShieldEndWallThickness; + +// double m_zClearance; + +// bool m_isOldGeometry; + +}; + +#endif // VETOGEOMODEL_VETOSTATION_H diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStationParameters.h b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStationParameters.h new file mode 100644 index 000000000..281e0c922 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/VetoGeoModel/VetoStationParameters.h @@ -0,0 +1,190 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef VetoGeoModel_VetoStationParameters_H +#define VetoGeoModel_VetoStationParameters_H + +#include <string> + +class VetoDataBase; + +class VetoStationParameters { + +public: + + // Constructor + VetoStationParameters(VetoDataBase* rdb); + +// // Ski +// int skiFirstStagger() const; +// double skiRadialSep() const; +// int modulesPerSki() const; +// double skiZPosition(int index) const; +// int skiModuleIdentifier(int index) const; + +// // Layer +// double tilt(int iLayer) const; +// int layerStereoSign(int iLayer) const; +// double radius(int iLayer) const; +// int skisPerLayer(int iLayer) const; +// double layerBracketPhiOffset(int iLayer) const; +// double layerPhiOfRefModule(int iLayer) const; + +// // Bracket +// double bracketThickness() const; +// double bracketWidth() const; +// double bracketLength() const; +// std::string bracketMaterial() const; + +// // Dogleg +// double doglegThickness() const; +// double doglegWidth() const; +// double doglegLength() const; +// std::string doglegMaterial() const; +// double doglegOffsetX() const; +// double doglegOffsetY() const; + +// // CoolingBlock +// double coolingBlockThickness() const; +// double coolingBlockWidth() const; +// double coolingBlockLength() const; +// std::string coolingBlockMaterial() const; +// double coolingBlockOffsetX() const; +// double coolingBlockOffsetY() const; +// double coolingBlockOffsetZ() const; + +// // CoolingPipe +// double coolingPipeRadius() const; +// std::string coolingPipeMaterial() const; +// double coolingPipeOffsetX() const; +// double coolingPipeOffsetY() const; + +// // PowerTape +// double powerTapeThickness() const; +// double powerTapeWidth() const; +// std::string powerTapeMaterial() const; +// double powerTapeStartPointOffset() const; + +// // Harness +// double harnessThickness() const; +// double harnessWidth() const; +// std::string harnessMaterial() const; + +// // SupportCyl +// double supportCylInnerRadius(int iLayer) const; +// double supportCylOuterRadius(int iLayer) const; +// double supportCylDeltaR(int iLayer) const; +// std::string supportCylMaterial(int iLayer) const; + +// // Flange +// double flangeDeltaZ(int iLayer) const; +// double flangeDeltaR(int iLayer) const; +// std::string flangeMaterial(int iLayer) const; + +// // Clamp +// double clampDeltaZ(int iLayer) const; +// double clampDeltaR(int iLayer) const; +// std::string clampMaterial(int iLayer) const; + +// // Cooling Inlet/outlets +// double coolingEndDeltaR(int iLayer) const; +// std::string coolingEndMaterial(int iLayer) const; + +// // CloseOut +// double closeOutDeltaZ(int iLayer) const; +// std::string closeOutMaterial(int iLayer) const; + +// // InterLink and B6 bearing +// double interLinkDeltaZ() const; +// double interLinkInnerRadius() const; +// double interLinkOuterRadius() const; +// std::string interLinkMaterial() const; +// double interLinkDeltaPhi() const; +// double interLinkPhiPos() const; +// int interLinkNRepeat() const; +// std::string bearingMaterial() const; +// double bearingDeltaPhi() const; +// double bearingPhiPos() const; +// int bearingNRepeat() const; + +// // FSI and FSI flange +// bool includeFSI() const; +// double fsiFlangeInnerRadius() const; +// double fsiFlangeOuterRadius() const; +// std::string fsiFlangeMaterial() const; +// double fsiFibreMaskDeltaR() const; +// std::string fsiFibreMaskMaterial() const; +// double fsiEndJewelRadialWidth() const; +// double fsiEndJewelRPhiWidth() const; +// double fsiEndJewelLength() const; +// std::string fsiEndJewelMaterial() const; +// int fsiEndJewelNRepeat(int iLayer) const; +// double fsiEndJewelPhi(int iLayer) const; +// double fsiEndJewelZ(int iLayer) const; +// double fsiScorpionRadialWidth() const; +// double fsiScorpionRPhiWidth() const; +// double fsiScorpionLength() const; +// std::string fsiScorpionMaterial() const; +// int fsiScorpionNRepeat(int iLayer) const; +// double fsiScorpionPhi(int iLayer) const; +// double fsiScorpionZ(int iLayer) const; + +// // Spider +// double spiderDeltaZ() const; +// double spiderInnerRadius() const; +// double spiderOuterRadius() const; +// std::string spiderMaterial() const; + +// // Thermal Shield +// double thermalShieldInnerRadius() const; +// double thermalShieldOuterRadius() const; +// double thermalShieldEndZMax() const; +// double thermalShieldCylTotalThickness() const; +// double thermalShieldCylInnerWallThickness() const; +// double thermalShieldCylOuterWallThickness() const; +// double thermalShieldSpacerZWidth() const; +// double thermalShieldFirstSpacerZMin() const; +// double thermalShieldEndCapCylThickness() const; +// double thermalShieldEndCapThickness() const; +// double thermalShieldBulkheadInnerRadius() const; +// double thermalShieldBulkheadOuterRadius() const; +// double thermalShieldEndPanelInnerRadius() const; +// double thermalShieldEndPanelOuterRadius() const; +// std::string thermalShieldMaterialSpacer() const; +// std::string thermalShieldMaterialCyl() const; +// std::string thermalShieldMaterialOuterSect() const; +// std::string thermalShieldMaterialInnerSect() const; + +// // EMI Shield (Inner Thermal Shield) +// double emiShieldInnerRadius() const; +// double emiShieldDeltaR() const; +// double emiShieldZMax() const; +// std::string emiShieldMaterial() const; +// double emiJointDeltaR() const; +// double emiJointRPhi() const; +// std::string emiJointMaterial() const; + +// // Attachment of pixel to SCT. +// double pixelAttachmentInnerRadius() const; +// double pixelAttachmentOuterRadius() const; +// double pixelAttachmentZMin() const; +// double pixelAttachmentDeltaZ() const; +// std::string pixelAttachmentMaterial() const; + + // Barrel General + int numPlates() const; + double stationThickness() const; + double stationWidth() const; + double stationLength() const; +// double cylinderLength() const; +// double activeLength() const; +// bool isOldGeometry() const; + + private: + VetoDataBase * m_rdb; + +}; + + +#endif // VetoGeoModel_VetoStationParameters_H diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoComponentFactory.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoComponentFactory.cxx new file mode 100644 index 000000000..55bb3efe0 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoComponentFactory.cxx @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoGeoModel/VetoComponentFactory.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <sstream> +#include <string> + +using ScintDD::VetoDetectorManager; + +const double VetoComponentFactory::s_epsilon = 1.0e-6 * Gaudi::Units::mm; + +VetoComponentFactory::VetoComponentFactory(const std::string & name, + ScintDD::VetoDetectorManager* detectorManager, + const VetoGeometryManager* geometryManager, + VetoMaterialManager* materials) + : m_detectorManager(detectorManager), + m_geometryManager(geometryManager), + m_materials(materials), + m_name(name) +{} + +VetoComponentFactory::~VetoComponentFactory() +{} + +std::string +VetoComponentFactory::intToString(int i) const +{ + std::ostringstream str; + str << i; + return str.str(); +} + +double +VetoComponentFactory::epsilon() const +{ + return s_epsilon; +} diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDataBase.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDataBase.cxx new file mode 100644 index 000000000..d77ebdb7d --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDataBase.cxx @@ -0,0 +1,267 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoGeoModel/VetoDataBase.h" + +#include "RDBAccessSvc/IRDBAccessSvc.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "RDBAccessSvc/IRDBRecord.h" + +#include "GeoModelInterfaces/IGeoDbTagSvc.h" +#include "GeoModelUtilities/DecodeVersionKey.h" + +#include "VetoGeoModel/VetoGeoModelAthenaComps.h" + +#include <iostream> + +VetoDataBase::VetoDataBase(const VetoGeoModelAthenaComps * athenaComps) +{ + m_athenaComps = athenaComps; + + IGeoDbTagSvc * geoDbTag = m_athenaComps->geoDbTagSvc(); + + // Get version tag and node for Veto + DecodeVersionKey versionKey(geoDbTag,"Veto"); + std::string versionTag = versionKey.tag(); + std::string versionNode = versionKey.node(); + + // Get version tag and node for InnerDetector. + DecodeVersionKey scintVersionKey(geoDbTag,"Scintillator"); + + // Access the RDB + IRDBAccessSvc* rdbSvc = m_athenaComps->rdbAccessSvc(); + + // SCT version tag + m_vetoVersionTag = rdbSvc->getChildTag("Veto", versionKey.tag(), versionKey.node()); + + +///////////////////////////////////////////////////////// +// +// Gets the structures +// +///////////////////////////////////////////////////////// + + msg(MSG::INFO) << "Retrieving Record Sets from database ..." << endmsg; + msg(MSG::DEBUG) << " Using version tag: " << versionTag << endmsg; + msg(MSG::DEBUG) << " at node: " << versionNode << endmsg; + msg(MSG::DEBUG) << " Veto Version: " << m_vetoVersionTag << endmsg; + + // ATLS - not sure I use it. + // General atlas parameters + + // + // Veto General + // + + // Veto TopLevel + m_topLevel = rdbSvc->getRecordsetPtr("VetoTopLevel", versionTag, versionNode); + msg(MSG::DEBUG) << "Table VetoTopLevel Fetched" << endmsg; + + // Weight Table + m_weightTable = rdbSvc->getRecordsetPtr("VetoWeights", versionTag, versionNode); + msg(MSG::DEBUG) << "Table VetoWeights Fetched" << endmsg; + + // Extra Scaling Table. This is used for extra material studies. For nominal material the table should be empty. + // NB this is at InnerDetector level node. + m_scalingTable = rdbSvc->getRecordsetPtr("VetoMatScaling", scintVersionKey.tag(), scintVersionKey.node()); + msg(MSG::DEBUG) << "Table VetoMatScaling Fetched" << endmsg; + + // Default conditions + m_conditions = rdbSvc->getRecordsetPtr("VetoConditions", versionTag, versionNode); + msg(MSG::DEBUG) << "Table VetoConditions Fetched" << endmsg; + +// // +// // SCT Barrel +// // +// m_brlSensor = rdbSvc->getRecordsetPtr("SctBrlSensor", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctBrlSensor Fetched" << endmsg; + +// m_brlModule = rdbSvc->getRecordsetPtr("SctBrlModule", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctBrlModule Fetched" << endmsg; + +// m_brlSki = rdbSvc->getRecordsetPtr("SctBrlSki", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctBrlSki Fetched" << endmsg; + +// m_brlSkiZ = rdbSvc->getRecordsetPtr("SctBrlSkiZ", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctBrlSkiZ Fetched" << endmsg; + +// m_brlLayer = rdbSvc->getRecordsetPtr("SctBrlLayer", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctBrlLayer Fetched" << endmsg; + +// m_brlServices = rdbSvc->getRecordsetPtr("SctBrlServices", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctBrlServices Fetched" << endmsg; + +// m_brlServPerLayer = rdbSvc->getRecordsetPtr("SctBrlServPerLayer", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctBrlServPerLayer Fetched" << endmsg; + +// m_brlThermalShield = rdbSvc->getRecordsetPtr("SctBrlThermalShield", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctBrlThermalShield Fetched" << endmsg; + + m_stationGeneral = rdbSvc->getRecordsetPtr("VetoStationGeneral", versionTag, versionNode); + msg(MSG::DEBUG) << "Table VetoStationGeneral Fetched" << endmsg; + +// m_brlFSI = rdbSvc->getRecordsetPtr("SctBrlFSI", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctBrlFSI Fetched" << endmsg; + +// m_brlFSILocation = rdbSvc->getRecordsetPtr("SctBrlFSILocation", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctBrlFSILocation Fetched" << endmsg; + +// m_fwdSensor = rdbSvc->getRecordsetPtr("SctFwdSensor", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdSensor Fetched" << endmsg; + +// m_fwdHybrid = rdbSvc->getRecordsetPtr("SctFwdHybrid", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdHybrid Fetched" << endmsg; + +// m_fwdSpine = rdbSvc->getRecordsetPtr("SctFwdSpine", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdSpine Fetched" << endmsg; + +// m_fwdModule = rdbSvc->getRecordsetPtr("SctFwdModule", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdModule Fetched" << endmsg; + +// m_fwdModuleConnector = rdbSvc->getRecordsetPtr("SctFwdModuleConnector", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdModuleConnector Fetched" << endmsg; + +// // +// // SCT Forward +// // +// m_fwdRing = rdbSvc->getRecordsetPtr("SctFwdRing", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdRing Fetched" << endmsg; + +// m_fwdWheel = rdbSvc->getRecordsetPtr("SctFwdWheel", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdWheel Fetched" << endmsg; + +// m_fwdWheelRingMap = rdbSvc->getRecordsetPtr("SctFwdWheelRingMap", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdWheelRingMap Fetched" << endmsg; + +// m_fwdDiscSupport = rdbSvc->getRecordsetPtr("SctFwdDiscSupport", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdDiscSupport Fetched" << endmsg; + +// m_fwdPatchPanelLoc = rdbSvc->getRecordsetPtr("SctFwdPatchPanelLoc", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdPatchPanelLoc Fetched" << endmsg; + +// m_fwdPatchPanel = rdbSvc->getRecordsetPtr("SctFwdPatchPanel", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdPatchPanel Fetched" << endmsg; + +// m_fwdPPConnector = rdbSvc->getRecordsetPtr("SctFwdPPConnector", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdPPConnector Fetched" << endmsg; + +// m_fwdPPCooling = rdbSvc->getRecordsetPtr("SctFwdPPCooling", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdPPCooling Fetched" << endmsg; + +// m_fwdCoolingBlock = rdbSvc->getRecordsetPtr("SctFwdCoolingBlock", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdCoolingBlock Fetched" << endmsg; + +// m_fwdRingServices = rdbSvc->getRecordsetPtr("SctFwdRingServices", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdRingServices Fetched" << endmsg; + +// m_fwdServices = rdbSvc->getRecordsetPtr("SctFwdServices", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdServices Fetched" << endmsg; + +// m_fwdFSILocation = rdbSvc->getRecordsetPtr("SctFwdFSILocation", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdFSILocation Fetched" << endmsg; + +// m_fwdFSIType = rdbSvc->getRecordsetPtr("SctFwdFSIType", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdFSIType Fetched" << endmsg; + +// m_fwdFSI = rdbSvc->getRecordsetPtr("SctFwdFSI", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdFSI Fetched" << endmsg; + +// m_fwdThermalShield = rdbSvc->getRecordsetPtr("SctFwdThermalShield", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdThermalShield Fetched" << endmsg; + +// m_fwdGeneral = rdbSvc->getRecordsetPtr("SctFwdGeneral", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdGeneral Fetched" << endmsg; + +// m_fwdOptoHarness = rdbSvc->getRecordsetPtr("SctFwdOptoHarness", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdOptoHarness Fetched" << endmsg; + +// m_fwdDiscFixation = rdbSvc->getRecordsetPtr("SctFwdDiscFixation", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdDiscFixation Fetched" << endmsg; + +// m_fwdCylServ = rdbSvc->getRecordsetPtr("SctFwdCylServ", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdCyServ Fetched" << endmsg; + +// m_fwdCylServLoc = rdbSvc->getRecordsetPtr("SctFwdCylServLoc", versionTag, versionNode); +// msg(MSG::DEBUG) << "Table SctFwdCylServLoc Fetched" << endmsg; + +} + +const VetoGeoModelAthenaComps* VetoDataBase::athenaComps() const { return m_athenaComps; } + +IRDBRecordset_ptr VetoDataBase::weightTable() const {return m_weightTable;} + +IRDBRecordset_ptr VetoDataBase::scalingTable() const {return m_scalingTable;} + +// //const IRDBRecord* VetoDataBase::atls() const {return *m_atls)[0];} +IRDBRecordset_ptr VetoDataBase::topLevelTable() const {return m_topLevel;} + +IRDBRecordset_ptr VetoDataBase::conditionsTable() const {return m_conditions;} +const IRDBRecord* VetoDataBase::conditions() const {return (*m_conditions)[0];} + +// const IRDBRecord* VetoDataBase::brlSensor() const {return (*m_brlSensor)[0];} +// const IRDBRecord* VetoDataBase::brlModule() const {return (*m_brlModule)[0];} + +// const IRDBRecord* VetoDataBase::brlSki() const {return (*m_brlSki)[0];} +// const IRDBRecord* VetoDataBase::brlSkiZ(int i) const {return (*m_brlSkiZ)[i];} +// int VetoDataBase::brlSkiZSize() const {return m_brlSkiZ->size();} +// const IRDBRecord* VetoDataBase::brlLayer(int i) const {return (*m_brlLayer)[i];} +// const IRDBRecord* VetoDataBase::brlServices() const {return (*m_brlServices)[0];} +// const IRDBRecord* VetoDataBase::brlServPerLayer(int i) const {return (*m_brlServPerLayer)[i];} +// const IRDBRecord* VetoDataBase::brlThermalShield() const {return (*m_brlThermalShield)[0];} +const IRDBRecord* VetoDataBase::stationGeneral() const {return (*m_stationGeneral)[0];} +// const IRDBRecord* VetoDataBase::brlFSI() const {return (*m_brlFSI)[0];} +// int VetoDataBase::brlFSISize() const {return m_brlFSI->size();} +// const IRDBRecord* VetoDataBase::brlFSILocation(int i) const {return (*m_brlFSILocation)[i];} + +// const IRDBRecord* VetoDataBase::fwdSensor(int i) const {return (*m_fwdSensor)[i];} +// const IRDBRecord* VetoDataBase::fwdHybrid() const {return (*m_fwdHybrid)[0];} +// const IRDBRecord* VetoDataBase::fwdSpine(int i) const {return (*m_fwdSpine)[i];} +// const IRDBRecord* VetoDataBase::fwdModule(int i) const {return (*m_fwdModule)[i];} +// int VetoDataBase::fwdModuleSize() const {return m_fwdModule->size();} +// IRDBRecordset_ptr VetoDataBase::fwdModuleConnectorTable() const {return m_fwdModuleConnector;} +// const IRDBRecord* VetoDataBase::fwdModuleConnector() const {return (*m_fwdModuleConnector)[0];} + +// const IRDBRecord* VetoDataBase::fwdRing(int i) const {return (*m_fwdRing)[i];} +// int VetoDataBase::fwdRingSize() const {return m_fwdRing->size();} +// const IRDBRecord* VetoDataBase::fwdWheel(int i) const {return (*m_fwdWheel)[i];} +// const IRDBRecord* VetoDataBase::fwdWheelRingMap(int i) const {return (*m_fwdWheelRingMap)[i];} +// int VetoDataBase::fwdWheelRingMapSize() const {return m_fwdWheelRingMap->size();} +// const IRDBRecord* VetoDataBase::fwdDiscSupport() const {return (*m_fwdDiscSupport)[0];} +// const IRDBRecord* VetoDataBase::fwdPatchPanelLoc(int i) const {return (*m_fwdPatchPanelLoc)[i];} +// int VetoDataBase::fwdPatchPanelLocSize() const {return m_fwdPatchPanelLoc->size();} +// const IRDBRecord* VetoDataBase::fwdPatchPanel(int i) const {return (*m_fwdPatchPanel)[i];} +// int VetoDataBase::fwdPatchPanelSize() const {return m_fwdPatchPanel->size();} +// const IRDBRecord* VetoDataBase::fwdPPConnector() const {return (*m_fwdPPConnector)[0];} +// int VetoDataBase::fwdPPConnectorSize() const {return m_fwdPPConnector->size();} +// const IRDBRecord* VetoDataBase::fwdPPCooling() const {return (*m_fwdPPCooling)[0];} +// int VetoDataBase::fwdPPCoolingSize() const {return m_fwdPPCooling->size();} +// const IRDBRecord* VetoDataBase::fwdCoolingBlock(int i) const {return (*m_fwdCoolingBlock)[i];} +// const IRDBRecord* VetoDataBase::fwdRingServices(int i) const {return (*m_fwdRingServices)[i];} +// const IRDBRecord* VetoDataBase::fwdServices() const {return (*m_fwdServices)[0];} +// const IRDBRecord* VetoDataBase::fwdFSILocation(int i) const {return (*m_fwdFSILocation)[i];} +// int VetoDataBase::fwdFSILocationSize() const {return m_fwdFSILocation->size();} +// const IRDBRecord* VetoDataBase::fwdFSIType(int i) const {return (*m_fwdFSIType)[i];} +// int VetoDataBase::fwdFSITypeSize() const {return m_fwdFSIType->size();} +// const IRDBRecord* VetoDataBase::fwdFSI(int i) const {return (*m_fwdFSI)[i];} +// int VetoDataBase::fwdFSISize() const {return m_fwdFSI->size();} +// const IRDBRecord* VetoDataBase::fwdThermalShield(int i) const {return (*m_fwdThermalShield)[i];} +// int VetoDataBase::fwdThermalShieldSize() const {return m_fwdThermalShield->size();} +// const IRDBRecord* VetoDataBase::fwdGeneral() const {return (*m_fwdGeneral)[0];} +// IRDBRecordset_ptr VetoDataBase::fwdOptoHarnessTable() const {return m_fwdOptoHarness;} +// const IRDBRecord* VetoDataBase::fwdOptoHarness(int i) const {return (*m_fwdOptoHarness)[i];} +// const IRDBRecord* VetoDataBase::fwdDiscFixation() const {return (*m_fwdDiscFixation)[0];} +// IRDBRecordset_ptr VetoDataBase::fwdDiscFixationTable() const {return m_fwdDiscFixation;} +// const IRDBRecord* VetoDataBase::fwdCylServ(int i) const {return (*m_fwdCylServ)[i];} +// int VetoDataBase::fwdCylServSize() const {return m_fwdCylServ->size();} +// const IRDBRecord* VetoDataBase::fwdCylServLoc(int i) const {return (*m_fwdCylServLoc)[i];} +// int VetoDataBase::fwdCylServLocSize() const {return m_fwdCylServLoc->size();} + +const std::string & VetoDataBase::versionTag() const { + return m_vetoVersionTag; +} + +MsgStream& VetoDataBase::msg (MSG::Level lvl) const +{ + return m_athenaComps->msg(lvl); +} diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorFactory.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorFactory.cxx index 5950d45aa..aa36ff0e7 100644 --- a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorFactory.cxx +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoDetectorFactory.cxx @@ -19,8 +19,7 @@ #include "ScintReadoutGeometry/ScintDD_Defs.h" #include "ScintReadoutGeometry/ScintDetectorDesign.h" -// #include "SCT_GeoModel/SCT_Barrel.h" -// #include "SCT_GeoModel/SCT_Forward.h" +#include "VetoGeoModel/VetoStation.h" #include "VetoGeoModel/VetoDataBase.h" #include "VetoGeoModel/VetoGeoModelAthenaComps.h" @@ -105,7 +104,7 @@ VetoDetectorFactory::VetoDetectorFactory(const VetoGeoModelAthenaComps * athenaC int versionMajorNumber = 1; int versionMinorNumber = 0; int versionPatchNumber = 0; - InDetDD::Version version(versionTag, + ScintDD::Version version(versionTag, versionName, layout, description, @@ -141,23 +140,15 @@ void VetoDetectorFactory::create(GeoPhysVol *world) GeoTrf::Transform3D vetoTransform = vetoGeneral->partTransform("Veto"); -// std::string barrelLabel = "Barrel"; -// std::string forwardPlusLabel = "EndcapA"; -// std::string forwardMinusLabel = "EndcapC"; - -// bool barrelPresent = sctGeneral->partPresent(barrelLabel); -// bool forwardPlusPresent = sctGeneral->partPresent(forwardPlusLabel); -// bool forwardMinusPresent = sctGeneral->partPresent(forwardMinusLabel); - std::string stationA_Label = "StationA"; - std::string stationB_Label = "StationB"; - std::string absorberA_Label = "AbsorberA"; - std::string absorberB_Label = "AbsorberB"; + // std::string stationB_Label = "StationB"; + // std::string absorberA_Label = "AbsorberA"; + // std::string absorberB_Label = "AbsorberB"; bool stationA_Present = vetoGeneral->partPresent(stationA_Label); - bool stationB_Present = vetoGeneral->partPresent(stationB_Label); - bool absorberA_Present = vetoGeneral->partPresent(absorberA_Label); - bool absorberB_Present = vetoGeneral->partPresent(absorberB_Label); + // bool stationB_Present = vetoGeneral->partPresent(stationB_Label); + // bool absorberA_Present = vetoGeneral->partPresent(absorberA_Label); + // bool absorberB_Present = vetoGeneral->partPresent(absorberB_Label); // // Station A @@ -292,9 +283,10 @@ void VetoDetectorFactory::create(GeoPhysVol *world) m_detectorManager->initNeighbours(); // Set maximum number of strips in numerology. - for (int iDesign = 0; iDesign < m_detectorManager->numDesigns(); iDesign++) { - m_detectorManager->numerology().setMaxNumPmts(m_detectorManager->getVetoDesign(iDesign)->cells()); - } + // for (int iDesign = 0; iDesign < m_detectorManager->numDesigns(); iDesign++) { + // m_detectorManager->numerology().setMaxNumPmts(m_detectorManager->getVetoDesign(iDesign)->cells()); + // } + m_detectorManager->numerology().setNumPmtsPerPlate(m_detectorManager->getVetoDesign()->cells()); // Register the keys and the level corresponding to the key // and whether it expects a global or local shift. diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeneralParameters.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeneralParameters.cxx new file mode 100644 index 000000000..0f64291ce --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeneralParameters.cxx @@ -0,0 +1,88 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoGeoModel/VetoGeneralParameters.h" +#include "VetoGeoModel/VetoDataBase.h" +#include "RDBAccessSvc/IRDBRecord.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "GaudiKernel/SystemOfUnits.h" +#include "GeoModelKernel/GeoDefinitions.h" +#include "ScintGeoModelUtils/TopLevelPlacements.h" + +const double VetoSAFETY = 0.01 * Gaudi::Units::mm; // Used in some places to make envelopes slightly larger to ensure + // no overlaps due to rounding errors. + + +VetoGeneralParameters::VetoGeneralParameters(VetoDataBase* rdb) +{ + m_rdb = rdb; + m_placements = new TopLevelPlacements(m_rdb->topLevelTable()); +} + + +VetoGeneralParameters::~VetoGeneralParameters() +{ + delete m_placements; +} + + +const GeoTrf::Transform3D & +VetoGeneralParameters::partTransform(const std::string & partName) const +{ + return m_placements->transform(partName); +} + + +bool +VetoGeneralParameters::partPresent(const std::string & partName) const +{ + return m_placements->present(partName); +} + + + +// +// General +// +double +VetoGeneralParameters::safety() const +{ + return VetoSAFETY; +} + +// Default Conditions. Values should be come form conditions data base. These values provide +// default vlaues if nothing from the conditions database is provided. + + +double +VetoGeneralParameters::temperature() const +{ + if (m_rdb->conditionsTable()->size() == 0) { + return 266.15 * Gaudi::Units::kelvin; // -7 C + } + return (m_rdb->conditions()->getDouble("TEMPERATURE") + 273.15) * Gaudi::Units::kelvin; +} + + +// double +// SCT_GeneralParameters::biasVoltage() const +// { +// if (m_rdb->conditionsTable()->size() == 0) { +// return 100 * Gaudi::Units::volt; +// } +// return m_rdb->conditions()->getDouble("BIASVOLT") * Gaudi::Units::volt; +// } + +// double +// SCT_GeneralParameters::depletionVoltage() const +// { +// if (m_rdb->conditionsTable()->size() == 0) { +// return 20 * Gaudi::Units::volt; +// } +// return m_rdb->conditions()->getDouble("DEPLETIONVOLT") * Gaudi::Units::volt; +// } + + + + diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeometryManager.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeometryManager.cxx new file mode 100644 index 000000000..5fa1af13f --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoGeometryManager.cxx @@ -0,0 +1,112 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoGeoModel/VetoGeometryManager.h" + +#include "ScintGeoModelUtils/DistortedMaterialManager.h" +#include "ScintIdentifier/VetoID.h" +#include "ScintReadoutGeometry/ScintCommonItems.h" +#include "VetoGeoModel/VetoStationParameters.h" +// #include "VetoGeoModel/VetoPlateParameters.h" +#include "VetoGeoModel/VetoDataBase.h" +#include "VetoGeoModel/VetoGeneralParameters.h" +#include "VetoGeoModel/VetoGeoModelAthenaComps.h" + +VetoGeometryManager::VetoGeometryManager(VetoDataBase* rdb) + : m_athenaComps{rdb->athenaComps()}, + m_rdb{rdb} +{ + // This class uses reference counting. Should not be delete'd in destructor. + m_commonItems = new ScintDD::ScintCommonItems(m_athenaComps->getIdHelper()); + + m_stationParameters = std::make_unique<VetoStationParameters>(m_rdb); +// m_plateParameters = std::make_unique<VetoPlateParameters>(m_rdb); + m_generalParameters = std::make_unique<VetoGeneralParameters>(m_rdb); + m_distortedMatManager = std::make_unique<ScintDD::DistortedMaterialManager>(); +} + +VetoGeometryManager::~VetoGeometryManager() +{ +} + +// +// Access to run time options. +// +const VetoOptions & +VetoGeometryManager::options() const +{ + return m_options; +} + +void +VetoGeometryManager::setOptions(const VetoOptions & options) +{ + m_options = options; +} + +const VetoGeoModelAthenaComps * +VetoGeometryManager::athenaComps() const +{ + return m_athenaComps; +} + +// +// ScintCommonItems which are passed to ScintDetectorElements. +// + +const ScintDD::ScintCommonItems * +VetoGeometryManager::commonItems() const +{ + return m_commonItems; +} + +const VetoStationParameters * +VetoGeometryManager::stationParameters() const +{ + return m_stationParameters.get(); +} + +// const VetoPlateParameters * +// VetoGeometryManager::plateParameters() const +// { +// return m_plateParameters.get(); +// } + +const VetoGeneralParameters * +VetoGeometryManager::generalParameters() const +{ + return m_generalParameters.get(); +} + +const ScintDD::DistortedMaterialManager * +VetoGeometryManager::distortedMatManager() const +{ + return m_distortedMatManager.get(); +} + +VetoGeometryManager& +VetoGeometryManager::operator=(const VetoGeometryManager& right) { + if (this != &right) { + m_options = right.m_options; + m_athenaComps = right.m_athenaComps; + m_commonItems = right.m_commonItems; + m_rdb = right.m_rdb; + m_stationParameters.reset(new VetoStationParameters(m_rdb)); + // m_plateParameters.reset(new VetoPlateParameters(m_rdb)); + m_generalParameters.reset(new VetoGeneralParameters(m_rdb)); + m_distortedMatManager.reset(new ScintDD::DistortedMaterialManager()); + } + return *this; +} + +VetoGeometryManager::VetoGeometryManager(const VetoGeometryManager& right) { + m_options = right.m_options; + m_athenaComps = right.m_athenaComps; + m_commonItems = right.m_commonItems; + m_rdb = right.m_rdb; + m_stationParameters.reset(new VetoStationParameters(m_rdb)); +// m_plateParameters.reset(new VetoPlateParameters(m_rdb)); + m_generalParameters.reset(new VetoGeneralParameters(m_rdb)); + m_distortedMatManager.reset(new ScintDD::DistortedMaterialManager()); +} diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoIdentifier.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoIdentifier.cxx new file mode 100644 index 000000000..0d6d17eac --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoIdentifier.cxx @@ -0,0 +1,23 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoGeoModel/VetoIdentifier.h" +#include "ScintIdentifier/VetoID.h" +#include "Identifier/Identifier.h" + +#include <cassert> +#include <iostream> + +Identifier +VetoIdentifier::getPlateId() +{ + assert (m_idHelper); + return m_idHelper->plate_id(m_station, m_plate); +} + +void VetoIdentifier::print() +{ + std::cout << "2/1/" << m_station << "/" + << m_plate << std::endl; +} diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoMaterialManager.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoMaterialManager.cxx new file mode 100644 index 000000000..b0a3b4de6 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoMaterialManager.cxx @@ -0,0 +1,83 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoGeoModel/VetoMaterialManager.h" +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoElement.h" +#include "VetoGeoModel/VetoDataBase.h" +#include "RDBAccessSvc/IRDBRecordset.h" +#include "StoreGate/StoreGateSvc.h" +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <iostream> + +// Constructor +VetoMaterialManager::VetoMaterialManager(VetoDataBase* db) +{ + // Get my material manager. + ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap + StoreGateSvc* detStore; + StatusCode sc = svcLocator->service("DetectorStore", detStore ); + if (sc.isFailure()) { + std::cout << "Could not locate DetectorStore" << std::endl; + return; + } + + m_materialManager = std::make_unique<ScintMaterialManager>("VetoMaterialManager", db->athenaComps()); + m_materialManager->addWeightTable(db->weightTable(), "veto"); + m_materialManager->addScalingTable(db->scalingTable()); + + loadMaterials(); + + m_gasMaterial = m_materialManager->getMaterial("std::Air"); +} + +// Add materials not yet in the database +void +VetoMaterialManager::loadMaterials() +{ +} + +const GeoElement* +VetoMaterialManager::getElement(const std::string & elementName) const +{ + return m_materialManager->getElement(elementName); +} + +const GeoMaterial* +VetoMaterialManager::getMaterial(const std::string & materialName) const +{ + return m_materialManager->getMaterial(materialName); +} + +void +VetoMaterialManager::addMaterial(GeoMaterial* material) +{ + return m_materialManager->addMaterial(material); +} + +const GeoMaterial* +VetoMaterialManager::getMaterial(const std::string & originalMaterial, + double density, + const std::string & newName) +{ + + return m_materialManager->getMaterial(originalMaterial, density, newName); +} + +const GeoMaterial * +VetoMaterialManager::getMaterialForVolume(const std::string & materialName, double volume) +{ + return m_materialManager->getMaterialForVolume(materialName, volume); +} + + + +const GeoMaterial* +VetoMaterialManager::gasMaterial() const +{ + return m_gasMaterial; +} diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStation.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStation.cxx new file mode 100644 index 000000000..9fa68d191 --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStation.cxx @@ -0,0 +1,286 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoGeoModel/VetoStation.h" + +#include "VetoGeoModel/VetoMaterialManager.h" + +#include "VetoGeoModel/VetoGeometryManager.h" +#include "VetoGeoModel/VetoStationParameters.h" +#include "VetoGeoModel/VetoIdentifier.h" + +// #include "VetoGeoModel/VetoLayer.h" +// #include "VetoGeoModel/VetoModule.h" +// #include "VetoGeoModel/VetoSensor.h" +// #include "VetoGeoModel/VetoInterLink.h" +// #include "VetoGeoModel/VetoSpider.h" +// #include "VetoGeoModel/VetoPixelAttachment.h" + +#include "ScintReadoutGeometry/VetoDetectorManager.h" + +#include "ScintGeoModelUtils/ExtraMaterial.h" + +// #include "GeoModelKernel/GeoTube.h" +// #include "GeoModelKernel/GeoTubs.h" +#include "GeoModelKernel/GeoBox.h" +#include "GeoModelKernel/GeoLogVol.h" +#include "GeoModelKernel/GeoFullPhysVol.h" +#include "GeoModelKernel/GeoPhysVol.h" +#include "GeoModelKernel/GeoNameTag.h" +#include "GeoModelKernel/GeoIdentifierTag.h" +#include "GeoModelKernel/GeoTransform.h" +#include "GeoModelKernel/GeoAlignableTransform.h" +#include "GeoModelKernel/GeoMaterial.h" +#include "GeoModelKernel/GeoShape.h" +#include "GeoModelKernel/GeoShapeShift.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <iostream> + +VetoStation::VetoStation(const std::string & name, + ScintDD::VetoDetectorManager* detectorManager, + const VetoGeometryManager* geometryManager, + VetoMaterialManager* materials) + : VetoUniqueComponentFactory(name, detectorManager, geometryManager, materials) +{ + getParameters(); + m_logVolume = preBuild(); +} + + +void +VetoStation::getParameters() +{ + const VetoStationParameters * parameters = m_geometryManager->stationParameters(); + + m_width = parameters->stationWidth(); + m_length = parameters->stationLength(); + m_thickness = parameters->stationThickness(); + m_numPlates = parameters->numPlates(); + + // Set numerology + m_detectorManager->numerology().setNumPlatesPerStation(m_numPlates); + +} + +const GeoLogVol * +VetoStation::preBuild() +{ + // Create the station volume + // Box envelope containing the station. + const GeoBox* stationEnvelopeShape = new GeoBox(0.5 * m_thickness, 0.5 * m_width, 0.5 * m_length); + GeoLogVol* stationLog = new GeoLogVol(getName(), stationEnvelopeShape, m_materials->gasMaterial()); + return stationLog; +// const GeoTube * barrelEnvelopeShape = new GeoTube(m_innerRadius, m_outerRadius, 0.5 * m_length); +// GeoLogVol * barrelLog = new GeoLogVol(getName(), barrelEnvelopeShape, m_materials->gasMaterial()); +// return barrelLog; +} + +GeoVPhysVol * +VetoStation::build(VetoIdentifier id) +{ + + GeoFullPhysVol * station = new GeoFullPhysVol(m_logVolume); + + id.setPlate(0); // temporary to suppress warning + + // There is only one type of plate. So we create it just the once. +// VetoPlate plate("Plate", m_detectorManager, m_geometryManager, m_materials); + + + + // Create the interlinks +// VetoInterLink interLink("InterLink", m_detectorManager, m_geometryManager, m_materials); + + // Calculte the length of the layer cylinder. This is the barrel length less the thermal + // shield and interlink width. + // This is only used for 'OldGeometry". In new geometry, layer length is set internally, + // and is equal to support cylinder length +// double layerLength = m_length - 2*m_thermalShieldEndWallThickness - 2*interLink.length(); + +// // We reduce to allow some alignment clearance +// layerLength -= 2*m_zClearance; + +// for (int iLayer = 0; iLayer < m_numLayers; iLayer++) { + +// // Create the layers + +// layerLength = 0.; +// VetoLayer layer("Layer"+intToString(iLayer), iLayer, &module, m_detectorManager, m_geometryManager, m_materials); +// barrel->add(new GeoNameTag("Layer#"+intToString(iLayer))); +// barrel->add(new GeoIdentifierTag(iLayer)); // Identifier layer= iLayer +// id.setLayerDisk(iLayer); +// GeoAlignableTransform * transform = new GeoAlignableTransform(GeoTrf::Transform3D::Identity()); +// barrel->add(transform); +// GeoVPhysVol * layerPV = layer.build(id); +// barrel->add(layerPV); +// // Store alignable transform +// m_detectorManager->addAlignableTransform(2, id.getWaferId(), transform, layerPV); +// layerLength = std::max(layerLength,layer.length()); +// } + +// // Build and place the interlinks +// double interLinkZPos = 0.; +// interLinkZPos = 0.5 * layerLength + m_zClearance + 0.5 * interLink.length(); +// barrel->add(new GeoTransform(GeoTrf::TranslateZ3D(+interLinkZPos))); +// barrel->add(interLink.getVolume()); +// barrel->add(new GeoTransform(GeoTrf::TranslateZ3D(-interLinkZPos))); +// barrel->add(interLink.getVolume()); + +// // Build and place the cooling spiders +// double spiderZPos = 0.; +// VetoSpider spider("Spider", m_detectorManager, m_geometryManager, m_materials); +// spiderZPos = interLinkZPos + 0.5*interLink.length() + 0.5*spider.length(); +// barrel->add(new GeoTransform(GeoTrf::TranslateZ3D(+spiderZPos))); +// barrel->add(spider.getVolume()); +// barrel->add(new GeoTransform(GeoTrf::TranslateZ3D(-spiderZPos))); +// barrel->add(spider.getVolume()); + +// // Build and place the thermal shield. +// buildThermalShield(barrel); + +// // Build and place the EMI shield (inner thermal shield). +// buildEMIShield(barrel); + +// // Build and place SCT to Pixel attachment +// VetoPixelAttachment pixelAttachment("AttachmentPixelToSCT", m_detectorManager, m_geometryManager, m_materials); +// barrel->add(new GeoTransform(GeoTrf::TranslateZ3D(+pixelAttachment.zPosition()))); // +ve z +// barrel->add(pixelAttachment.getVolume()); +// barrel->add(new GeoTransform(GeoTrf::TranslateZ3D(-pixelAttachment.zPosition()))); // -ve z +// barrel->add(pixelAttachment.getVolume()); + + // Extra Material +// Unclear whether the geometrical assumptions are valid for a box shape (likely NOT) +// ScintDD::ExtraMaterial xMat(m_geometryManager->distortedMatManager()); +// xMat.add(station, "VetoStation"); + + return station; + +} + +// void VetoStation::buildThermalShield(GeoFullPhysVol * parent) const +// { + +// // The thermal shield is now in 3 parts: +// // (a) outer cylinder +// // (b) bulkheads +// // (c) end panels +// // The inner cylinder is called 'EMI shield' for backwards compatibility + +// const VetoStationParameters * parameters = m_geometryManager->barrelParameters(); + +// double cylinderOuterRadius = parameters->thermalShieldOuterRadius(); +// double cylinderInnerRadius = parameters->thermalShieldInnerRadius(); +// double cylinderLength = parameters->cylinderLength(); +// double bulkheadInnerRadius = parameters->thermalShieldBulkheadInnerRadius(); +// double bulkheadOuterRadius = parameters->thermalShieldBulkheadOuterRadius(); +// double bulkheadThickness = parameters->thermalShieldEndCapCylThickness(); +// double endPanelInnerRadius = parameters->thermalShieldEndPanelInnerRadius(); +// double endPanelOuterRadius = parameters->thermalShieldEndPanelOuterRadius(); +// double endPanelThickness = parameters->thermalShieldEndCapThickness(); +// double endPanelZMax = parameters->thermalShieldEndZMax(); + +// std::string cylinderMaterialName = parameters->thermalShieldMaterialCyl(); +// std::string bulkheadMaterialName = parameters->thermalShieldMaterialOuterSect(); +// std::string endPanelMaterialName = parameters->thermalShieldMaterialInnerSect(); + + +// // The outer cylinder part of thermal shield. +// const GeoTube * cylinderShape = new GeoTube(cylinderInnerRadius, cylinderOuterRadius, 0.5*cylinderLength); +// const GeoMaterial* cylinderMaterial = m_materials->getMaterialForVolume(cylinderMaterialName,cylinderShape->volume()); +// const GeoLogVol * cylinderLog = new GeoLogVol("ThShieldOuterCyl", cylinderShape, cylinderMaterial); +// GeoPhysVol * cylinder = new GeoPhysVol(cylinderLog); +// parent->add(cylinder); + +// // The bulkheads +// const GeoTube * bulkheadShape = new GeoTube(bulkheadInnerRadius, bulkheadOuterRadius, 0.5*bulkheadThickness); +// const GeoMaterial* bulkheadMaterial = m_materials->getMaterialForVolume(bulkheadMaterialName,bulkheadShape->volume()); +// const GeoLogVol * bulkheadLog = new GeoLogVol("ThShieldBulkhead", bulkheadShape, bulkheadMaterial); +// GeoPhysVol * bulkhead = new GeoPhysVol(bulkheadLog); +// GeoTransform * bulkheadPosPlus = new GeoTransform(GeoTrf::TranslateZ3D(+(endPanelZMax-endPanelThickness-0.5*bulkheadThickness))); +// GeoTransform * bulkheadPosMinus = new GeoTransform(GeoTrf::TranslateZ3D(-(endPanelZMax-endPanelThickness-0.5*bulkheadThickness))); +// parent->add(bulkheadPosPlus); +// parent->add(bulkhead); +// parent->add(bulkheadPosMinus); +// parent->add(bulkhead); + +// // The end panels +// const GeoTube * endPanelShape = new GeoTube(endPanelInnerRadius, endPanelOuterRadius, 0.5*endPanelThickness); +// const GeoMaterial* endPanelMaterial = m_materials->getMaterialForVolume(endPanelMaterialName,endPanelShape->volume()); +// const GeoLogVol * endPanelLog = new GeoLogVol("ThShieldEndPanel", endPanelShape, endPanelMaterial); +// GeoPhysVol * endPanel = new GeoPhysVol(endPanelLog); +// GeoTransform * endPanelPosPlus = new GeoTransform(GeoTrf::TranslateZ3D(+(endPanelZMax-0.5*endPanelThickness))); +// GeoTransform * endPanelPosMinus = new GeoTransform(GeoTrf::TranslateZ3D(-(endPanelZMax-0.5*endPanelThickness))); +// parent->add(endPanelPosPlus); +// parent->add(endPanel); +// parent->add(endPanelPosMinus); +// parent->add(endPanel); + +// } + +// void VetoStation::buildEMIShield(GeoFullPhysVol * parent) const +// { + +// const VetoStationParameters * parameters = m_geometryManager->barrelParameters(); + +// // Parameters of cylinder +// double innerRadius = parameters->emiShieldInnerRadius(); +// double deltaR = parameters->emiShieldDeltaR(); +// double outerRadius = innerRadius + deltaR; +// double length = 2 * parameters->emiShieldZMax(); +// std::string materialName = parameters->emiShieldMaterial(); + +// // Parameters of Electrical Shield Joint +// double jointDeltaR = 0; +// double jointRPhi = 0; +// std::string jointMaterialName; +// if(!m_isOldGeometry) { +// jointDeltaR = parameters->emiJointDeltaR(); +// jointRPhi = parameters->emiJointRPhi(); +// jointMaterialName = parameters->emiJointMaterial(); +// } + +// // Parameters of Pixel Attachment - needed for cut-out +// double pixelAttachmentLength = parameters->pixelAttachmentDeltaZ(); +// double pixelAttachmentZpos = parameters->pixelAttachmentZMin() + 0.5 * pixelAttachmentLength; + +// // Build cylinder (with cut-outs) +// const GeoShape * emiShieldShape = 0; +// const GeoMaterial * material; +// const GeoTube * emiShieldTube = new GeoTube(innerRadius, outerRadius, 0.5*length); +// if (m_isOldGeometry) { +// emiShieldShape = emiShieldTube; +// material = m_materials->getMaterial(materialName); +// } else { +// const GeoTube* cutOut = new GeoTube(innerRadius, outerRadius, 0.5*pixelAttachmentLength); +// const GeoShape* emiTemp = (GeoShape*)&(emiShieldTube->subtract(*cutOut << GeoTrf::TranslateZ3D(pixelAttachmentZpos))); +// emiShieldShape = (GeoShape*)&emiTemp->subtract(*cutOut << GeoTrf::TranslateZ3D(-pixelAttachmentZpos)); +// double emiVolume = emiShieldTube->volume() - 2. * cutOut->volume(); +// material = m_materials->getMaterialForVolume(materialName, emiVolume); +// } +// const GeoLogVol * emiShieldLog = new GeoLogVol("EMIShield", emiShieldShape, material); +// GeoPhysVol * emiShield = new GeoPhysVol(emiShieldLog); +// parent->add(emiShield); + +// // Build electrical shield joints (with cut-outs) +// if (!m_isOldGeometry) { +// double dphi = jointRPhi / outerRadius; +// const GeoTubs* emiJointTubs = new GeoTubs(outerRadius, outerRadius+jointDeltaR, 0.5*length, +// -0.5 * dphi * Gaudi::Units::radian, dphi * Gaudi::Units::radian); +// const GeoTubs* jointCutOut = new GeoTubs(outerRadius, outerRadius+jointDeltaR, 0.5*pixelAttachmentLength, +// -0.5 * dphi * Gaudi::Units::radian, dphi * Gaudi::Units::radian); +// const GeoShape* jointTemp = (GeoShape*)&(emiJointTubs->subtract(*jointCutOut << GeoTrf::TranslateZ3D(pixelAttachmentZpos))); +// const GeoShape* emiJointShape = (GeoShape*)&jointTemp->subtract(*jointCutOut << GeoTrf::TranslateZ3D(-pixelAttachmentZpos)); +// double jointVolume = emiJointTubs->volume() - 2. * jointCutOut->volume(); +// const GeoMaterial * jointMaterial = m_materials->getMaterialForVolume(jointMaterialName, jointVolume); +// const GeoLogVol * emiJointLog = new GeoLogVol("EMIShieldJoint", emiJointShape, jointMaterial); +// GeoPhysVol * emiJoint = new GeoPhysVol(emiJointLog); +// // Place 3 copies +// for (int i=0; i<3; i++) { +// double angle = (90. + i * 120.) * Gaudi::Units::degree; +// parent->add(new GeoTransform(GeoTrf::RotateZ3D(angle))); +// parent->add(emiJoint); +// } +// } +// } diff --git a/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStationParameters.cxx b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStationParameters.cxx new file mode 100644 index 000000000..41b62b62f --- /dev/null +++ b/Scintillator/ScintDetDescr/VetoGeoModel/src/VetoStationParameters.cxx @@ -0,0 +1,866 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "VetoGeoModel/VetoStationParameters.h" +#include "VetoGeoModel/VetoGeometryManager.h" + +#include "VetoGeoModel/VetoDataBase.h" + +#include "RDBAccessSvc/IRDBRecord.h" +#include "GaudiKernel/SystemOfUnits.h" + +#include <cmath> + + +VetoStationParameters::VetoStationParameters(VetoDataBase* rdb) +{ + m_rdb = rdb; +} + + +// // +// // Barrel Ski +// // +// int +// SCT_BarrelParameters::skiFirstStagger() const +// { +// return m_rdb->brlSki()->getInt("SKIFIRSTSTAGGER"); +// } + +// double +// SCT_BarrelParameters::skiRadialSep() const +// { +// return m_rdb->brlSki()->getDouble("SKIRADIALSEP") * Gaudi::Units::mm; +// } + +// int +// SCT_BarrelParameters::modulesPerSki() const +// { +// return m_rdb->brlSkiZSize(); +// } + +// double +// SCT_BarrelParameters::skiZPosition(int index) const +// { +// return m_rdb->brlSkiZ(index)->getDouble("ZPOSITION") * Gaudi::Units::mm; +// } + +// int +// SCT_BarrelParameters::skiModuleIdentifier(int index) const +// { +// return m_rdb->brlSkiZ(index)->getInt("MODULEID"); +// } + +// // +// // Barrel Layer +// // +// double +// SCT_BarrelParameters::tilt(int iLayer) const +// { +// return m_rdb->brlLayer(iLayer)->getDouble("TILT") * Gaudi::Units::degree; +// } + +// int +// SCT_BarrelParameters::layerStereoSign(int iLayer) const +// { +// return m_rdb->brlLayer(iLayer)->getInt("STEREOSIGN"); +// } + + +// double +// SCT_BarrelParameters::radius(int iLayer) const +// { +// return m_rdb->brlLayer(iLayer)->getDouble("RADIUS") * Gaudi::Units::mm; +// } + +// int +// SCT_BarrelParameters::skisPerLayer(int iLayer) const +// { +// return m_rdb->brlLayer(iLayer)->getInt("SKISPERLAYER"); +// } + +// double +// SCT_BarrelParameters::layerBracketPhiOffset(int iLayer) const +// { +// return m_rdb->brlLayer(iLayer)->getDouble("BRACKETPHIOFFSET") * Gaudi::Units::deg; +// } + +// double +// SCT_BarrelParameters::layerPhiOfRefModule(int iLayer) const +// { +// // For backward compatibility, if field is null return (90 - tilt) +// // as ref module is horizontal in old versions. +// if (m_rdb->brlLayer(iLayer)->isFieldNull("PHIOFREFMODULE")) { +// return 90*Gaudi::Units::deg - tilt(iLayer); +// } +// return m_rdb->brlLayer(iLayer)->getDouble("PHIOFREFMODULE") * Gaudi::Units::deg; +// } + + +// // +// // Barrel Bracket +// // +// double +// SCT_BarrelParameters::bracketThickness() const +// { +// return m_rdb->brlSki()->getDouble("BRACKETTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::bracketWidth() const +// { +// return m_rdb->brlSki()->getDouble("BRACKETWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::bracketLength() const +// { +// return m_rdb->brlSki()->getDouble("BRACKETLENGTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::bracketMaterial() const +// { +// return m_rdb->brlSki()->getString("BRACKETMATERIAL"); +// } + +// // +// // Barrel Dogleg +// // +// double +// SCT_BarrelParameters::doglegThickness() const +// { +// return m_rdb->brlSki()->getDouble("DOGLEGTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::doglegWidth() const +// { +// return m_rdb->brlSki()->getDouble("DOGLEGWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::doglegLength() const +// { +// return m_rdb->brlSki()->getDouble("DOGLEGLENGTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::doglegMaterial() const +// { +// return m_rdb->brlSki()->getString("DOGLEGMATERIAL"); +// } + +// double +// SCT_BarrelParameters::doglegOffsetX() const +// { +// return m_rdb->brlSki()->getDouble("DOGLEGOFFSETX") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::doglegOffsetY() const +// { +// return m_rdb->brlSki()->getDouble("DOGLEGOFFSETY") * Gaudi::Units::mm; +// } + +// // +// // Barrel CoolingBlock +// // +// double +// SCT_BarrelParameters::coolingBlockThickness() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKTHICK") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::coolingBlockWidth() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::coolingBlockLength() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKLENGTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::coolingBlockMaterial() const +// { +// return m_rdb->brlSki()->getString("COOLINGBLOCKMATERIAL"); +// } + +// double +// SCT_BarrelParameters::coolingBlockOffsetX() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKOFFSETX") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::coolingBlockOffsetY() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKOFFSETY") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::coolingBlockOffsetZ() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGBLOCKOFFSETZ") * Gaudi::Units::mm; +// } + +// // +// // Barrel CoolingPipe +// // +// double +// SCT_BarrelParameters::coolingPipeRadius() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGPIPERADIUS") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::coolingPipeMaterial() const +// { +// return m_rdb->brlSki()->getString("COOLINGPIPEMATERIAL"); +// } + +// double +// SCT_BarrelParameters::coolingPipeOffsetX() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGPIPEOFFSETX") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::coolingPipeOffsetY() const +// { +// return m_rdb->brlSki()->getDouble("COOLINGPIPEOFFSETY") * Gaudi::Units::mm; +// } + + +// // +// // Barrel PowerTape +// // +// double +// SCT_BarrelParameters::powerTapeThickness() const +// { +// return m_rdb->brlSki()->getDouble("POWERTAPETHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::powerTapeWidth() const +// { +// return m_rdb->brlSki()->getDouble("POWERTAPEWIDTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::powerTapeMaterial() const +// { +// return m_rdb->brlSki()->getString("POWERTAPEMATERIAL"); +// } + +// double +// SCT_BarrelParameters::powerTapeStartPointOffset() const +// { +// return m_rdb->brlSki()->getDouble("POWERTAPESTARTOFFSET") * Gaudi::Units::mm; +// } + +// // +// // Barrel Harness +// // +// double +// SCT_BarrelParameters::harnessThickness() const +// { +// return m_rdb->brlSki()->getDouble("HARNESSTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::harnessWidth() const +// { +// return m_rdb->brlSki()->getDouble("HARNESSWIDTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::harnessMaterial() const +// { +// return m_rdb->brlSki()->getString("HARNESSMATERIAL"); +// } + +// // +// // Barrel SupportCyl +// // +// double +// SCT_BarrelParameters::supportCylInnerRadius(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("SUPPORTCYLINNERRAD") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::supportCylOuterRadius(int iLayer) const +// { +// return supportCylInnerRadius(iLayer) + supportCylDeltaR(iLayer); +// } + +// double +// SCT_BarrelParameters::supportCylDeltaR(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("SUPPORTCYLDELTAR") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::supportCylMaterial(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getString("SUPPORTCYLMATERIAL"); +// } + + +// // +// // Barrel Flange +// // +// double +// SCT_BarrelParameters::flangeDeltaZ(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("FLANGEDELTAZ") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::flangeDeltaR(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("FLANGEDELTAR") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::flangeMaterial(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getString("FLANGEMATERIAL"); +// } + +// // +// // Barrel Clamp +// // +// double +// SCT_BarrelParameters::clampDeltaZ(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("CLAMPDELTAZ") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::clampDeltaR(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("CLAMPDELTAR") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::clampMaterial(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getString("CLAMPMATERIAL"); +// } + +// // +// // Barrel Cooling Inlet/outlets +// // +// double +// SCT_BarrelParameters::coolingEndDeltaR(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("COOLINGENDDELTAR") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::coolingEndMaterial(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getString("COOLINGENDMATERIAL"); +// } + +// // +// // Barrel CloseOut +// // +// double +// SCT_BarrelParameters::closeOutDeltaZ(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getDouble("CLOSEOUTDELTAZ") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::closeOutMaterial(int iLayer) const +// { +// return m_rdb->brlServPerLayer(iLayer)->getString("CLOSEOUTMATERIAL"); +// } + +// // +// // Barrel InterLink and B6 bearing +// // +// double +// SCT_BarrelParameters::interLinkDeltaZ() const +// { +// return m_rdb->brlServices()->getDouble("INTERLINKDELTAZ") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::interLinkInnerRadius() const +// { +// return m_rdb->brlServices()->getDouble("INTERLINKINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::interLinkOuterRadius() const +// { +// return m_rdb->brlServices()->getDouble("INTERLINKOUTERRADIUS") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::interLinkMaterial() const +// { +// return m_rdb->brlServices()->getString("INTERLINKMATERIAL"); +// } + +// double +// SCT_BarrelParameters::interLinkDeltaPhi() const +// { +// if (m_rdb->brlServices()->isFieldNull("INTERLINKDPHI")) { +// return 360.*Gaudi::Units::deg; +// } +// return m_rdb->brlServices()->getDouble("INTERLINKDPHI") * Gaudi::Units::deg; +// } + +// double +// SCT_BarrelParameters::interLinkPhiPos() const +// { +// if (m_rdb->brlServices()->isFieldNull("INTERLINKPHIPOS")) { +// return 0.; +// } +// return m_rdb->brlServices()->getDouble("INTERLINKPHIPOS") * Gaudi::Units::deg; +// } + +// int +// SCT_BarrelParameters::interLinkNRepeat() const +// { +// if (m_rdb->brlServices()->isFieldNull("INTERLINKNREPEAT")) { +// return 1; +// } +// return m_rdb->brlServices()->getInt("INTERLINKNREPEAT"); +// } + +// double +// SCT_BarrelParameters::bearingDeltaPhi() const +// { +// if (m_rdb->brlServices()->isFieldNull("BEARINGDPHI")) { +// return 0.; +// } +// return m_rdb->brlServices()->getDouble("BEARINGDPHI") * Gaudi::Units::deg; +// } + +// double +// SCT_BarrelParameters::bearingPhiPos() const +// { +// if (m_rdb->brlServices()->isFieldNull("BEARINGPHIPOS")) { +// return 0.; +// } +// return m_rdb->brlServices()->getDouble("BEARINGPHIPOS") * Gaudi::Units::deg; +// } + +// int +// SCT_BarrelParameters::bearingNRepeat() const +// { +// if (m_rdb->brlServices()->isFieldNull("BEARINGNREPEAT")) { +// return 0; +// } +// return m_rdb->brlServices()->getInt("BEARINGNREPEAT"); +// } + +// std::string +// SCT_BarrelParameters::bearingMaterial() const +// { +// if (m_rdb->brlServices()->isFieldNull("BEARINGMATERIAL")) { +// return " "; +// } +// return m_rdb->brlServices()->getString("BEARINGMATERIAL"); +// } + +// // +// // Barrel FSI and FSI flange +// // +// bool +// SCT_BarrelParameters::includeFSI() const +// { +// if (m_rdb->brlFSISize() > 0) {return true;} +// return false; +// } + +// double +// SCT_BarrelParameters::fsiFlangeInnerRadius() const +// { +// return m_rdb->brlFSI()->getDouble("FLANGEINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiFlangeOuterRadius() const +// { +// return m_rdb->brlFSI()->getDouble("FLANGEOUTERRADIUS") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::fsiFlangeMaterial() const +// { +// return m_rdb->brlFSI()->getString("FLANGEMATERIAL"); +// } + +// double +// SCT_BarrelParameters::fsiFibreMaskDeltaR() const +// { +// return m_rdb->brlFSI()->getDouble("FIBREMASKDELTAR") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::fsiFibreMaskMaterial() const +// { +// return m_rdb->brlFSI()->getString("FIBREMASKMATERIAL"); +// } + +// double +// SCT_BarrelParameters::fsiEndJewelRadialWidth() const +// { +// return m_rdb->brlFSI()->getDouble("ENDJEWELRADIALWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiEndJewelRPhiWidth() const +// { +// return m_rdb->brlFSI()->getDouble("ENDJEWELRPHIWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiEndJewelLength() const +// { +// return m_rdb->brlFSI()->getDouble("ENDJEWELLENGTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::fsiEndJewelMaterial() const +// { +// return m_rdb->brlFSI()->getString("ENDJEWELMATERIAL"); +// } + +// int +// SCT_BarrelParameters::fsiEndJewelNRepeat(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getInt("ENDJEWELNREPEAT"); +// } + +// double +// SCT_BarrelParameters::fsiEndJewelPhi(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getDouble("ENDJEWELPHI") * Gaudi::Units::degree; +// } + +// double +// SCT_BarrelParameters::fsiEndJewelZ(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getDouble("ENDJEWELZ") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiScorpionRadialWidth() const +// { +// return m_rdb->brlFSI()->getDouble("SCORPIONRADIALWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiScorpionRPhiWidth() const +// { +// return m_rdb->brlFSI()->getDouble("SCORPIONRPHIWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::fsiScorpionLength() const +// { +// return m_rdb->brlFSI()->getDouble("SCORPIONLENGTH") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::fsiScorpionMaterial() const +// { +// return m_rdb->brlFSI()->getString("SCORPIONMATERIAL"); +// } + +// int +// SCT_BarrelParameters::fsiScorpionNRepeat(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getInt("SCORPIONNREPEAT"); +// } + +// double +// SCT_BarrelParameters::fsiScorpionPhi(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getDouble("SCORPIONPHI") * Gaudi::Units::degree; +// } + +// double +// SCT_BarrelParameters::fsiScorpionZ(int iLayer) const +// { +// return m_rdb->brlFSILocation(iLayer)->getDouble("SCORPIONZ") * Gaudi::Units::mm; +// } + + +// // +// // Barrel Cooling Spider +// // +// double +// SCT_BarrelParameters::spiderDeltaZ() const +// { +// return m_rdb->brlServices()->getDouble("SPIDERDELTAZ") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::spiderInnerRadius() const +// { +// return m_rdb->brlServices()->getDouble("SPIDERINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::spiderOuterRadius() const +// { +// return m_rdb->brlServices()->getDouble("SPIDEROUTERRADIUS") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::spiderMaterial() const +// { +// return m_rdb->brlServices()->getString("SPIDERMATERIAL"); +// } + +// // +// // Barrel Thermal Shield +// // +// double +// SCT_BarrelParameters::thermalShieldInnerRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("INNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldOuterRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("OUTERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldEndZMax() const +// { +// return m_rdb->brlThermalShield()->getDouble("ENDZMAX") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldCylTotalThickness() const +// { +// return m_rdb->brlThermalShield()->getDouble("CYLTOTALTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldCylInnerWallThickness() const +// { +// return m_rdb->brlThermalShield()->getDouble("CYLINNERWALLTHICK") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldCylOuterWallThickness() const +// { +// return m_rdb->brlThermalShield()->getDouble("CYLOUTERWALLTHICK") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldSpacerZWidth() const +// { +// return m_rdb->brlThermalShield()->getDouble("SPACERZWIDTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldFirstSpacerZMin() const +// { +// return m_rdb->brlThermalShield()->getDouble("FIRSTSPACERZMIN") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldEndCapCylThickness() const +// { +// return m_rdb->brlThermalShield()->getDouble("ENDCAPCYLTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldEndCapThickness() const +// { +// return m_rdb->brlThermalShield()->getDouble("ENDCAPTHICKNESS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldBulkheadInnerRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("BULKHEADINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldBulkheadOuterRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("BULKHEADOUTERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldEndPanelInnerRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("ENDPANELINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::thermalShieldEndPanelOuterRadius() const +// { +// return m_rdb->brlThermalShield()->getDouble("ENDPANELOUTERRADIUS") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::thermalShieldMaterialSpacer() const +// { +// return m_rdb->brlThermalShield()->getString("MATERIALSPACER"); +// } + +// std::string +// SCT_BarrelParameters::thermalShieldMaterialCyl() const +// { +// return m_rdb->brlThermalShield()->getString("MATERIALCYL"); +// } + +// std::string +// SCT_BarrelParameters::thermalShieldMaterialOuterSect() const +// { +// return m_rdb->brlThermalShield()->getString("MATERIALOUTERSECT"); +// } + +// std::string +// SCT_BarrelParameters::thermalShieldMaterialInnerSect() const +// { +// return m_rdb->brlThermalShield()->getString("MATERIALINNERSECT"); +// } + +// // +// // Barrel EMI Shield +// // +// double +// SCT_BarrelParameters::emiShieldInnerRadius() const +// { +// return m_rdb->brlServices()->getDouble("EMIINNERRADIUS") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::emiShieldDeltaR() const +// { +// return m_rdb->brlServices()->getDouble("EMIDELTAR") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::emiShieldZMax() const +// { +// return m_rdb->brlServices()->getDouble("EMIZMAX") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::emiShieldMaterial() const +// { +// return m_rdb->brlServices()->getString("EMIMATERIAL"); +// } + +// double +// SCT_BarrelParameters::emiJointDeltaR() const +// { +// return m_rdb->brlServices()->getDouble("EMIJOINTDELTAR") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::emiJointRPhi() const +// { +// return m_rdb->brlServices()->getDouble("EMIJOINTRPHI") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::emiJointMaterial() const +// { +// return m_rdb->brlServices()->getString("EMIJOINTMATERIAL"); +// } + + + +// // +// // Attachment of pixel to SCT. +// // +// double +// SCT_BarrelParameters::pixelAttachmentInnerRadius() const +// { +// return m_rdb->brlServices()->getDouble("PIXELATTACHINNERRAD") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::pixelAttachmentOuterRadius() const +// { +// return m_rdb->brlServices()->getDouble("PIXELATTACHOUTERRAD") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::pixelAttachmentZMin() const +// { +// return m_rdb->brlServices()->getDouble("PIXELATTACHZMIN") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::pixelAttachmentDeltaZ() const +// { +// return m_rdb->brlServices()->getDouble("PIXELATTACHDELTAZ") * Gaudi::Units::mm; +// } + +// std::string +// SCT_BarrelParameters::pixelAttachmentMaterial() const +// { +// return m_rdb->brlServices()->getString("PIXELATTACHMATERIAL"); +// } + +// +// Barrel General +// +int +VetoStationParameters::numPlates() const +{ + return m_rdb->stationGeneral()->getInt("NUMPLATES"); +} + +double +VetoStationParameters::stationWidth() const +{ + return m_rdb->stationGeneral()->getDouble("WIDTH") * Gaudi::Units::mm; +} + +double +VetoStationParameters::stationLength() const +{ + return m_rdb->stationGeneral()->getDouble("LENGTH") * Gaudi::Units::mm; +} + +double +VetoStationParameters::stationThickness() const +{ + return m_rdb->stationGeneral()->getDouble("THICKNESS") * Gaudi::Units::mm; +} + +// double +// SCT_BarrelParameters::cylinderLength() const +// { +// return m_rdb->brlGeneral()->getDouble("CYLINDERLENGTH") * Gaudi::Units::mm; +// } + +// double +// SCT_BarrelParameters::activeLength() const +// { +// return m_rdb->brlGeneral()->getDouble("ACTIVELENGTH") * Gaudi::Units::mm; +// } + +// bool +// SCT_BarrelParameters::isOldGeometry() const +// { +// if (m_rdb->brlGeneral()->isFieldNull("CYLINDERLENGTH")) {return true;} +// return false; +// } + -- GitLab