83 return StatusCode::SUCCESS;
88 std::vector<std::unique_ptr<const Trk::TrackStateOnSurface>>& states)
const {
106 ATH_MSG_DEBUG(
" MuonChamberHoleRecoveryTool failed to create a new track "
107 <<
" Returning input (unrecovered) track ");
108 return std::make_unique<Trk::Track>(track);
111 <<
m_printer->printStations(*chRecTrack));
146 std::unique_ptr<Trk::Track> triggerRecTrack =
addMissingChambers(ctx, *chRecTrack, muonData,
false);
147 if (triggerRecTrack) chRecTrack.swap(triggerRecTrack);
149 std::unique_ptr<Trk::Track> mdtRecTrack =
addMissingChambers(ctx, *chRecTrack, muonData,
true);
150 if (mdtRecTrack) chRecTrack.swap(mdtRecTrack);
152 std::unique_ptr<Trk::Track> mdtRecTrackWithHoles =
findHoles(ctx, *chRecTrack, muonData);
153 if (mdtRecTrackWithHoles) chRecTrack.swap(mdtRecTrackWithHoles);
164 const std::set<IdentifierHash>& exclusion)
const {
168 std::vector<IdentifierHash> crossed;
178 if (exclusion.count(hash) || hashes.count(hash)) {
239 std::set<MuonStationIndex::StIndex> stations;
240 double etamin{1e9}, etamax{-1e9}, phimin{1e9}, phimax{-1e9};
245 for (; tsit != tsit_end; ++tsit) {
249 double rpos = pars->position().perp();
250 double zpos = std::abs(pars->position().z());
251 if (rpos < 2500 && zpos < 4000)
continue;
252 double eta = pars->position().eta();
253 double phi = pars->position().phi();
254 if (msgLvl(MSG::DEBUG)) {
255 msg() <<
"All State parameters: eta: " <<
eta <<
" ,phi: " <<
phi <<
" pos r " << rpos <<
" z " << zpos;
256 if (pars->covariance())
msg() << MSG::DEBUG <<
" extrapolation error " <<
Amg::error(*pars->covariance(),
Trk::locX);
265 bool pseudo = !
id.is_valid();
267 if (pseudo || !
m_idHelperSvc->mdtIdHelper().is_muon(
id))
continue;
269 if (
eta > etamax) etamax =
eta;
270 if (
eta < etamin) etamin =
eta;
271 if (
phi > phimax) phimax =
phi;
272 if (
phi < phimin) phimin =
phi;
273 if (msgLvl(MSG::DEBUG)) {
274 msg() <<
"Selected State parameters: eta: " <<
eta <<
" ,phi: " <<
phi <<
" pos r " << rpos <<
" z " << zpos;
275 if (pars->covariance())
msg() << MSG::DEBUG <<
" extrapolation error " <<
Amg::error(*pars->covariance(),
Trk::locX);
280 if (stations.count(stIndex))
continue;
281 stations.insert(stIndex);
290 ATH_MSG_DEBUG(
"Eta range: " << etamin <<
" " << etamax <<
" Phi range " << phimin <<
" " << phimax);
291 if (etamin > etamax) {
292 ATH_MSG_DEBUG(
"no hits selected, nothing further will be done");
305 std::set<IdentifierHash>::iterator hsit =
data.mdt.begin();
306 std::set<IdentifierHash>::iterator hsit_end =
data.mdt.end();
307 for (; hsit != hsit_end; ++hsit) {
315 hsit =
data.csc.begin();
316 hsit_end =
data.csc.end();
317 for (; hsit != hsit_end; ++hsit) {
337 std::set<MuonStationIndex::StIndex> stations;
342 for (; tsit != tsit_end; ++tsit) {
392 if (mm && !
data.mmTrack.count(mm->collectionHash())) {
393 data.mmTrack.insert(mm->collectionHash());
404 ATH_MSG_WARNING(
" track without states, cannot perform mdt hole search ");
410 ATH_MSG_ERROR(
"Failed to retrieve chamber intersection service");
417 std::vector<std::unique_ptr<const Trk::TrackStateOnSurface>> states;
418 unsigned int nholes = 0;
419 std::set<Identifier> chambersInSearch;
422 if (
data.mdtTrack.count(ith)) {
431 if (chambersInSearch.count(chId)) {
440 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *detEl,
true)};
448 const MuonStationIntersect intersect = InterSectSvc->tubesCrossedByTrack(MuonDetMgr, chId, exPars->position(), exPars->momentum().unit());
451 for (
unsigned int ii = 0; ii < intersect.tubeIntersects().size(); ++ii) {
460 chambersInSearch.insert(ch);
463 std::unique_ptr<Trk::TrackParameters> tubePars{
472 double distEdge = std::abs(tubePars->parameters()[
Trk::locZ]) - 0.5 * tubeLen;
476 std::optional<Amg::Vector2D> locPos = surf.Trk::Surface::globalToLocal(tubePars->position());
478 bool inBounds =
false;
485 <<
" outside bounds ");
489 <<
" dist tube edge " << distEdge <<
" pullEdge " << pullEdge);
492 states.emplace_back(std::move(tsos));
499 if (
data.cscTrack.count(ith)) {
514 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *detEl,
true)};
520 std::set<Identifier> layIds;
521 std::vector<std::unique_ptr<const Trk::TrackStateOnSurface>> cscstates;
525 for (std::unique_ptr<const Trk::TrackStateOnSurface>& cscit : cscstates) {
527 states.emplace_back(std::move(cscit));
532 if (
data.tgcTrack.count(ith)) {
547 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *detEl,
true)};
553 std::set<Identifier> layIds;
554 std::vector<std::unique_ptr<const Trk::TrackStateOnSurface>> tgcstates;
558 for (std::unique_ptr<const Trk::TrackStateOnSurface>& tgcit : tgcstates) {
560 states.emplace_back(std::move(tgcit));
566 if (
data.rpcTrack.count(ith)) {
581 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *detEl,
true)};
587 std::set<Identifier> layIds;
588 std::vector<std::unique_ptr<const Trk::TrackStateOnSurface>> rpcstates;
592 for (std::unique_ptr<const Trk::TrackStateOnSurface>& rpcit : rpcstates) {
594 states.emplace_back(std::move(rpcit));
602 if (
data.stgcTrack.count(ith)) {
623 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *detEl,
true)};
629 std::set<Identifier> layIds;
630 std::vector<std::unique_ptr<const Trk::TrackStateOnSurface>> stgcstates;
634 for (std::unique_ptr<const Trk::TrackStateOnSurface>& stgcit : stgcstates) {
636 states.push_back(std::move(stgcit));
643 if (
data.mmTrack.count(ith)) {
664 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *detEl,
true)};
670 std::set<Identifier> layIds;
671 std::vector<std::unique_ptr<const Trk::TrackStateOnSurface>> mmstates;
675 for (std::unique_ptr<const Trk::TrackStateOnSurface>& mmit : mmstates) {
677 states.emplace_back(std::move(mmit));
680 if (!states.empty()) {
682 auto trackStateOnSurfaces = std::make_unique<Trk::TrackStates>();
683 trackStateOnSurfaces->reserve(oldStates->
size() + states.size());
685 std::vector<std::unique_ptr<const Trk::TrackStateOnSurface>> toBeSorted;
686 toBeSorted.reserve(oldStates->
size() + states.size());
690 for (std::unique_ptr<const Trk::TrackStateOnSurface>& stit : states) toBeSorted.emplace_back(std::move(stit));
694 for (std::unique_ptr<const Trk::TrackStateOnSurface>& sorted : toBeSorted) { trackStateOnSurfaces->push_back(sorted.release()); }
695 std::unique_ptr<Trk::Track> trackWithHoles = std::make_unique<Trk::Track>(
696 track.info(), std::move(trackStateOnSurfaces), track.fitQuality() ? track.fitQuality()->uniqueClone() :
nullptr);
700 <<
m_printer->printStations(*trackWithHoles));
701 return trackWithHoles;
709 std::vector<std::unique_ptr<const Trk::TrackStateOnSurface>> states;
710 std::set<IdentifierHash> newMdtHashes;
711 std::set<IdentifierHash> newRpcHashes;
712 std::set<IdentifierHash> newTgcHashes;
713 std::set<IdentifierHash> newCscHashes;
715 std::set<IdentifierHash> newMMHashes;
716 std::set<IdentifierHash> newsTgcHashes;
718 ATH_MSG_DEBUG(
"Adding Missing MDT chambers: regions " <<
data.mdtPerStation.size());
719 std::vector<const MdtPrepDataCollection*> newmcols;
720 for (
const auto& chit :
data.mdtPerStation) {
722 std::vector<const MdtPrepDataCollection*> cols;
724 std::map<int, std::vector<const MdtPrepData*>> mdtPrds;
725 std::unique_ptr<const Trk::TrackParameters> exParsFirst;
727 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *mit->front()->detectorElement())};
731 <<
" sector " << sector);
732 newmcols.emplace_back(mit);
733 std::vector<const MdtPrepData*>& col = mdtPrds[sector];
734 col.insert(col.end(), mit->begin(), mit->end());
735 if (!exParsFirst) exParsFirst.swap(exPars);
739 << mit->identifyHash());
742 std::vector<const MdtPrepData*>* prds =
nullptr;
743 std::map<int, std::vector<const MdtPrepData*>>
::iterator sectorIt = mdtPrds.begin();
744 if (mdtPrds.empty()) {
746 }
else if (mdtPrds.size() == 1) {
747 prds = §orIt->second;
751 std::map<int, std::vector<const MdtPrepData*>>
::iterator pos = mdtPrds.find(hitSummary.
mainSector);
752 if (pos != mdtPrds.end())
758 if (prds && exParsFirst) {
759 std::unique_ptr<Trk::SegmentCollection> segments =
m_seededSegmentFinder->find(ctx, *exParsFirst, *prds);
761 if (!segments->empty())
ATH_MSG_DEBUG(
"found segments " << segments->size());
764 std::unique_ptr<const Trk::TrackParameters> bestSegmentPars;
776 std::unique_ptr<const Trk::TrackParameters> segPars{
m_extrapolator->extrapolateDirectly(
784 if (std::abs(dangleYZ) < 0.05) {
786 bestSegmentPars.swap(segPars);
794 std::unique_ptr<Trk::TrackParameters> hitPars{
m_extrapolator->extrapolateDirectly(
797 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
801 states.emplace_back(tsos);
812 data.mdtCols = std::move(newmcols);
814 unsigned int nstates = states.size();
817 std::vector<const RpcPrepDataCollection*> newtcols;
819 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *(rit)->front()->detectorElement())};
821 newtcols.emplace_back(rit);
823 std::set<Identifier> layIds;
825 if (states.size() != nstates) {
826 nstates = states.size();
831 data.rpcCols = std::move(newtcols);
835 std::vector<const TgcPrepDataCollection*> newtcols;
837 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *(tgcit)->front()->detectorElement())};
839 newtcols.emplace_back(tgcit);
841 std::set<Identifier> layIds;
843 if (states.size() != nstates) {
844 nstates = states.size();
849 data.tgcCols = std::move(newtcols);
853 std::vector<const CscPrepDataCollection*> newccols;
855 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *(cit)->front()->detectorElement())};
857 newccols.push_back(cit);
859 std::set<Identifier> layIds;
861 if (states.size() != nstates) {
862 nstates = states.size();
867 data.cscCols = std::move(newccols);
869 nstates = states.size();
872 std::vector<const sTgcPrepDataCollection*> newstcols;
873 ATH_MSG_DEBUG(
" extractsTgcPrdCols data.stgcCols.size() " <<
data.stgcCols.size());
875 std::unique_ptr<const Trk::TrackParameters> exPars{
reachableDetEl(ctx, track, *(stgcit)->front()->detectorElement())};
877 newstcols.push_back(stgcit);
879 std::set<Identifier> layIds;
881 ATH_MSG_DEBUG(
"Collected new sTgc states: " << states.size());
882 if (states.size() != nstates) {
883 nstates = states.size();
888 data.stgcCols = std::move(newstcols);
894 std::vector<const MMPrepDataCollection*> newmcols;
898 newmcols.push_back(mit);
900 std::set<Identifier> layIds;
903 if (states.size() != nstates) {
904 nstates = states.size();
909 data.mmCols = std::move(newmcols);
912 if (!states.empty()) {
925 ATH_MSG_DEBUG(
"Filling DataVector with TSOSs " << states.size());
926 auto trackStateOnSurfaces = std::make_unique<Trk::TrackStates>();
927 trackStateOnSurfaces->reserve(states.size());
928 for (std::unique_ptr<const Trk::TrackStateOnSurface>& sorted : states) { trackStateOnSurfaces->push_back(sorted.release()); }
930 std::unique_ptr<Trk::Track> newTrack = std::make_unique<Trk::Track>(track.info(), std::move(trackStateOnSurfaces),
931 track.fitQuality() ? track.fitQuality()->uniqueClone() :
nullptr);
932 std::unique_ptr<Trk::Track> refittedTrack;
941 data.mdtTrack.insert(newMdtHashes.begin(), newMdtHashes.end());
942 data.rpcTrack.insert(newRpcHashes.begin(), newRpcHashes.end());
943 data.tgcTrack.insert(newTgcHashes.begin(), newTgcHashes.end());
944 data.cscTrack.insert(newCscHashes.begin(), newCscHashes.end());
946 data.stgcTrack.insert(newsTgcHashes.begin(), newsTgcHashes.end());
947 data.mmTrack.insert(newMMHashes.begin(), newMMHashes.end());
949 return refittedTrack;
957 bool smallerBounds)
const {
959 std::unique_ptr<const Trk::TrackParameters> exPars;
983 if (covx > 0.0 && covy > 0.0) {
992 if (tolx > 10.) tolx = 10.;
993 if (toly > 10.) toly = 10.;
999 if (msgLvl(MSG::DEBUG)) {
1000 std::ostringstream parsType;
1003 parsType <<
" tolerance=(" << tolx <<
"," << toly <<
")";
1005 parsType <<
" => inbounds";
1007 parsType <<
" => outbounds";
1010 if (!inbounds) {
return nullptr; }
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
char data[hepevt_bytes_allocation_ATLAS]
DataModel_detail::const_iterator< DataVector > const_iterator
const PrepDataT * front() const
size_type size() const noexcept
Returns the number of elements in the collection.
Describes the API of the Region of Ineterest geometry.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
This is a "hash" representation of an Identifier.
bool is_valid() const
Check if id is in a valid state.
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
double getActiveTubeLength(const int tubeLayer, const int tube) const
virtual const Trk::Surface & surface() const override final
Return surface associated with this detector element.
double innerTubeRadius() const
Returns the inner tube radius excluding the aluminium walls.
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const MMReadoutElement * getMMReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const TgcReadoutElement * getTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const sTgcReadoutElement * getsTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
IdentifierHash identifyHash() const override final
Returns the IdentifierHash of the MuonStation, i.e.
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
Class for competing MuonClusters, it extends the Trk::CompetingRIOsOnTrack base class.
const MuonClusterOnTrack & rioOnTrack(unsigned int) const
returns the RIO_OnTrack (also known as ROT) objects depending on the integer
Class to represent the calibrated clusters created from CSC strips.
Class to represent calibrated clusters formed from TGC strips.
virtual const MuonGM::MMReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD.
This class represents the corrected MDT measurements, where the corrections include the effects of wi...
IdentifierHash collectionHash() const
Returns the hashID of the PRD collection.
Base class for Muon cluster RIO_OnTracks.
virtual IdentifierHash collectionHash() const
Returns the hashID of the PRD collection.
static std::unique_ptr< Trk::TrackParameters > closestParameters(const Trk::Track &track, const Amg::Vector3D &pos, bool onlyUseMeasured=false)
virtual Identifier identify() const override final
virtual IdentifierHash identifyHash() const override final
This is the common class for 3D segments used in the muon spectrometer.
const Trk::LocalDirection & localDirection() const
local direction
virtual const Trk::PlaneSurface & associatedSurface() const override final
returns the surface for the local to global transformation
static std::unique_ptr< Trk::TrackStateOnSurface > createHoleTSOS(std::unique_ptr< Trk::TrackParameters > pars)
create a hole TSOS, takes ownership of the pointers
Class to represent calibrated clusters formed from RPC strips.
Class to represent calibrated clusters formed from TGC strips.
Class to represent calibrated clusters formed from TGC strips.
Describes the Region of Ineterest geometry It has basically 9 parameters.
const_pointer_type cptr()
represents the three-dimensional global direction with respect to a planar surface frame.
double angleYZ() const
access method for angle of local YZ projection
This class is the pure abstract base class for all fittable tracking measurements.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
void globalToLocalDirection(const Amg::Vector3D &glodir, Trk::LocalDirection &locdir) const
This method transforms the global direction to a local direction wrt the plane.
Identifier identify() const
return the identifier -extends MeasurementBase
Base class for all TrackSegment implementations, extends the common MeasurementBase.
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects
virtual bool insideLoc2(const Amg::Vector2D &locpo, double tol2=0.) const =0
Extend the interface to for single inside Loc 1 / Loc2 tests.
Abstract Base Class for tracking surfaces.
virtual bool insideBounds(const Amg::Vector2D &locpos, double tol1=0., double tol2=0.) const =0
virtual methods to be overwritten by the inherited surfaces
virtual const SurfaceBounds & bounds() const =0
Surface Bounds method.
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
This is the base class for all tracking detector elements with read-out relevant information.
virtual const Amg::Vector3D & center() const =0
Return the center of the element.
virtual Identifier identify() const =0
Identifier.
virtual const Surface & surface() const =0
Return surface associated with this detector element.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
bool hasPositiveDiagElems(const AmgSymMatrix(N) &mat)
Returns true if all diagonal elements of the covariance matrix are finite aka sane in the above defin...
Eigen::Matrix< double, 2, 1 > Vector2D
StIndex
enum to classify the different station layers in the muon spectrometer
ChIndex chIndex(const std::string &index)
convert ChIndex name string to enum
TechnologyIndex
enum to classify the different layers in the muon spectrometer
const std::string & chName(ChIndex index)
convert ChIndex into a string
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< CscPrepData > CscPrepDataCollection
MuonPrepDataCollection< TgcPrepData > TgcPrepDataCollection
MuonPrepDataCollection< MMPrepData > MMPrepDataCollection
MuonPrepDataCollection< MdtPrepData > MdtPrepDataCollection
MuonPrepDataCollection< RpcPrepData > RpcPrepDataCollection
MuonPrepDataCollection< sTgcPrepData > sTgcPrepDataCollection
DataVector< const Trk::TrackStateOnSurface > TrackStates
ParametersBase< TrackParametersDim, Charged > TrackParameters
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.