ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::MuPatHitTool Class Reference

#include <MuPatHitTool.h>

Inheritance diagram for Muon::MuPatHitTool:
Collaboration diagram for Muon::MuPatHitTool:

Public Member Functions

 MuPatHitTool (const std::string &, const std::string &, const IInterface *)
 default AlgTool constructor
 ~MuPatHitTool ()
 destructor
StatusCode initialize () override
 initialize method, method taken from bass-class AlgTool
bool create (const EventContext &ctx, const MuonSegment &seg, MuPatHitList &hitList) const
 create a MCTBList from a MuonSegment
bool create (const Trk::Track &track, MuPatHitList &hitList) const
 create a MuPatHitList from a Track
bool create (const EventContext &ctx, const Trk::TrackParameters &pars, const std::vector< const Trk::MeasurementBase * > &measVec, MuPatHitList &hitList) const
 create a MuPatHitList from a Track
std::string print (const MuPatHitList &hitList, bool printPos=true, bool printDir=true, bool printMom=true) const
 print the list of hits, with optional parts of the printout (position,direction,momentum)
bool remove (const Trk::MeasurementBase &meas, MuPatHitList &hitList) const
 remove hit containing give measurement (uses pointer comparison)
bool update (const Trk::Track &track, MuPatHitList &hitList) const
 update hit list for a give track
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 access to tool interface
static MuPatHitList merge (const MuPatHitList &hitList1, const MuPatHitList &hitList2)
 merge two MuPatHitLists into a new one
static bool extract (const MuPatHitList &hitList, std::vector< const Trk::MeasurementBase * > &measVec, bool usePreciseHits=true, bool getReducedTrack=false)
 merge two MuPatHitLists into a new one.
static bool isSorted (const MuPatHitList &hitList)
 check whether the list is correctly sorted
static bool remove (const Identifier &id, MuPatHitList &hitList)
 remove hit with a give Identifier

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

MuPatHit::Type getHitType (const Identifier &id) const
 get hit type
MuPatHit::Info getHitInfo (const Trk::MeasurementBase &meas) const
 get hit info
std::unique_ptr< const Trk::MeasurementBasecreateBroadMeasurement (const Trk::MeasurementBase &preciseMeas, const MuPatHit::Info &hitInfo) const
 calculate broad measurement for a give precise measurement
void calculateResiduals (const Trk::TrackStateOnSurface *tsos, Trk::ResidualPull::ResidualType type, double &residual, double &residualPull) const
 calculate the residuals
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< Trk::IPropagatorm_propagator
ToolHandle< IMdtDriftCircleOnTrackCreatorm_mdtRotCreator
ToolHandle< IMuonClusterOnTrackCreatorm_cscRotCreator
ToolHandle< Trk::IResidualPullCalculatorm_pullCalculator
PublicToolHandle< MuonEDMPrinterToolm_printer
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc
ServiceHandle< IMuonEDMHelperSvcm_edmHelperSvc
Trk::MagneticFieldProperties m_magFieldProperties {Trk::NoField}
 magnetic field properties
Gaudi::Property< bool > m_isCosmic
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 27 of file MuPatHitTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ MuPatHitTool()

Muon::MuPatHitTool::MuPatHitTool ( const std::string & t,
const std::string & n,
const IInterface * p )

default AlgTool constructor

Definition at line 26 of file MuPatHitTool.cxx.

26 : AthAlgTool(t, n, p) {
27 declareInterface<MuPatHitTool>(this);
28 }
AthAlgTool()
Default constructor:

◆ ~MuPatHitTool()

Muon::MuPatHitTool::~MuPatHitTool ( )
default

destructor

Member Function Documentation

◆ calculateResiduals()

void Muon::MuPatHitTool::calculateResiduals ( const Trk::TrackStateOnSurface * tsos,
Trk::ResidualPull::ResidualType type,
double & residual,
double & residualPull ) const
inlineprivate

calculate the residuals

