ATLAS Offline Software
Loading...
Searching...
No Matches
MuonEDMHelperSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6
13
16
19
20#include "TrkTrack/Track.h"
21
22namespace Muon {
23
24 MuonEDMHelperSvc::MuonEDMHelperSvc(const std::string& name, ISvcLocator* svc) : base_class(name, svc) {}
26 ATH_CHECK(AthService::initialize());
27 ATH_CHECK(m_idHelperSvc.retrieve());
28 return StatusCode::SUCCESS;
29 }
30
32 const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(&meas);
33 if( rot ) return rot->identify();
34 const CompetingMuonClustersOnTrack* crot = dynamic_cast<const CompetingMuonClustersOnTrack*>(&meas);
35 if( crot ) {
36 if( crot->containedROTs().empty() ){
37 ATH_MSG_WARNING(" CompetingMuonClustersOnTrack without contained ROTs ");
38 return {};
39 }
40 if( !crot->containedROTs().front() ) {
41 ATH_MSG_WARNING(" CompetingMuonClustersOnTrack contains a ROT pointer that is zero ");
42 return {};
43 }
44 return crot->containedROTs().front()->identify();
45 }
46 return {};
47 }
48
49
51 Identifier chid;
52 for(const Trk::MeasurementBase* meas : seg.containedMeasurements()){
53
54 // get Identifier
55 Identifier id = getIdentifier(*meas);
56 if( !id.is_valid() ) continue;
57
58 // create chamber ID
59 chid = m_idHelperSvc->chamberId(id);
60
61 // stop at first none trigger hit
62 if( !m_idHelperSvc->isTrigger(id) ) break;
63 }
64
65 if( !chid.is_valid() ){
66 ATH_MSG_WARNING("Got segment without valid identifiers");
67 }
68
69 return chid;
70 }
71
72 std::set<Identifier> MuonEDMHelperSvc::chamberIds( const MuonSegment& seg ) const {
73
74 std::set<Identifier> chIds;
75 Identifier chid;
76 Identifier chidTrig;
77 for(const Trk::MeasurementBase* meas : seg.containedMeasurements()){
78
79 // get Identifier
80 Identifier id = getIdentifier(*meas);
81 if( !id.is_valid() ) continue;
82
83 // create chamber ID
84 chid = m_idHelperSvc->chamberId(id);
85
86 // stop at first none trigger hit
87 if( !m_idHelperSvc->isTrigger(id) ) chIds.insert(chid);
88 else chidTrig = chid;
89 }
90 if( chIds.empty() ) {
91 chIds.insert(chidTrig);
92 }
93
94 return chIds;
95 }
96
97 bool MuonEDMHelperSvc::isEndcap( const MuonSegment& seg ) const {
98 return m_idHelperSvc->isEndcap( chamberId(seg) );
99 }
100
101 bool MuonEDMHelperSvc::isEndcap( const Trk::Track& track ) const {
102
103 const DataVector<const Trk::MeasurementBase>* measurements = track.measurementsOnTrack();
104 if( !measurements ) return true;
105
106 // loop over measurements in reversed order (should be faster as endcap hits tend to be at the end of the track)
109 for( ;rit!=rit_end;++rit ){
110 Identifier id = getIdentifier(**rit);
111 if( !id.is_valid() ) continue;
112
113 if( m_idHelperSvc->isEndcap(id) ) return true;
114 }
115 return false;
116 }
117
118
119 const Trk::AtaPlane* MuonEDMHelperSvc::createTrackParameters( const MuonSegment& seg, double momentum, double charge ) const {
120
121 // we need a none zero momentum
122 if( momentum == 0. ) {
123 ATH_MSG_WARNING(" cannot create parameters with zero momentum ");
124 return nullptr;
125 }
126 double locx = seg.localParameters().contains(Trk::locX) ? seg.localParameters()[Trk::locX] : 0.;
127 double locy = seg.localParameters().contains(Trk::locY) ? seg.localParameters()[Trk::locY] : 0.;
128 double qoverp = charge/momentum;
129 return dynamic_cast<const Trk::AtaPlane*>(
131 .createUniqueParameters<5, Trk::Charged>(locx,
132 locy,
133 seg.globalDirection().phi(),
134 seg.globalDirection().theta(),
135 qoverp)
136 .release());
137 }
138
139 bool MuonEDMHelperSvc::goodTrack( const Trk::Track& track, double chi2Cut ) const {
140
141 // get reduced chi2
142 const Trk::FitQuality* fq = track.fitQuality();
143 if( !fq || fq->numberDoF() == 0 ){
144 return false;
145 }
146
147 double reducedChi2 = fq->chiSquared()/fq->numberDoF();
148 // reject fit if larger than cut
149 return reducedChi2 <= chi2Cut;
150 }
151
152 bool MuonEDMHelperSvc::isSLTrack( const Trk::Track& track ) const {
153 // use track info if set properly
154 if( track.info().trackProperties(Trk::TrackInfo::StraightTrack) ) return true;
155
156 // else try using error matrix
157 const Trk::Perigee* pp = track.perigeeParameters();
158 if (!pp || !pp->covariance()) return false;
160 double momCov = 0.;
161 for( int i=0;i<4;++i ) momCov += std::abs( (*pp->covariance())(4,i) );
162 return momCov < 1.e-10;
163 }
164} //end of namespace
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
double charge(const T &p)
Definition AtlasPID.h:997
Derived DataVector<T>.
Definition DataVector.h:795
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
std::reverse_iterator< const_iterator > const_reverse_iterator
Standard const_reverse_iterator.
Definition DataVector.h:847
bool is_valid() const
Check if id is in a valid state.
Class for competing MuonClusters, it extends the Trk::CompetingRIOsOnTrack base class.
const std::vector< const MuonClusterOnTrack * > & containedROTs() const
returns the vector of SCT_ClusterOnTrack objects .
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode initialize() override
initialize method, method taken from bass-class AlgTool
virtual std::set< Identifier > chamberIds(const MuonSegment &seg) const override
returns a set containing the chamber Ids of all MDT or CSC chambers on the segment
MuonEDMHelperSvc(const std::string &name, ISvcLocator *svc)
default AlgService constructor
virtual bool isSLTrack(const Trk::Track &track) const override
determines whether a track is a straight line track (no momentum fitted).
virtual bool isEndcap(const MuonSegment &seg) const override
returns whether the segment is in the endcap
virtual Identifier getIdentifier(const Trk::MeasurementBase &meas) const override
tries to get Identifier for measurement, if not possible it will return Identifier()
virtual const Trk::AtaPlane * createTrackParameters(const MuonSegment &seg, double momentum=1., double charge=0.) const override
brief create a AtaPlane track parameter for segment
virtual Identifier chamberId(const MuonSegment &seg) const override
returns the first MDT or CSC identifier of the segment
virtual bool goodTrack(const Trk::Track &track, double chi2Cut) const override
check whether track satisfies selection chi2 cut
This is the common class for 3D segments used in the muon spectrometer.
virtual const Trk::PlaneSurface & associatedSurface() const override final
returns the surface for the local to global transformation
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition FitQuality.h:97
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition FitQuality.h:60
double chiSquared() const
returns the of the overall track fit
Definition FitQuality.h:56
bool contains(ParamDefs par) const
The simple check for the clients whether the parameter is contained.
This class is the pure abstract base class for all fittable tracking measurements.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
Identifier identify() const
return the identifier -extends MeasurementBase
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane