24#include "Identifier/Identifier.h"
30#include "CLHEP/Units/SystemOfUnits.h"
31#include "CLHEP/Geometry/Transform3D.h"
42 declareInterface<ITrackHoleSearchTool>(
this);
63 return StatusCode::SUCCESS;
71 return StatusCode::SUCCESS;
77 std::vector<int>& information ,
103 if (track.perigeeParameters()) {
105 <<
" pT = " << track.perigeeParameters()->pT()/CLHEP::GeV <<
" CLHEP::GeV\n"
106 <<
" eta = " << track.perigeeParameters()->eta() <<
"\n"
107 <<
" phi = " << track.perigeeParameters()->parameters()[
Trk::phi0] <<
"\n"
108 <<
" d0 = " << track.perigeeParameters()->parameters()[
Trk::d0] <<
"\n"
109 <<
" z0 = " << track.perigeeParameters()->parameters()[
Trk::z0] );
115 ATH_MSG_DEBUG(
" This track has " << track_states->
size() <<
" track states on surface." );
117 ATH_MSG_WARNING(
" This track has null track states on surface. Returning 0." );
121 if (track_states->
size() < 2) {
134 if (beginning_track_state == track_states->
end()) {
135 ATH_MSG_WARNING(
" beginning_track_state == track_states->end(). There must be no Si hits.\n"
136 <<
" Will try to begin at the first TRT hit." );
141 if (beginning_track_state == track_states->
end()) {
142 ATH_MSG_WARNING(
" beginning_track_state == track_states->end(). No where to extrapolate to. Returning 0." );
153 for (; track_state != track_states->
end(); ++track_state) {
156 ATH_MSG_VERBOSE(
" TrackStateOnSurface is not of type Trk::TrackStateOnSurface::Measurement." );
163 << end_parameters->
position().x() <<
", "
164 << end_parameters->
position().y() <<
", "
165 << end_parameters->
position().z() <<
"); (rho, eta, phi) = ("
166 << end_parameters->
position().perp() <<
", "
167 << end_parameters->
position().eta() <<
", "
168 << end_parameters->
position().phi() <<
")");
175 if (!start_parameters) {
176 start_parameters = end_parameters;
179 start_parameters = end_parameters;
189 ATH_MSG_DEBUG(
"There are " << trailing_hole_count <<
" trailing holes removed.");
190 for(
int i=0; i < trailing_hole_count; i++) {
206 ATH_MSG_DEBUG(
"TRTTrackHoleSearchTool::getTrackWithHoles" );
217 ATH_MSG_DEBUG(
"TRTTrackHoleSearchTool::getTrackWithHolesAndOutliers" );
240 std::vector<std::unique_ptr<Trk::TrackParameters> > steps =
241 m_extrapolator->extrapolateStepwise(Gaudi::Hive::currentContext(),
248 ATH_MSG_DEBUG(
"extrapolateBetweenHits: extrapolateStepwise returned null");
252 for(std::vector<std::unique_ptr<Trk::TrackParameters> >
::const_iterator step = steps.begin(); step != steps.end()-1; ++step) {
254 const Trk::Surface& surf = (*step)->associatedSurface();
261 ATH_MSG_DEBUG(
"extrapolateBetweenHits: surf is not a TRT straw. Skipping.");
266 if(
id == previous_id) {
278 if(
id == 0xffffffff) {
279 ATH_MSG_DEBUG(
"extrapolateBetweenHits: id == 0xffffffff. Skipping.");
285 ATH_MSG_DEBUG(
"extrapolateBetweenHits: ConditionsSvc says this straw is bad. Skipping.");
290 const float locR = (*step)->parameters()[
Trk::locR];
308 ATH_MSG_WARNING(
"extrapolateBetweenHits: Track parameters failed to dynamic_cast< const Trk::MeasuredTrackParameters* >.");
319 const float locZ = (*step)->parameters()[
Trk::locZ];
323 if( fabs(locZ) > halfz -
m_locZ_cut )
continue;
325 ATH_MSG_WARNING(
"extrapolateBetweenHits: Surface failed to dynamic_cast to Trk::CylinderBounds. Skipping.");
331 ATH_MSG_DEBUG(
" HOLE Found! Identifier = " <<
id.getString() <<
" indicates:\n"
332 <<
" is_pixel = " <<
m_TRT_ID->is_pixel(
id) <<
"\n"
333 <<
" is_sct = " <<
m_TRT_ID->is_sct(
id) <<
"\n"
334 <<
" is_trt = " <<
m_TRT_ID->is_trt(
id) <<
"\n"
335 <<
" barrel_ec = " <<
m_TRT_ID->barrel_ec(
id) <<
"\n"
336 <<
" phi_module = " <<
m_TRT_ID->phi_module(
id) <<
"\n"
337 <<
" layer_or_wheel = " <<
m_TRT_ID->layer_or_wheel(
id) <<
"\n"
338 <<
" straw_layer = " <<
m_TRT_ID->straw_layer(
id) <<
"\n"
339 <<
" straw = " <<
m_TRT_ID->straw(
id) <<
"\n"
340 <<
" rho = " << (*step)->position().perp() );
342 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
355 ATH_MSG_DEBUG(
"TRTTrackHoleSearchTool::dump_bad_straw_log" );
356 std::ofstream out(
"TRT_ConditionsSummarySvc_bad_straws.log");
357 out <<
"# id barrel_ec phi_module layer_or_wheel straw_layer straw" << std::endl;
358 for(std::vector<Identifier>::const_iterator it =
m_TRT_ID->straw_layer_begin(); it !=
m_TRT_ID->straw_layer_end(); ++it) {
359 for(
int i=0; i<=
m_TRT_ID->straw_max(*it); ++i) {
362 out <<
id.getString()
363 << std::setw(3) <<
m_TRT_ID->barrel_ec(
id)
364 << std::setw(4) <<
m_TRT_ID->phi_module(
id)
365 << std::setw(4) <<
m_TRT_ID->layer_or_wheel(
id)
366 << std::setw(4) <<
m_TRT_ID->straw_layer(
id)
367 << std::setw(4) <<
m_TRT_ID->straw(
id)
379 ATH_MSG_DEBUG(
"TRTTrackHoleSearchTool::find_first_trt_hit" );
382 for(; track_state != track_states.
end(); ++track_state) {
385 ATH_MSG_VERBOSE(
" TrackStateOnSurface is not of type Trk::TrackStateOnSurface::Measurement." );
400 ATH_MSG_DEBUG(
"TRTTrackHoleSearchTool::find_last_hit_before_trt" );
404 if(track_states.
size() < 2 || track_state == track_states.
begin()) {
405 return track_states.
end();
408 for(; track_state != track_states.
begin(); --track_state) {
415 return track_states.
end();
433 auto tsos = std::make_unique<Trk::TrackStates>();
434 for (
const auto *it : *track.trackStateOnSurfaces()) {
443 if (track.trackStateOnSurfaces()->size() == tsos->size() && holes->empty()) {
448 track.fitQuality() ? track.fitQuality()->uniqueClone() :
nullptr);
453 tsos->insert(tsos->end(), holes->begin(), holes->end());
458 perigee = (*(track.trackStateOnSurfaces()->begin()))->trackParameters();
463 if (fabs(perigee->parameters()[
Trk::qOverP]) > 0.002) {
467 msg() <<
"sorting vector with stable_sort" <<
endmsg;
471 tsos->sort(CompFunc);
479 track.fitQuality() ? track.fitQuality()->uniqueClone() :
nullptr);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
This is an Identifier helper class for the TRT subdetector.
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
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.
size_type size() const noexcept
Returns the number of elements in the collection.
Represents 'corrected' measurements from the TRT (for example, corrected for wire sag).
Bounds for a cylindrical Surface.
double halflengthZ() const
This method returns the halflengthZ.
Class for a CylinderSurface in the ATLAS detector.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
Abstract Base Class for tracking surfaces.
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
virtual const SurfaceBounds & bounds() const =0
Surface Bounds method.
Class providing comparison function, or relational definition, for sorting MeasurementBase objects.
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Hole
A hole on the track - this is defined in the following way.
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Eigen::Affine3d Transform3D
DataVector< const Trk::TrackStateOnSurface > TrackStates
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
ParametersBase< TrackParametersDim, Charged > TrackParameters
@ numberOfTRTHoles
number of TRT hits which pass the high threshold (only xenon counted) total number of TRT hits which ...
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.