Definition at line 397 of file MuPatHitTool.cxx.

398 {
399 std::optional<Trk::ResidualPull> resPull(
400 m_pullCalculator->residualPull(tsos->measurementOnTrack(), tsos->trackParameters(), type));
401 if (resPull) {
402 residual = resPull->residual().front();
403 residualPull = resPull->pull().front();
404 } else {
405 residual = residualPull = -999;
406 }
407 }
ToolHandle< Trk::IResidualPullCalculator > m_pullCalculator
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload

◆ create() [1/3]

bool Muon::MuPatHitTool::create ( const EventContext & ctx,
const MuonSegment & seg,
MuPatHitList & hitList ) const

create a MCTBList from a MuonSegment

Parameters
segthe MuonSegment
hitListthe list to be filled
Returns
true if creation succeded

Definition at line 44 of file MuPatHitTool.cxx.

44 {
45 ATH_MSG_DEBUG(" creating hit list from segment " << std::endl << m_printer->print(seg));
46
47 // create parameters with very large momentum and no charge
48 double momentum{1.e8}, charge{0.};
49 std::unique_ptr<const Trk::TrackParameters> pars{m_edmHelperSvc->createTrackParameters(seg, momentum, charge)};
50 if (!pars) {
51 ATH_MSG_WARNING(" could not create track parameters for segment ");
52 return false;
53 }
54
55 return create(ctx, *pars, seg.containedMeasurements(), hitList);
56 }
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
double charge(const T &p)
Definition AtlasPID.h:997
PublicToolHandle< MuonEDMPrinterTool > m_printer
ServiceHandle< IMuonEDMHelperSvc > m_edmHelperSvc
bool create(const EventContext &ctx, const MuonSegment &seg, MuPatHitList &hitList) const
create a MCTBList from a MuonSegment
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects

◆ create() [2/3]

bool Muon::MuPatHitTool::create ( const EventContext & ctx,
const Trk::TrackParameters & pars,
const std::vector< const Trk::MeasurementBase * > & measVec,
MuPatHitList & hitList ) const

create a MuPatHitList from a Track

Parameters
parsthe input parameters
measVecthe list of measurements
hitListthe list to be filled
Returns
true if creation succeded

Definition at line 58 of file MuPatHitTool.cxx.

59 {
60 // loop over hits
61 for (const Trk::MeasurementBase* meas : measVec) {
62 // create hit info
63 MuPatHit::Info hitInfo = getHitInfo(*meas);
64
65 const Identifier& id = hitInfo.id;
66 if (hitInfo.type == MuPatHit::UnknownType) {
67 ATH_MSG_WARNING(" unknown hit type " << m_idHelperSvc->toString(id));
68 continue;
69 }
70
71 // create broad measurement
72 std::unique_ptr<const Trk::MeasurementBase> broadMeas = createBroadMeasurement(*meas, hitInfo);
73 if (!broadMeas) {
74 ATH_MSG_WARNING(" could not create broad measurement " << m_idHelperSvc->toString(id));
75 continue;
76 }
77 // extrapolate
78 std::unique_ptr<const Trk::TrackParameters> exPars;
79 if (pars.associatedSurface() == broadMeas->associatedSurface()) {
80 exPars = pars.uniqueClone();
81 ATH_MSG_VERBOSE(" start parameters and measurement expressed at same surface, cloning parameters ");
82 } else {
83 exPars = m_propagator->propagate(ctx, pars, broadMeas->associatedSurface(), Trk::anyDirection, false, m_magFieldProperties);
84 if (!exPars) { continue; } // !exPars
85 }
86
87 // create hit and insert it into list
88 ATH_MSG_VERBOSE(" inserting hit " << m_idHelperSvc->toString(id) << " " << m_printer->print(*exPars));
89 std::unique_ptr<MuPatHit> hit = std::make_unique<MuPatHit>(std::move(exPars), meas->uniqueClone(), std::move(broadMeas), hitInfo);
90 hitList.push_back(std::move(hit));
91 }
92
93 const SortByDirectionMuPatHits isLargerCal{pars};
94 std::stable_sort(hitList.begin(), hitList.end(), isLargerCal);
95 return true;
96 }
#define ATH_MSG_VERBOSE(x)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Trk::MagneticFieldProperties m_magFieldProperties
magnetic field properties
ToolHandle< Trk::IPropagator > m_propagator
MuPatHit::Info getHitInfo(const Trk::MeasurementBase &meas) const
get hit info
std::unique_ptr< const Trk::MeasurementBase > createBroadMeasurement(const Trk::MeasurementBase &preciseMeas, const MuPatHit::Info &hitInfo) const
calculate broad measurement for a give precise measurement
@ anyDirection
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.

