20 std::string
to_string(
const std::vector<T>&
v) {
21 std::stringstream ostr{};
23 for (
auto x:
v)ostr<<
x<<
", ";
30 return (
pars.position().dot(parDir) > 0 ? 1 : -1) * (parDir.dot(
pos));
40 declareInterface<IMuonSystemExtensionTool>(
this);
49 return StatusCode::SUCCESS;
57 for (
unsigned int sector = 1; sector <= 16; ++sector) {
85 std::unique_ptr<Trk::PlaneSurface> surface = std::make_unique<Trk::PlaneSurface>(trans);
97 surfaces.push_back(std::move(
data));
109 constexpr
double xToZRotation = -M_PI_2;
119 Amg::Vector3D globalPosition = sectorRotation * positionInSector;
123 trans.pretranslate(globalPosition);
124 std::unique_ptr<Trk::PlaneSurface> surface = std::make_unique<Trk::PlaneSurface>(trans);
129 <<
" ref theta " << globalPosition.theta() <<
" phi " << globalPosition.phi() <<
" r "
130 << globalPosition.perp() <<
" pos " <<
Amg::toString(globalPosition)
135 surfaces.push_back(std::move(
data));
144 if (!cache.
candidate->getCaloExtension()) {
146 std::unique_ptr<Trk::CaloExtension> caloExtension =
152 cache.
candidate->setExtension(caloExtension);
160 cache.
candidate->setExtension(caloExtension);
176 std::vector<MuonSystemExtension::Intersection> intersections;
179 std::vector<std::shared_ptr<Trk::TrackParameters> > trackParametersVec;
188 <<
" r " << surface.
center().perp() <<
" z " << surface.
center().z());
190 std::unique_ptr<Trk::TrackParameters> exPars{
m_extrapolator->extrapolate(ctx, *currentPars, surface,
196 ATH_MSG_DEBUG(
"Extrapolated in event "<<ctx.eventID().event_number()<<
" track @ "<<
m_printer->print(*exPars));
207 std::shared_ptr<Trk::TrackParameters> sharedPtr{std::move(exPars)};
208 trackParametersVec.emplace_back(sharedPtr);
210 intersections.emplace_back(sharedPtr,
it);
215 currentPars = sharedPtr.get();
217 ATH_MSG_DEBUG(
"Extrapolation reached at "<<
m_printer->print(*sharedPtr)<<
" has larger uncertainties than "<<
221 ATH_MSG_DEBUG(
"Completed extrapolation: destinations " << surfaces.size() <<
" intersections " << intersections.size());
222 if (intersections.empty()){
227 cache.
candidate->setExtension(std::make_unique<MuonSystemExtension>(cache.
candidate->getCaloExtension()->muonEntryLayerIntersection(),
228 std::move(intersections)));
234 const double eta = muonEntryPars.
position().eta();
240 const double phi = muonEntryPars.
position().phi();
241 std::vector<int> sectors;
251 std::vector<int>::const_iterator sec_itr = std::find_if(
252 sectors.begin(), sectors.end(), [&map_itr](
const int& sector) ->
bool { return map_itr->second.count(sector); });
253 if (sec_itr == sectors.end()) {
260 for (
const int sector : sectors) {
264 std::stable_sort(surfaces.begin(), surfaces.end(),
266 return std::abs(pathAlongPars(muonEntryPars,s1.surfacePtr->center())) <
267 std::abs(pathAlongPars(muonEntryPars,s2.surfacePtr->center()));
271 for (
auto& s1 : surfaces) {
274 <<
", pathAlongPars "<<pathAlongPars(muonEntryPars,s1.surfacePtr->center())
275 <<std::endl<<(*s1.surfacePtr));
292 std::vector<const Trk::TrackStateOnSurface*> cmbParVec{};
295 std::vector<Muon::MuonSystemExtension::Intersection> intersections{};
303 if (!msTSOS->measurementOnTrack()) {
309 if (!
m_idHelperSvc->isMuon(measId) || pathAlongPars(msPars, msPars.position() - entryPars->
position())< 0.){
323 if (lastSurf.layerIndex == layerIdx && lastSurf.regionIndex == regionIdx && lastSurf.sector == sector) {
327 SurfaceVec::const_iterator surfItr = std::find_if(refSurfaces.begin(), refSurfaces.end(),
329 return surf.layerIndex == layerIdx;
331 if (surfItr == refSurfaces.end()) {
337 lastSurf = (*surfItr);
343 if (!tsosInChamb->measurementOnTrack())
continue;
346 if (std::abs(pathAlongPars(chPars, chPars.position() -
target.center())) >
347 std::abs(pathAlongPars(*msTSOS->trackParameters(),
348 msTSOS->trackParameters()->position() -
target.center()))) {
355 std::unique_ptr<Trk::TrackParameters> exPars{
m_extrapolator->extrapolate(ctx, *msTSOS->trackParameters(),
359 <<
", sector: "<<sector
362 <<
" to surface "<<std::endl<<
target<<std::endl
363 <<
", sector: "<<lastSurf.sector
366 <<
" pathAlongPars "<<pathAlongPars(*msTSOS->trackParameters(),
target.center())
367 <<
", dir: "<<
Amg::toString(msTSOS->trackParameters()->momentum().unit()));
370 intersections.emplace_back(std::move(exPars), lastSurf);
376 if (intersections.empty()) {
377 ATH_MSG_DEBUG(
"Failed to find the intersections for the combined track");
380 cache.
candidate->setExtension(std::make_unique<MuonSystemExtension>(entryPars, std::move(intersections)));