10#include "GaudiKernel/MsgStream.h"
18#include "GeoModelKernel/throwExcept.h"
36 log << MSG::WARNING <<
"MdtIntersectGeometry::intersection() - MdtIntersectGeometry not correctly initialized "
44 double dxdy = std::abs(ldir.y()) > 0.001 ? ldir.x() / ldir.y() : 1000.;
46 double lineAngle = std::atan2(ldir.z(), ldir.y());
58 for (; dit != dit_end; ++dit) {
61 double xint = dxdy * (dit->position().
x() - lpos.y()) + lpos.x();
66 double distWall = std::abs(xint) - 0.5 *
tubeLength(detElMl0, detElMl1,
68 intersects.emplace_back(tubeid, dit->dr(), distWall);
70 intersect.setTubeIntersects(std::move(intersects));
77 const int ml,
const int layer,
const int tube)
const {
79 if (ml < 0 || ml > 1){
80 THROW_EXCEPTION(__func__<<
"() got called with ml="<<ml<<
" which is definetly out of range");
82 if (layer < 0 || layer > 3) {
83 THROW_EXCEPTION(__func__<<
"() got called with layer="<<layer<<
" which is definetly out of range");
86 THROW_EXCEPTION(__func__<<
"() got called with tube="<<tube<<
" which is definetly out of range");
90 int theTube = tube + 1;
91 int theLayer = layer + 1;
125 msg << MSG::WARNING <<
"MdtIntersectGeometry::init() - failed to get readout element for ML0" <<
endmsg;
142 bool goodMl0{
false}, goodMl1{
false};
144 goodMl0 =
m_dbData->isGoodMultilayer(firstIdml0);
145 goodMl1 = detElMl1 ?
m_dbData->isGoodMultilayer(firstIdml1) :
false;
150 int firstMlIndex = 1;
151 if (goodMl0 && !goodMl1) {
154 }
else if (!goodMl0 && goodMl1) {
159 firstIdml0 = firstIdml1;
161 }
else if (!goodMl0 && !goodMl1) {
162 msg << MSG::WARNING <<
"MdtIntersectGeometry::init() - neither multilayer is good" <<
endmsg;
190 double tubeDist = (secondTubeMl0 - firstTubeMl0).
y();
191 double tubeStage = (firstTubeMl0lay1 - firstTubeMl0).
y();
192 double layDist = (firstTubeMl0lay1 - firstTubeMl0).
z();
194 m_mdtGeometry = std::make_unique<TrkDriftCircleMath::MdtChamberGeometry>(
195 m_chid,
m_idHelperSvc, nml, nlay, ntube0, ntube1, firstTube0, firstTube1, tubeDist, tubeStage, layDist, detElMl0->
center().theta());
198 if (!goodMl0 && goodMl1)
m_mdtGeometry->isSecondMultiLayer(
true);
205 if ((mydetEl->
getStationName()).find(
"BMG") != std::string::npos) {
206 PVConstLink cv = mydetEl->getMaterialGeom();
207 int nGrandchildren = cv->getNChildVols();
208 if (nGrandchildren <= 0)
return;
210 std::vector<int> tubes;
211 geoGetIds([&](
int id) { tubes.push_back(
id); }, &*cv);
216 int name =
m_idHelperSvc->mdtIdHelper().stationName(detElId);
221 std::vector<int>::iterator it = tubes.begin();
222 for (
int layer = 1; layer <= mydetEl->
getNLayers(); layer++) {
225 if (it != tubes.end() && *it == want_id) {
228 it = std::lower_bound(tubes.begin(), tubes.end(), want_id);
229 if (it != tubes.end() && *it == want_id) {
236 if (
msg.level() == MSG::VERBOSE)
237 msg << MSG::VERBOSE <<
" MdtIntersectGeometry: adding dead tube (" << tube <<
"), layer(" << layer
238 <<
"), phi(" <<
phi <<
"), eta(" <<
eta <<
"), name(" << name <<
") and adding multilayerId("
239 << deadTubeMLId <<
")." <<
endmsg;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Visitor to collect all IDs under a GeoModel node.
void geoGetIds(FUNCTION f, const GeoGraphNode *node, int depthLimit=1)
Template helper for running the visitor.
static constexpr int maxNTubesPerLayer
The maxNTubesPerLayer represents the absolute maximum of tubes which are built into a single multilay...
unsigned int nMDTinStation() const
How many MDT chambers are in the station.
double getActiveTubeLength(const int tubeLayer, const int tube) const
Amg::Vector3D tubePos(const Identifier &id) const
Returns the global position of the given tube.
int getNLayers() const
Returns the number of tube layers inside the multilayer.
int getNtubesperlayer() const
Returns the number of tubes in each tube layer.
virtual const Amg::Vector3D & center(const Identifier &) const override final
Return the center of the surface associated with this identifier In the case of silicon it returns th...
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
IdentifierHash detectorElementHash() const
Returns the IdentifierHash of the detector element.
virtual Amg::Transform3D GlobalToAmdbLRSTransform() const
const std::string & getStationName() const
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
std::set< Identifier > m_deadTubesML
double tubeLength(const MuonGM::MdtReadoutElement *detElMl0, const MuonGM::MdtReadoutElement *detElMl1, const int ml, const int layer, const int tube) const
std::shared_ptr< const TrkDriftCircleMath::MdtChamberGeometry > mdtChamberGeometry() const
Amg::Transform3D m_transform
const MdtCondDbData * m_dbData
const Amg::Transform3D & transform() const
std::vector< Identifier > m_deadTubes
const IMuonIdHelperSvc * m_idHelperSvc
virtual ~MdtIntersectGeometry()
void fillDeadTubes(const MuonGM::MdtReadoutElement *mydetEl, MsgStream &msg)
void init(const MuonGM::MuonDetectorManager *detMgr, MsgStream &msg)
std::shared_ptr< TrkDriftCircleMath::MdtChamberGeometry > m_mdtGeometry
MuonStationIntersect intersection(const MuonGM::MuonDetectorManager *detMgr, const Amg::Vector3D &pos, const Amg::Vector3D &dir) const override
MdtIntersectGeometry(MsgStream &msg, const Identifier &chid, const IMuonIdHelperSvc *idHelperSvc, const MuonGM::MuonDetectorManager *detMgr, const MdtCondDbData *dbData)
std::vector< MuonTubeIntersect > TubeIntersects
Implementation of 2 dimensional vector class.
singleton-like access to IMessageSvc via open function and helper
Eigen::Matrix< double, 3, 1 > Vector3D
IMessageSvc * getMessageSvc(bool quiet=false)
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
DCVec::const_iterator DCCit
std::vector< DriftCircle > DCVec
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
#define THROW_EXCEPTION(MESSAGE)