◆ create() [3/3]

bool Muon::MuPatHitTool::create ( const Trk::Track & track,
MuPatHitList & hitList ) const

create a MuPatHitList from a Track

Parameters
trackthe input track
hitListthe list to be filled
Returns
true if creation succeded

Definition at line 98 of file MuPatHitTool.cxx.

98 {
99 // loop over hits
100 for (const Trk::TrackStateOnSurface* tsit : *track.trackStateOnSurfaces()) {
101 // do not take into account scatteres and holes for now
102 if (tsit->type(Trk::TrackStateOnSurface::Scatterer) ||
103 tsit->type(Trk::TrackStateOnSurface::Hole)) continue;
104
105 const Trk::MeasurementBase* meas = tsit->measurementOnTrack();
106 if (!meas) continue;
107
108 const Trk::TrackParameters* pars = tsit->trackParameters();
109 if (!pars) continue;
110
111 // create hit info
112 MuPatHit::Info hitInfo = getHitInfo(*meas);
113
114 if (tsit->type(Trk::TrackStateOnSurface::Outlier)) hitInfo.status = MuPatHit::Outlier;
115
116 const Identifier& id = hitInfo.id;
117
118 if (!m_idHelperSvc->isMuon(id)) continue;
119
120 if (hitInfo.type == MuPatHit::UnknownType) {
121 ATH_MSG_WARNING(" unknown hit type " << m_idHelperSvc->toString(id));
122 continue;
123 }
124
125 // create broad measurement
126 std::unique_ptr<const Trk::MeasurementBase> broadMeas = createBroadMeasurement(*meas, hitInfo);
127 if (!broadMeas) {
128 ATH_MSG_WARNING(" could not create broad measurement " << m_idHelperSvc->toString(id));
129 continue;
130 }
131
132 // create hit and insert it into list
133 std::unique_ptr<MuPatHit> hit = std::make_unique<MuPatHit>(pars->uniqueClone(), meas->uniqueClone(), std::move(broadMeas), hitInfo);
134 ATH_MSG_VERBOSE(" inserting hit " << m_printer->print(*meas) << (hitInfo.status == MuPatHit::Outlier ? " Outlier" : ""));
135 double residual{0.}, pull{0.};
136 calculateResiduals(tsit, Trk::ResidualPull::Unbiased, residual, pull);
137 hit->setResidual(residual,pull);
138 hitList.push_back(std::move(hit));
139 }
140
141 const Trk::TrackParameters* pars = track.perigeeParameters();
142 const SortByDirectionMuPatHits isLargerCal{*pars};
143 std::stable_sort(hitList.begin(), hitList.end(), isLargerCal);
144
145 return true;
146 }
void calculateResiduals(const Trk::TrackStateOnSurface *tsos, Trk::ResidualPull::ResidualType type, double &residual, double &residualPull) const
calculate the residuals
std::unique_ptr< MeasurementBase > uniqueClone() const
NVI Clone giving up unique pointer.
@ Unbiased
RP with track state that has measurement not included.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
@ Scatterer
This represents a scattering point on the track, and so will contain TrackParameters and MaterialEffe...
@ Hole
A hole on the track - this is defined in the following way.
ParametersBase< TrackParametersDim, Charged > TrackParameters

