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;
165 event_data_p =
m_trackmaker->newRegion(ctx, combinatorialData, listOfPixIds, listOfSCTIds);
167 event_data_p =
m_trackmaker->newEvent(ctx, combinatorialData);
170 std::unique_ptr<InDet::ITRT_TrackExtensionTool::IEventData> ext_event_data_p(
m_trtExtension->newEvent(ctx) );
171 std::unique_ptr<TrackCollection> outTracks = std::make_unique<TrackCollection>();
172 std::vector<Trk::Track*> tempTracks;
173 tempTracks.reserve(128);
175 ATH_MSG_DEBUG (
"Begin looping over all TRT segments in the event");
179 for(; iseg != isegEnd; ++ iseg) {
196 ATH_MSG_DEBUG (
"====> Reached maximal number of segments in event, stop !!!");
204 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtSegGood]++;
206 std::list<Trk::Track*> trackSi =
m_trackmaker->getTrack(ctx, *event_data_p, *trackTRT);
207 if (trackSi.empty()) {
208 ATH_MSG_DEBUG (
"No Si track candidates associated to the TRT track ");
216 ATH_MSG_DEBUG (
"Failed to make a track out of the TRT segment!");
222 outTracks->push_back(trtSeg);
227 ATH_MSG_DEBUG (
"Found " << (trackSi.size()) <<
" Si tracks associated to the TRT track ");
229 std::list<Trk::Track*>::const_iterator itt = trackSi.begin();
230 std::list<Trk::Track*>::const_iterator ittEnd = trackSi.end();
231 for (; itt != ittEnd ; ++itt){
232 tempTracks.push_back(*itt);
244 auto input = (*itt)->trackParameters()->front()->uniqueClone();
262 beamSpotPosition = beamSpotHandle->beamVtx().position();
268 std::unique_ptr<const Trk::TrackParameters> parm =
270 ctx, *
input, perigeeSurface);
271 std::unique_ptr<const Trk::Perigee> extrapolatedPerigee =
nullptr;
273 extrapolatedPerigee.reset(
static_cast<const Trk::Perigee*
>(parm.release()));
275 if (!extrapolatedPerigee) {
276 ATH_MSG_WARNING(
"Extrapolation of perigee failed, this should never happen" );
302 ATH_MSG_DEBUG (
"Try to improve TRT calling extension tool.");
304 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtExtCalls]++;
306 std::vector<const Trk::MeasurementBase*>& tn =
307 m_trtExtension->extendTrack(ctx, *(*itt), *ext_event_data_p, map);
310 ATH_MSG_DEBUG (
"No new segment found, use input segment as fallback.");
312 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtExtFail]++;
326 std::vector<const Trk::MeasurementBase*>::const_iterator iv, ive=tn.end();
327 for(iv=tn.begin(); iv!=ive; ++iv)
delete (*iv);
336 ev_stat.
m_counter[Stat_t::Stat_t::kNTrtExtBad]++;
338 std::vector<const Trk::MeasurementBase*>::const_iterator iv, ive=tn.end();
339 for(iv=tn.begin(); iv!=ive; ++iv)
delete (*iv);
343 ATH_MSG_DEBUG (
"Do not try to extend Si track, merging it with input TRT.");
353 ATH_MSG_DEBUG (
"Failed to make a track out of the TRT segment!");
364 outTracks->push_back(trtSeg);
375 outTracks->push_back(globalTrackNew);
388 return StatusCode::FAILURE;
392 std::lock_guard<std::mutex> lock(m_statMutex);
393 m_totalStat += ev_stat;
396 for (
auto *
p : tempTracks){
406 return StatusCode::SUCCESS;
416 msg(MSG::INFO) <<
"\n";
420 return StatusCode::SUCCESS;
431 std::string s1;
for(
int i=0;
i<
n; ++
i) s1.append(
" "); s1.append(
"|");
433 std::string
s2;
for(
int i=0;
i<
n; ++
i)
s2.append(
" ");
s2.append(
"|");
435 std::string
s3;
for(
int i=0;
i<
n; ++
i)
s3.append(
" ");
s3.append(
"|");
437 std::string
s4;
for(
int i=0;
i<
n; ++
i)
s4.append(
" ");
s4.append(
"|");
439 std::string s5;
for(
int i=0;
i<
n; ++
i) s5.append(
" "); s5.append(
"|");
441 out<<
"|----------------------------------------------------------------------"
442 <<
"-------------------|"
444 out<<
"| Tool for TRT seeded track finding | "<<
m_trackmaker.type() <<s1<<std::endl;
449 out<<
"|----------------------------------------------------------------------"
450 <<
"-------------------|"
461 out<<
"|-------------------------------------------------------------------"<<std::endl;
462 out<<
"| Investigated :"<<std::endl
465 <<
"| "<<std::setw(7)<<
stat.m_counter[Stat_t::Stat_t::kNTrtSegGood] <<
" TRT Segments after selection"<<std::endl;
467 out<<
"|-------------------------------------------------------------------"<<std::endl;
468 out<<
"| "<<std::setw(7)<<
stat.m_counter[
Stat_t::kNTrtLimit] <<
" TRT segments lost because of processing limit"<<std::endl;
470 out<<
"|-------------------------------------------------------------------"<<std::endl;
475 if (
stat.m_counter[Stat_t::Stat_t::kNBckTrkTrt]>0) {
476 out<<
"| "<<std::setw(7)<<
stat.m_counter[Stat_t::Stat_t::kNBckTrkTrt] <<
" number ot TRT only tracks created"<<std::endl;
479 out<<
"|-------------------------------------------------------------------"<<std::endl;
480 out<<
"| "<<std::setw(7)<<
stat.m_counter[Stat_t::Stat_t::kNTrtExtCalls]<<
" number of times TRT extension is called"<<std::endl
481 <<
"| "<<std::setw(7)<<
stat.m_counter[
Stat_t::kNTrtExt] <<
" number of good TRT extension"<<std::endl;
483 out<<
"| "<<std::setw(7)<<
stat.m_counter[Stat_t::Stat_t::kNTrtExtBad]<<
" number of bad TRT extension"<<std::endl;
485 out<<
"| "<<std::setw(7)<<
stat.m_counter[Stat_t::Stat_t::kNTrtExtFail]<<
" number of failed TRT extension and fallback"<<std::endl;
487 out<<
"|-------------------------------------------------------------------"<<std::endl;
488 out<<
"| "<<std::setw(7)<<
stat.m_counter[Stat_t::Stat_t::kNBckTrkSi] <<
" TRT+Si tracks created of output"<<std::endl;
492 out<<
"|-------------------------------------------------------------------";
507 auto ntsos = std::make_unique<Trk::TrackStates>();
511 for (p_stsos=stsos->
begin(); p_stsos != stsos->
end(); ++p_stsos) {
512 ntsos->push_back( (*p_stsos)->clone() );
520 ATH_MSG_DEBUG (
"Too few Si hits.Will keep pseudomeasurement...");
522 ntsos->push_back(seg_tsos);
525 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
528 ntsos->push_back(seg_tsos);
535 std::unique_ptr<Trk::Track> newTrack(std::make_unique<Trk::Track>(
info, std::move(ntsos), std::move(fq)));
547 if (!CM || std::sqrt((*CM)(1,1)) == 0. || std::sqrt((*CM)(3,3)) == 0.) {
552 return newTrack.release();
560 ATH_MSG_DEBUG (
"Transforming the TRT segment into a track...");
565 throw std::logic_error(
"Unhandled surface.");
569 auto ntsos = std::make_unique<Trk::TrackStates>();
570 std::unique_ptr<Trk::TrackParameters> segPar =
572 p(0),
p(1),
p(2),
p(3),
p(4), std::move(ep));
574 ATH_MSG_DEBUG(
"Initial TRT Segment Parameters for refitting " << (*segPar) );
576 ATH_MSG_DEBUG(
"Could not get initial TRT segment parameters! " );
582 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
589 ntsos->push_back(seg_tsos);
593 std::unique_ptr<Trk::Track> newTrack = std::make_unique<Trk::Track>(
info, std::move(ntsos),
nullptr);
605 if (!CM || std::sqrt((*CM)(1,1)) == 0. || std::sqrt((*CM)(3,3)) == 0.) {
610 return newTrack.release();
624 auto ntsos = std::make_unique<Trk::TrackStates>();
627 for (p_stsos = stsos->
begin(); p_stsos != stsos->
end(); ++p_stsos) {
628 ntsos->push_back((*p_stsos)->clone());
631 for (
auto &
it : tS) {
632 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
635 ntsos->push_back(seg_tsos);
640 std::unique_ptr<Trk::Track> newTrack( std::make_unique<Trk::Track>(
info, std::move(ntsos), std::move(fq)) );
652 if (!CM || std::sqrt((*CM)(1,1)) == 0. || std::sqrt((*CM)(3,3)) == 0.) {
658 return newTrack.release();
670 int nsct1{}, nsct2{}, nsct3{}, nsct4{};
671 int nsctTot1{}, nsctTot2{}, nsctTot3{}, nsctTot4{};
672 int npix1{}, npix2{}, npix3{};
673 int npixTot1{}, npixTot2{}, npixTot3{};
677 for (;
r !=
re ; ++
r){
678 nsct1=nsct2=nsct3=nsct4=0; npix1=npix2=npix3=0;
680 if(!newtsos)
continue;
687 if((40.<=rc)&&(rc<80.)){npix1++;}
688 if((80.<=rc)&&(rc<100.)){npix2++;}
689 if((100.<=rc)&&(rc<150.)){npix3++;}
690 if((280.<=rc)&&(rc<340.)){nsct1++;}
691 if((340.<=rc)&&(rc<390.)){nsct2++;}
692 if((390.<=rc)&&(rc<460.)){nsct3++;}
693 if((460.<=rc)&&(rc<550.)){nsct4++;}
696 nsctTot1+=nsct1; nsctTot2+=nsct2; nsctTot3+=nsct3; nsctTot4+=nsct4;
697 npixTot1+=npix1; npixTot2+=npix2; npixTot3+=npix3;
699 ATH_MSG_DEBUG(
"Total hits on 1st SCT: "<<nsctTot1<<
" 2nd SCT: "<<nsctTot2<<
" 3rd SCT: "<<nsctTot3<<
" 4th SCT: "<<nsctTot4);
700 ATH_MSG_DEBUG(
"Total hits on 1st Pixel: "<<npixTot1<<
" 2nd Pixel: "<<npixTot2<<
" 3rd Pixel: "<<npixTot3);