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 !!!");
138 std::unique_ptr<InDet::ITRT_SeededTrackFinder::IEventData> event_data_p;
141 std::unique_ptr<RoiDescriptor> roiComp = std::make_unique<RoiDescriptor>(
true);
145 double beamZ = beamSpotHandle->beamVtx().position().z();
147 roiComp->setComposite();
148 for (
const ROIPhiRZ &the_roi : *calo_rois) {
149 double eta = the_roi.eta();
150 double phi = the_roi.phi();
157 roi =
new RoiDescriptor(
eta, roiEtaMin, roiEtaMax,
phi, roiPhiMin ,roiPhiMax, beamZ, roiZMin,roiZMax);
158 roiComp->push_back(roi);
162 std::vector<IdentifierHash> listOfSCTIds;
163 std::vector<IdentifierHash> listOfPixIds;
167 event_data_p =
m_trackmaker->newRegion(ctx, combinatorialData, listOfPixIds, listOfSCTIds);
169 event_data_p =
m_trackmaker->newEvent(ctx, combinatorialData);
172 std::unique_ptr<InDet::ITRT_TrackExtensionTool::IEventData> ext_event_data_p(
m_trtExtension->newEvent(ctx) );
173 std::unique_ptr<TrackCollection> outTracks = std::make_unique<TrackCollection>();
174 std::vector<Trk::Track*> tempTracks;
175 tempTracks.reserve(128);
177 ATH_MSG_DEBUG (
"Begin looping over all TRT segments in the event");
181 for(; iseg != isegEnd; ++ iseg) {
198 ATH_MSG_DEBUG (
"====> Reached maximal number of segments in event, stop !!!");
206 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtSegGood]++;
208 std::list<Trk::Track*> trackSi =
m_trackmaker->getTrack(ctx, *event_data_p, *trackTRT);
209 if (trackSi.empty()) {
210 ATH_MSG_DEBUG (
"No Si track candidates associated to the TRT track ");
218 ATH_MSG_DEBUG (
"Failed to make a track out of the TRT segment!");
224 outTracks->push_back(trtSeg);
229 ATH_MSG_DEBUG (
"Found " << (trackSi.size()) <<
" Si tracks associated to the TRT track ");
231 std::list<Trk::Track*>::const_iterator itt = trackSi.begin();
232 std::list<Trk::Track*>::const_iterator ittEnd = trackSi.end();
233 for (; itt != ittEnd ; ++itt){
234 tempTracks.push_back(*itt);
246 auto input = (*itt)->trackParameters()->front()->uniqueClone();
248 if (std::abs(input->pT()) <
m_minPt) {
254 if (std::abs(input->eta()) >
m_maxEta) {
264 beamSpotPosition = beamSpotHandle->beamVtx().position();
270 std::unique_ptr<const Trk::TrackParameters> parm =
272 ctx, *input, perigeeSurface);
273 std::unique_ptr<const Trk::Perigee> extrapolatedPerigee =
nullptr;
275 extrapolatedPerigee.reset(
static_cast<const Trk::Perigee*
>(parm.release()));
277 if (!extrapolatedPerigee) {
278 ATH_MSG_WARNING(
"Extrapolation of perigee failed, this should never happen" );
304 ATH_MSG_DEBUG (
"Try to improve TRT calling extension tool.");
306 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtExtCalls]++;
308 std::vector<const Trk::MeasurementBase*>& tn =
309 m_trtExtension->extendTrack(ctx, *(*itt), *ext_event_data_p, map);
312 ATH_MSG_DEBUG (
"No new segment found, use input segment as fallback.");
314 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtExtFail]++;
328 std::vector<const Trk::MeasurementBase*>::const_iterator iv, ive=tn.end();
329 for(iv=tn.begin(); iv!=ive; ++iv)
delete (*iv);
338 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtExtBad]++;
340 std::vector<const Trk::MeasurementBase*>::const_iterator iv, ive=tn.end();
341 for(iv=tn.begin(); iv!=ive; ++iv)
delete (*iv);
345 ATH_MSG_DEBUG (
"Do not try to extend Si track, merging it with input TRT.");
355 ATH_MSG_DEBUG (
"Failed to make a track out of the TRT segment!");
366 outTracks->push_back(trtSeg);
377 outTracks->push_back(globalTrackNew);
390 return StatusCode::FAILURE;
394 std::lock_guard<std::mutex> lock(m_statMutex);
395 m_totalStat += ev_stat;
398 for (
auto *p : tempTracks){
408 return StatusCode::SUCCESS;
418 msg(MSG::INFO) <<
"\n";
422 return StatusCode::SUCCESS;
433 std::string s1;
for(
int i=0; i<n; ++i) s1.append(
" "); s1.append(
"|");
435 std::string s2;
for(
int i=0; i<n; ++i) s2.append(
" "); s2.append(
"|");
437 std::string s3;
for(
int i=0; i<n; ++i) s3.append(
" "); s3.append(
"|");
439 std::string s4;
for(
int i=0; i<n; ++i) s4.append(
" "); s4.append(
"|");
441 std::string s5;
for(
int i=0; i<n; ++i) s5.append(
" "); s5.append(
"|");
443 out<<
"|----------------------------------------------------------------------"
444 <<
"-------------------|"
446 out<<
"| Tool for TRT seeded track finding | "<<
m_trackmaker.type() <<s1<<std::endl;
447 out<<
"| Tool for final track refitting | "<<
m_fitterTool.type() <<s2<<std::endl;
448 out<<
"| Tool for TRT trac extension | "<<
m_trtExtension.type() <<s3<<std::endl;
449 out<<
"| Location of input tracks | "<<
m_SegmentsKey.key() <<s4<<std::endl;
450 out<<
"| Location of output tracks | "<<
m_outTracksKey.key() <<s5<<std::endl;
451 out<<
"|----------------------------------------------------------------------"
452 <<
"-------------------|"
463 out<<
"|-------------------------------------------------------------------"<<std::endl;
464 out<<
"| Investigated :"<<std::endl
465 <<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNTrtSeg] <<
" TRT Segments on input"<<std::endl
466 <<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNTrtFailSel] <<
" TRT Segments fail selection on input"<<std::endl
467 <<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNTrtSegGood] <<
" TRT Segments after selection"<<std::endl;
469 out<<
"|-------------------------------------------------------------------"<<std::endl;
470 out<<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNTrtLimit] <<
" TRT segments lost because of processing limit"<<std::endl;
472 out<<
"|-------------------------------------------------------------------"<<std::endl;
473 out<<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNTrtNoSiExt] <<
" TRT segments without Si extension"<<std::endl;
475 out<<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNExtCut] <<
" number of Si extension failing cuts"<<std::endl;
477 if (stat.m_counter[Stat_t::Stat_t::kNBckTrkTrt]>0) {
478 out<<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNBckTrkTrt] <<
" number ot TRT only tracks created"<<std::endl;
481 out<<
"|-------------------------------------------------------------------"<<std::endl;
482 out<<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNTrtExtCalls]<<
" number of times TRT extension is called"<<std::endl
483 <<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNTrtExt] <<
" number of good TRT extension"<<std::endl;
485 out<<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNTrtExtBad]<<
" number of bad TRT extension"<<std::endl;
487 out<<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNTrtExtFail]<<
" number of failed TRT extension and fallback"<<std::endl;
489 out<<
"|-------------------------------------------------------------------"<<std::endl;
490 out<<
"| "<<std::setw(7)<<stat.m_counter[Stat_t::Stat_t::kNBckTrkSi] <<
" TRT+Si tracks created of output"<<std::endl;
492 out<<
"| "<<std::setw(7)<<stat.m_counter[
Stat_t::kNBckTrk] <<
" total number of tracks on output"<<std::endl;
494 out<<
"|-------------------------------------------------------------------";
509 auto ntsos = std::make_unique<Trk::TrackStates>();
513 for (p_stsos=stsos->
begin(); p_stsos != stsos->
end(); ++p_stsos) {
514 ntsos->push_back( (*p_stsos)->clone() );
522 ATH_MSG_DEBUG (
"Too few Si hits.Will keep pseudomeasurement...");
524 ntsos->push_back(seg_tsos);
527 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
530 ntsos->push_back(seg_tsos);
537 std::unique_ptr<Trk::Track> newTrack(std::make_unique<Trk::Track>(info, std::move(ntsos), std::move(fq)));
546 const Trk::Perigee* perTrack=newTrack->perigeeParameters();
549 if (!CM || std::sqrt((*CM)(1,1)) == 0. || std::sqrt((*CM)(3,3)) == 0.) {
554 return newTrack.release();
562 ATH_MSG_DEBUG (
"Transforming the TRT segment into a track...");
567 throw std::logic_error(
"Unhandled surface.");
571 auto ntsos = std::make_unique<Trk::TrackStates>();
572 std::unique_ptr<Trk::TrackParameters> segPar =
574 p(0), p(1), p(2), p(3), p(4), std::move(ep));
576 ATH_MSG_DEBUG(
"Initial TRT Segment Parameters for refitting " << (*segPar) );
578 ATH_MSG_DEBUG(
"Could not get initial TRT segment parameters! " );
584 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
591 ntsos->push_back(seg_tsos);
595 std::unique_ptr<Trk::Track> newTrack = std::make_unique<Trk::Track>(info, std::move(ntsos),
nullptr);
604 const Trk::Perigee* perTrack=newTrack->perigeeParameters();
607 if (!CM || std::sqrt((*CM)(1,1)) == 0. || std::sqrt((*CM)(3,3)) == 0.) {
612 return newTrack.release();
626 auto ntsos = std::make_unique<Trk::TrackStates>();
629 for (p_stsos = stsos->
begin(); p_stsos != stsos->
end(); ++p_stsos) {
630 ntsos->push_back((*p_stsos)->clone());
633 for (
auto & it : tS) {
634 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
637 ntsos->push_back(seg_tsos);
642 std::unique_ptr<Trk::Track> newTrack( std::make_unique<Trk::Track>(info, std::move(ntsos), std::move(fq)) );
651 const Trk::Perigee* perTrack=newTrack->perigeeParameters();
654 if (!CM || std::sqrt((*CM)(1,1)) == 0. || std::sqrt((*CM)(3,3)) == 0.) {
660 return newTrack.release();
672 int nsct1{}, nsct2{}, nsct3{}, nsct4{};
673 int nsctTot1{}, nsctTot2{}, nsctTot3{}, nsctTot4{};
674 int npix1{}, npix2{}, npix3{};
675 int npixTot1{}, npixTot2{}, npixTot3{};
679 for (;
r !=
re ; ++
r){
680 nsct1=nsct2=nsct3=nsct4=0; npix1=npix2=npix3=0;
682 if(!newtsos)
continue;
684 for(itp=newtsos->
begin(); itp!=itpe; ++itp){
689 if((40.<=
rc)&&(
rc<80.)){npix1++;}
690 if((80.<=
rc)&&(
rc<100.)){npix2++;}
691 if((100.<=
rc)&&(
rc<150.)){npix3++;}
692 if((280.<=
rc)&&(
rc<340.)){nsct1++;}
693 if((340.<=
rc)&&(
rc<390.)){nsct2++;}
694 if((390.<=
rc)&&(
rc<460.)){nsct3++;}
695 if((460.<=
rc)&&(
rc<550.)){nsct4++;}
698 nsctTot1+=nsct1; nsctTot2+=nsct2; nsctTot3+=nsct3; nsctTot4+=nsct4;
699 npixTot1+=npix1; npixTot2+=npix2; npixTot3+=npix3;
701 ATH_MSG_DEBUG(
"Total hits on 1st SCT: "<<nsctTot1<<
" 2nd SCT: "<<nsctTot2<<
" 3rd SCT: "<<nsctTot3<<
" 4th SCT: "<<nsctTot4);
702 ATH_MSG_DEBUG(
"Total hits on 1st Pixel: "<<npixTot1<<
" 2nd Pixel: "<<npixTot2<<
" 3rd Pixel: "<<npixTot3);
const boost::regex re(r_e)
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)
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.