◆ createBroadMeasurement()

std::unique_ptr< const Trk::MeasurementBase > Muon::MuPatHitTool::createBroadMeasurement ( const Trk::MeasurementBase & preciseMeas,
const MuPatHit::Info & hitInfo ) const
private

calculate broad measurement for a give precise measurement

Definition at line 251 of file MuPatHitTool.cxx.

252 {
253 // don't change errors for Pseudo measurements
254 if (hitInfo.type == MuPatHit::MDT) {
255 const MdtDriftCircleOnTrack* mdt = dynamic_cast<const MdtDriftCircleOnTrack*>(&meas);
256 if (!mdt) {
257 ATH_MSG_WARNING(" found hit with a MDT Identifier that is not a MdtDriftCircleOnTrack "
258 << m_idHelperSvc->toString(hitInfo.id));
259 return nullptr;
260 }
261 ATH_MSG_DEBUG(" creating broad MdtDriftCircleOnTrack ");
262
263 return std::unique_ptr<const Trk::MeasurementBase>(m_mdtRotCreator->updateError(*mdt));
264
265 } else if (hitInfo.type == MuPatHit::CSC && !hitInfo.measuresPhi) {
266 if (m_cscRotCreator.empty()) {
267 // Configured to not use CSC's
268 return nullptr;
269 }
270 const CscClusterOnTrack* csc = dynamic_cast<const CscClusterOnTrack*>(&meas);
271 if (!csc) {
272 ATH_MSG_WARNING(" found hit with CSC identifier that is not a CscClusterOnTrack " << m_idHelperSvc->toString(hitInfo.id));
273 return nullptr;
274 }
275 ATH_MSG_DEBUG(" creating broad CscClusterOnTrack ");
276
277 return std::unique_ptr<const Trk::MeasurementBase>(
278 m_cscRotCreator->createRIO_OnTrack(*csc->prepRawData(), csc->globalPosition()));
279 }
280
281 // don't change errors for CSC phi hits, TGC, RPC and Pseudo measurements
282 return meas.uniqueClone();
283 }
virtual const CscPrepData * prepRawData() const override final
Returns the CscPrepData - is a CscPrepData in this scope.
ToolHandle< IMuonClusterOnTrackCreator > m_cscRotCreator
ToolHandle< IMdtDriftCircleOnTrackCreator > m_mdtRotCreator
virtual const Amg::Vector3D & globalPosition() const override
Returns global position.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extract()

bool Muon::MuPatHitTool::extract ( const MuPatHitList & hitList,
std::vector< const Trk::MeasurementBase * > & measVec,
bool usePreciseHits = true,
bool getReducedTrack = false )
static

merge two MuPatHitLists into a new one.

The first list will be added to the second

Parameters
hitList1the first list
hitList2the second list
Returns
true if merge succeded

Definition at line 171 of file MuPatHitTool.cxx.

172 {
173 // make sure the vector is sufficiently large
174 measVec.reserve(hitList.size());
175
176 // loop over hit list
177 for (const MuPatHitPtr& hit : hitList) {
178 if (hit->info().status != MuPatHit::OnTrack) { continue; }
179 const Trk::MeasurementBase* meas = usePreciseHits ? &hit->preciseMeasurement() : &hit->broadMeasurement();
180 measVec.push_back(meas);
181 }
182 return true;
183 }
std::shared_ptr< MuPatHit > MuPatHitPtr
Definition MuPatHit.h:25

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getHitInfo()

MuPatHit::Info Muon::MuPatHitTool::getHitInfo ( const Trk::MeasurementBase & meas) const
private

get hit info

Definition at line 233 of file MuPatHitTool.cxx.

