46 return StatusCode::SUCCESS;
50 const std::set<Identifier>& chIds)
const {
52 std::vector<const MdtPrepData*> mdtPrds =
extractPrds(ctx, chIds);
54 if (mdtPrds.empty()) {
60 return find(ctx, pars, mdtPrds);
64 const std::set<IdentifierHash>& chIdHs)
const {
66 std::vector<const MdtPrepData*> mdtPrds =
extractPrds(ctx, chIdHs);
68 if (mdtPrds.empty()) {
74 return find(ctx, pars, mdtPrds);
78 const std::vector<const MdtPrepData*>& mdtPrds)
const {
80 bool doHoleSearch =
true;
83 std::vector<const MdtDriftCircleOnTrack*> mdtROTs;
84 mdtROTs.reserve(mdtPrds.size());
87 if (mdtROTs.empty()) {
93 double roadWidthEta = 1.;
94 if (pars.covariance()) {
97 if (trackError < 0.2) trackError = 0.2;
98 roadWidthEta = 5. * trackError;
100 Trk::TrackRoad road(pars.position(), pars.momentum(), roadWidthEta, 1.);
103 std::vector<std::vector<const MdtDriftCircleOnTrack*> > mdtROTsVec;
104 mdtROTsVec.push_back(mdtROTs);
105 std::vector<std::vector<const MuonClusterOnTrack*> > clusterROTsVec;
109 doHoleSearch ?
m_segMaker->find(road, mdtROTsVec, clusterROTsVec, segments.get(),
true)
110 :
m_segMakerNoHoles->find(road, mdtROTsVec, clusterROTsVec, segments.get(),
true);
118 ATH_MSG_DEBUG(
" Number of segments found: " << segments->size());
127 if (MuonDetMgr ==
nullptr) {
128 ATH_MSG_ERROR(
"Null pointer to the read MuonDetectorManager conditions object");
133 std::set<IdentifierHash> chIdHs;
136 std::set<Identifier>::const_iterator chit = chIds.begin();
137 std::set<Identifier>::const_iterator chit_end = chIds.end();
138 for (; chit != chit_end; ++chit) {
153 std::vector<const MdtPrepData*> mdtPrds =
extractPrds(ctx, chIdHs);
159 const std::set<IdentifierHash>& chIdHs)
const {
163 mdtPrdContainer = h_mdtPrdCont.
cptr();
170 std::vector<const MdtPrepData*> mdtPrds;
173 std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
174 std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
175 for (; chit != chit_end; ++chit) {
176 const auto* collptr = mdtPrdContainer->
indexFindPtr(*chit);
177 if (collptr ==
nullptr) {
continue; }
180 mdtPrds.insert(mdtPrds.end(), collptr->begin(), collptr->end());
187 std::vector<const MdtPrepDataCollection*>& target)
const {
191 if (mdtPrdContainer->empty())
return;
194 std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
195 std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
196 for (; chit != chit_end; ++chit) {
197 const auto* collptr = mdtPrdContainer->indexFindPtr(*chit);
198 if (collptr ==
nullptr || collptr->empty()) {
continue; }
203 target.push_back(collptr);
208 std::vector<const RpcPrepDataCollection*>& target)
const {
211 if (rpcPrdContainer->empty())
return;
214 std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
215 std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
216 for (; chit != chit_end; ++chit) {
217 const auto* collptr = rpcPrdContainer->indexFindPtr(*chit);
218 if (collptr ==
nullptr || collptr->empty()) {
continue; }
223 target.push_back(collptr);
228 std::vector<const TgcPrepDataCollection*>& target)
const {
231 if (tgcPrdContainer->empty())
return;
234 std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
235 std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
236 for (; chit != chit_end; ++chit) {
237 const auto* collptr = tgcPrdContainer->indexFindPtr(*chit);
238 if (collptr ==
nullptr || collptr->empty()) {
continue; }
243 target.push_back(collptr);
248 std::vector<const CscPrepDataCollection*>& target)
const {
254 if (cscPrdContainer->empty())
return;
257 std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
258 std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
259 for (; chit != chit_end; ++chit) {
260 const auto* collptr = cscPrdContainer->indexFindPtr(*chit);
261 if (collptr ==
nullptr || collptr->empty()) {
continue; }
267 target.push_back(collptr);
275 std::vector<const sTgcPrepDataCollection*>& target)
const {
284 stgcPrdContainer = h_stgcPrdCont.
cptr();
289 if (stgcPrdContainer->
empty())
return;
292 std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
293 std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
294 for (; chit != chit_end; ++chit) {
295 const auto* collptr = stgcPrdContainer->
indexFindPtr(*chit);
296 if (collptr ==
nullptr || collptr->empty()) {
continue; }
301 target.push_back(collptr);
307 std::vector<const MMPrepDataCollection*>& target)
const {
316 mmPrdContainer = h_mmPrdCont.
cptr();
321 if (mmPrdContainer->
empty())
return;
324 std::set<IdentifierHash>::const_iterator chit = chIdHs.begin();
325 std::set<IdentifierHash>::const_iterator chit_end = chIdHs.end();
326 for (; chit != chit_end; ++chit) {
327 const auto* collptr = mmPrdContainer->
indexFindPtr(*chit);
328 if (collptr ==
nullptr || collptr->empty()) {
continue; }
332 target.push_back(collptr);
337 const std::vector<const MdtPrepData*>& mdtPrdCols,
338 std::vector<const MdtDriftCircleOnTrack*>& mdtROTs,
bool& doHoleSearch)
const {
339 ATH_MSG_VERBOSE(
" in selectAndCalibrate, get PRDs " << mdtPrdCols.size());
342 std::vector<const MdtPrepData*>::const_iterator mit = mdtPrdCols.begin();
343 std::vector<const MdtPrepData*>::const_iterator mit_end = mdtPrdCols.end();
344 for (; mit != mit_end; ++mit) {
352 mdtROTs.push_back(mdt);
354 ATH_MSG_VERBOSE(
" calibrated " << mdtROTs.size() <<
" prds out of " << mdtPrdCols.size());
358 const MdtPrepData& mdtPrd,
bool& doHoleSearch)
const {
376 double distanceToWire = exPars->parameters()[
Trk::locR];
377 double posAlongWire = exPars->parameters()[
Trk::locZ];
379 double errorR = exPars->covariance() ? fabs(
Amg::error(*exPars->covariance(),
Trk::locR)) : 500.;
380 double errorZ = exPars->covariance() ? fabs(
Amg::error(*exPars->covariance(),
Trk::locZ)) : 300.;
383 bool isOnSurface = surf.
isOnSurface(exPars->position(),
true, 5 * errorR, 5 * errorZ);
392 double roadWidthR = 5 * errorR + 4 * tubeRadius;
393 double roadWidthZ = 5 * errorZ + 100.;
396 double nSigmaFromTrack = fabs(fabs(distanceToWire) - mdtPrd.
localPosition()[
Trk::locR]) / sqrt(errorR * errorR + driftdr * driftdr);
398 if (msgLvl(MSG::VERBOSE)) {
399 std::string boundCheckStr = isOnSurface ?
" onSurface" :
" outOfSurface";
401 << roadWidthR <<
" z " << posAlongWire <<
" range " << halfTubeLength + roadWidthZ << boundCheckStr;
405 if (nSigmaFromTrack >
m_maxSigma || fabs(posAlongWire) > halfTubeLength + roadWidthZ) {
406 if (msgLvl(MSG::VERBOSE))
msg() <<
" --- dropped" <<
endmsg;
412 if (doHoleSearch && fabs(posAlongWire) < halfTubeLength + roadWidthZ) doHoleSearch =
false;
428 if (msgLvl(MSG::VERBOSE)) {
430 double error = driftdr;
431 double residual = radius - fabs(distanceToWire);
432 double fullError = sqrt(errorR * errorR +
error *
error);
433 double radialPull = residual / fullError;
435 if (fabs(radialPull) < 5)
437 else if (fabs(radialPull) > 5 && residual > 0)
440 hitType =
"outOfTime";
441 msg() <<
" r_drift " << radius <<
" res " << residual <<
" pull " << radialPull <<
" " << hitType <<
endmsg;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
ATLAS-specific HepMC functions.
bool empty() const
return true if container is empty
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,...
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 MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
IdentifierHash identifyHash() const override final
Returns the IdentifierHash of the MuonStation, i.e.
This class represents the corrected MDT measurements, where the corrections include the effects of wi...
Class to represent measurements from the Monitored Drift Tubes.
int adc() const
Returns the ADC (typically range is 0 to 250)
virtual const MuonGM::MdtReadoutElement * detectorElement() const override
Returns the detector element corresponding to this PRD.
void extractRpcPrdCols(const EventContext &ctx, const std::set< IdentifierHash > &chIdHs, std::vector< const RpcPrepDataCollection * > &target) const
retrieve RPC PRD collections for the given hashes
ToolHandle< Muon::IMdtDriftCircleOnTrackCreator > m_mdtRotCreator
IMdtDriftCircleOnTrackCreator.
SG::ReadHandleKey< Muon::MMPrepDataContainer > m_key_mm
void extractMMPrdCols(const std::set< IdentifierHash > &chIdHs, std::vector< const MMPrepDataCollection * > &target) const
retrieve MM PRD collections for the given hashes
void extractCscPrdCols(const std::set< IdentifierHash > &chIdHs, std::vector< const CscPrepDataCollection * > &target) const
retrieve CSC PRD collections for the given hashes
void extractsTgcPrdCols(const EventContext &ctx, const std::set< IdentifierHash > &chIdHs, std::vector< const sTgcPrepDataCollection * > &target) const
retrieve STGC PRD collections for the given hashes
Trk::MagneticFieldProperties m_magFieldProperties
magnetic field properties
SG::ReadHandleKey< Muon::MdtPrepDataContainer > m_key_mdt
SG::ReadHandleKey< Muon::CscPrepDataContainer > m_key_csc
SG::ReadHandleKey< Muon::sTgcPrepDataContainer > m_key_stgc
void extractTgcPrdCols(const EventContext &ctx, const std::set< IdentifierHash > &chIdHs, std::vector< const TgcPrepDataCollection * > &target) const
retrieve TGC PRD collections for the given hashes
MuonSeededSegmentFinder(const std::string &, const std::string &, const IInterface *)
constructor
ToolHandle< Muon::IMuonSegmentMaker > m_segMakerNoHoles
actual segment maker no hole search
PublicToolHandle< Muon::MuonEDMPrinterTool > m_printer
EDM printer tool.
std::unique_ptr< Trk::SegmentCollection > find(const EventContext &ctx, const Trk::TrackParameters &pars, const std::set< Identifier > &chIds) const
find segments in a set of chambers starting from seeding TrackParameters
void extractMdtPrdCols(const EventContext &ctx, const std::set< IdentifierHash > &chIdHs, std::vector< const MdtPrepDataCollection * > &target) const
retrieve MDT PRD collections for the given hashes
void selectAndCalibrate(const EventContext &ctx, const Trk::TrackParameters &pars, const std::vector< const MdtPrepData * > &mdtPrdCols, std::vector< const MdtDriftCircleOnTrack * > &mdtROTs, bool &doHoleSearch) const
select a set of Mdt hits and calibrate them
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
std::vector< const MdtPrepData * > extractPrds(const EventContext &ctx, const std::set< Identifier > &chIds) const
retrieve the MdtPrepDataCollections for the give Identifiers
Gaudi::Property< double > m_maxSigma
ToolHandle< Trk::IPropagator > m_propagator
propagator
ToolHandle< Muon::IMuonSegmentMaker > m_segMaker
actual segment maker with hole search
Gaudi::Property< double > m_adcCut
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
SG::ReadHandleKey< Muon::RpcPrepDataContainer > m_key_rpc
const MdtDriftCircleOnTrack * handleMdtPrd(const EventContext &ctx, const Trk::TrackParameters &pars, const MdtPrepData &mdtPrd, bool &doHoleSearch) const
select and calibrate a single MdtPrepData
StatusCode initialize()
AlgTool initilize.
SG::ReadHandleKey< Muon::TgcPrepDataContainer > m_key_tgc
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
const Amg::Vector2D & localPosition() const
return the local position reference
Identifier identify() const
return the identifier
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
Class for a StraightLineSurface in the ATLAS detector to describe dirft tube and straw like detectors...
virtual bool isOnSurface(const Amg::Vector3D &glopo, const BoundaryCheck &bchk=true, double tol1=0., double tol2=0.) const override final
This method checks if the provided GlobalPosition is inside the assigned straw radius,...
Encapsulates the information required by the find() method of the muon segment makers.
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 ...
Eigen::Matrix< double, 3, 1 > Vector3D
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
MuonPrepDataContainerT< MdtPrepData > MdtPrepDataContainer
MuonPrepDataContainerT< sTgcPrepData > sTgcPrepDataContainer
MuonPrepDataContainerT< MMPrepData > MMPrepDataContainer
Ensure that the ATLAS eigen extensions are properly loaded.
DataVector< Trk::Segment > SegmentCollection
ParametersBase< TrackParametersDim, Charged > TrackParameters