27 template<
typename T,
size_t N>
29 operator += (std::array<T, N>& a1,
const std::array<T, N>& a2) {
64 return StatusCode::SUCCESS;
76 const auto nTracks {tracks->size()};
86 <<
"' recorded in StoreGate, size : "
87 << extendedTracksResult->
size());
88 if (extendedTracksResult->
size() != nTracks)
ATH_MSG_WARNING(
"Lost tracks after extension ??? This is a bug !");
89 return StatusCode::SUCCESS;
96 std::unique_ptr<TrackCollection> newTracks(std::make_unique<TrackCollection>());
97 std::array< std::array<std::atomic<int>,
Nregions>,
nTypes> counters{};
104 TrackExtensionMap::const_iterator pThisExtensionPair = trackExtensionMap->find(thisTrack);
106 if (pThisExtensionPair == trackExtensionMap->end()) {
107 ATH_MSG_DEBUG(
"track not in extension map, copy original track to output");
109 std::unique_ptr<Trk::Track> ntrk(std::make_unique<Trk::Track>(*thisTrack));
115 ATH_MSG_DEBUG(
"track found in extension map, processing...");
119 std::unique_ptr<Trk::Track> newtrack;
123 const auto nRIO_OnTrack {pThisExtensionPair->second.size()};
124 std::vector<const Trk::PrepRawData*> vecPrd;
125 vecPrd.reserve(nRIO_OnTrack);
132 const auto& theRIOs_OnTrack {pThisExtensionPair->second};
134 std::transform(theRIOs_OnTrack.begin(), theRIOs_OnTrack.end(), std::back_inserter(vecPrd), getPrepRawDataPtr);
136 ATH_MSG_DEBUG(
"fit track " << thisTrack <<
" with PRDs, number : " << vecPrd.size());
154 thisTrack->trackParameters()->front()->pT() >
m_pTminBrem &&
157 ATH_MSG_DEBUG(
"normal fit track failed, try to recover with brem fit");
166 std::vector<const Trk::PrepRawData*> vecPrdComb;
168 const Trk::Perigee* siPerigee = thisTrack->perigeeParameters();
174 std::unique_ptr<Trk::Track> ntrk(std::make_unique< Trk::Track>(*thisTrack));
180 pThisExtensionPair->first->measurementsOnTrack()->
begin();
181 for (; RIOit != pThisExtensionPair->first->measurementsOnTrack()->
end(); ++RIOit) {
183 if (!rot)
ATH_MSG_ERROR(
"cast to ROT failed, should not happen here !");
187 for (
auto &
i : vecPrd) {
189 (
i->detectorElement()->surface(
i->identify()).center() - siPerigee->position()).
dot(
190 siPerigee->momentum());
192 vecPrdComb.insert(vecPrdComb.begin(),
i);
194 vecPrdComb.push_back(
i);
205 const auto& RIOs_OnTrack {pThisExtensionPair->second};
207 ATH_MSG_DEBUG(
"fit track " << thisTrack <<
" with ROTs, number : " << RIOs_OnTrack.size());
222 thisTrack->trackParameters()->front()->pT() >
m_pTminBrem &&
224 ATH_MSG_DEBUG(
"normal fit track failed, try to recover with brem fit");
235 const Trk::Perigee* siPerigee = thisTrack->perigeeParameters();
241 std::unique_ptr<Trk::Track> ntrk(std::make_unique< Trk::Track>(*thisTrack));
247 pThisExtensionPair->first->measurementsOnTrack()->
begin();
248 for (; RIOit != pThisExtensionPair->first->measurementsOnTrack()->
end(); ++RIOit) {
249 rotSet.push_back(*RIOit);
252 for (
const auto *
i : pThisExtensionPair->second) {
253 double inprod = (
i->associatedSurface().center() - siPerigee->position()).
dot(
254 siPerigee->momentum());
256 rotSet.insert(rotSet.begin(),
i);
270 ATH_MSG_DEBUG(
"refit of extended track failed, copy original track to output");
278 std::unique_ptr<Trk::Track> ntrk(std::make_unique<Trk::Track>(*thisTrack));
287 bool passBasicSelections =
m_scoringTool->passBasicSelections(*newtrack);
288 if(passBasicSelections){
292 bool recheckBasicSel =
false;
299 thisTrack->trackParameters()->front()->pT() >
m_pTminBrem &&
301 ATH_MSG_DEBUG(
"new track has low score, try to recover track using brem fit");
304 std::unique_ptr<Trk::Track> newBremTrack;
318 ATH_MSG_DEBUG(
"recovered new track has score : " << newScore);
320 newtrack = std::move(newBremTrack);
323 if (newScore >= oldScore) {
334 newTracks->
push_back(std::move(newtrack));
340 std::unique_ptr<Trk::Track> ntrk;
344 ntrk = std::make_unique<Trk::Track>(*thisTrack);
357 return newTracks.release();
363 bool updateAll)
const {
370 const auto *
const pTrackParameters {
track->trackParameters()};
372 if (not pTrackParameters) {
373 ATH_MSG_WARNING(
"No track parameters, needed for statistics code in Trk::SimpleAmbiguityProcessorTool!");
375 const double absEta = std::abs(pTrackParameters->front()->eta());
386 const EventContext& ctx,
388 const std::vector<const Trk::MeasurementBase*>& extension)
const
391 auto pExtendedTrajectory = std::make_unique<Trk::TrackStates>();
393 pExtendedTrajectory->reserve(trackStatesOnSurfaces.size() + extension.size());
394 int nSiStates = 0, nExtStates = 0;
399 std::transform(trackStatesOnSurfaces.begin(), trackStatesOnSurfaces.end(), std::back_inserter(
400 *pExtendedTrajectory), cloneTSOS);
401 nSiStates += trackStatesOnSurfaces.size();
404 constexpr std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> outlierPattern(outlierDigit);
410 auto addNewTSOS_ForCosmics = [&pExtendedTrajectory, siTrack, createNewTSOS](
const Trk::MeasurementBase* pm) {
411 const auto& perigee {siTrack->perigeeParameters()};
413 const double inprod = (pm->associatedSurface().center() - perigee->position()).
dot(
414 perigee->momentum());
416 pExtendedTrajectory->insert(pExtendedTrajectory->begin(), createNewTSOS(pm));
418 pExtendedTrajectory->push_back(createNewTSOS(pm));
423 std::transform(extension.begin(), extension.end(), std::back_inserter(*pExtendedTrajectory), createNewTSOS);
426 for (
const auto *
const pMeasurementBase: extension) {
427 addNewTSOS_ForCosmics(pMeasurementBase);
430 nExtStates += pExtendedTrajectory->size();
431 const auto& pFitQuality {siTrack->fitQuality()};
433 new Trk::Track(siTrack->info(), std::move(pExtendedTrajectory), (pFitQuality ? pFitQuality->uniqueClone() :
nullptr));
438 ATH_MSG_DEBUG(
"rejected extension saved as Trk::Track with " << nSiStates <<
439 " fitted hits and " << nExtStates <<
" additional Outliers, score :" << extScore);
448 MsgStream &
out =
msg(MSG::INFO);
449 out <<
"::finalize() -- statistics:" << std::endl;
453 return StatusCode::SUCCESS;
460 out <<
"-------------------------------------------------------------------------------" << std::endl;
461 out <<
" Number of events processed : " << m_Nevents << std::endl;
462 out <<
" statistics by eta range ------All---Barrel---Trans.-- Endcap-- " << std::endl;
463 out <<
"-------------------------------------------------------------------------------" << std::endl;
464 out <<
" Number of tracks at input :" << std::setiosflags(std::ios::dec) << std::setw(iw)
469 out <<
" Number of not extended tracks :" << std::setiosflags(std::ios::dec) << std::setw(iw)
477 out <<
" Number of proposed ext. roads :" << std::setiosflags(std::ios::dec) << std::setw(iw)
484 out <<
"-------------------------------------------------------------------------------" << std::endl;
485 out <<
" Number of track fits :" << std::setiosflags(std::ios::dec) << std::setw(iw)
491 out <<
" + brem fits for electron tracks :" << std::setiosflags(std::ios::dec) << std::setw(iw)
498 out <<
" + brem fit to recover failed fit:" << std::setiosflags(std::ios::dec) << std::setw(iw)
506 out <<
" + brem fit to recover low score :" << std::setiosflags(std::ios::dec) << std::setw(iw)
515 out <<
"-------------------------------------------------------------------------------" << std::endl;
516 out <<
" Number of track fit failing :" << std::setiosflags(std::ios::dec) << std::setw(iw)
521 out <<
" Number of rejected extensions :" << std::setiosflags(std::ios::dec) << std::setw(iw)
528 out <<
" Number of successful extensions :" << std::setiosflags(std::ios::dec) << std::setw(iw)
536 out <<
" including brem fitted tracks :" << std::setiosflags(std::ios::dec) << std::setw(iw)
545 out <<
"-------------------------------------------------------------------------------" << std::endl;
546 out << std::setiosflags(std::ios::fixed | std::ios::showpoint) << std::setprecision(2)
548 <<
" < Endcap < " <<
m_etabounds[2] <<
" )" << std::setprecision(-1) << std::endl;
549 out <<
"-------------------------------------------------------------------------------" << std::endl;