233 {
234 MuPatHit::Info hitInfo{};
235 hitInfo.id = m_edmHelperSvc->getIdentifier(meas);
236 // for clusters store layer id instead of channel id
237 hitInfo.measuresPhi = true; // assume that all PseudoMeasurements measure phi!!
238 hitInfo.type = MuPatHit::Pseudo;
239 hitInfo.status = MuPatHit::OnTrack;
240 if (hitInfo.id.is_valid() && m_idHelperSvc->isMuon(hitInfo.id)) {
241 hitInfo.type = getHitType(hitInfo.id);
242 hitInfo.measuresPhi = m_idHelperSvc->measuresPhi(hitInfo.id);
243 hitInfo.isSmall = m_idHelperSvc->isSmallChamber(hitInfo.id);
244 hitInfo.stIdx = m_idHelperSvc->stationIndex(hitInfo.id);
245 hitInfo.isEndcap = m_idHelperSvc->isEndcap(hitInfo.id);
246 if (hitInfo.type != MuPatHit::MDT && hitInfo.type != MuPatHit::MM) hitInfo.id = m_idHelperSvc->layerId(hitInfo.id);
247 }
248 return hitInfo;
249 }
MuPatHit::Type getHitType(const Identifier &id) const
get hit type

◆ getHitType()

MuPatHit::Type Muon::MuPatHitTool::getHitType ( const Identifier & id) const
private

get hit type

Definition at line 215 of file MuPatHitTool.cxx.

215 {
216 if (m_idHelperSvc->isMdt(id))
217 return MuPatHit::MDT;
218 else if (m_idHelperSvc->isTgc(id))
219 return MuPatHit::TGC;
220 else if (m_idHelperSvc->isCsc(id))
221 return MuPatHit::CSC;
222 else if (m_idHelperSvc->isRpc(id))
223 return MuPatHit::RPC;
224 else if (m_idHelperSvc->isMM(id))
225 return MuPatHit::MM;
226 else if (m_idHelperSvc->issTgc(id))
227 return MuPatHit::sTGC;
228 else if (m_idHelperSvc->isMuon(id))
229 return MuPatHit::PREC;
231 }

◆ initialize()

StatusCode Muon::MuPatHitTool::initialize ( )
override

initialize method, method taken from bass-class AlgTool

Definition at line 32 of file MuPatHitTool.cxx.

32 {
33 ATH_CHECK(m_idHelperSvc.retrieve());
34 ATH_CHECK(m_mdtRotCreator.retrieve());
35 ATH_CHECK(m_cscRotCreator.retrieve(DisableTool{m_cscRotCreator.empty()}));
36 ATH_CHECK(m_edmHelperSvc.retrieve());
37 ATH_CHECK(m_printer.retrieve());
38 ATH_CHECK(m_pullCalculator.retrieve());
39 ATH_CHECK(m_propagator.retrieve());
40
41 return StatusCode::SUCCESS;
42 }
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Muon::MuPatHitTool::interfaceID ( )
inlinestatic

access to tool interface

Definition at line 39 of file MuPatHitTool.h.

39 {
40 static const InterfaceID IID_MuPatHitTool("Muon::MuPatHitTool", 1, 0);
41 return IID_MuPatHitTool;
42 }

◆ isSorted()

bool Muon::MuPatHitTool::isSorted ( const MuPatHitList & hitList)
static

check whether the list is correctly sorted

Definition at line 381 of file MuPatHitTool.cxx.

381 {
382 MuPatHitCit it = hitList.begin();
383 MuPatHitCit it_end = hitList.end();
384 MuPatHitCit itNext = it;
385 if (itNext != it_end) ++itNext;
386 bool isLarger = true;
387 const Trk::TrackParameters& pars{hitList.front()->parameters()};
388 const SortByDirectionMuPatHits isLargerCal{pars};
389 for (; itNext != it_end; ++it, ++itNext) {
390 isLarger = isLargerCal(*it, *itNext);
391 bool sameSurface = (isLarger == isLargerCal(*it, *itNext)); // same surface
392 if (!isLarger && !sameSurface) return false;
393 if (sameSurface) return false;
394 }
395 return true;
396 }
MuPatHitList::const_iterator MuPatHitCit
Definition MuPatHit.h:27

