ATLAS Offline Software
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 //____________________________________________________________________
34  m_nhits_pixel(0), m_nhits_sct(0), m_nhits_trt(0), m_nhits_muon_phi(0), m_nhits_rpc(0), m_nhits_mdt(0),
35  m_nhits_tgc(0), m_nhits_csc(0), m_nhits_mm(0), m_nhits_stgc(0), m_hitInfoStatus(-1),
36  m_segment(segment), m_points(nullptr)
37 {
38 }
39 //____________________________________________________________________
41 {
42  delete m_points;
43 }
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)
85  }
86  }
87 }
88 
89 //____________________________________________________________________
91 {
93  static_cast<TrackCollHandle_TrkSegment*>(collHandle())->visibleStateUpdated(this);
94 }
95 
96 //____________________________________________________________________
98 {
99  if (visible())
100  static_cast<TrackCollHandle_TrkSegment*>(collHandle())->visibleStateUpdated(this);
101 }
102 
103 //____________________________________________________________________
105 {
106  if (m_hitInfoStatus==-1)
108 }
109 
110 //____________________________________________________________________
111 const std::vector< Amg::Vector3D > * TrackHandle_TrkSegment::provide_pathInfoPoints()
112 {
113  if (!m_points) {
114  m_points = new std::vector< Amg::Vector3D >;
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];
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 
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 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TrackHandle_TrkSegment::m_nhits_trt
unsigned m_nhits_trt
Definition: TrackHandle_TrkSegment.h:59
TrackSysCommonData::muonChamberProjectionHelper
MuonChamberProjectionHelper * muonChamberProjectionHelper() const
Definition: TrackSysCommonData.h:125
TrackHandleBase::touchedMuonChambers
const std::set< GeoPVConstLink > & touchedMuonChambers() const
Definition: TrackHandleBase.cxx:1275
TrackHandleBase::visibleStateChanged
virtual void visibleStateChanged()
override if need to take action in this case.
Definition: TrackHandleBase.cxx:2029
TrackCollHandleBase
Definition: TrackCollHandleBase.h:49
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
TrackSysCommonData::controller
TrackSystemController * controller() const
Definition: TrackSysCommonData.h:124
TrackHandleBase::registerTouchedMuonChamber
void registerTouchedMuonChamber(const GeoPVConstLink &) const
If not earlier, touched muon chambers must me registered at latest when this method is invoked.
Definition: TrackHandleBase.cxx:1269
TrackHandle_TrkSegment::m_nhits_mdt
unsigned m_nhits_mdt
Definition: TrackHandle_TrkSegment.h:62
MeasurementBase.h
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
TrackHandle_TrkSegment.h
TrackSystemController.h
Surface.h
MuonEDMPrinterTool.h
TrackHandle_TrkSegment::m_nhits_mm
unsigned m_nhits_mm
Definition: TrackHandle_TrkSegment.h:65
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
VP1Msg.h
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition: VP1HelperClassBase.cxx:78
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
TrackHandleBase::collHandle
TrackCollHandleBase * collHandle() const
Definition: TrackHandleBase.h:68
TrackHandle_TrkSegment::clicked
QStringList clicked() const
Called when user selects the node (stringlist is displayed in messagebox).
Definition: TrackHandle_TrkSegment.cxx:46
TrackHandle_TrkSegment::provide_pathInfoPoints
const std::vector< Amg::Vector3D > * provide_pathInfoPoints()
Definition: TrackHandle_TrkSegment.cxx:111
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Trk::loc2
@ loc2
generic first and second local coordinate
Definition: ParamDefs.h:35
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
TrackCollHandle_TrkSegment.h
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
TrackHandle_TrkSegment::visibleStateChanged
void visibleStateChanged()
override if need to take action in this case.
Definition: TrackHandle_TrkSegment.cxx:90
VP1HelperClassBase::messageDebug
void messageDebug(const QString &) const
Definition: VP1HelperClassBase.cxx:65
TrackHandle_TrkSegment::m_nhits_stgc
unsigned m_nhits_stgc
Definition: TrackHandle_TrkSegment.h:66
TrackHandle_TrkSegment::m_nhits_muon_phi
unsigned m_nhits_muon_phi
Definition: TrackHandle_TrkSegment.h:60
TruthTest.itE
itE
Definition: TruthTest.py:25
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
TrackHandleBase::getMuonReadoutElement
virtual const MuonGM::MuonReadoutElement * getMuonReadoutElement(const Trk::RIO_OnTrack &mb) const
Definition: TrackHandleBase.cxx:1966
MuonGM::MuonReadoutElement
Base class for the XxxReadoutElement, with Xxx = Mdt, Rpc, Tgc, Csc.
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:40
TrackHandle_TrkSegment::m_points
std::vector< Amg::Vector3D > * m_points
Definition: TrackHandle_TrkSegment.h:70
TrackHandle_TrkSegment::m_segment
const Trk::Segment * m_segment
Definition: TrackHandle_TrkSegment.h:69
Muon::MuonEDMPrinterTool::print
std::string print(const Trk::Track &track) const
print track parameters to string
Definition: MuonEDMPrinterTool.cxx:279
MuonChamberProjectionHelper::clipLineSegmentToMDTChamber
bool clipLineSegmentToMDTChamber(const GeoPVConstLink &mdtChamber, Amg::Vector3D &pointA, Amg::Vector3D &pointB, bool &outsidechamber, const double &extradist=0.0)
Definition: MuonChamberProjectionHelper.cxx:482
TrackCollHandle_TrkSegment
Definition: TrackCollHandle_TrkSegment.h:25
TrackHandle_TrkSegment::m_nhits_csc
unsigned m_nhits_csc
Definition: TrackHandle_TrkSegment.h:64
TrackHandle_TrkSegment::m_hitInfoStatus
int m_hitInfoStatus
-1: uninitialized, 0: not present, 1: present.
Definition: TrackHandle_TrkSegment.h:67
TrackSystemController::muonEDMPrinterTool
Muon::MuonEDMPrinterTool * muonEDMPrinterTool() const
Definition: TrackSystemController.cxx:1680
TrackHandleBase::visible
bool visible() const
Definition: TrackHandleBase.h:67
Trk::theta
@ theta
Definition: ParamDefs.h:66
TrackHandle_TrkSegment::m_nhits_tgc
unsigned m_nhits_tgc
Definition: TrackHandle_TrkSegment.h:63
TrackHandle_TrkSegment::m_nhits_rpc
unsigned m_nhits_rpc
Definition: TrackHandle_TrkSegment.h:61
Trk::Segment::containedMeasurements
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects
Definition: Tracking/TrkEvent/TrkSegment/TrkSegment/Segment.h:166
Trk::Segment
Definition: Tracking/TrkEvent/TrkSegment/TrkSegment/Segment.h:56
VP1TrackSummary.h
MuonReadoutElement.h
TrackHandle_TrkSegment::currentMaterialChanged
void currentMaterialChanged()
Definition: TrackHandle_TrkSegment.cxx:97
TrackHandleBase::common
TrackSysCommonData * common() const
Definition: TrackHandleBase.cxx:255
Trk::MeasurementBase
Definition: MeasurementBase.h:58
TrackHandle_TrkSegment::~TrackHandle_TrkSegment
virtual ~TrackHandle_TrkSegment()
Definition: TrackHandle_TrkSegment.cxx:40
Trk::MeasurementBase::associatedSurface
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonChamberProjectionHelper.h
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
Trk::MeasurementBase::localParameters
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Definition: MeasurementBase.h:132
TrackHandle_TrkSegment::TrackHandle_TrkSegment
TrackHandle_TrkSegment(TrackCollHandleBase *, const Trk::Segment *)
Definition: TrackHandle_TrkSegment.cxx:32
TrackHandle_TrkSegment::ensureTouchedMuonChambersInitialised
void ensureTouchedMuonChambersInitialised() const
Definition: TrackHandle_TrkSegment.cxx:68
a
TList * a
Definition: liststreamerinfos.cxx:10
VP1HelperClassBase::message
void message(const QString &) const
Definition: VP1HelperClassBase.cxx:49
MuonSegment.h
TrackHandle_TrkSegment::m_nhits_pixel
unsigned m_nhits_pixel
Definition: TrackHandle_TrkSegment.h:57
TrackHandleBase::baseInfo
QStringList baseInfo() const
Definition: TrackHandleBase.cxx:1551
VP1JobConfigInfo.h
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
Muon::MuonSegment
Definition: MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonSegment/MuonSegment/MuonSegment.h:45
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
VP1TrackSummary::countHits
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)
Definition: VP1TrackSummary.cxx:30
TrackHandleBase
Definition: TrackHandleBase.h:56
Trk::loc1
@ loc1
Definition: ParamDefs.h:34
VP1JobConfigInfo::hasMuonGeometry
static bool hasMuonGeometry()
Definition: VP1JobConfigInfo.cxx:134
TrackHandle_TrkSegment::m_nhits_sct
unsigned m_nhits_sct
Definition: TrackHandle_TrkSegment.h:58
MuonGM::MuonReadoutElement::parentStationPV
PVConstLink parentStationPV() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:100
Trk::phi0
@ phi0
Definition: ParamDefs.h:65
Trk::Surface::localToGlobal
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const =0
Specified by each surface type: LocalToGlobal method without dynamic memory allocation.
Segment.h
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
TrackHandle_TrkSegment::ensureInitSubSysHitInfo
void ensureInitSubSysHitInfo() const
Definition: TrackHandle_TrkSegment.cxx:104