ATLAS Offline Software
Loading...
Searching...
No Matches
TrackHandle_TrkSegment.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7// //
8// Implementation of class TrackHandle_TrkSegment //
9// //
10// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11// Initial version: February 2008 //
12// //
14
19#include "VP1Base/VP1Msg.h"
21#include "TrkSegment/Segment.h"
22#include "TrkSurfaces/Surface.h"
25
29
30
31//____________________________________________________________________
39//____________________________________________________________________
44
45//____________________________________________________________________
47{
48 QStringList l;
49 l << "Trk::Segment";//fixme - more info
51
52 const Muon::MuonSegment* muonSegment = dynamic_cast<const Muon::MuonSegment*>(m_segment);
53 if (muonSegment && common()->controller()->muonEDMPrinterTool()) {
54 std::string temp = common()->controller()->muonEDMPrinterTool()->print(*muonSegment);
55 l << QString(temp.c_str());
56 }
57
58 if (m_segment&&common()->controller()->printVerboseInfoOnSingleSelection()) {
59 l << " ===== dump =====";
60 std::ostringstream s;
61 s << *m_segment;
62 l << QString(s.str().c_str()).split('\n');
63 }
64 return l;
65}
66
67//____________________________________________________________________
69{
71 if (VP1Msg::verbose())
73 return;
74 }
75 const Trk::MeasurementBase* meas;
76 const MuonGM::MuonReadoutElement* muonDetEl;
77 std::vector < const Trk::MeasurementBase * >::const_iterator tsos_iter, tsos_end(m_segment->containedMeasurements().end());
78 for (tsos_iter = m_segment->containedMeasurements().begin(); tsos_iter != tsos_end; ++tsos_iter) {
79 meas = *tsos_iter;
80 const Trk::RIO_OnTrack* rio = dynamic_cast<const Trk::RIO_OnTrack*>(meas);
81 if (rio) {
82 muonDetEl = getMuonReadoutElement(*rio);
83 if (muonDetEl)
84 registerTouchedMuonChamber(muonDetEl->getMaterialGeom()->getParent());
85 }
86 }
87}
88
89//____________________________________________________________________
95
96//____________________________________________________________________
98{
99 if (visible())
100 static_cast<TrackCollHandle_TrkSegment*>(collHandle())->visibleStateUpdated(this);
101}
102
103//____________________________________________________________________
109
110//____________________________________________________________________
111const std::vector< Amg::Vector3D > * TrackHandle_TrkSegment::provide_pathInfoPoints()
112{
113 if (!m_points) {
114 m_points = new std::vector< Amg::Vector3D >;
115 std::set<GeoPVConstLink>::iterator it(touchedMuonChambers().begin()), itE(touchedMuonChambers().end());
116 const bool muonsegment = it!=itE;
117
119 // Find the two endpoints of the segment: //
121 double radius = ( muonsegment ? 1000.0 : 150.0 );//A bit arbitrary for ID segments.
122
123 double xOffset(0),yOffset(0),zOffset(0);
124 if (muonsegment) {
125 //Fixme: jobconfig safety.
126 double phi = m_segment->localParameters()[Trk::phi0];
127 double theta = m_segment->localParameters()[Trk::theta];
128 xOffset = radius*cos(phi)*sin(theta);
129 yOffset = radius*sin(phi)*sin(theta);
130 zOffset = radius*cos(theta);
131 }
132
133 //TK: Fixme: globalPosition can cause a crash!
134
135 Amg::Vector2D localPos(m_segment->localParameters()[Trk::loc1], m_segment->localParameters()[Trk::loc2]);
136 const Amg::Vector3D globalPos = m_segment->associatedSurface().localToGlobal(localPos);
137 Amg::Vector3D pointA(globalPos.x()-xOffset,globalPos.y()-yOffset,globalPos.z()-zOffset);
138 Amg::Vector3D pointB(globalPos.x()+xOffset,globalPos.y()+yOffset,globalPos.z()+zOffset);
139
140 bool hasnonmdtchamber(false);
141 bool outsidechamber, success;
142 if (muonsegment) {
143 for (;it!=itE;++it) {
144 if (true||/*FIXME: TEMPORARY DISABLE CLIPPING DUE TO BUG IN clipLineSegmentToMDTChamber*/
145 !common()->muonChamberProjectionHelper()->isKnownMDTChamber(*it)) {
146 hasnonmdtchamber = true;
147 break;
148 }
149 Amg::Vector3D a(pointA),b(pointB);
150 success = common()->muonChamberProjectionHelper()->clipLineSegmentToMDTChamber( *it,a,b, outsidechamber,200.0 );
151 if (!success) {
152 collHandle()->message("Error: Something we wrong with clipLineSegmentToMDTChamber");
153 continue;
154 }
155 if (outsidechamber) {
156 collHandle()->messageDebug("WARNING: Segment is outside a chamber that it is touching!");
157 continue;
158 }
159 m_points->push_back(a);
160 m_points->push_back(b);
161 }
162 if (hasnonmdtchamber) {
163 m_points->clear();//Fixme: ok?
164 m_points->push_back(pointA);
165 m_points->push_back(pointB);
166 } else if (m_points->size()>2) {
167 if (VP1Msg::verbose())
168 collHandle()->messageVerbose("Combining segment points into a single line!");
169 (*m_points)[1] = m_points->back();
170 m_points->resize(2);
171 }
172 } else {
173 //Fixme: Do we need something better for ID segments?
174 m_points->push_back(pointA);
175 m_points->push_back(pointB);
176 }
177
178 }
179 return m_points;
180}
Scalar phi() const
phi method
Scalar theta() const
theta method
static Double_t a
bool clipLineSegmentToMDTChamber(const GeoPVConstLink &mdtChamber, Amg::Vector3D &pointA, Amg::Vector3D &pointB, bool &outsidechamber, const double &extradist=0.0)
Base class for the XxxReadoutElement, with Xxx = Mdt, Rpc, Tgc, Csc.
std::string print(const Trk::Track &track) const
print track parameters to string
This is the common class for 3D segments used in the muon spectrometer.
void registerTouchedMuonChamber(const GeoPVConstLink &) const
If not earlier, touched muon chambers must me registered at latest when this method is invoked.
const std::set< GeoPVConstLink > & touchedMuonChambers() const
virtual void visibleStateChanged()
override if need to take action in this case.
friend class TrackCollHandleBase
TrackHandleBase(TrackCollHandleBase *)
QStringList baseInfo() const
virtual const MuonGM::MuonReadoutElement * getMuonReadoutElement(const Trk::RIO_OnTrack &mb) const
bool visible() const
TrackCollHandleBase * collHandle() const
TrackSysCommonData * common() const
std::vector< Amg::Vector3D > * m_points
int m_hitInfoStatus
-1: uninitialized, 0: not present, 1: present.
const Trk::Segment * m_segment
void visibleStateChanged()
override if need to take action in this case.
QStringList clicked() const
Called when user selects the node (stringlist is displayed in messagebox).
const std::vector< Amg::Vector3D > * provide_pathInfoPoints()
TrackHandle_TrkSegment(TrackCollHandleBase *, const Trk::Segment *)
void ensureTouchedMuonChambersInitialised() const
MuonChamberProjectionHelper * muonChamberProjectionHelper() const
TrackSystemController * controller() const
Muon::MuonEDMPrinterTool * muonEDMPrinterTool() const
This class is the pure abstract base class for all fittable tracking measurements.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
Base class for all TrackSegment implementations, extends the common MeasurementBase.
void messageVerbose(const QString &) const
void message(const QString &) const
void messageDebug(const QString &) const
static bool hasMuonGeometry()
static bool verbose()
Definition VP1Msg.h:31
static bool countHits(const Trk::Track *, unsigned &nPixelHits, unsigned &nSCTHits, unsigned &nTRTHits, unsigned &nhits_muon_phi, unsigned &nhits_rpc, unsigned &nhits_mdt, unsigned &nhits_tgc, unsigned &nhits_csc, unsigned &nhits_mm, unsigned &nhits_stgc)
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
@ phi0
Definition ParamDefs.h:65
@ theta
Definition ParamDefs.h:66
@ loc2
generic first and second local coordinate
Definition ParamDefs.h:35
@ loc1
Definition ParamDefs.h:34