◆ merge()

MuPatHitList Muon::MuPatHitTool::merge ( const MuPatHitList & hitList1,
const MuPatHitList & hitList2 )
static

merge two MuPatHitLists into a new one

Parameters
hitList1the first list
hitList2the second list
outListthe resulting list
Returns
true if merge succeded

Loop another time to ensure that duplicate hits are removed

Definition at line 148 of file MuPatHitTool.cxx.

148 {
149 // copy first list into outList
150 MuPatHitList tmpList{};
151 tmpList.reserve(hitList1.size() + hitList2.size());
152
153 if (!hitList1.empty()) {
154 const Trk::TrackParameters& pars{hitList1.front()->parameters()};
155 const SortByDirectionMuPatHits isLargerCal{pars};
156 std::merge(hitList1.begin(), hitList1.end(), hitList2.begin(), hitList2.end(),
157 std::back_inserter(tmpList), isLargerCal);
158 } else {
159 return hitList2;
160 }
162 outList.reserve(tmpList.size());
163 std::set<Identifier> used_hits{};
165 std::copy_if(std::make_move_iterator(tmpList.begin()), std::make_move_iterator(tmpList.end()), std::back_inserter(outList),
166 [&used_hits](const MuPatHitPtr& pathit) { return used_hits.insert(pathit->info().id).second; });
167
168 return outList;
169 }
std::vector< MuPatHitPtr > MuPatHitList
Definition MuPatHit.h:26

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ print()

std::string Muon::MuPatHitTool::print ( const MuPatHitList & hitList,
bool printPos = true,
bool printDir = true,
bool printMom = true ) const

print the list of hits, with optional parts of the printout (position,direction,momentum)

Definition at line 314 of file MuPatHitTool.cxx.

314 {
315 std::ostringstream sout;
316 DistanceAlongParameters distCal{};
317
318 // for nicely aligned printout, get max width of Id printout
319 std::vector<std::string> idStrings;
320 std::vector<std::string> dataStrings;
321 idStrings.reserve(hitList.size());
322 unsigned int idWidth = 0;
323 std::string result = "first ";
324 bool isLarger = true;
325 double distance = 0;
326 MuPatHitCit it = hitList.begin();
327 MuPatHitCit it_end = hitList.end();
328 MuPatHitCit itNext = hitList.begin();
329
330 const Trk::TrackParameters& pars{hitList.front()->parameters()};
331 const SortByDirectionMuPatHits isLargerCal{pars};
332
333 if (itNext != it_end) ++itNext;
334 for (; it != it_end; ++it, ++itNext) {
335
336 Identifier id = m_edmHelperSvc->getIdentifier((*it)->measurement());
337 std::string idStr = id.is_valid() ? m_idHelperSvc->toString(id) : "pseudo-measurement";
338 idStrings.push_back(idStr);
339 if (idStr.length() > idWidth) idWidth = idStr.length();
340 const Trk::TrackParameters& pars = (*it)->parameters();
341 std::ostringstream dataOss;
342 if (printPos) {
343 dataOss << "r " << std::fixed << std::setprecision(0) << std::setw(5) << pars.position().perp() << " z " << std::fixed
344 << std::setprecision(0) << std::setw(6) << pars.position().z();
345 }
346 if (printDir) {
347 dataOss << " theta " << std::fixed << std::setprecision(5) << std::setw(7) << pars.momentum().theta() << " phi "
348 << std::fixed << std::setprecision(3) << std::setw(6) << pars.momentum().phi();
349 }
350 if (printMom) {
351 dataOss << " q*p(GeV) " << std::scientific << std::setprecision(3) << std::setw(10)
352 << pars.momentum().mag() * pars.charge() / 1000.;
353 }
354
355
356 dataOss << " " << result << " dist " << distance;
357 dataStrings.push_back(dataOss.str());
358 if (itNext != it_end) {
359 isLarger = isLargerCal(*it, *itNext);
360
361 distance = distCal(*it, *itNext);
362 result = isLarger ? "larger " : "smaller";
363
364 if (isLarger == isLargerCal(*itNext, *it)) {
365 result = "duplicate";
366 } else if (!isLarger) {
367 result += " sorting problem ";
368 }
369 }
370 }
371
372 // second loop to print out aligned strings
373 unsigned int n = idStrings.size();
374 for (unsigned int i = 0; i < n; ++i) {
375 sout << " " << std::left << std::setw(idWidth) << idStrings[i] << std::right << " " << dataStrings[i];
376 if (i != n - 1) sout << std::endl;
377 }
378
379 return sout.str();
380 }
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space

◆ remove() [1/2]

bool Muon::MuPatHitTool::remove ( const Identifier & id,
MuPatHitList & hitList )
static

remove hit with a give Identifier

Definition at line 185 of file MuPatHitTool.cxx.

185 {
186 // loop over hit list
187 MuPatHitIt lit = hitList.begin(), lit_end = hitList.end();
188 for (; lit != lit_end; ++lit) {
189 const MuPatHit& hit = **lit;
190 if (hit.info().id == id) {
191 hitList.erase(lit);
192 return true;
193 }
194 }
195 // if we get here the hit was not found
196 return false;
197 }
MuPatHitList::iterator MuPatHitIt
Definition MuPatHit.h:28

◆ remove() [2/2]

bool Muon::MuPatHitTool::remove ( const Trk::MeasurementBase & meas,
MuPatHitList & hitList ) const

remove hit containing give measurement (uses pointer comparison)

Definition at line 199 of file MuPatHitTool.cxx.

199 {
200 // loop over hit list
201 const Identifier meas_id = m_edmHelperSvc->getIdentifier(meas);
202 MuPatHitIt lit = hitList.begin(), lit_end = hitList.end();
203 for (; lit != lit_end; ++lit) {
204 const MuPatHit& hit = **lit;
205 if (m_edmHelperSvc->getIdentifier(hit.preciseMeasurement()) == meas_id ||
206 m_edmHelperSvc->getIdentifier(hit.broadMeasurement()) == meas_id) {
207 hitList.erase(lit);
208 return true;
209 }
210 }
211 // if we get here the hit was not found
212 return false;
213 }

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ update()

bool Muon::MuPatHitTool::update ( const Trk::Track & track,
MuPatHitList & hitList ) const

update hit list for a give track

Definition at line 285 of file MuPatHitTool.cxx.

285 {
286 const DataVector<const Trk::MeasurementBase>* measurements = track.measurementsOnTrack();
287 if (!measurements) return false;
288
289 std::set<Identifier> ids;
290
293 for (; mit != mit_end; ++mit) {
294 Identifier id = m_edmHelperSvc->getIdentifier(**mit);
295 if (!id.is_valid()) continue;
296
297 if (!m_idHelperSvc->isMdt(id)) id = m_idHelperSvc->layerId(id);
298
299 ids.insert(id);
300 }
301
302 // loop over hit list
303 MuPatHitIt lit = hitList.begin(), lit_end = hitList.end();
304 for (; lit != lit_end; ++lit) {
305 MuPatHit& hit = **lit;
306 if (!ids.count(hit.info().id)) {
307 hit.info().status = MuPatHit::Outlier;
308 continue;
309 }
310 }
311 return true;
312 }
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_cscRotCreator

ToolHandle<IMuonClusterOnTrackCreator> Muon::MuPatHitTool::m_cscRotCreator
private
Initial value:
{
this,
"CscRotCreator",
"Muon::CscClusterOnTrackCreator/CscClusterOnTrackCreator",
}

Definition at line 123 of file MuPatHitTool.h.

