15#include "GaudiKernel/MsgStream.h"
39(
const std::string& name, ISvcLocator* pSvcLocator)
88 return StatusCode::SUCCESS;
94 unsigned int size()
const {
103 if (!key.key().empty()) {
125 ATH_MSG_FATAL (
"No segment with name " << segments.
name() <<
" found in StoreGate!");
126 return StatusCode::FAILURE;
128 ATH_MSG_DEBUG (
"Found segments collection " << segments.
name() <<
" in StoreGate!");
134 ATH_MSG_DEBUG (
"TRT track container size huge; will process event partially if number of max segments reached !!!");
140 std::unique_ptr<InDet::ITRT_SeededTrackFinder::IEventData> event_data_p;
143 std::unique_ptr<RoiDescriptor> roiComp = std::make_unique<RoiDescriptor>(
true);
147 double beamZ = beamSpotHandle->beamVtx().position().z();
149 roiComp->setComposite();
150 for (
const ROIPhiRZ &the_roi : *calo_rois) {
151 double eta = the_roi.eta();
152 double phi = the_roi.phi();
159 roi =
new RoiDescriptor(
eta, roiEtaMin, roiEtaMax,
phi, roiPhiMin ,roiPhiMax, beamZ, roiZMin,roiZMax);
160 roiComp->push_back(roi);
164 std::vector<IdentifierHash> listOfSCTIds;
165 std::vector<IdentifierHash> listOfPixIds;
169 event_data_p =
m_trackmaker->newRegion(ctx, combinatorialData, listOfPixIds, listOfSCTIds);
171 event_data_p =
m_trackmaker->newEvent(ctx, combinatorialData);
174 std::unique_ptr<InDet::ITRT_TrackExtensionTool::IEventData> ext_event_data_p(
m_trtExtension->newEvent(ctx) );
175 std::unique_ptr<TrackCollection> outTracks = std::make_unique<TrackCollection>();
176 std::vector<Trk::Track*> tempTracks;
177 tempTracks.reserve(128);
179 ATH_MSG_DEBUG (
"Begin looping over all TRT segments in the event");
183 for(; iseg != isegEnd; ++ iseg) {
200 ATH_MSG_DEBUG (
"====> Reached maximal number of segments in event, stop !!!");
208 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtSegGood]++;
210 std::list<Trk::Track*> trackSi =
m_trackmaker->getTrack(ctx, *event_data_p, *trackTRT);
211 if (trackSi.empty()) {
212 ATH_MSG_DEBUG (
"No Si track candidates associated to the TRT track ");
220 ATH_MSG_DEBUG (
"Failed to make a track out of the TRT segment!");
226 outTracks->push_back(trtSeg);
231 ATH_MSG_DEBUG (
"Found " << (trackSi.size()) <<
" Si tracks associated to the TRT track ");
233 std::list<Trk::Track*>::const_iterator itt = trackSi.begin();
234 std::list<Trk::Track*>::const_iterator ittEnd = trackSi.end();
235 for (; itt != ittEnd ; ++itt){
236 tempTracks.push_back(*itt);
248 auto input = (*itt)->trackParameters()->front()->uniqueClone();
250 if (std::abs(input->pT()) <
m_minPt) {
256 if (std::abs(input->eta()) >
m_maxEta) {
266 beamSpotPosition = beamSpotHandle->beamVtx().position();
272 std::unique_ptr<const Trk::TrackParameters> parm =
274 ctx, *input, perigeeSurface);
275 std::unique_ptr<const Trk::Perigee> extrapolatedPerigee =
nullptr;
277 extrapolatedPerigee.reset(
static_cast<const Trk::Perigee*
>(parm.release()));
279 if (!extrapolatedPerigee) {
280 ATH_MSG_WARNING(
"Extrapolation of perigee failed, this should never happen" );
306 ATH_MSG_DEBUG (
"Try to improve TRT calling extension tool.");
308 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtExtCalls]++;
310 std::vector<const Trk::MeasurementBase*>& tn =
311 m_trtExtension->extendTrack(ctx, *(*itt), *ext_event_data_p, map);
314 ATH_MSG_DEBUG (
"No new segment found, use input segment as fallback.");
316 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtExtFail]++;
330 std::vector<const Trk::MeasurementBase*>::const_iterator iv, ive=tn.end();
331 for(iv=tn.begin(); iv!=ive; ++iv)
delete (*iv);
340 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtExtBad]++;
342 std::vector<const Trk::MeasurementBase*>::const_iterator iv, ive=tn.end();
343 for(iv=tn.begin(); iv!=ive; ++iv)
delete (*iv);
347 ATH_MSG_DEBUG (
"Do not try to extend Si track, merging it with input TRT.");
357 ATH_MSG_DEBUG (
"Failed to make a track out of the TRT segment!");
368 outTracks->push_back(trtSeg);
379 outTracks->push_back(globalTrackNew);
392 return StatusCode::FAILURE;
396 std::lock_guard<std::mutex>
lock(m_statMutex);
397 m_totalStat += ev_stat;
400 for (
auto *p : tempTracks){
410 return StatusCode::SUCCESS;
420 msg(MSG::INFO) <<
"\n";
424 return StatusCode::SUCCESS;
435 std::string s1;
for(
int i=0; i<n; ++i) s1.append(
" "); s1.append(
"|");
437 std::string s2;
for(
int i=0; i<n; ++i) s2.append(
" "); s2.append(
"|");
439 std::string s3;
for(
int i=0; i<n; ++i) s3.append(
" "); s3.append(
"|");
441 std::string s4;
for(
int i=0; i<n; ++i) s4.append(
" "); s4.append(
"|");
443 std::string s5;
for(
int i=0; i<n; ++i) s5.append(
" "); s5.append(
"|");
445 out<<
"|----------------------------------------------------------------------"
446 <<
"-------------------|"
448 out<<
"| Tool for TRT seeded track finding | "<<
m_trackmaker.type() <<s1<<std::endl;
449 out<<
"| Tool for final track refitting | "<<
m_fitterTool.type() <<s2<<std::endl;
450 out<<
"| Tool for TRT trac extension | "<<
m_trtExtension.type() <<s3<<std::endl;
451 out<<
"| Location of input tracks | "<<
m_SegmentsKey.key() <<s4<<std::endl;
452 out<<
"| Location of output tracks | "<<
m_outTracksKey.key() <<s5<<std::endl;
453 out<<
"|----------------------------------------------------------------------"
454 <<
"-------------------|"
465 out<<
"|-------------------------------------------------------------------"<<std::endl;
466 out<<
"| Investigated :"<<std::endl
467 <<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNTrtSeg] <<
" TRT Segments on input"<<std::endl
468 <<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNTrtFailSel] <<
" TRT Segments fail selection on input"<<std::endl
469 <<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNTrtSegGood] <<
" TRT Segments after selection"<<std::endl;
471 out<<
"|-------------------------------------------------------------------"<<std::endl;
472 out<<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNTrtLimit] <<
" TRT segments lost because of processing limit"<<std::endl;
474 out<<
"|-------------------------------------------------------------------"<<std::endl;
475 out<<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNTrtNoSiExt] <<
" TRT segments without Si extension"<<std::endl;
477 out<<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNExtCut] <<
" number of Si extension failing cuts"<<std::endl;
479 if (stat.m_counter[Stat_t::Stat_t::kNBckTrkTrt]>0) {
480 out<<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNBckTrkTrt] <<
" number ot TRT only tracks created"<<std::endl;
483 out<<
"|-------------------------------------------------------------------"<<std::endl;
484 out<<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNTrtExtCalls]<<
" number of times TRT extension is called"<<std::endl
485 <<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNTrtExt] <<
" number of good TRT extension"<<std::endl;
487 out<<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNTrtExtBad]<<
" number of bad TRT extension"<<std::endl;
489 out<<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNTrtExtFail]<<
" number of failed TRT extension and fallback"<<std::endl;
491 out<<
"|-------------------------------------------------------------------"<<std::endl;
492 out<<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNBckTrkSi] <<
" TRT+Si tracks created of output"<<std::endl;
494 out<<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNBckTrk] <<
" total number of tracks on output"<<std::endl;
496 out<<
"|-------------------------------------------------------------------";
511 auto ntsos = std::make_unique<Trk::TrackStates>();
515 for (p_stsos=stsos->
begin(); p_stsos != stsos->
end(); ++p_stsos) {
516 ntsos->push_back( (*p_stsos)->clone() );
524 ATH_MSG_DEBUG (
"Too few Si hits.Will keep pseudomeasurement...");
526 ntsos->push_back(seg_tsos);
529 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
532 ntsos->push_back(seg_tsos);
539 std::unique_ptr<Trk::Track> newTrack(std::make_unique<Trk::Track>(info, std::move(ntsos), std::move(fq)));
549 const Trk::Perigee* perTrack=newTrack->perigeeParameters();
552 if (!CM || std::sqrt((*CM)(1,1)) == 0. || std::sqrt((*CM)(3,3)) == 0.) {
557 return newTrack.release();
565 ATH_MSG_DEBUG (
"Transforming the TRT segment into a track...");
570 throw std::logic_error(
"Unhandled surface.");
574 auto ntsos = std::make_unique<Trk::TrackStates>();
575 std::unique_ptr<Trk::TrackParameters> segPar =
577 p(0), p(1), p(2), p(3), p(4), std::move(ep));
579 ATH_MSG_DEBUG(
"Initial TRT Segment Parameters for refitting " << (*segPar) );
581 ATH_MSG_DEBUG(
"Could not get initial TRT segment parameters! " );
587 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
594 ntsos->push_back(seg_tsos);
598 std::unique_ptr<Trk::Track> newTrack = std::make_unique<Trk::Track>(info, std::move(ntsos),
nullptr);
608 const Trk::Perigee* perTrack=newTrack->perigeeParameters();
611 if (!CM || std::sqrt((*CM)(1,1)) == 0. || std::sqrt((*CM)(3,3)) == 0.) {
616 return newTrack.release();
630 auto ntsos = std::make_unique<Trk::TrackStates>();
633 for (p_stsos = stsos->
begin(); p_stsos != stsos->
end(); ++p_stsos) {
634 ntsos->push_back((*p_stsos)->clone());
637 for (
auto & it : tS) {
638 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
641 ntsos->push_back(seg_tsos);
646 std::unique_ptr<Trk::Track> newTrack( std::make_unique<Trk::Track>(info, std::move(ntsos), std::move(fq)) );
656 const Trk::Perigee* perTrack=newTrack->perigeeParameters();
659 if (!CM || std::sqrt((*CM)(1,1)) == 0. || std::sqrt((*CM)(3,3)) == 0.) {
665 return newTrack.release();
677 int nsct1{}, nsct2{}, nsct3{}, nsct4{};
678 int nsctTot1{}, nsctTot2{}, nsctTot3{}, nsctTot4{};
679 int npix1{}, npix2{}, npix3{};
680 int npixTot1{}, npixTot2{}, npixTot3{};
684 for (;
r !=
re ; ++
r){
685 nsct1=nsct2=nsct3=nsct4=0; npix1=npix2=npix3=0;
687 if(!newtsos)
continue;
689 for(itp=newtsos->
begin(); itp!=itpe; ++itp){
694 if((40.<=
rc)&&(
rc<80.)){npix1++;}
695 if((80.<=
rc)&&(
rc<100.)){npix2++;}
696 if((100.<=
rc)&&(
rc<150.)){npix3++;}
697 if((280.<=
rc)&&(
rc<340.)){nsct1++;}
698 if((340.<=
rc)&&(
rc<390.)){nsct2++;}
699 if((390.<=
rc)&&(
rc<460.)){nsct3++;}
700 if((460.<=
rc)&&(
rc<550.)){nsct4++;}
703 nsctTot1+=nsct1; nsctTot2+=nsct2; nsctTot3+=nsct3; nsctTot4+=nsct4;
704 npixTot1+=npix1; npixTot2+=npix2; npixTot3+=npix3;
706 ATH_MSG_DEBUG(
"Total hits on 1st SCT: "<<nsctTot1<<
" 2nd SCT: "<<nsctTot2<<
" 3rd SCT: "<<nsctTot3<<
" 4th SCT: "<<nsctTot4);
707 ATH_MSG_DEBUG(
"Total hits on 1st Pixel: "<<npixTot1<<
" 2nd Pixel: "<<npixTot2<<
" 3rd Pixel: "<<npixTot3);
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
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.
SG::ReadHandle< Trk::PRDtoTrackMap > m_prdToTrackMap
ExtendedSiCombinatorialTrackFinderData_xk(const SG::ReadHandleKey< Trk::PRDtoTrackMap > &key)
unsigned int size() const
RIO_OnTrack base class for Silicon detector in the InnerDetector.
virtual const Amg::Vector3D & globalPosition() const override
returns global position (gathered through Surface constraint)
InDet::SiCombinatorialTrackFinderData_xk holds event dependent data used by SiCombinatorialTrackFinde...
void setPRDtoTrackMap(const Trk::PRDtoTrackMap *prd_to_track_map)
Set PRD to track map.
std::array< std::vector< std::vector< Used_t > >, 3 > TRT_DetElemUsedMap
IntegerProperty m_MaxSegNum
Trk::Track * segToTrack(const EventContext &, const Trk::TrackSegment &) const
Transform a TRT track segment into a track.
ToolHandle< Trk::IExtendedTrackSummaryTool > m_trackSummaryTool
BooleanProperty m_doExtension
BooleanProperty m_SiExtensionCuts
StatusCode finalize() override
MsgStream & dumptools(MsgStream &out) const
StatusCode execute(const EventContext &ctx) const override
TRT_SeededTrackFinder(const std::string &name, ISvcLocator *pSvcLocator)
Standard Algorithm methods.
Trk::Track * mergeSegments(const Trk::Track &, const Trk::TrackSegment &) const
Protected methods.
StatusCode initialize() override
BooleanProperty m_caloSeededRoI
DoubleProperty m_maxRPhiImp
ToolHandle< ITRT_SeededTrackFinder > m_trackmaker
SG::ReadHandleKey< Trk::PRDtoTrackMap > m_prdToTrackMap
ToolHandle< ITRT_TrackExtensionTool > m_trtExtension
SG::ReadHandleKey< ROIPhiRZContainer > m_caloClusterROIKey
BooleanProperty m_rejectShortExten
Trk::Track * mergeExtension(const Trk::Track &, std::vector< const Trk::MeasurementBase * > &) const
Merge a TRT track extension and a Si track component into one global ID track.
ToolHandle< Trk::IExtrapolator > m_extrapolator
BooleanProperty m_saveTRT
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
UnsignedIntegerProperty m_minTRTonSegment
UnsignedIntegerProperty m_minTRTonly
void Analyze(TrackCollection *) const
Do some statistics analysis at the end of each event.
ToolHandle< Trk::ITrackFitter > m_fitterTool
SG::WriteHandleKey< TrackCollection > m_outTracksKey
SG::ReadHandleKey< Trk::SegmentCollection > m_SegmentsKey
ToolHandle< IRegSelTool > m_regionSelector
MsgStream & dumpevent(MsgStream &out, const InDet::TRT_SeededTrackFinder::Stat_t &stat) const
BooleanProperty m_doRefit
Describes the Region of Ineterest geometry It has basically 9 parameters.
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const std::string & name() const
Return the StoreGate ID for the referenced object.
Simple helper class for defining track parameters for charged particles.
std::unique_ptr< FitQuality > uniqueClone() const
NVI uniqueClone.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
std::unique_ptr< MeasurementBase > uniqueClone() const
NVI Clone giving up unique pointer.
PrepRawDataTrackMap m_prepRawDataTrackMap
holds the tracks associated with each PRD (i.e.
Class describing the Line to which the Perigee refers to.
Class to handle pseudo-measurements in fitters and on track objects.
const MeasurementBase * measurement(unsigned int) const
returns the Trk::MeasurementBase objects depending on the integer
unsigned int numberOfMeasurementBases() const
Return the number of contained Trk::MeasurementBase (s).
Class for a StraightLineSurface in the ATLAS detector to describe dirft tube and straw like detectors...
std::unique_ptr< ParametersT< DIM, T, StraightLineSurface > > createUniqueParameters(double l1, double l2, double phi, double theta, double qop, std::optional< AmgSymMatrix(DIM)> cov=std::nullopt) const
Use the Surface as a ParametersBase constructor, from local parameters.
Contains information about the 'fitter' of this track.
@ TRTSeededTrackFinder
Tracks from TRT Seeded Track finder.
Class for a generic track segment that holdes polymorphic Trk::MeasurementBase objects,...
const Surface & associatedSurface() const override final
returns the surface for the local to global transformation
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.
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
const FitQuality * fitQuality() const
return a pointer to the fit quality const-overload
Eigen::Matrix< double, 3, 1 > Vector3D
DataVector< const Trk::TrackStateOnSurface > TrackStates
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
Global Counters for final algorithm statistics.
std::array< int, kNCounter > m_counter
@ kNTrtFailSel
Number of TRT segments to be investigated per event.
@ kNTrtNoSiExt
Number of TRT segments lost in busy events.
@ kNBckTrk
Number of back tracks found with Si extension per event.
@ kNTrtLimit
Number of TRT segments that will be investigated per event.
@ kNBckTrkSi
Number of failed TRT extensions.
@ kNExtCut
Number of TRT segments not extended in Si.
@ kNTrtExt
Number of times the TRT extension is called.