ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
Muon::MuonEDMHelperSvc Class Reference

Helper tool containing functionality needed by multiple tools. More...

#include <MuonEDMHelperSvc.h>

Inheritance diagram for Muon::MuonEDMHelperSvc:
Collaboration diagram for Muon::MuonEDMHelperSvc:

Public Member Functions

 MuonEDMHelperSvc (const std::string &name, ISvcLocator *svc)
 default AlgService constructor More...
 
virtual ~MuonEDMHelperSvc () override
 destructor More...
 
virtual StatusCode initialize () override
 initialize method, method taken from bass-class AlgTool More...
 
virtual Identifier getIdentifier (const Trk::MeasurementBase &meas) const override
 tries to get Identifier for measurement, if not possible it will return Identifier() More...
 
virtual Identifier chamberId (const MuonSegment &seg) const override
 returns the first MDT or CSC identifier of the segment More...
 
virtual std::set< IdentifierchamberIds (const MuonSegment &seg) const override
 returns a set containing the chamber Ids of all MDT or CSC chambers on the segment More...
 
virtual bool isEndcap (const MuonSegment &seg) const override
 returns whether the segment is in the endcap More...
 
virtual bool isEndcap (const Trk::Track &seg) const override
 returns whether the track is in the endcap More...
 
virtual const Trk::AtaPlanecreateTrackParameters (const MuonSegment &seg, double momentum=1., double charge=0.) const override
 brief create a AtaPlane track parameter for segment More...
 
virtual bool goodTrack (const Trk::Track &track, double chi2Cut) const override
 check whether track satisfies selection chi2 cut More...
 
virtual bool isSLTrack (const Trk::Track &track) const override
 determines whether a track is a straight line track (no momentum fitted). More...
 

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 

Detailed Description

Helper tool containing functionality needed by multiple tools.

Definition at line 33 of file MuonEDMHelperSvc.h.

Constructor & Destructor Documentation

◆ MuonEDMHelperSvc()

Muon::MuonEDMHelperSvc::MuonEDMHelperSvc ( const std::string &  name,
ISvcLocator *  svc 
)

default AlgService constructor

Definition at line 24 of file MuonEDMHelperSvc.cxx.

24 : base_class(name, svc) {}

◆ ~MuonEDMHelperSvc()

virtual Muon::MuonEDMHelperSvc::~MuonEDMHelperSvc ( )
inlineoverridevirtual

destructor

Definition at line 39 of file MuonEDMHelperSvc.h.

39 {};

Member Function Documentation

◆ chamberId()

Identifier Muon::MuonEDMHelperSvc::chamberId ( const MuonSegment seg) const
overridevirtual

returns the first MDT or CSC identifier of the segment

Definition at line 50 of file MuonEDMHelperSvc.cxx.

50  {
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  }

◆ chamberIds()

std::set< Identifier > Muon::MuonEDMHelperSvc::chamberIds ( const MuonSegment seg) const
overridevirtual

returns a set containing the chamber Ids of all MDT or CSC chambers on the segment

Definition at line 72 of file MuonEDMHelperSvc.cxx.

72  {
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  }

◆ createTrackParameters()

const Trk::AtaPlane * Muon::MuonEDMHelperSvc::createTrackParameters ( const MuonSegment seg,
double  momentum = 1.,
double  charge = 0. 
) const
overridevirtual

brief create a AtaPlane track parameter for segment

Definition at line 119 of file MuonEDMHelperSvc.cxx.

119  {
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*>(
130  seg.associatedSurface()
131  .createUniqueParameters<5, Trk::Charged>(locx,
132  locy,
133  seg.globalDirection().phi(),
134  seg.globalDirection().theta(),
135  qoverp)
136  .release());
137  }

◆ getIdentifier()

Identifier Muon::MuonEDMHelperSvc::getIdentifier ( const Trk::MeasurementBase meas) const
overridevirtual

tries to get Identifier for measurement, if not possible it will return Identifier()

Definition at line 31 of file MuonEDMHelperSvc.cxx.

31  {
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  }

◆ goodTrack()

bool Muon::MuonEDMHelperSvc::goodTrack ( const Trk::Track track,
double  chi2Cut 
) const
overridevirtual

check whether track satisfies selection chi2 cut

Definition at line 139 of file MuonEDMHelperSvc.cxx.

139  {
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  }

◆ initialize()

StatusCode Muon::MuonEDMHelperSvc::initialize ( )
overridevirtual

initialize method, method taken from bass-class AlgTool

Definition at line 25 of file MuonEDMHelperSvc.cxx.

25  {
27  ATH_CHECK(m_idHelperSvc.retrieve());
28  return StatusCode::SUCCESS;
29  }

◆ isEndcap() [1/2]

bool Muon::MuonEDMHelperSvc::isEndcap ( const MuonSegment seg) const
overridevirtual

returns whether the segment is in the endcap

Definition at line 97 of file MuonEDMHelperSvc.cxx.

97  {
98  return m_idHelperSvc->isEndcap( chamberId(seg) );
99  }

◆ isEndcap() [2/2]

bool Muon::MuonEDMHelperSvc::isEndcap ( const Trk::Track seg) const
overridevirtual

returns whether the track is in the endcap

Definition at line 101 of file MuonEDMHelperSvc.cxx.

101  {
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  }

◆ isSLTrack()

bool Muon::MuonEDMHelperSvc::isSLTrack ( const Trk::Track track) const
overridevirtual

determines whether a track is a straight line track (no momentum fitted).

sum covariance terms of momentum, use it to determine whether fit was SL fit

Definition at line 152 of file MuonEDMHelperSvc.cxx.

152  {
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  }

Member Data Documentation

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::MuonEDMHelperSvc::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 69 of file MuonEDMHelperSvc.h.


The documentation for this class was generated from the following files:
Trk::locX
@ locX
Definition: ParamDefs.h:43
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:44
DataVector::rend
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
initialize
void initialize()
Definition: run_EoverP.cxx:894
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
Muon::MuonEDMHelperSvc::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonEDMHelperSvc.h:69
Trk::Charged
Definition: Charged.h:27
Trk::TrackInfo::StraightTrack
@ StraightTrack
A straight track.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:84
Muon::MuonEDMHelperSvc::getIdentifier
virtual Identifier getIdentifier(const Trk::MeasurementBase &meas) const override
tries to get Identifier for measurement, if not possible it will return Identifier()
Definition: MuonEDMHelperSvc.cxx:31
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::FitQuality
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition: FitQuality.h:97
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
DataVector< const Trk::MeasurementBase >
DataVector::rbegin
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
Trk::MeasurementBase
Definition: MeasurementBase.h:58
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
charge
double charge(const T &p)
Definition: AtlasPID.h:494
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Muon::MuonEDMHelperSvc::chamberId
virtual Identifier chamberId(const MuonSegment &seg) const override
returns the first MDT or CSC identifier of the segment
Definition: MuonEDMHelperSvc.cxx:50
Trk::RIO_OnTrack::identify
virtual Identifier identify() const final
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:155
Trk::FitQuality::chiSquared
double chiSquared() const
returns the of the overall track fit
Definition: FitQuality.h:56
Trk::FitQuality::numberDoF
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition: FitQuality.h:60
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Muon::release
std::vector< ObjType * > release(std::vector< std::unique_ptr< ObjType >> &objVec)
Definition: MuonSpectrometer/MuonDetDescr/MuonTrackingGeometry/MuonTrackingGeometry/Utils.h:18