123 {
124 this,
125 "CscRotCreator",
126 "Muon::CscClusterOnTrackCreator/CscClusterOnTrackCreator",
127 }; //<! tool to calibrate CSC hits

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_edmHelperSvc

ServiceHandle<IMuonEDMHelperSvc> Muon::MuPatHitTool::m_edmHelperSvc
private
Initial value:
{
this,
"edmHelper",
"Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
"Handle to the service providing the IMuonEDMHelperSvc interface",
}

Definition at line 145 of file MuPatHitTool.h.

145 {
146 this,
147 "edmHelper",
148 "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
149 "Handle to the service providing the IMuonEDMHelperSvc interface",
150 }; //<! multipurpose helper tool

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::MuPatHitTool::m_idHelperSvc
private
Initial value:
{
this,
"MuonIdHelperSvc",
"Muon::MuonIdHelperSvc/MuonIdHelperSvc",
}

Definition at line 140 of file MuPatHitTool.h.

140 {
141 this,
142 "MuonIdHelperSvc",
143 "Muon::MuonIdHelperSvc/MuonIdHelperSvc",
144 };

◆ m_isCosmic

Gaudi::Property<bool> Muon::MuPatHitTool::m_isCosmic
private
Initial value:
{this, "isCosmic", false,
"Toggle whether the job runs on cosmic data. That influences the hit sorting on track"}

Definition at line 154 of file MuPatHitTool.h.

154 {this, "isCosmic", false,
155 "Toggle whether the job runs on cosmic data. That influences the hit sorting on track"};

◆ m_magFieldProperties

Trk::MagneticFieldProperties Muon::MuPatHitTool::m_magFieldProperties {Trk::NoField}
private

magnetic field properties

Definition at line 152 of file MuPatHitTool.h.

152{Trk::NoField};
@ NoField
Field is set to 0., 0., 0.,.

◆ m_mdtRotCreator

ToolHandle<IMdtDriftCircleOnTrackCreator> Muon::MuPatHitTool::m_mdtRotCreator
private
Initial value:
{
this,
"MdtRotCreator",
"Muon::MdtDriftCircleOnTrackCreator/MdtDriftCircleOnTrackCreator",
}

Definition at line 118 of file MuPatHitTool.h.

118 {
119 this,
120 "MdtRotCreator",
121 "Muon::MdtDriftCircleOnTrackCreator/MdtDriftCircleOnTrackCreator",
122 }; //<! tool to calibrate MDT hits

◆ m_printer

PublicToolHandle<MuonEDMPrinterTool> Muon::MuPatHitTool::m_printer
private
Initial value:
{
this,
"Printer",
"Muon::MuonEDMPrinterTool/MuonEDMPrinterTool",
}

Definition at line 134 of file MuPatHitTool.h.

134 {
135 this,
136 "Printer",
137 "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool",
138 }; //<! tool to print EDM objects

◆ m_propagator

ToolHandle<Trk::IPropagator> Muon::MuPatHitTool::m_propagator
private
Initial value:
{
this,
"AtlasRungeKuttaPropagator",
"Trk::RungeKuttaPropagator/AtlasRungeKuttaPropagator",
}

Definition at line 113 of file MuPatHitTool.h.

113 {
114 this,
115 "AtlasRungeKuttaPropagator",
116 "Trk::RungeKuttaPropagator/AtlasRungeKuttaPropagator",
117 };

◆ m_pullCalculator

ToolHandle<Trk::IResidualPullCalculator> Muon::MuPatHitTool::m_pullCalculator
private
Initial value:
{
this,
"ResidualPullCalculator",
"Trk::ResidualPullCalculator/ResidualPullCalculator",
}

Definition at line 129 of file MuPatHitTool.h.

129 {
130 this,
131 "ResidualPullCalculator",
132 "Trk::ResidualPullCalculator/ResidualPullCalculator",
133 }; //<! tool to calculate residuals and pulls

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: