Commit 08068972 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'MuonStationBuilderCond_unneeded_const' into 'master'

MuonStationTypeBuilder . Move state to external cache to be passed by the caller

See merge request !44465
parents ab5daf7a 82b25901
......@@ -44,13 +44,21 @@ namespace Muon {
virtual ~MuonStationBuilderCond() = default;
StatusCode initialize();
//FIXME: THIS IS USING const_cast TO ACCESS buildDetachedTrackingVolumeTypes(...)
std::pair<EventIDRange, std::unique_ptr<const std::vector<std::unique_ptr<const Trk::DetachedTrackingVolume> > > > buildDetachedTrackingVolumes ATLAS_NOT_THREAD_SAFE (const EventContext& ctx, bool blend=false) const;
// FIXME: THIS IS USING const_cast TO ACCESS
// buildDetachedTrackingVolumeTypes(...)
std::pair<EventIDRange,
std::unique_ptr<const std::vector<
std::unique_ptr<const Trk::DetachedTrackingVolume>>>>
buildDetachedTrackingVolumes(const EventContext& ctx,
bool blend = false) const;
private:
ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
const std::vector<const Trk::DetachedTrackingVolume*>* buildDetachedTrackingVolumeTypes(bool blend, const MuonGM::MuonDetectorManager* muonMgr);
const std::vector<const Trk::DetachedTrackingVolume*>*
buildDetachedTrackingVolumeTypes(
bool blend,
const MuonGM::MuonDetectorManager* muonMgr) const;
void glueComponents(const Trk::DetachedTrackingVolume* ) const;
void encloseLayers( const Trk::DetachedTrackingVolume* ) const;
......
......@@ -9,115 +9,155 @@
#ifndef MUONTRACKINGGEOMETRY_MUONSTATIONTYPEBUILDER_H
#define MUONTRACKINGGEOMETRY_MUONSTATIONTYPEBUILDER_H
//Trk
#include "TrkGeometry/TrackingVolume.h"
#include "TrkGeometry/Material.h"
#include "TrkDetDescrUtils/SharedObject.h"
// Trk
#include "TrkDetDescrGeoModelCnv/GeoMaterialConverter.h"
#include "TrkDetDescrInterfaces/ITrackingVolumeArrayCreator.h"
#include "TrkDetDescrUtils/SharedObject.h"
#include "TrkGeometry/Material.h"
#include "TrkGeometry/MaterialProperties.h"
#include "TrkGeometry/TrackingVolume.h"
// Gaudi
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "GeoModelKernel/GeoVPhysVol.h"
#include "GeoModelKernel/GeoMaterial.h"
#include "GeoModelKernel/GeoVPhysVol.h"
namespace Trk {
class Volume;
class Layer;
class CuboidVolumeBounds;
class TrapezoidVolumeBounds;
class DoubleTrapezoidVolumeBounds;
class PlaneLayer;
class Volume;
class Layer;
class CuboidVolumeBounds;
class TrapezoidVolumeBounds;
class DoubleTrapezoidVolumeBounds;
class PlaneLayer;
}
namespace MuonGM {
class MuonDetectorManager;
class MuonStation;
class MuonDetectorManager;
class MuonStation;
}
namespace Muon {
typedef std::pair<Trk::SharedObject<const Trk::Layer>,const Amg::Transform3D*> LayTr;
/** @class MuonStationTypeBuilder
typedef std::pair<Trk::SharedObject<const Trk::Layer>, const Amg::Transform3D*> LayTr;
/** @class MuonStationTypeBuilder
The Muon::MuonStationTypeBuilder retrieves components of muon stations from
Muon Geometry Tree, builds 'prototype' object (TrackingVolume with NameType)
by Sarka.Todorova@cern.ch
*/
class MuonStationTypeBuilder : public AthAlgTool
{
public:
struct Cache
{
std::unique_ptr<Trk::MaterialProperties> m_mdtTubeMat{};
std::unique_ptr<Trk::MaterialProperties> m_rpcLayer{};
std::vector<std::unique_ptr<Trk::MaterialProperties>> m_mdtFoamMat{};
std::unique_ptr<Trk::MaterialProperties> m_rpc46{};
std::vector<std::unique_ptr<Trk::MaterialProperties>> m_rpcDed{};
std::unique_ptr<Trk::MaterialProperties> m_rpcExtPanel{};
std::unique_ptr<Trk::MaterialProperties> m_rpcMidPanel{};
std::unique_ptr<Trk::MaterialProperties> m_matCSC01{};
std::unique_ptr<Trk::MaterialProperties> m_matCSCspacer1{};
std::unique_ptr<Trk::MaterialProperties> m_matCSC02{};
std::unique_ptr<Trk::MaterialProperties> m_matCSCspacer2{};
std::unique_ptr<Trk::MaterialProperties> m_matTGC01{};
std::unique_ptr<Trk::MaterialProperties> m_matTGC06{};
};
/** Constructor */
MuonStationTypeBuilder(const std::string&, const std::string&, const IInterface*);
/** Destructor */
virtual ~MuonStationTypeBuilder() = default;
/** AlgTool initailize method.*/
StatusCode initialize();
/** AlgTool finalize method */
StatusCode finalize();
/** Interface methode */
static const InterfaceID& interfaceID();
/** steering routine */
const Trk::TrackingVolumeArray* processBoxStationComponents(const GeoVPhysVol* cv,
Trk::CuboidVolumeBounds* envBounds,
Cache&) const;
const Trk::TrackingVolumeArray* processTrdStationComponents(const GeoVPhysVol* cv,
Trk::TrapezoidVolumeBounds* envBounds,
Cache&) const;
Trk::TrackingVolume* processCscStation(const GeoVPhysVol* cv, std::string name, Cache&) const;
std::vector<const Trk::TrackingVolume*> processTgcStation(const GeoVPhysVol* cv,Cache&) const;
The Muon::MuonStationTypeBuilder retrieves components of muon stations from Muon Geometry Tree,
builds 'prototype' object (TrackingVolume with NameType)
by Sarka.Todorova@cern.ch
*/
class MuonStationTypeBuilder : public AthAlgTool{
public:
/** Constructor */
MuonStationTypeBuilder(const std::string&,const std::string&,const IInterface*);
/** Destructor */
virtual ~MuonStationTypeBuilder() = default;
/** AlgTool initailize method.*/
StatusCode initialize();
/** AlgTool finalize method */
StatusCode finalize();
/** Interface methode */
static const InterfaceID& interfaceID();
/** steering routine */
const Trk::TrackingVolumeArray* processBoxStationComponents(const GeoVPhysVol* cv, Trk::CuboidVolumeBounds* envBounds);
const Trk::TrackingVolumeArray* processTrdStationComponents(const GeoVPhysVol* cv, Trk::TrapezoidVolumeBounds* envBounds);
Trk::TrackingVolume* processCscStation(const GeoVPhysVol* cv, std::string name);
std::vector<const Trk::TrackingVolume*> processTgcStation(const GeoVPhysVol* cv);
/** components */
const Trk::TrackingVolume* processMdtBox(Trk::Volume*&,const GeoVPhysVol*&, Amg::Transform3D*, double );
const Trk::TrackingVolume* processMdtTrd(Trk::Volume*&,const GeoVPhysVol*&, Amg::Transform3D*);
const Trk::TrackingVolume* processRpc(Trk::Volume*&,std::vector<const GeoVPhysVol*>,std::vector<Amg::Transform3D>);
const Trk::TrackingVolume* processSpacer(Trk::Volume&,std::vector<const GeoVPhysVol*>,std::vector<Amg::Transform3D>) const;
const Trk::TrackingVolume* processNSW(std::vector<const Trk::Layer*>) const;
const Trk::LayerArray* processCSCTrdComponent(const GeoVPhysVol*&, Trk::TrapezoidVolumeBounds*&, Amg::Transform3D*&);
const Trk::LayerArray* processCSCDiamondComponent(const GeoVPhysVol*&, Trk::DoubleTrapezoidVolumeBounds*&, Amg::Transform3D*&);
const Trk::LayerArray* processTGCComponent(const GeoVPhysVol*&, Trk::TrapezoidVolumeBounds*&, Amg::Transform3D*&);
std::pair<const Trk::Layer*,const std::vector<const Trk::Layer*>* > createLayerRepresentation(const Trk::TrackingVolume* trVol) const;
const Trk::Layer* createLayer(const Trk::TrackingVolume* trVol,Trk::MaterialProperties*, Amg::Transform3D&) const;
Identifier identifyNSW( std::string, Amg::Transform3D ) const;
void printChildren(const GeoVPhysVol*) const ;
// used to be private ..
double get_x_size(const GeoVPhysVol*) const ;
double decodeX(const GeoShape*) const ;
double getVolume(const GeoShape*) const;
Trk::MaterialProperties getAveragedLayerMaterial(const GeoVPhysVol*,double,double) const;
void collectMaterial(const GeoVPhysVol*,Trk::MaterialProperties&,double) const;
Trk::MaterialProperties collectStationMaterial(const Trk::TrackingVolume* trVol,double) const;
private:
/** Private method to fill default material */
//void fillDefaultServiceMaterial();
const MuonGM::MuonDetectorManager* m_muonMgr; //!< the MuonDetectorManager
Gaudi::Property<std::string> m_muonMgrLocation{this,"MuonDetManagerLocation","MuonMgr"};//!< the location of the Muon Manager
Gaudi::Property<bool> m_multilayerRepresentation{this,"BuildMultilayerRepresentation",true};
Gaudi::Property<bool> m_resolveSpacer{this,"ResolveSpacerBeams",false};
ToolHandle<Trk::ITrackingVolumeArrayCreator> m_trackingVolumeArrayCreator{this,"TrackingVolumeArrayCreator","Trk::TrackingVolumeArrayCreator/TrackingVolumeArrayCreator"}; //!< Helper Tool to create TrackingVolume Arrays
std::unique_ptr<Trk::Material> m_muonMaterial; //!< the material
std::unique_ptr<Trk::GeoMaterialConverter> m_materialConverter;
std::unique_ptr<Trk::MaterialProperties> m_mdtTubeMat;
std::vector<std::unique_ptr<Trk::MaterialProperties> > m_mdtFoamMat;
std::unique_ptr<Trk::MaterialProperties> m_rpc46;
std::vector<std::unique_ptr<Trk::MaterialProperties> > m_rpcDed;
std::unique_ptr<Trk::MaterialProperties> m_rpcLayer;
std::unique_ptr<Trk::MaterialProperties> m_rpcExtPanel;
std::unique_ptr<Trk::MaterialProperties> m_rpcMidPanel;
std::unique_ptr<Trk::MaterialProperties> m_matCSC01;
std::unique_ptr<Trk::MaterialProperties> m_matCSCspacer1;
std::unique_ptr<Trk::MaterialProperties> m_matCSC02;
std::unique_ptr<Trk::MaterialProperties> m_matCSCspacer2;
std::unique_ptr<Trk::MaterialProperties> m_matTGC01;
std::unique_ptr<Trk::MaterialProperties> m_matTGC06;
};
/** components */
const Trk::TrackingVolume* processMdtBox(Trk::Volume*&, const GeoVPhysVol*&, Amg::Transform3D*, double, Cache&) const;
const Trk::TrackingVolume* processMdtTrd(Trk::Volume*&, const GeoVPhysVol*&, Amg::Transform3D*, Cache&) const;
const Trk::TrackingVolume* processRpc(Trk::Volume*&,
std::vector<const GeoVPhysVol*>,
std::vector<Amg::Transform3D>,
Cache&) const;
const Trk::TrackingVolume* processSpacer(Trk::Volume&,
std::vector<const GeoVPhysVol*>,
std::vector<Amg::Transform3D>) const;
const Trk::TrackingVolume* processNSW(std::vector<const Trk::Layer*>) const;
const Trk::LayerArray* processCSCTrdComponent(const GeoVPhysVol*&,
Trk::TrapezoidVolumeBounds*&,
Amg::Transform3D*&,
Cache&) const;
const Trk::LayerArray* processCSCDiamondComponent(const GeoVPhysVol*&,
Trk::DoubleTrapezoidVolumeBounds*&,
Amg::Transform3D*&,
Cache&) const;
const Trk::LayerArray* processTGCComponent(const GeoVPhysVol*&,
Trk::TrapezoidVolumeBounds*&,
Amg::Transform3D*&,
Cache&) const;
std::pair<const Trk::Layer*, const std::vector<const Trk::Layer*>*> createLayerRepresentation(
const Trk::TrackingVolume* trVol) const;
const Trk::Layer* createLayer(const Trk::TrackingVolume* trVol, Trk::MaterialProperties*, Amg::Transform3D&) const;
Identifier identifyNSW(std::string, Amg::Transform3D) const;
void printChildren(const GeoVPhysVol*) const;
// used to be private ..
double get_x_size(const GeoVPhysVol*) const;
double decodeX(const GeoShape*) const;
double getVolume(const GeoShape*) const;
Trk::MaterialProperties getAveragedLayerMaterial(const GeoVPhysVol*, double, double) const;
void collectMaterial(const GeoVPhysVol*, Trk::MaterialProperties&, double) const;
Trk::MaterialProperties collectStationMaterial(const Trk::TrackingVolume* trVol, double) const;
private:
/** Private method to fill default material */
// void fillDefaultServiceMaterial();
const MuonGM::MuonDetectorManager* m_muonMgr; //!< the MuonDetectorManager
Gaudi::Property<std::string> m_muonMgrLocation{ this,
"MuonDetManagerLocation",
"MuonMgr" }; //!< the location of the Muon Manager
Gaudi::Property<bool> m_multilayerRepresentation{ this, "BuildMultilayerRepresentation", true };
Gaudi::Property<bool> m_resolveSpacer{ this, "ResolveSpacerBeams", false };
ToolHandle<Trk::ITrackingVolumeArrayCreator> m_trackingVolumeArrayCreator{
this,
"TrackingVolumeArrayCreator",
"Trk::TrackingVolumeArrayCreator/TrackingVolumeArrayCreator"
}; //!< Helper Tool to create TrackingVolume Arrays
std::unique_ptr<Trk::Material> m_muonMaterial; //!< the material
std::unique_ptr<Trk::GeoMaterialConverter> m_materialConverter;
};
} // end of namespace
#endif //MUONTRACKINGGEOMETRY_MUONSTATIONTYPEBUILDER_H
#endif // MUONTRACKINGGEOMETRY_MUONSTATIONTYPEBUILDER_H
......@@ -631,7 +631,8 @@ const std::vector<const Trk::DetachedTrackingVolume*>* Muon::MuonStationBuilder:
ATH_MSG_INFO( name() <<" building station types" );
///////////////////////////////////////////////////////////////////////////////////////////////////
std::vector<const Trk::DetachedTrackingVolume*> stations;
MuonStationTypeBuilder::Cache cache{};
std::vector<const Trk::DetachedTrackingVolume*> stations;
if (m_muonMgr){
......@@ -700,7 +701,7 @@ const std::vector<const Trk::DetachedTrackingVolume*>* Muon::MuonStationBuilder:
if (name.substr(0,2)=="CS" || name.substr(0,1)=="T") {
if (m_muonStationTypeBuilder) {
if (name.substr(0,2)=="CS") {
Trk::TrackingVolume* csc_station = m_muonStationTypeBuilder->processCscStation(cv, name);
Trk::TrackingVolume* csc_station = m_muonStationTypeBuilder->processCscStation(cv, name,cache);
// create layer representation
std::pair<const Trk::Layer*,const std::vector<const Trk::Layer*>*> layerRepr =
m_muonStationTypeBuilder->createLayerRepresentation(csc_station);
......@@ -708,7 +709,7 @@ const std::vector<const Trk::DetachedTrackingVolume*>* Muon::MuonStationBuilder:
Trk::DetachedTrackingVolume* typeStat = new Trk::DetachedTrackingVolume(name,csc_station,layerRepr.first,layerRepr.second);
stations.push_back(typeStat);
} else {
std::vector<const Trk::TrackingVolume*> tgc_stations = m_muonStationTypeBuilder->processTgcStation(cv);
std::vector<const Trk::TrackingVolume*> tgc_stations = m_muonStationTypeBuilder->processTgcStation(cv,cache);
for (unsigned int i=0;i<tgc_stations.size();i++) {
// create layer representation
std::pair<const Trk::Layer*,const std::vector<const Trk::Layer*>*> layerRepr =
......@@ -761,7 +762,7 @@ const std::vector<const Trk::DetachedTrackingVolume*>* Muon::MuonStationBuilder:
Trk::CuboidVolumeBounds* envBounds = new Trk::CuboidVolumeBounds(halfX1,halfY1,halfZ);
// station components
if (m_muonStationTypeBuilder) confinedVolumes =
m_muonStationTypeBuilder->processBoxStationComponents(cv,envBounds);
m_muonStationTypeBuilder->processBoxStationComponents(cv,envBounds,cache);
// enveloping volume
envelope= new Trk::Volume(0,envBounds);
} else if (shape=="Trd") {
......@@ -782,7 +783,7 @@ const std::vector<const Trk::DetachedTrackingVolume*>* Muon::MuonStationBuilder:
if (envBounds) {
// station components
if (m_muonStationTypeBuilder) confinedVolumes =
m_muonStationTypeBuilder->processTrdStationComponents(cv,envBounds);
m_muonStationTypeBuilder->processTrdStationComponents(cv,envBounds,cache);
// enveloping volume
envelope= new Trk::Volume(transf,envBounds);
}
......
......@@ -124,7 +124,7 @@ std::pair<EventIDRange,
const MuonGM::MuonDetectorManager* muonMgr = readHandle.cptr();
if (muonMgr) {
// retrieve muon station prototypes from GeoMode(this)->l
const std::vector<const Trk::DetachedTrackingVolume*>* msTypes = const_cast<MuonStationBuilderCond*>(this)->buildDetachedTrackingVolumeTypes(blend, muonMgr);
const std::vector<const Trk::DetachedTrackingVolume*>* msTypes =this->buildDetachedTrackingVolumeTypes(blend, muonMgr);
std::vector<const Trk::DetachedTrackingVolume*>::const_iterator msTypeIter = msTypes->begin();
......@@ -643,11 +643,15 @@ std::pair<EventIDRange,
return std::make_pair(range, std::move(mStations));
}
const std::vector<const Trk::DetachedTrackingVolume*>* Muon::MuonStationBuilderCond::buildDetachedTrackingVolumeTypes(bool /*blend*/,const MuonGM::MuonDetectorManager* muonMgr)
const std::vector<const Trk::DetachedTrackingVolume*>*
Muon::MuonStationBuilderCond::buildDetachedTrackingVolumeTypes(
bool /*blend*/,
const MuonGM::MuonDetectorManager* muonMgr) const
{
ATH_MSG_INFO( name() <<" building station types" );
///////////////////////////////////////////////////////////////////////////////////////////////////
MuonStationTypeBuilder::Cache cache{};
std::vector<const Trk::DetachedTrackingVolume*> stations;
if (muonMgr){
......@@ -717,7 +721,7 @@ const std::vector<const Trk::DetachedTrackingVolume*>* Muon::MuonStationBuilderC
if (name.substr(0,2)=="CS" || name.substr(0,1)=="T") {
if (m_muonStationTypeBuilder) {
if (name.substr(0,2)=="CS") {
Trk::TrackingVolume* csc_station = m_muonStationTypeBuilder->processCscStation(cv, name);
Trk::TrackingVolume* csc_station = m_muonStationTypeBuilder->processCscStation(cv, name,cache);
// create layer representation
std::pair<const Trk::Layer*,const std::vector<const Trk::Layer*>*> layerRepr =
m_muonStationTypeBuilder->createLayerRepresentation(csc_station);
......@@ -725,7 +729,7 @@ const std::vector<const Trk::DetachedTrackingVolume*>* Muon::MuonStationBuilderC
Trk::DetachedTrackingVolume* typeStat = new Trk::DetachedTrackingVolume(name,csc_station,layerRepr.first,layerRepr.second);
stations.push_back(typeStat);
} else {
std::vector<const Trk::TrackingVolume*> tgc_stations = m_muonStationTypeBuilder->processTgcStation(cv);
std::vector<const Trk::TrackingVolume*> tgc_stations = m_muonStationTypeBuilder->processTgcStation(cv,cache);
for (unsigned int i=0;i<tgc_stations.size();i++) {
// create layer representation
std::pair<const Trk::Layer*,const std::vector<const Trk::Layer*>*> layerRepr =
......@@ -778,7 +782,7 @@ const std::vector<const Trk::DetachedTrackingVolume*>* Muon::MuonStationBuilderC
Trk::CuboidVolumeBounds* envBounds = new Trk::CuboidVolumeBounds(halfX1,halfY1,halfZ);
// station components
if (m_muonStationTypeBuilder) confinedVolumes =
m_muonStationTypeBuilder->processBoxStationComponents(cv,envBounds);
m_muonStationTypeBuilder->processBoxStationComponents(cv,envBounds,cache);
// enveloping volume
envelope= new Trk::Volume(0,envBounds);
} else if (shape=="Trd") {
......@@ -799,7 +803,7 @@ const std::vector<const Trk::DetachedTrackingVolume*>* Muon::MuonStationBuilderC
if (envBounds) {
// station components
if (m_muonStationTypeBuilder) confinedVolumes =
m_muonStationTypeBuilder->processTrdStationComponents(cv,envBounds);
m_muonStationTypeBuilder->processTrdStationComponents(cv,envBounds,cache);
// enveloping volume
envelope= new Trk::Volume(transf,envBounds);
}
......@@ -839,7 +843,7 @@ const std::vector<const Trk::DetachedTrackingVolume*>* Muon::MuonStationBuilderC
///////////////////////////////////////////////////////////////////////////////////////
const std::vector<const Trk::DetachedTrackingVolume*>* mStations = new std::vector<const Trk::DetachedTrackingVolume*>(stations);
return mStations;
return mStations;
}
void Muon::MuonStationBuilderCond::glueComponents(const Trk::DetachedTrackingVolume* stat) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment