3636 {
3637 if (refpar2 == nullptr) {
3638 return;
3639 }
3640 const MeasurementBase *firstmuonhit = nullptr;
3641 const MeasurementBase *lastmuonhit = nullptr;
3642 const MeasurementBase *firstidhit =
3643 nullptr;
3644 const MeasurementBase *lastidhit = nullptr;
3645 const MeasurementBase *firsthit = nullptr;
3646 const MeasurementBase *lasthit = nullptr;
3647 std::vector<std::unique_ptr<GXFTrackState>> &
states = trajectory.trackStates();
3648 std::vector<std::unique_ptr<GXFTrackState>> matstates;
3649 std::unique_ptr< const std::vector < const TrackStateOnSurface *>,
3650 void (*)(const std::vector<const TrackStateOnSurface *> *) >
3652 bool matvec_used=false;
3653 std::unique_ptr<TrackParameters> startmatpar1;
3654 std::unique_ptr<TrackParameters> startmatpar2;
3664
3665 int npseudomuon1 = 0;
3666 int npseudomuon2 = 0;
3667
3668 for (auto & state : states) {
3671 GXFMaterialEffects *meff = state->materialEffects();
3672
3674 if (firstidhit == nullptr) {
3675 npseudomuon1++;
3676 } else {
3677 npseudomuon2++;
3678 }
3679 continue;
3680 }
3681
3683 if (firsthit == nullptr) {
3684 firsthit = state->measurement();
3685 if (
cache.m_acceleration) {
3686 if (tp == nullptr) {
3688 ctx,
3689 *refpar2,
3690 state->associatedSurface(),
3692 false,
3693 matEffects
3694 ).release();
3695
3696 if (tp == nullptr) {
3697 return;
3698 }
3699
3700 state->setTrackParameters(std::unique_ptr<const TrackParameters>(tp));
3701 }
3702
3703 refpar2 = tp;
3704 }
3705 }
3706 lasthit = state->measurement();
3707 if (
3711 ) {
3712 if (firstidhit == nullptr) {
3713 firstidhit = state->measurement();
3714 }
3715
3716 if ((firstidpar == nullptr) && (tp != nullptr)) {
3717 firstidpar = tp;
3718 }
3719
3720 lastidhit = state->measurement();
3721 if (tp != nullptr) {
3722 lastidpar = tp;
3723 }
3724
3726 if (firstsiliconpar == nullptr) {
3727 firstsiliconpar = tp;
3728 }
3729 lastsiliconpar = tp;
3730 }
3731 }
3732
3733 if (
3740 ) {
3741 if (firstmuonhit == nullptr) {
3742 firstmuonhit = state->measurement();
3743 if (tp != nullptr) {
3744 firstmuonpar = tp;
3745 }
3746 }
3747 lastmuonhit = state->measurement();
3748 if (tp != nullptr) {
3749 lastmuonpar = tp;
3750 }
3751 }
3752 }
3754 if (meff->deltaE() == 0) {
3755 if (firstcalopar == nullptr) {
3756 firstcalopar = state->trackParameters();
3757 }
3758 lastcalopar = state->trackParameters();
3759 }
3760 if (firstmatpar == nullptr) {
3761 firstmatpar = state->trackParameters();
3762 }
3763 }
3764 }
3765
3766 std::unique_ptr<TrackParameters> refpar;
3767 AmgVector(5) newpars = refpar2->parameters();
3768
3769 if (trajectory.m_straightline &&
m_p != 0) {
3771 }
3772
3773 refpar = refpar2->associatedSurface().createUniqueTrackParameters(
3774 newpars[0], newpars[1], newpars[2], newpars[3], newpars[4], std::nullopt
3775 );
3776
3777 if (firstmatpar != nullptr) {
3780 }
3781
3782 if ((startmatpar1 == nullptr) || ((firstidhit != nullptr) && (firstmuonhit != nullptr))) {
3785
3786 const double mass = trajectory.mass();
3787 if (mass > 200 *
MeV) {
3788 const AmgVector(5) & newpars = startmatpar2->parameters();
3789 const double oldp = std::abs(1 / newpars[
Trk::qOverP]);
3791
3792 startmatpar2 = startmatpar2->associatedSurface().createUniqueTrackParameters(
3793 newpars[0], newpars[1], newpars[2], newpars[3],
3794 sign / std::sqrt(oldp * oldp + 2 * 100 *
MeV * std::sqrt(oldp * oldp + mass * mass) + 100 *
MeV * 100 *
MeV),
3795 std::nullopt
3796 );
3797 }
3798 }
else if (trajectory.m_straightline &&
m_p != 0) {
3799 AmgVector(5) newpars = startmatpar1->parameters();
3801
3802 startmatpar1 = startmatpar1->associatedSurface().createUniqueTrackParameters(
3803 newpars[0], newpars[1], newpars[2], newpars[3], newpars[4], std::nullopt
3804 );
3805
3806 newpars = startmatpar2->parameters();
3808
3809 startmatpar2 = startmatpar2->associatedSurface().createUniqueTrackParameters(
3810 newpars[0], newpars[1], newpars[2], newpars[3], newpars[4], std::nullopt
3811 );
3812 }
3813
3814 if ((firstidhit !=
nullptr) && trajectory.numberOfSiliconHits() > 0 &&
cache.m_idmat) {
3815
3816 const DistanceSolution distsol = firstidhit->associatedSurface().straightLineDistanceEstimate(
3817 refpar->position(),
3818 refpar->momentum().unit()
3819 );
3820
3822
3823 if (distance < 0 && distsol.numberOfSolutions() > 0 && !
cache.m_acceleration) {
3824 ATH_MSG_DEBUG("Obtaining upstream layers from Extrapolator");
3825
3826 const Surface *destsurf = &firstidhit->associatedSurface();
3827 std::unique_ptr<const TrackParameters> tmppar;
3828
3829 if (firstmuonhit != nullptr) {
3830 const bool caloEntranceIsValid = ensureValidEntranceCalo(ctx, cache);
3831 if (caloEntranceIsValid) {
3832 tmppar = m_extrapolator->extrapolateToVolume(ctx,
3833 *startmatpar1,
3834 *cache.m_caloEntrance,
3835 oppositeMomentum,
3836 Trk::nonInteracting);
3837
3838 if (tmppar != nullptr) {
3839 destsurf = &tmppar->associatedSurface();
3840 }
3841 }
3842 }
3843
3844 if (matvec_used)
cache.m_matTempStore.push_back( std::move(matvec) );
3846 *startmatpar1,
3847 *destsurf,
3849 false, matEffects) );
3850 matvec_used=false;
3851
3852 if (matvec && !matvec->empty()) {
3853 for (int i = (int)matvec->size() - 1; i > -1; i--) {
3854 const MaterialEffectsBase *meb = (*matvec)[i]->materialEffectsOnTrack();
3855 if (meb) {
3856 if (meb->derivedType() == MaterialEffectsBase::MATERIAL_EFFECTS_ON_TRACK) {
3857 const MaterialEffectsOnTrack *meot = static_cast < const MaterialEffectsOnTrack * >(meb);
3858 std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(*meot);
3859 const TrackParameters * newpars = (*matvec)[i]->trackParameters() != nullptr ? (*matvec)[i]->trackParameters()->clone() : nullptr;
3860 meff->setSigmaDeltaE(0);
3861 matstates.push_back(std::make_unique<GXFTrackState>(
3862 std::move(meff),
3863 std::unique_ptr<const TrackParameters>(newpars)
3864 ));
3865 matvec_used=true;
3866 }
3867 }
3868 }
3869 }
3870 }
3871 }
3872
3873 if ((lastidhit !=
nullptr) && trajectory.numberOfSiliconHits() > 0 &&
cache.m_idmat) {
3874 const DistanceSolution distsol = lastidhit->associatedSurface().straightLineDistanceEstimate(
3875 refpar->position(),
3876 refpar->momentum().unit()
3877 );
3878
3880
3881 if (distance > 0 && distsol.numberOfSolutions() > 0) {
3882 ATH_MSG_DEBUG(
"Obtaining downstream ID layers from Extrapolator");
3883 const Surface *destsurf = &lastidhit->associatedSurface();
3884 std::unique_ptr<const TrackParameters> tmppar;
3885 std::unique_ptr<Surface> calosurf;
3886 if (firstmuonhit != nullptr) {
3888 if (caloEntranceIsValid) {
3890 *startmatpar2,
3891 *
cache.m_caloEntrance,
3894 }
3895
3896 if (tmppar != nullptr) {
3897 const CylinderSurface *cylcalosurf = nullptr;
3898
3900 cylcalosurf = static_cast<const CylinderSurface *>(&tmppar->associatedSurface());
3901
3902 const DiscSurface *disccalosurf = nullptr;
3903
3905 disccalosurf = static_cast<const DiscSurface *>(&tmppar->associatedSurface());
3906
3907 if (cylcalosurf != nullptr) {
3909 const CylinderBounds & cylbounds = cylcalosurf->bounds();
3910 const double radius = cylbounds.r();
3911 const double hlength = cylbounds.halflengthZ();
3912 calosurf = std::make_unique<CylinderSurface>(trans, radius - 1, hlength);
3913 } else if (disccalosurf != nullptr) {
3914 const double newz = (
3915 disccalosurf->center().
z() > 0 ?
3916 disccalosurf->center().z() - 1 :
3917 disccalosurf->center().z() + 1
3918 );
3919
3921 disccalosurf->center().x(),
3922 disccalosurf->center().y(),
3923 newz
3924 );
3925
3927 trans.translation() << newpos;
3928
3929 const DiscBounds *discbounds = static_cast<const DiscBounds *>(&disccalosurf->bounds());
3930 const double rmin = discbounds->rMin();
3931 const double rmax = discbounds->rMax();
3932 calosurf = std::make_unique<DiscSurface>(trans, rmin, rmax);
3933 }
3934 destsurf = calosurf.release();
3935 }
3936 }
3937
3938 if (matvec_used)
cache.m_matTempStore.push_back( std::move(matvec) );
3940 ctx, *startmatpar2, *destsurf,
alongMomentum,
false, matEffects));
3941 matvec_used = false;
3942
3943 if (matvec && !matvec->empty()) {
3944 for (const auto & i : *matvec) {
3945 const Trk::MaterialEffectsBase * meb =
i->materialEffectsOnTrack();
3946
3947 if (meb) {
3949 const MaterialEffectsOnTrack *meot = static_cast<const MaterialEffectsOnTrack *>(meb);
3950 std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(*meot);
3951 if (
cache.m_fiteloss && (meot->energyLoss() !=
nullptr)) {
3952 meff->setSigmaDeltaE(meot->energyLoss()->sigmaDeltaE());
3953 }
3954
3956 meff->setDeltaE(-5);
3957
3958 if (trajectory.numberOfTRTHits() == 0) {
3959 meff->setScatteringSigmas(0, 0);
3960 }
3961
3962 meff->setSigmaDeltaE(50);
3963 }
3964
3965 const TrackParameters * newparams =
i->trackParameters() !=
nullptr ?
i->trackParameters()->clone() :
nullptr;
3966
3967 matstates.push_back(std::make_unique<GXFTrackState>(
3968 std::move(meff),
3969 std::unique_ptr<const TrackParameters>(newparams)
3970 ));
3971 matvec_used=true;
3972 }
3973 }
3974 }
3975 } else {
3977 }
3978 }
3979 }
3980
3981 if (
cache.m_calomat && (firstmuonhit !=
nullptr) && (firstidhit !=
nullptr)) {
3983
3984 std::vector<MaterialEffectsOnTrack> calomeots =
m_calotool->extrapolationSurfacesAndEffects(
3986 *prop,
3987 *lastidpar,
3988 firstmuonhit->associatedSurface(),
3991 );
3992
3993 if (calomeots.empty()) {
3995 return;
3996 }
3997
3998 std::unique_ptr<const TrackParameters> prevtrackpars =
unique_clone(lastidpar);
3999 if (lasthit == lastmuonhit) {
4000 for (
int i = 0;
i < (
int) calomeots.size();
i++) {
4002
4003 std::unique_ptr<const TrackParameters> layerpar(
m_propagator->propagateParameters(
4004 ctx,
4005 *prevtrackpars,
4006 calomeots[i].associatedSurface(),
4007 propdir,
4008 false,
4009 trajectory.m_fieldprop,
4011 ));
4012
4013 if (layerpar == nullptr) {
4015 return;
4016 }
4017
4018 std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(calomeots[i]);
4019
4020 if (i == 2) {
4021 lastcalopar = layerpar.get();
4022 }
4023
4024 if (i == 1) {
4025 const double qoverp = layerpar->parameters()[
Trk::qOverP];
4026 double qoverpbrem = 0;
4027
4028 if (
4029 npseudomuon2 < 2 &&
4030 (firstmuonpar != nullptr) &&
4031 std::abs(firstmuonpar->parameters()[
Trk::qOverP]) > 1.e-9
4032 ) {
4033 qoverpbrem = firstmuonpar->parameters()[
Trk::qOverP];
4034 } else {
4035 const double sign = (qoverp > 0) ? 1 : -1;
4036 qoverpbrem =
sign / (1 / std::abs(qoverp) - std::abs(calomeots[i].energyLoss()->deltaE()));
4037 }
4038
4039 const AmgVector(5) & newpar = layerpar->parameters();
4040
4041 layerpar = layerpar->associatedSurface().createUniqueTrackParameters(
4042 newpar[0], newpar[1], newpar[2], newpar[3], qoverpbrem, std::nullopt
4043 );
4044 meff->setdelta_p(1000 * (qoverpbrem - qoverp));
4045 }
4046
4047 matstates.push_back(std::make_unique<GXFTrackState>(
4048 std::move(meff),
4049 std::unique_ptr<const TrackParameters>(layerpar != nullptr ? layerpar->clone() : nullptr)
4050 ));
4051 prevtrackpars = std::move(layerpar);
4052 }
4053 }
4054
4055 if (
4056 firsthit == firstmuonhit &&
4057 (!
cache.m_getmaterialfromtrack || lasthit == lastidhit)
4058 ) {
4060 for (
int i = 0;
i < (
int) calomeots.size();
i++) {
4062 std::unique_ptr<const TrackParameters> layerpar(
m_propagator->propagateParameters(
4063 ctx,
4064 *prevtrackpars,
4065 calomeots[i].associatedSurface(),
4066 propdir,
4067 false,
4068 trajectory.m_fieldprop,
4070 ));
4071
4072 if (layerpar == nullptr) {
4074 return;
4075 }
4076
4077 std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(calomeots[i]);
4078
4079 if (i == 2) {
4081 }
4082
4084
4085 if (i == 1) {
4086 const double qoverpbrem = layerpar->parameters()[
Trk::qOverP];
4087 double qoverp = 0;
4088
4089 if (
4090 npseudomuon1 < 2 &&
4091 (lastmuonpar != nullptr) &&
4092 std::abs(lastmuonpar->parameters()[
Trk::qOverP]) > 1.e-9
4093 ) {
4095 } else {
4096 const double sign = (qoverpbrem > 0) ? 1 : -1;
4097 qoverp =
sign / (1 / std::abs(qoverpbrem) + std::abs(calomeots[i].energyLoss()->deltaE()));
4098 }
4099
4100 meff->setdelta_p(1000 * (qoverpbrem - qoverp));
4101 const AmgVector(5) & newpar = layerpar->parameters();
4102
4103 prevtrackpars = layerpar->associatedSurface().createUniqueTrackParameters(
4104 newpar[0], newpar[1], newpar[2], newpar[3], qoverp, std::nullopt
4105 );
4106 }
4107
4108 matstates.insert(matstates.begin(), std::make_unique<GXFTrackState>(std::move(meff), std::move(layerpar)));
4109 }
4110 }
4111 }
4112
4113 if (lasthit == lastmuonhit &&
cache.m_extmat) {
4114 std::unique_ptr<const Trk::TrackParameters> muonpar1;
4115
4116 if (lastcalopar != nullptr) {
4118 if (msEntranceIsValid) {
4119 if (
cache.m_msEntrance->inside(lastcalopar->position())) {
4121 *lastcalopar,
4122 *
cache.m_msEntrance,
4125
4126 if (muonpar1 != nullptr) {
4132 rot.col(0) = curvU;
4133 rot.col(1) = curvV;
4134 rot.col(2) = trackdir;
4136 trans.linear().matrix() << rot;
4137 trans.translation() << muonpar1->position() - .1 * trackdir;
4138 PlaneSurface const curvlinsurf(trans);
4139
4140 std::unique_ptr<const TrackParameters> curvlinpar(
m_extrapolator->extrapolateDirectly(
4141 ctx,
4142 *muonpar1,
4143 curvlinsurf,
4146 ));
4147
4148 if (curvlinpar != nullptr) {
4149 muonpar1 = std::move(curvlinpar);
4150 }
4151 }
4152 } else {
4153 muonpar1 = std::unique_ptr<TrackParameters>(lastcalopar->clone());
4154 }
4155 }
4156 } else {
4157 muonpar1 = std::unique_ptr<TrackParameters>(refpar->clone());
4158 }
4159
4160 DistanceSolution distsol;
4161
4162 if (muonpar1 != nullptr) {
4163 distsol = lastmuonhit->associatedSurface().straightLineDistanceEstimate(
4164 muonpar1->position(),
4165 muonpar1->momentum().unit()
4166 );
4167 }
4168
4170
4171 if ((distance > 0) and(distsol.numberOfSolutions() >
4172 0) and (firstmuonhit != nullptr)) {
4173 distsol = firstmuonhit->associatedSurface().straightLineDistanceEstimate(
4174 muonpar1->position(),
4175 muonpar1->momentum().unit()
4176 );
4177
4179
4180 if (distsol.numberOfSolutions() == 1) {
4182 } else if (distsol.numberOfSolutions() == 2) {
4184 std::abs(distsol.first()) < std::abs(distsol.second()) ?
4185 distsol.first() :
4186 distsol.second()
4187 );
4188 }
4189
4190 if (distance < 0 && distsol.numberOfSolutions() > 0 && (firstidhit == nullptr)) {
4191 if (firstmuonpar != nullptr) {
4192 AmgVector(5) newpars = firstmuonpar->parameters();
4193
4194 if (trajectory.m_straightline &&
m_p != 0) {
4196 }
4197
4198 muonpar1 = firstmuonpar->associatedSurface().createUniqueTrackParameters(
4199 newpars[0], newpars[1], newpars[2], newpars[3], newpars[4], std::nullopt
4200 );
4201 } else {
4202 std::unique_ptr<const TrackParameters> tmppar(
m_propagator->propagateParameters(
4203 ctx,
4204 *muonpar1,
4205 firstmuonhit->associatedSurface(),
4207 false,
4208 trajectory.m_fieldprop,
4210 ));
4211
4212 if (tmppar != nullptr) {
4213 muonpar1 = std::move(tmppar);
4214 }
4215 }
4216 }
4217
4219 ATH_MSG_DEBUG(
"Obtaining downstream layers from Extrapolator");
4220 if (matvec_used)
cache.m_matTempStore.push_back( std::move(matvec) );
4222 *prevtp,
4223 states.back()->associatedSurface(),
4225 false,
4227 matvec_used = false;
4228
4231 return;
4232 }
4233
4234 if (matvec && !matvec->empty()) {
4235 for (
int j = 0;
j < (
int) matvec->size();
j++) {
4236 const MaterialEffectsBase *meb = (*matvec)[
j]->materialEffectsOnTrack();
4237
4238 if (meb) {
4240 const MaterialEffectsOnTrack *meot = static_cast<const MaterialEffectsOnTrack *>(meb);
4241 std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(*meot);
4242
4243 if (
4244 !trajectory.m_straightline &&
4245 (meot->energyLoss() != nullptr) &&
4246 std::abs(meff->deltaE()) > 25 &&
4247 std::abs((*matvec)[j]->trackParameters()->position().z()) < 13000
4248 ) {
4249 meff->setSigmaDeltaE(meot->energyLoss()->sigmaDeltaE());
4250 }
4251
4252 const TrackParameters * newparams = (*matvec)[
j]->trackParameters() !=
nullptr ? (*matvec)[
j]->trackParameters()->
clone() :
nullptr;
4253
4254 matstates.push_back(std::make_unique<GXFTrackState>(
4255 std::move(meff),
4256 std::unique_ptr<const TrackParameters>(newparams)
4257 ));
4258 matvec_used=true;
4259 }
4260 }
4261 }
4262 }
4263 }
4264 }
4265
4266 if (firsthit == firstmuonhit &&
cache.m_extmat && (firstcalopar !=
nullptr)) {
4267 std::unique_ptr<const Trk::TrackParameters> muonpar1;
4268
4270 if (msEntranceIsValid) {
4271 if (
cache.m_msEntrance->inside(firstcalopar->position())) {
4273 *firstcalopar,
4274 *
cache.m_msEntrance,
4277
4278 if (muonpar1 != nullptr) {
4284 rot.col(0) = curvU;
4285 rot.col(1) = curvV;
4286 rot.col(2) = trackdir;
4288 trans.linear().matrix() << rot;
4289 trans.translation() << muonpar1->position() - .1 * trackdir;
4290 const PlaneSurface curvlinsurf(trans);
4291
4292 std::unique_ptr<const TrackParameters> curvlinpar(
m_extrapolator->extrapolateDirectly(
4293 ctx,
4294 *muonpar1,
4295 curvlinsurf,
4298 ));
4299
4300 if (curvlinpar != nullptr) {
4301 muonpar1 = std::move(curvlinpar);
4302 }
4303 }
4304 } else {
4305 muonpar1 = std::unique_ptr<const TrackParameters>(firstcalopar->clone());
4306 }
4307 }
4308
4309 DistanceSolution distsol;
4310
4311 if (muonpar1 != nullptr) {
4312 distsol = firstmuonhit->associatedSurface().straightLineDistanceEstimate(
4313 muonpar1->position(),
4314 muonpar1->momentum().unit()
4315 );
4316 }
4317
4319
4320 if (distance < 0 && distsol.numberOfSolutions() > 0) {
4322 ATH_MSG_DEBUG(
"Collecting upstream muon material from extrapolator");
4323 if (matvec_used)
cache.m_matTempStore.push_back( std::move(matvec) );
4325 *prevtp,
4326 states[0]->associatedSurface(),
4328 false,
4330 matvec_used = false;
4331
4332 if (matvec && !matvec->empty()) {
4333 ATH_MSG_DEBUG(
"Retrieved " << matvec->size() <<
" material states");
4334
4335 for (
int j = 0;
j < (
int) matvec->size();
j++) {
4336 const MaterialEffectsBase *meb = (*matvec)[
j]->materialEffectsOnTrack();
4337
4338 if (meb != nullptr) {
4339
4340
4342 const MaterialEffectsOnTrack *meot = static_cast<const MaterialEffectsOnTrack *>(meb);
4343 std::unique_ptr<GXFMaterialEffects> meff = std::make_unique<GXFMaterialEffects>(*meot);
4344
4345 if (
4346 !trajectory.m_straightline &&
4347 (meot->energyLoss() != nullptr) &&
4348 std::abs(meff->deltaE()) > 25 &&
4349 std::abs((*matvec)[j]->trackParameters()->position().z()) < 13000
4350 ) {
4351 meff->setSigmaDeltaE(meot->energyLoss()->sigmaDeltaE());
4352 }
4353
4355 (*matvec)[
j]->trackParameters() !=
nullptr
4356 ? (*matvec)[
j]->trackParameters()->
clone()
4357 : nullptr;
4358
4359 matstates.insert(matstates.begin(), std::make_unique<GXFTrackState>(
4360 std::move(meff),
4361 std::unique_ptr<const TrackParameters>(tmpparams)
4362 ));
4363 matvec_used=true;
4364 }
4365 }
4366 }
4367 }
4368 }
4369 }
4370
4372
4373
4374 std::vector<std::unique_ptr<GXFTrackState>> & newstates =
states;
4375 std::vector<std::unique_ptr<GXFTrackState>> oldstates = std::move(newstates);
4376
4377 newstates.clear();
4378 newstates.reserve(oldstates.size() + matstates.size());
4379
4380 int layerno = 0;
4381 int firstlayerno = -1;
4382
4383 if (
cache.m_acceleration) {
4384 trajectory.addBasicState(std::move(oldstates[0]));
4385 }
4386
4387 const double cosphi = std::cos(refpar->parameters()[
Trk::phi0]);
4388 const double sinphi = std::sin(refpar->parameters()[
Trk::phi0]);
4389
4390 for (
int i =
cache.m_acceleration ? 1 : 0; i < (
int) oldstates.size(); i++) {
4391 bool addlayer = true;
4392
4393 while (addlayer && layerno < (int) matstates.size()) {
4394 addlayer = false;
4395 const TrackParameters *layerpar = matstates[layerno]->trackParameters();
4396
4397 const DistanceSolution distsol = oldstates[
i]->associatedSurface().straightLineDistanceEstimate(
4398 layerpar->position(),
4399 layerpar->momentum().unit()
4400 );
4401
4403
4404 if (distance > 0 && distsol.numberOfSolutions() > 0) {
4405 addlayer = true;
4406 }
4407
4409 const double cylinderradius = layerpar->associatedSurface().bounds().r();
4410 const double trackimpact = std::abs(-refpar->position().x() * sinphi + refpar->position().y() * cosphi);
4411
4412 if (trackimpact > cylinderradius - 5 * mm) {
4413 layerno++;
4414 continue;
4415 }
4416 }
4417
4418 if (i == (int) oldstates.size() - 1) {
4419 addlayer = true;
4420 }
4421
4422 if (addlayer) {
4423 GXFMaterialEffects *meff = matstates[layerno]->materialEffects();
4424
4425 if (meff->sigmaDeltaPhi() > .4 || (meff->sigmaDeltaPhi() == 0 && meff->sigmaDeltaE() <= 0)) {
4426 if (meff->sigmaDeltaPhi() > .4) {
4427 ATH_MSG_DEBUG(
"Material state with excessive scattering, skipping it");
4428 }
4429
4430 if (meff->sigmaDeltaPhi() == 0) {
4432 }
4433
4434 layerno++;
4435 continue;
4436 }
4437
4438 if (firstlayerno < 0) {
4439 firstlayerno = layerno;
4440 }
4441
4442 trajectory.addMaterialState(std::move(matstates[layerno]));
4443
4444 if ((layerpar !=
nullptr) && matEffects !=
pion && matEffects !=
muon) {
4445 const TrackingVolume *tvol =
m_navigator->volume(ctx,layerpar->position());
4446 const Layer *lay =
nullptr;
4447
4448 if (tvol != nullptr) {
4449 lay = (tvol->closestMaterialLayer(layerpar->position(),layerpar->momentum().normalized())).object;
4450 }
4451
4452 const MaterialProperties *matprop = lay != nullptr ? lay->fullUpdateMaterialProperties(*layerpar) : nullptr;
4453 meff->setMaterialProperties(matprop);
4454 }
4455
4456 layerno++;
4457 }
4458 }
4459 trajectory.addBasicState(std::move(oldstates[i]));
4460 }
4461
4462 ATH_MSG_DEBUG(
"Total X0: " << trajectory.totalX0() <<
" total eloss: " << trajectory.totalEnergyLoss());
4463
4464 if (matvec_used)
cache.m_matTempStore.push_back( std::move(matvec) );
4465 }
#define ATH_MSG_WARNING(x)
Gaudi::Property< double > m_p
Gaudi::Property< bool > m_rejectLargeNScat
ToolHandle< INavigator > m_navigator
ToolHandle< IExtrapolator > m_extrapolator
bool ensureValidEntranceMuonSpectrometer(const EventContext &ctx, Cache &cache) const
ToolHandle< IMaterialEffectsOnTrackProvider > m_calotool
@ MATERIAL_EFFECTS_ON_TRACK
virtual MaterialEffectsDerivedType derivedType() const =0
Returns the concrete derived type.
virtual ParametersBase< DIM, T > * clone() const override=0
clone method for polymorphic deep copy
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ BremPoint
This represents a brem point on the track, and so will contain TrackParameters and MaterialEffectsBas...
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
@ Scatterer
This represents a scattering point on the track, and so will contain TrackParameters and MaterialEffe...
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Eigen::Affine3d Transform3D
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Eigen::Matrix< double, 3, 1 > Vector3D
double getDistance(const xAOD::Vertex *vtx1, const xAOD::Vertex *vtx2)
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
MeasurementType
enum describing the flavour of MeasurementBase
PropDirection
PropDirection, enum for direction of the propagation.
std::unique_ptr< T > unique_clone(const T *v)
@ z
global position (cartesian)
@ u
Enums for curvilinear frames.
static void objVectorDeleter(const std::vector< const T * > *ptr)