Skip to content
Snippets Groups Projects
Commit 33329cc3 authored by Dave Casper's avatar Dave Casper
Browse files

Merge branch 'master-22.0.29-ecal' into 'master'

Update to Athena 22.0.29 and add Ecal

See merge request faser/calypso!117
parents 635afed1 651cee5d
No related branches found
No related tags found
1 merge request!117Update to Athena 22.0.29 and add Ecal
Pipeline #2462004 passed
Showing
with 2285 additions and 5 deletions
......@@ -25,7 +25,7 @@ build_image:
- mkdir build
- cd build
- set +e && source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh; set -e
- set +e && asetup --input=../../calypso/asetup.faser Athena,22.0.19; set -e
- set +e && asetup --input=../../calypso/asetup.faser Athena,22.0.29; set -e
- cmake ../../calypso
- make -j 3
artifacts:
......@@ -41,7 +41,7 @@ test_unittest:
- yum -y install man
- cd build
- set +e && source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh; set -e
- set +e && asetup --input=../../calypso/asetup.faser Athena,22.0.19; set -e
- set +e && asetup --input=../../calypso/asetup.faser Athena,22.0.29; set -e
- set +e && source `find . -name 'setup.sh'`; set -e
- ctest -j12
dependencies:
......
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/bin/gcc",
"cStandard": "c99",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}
\ No newline at end of file
################################################################################
# Package: CaloGeoModelUtils
################################################################################
# Declare the package name:
atlas_subdir( CaloGeoModelUtils )
# External dependencies:
find_package( Boost COMPONENTS filesystem thread system )
find_package( CLHEP )
find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess )
find_package( GeoModel )
# Component(s) in the package:
atlas_add_library( CaloGeoModelUtils
src/*.cxx
PUBLIC_HEADERS CaloGeoModelUtils
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${GEOMODEL_INCLUDE_DIRS}
DEFINITIONS ${CLHEP_DEFINITIONS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${CLHEP_LIBRARIES} ${GEOMODEL_LIBRARIES} AthenaKernel GaudiKernel RDBAccessSvcLib StoreGateLib SGtests GeoModelFaserUtilities GeoModelInterfaces GeoPrimitives GeometryDBSvcLib
PRIVATE_LINK_LIBRARIES GeoModelFaserUtilities )
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CaloGeoModelUtils_CaloDDAthenaComps_H
#define CaloGeoModelUtils_CaloDDAthenaComps_H
// Message Stream Member
#include "AthenaKernel/MsgStreamMember.h"
class StoreGateSvc;
class IGeoDbTagSvc;
class IRDBAccessSvc;
class IGeometryDBSvc;
#include <string>
namespace CaloDD {
/// Class to hold various Athena components.
class AthenaComps {
public:
AthenaComps(const std::string & msgStreamName);
//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) const { return m_msg.get().level() <= lvl; }
void setDetStore(StoreGateSvc *);
void setGeoDbTagSvc(IGeoDbTagSvc *);
void setRDBAccessSvc(IRDBAccessSvc *);
void setGeometryDBSvc(IGeometryDBSvc *);
StoreGateSvc * detStore() const;
IGeoDbTagSvc * geoDbTagSvc() const;
IRDBAccessSvc * rdbAccessSvc() const;
IGeometryDBSvc * geomDB() const;
private:
//Declaring private message stream member.
mutable Athena::MsgStreamMember m_msg;
StoreGateSvc * m_detStore;
IGeoDbTagSvc * m_geoDbTagSvc;
IRDBAccessSvc * m_rdbAccessSvc;
IGeometryDBSvc * m_geometryDBSvc;
};
inline StoreGateSvc * AthenaComps::detStore() const
{
return m_detStore;
}
inline IGeoDbTagSvc * AthenaComps::geoDbTagSvc() const
{
return m_geoDbTagSvc;
}
inline IRDBAccessSvc * AthenaComps::rdbAccessSvc() const
{
return m_rdbAccessSvc;
}
inline IGeometryDBSvc * AthenaComps::geomDB() const
{
return m_geometryDBSvc;
}
} // endnamespace
#endif // CaloGeoModelUtils_CaloDDAthenaComps_H
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOMATERIALMANAGER_H
#define CALOMATERIALMANAGER_H
// Message Stream Member
#include "AthenaKernel/MsgStreamMember.h"
#include "RDBAccessSvc/IRDBAccessSvc.h"
class GeoMaterial;
class GeoElement;
class AbsMaterialManager;
class StoreGateSvc;
class IGeometryDBSvc;
namespace CaloDD
{
class AthenaComps;
}
#include <string>
#include <map>
/// CaloMaterialManager. 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 CaloMaterialManager
{
public:
CaloMaterialManager(const std::string & managerName, StoreGateSvc* detStore);
CaloMaterialManager(const std::string & managerName, StoreGateSvc* detStore,
IRDBRecordset_ptr weightTable,
const std::string & space = "",
bool extraFunctionality = false);
CaloMaterialManager(const std::string & managerName, StoreGateSvc* detStore,
IRDBRecordset_ptr weightTable,
IRDBRecordset_ptr compositionTable,
const std::string & space = "");
CaloMaterialManager(const std::string & managerName,
const CaloDD::AthenaComps *);
~CaloMaterialManager();
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 CaloDD::AthenaComps * m_athenaComps;
};
#endif // CALOMATERIALMANAGER_H
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CaloGeoModelUtils_DetectorFactoryBase_H
#define CaloGeoModelUtils_DetectorFactoryBase_H
#include "AthenaKernel/MsgStreamMember.h"
#include "GeoModelKernel/GeoVDetectorFactory.h"
#include "CaloGeoModelUtils/CaloDDAthenaComps.h"
class StoreGateSvc;
class IGeoDbTagSvc;
class IRDBAccessSvc;
namespace CaloDD {
class DetectorFactoryBase : public GeoVDetectorFactory
{
public:
DetectorFactoryBase(const CaloDD::AthenaComps * athenaComps)
: m_athenaComps(athenaComps)
{}
StoreGateSvc * detStore() const {return m_athenaComps->detStore();}
IGeoDbTagSvc * geoDbTagSvc() const {return m_athenaComps->geoDbTagSvc();}
IRDBAccessSvc * rdbAccessSvc() const {return m_athenaComps->rdbAccessSvc();}
IGeometryDBSvc * geomDB() const {return m_athenaComps->geomDB();}
//Declaring the Message method for further use
MsgStream& msg (MSG::Level lvl) const { return m_athenaComps->msg(lvl); }
//Declaring the Method providing Verbosity Level
bool msgLvl (MSG::Level lvl) const { return m_athenaComps->msgLvl(lvl); }
const CaloDD::AthenaComps * getAthenaComps() {return m_athenaComps;}
private:
const CaloDD::AthenaComps * m_athenaComps;
};
} // end namespace
#endif // CaloGeoModelUtils_DetectorFactoryBase_H
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CaloGeoModelUtils_DistortedMaterialManager_h
#define CaloGeoModelUtils_DistortedMaterialManager_h
class AbsMaterialManager;
#include "RDBAccessSvc/IRDBAccessSvc.h"
namespace CaloDD {
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 // CaloGeoModelUtils_DistortedMaterialManager_h
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CaloGeoModelUtils_ExtraMaterial
#define CaloGeoModelUtils_ExtraMaterial
#include <cmath>
#include <string>
#include <sstream>
#include "RDBAccessSvc/IRDBAccessSvc.h"
class GeoPhysVol;
class GeoFullPhysVol;
class AbsMaterialManager;
namespace CaloDD {
class DistortedMaterialManager;
class ExtraMaterial
{
public:
ExtraMaterial(IRDBRecordset_ptr xMatTable, const AbsMaterialManager * matManager);
ExtraMaterial(const CaloDD::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 // CaloGeoModelUtils_ExtraMaterial
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CaloGeoModelUtils_GenericTubeMaker_h
#define CaloGeoModelUtils_GenericTubeMaker_h
#include "CaloGeoModelUtils/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 CaloDD {
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 // CaloGeoModelUtils_GenericTubeMaker_h
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CALOGEOMODELUTILS_TOPLEVELPLACEMENTS_H
#define CALOGEOMODELUTILS_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 // CALOGEOMODELUTILS_TOPLEVELPLACEMENTS_H
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CaloGeoModelUtils_TubeVolData_h
#define CaloGeoModelUtils_TubeVolData_h
class IRDBRecord;
#include <string>
namespace CaloDD {
/// 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 // CaloGeoModelUtils_TubeVolData
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#include "CaloGeoModelUtils/CaloDDAthenaComps.h"
namespace CaloDD {
AthenaComps::AthenaComps(const std::string& msgStreamName)
: m_msg(msgStreamName),
m_detStore(0),
m_geoDbTagSvc(0),
m_rdbAccessSvc(0),
m_geometryDBSvc(0)
{}
void
AthenaComps::setDetStore(StoreGateSvc* detStore) {
m_detStore = detStore;
}
void
AthenaComps::setGeoDbTagSvc(IGeoDbTagSvc* geoDbTagSvc) {
m_geoDbTagSvc = geoDbTagSvc;
}
void
AthenaComps::setRDBAccessSvc(IRDBAccessSvc* rdbAccessSvc) {
m_rdbAccessSvc = rdbAccessSvc;
}
void
AthenaComps::setGeometryDBSvc(IGeometryDBSvc* geometryDBSvc) {
m_geometryDBSvc = geometryDBSvc;
}
}
This diff is collapsed.
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#include "CaloGeoModelUtils/DistortedMaterialManager.h"
#include "GeoModelInterfaces/StoredMaterialManager.h"
#include "GeoModelFaserUtilities/DecodeFaserVersionKey.h"
#include "AthenaKernel/MsgStreamMember.h"
#include "StoreGate/StoreGateSvc.h"
#include "RDBAccessSvc/IRDBAccessSvc.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/Bootstrap.h"
namespace CaloDD {
DistortedMaterialManager::DistortedMaterialManager() {
ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap
Athena::MsgStreamMember log("ExtraMaterialManager");
log << MSG::DEBUG << "Initialized Calo 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.
DecodeFaserVersionKey versionKey("Calorimeter");
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("CaloExtraMaterial", detectorKey, detectorNode, "FASERDD");
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
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#include "CaloGeoModelUtils/ExtraMaterial.h"
#include "CaloGeoModelUtils/GenericTubeMaker.h"
#include "CaloGeoModelUtils/TubeVolData.h"
#include "CaloGeoModelUtils/DistortedMaterialManager.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 CaloDD {
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
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#include "CaloGeoModelUtils/GenericTubeMaker.h"
#include "CaloGeoModelUtils/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 CaloDD {
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
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#include "CaloGeoModelUtils/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;
}
GeoTrf::Transform3D rotation(GeoTrf::Translate3D::Identity());
std::vector<int> order { ixyz1 , ixyz2, ixyz3 };
for (int ixyz : order)
{
switch (ixyz)
{
case 0:
if (rotX != 0) rotation = GeoTrf::RotateX3D{rotX} * rotation;
break;
case 1:
if (rotY != 0) rotation = GeoTrf::RotateY3D{rotY} * rotation;
break;
case 2:
if (rotZ != 0) rotation = GeoTrf::RotateZ3D{rotZ} * rotation;
break;
}
}
// This segfaults at runtime when deleting the pointers,
// I think because the base class of Transform3D
// does not have a virtual destructor
//
// List of the three transforms
// GeoTrf::Transform3D* xformList[] = { nullptr, nullptr, nullptr };
// 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] != nullptr) rotation = *(xformList[ixyz1]) * rotation;
// if (xformList[ixyz2] != nullptr) rotation = *(xformList[ixyz2]) * rotation;
// if (xformList[ixyz3] != nullptr) rotation = *(xformList[ixyz3]) * rotation;
// if (xformList[0] != nullptr)
// delete xformList[0];
// if (xformList[1] != nullptr)
// delete xformList[1];
// if (xformList[2] != nullptr)
// 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;
}
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#include "CaloGeoModelUtils/TubeVolData.h"
#include "RDBAccessSvc/IRDBRecord.h"
#include "GaudiKernel/SystemOfUnits.h"
#include <cmath>
#include <string>
#include <iostream>
namespace CaloDD {
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
<IdDictionary name="Calorimeter">
<field name="part" >
<label name="ECAL" value="1" />
<label name="Ecal" value="1" />
</field>
<field name="row">
<label name="Bottom" value="0" />
<label name="Top" value="1" />
</field>
<field name="module">
<!-- facing downstream (hence "starboard" and "port")
x must increase right to left for a right-handed
coordinate system -->
<label name="Starboard" value="0" />
<label name="Port" value="1" />
</field>
<region>
<range field="part" value="ECAL" />
<range field="part" value="Ecal" />
<range field="row" values="Bottom Top" wraparound="FALSE" />
<range field="module" values="Starboard Port" wraparound="FALSE" />
<range field="pmt" minvalue="0" maxvalue="0" />
</region>
</IdDictionary>
\ No newline at end of file
################################################################################
# Package: CaloReadoutGeometry
################################################################################
# Declare the package name:
atlas_subdir( CaloReadoutGeometry )
# External dependencies:
find_package( CLHEP )
find_package( Eigen )
find_package( GeoModel )
# Component(s) in the package:
atlas_add_library( CaloReadoutGeometry
src/*.cxx
PUBLIC_HEADERS CaloReadoutGeometry
INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${GEOMODEL_INCLUDE_DIRS}
DEFINITIONS ${CLHEP_DEFINITIONS}
LINK_LIBRARIES ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} ${GEOMODEL_LIBRARIES} AthenaKernel CxxUtils FaserDetDescr GeoModelFaserUtilities GeoPrimitives Identifier GaudiKernel FaserCaloIdentifier TrkDetElementBase TrkSurfaces TrkEventPrimitives StoreGateLib SGtests AthenaBaseComps DetDescrConditions
PRIVATE_LINK_LIBRARIES AthenaPoolUtilities IdDictDetDescr )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment