23 : base_class(t, n, p) {}
35 return StatusCode::SUCCESS;
46 return StatusCode::SUCCESS;
75 RegionMap& regionMap,
bool hasPhiMeasurements )
const
77 if (hasPhiMeasurements)
78 ATH_MSG_DEBUG(
"pattern has phi measurements using extrapolation to determine second coordinate");
90 if (isect.prepRawDataVec().empty())
continue;
93 const Amg::Vector3D patdire = isect.intersectDirection().unit();
100 std::map<int, EtaPhiHits> etaPhiHitsPerChamber;
101 std::set<Identifier> clusterIds;
109 double phiStart = patdire.phi();
111 constexpr double phiRange = 0.75 *
M_PI;
112 constexpr double phiRange2 = 0.25 *
M_PI;
113 double phiOffset = 0.;
114 if (phiStart > phiRange || phiStart < -phiRange)
115 phiOffset = 2 *
M_PI;
116 else if (phiStart > -phiRange2 && phiStart < phiRange2)
119 if (phiOffset > 1.5 *
M_PI) {
120 if (phiStart < 0) phiStart += phiOffset;
121 if (chPhi < 0) chPhi += phiOffset;
122 }
else if (phiOffset > 0.) {
123 phiStart += phiOffset;
126 double dphi = std::abs(phiStart - chPhi);
129 ATH_MSG_DEBUG(
"Large angular phi difference between pattern and chamber, phi pattern "
135 std::map<Identifier, const MdtPrepData*> idMdtMap{};
143 if (!previousMdt || previousMdt->
tdc() > mdt->
tdc())
148 insertMdt(*mdt, regionMap, patpose, patdire, hasPhiMeasurements);
157 if (!clusterIds.insert(
id).second)
continue;
162 EtaPhiHits& hitsPerChamber = etaPhiHitsPerChamber[colHash];
164 ++hitsPerChamber.
nphi;
166 ++hitsPerChamber.
neta;
168 insertCluster(*clus, regionMap, patpose, patdire, hasPhiMeasurements);
170 for (
const auto& [coll_hash, hits] : etaPhiHitsPerChamber) {
171 if ((hits.neta > 0 && hits.nphi == 0) || (hits.nphi > 0 && hits.neta == 0)) {
180 if (!clusterIds.insert(rpc_prd->identify()).second)
continue;
181 insertCluster(*rpc_prd, regionMap, patpose, patdire, hasPhiMeasurements);
191 if (!clusterIds.insert(tgc_prd->identify()).second)
continue;
192 insertCluster(*tgc_prd, regionMap, patpose, patdire, hasPhiMeasurements);
198 return StatusCode::SUCCESS;
213 if (hasPhiMeasurements) {
221 double denom = patdire.dot(planenormal);
222 double u = (planenormal.dot(planepostion - patpose)) / (denom);
234 bool hasPointingPhiStrips =
false;
246 hasPointingPhiStrips =
true;
256 glpos[0] = ilpos.x();
258 if (hasPointingPhiStrips) {
260 glpos[1] = ilpos.y();
262 glpos[1] = ilpos.y();
267 intersect = gToLocal.inverse() * glpos;
271 ATH_MSG_VERBOSE(
">>>> extrapolated position far outside volume, dropping hit "
272 <<
m_idHelperSvc->toString(
id) <<
". dist along strip " << dif.mag() <<
" 1/2 strip len "
273 << 0.5 * striplen <<
" dist measurement plane " << (intersect - piOnPlane).mag());
276 if (dif.mag() > 0.5 * striplen) {
277 Amg::Vector3D newpos = globalpos - dif * (0.5 * striplen / dif.mag());
279 ATH_MSG_VERBOSE(
">>>> extrapolated position outside volume, shifting position "
280 <<
m_idHelperSvc->toString(
id) <<
". position along strip " << dif.mag() <<
" 1/2 tube len "
281 << 0.5 * striplen <<
" dist To strip " << (intersect - piOnPlane).mag()
282 <<
". dist to newpos " << (newpos - globalpos).mag() <<
" pos " << newpos);
288 intersect = globalpos;
294 Region& region = regionMap[regionId];
315 if (hasPhiMeasurements) {
330 double denom = patdire.dot(planenormal);
331 double u = (planenormal.dot(planepostion - patpose)) / (denom);
334 Amg::Vector3D lpiOnPlane = amdbToGlobal.inverse() * piOnPlane;
337 intersect = amdbToGlobal *
Amg::Vector3D(lpiOnPlane.x(), ltubePos.y(), ltubePos.z());
343 if (dif.mag() > 0.5 * tubelen) {
344 Amg::Vector3D newpos = tubePos - dif * (0.5 * tubelen / dif.mag());
346 ATH_MSG_VERBOSE(
">>>> extrapolated position outside volume, shifting position "
347 <<
m_idHelperSvc->toString(
id) <<
". position along strip " << dif.mag() <<
" 1/2 tube len "
348 << 0.5 * tubelen <<
" dist To Wire " << (piOnPlane - intersect).mag() <<
". dist to newpos "
349 << (newpos - tubePos).mag() <<
" pos " << newpos);
390 Region& region = regionMap[regionId];
405 for (
const auto& [detRegionId, chamberData] : regionMap) {
406 ATH_MSG_INFO(
"new region " << detRegionId <<
" trigger " << chamberData.triggerPrds.size() <<
" mdt ch "
407 << chamberData.mdtPrdsPerChamber.size());
408 if (!chamberData.triggerPrds.empty())
ATH_MSG_INFO(
"trigger hits " << chamberData.triggerPrds.size());
410 for (
const auto& [globalPos, prd] : chamberData.triggerPrds) {
413 for (
const auto& [statId, MdtChamHits]: chamberData.mdtPrdsPerChamber) {
414 ATH_MSG_INFO(
"new MDT chamber with " << MdtChamHits.size() <<
" hits");
415 for (
const auto& [globalPos, prd] : MdtChamHits) {
427 for (
const auto& [regionId, regMeasColl] : regionMap) {
429 ROTRegion rotRegion{};
430 rotRegion.regionId = regionId;
431 rotRegion.regionPos = regMeasColl.regionPos;
432 rotRegion.regionDir = regMeasColl.regionDir;
433 for (
const auto& [globalPos, prd] : regMeasColl.triggerPrds) {
434 std::unique_ptr<const MuonClusterOnTrack> cluster{
m_clusterCreator->createRIO_OnTrack(*prd, globalPos)};
435 if (!cluster)
continue;
436 rotRegion.push_back(std::move(cluster));
438 for (
const auto& [regionId, MdtsWithIsect] :regMeasColl.mdtPrdsPerChamber) {
441 for (
const auto& [globalPos, prd] : MdtsWithIsect) {
443 <<
",tdc: "<<prd->tdc()<<
",adc: "<<prd->adc()<<
" at "<<
Amg::toString(globalPos));
449 mdtROTs.push_back(mdt);
451 if (!mdtROTs.empty()) rotRegion.push_back(std::move(mdtROTs));
453 hitsPerRegion.push_back(std::move(rotRegion));
459 const ContType* & cont_ptr)
const {
463 return StatusCode::SUCCESS;
467 ATH_MSG_FATAL(
"Failed to retrieve "<<key.fullKey()<<
" from store gate");
468 return StatusCode::FAILURE;
470 cont_ptr = readHandle.
cptr();
471 return StatusCode::SUCCESS;
Scalar phi() const
phi method
Scalar mag() const
mag method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
double getActiveTubeLength(const int tubeLayer, const int tube) const
virtual Amg::Transform3D AmdbLRSToGlobalTransform() const
double StripLength(bool measphi) const
returns the strip length for the phi or eta plane
double stripLength() const
Returns the length of each strip which is equal to the height of the chamber.
double gangCentralWidth(int gasGap, int gang) const
Returns the length of the central wire in the gang.
std::vector< ROTRegion > ROTsPerRegion
This class represents the corrected MDT measurements, where the corrections include the effects of wi...
Class to represent measurements from the Monitored Drift Tubes.
virtual const MuonGM::MdtReadoutElement * detectorElement() const override
Returns the detector element corresponding to this PRD.
virtual const Amg::Vector3D & globalPosition() const
Returns the global position of the CENTER of the drift tube (i.e.
int tdc() const
Returns the TDC (typically range is 0 to 2500).
Class representing clusters in the muon system.
virtual IdentifierHash collectionHash() const
Returns the IdentifierHash corresponding to the PRD collection in the PRD container.
virtual const Amg::Vector3D & globalPosition() const =0
Returns the global position of the measurement (calculated on the fly)
Gaudi::Property< double > m_dropDistance
int getRegionId(const Identifier &id) const override
void printRegionMap(const RegionMap ®ionMap) const
StatusCode loadFromStoreGate(const EventContext &ctx, const SG::ReadHandleKey< ContType > &key, const ContType *&cont_ptr) const
load the container from storegate given a ReadHandleKey.
SG::ReadHandleKey< Muon::TgcPrepDataContainer > m_keyTgc
void insertCluster(const MuonCluster &mdt, RegionMap ®ionMap, const Amg::Vector3D &patpose, const Amg::Vector3D &patdire, bool hasPhiMeasurements) const
ToolHandle< IMdtDriftCircleOnTrackCreator > m_mdtCreator
StatusCode createRegionMap(const EventContext &ctx, const MuonPatternCombination &pat, RegionMap ®ionMap, bool hasPhiMeasurements) const
Gaudi::Property< bool > m_doMultiAnalysis
virtual StatusCode initialize() override
bool checkForPhiMeasurements(const MuonPatternCombination &pat) const override
StatusCode calibrate(const EventContext &ctx, const MuonPatternCombination &pat, ROTsPerRegion &hitsPerRegion) const override
PublicToolHandle< MuonEDMPrinterTool > m_printer
SG::ReadHandleKey< Muon::RpcPrepDataContainer > m_keyRpc
Gaudi::Property< double > m_phiAngleCut
std::map< int, Region > RegionMap
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Gaudi::Property< bool > m_removeDoubleMdtHits
MuonPatternCalibration(const std::string &, const std::string &, const IInterface *)
void calibrateRegionMap(const RegionMap ®ionMap, IMuonPatternCalibration::ROTsPerRegion &hitsPerRegion) const
Gaudi::Property< bool > m_recoverTriggerHits
ToolHandle< IMuonClusterOnTrackCreator > m_clusterCreator
void insertMdt(const MdtPrepData &clus, RegionMap ®ionMap, const Amg::Vector3D &patpose, const Amg::Vector3D &patdire, bool hasPhiMeasurements) const
This class holds information needed for the Moore and MoMu pattern recognition for a muon chamber.
The MuonPatternCombination class provides the means to store the output of the initial global pattern...
Class to represent RPC measurements.
virtual const MuonGM::RpcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD.
Class to represent TGC measurements.
virtual const MuonGM::TgcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD The pointer will be zero if the det el is not ...
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
virtual const TrkDetElementBase * detectorElement() const =0
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
Identifier identify() const
return the identifier
Abstract Base Class for tracking surfaces.
virtual const Amg::Vector3D & normal() const
Returns the normal vector of the Surface (i.e.
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
virtual const Amg::Vector3D & center() const =0
Return the center of the element.
virtual const Surface & surface() const =0
Return surface associated with this detector element.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
ChIndex chIndex(const std::string &index)
convert ChIndex name string to enum
bool isSmall(const ChIndex index)
Returns true if the chamber index is in a small sector.
constexpr int toInt(const EnumType enumVal)
ChIndex
enum to classify the different chamber layers in the muon spectrometer
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
MuonPrepDataCollection< TgcPrepData > TgcPrepDataCollection
MuonPrepDataContainerT< RpcPrepData > RpcPrepDataContainer
MuonPrepDataContainerT< TgcPrepData > TgcPrepDataContainer
MuonPrepDataCollection< RpcPrepData > RpcPrepDataCollection
RegionIdMap mdtPrdsPerChamber