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();
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);
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();
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;
451 out<<
"|----------------------------------------------------------------------"
452 <<
"-------------------|"
463 out<<
"|-------------------------------------------------------------------"<<std::endl;
464 out<<
"| Investigated :"<<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;
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;
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)));
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);
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)) );
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;
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);