20 std::stringstream sstr;
21 sstr<<
"position: "<<
pars.position().x()<<
", "<<
pars.position().y()<<
", "<<
pars.position().z()
22 <<
" -- momentum: "<<
pars.momentum().x()<<
", "<<
pars.momentum().y()<<
", "<<
pars.momentum().z()<<
" ";
23 if (
pars.covariance())
34 declareInterface<IMuonSystemExtensionTool>(
this);
43 return StatusCode::SUCCESS;
53 for (
unsigned int sector = 1; sector <= 16; ++sector) {
84 trans.pretranslate(globalPosition);
88 surfaces.push_back(std::move(
data));
98 << globalPosition.x() <<
" hit z " << globalPosition.z() <<
" lpos3d " << lpos3d.x() <<
" "
99 << lpos3d.y() <<
" " << lpos3d.z() <<
" lpos " << lpos[
Trk::loc1] <<
" " << lpos[
Trk::loc2]
100 <<
" center " << surface->
center().z() <<
" normal: phi " << surface->
normal().phi()
101 <<
" theta " << surface->
normal().theta() <<
" normal: x " << surface->
normal().x() <<
" y "
102 << surface->
normal().y() <<
" z " << surface->
normal().z());
103 globalPosition[0] += 100;
115 constexpr
double xToZRotation = -M_PI_2;
125 Amg::Vector3D globalPosition = sectorRotation * positionInSector;
129 trans.pretranslate(globalPosition);
133 surfaces.push_back(std::move(
data));
140 surface->
globalToLocal(globalPosition, globalPosition, lpos);
144 <<
" ref theta " << globalPosition.theta() <<
" phi " << globalPosition.phi() <<
" r "
145 << globalPosition.perp() <<
" pos " << globalPosition.x() <<
" " << globalPosition.y() <<
" "
146 << globalPosition.z() <<
" lpos3d " << lpos3d.x() <<
" " << lpos3d.y() <<
" " << lpos3d.z()
147 <<
" normal: x " << surface->
normal().x() <<
" y " << surface->
normal().y() <<
" z "
148 << surface->
normal().z());
156 if (!cache.
candidate->getCaloExtension()) {
158 std::unique_ptr<Trk::CaloExtension> caloExtension =
164 cache.
candidate->setExtension(caloExtension);
172 cache.
candidate->setExtension(caloExtension);
188 std::vector<MuonSystemExtension::Intersection> intersections;
191 std::vector<std::shared_ptr<const Trk::TrackParameters> > trackParametersVec;
200 <<
" r " << surface.
center().perp() <<
" z " << surface.
center().z());
202 std::unique_ptr<const Trk::TrackParameters> exPars{
220 std::shared_ptr<const Trk::TrackParameters> sharedPtr{std::move(exPars)};
221 trackParametersVec.emplace_back(sharedPtr);
230 currentPars = sharedPtr.get();
236 ATH_MSG_DEBUG(
"Completed extrapolation: destinations " << surfaces.size() <<
" intersections " << intersections.size());
237 if (intersections.empty()){
243 std::make_unique<MuonSystemExtension>(cache.
candidate->getCaloExtension()->muonEntryLayerIntersection(), std::move(intersections)));
250 std::vector<int> sectors;
256 for (
const int& sec : sectors) {
257 if (
it.sector % 2 == sec % 2) {
262 ATH_MSG_DEBUG(
" sector " <<
it.sector <<
" selected " << sector <<
" nsectors " << sectors);
284 std::vector<int> sectors;
294 std::vector<int>::const_iterator sec_itr = std::find_if(
295 sectors.begin(), sectors.end(), [&map_itr](
const int& sector) ->
bool { return map_itr->second.count(sector); });
296 if (sec_itr == sectors.end()) {
303 for (
const int sector : sectors) {
309 const MuonLayerSurface&
s2) {
return s1.surfacePtr->center().perp() <
s2.surfacePtr->center().perp(); }
311 return std::abs(s1.surfacePtr->center().z()) < std::abs(
s2.surfacePtr->center().z());
314 std::stable_sort(surfaces.begin(), surfaces.end(), sortFunction);
330 std::vector<const Trk::TrackStateOnSurface*> ms_tsos;
331 ms_tsos.reserve(cmb_tsos->
size());
333 if (!(tsos->type(Trk::TrackStateOnSurface::Perigee) || tsos->type(Trk::TrackStateOnSurface::Parameter)))
335 const Trk::TrackParameters* params = tsos->trackParameters();
336 if (!params) return false;
337 const Trk::Surface& surf = params->associatedSurface();
338 if (!surf.associatedDetectorElement()) {
339 return entry_pars->associatedSurface().normal().dot(params->position() - entry_pars->associatedSurface().center())>0;
341 return m_idHelperSvc->isMuon(surf.associatedDetectorElement()->identify());
344 if (ms_tsos.empty()){
345 ATH_MSG_VERBOSE(
"A combined track without track parameters in the MS. THat should not happen");
349 SurfaceVec surfaces = getSurfacesForIntersection(*entry_pars, cache);
350 if (surfaces.empty()) {
351 ATH_MSG_DEBUG(
"MS extenion without surfaces.. "<<cache.candidate->toString());
355 std::vector<Muon::MuonSystemExtension::Intersection> intersections;
357 std::vector<const Trk::TrackStateOnSurface*>::const_iterator itr = ms_tsos.begin();
358 std::vector<const Trk::TrackStateOnSurface*>::const_iterator
end = ms_tsos.end();
363 return std::abs(surf.
normal().dot(
a->trackParameters()->position() - surf.
center())) <
364 std::abs(surf.
normal().dot(
b->trackParameters()->position() - surf.
center()));
376 std::shared_ptr<const Trk::TrackParameters> exPars{m_extrapolator->extrapolate(ctx, *trk_pars, surf,
dir,
false,
Trk::muon)};
381 MuonSystemExtension::Intersection
intersect = makeInterSection(exPars,
it);
386 if (intersections.empty()) {
387 ATH_MSG_DEBUG(
"Failed to find the intersections for the combined track");
390 cache.candidate->setExtension(std::make_unique<MuonSystemExtension>(entry_pars, std::move(intersections)));