From d67f4429484730f0d526cd47708c4d504275d552 Mon Sep 17 00:00:00 2001 From: michaelmackenzie Date: Fri, 13 Nov 2026 10:33:41 -0600 Subject: [PATCH 1/7] Add optional TS5 face intersection to KKExtrap Add a TS5_Face SurfaceId and a KinKalGeom disk filling the TSDA hole, 1 mm downstream of the TSDA back face. With ExtrapolationSettings.ToTS5 (default false, requires Upstream) the upstream sweep records crossings of it before the TSDA ends the sweep. Tracks reaching the TS this way are highly cosmic-like. Co-Authored-By: Claude Opus 5.5 --- DataProducts/inc/SurfaceId.hh | 3 ++- DataProducts/src/SurfaceId.cc | 1 + GeometryService/src/KinKalGeomMaker.cc | 7 ++++++- KinKalGeom/inc/DetectorSolenoid.hh | 7 +++++-- Mu2eKinKal/fcl/prolog.fcl | 1 + Mu2eKinKal/inc/KKExtrap.hh | 19 ++++++++++++++++--- Mu2eKinKal/inc/KKFitSettings.hh | 1 + 7 files changed, 32 insertions(+), 7 deletions(-) diff --git a/DataProducts/inc/SurfaceId.hh b/DataProducts/inc/SurfaceId.hh index d38fb54b9a..2cf6c20f00 100644 --- a/DataProducts/inc/SurfaceId.hh +++ b/DataProducts/inc/SurfaceId.hh @@ -21,6 +21,7 @@ namespace mu2e { DS_CryoInner, DS_CryoOuter, DS_ShieldInner, DS_ShieldOuter, DS_Coil, IPA=90, IPA_Front, IPA_Back, OPA=95, TSDA, // Absorbers in the DS + TS5_Face=97, // the TS5 aperture (TSDA hole), just downstream of the TSDA ST_Front=100,ST_Back, ST_Inner, ST_Outer, ST_Foils, ST_Wires, // stopping target bounding surfaces and components TCRV=200, // CRV test plane (deprecated) CRV_EX=201, CRV_T1, CRV_T2, // keep values 201-203 for extracted geometry compatibility @@ -43,7 +44,7 @@ namespace mu2e { EMC_Disk_0_InnerRing=322, EMC_Disk_1_InnerRing // calorimeter case inner rings (index 0,1 = Al via case front, hole; 2,3 = CF ring via its inner radius, case front; 4 = Al via CF ring inner radius) }; // Update this counter whenever you add/remove surface IDs from the enum above. - static constexpr std::size_t nSurfaceIds = 76; + static constexpr std::size_t nSurfaceIds = 77; static std::string const& typeName(); static std::map const& names(); }; diff --git a/DataProducts/src/SurfaceId.cc b/DataProducts/src/SurfaceId.cc index 88d641af38..d31215b93b 100644 --- a/DataProducts/src/SurfaceId.cc +++ b/DataProducts/src/SurfaceId.cc @@ -38,6 +38,7 @@ namespace mu2e { std::make_pair(SurfaceIdEnum::IPA_Back, "IPA_Back"), std::make_pair(SurfaceIdEnum::OPA, "OPA"), std::make_pair(SurfaceIdEnum::TSDA, "TSDA"), + std::make_pair(SurfaceIdEnum::TS5_Face, "TS5_Face"), std::make_pair(SurfaceIdEnum::ST_Front, "ST_Front"), std::make_pair(SurfaceIdEnum::ST_Back, "ST_Back"), std::make_pair(SurfaceIdEnum::ST_Inner, "ST_Inner"), diff --git a/GeometryService/src/KinKalGeomMaker.cc b/GeometryService/src/KinKalGeomMaker.cc index 883edfa50a..47090cc55b 100644 --- a/GeometryService/src/KinKalGeomMaker.cc +++ b/GeometryService/src/KinKalGeomMaker.cc @@ -373,6 +373,10 @@ namespace mu2e { auto ipaback= std::make_shared(ipa->backDisk()); auto opa= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,-3766),454.0,728.4,2125.0); // inner surface auto tsda= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,-5967),235.0,525.0); // back surface + // TS5 face: a disk filling the TSDA hole, offset just downstream of the TSDA back surface so an upstream-going track + // crosses it before the TSDA. A track crossing it leaves the DS into the TS, which is rare for anything but cosmics + static constexpr double ts5FaceOffset = 1.0; // mm + auto ts5face= std::make_shared(tsda->normal(),tsda->uDirection(),tsda->center()+VEC3(0.0,0.0,ts5FaceOffset),tsda->innerRadius()); kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::DS_Front),std::static_pointer_cast(front))); kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::DS_Back),std::static_pointer_cast(back))); @@ -383,8 +387,9 @@ namespace mu2e { kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::IPA_Back),std::static_pointer_cast(ipaback))); kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::OPA),std::static_pointer_cast(opa))); kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::TSDA),std::static_pointer_cast(tsda))); + kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::TS5_Face),std::static_pointer_cast(ts5face))); - kkg_->ds_ = std::make_unique(inner, outer, front, back, ipa, ipafront, ipaback, opa, tsda, materialCylinders); + kkg_->ds_ = std::make_unique(inner, outer, front, back, ipa, ipafront, ipaback, opa, tsda, ts5face, materialCylinders); } void KinKalGeomMaker::makeTarget() { diff --git a/KinKalGeom/inc/DetectorSolenoid.hh b/KinKalGeom/inc/DetectorSolenoid.hh index c697d3b27e..e592a62bc1 100644 --- a/KinKalGeom/inc/DetectorSolenoid.hh +++ b/KinKalGeom/inc/DetectorSolenoid.hh @@ -32,9 +32,9 @@ namespace mu2e { // default constructor with nominal geometry DetectorSolenoid( CylPtr inner, CylPtr outer, DiskPtr front, DiskPtr back, CylPtr ipa, DiskPtr ipafront, DiskPtr ipaback, - FruPtr opa, AnnPtr tsda, MaterialCylinderCollection const& materialCylinders = MaterialCylinderCollection()) : + FruPtr opa, AnnPtr tsda, DiskPtr ts5face, MaterialCylinderCollection const& materialCylinders = MaterialCylinderCollection()) : inner_(inner) , outer_(outer), front_(front), back_(back), - ipa_(ipa), ipa_front_(ipafront), ipa_back_(ipaback), opa_(opa), tsda_(tsda), + ipa_(ipa), ipa_front_(ipafront), ipa_back_(ipaback), opa_(opa), tsda_(tsda), ts5face_(ts5face), materialCylinders_(materialCylinders) {} @@ -49,6 +49,7 @@ namespace mu2e { auto const& innerProtonAbsorberBack() const { return *ipa_back_; } auto const& outerProtonAbsorber() const { return *opa_; } auto const& upstreamAbsorber() const { return *tsda_; } + auto const& ts5Face() const { return *ts5face_; } // return by ptr auto const& outerPtr() const { return outer_; } auto const& innerPtr() const { return inner_; } @@ -59,6 +60,7 @@ namespace mu2e { auto const& innerProtonAbsorberBackPtr() const { return ipa_back_; } auto const& outerProtonAbsorberPtr() const { return opa_; } auto const& upstreamAbsorberPtr() const { return tsda_; } + auto const& ts5FacePtr() const { return ts5face_; } auto const& materialCylinders() const { return materialCylinders_; } private: CylPtr inner_; // inner cryostat cylinder boundary @@ -70,6 +72,7 @@ namespace mu2e { DiskPtr ipa_back_; FruPtr opa_; // outer proton absorber AnnPtr tsda_; // TS downstream absorber + DiskPtr ts5face_; // TS5 aperture: the TSDA hole, just downstream of the TSDA. Tracks crossing it enter the TS MaterialCylinderCollection materialCylinders_; // passive cylindrical material shells }; } diff --git a/Mu2eKinKal/fcl/prolog.fcl b/Mu2eKinKal/fcl/prolog.fcl index c6e5ae4e23..02b3cdf8b6 100644 --- a/Mu2eKinKal/fcl/prolog.fcl +++ b/Mu2eKinKal/fcl/prolog.fcl @@ -389,6 +389,7 @@ Mu2eKinKal : { Upstream : true BackToTracker : false ToOPA : true + ToTS5 : false # record tracks that reach the TS through the TSDA hole (cosmic-like) ToCRV : false ToCaloD0 : true ToCaloD1 : true diff --git a/Mu2eKinKal/inc/KKExtrap.hh b/Mu2eKinKal/inc/KKExtrap.hh index c27f549be2..7037dc8d6f 100644 --- a/Mu2eKinKal/inc/KKExtrap.hh +++ b/Mu2eKinKal/inc/KKExtrap.hh @@ -55,7 +55,7 @@ namespace mu2e { template bool reflect(ExtrapolateSweep& xs, KinKal::ParticleTrajectory const& ftraj, TimeDir tdir) const; int debug_; double btol_, intertol_, maxdt_, maxdtstep_, minv_; - bool backToTracker_, extrapolateOPA_, toTrackerPerimeter_, upstream_, toCRV_; + bool backToTracker_, extrapolateOPA_, toTS5_, toTrackerPerimeter_, upstream_, toCRV_; bool toCaloD0_, toCaloD1_, toCaloMaterial_; // nominal literal like the hard-coded KinKalGeom IPA surface (KinKalGeomMaker::makeDS); TODO: take it from the geometry service. // The ST foil thicknesses come from the geometry service (KKGeom::StoppingTarget::foilThickness) @@ -75,13 +75,17 @@ namespace mu2e { minv_(extrapconfig.MinV()), backToTracker_(extrapconfig.BackToTracker()), extrapolateOPA_(extrapconfig.ToOPA()), + toTS5_(extrapconfig.ToTS5()), toTrackerPerimeter_(extrapconfig.ToTrackerPerimeter()), upstream_(extrapconfig.Upstream()), toCRV_(extrapconfig.ToCRV()), toCaloD0_(extrapconfig.ToCaloD0()), toCaloD1_(extrapconfig.ToCaloD1()), toCaloMaterial_(extrapconfig.ToCaloMaterial()) - {} + { + if(toTS5_ && !upstream_) + throw cet::exception("RECO") << "mu2e::KKExtrap: ToTS5 requires Upstream extrapolation" << std::endl; + } inline void KKExtrap::checkConfig(KinKal::Config const& config) const { if(config.bfcorr_ && config.mindtstep_ > maxdtstep_) @@ -160,7 +164,7 @@ namespace mu2e { auto back = face("TT_Back",trk.backPtr().get()); tgts.push_back(back); } - // upstream: IPA, ST foils, TSDA (ends the sweep), OPA, and optionally the tracker entrance after a reflection + // upstream: IPA, ST foils, optionally the TS5 face, TSDA (ends the sweep), OPA, and optionally the tracker entrance after a reflection if(updir && upstream_){ auto const& ipa = ds.innerProtonAbsorberPtr(); SweepTarget ipatg; @@ -194,6 +198,15 @@ namespace mu2e { tg.zreglo_ = stzlo; tg.zreghi_ = stzhi; tgts.push_back(tg); } + if(toTS5_){ + // record-only: the TSDA hole just downstream of the TSDA, crossed just before the TSDA ends the sweep. + // A crossing inside its bounds means the track leaves the DS into the TS, which is highly cosmic-like. + SweepTarget ts5; + ts5.sid_ = SurfaceId("TS5_Face"); + ts5.surf_ = ds.ts5FacePtr().get(); + ts5.drives_ = false; // the TSDA plane drives the extension + tgts.push_back(ts5); + } SweepTarget tsda; tsda.reach_ = SweepTarget::zplane; tsda.sid_ = SurfaceId("TSDA"); diff --git a/Mu2eKinKal/inc/KKFitSettings.hh b/Mu2eKinKal/inc/KKFitSettings.hh index 33e65fa3a7..f6d36d046a 100644 --- a/Mu2eKinKal/inc/KKFitSettings.hh +++ b/Mu2eKinKal/inc/KKFitSettings.hh @@ -129,6 +129,7 @@ namespace mu2e { fhicl::Atom ToTrackerPerimeter { Name("ToTrackerPerimeter"), Comment("Extrapolate tracks to the tracker perimeter (z-ends and outer wall)") }; fhicl::Atom Upstream { Name("Upstream"), Comment("Extrapolate tracks upstream") }; fhicl::Atom ToOPA { Name("ToOPA"), Comment("Test tracks for intersection with the OPA") }; + fhicl::Atom ToTS5 { Name("ToTS5"), Comment("Record upstream intersections with the TS5 face (the TSDA hole, just downstream of the TSDA); tracks reaching the TS are cosmic-like. Requires Upstream"), false }; fhicl::Atom ToCRV { Name("ToCRV"), Comment("Extrapolate tracks to the CRV modules") }; fhicl::Atom ToCaloD0 { Name("ToCaloD0"), Comment("Extrapolate tracks to the calorimeter disk0 surfaces") }; fhicl::Atom ToCaloD1 { Name("ToCaloD1"), Comment("Extrapolate tracks to the calorimeter disk1 surfaces") }; From 69765ec2d647dac29212a1d58d8f3c31c620cf29 Mon Sep 17 00:00:00 2001 From: michaelmackenzie Date: Fri, 13 Nov 2026 10:36:05 -0600 Subject: [PATCH 2/7] Add TS5 face case to ExtrapolateSweepTest Mirror the KKExtrap ToTS5 targets (record-only TS5 disk 1 mm downstream of the terminal TSDA plane) and check, for a line and a LoopHelix in both time directions, that a track through the TSDA hole records TS5_Face just before the TSDA, while one hitting the TSDA body or passing outside it records only the TSDA. Co-Authored-By: Claude Opus 5.5 --- Mu2eKinKal/src/ExtrapolateSweepTest_main.cc | 63 +++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc b/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc index 18a2c13a3f..9b5bd5cef3 100644 --- a/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc +++ b/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc @@ -739,6 +739,67 @@ namespace { require(limited == 1 && unlimited == 2,"notBefore crossings " + std::to_string(limited) + " and " + std::to_string(unlimited)); } + // The TS5 face (KKExtrap ToTS5): a record-only disk filling the TSDA hole just downstream of the TSDA. An upstream track + // through the hole records it just before the terminal TSDA plane; one hitting the TSDA body or passing outside it does not. + // Geometry literals follow KinKalGeomMaker::makeDS. + template void ts5Face(TimeDir dir) { + double const ztsda = -5967.0, rin = 235.0, rout = 525.0, offset = 1.0; + KinKal::Annulus tsda(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,ztsda),rin,rout); + KinKal::Disk face(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,ztsda+offset),rin); + SweepTarget ts5; + ts5.sid_ = mu2e::SurfaceId(mu2e::SurfaceIdEnum::TS5_Face); + ts5.surf_ = &face; + ts5.drives_ = false; + SweepTarget tsdatg; + tsdatg.reach_ = SweepTarget::zplane; + tsdatg.sid_ = mu2e::SurfaceId(mu2e::SurfaceIdEnum::TSDA); + tsdatg.surf_ = &tsda; + tsdatg.zval_ = ztsda; + tsdatg.terminal_ = true; + tsdatg.inbounds_ = false; + bool forward = dir == TimeDir::forwards; + for(double radius : {0.0,100.0,150.0,400.0,700.0}){ + // the particle moves upstream (-z) along the sweep direction, from z = -5800 to z = -6100 + double zstart = forward ? -5800.0 : -6100.0; + KinKal::ParticleState state(VEC3(radius,0.0,zstart),VEC3(0.0,10.0,forward ? -100.0 : 100.0),0.0,105.658,-1); + KTRAJ traj0(state,VEC3(0.0,0.0,1.0),TimeRange(0.0,1.0)); + traj0.setRange(TimeRange(0.0,300.0/std::fabs(traj0.velocity(0.0).Z()))); + KinKal::ParticleTrajectory traj(traj0); + double rmin = 1.0e100, rmax = 0.0; + for(unsigned i = 0; i <= 200; ++i){ + double rho = traj.position3(traj.range().begin()+traj.range().range()*i/200.0).Rho(); + rmin = std::min(rmin,rho); rmax = std::max(rmax,rho); + } + bool inhole = rmax < rin; + require(inhole || rmin > rin,"TS5 fixture straddles the TSDA hole edge"); + SweepTargetCollection targets{ts5,tsdatg}; + ExtrapolateSweep sweep(targets,dir,1.0e6,1.0e6,1.0e-4,tol,1.0e-6,0); + sweep.start(forward ? traj.range().begin() : traj.range().end()); + sweep.limit(forward ? traj.range().end() : traj.range().begin(),false); + std::vector> found; + while(!sweep.needsExtrapolation(traj,dir) && sweep.hasCrossing()){ + auto const& tg = targets[sweep.crossing().itarget_]; + found.emplace_back(tg.sid_,sweep.crossing().inter_); + sweep.accept(); + if(tg.terminal_) break; + require(found.size() < 10,"runaway TS5 crossings"); + } + require(!sweep.failed(),"TS5 sweep failed: " + sweep.error()); + require(found.size() == (inhole ? 2u : 1u),"TS5 sweep found " + std::to_string(found.size()) + " crossings at radius " + std::to_string(radius)); + require(found.back().first == tsdatg.sid_,"TS5 sweep did not end at the TSDA"); + require(std::fabs(found.back().second.pos_.Z()-ztsda) < 10.0*tol,"TSDA crossing off its plane"); + if(inhole){ + auto const& inter = found.front().second; + require(found.front().first == ts5.sid_,"TS5 face not crossed first"); + require(inter.inbounds_ && inter.pos_.Rho() < rin,"TS5 crossing outside the TSDA hole"); + require(std::fabs(inter.pos_.Z()-(ztsda+offset)) < 10.0*tol,"TS5 crossing off its plane"); + double sgn = forward ? 1.0 : -1.0; + require(sgn*inter.pdir_.Z() < 0.0,"TS5 crossing not moving upstream along the sweep"); + require(sgn*(found.back().second.time_-inter.time_) > 0.0,"TS5 face not crossed before the TSDA"); + } + } + } + void emptySearch() { KinKal::ParticleState state(VEC3(0.0,0.0,0.0),VEC3(0.0,0.0,100.0),0.0,105.658,1); KinKal::KinematicLine line(state,VEC3(0.0,0.0,0.0),TimeRange(0.0,0.1)); @@ -770,6 +831,8 @@ int main() { reachBound(dir); shellIncidence(dir); notBefore(dir); + ts5Face(dir); + ts5Face(dir); invalidBoundaryInterior(dir,true); invalidBoundaryInterior(dir,false); closeCoplanar(dir); From 7cf7d7792a467c3fe80489b1588a34204935e5f6 Mon Sep 17 00:00:00 2001 From: michaelmackenzie Date: Fri, 13 Nov 2026 11:30:36 -0600 Subject: [PATCH 3/7] Extend TS5 face to the DS inner radius Make the TS5_Face disk cover the whole TS5 face out to the DS inner radius instead of only the TSDA hole, so tracks reaching the TS end of the DS are recorded whether they then pass the TSDA hole, body or outside it. Update the ExtrapolateSweepTest case to match, with a track beyond the DS inner radius recording only the TSDA. Co-Authored-By: Claude Opus 5.5 --- DataProducts/inc/SurfaceId.hh | 2 +- GeometryService/src/KinKalGeomMaker.cc | 6 +++--- KinKalGeom/inc/DetectorSolenoid.hh | 2 +- Mu2eKinKal/fcl/prolog.fcl | 2 +- Mu2eKinKal/inc/KKExtrap.hh | 4 ++-- Mu2eKinKal/inc/KKFitSettings.hh | 2 +- Mu2eKinKal/src/ExtrapolateSweepTest_main.cc | 23 +++++++++++---------- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/DataProducts/inc/SurfaceId.hh b/DataProducts/inc/SurfaceId.hh index 2cf6c20f00..7b259932d4 100644 --- a/DataProducts/inc/SurfaceId.hh +++ b/DataProducts/inc/SurfaceId.hh @@ -21,7 +21,7 @@ namespace mu2e { DS_CryoInner, DS_CryoOuter, DS_ShieldInner, DS_ShieldOuter, DS_Coil, IPA=90, IPA_Front, IPA_Back, OPA=95, TSDA, // Absorbers in the DS - TS5_Face=97, // the TS5 aperture (TSDA hole), just downstream of the TSDA + TS5_Face=97, // the TS5 face out to the DS inner radius, just downstream of the TSDA ST_Front=100,ST_Back, ST_Inner, ST_Outer, ST_Foils, ST_Wires, // stopping target bounding surfaces and components TCRV=200, // CRV test plane (deprecated) CRV_EX=201, CRV_T1, CRV_T2, // keep values 201-203 for extracted geometry compatibility diff --git a/GeometryService/src/KinKalGeomMaker.cc b/GeometryService/src/KinKalGeomMaker.cc index 47090cc55b..4d490a92c2 100644 --- a/GeometryService/src/KinKalGeomMaker.cc +++ b/GeometryService/src/KinKalGeomMaker.cc @@ -373,10 +373,10 @@ namespace mu2e { auto ipaback= std::make_shared(ipa->backDisk()); auto opa= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,-3766),454.0,728.4,2125.0); // inner surface auto tsda= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,-5967),235.0,525.0); // back surface - // TS5 face: a disk filling the TSDA hole, offset just downstream of the TSDA back surface so an upstream-going track - // crosses it before the TSDA. A track crossing it leaves the DS into the TS, which is rare for anything but cosmics + // TS5 face: a disk out to the DS inner radius covering the whole TS5 face, offset just downstream of the TSDA back surface + // so an upstream-going track crosses it before the TSDA. A track crossing it reaches the TS end of the DS, which is rare for anything but cosmics static constexpr double ts5FaceOffset = 1.0; // mm - auto ts5face= std::make_shared(tsda->normal(),tsda->uDirection(),tsda->center()+VEC3(0.0,0.0,ts5FaceOffset),tsda->innerRadius()); + auto ts5face= std::make_shared(tsda->normal(),tsda->uDirection(),tsda->center()+VEC3(0.0,0.0,ts5FaceOffset),inner->radius()); kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::DS_Front),std::static_pointer_cast(front))); kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::DS_Back),std::static_pointer_cast(back))); diff --git a/KinKalGeom/inc/DetectorSolenoid.hh b/KinKalGeom/inc/DetectorSolenoid.hh index e592a62bc1..a51ef31dd3 100644 --- a/KinKalGeom/inc/DetectorSolenoid.hh +++ b/KinKalGeom/inc/DetectorSolenoid.hh @@ -72,7 +72,7 @@ namespace mu2e { DiskPtr ipa_back_; FruPtr opa_; // outer proton absorber AnnPtr tsda_; // TS downstream absorber - DiskPtr ts5face_; // TS5 aperture: the TSDA hole, just downstream of the TSDA. Tracks crossing it enter the TS + DiskPtr ts5face_; // TS5 face out to the DS inner radius, just downstream of the TSDA. Tracks crossing it reach the TS end of the DS MaterialCylinderCollection materialCylinders_; // passive cylindrical material shells }; } diff --git a/Mu2eKinKal/fcl/prolog.fcl b/Mu2eKinKal/fcl/prolog.fcl index 02b3cdf8b6..ae4a19ed15 100644 --- a/Mu2eKinKal/fcl/prolog.fcl +++ b/Mu2eKinKal/fcl/prolog.fcl @@ -389,7 +389,7 @@ Mu2eKinKal : { Upstream : true BackToTracker : false ToOPA : true - ToTS5 : false # record tracks that reach the TS through the TSDA hole (cosmic-like) + ToTS5 : false # record tracks that reach the TS5 face, just downstream of the TSDA (cosmic-like) ToCRV : false ToCaloD0 : true ToCaloD1 : true diff --git a/Mu2eKinKal/inc/KKExtrap.hh b/Mu2eKinKal/inc/KKExtrap.hh index 7037dc8d6f..bf648be084 100644 --- a/Mu2eKinKal/inc/KKExtrap.hh +++ b/Mu2eKinKal/inc/KKExtrap.hh @@ -199,8 +199,8 @@ namespace mu2e { tgts.push_back(tg); } if(toTS5_){ - // record-only: the TSDA hole just downstream of the TSDA, crossed just before the TSDA ends the sweep. - // A crossing inside its bounds means the track leaves the DS into the TS, which is highly cosmic-like. + // record-only: the TS5 face out to the DS inner radius, just downstream of the TSDA, crossed just before the TSDA ends the sweep. + // A crossing inside its bounds means the track reaches the TS end of the DS, which is highly cosmic-like. SweepTarget ts5; ts5.sid_ = SurfaceId("TS5_Face"); ts5.surf_ = ds.ts5FacePtr().get(); diff --git a/Mu2eKinKal/inc/KKFitSettings.hh b/Mu2eKinKal/inc/KKFitSettings.hh index f6d36d046a..6e9d9af356 100644 --- a/Mu2eKinKal/inc/KKFitSettings.hh +++ b/Mu2eKinKal/inc/KKFitSettings.hh @@ -129,7 +129,7 @@ namespace mu2e { fhicl::Atom ToTrackerPerimeter { Name("ToTrackerPerimeter"), Comment("Extrapolate tracks to the tracker perimeter (z-ends and outer wall)") }; fhicl::Atom Upstream { Name("Upstream"), Comment("Extrapolate tracks upstream") }; fhicl::Atom ToOPA { Name("ToOPA"), Comment("Test tracks for intersection with the OPA") }; - fhicl::Atom ToTS5 { Name("ToTS5"), Comment("Record upstream intersections with the TS5 face (the TSDA hole, just downstream of the TSDA); tracks reaching the TS are cosmic-like. Requires Upstream"), false }; + fhicl::Atom ToTS5 { Name("ToTS5"), Comment("Record upstream intersections with the TS5 face (out to the DS inner radius, just downstream of the TSDA); tracks reaching the TS are cosmic-like. Requires Upstream"), false }; fhicl::Atom ToCRV { Name("ToCRV"), Comment("Extrapolate tracks to the CRV modules") }; fhicl::Atom ToCaloD0 { Name("ToCaloD0"), Comment("Extrapolate tracks to the calorimeter disk0 surfaces") }; fhicl::Atom ToCaloD1 { Name("ToCaloD1"), Comment("Extrapolate tracks to the calorimeter disk1 surfaces") }; diff --git a/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc b/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc index 9b5bd5cef3..b43c4f9eec 100644 --- a/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc +++ b/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc @@ -739,13 +739,13 @@ namespace { require(limited == 1 && unlimited == 2,"notBefore crossings " + std::to_string(limited) + " and " + std::to_string(unlimited)); } - // The TS5 face (KKExtrap ToTS5): a record-only disk filling the TSDA hole just downstream of the TSDA. An upstream track - // through the hole records it just before the terminal TSDA plane; one hitting the TSDA body or passing outside it does not. - // Geometry literals follow KinKalGeomMaker::makeDS. + // The TS5 face (KKExtrap ToTS5): a record-only disk out to the DS inner radius just downstream of the TSDA. An upstream track + // inside that radius records it just before the terminal TSDA plane, whether it then passes the TSDA hole, body or outside; + // one beyond the DS inner radius records only the TSDA. Geometry literals follow KinKalGeomMaker::makeDS. template void ts5Face(TimeDir dir) { - double const ztsda = -5967.0, rin = 235.0, rout = 525.0, offset = 1.0; + double const ztsda = -5967.0, rin = 235.0, rout = 525.0, rface = 950.0, offset = 1.0; KinKal::Annulus tsda(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,ztsda),rin,rout); - KinKal::Disk face(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,ztsda+offset),rin); + KinKal::Disk face(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,ztsda+offset),rface); SweepTarget ts5; ts5.sid_ = mu2e::SurfaceId(mu2e::SurfaceIdEnum::TS5_Face); ts5.surf_ = &face; @@ -758,7 +758,7 @@ namespace { tsdatg.terminal_ = true; tsdatg.inbounds_ = false; bool forward = dir == TimeDir::forwards; - for(double radius : {0.0,100.0,150.0,400.0,700.0}){ + for(double radius : {0.0,100.0,400.0,700.0,1100.0}){ // TSDA hole, hole, body, outside the TSDA, beyond the DS inner radius // the particle moves upstream (-z) along the sweep direction, from z = -5800 to z = -6100 double zstart = forward ? -5800.0 : -6100.0; KinKal::ParticleState state(VEC3(radius,0.0,zstart),VEC3(0.0,10.0,forward ? -100.0 : 100.0),0.0,105.658,-1); @@ -770,8 +770,9 @@ namespace { double rho = traj.position3(traj.range().begin()+traj.range().range()*i/200.0).Rho(); rmin = std::min(rmin,rho); rmax = std::max(rmax,rho); } - bool inhole = rmax < rin; - require(inhole || rmin > rin,"TS5 fixture straddles the TSDA hole edge"); + bool onface = rmax < rface; + require(onface || rmin > rface,"TS5 fixture straddles the TS5 face edge"); + require(rmax < rin || rmin > rin,"TS5 fixture straddles the TSDA hole edge"); SweepTargetCollection targets{ts5,tsdatg}; ExtrapolateSweep sweep(targets,dir,1.0e6,1.0e6,1.0e-4,tol,1.0e-6,0); sweep.start(forward ? traj.range().begin() : traj.range().end()); @@ -785,13 +786,13 @@ namespace { require(found.size() < 10,"runaway TS5 crossings"); } require(!sweep.failed(),"TS5 sweep failed: " + sweep.error()); - require(found.size() == (inhole ? 2u : 1u),"TS5 sweep found " + std::to_string(found.size()) + " crossings at radius " + std::to_string(radius)); + require(found.size() == (onface ? 2u : 1u),"TS5 sweep found " + std::to_string(found.size()) + " crossings at radius " + std::to_string(radius)); require(found.back().first == tsdatg.sid_,"TS5 sweep did not end at the TSDA"); require(std::fabs(found.back().second.pos_.Z()-ztsda) < 10.0*tol,"TSDA crossing off its plane"); - if(inhole){ + if(onface){ auto const& inter = found.front().second; require(found.front().first == ts5.sid_,"TS5 face not crossed first"); - require(inter.inbounds_ && inter.pos_.Rho() < rin,"TS5 crossing outside the TSDA hole"); + require(inter.inbounds_ && inter.pos_.Rho() < rface,"TS5 crossing outside the DS inner radius"); require(std::fabs(inter.pos_.Z()-(ztsda+offset)) < 10.0*tol,"TS5 crossing off its plane"); double sgn = forward ? 1.0 : -1.0; require(sgn*inter.pdir_.Z() < 0.0,"TS5 crossing not moving upstream along the sweep"); From abd3f2412c400c04e777163985595d94b312e624 Mon Sep 17 00:00:00 2001 From: michaelmackenzie Date: Fri, 13 Nov 2026 12:35:02 -0600 Subject: [PATCH 4/7] Correct TS5_Face documentation per review Describe the TS5_Face record as what it is: the extrapolated helix reaching the TSDA plane inside the DS bore. For downstream fits it comes from the backwards extrapolation, which for CE continues past the stopping target, so it is not by itself a cosmic tag. The KinKal TSDA plane is the absorber mid-plane, not its back surface, so the disk sits inside the absorber; fix that comment and stop calling the disk "downstream of the TSDA". Co-Authored-By: Claude Opus 5.5 --- DataProducts/inc/SurfaceId.hh | 2 +- GeometryService/src/KinKalGeomMaker.cc | 7 ++++--- KinKalGeom/inc/DetectorSolenoid.hh | 2 +- Mu2eKinKal/fcl/prolog.fcl | 2 +- Mu2eKinKal/inc/KKExtrap.hh | 6 ++++-- Mu2eKinKal/inc/KKFitSettings.hh | 2 +- Mu2eKinKal/src/ExtrapolateSweepTest_main.cc | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/DataProducts/inc/SurfaceId.hh b/DataProducts/inc/SurfaceId.hh index 7b259932d4..bcc5e09749 100644 --- a/DataProducts/inc/SurfaceId.hh +++ b/DataProducts/inc/SurfaceId.hh @@ -21,7 +21,7 @@ namespace mu2e { DS_CryoInner, DS_CryoOuter, DS_ShieldInner, DS_ShieldOuter, DS_Coil, IPA=90, IPA_Front, IPA_Back, OPA=95, TSDA, // Absorbers in the DS - TS5_Face=97, // the TS5 face out to the DS inner radius, just downstream of the TSDA + TS5_Face=97, // disk out to the DS inner radius 1 mm downstream of the KinKal TSDA plane (the TSDA mid-plane) ST_Front=100,ST_Back, ST_Inner, ST_Outer, ST_Foils, ST_Wires, // stopping target bounding surfaces and components TCRV=200, // CRV test plane (deprecated) CRV_EX=201, CRV_T1, CRV_T2, // keep values 201-203 for extracted geometry compatibility diff --git a/GeometryService/src/KinKalGeomMaker.cc b/GeometryService/src/KinKalGeomMaker.cc index 4d490a92c2..1f9db78f60 100644 --- a/GeometryService/src/KinKalGeomMaker.cc +++ b/GeometryService/src/KinKalGeomMaker.cc @@ -372,9 +372,10 @@ namespace mu2e { auto ipafront= std::make_shared(ipa->frontDisk()); auto ipaback= std::make_shared(ipa->backDisk()); auto opa= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,-3766),454.0,728.4,2125.0); // inner surface - auto tsda= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,-5967),235.0,525.0); // back surface - // TS5 face: a disk out to the DS inner radius covering the whole TS5 face, offset just downstream of the TSDA back surface - // so an upstream-going track crosses it before the TSDA. A track crossing it reaches the TS end of the DS, which is rare for anything but cosmics + auto tsda= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,-5967),235.0,525.0); // mid-plane: TSdA_v02 spans z = -5991.8 to -5941.0 + // TS5 face: a disk out to the DS inner radius, 1 mm downstream of the KinKal TSDA plane (so inside the absorber), so an + // upstream-going extrapolation crosses it just before the TSDA plane. A crossing means the extrapolated helix reaches the + // TSDA plane inside the DS bore; it is not by itself a cosmic tag (see KKExtrap ToTS5) static constexpr double ts5FaceOffset = 1.0; // mm auto ts5face= std::make_shared(tsda->normal(),tsda->uDirection(),tsda->center()+VEC3(0.0,0.0,ts5FaceOffset),inner->radius()); diff --git a/KinKalGeom/inc/DetectorSolenoid.hh b/KinKalGeom/inc/DetectorSolenoid.hh index a51ef31dd3..c16489d7af 100644 --- a/KinKalGeom/inc/DetectorSolenoid.hh +++ b/KinKalGeom/inc/DetectorSolenoid.hh @@ -72,7 +72,7 @@ namespace mu2e { DiskPtr ipa_back_; FruPtr opa_; // outer proton absorber AnnPtr tsda_; // TS downstream absorber - DiskPtr ts5face_; // TS5 face out to the DS inner radius, just downstream of the TSDA. Tracks crossing it reach the TS end of the DS + DiskPtr ts5face_; // TS5 face: disk out to the DS inner radius, 1 mm downstream of the KinKal TSDA plane (inside the absorber) MaterialCylinderCollection materialCylinders_; // passive cylindrical material shells }; } diff --git a/Mu2eKinKal/fcl/prolog.fcl b/Mu2eKinKal/fcl/prolog.fcl index ae4a19ed15..cda8df68e9 100644 --- a/Mu2eKinKal/fcl/prolog.fcl +++ b/Mu2eKinKal/fcl/prolog.fcl @@ -389,7 +389,7 @@ Mu2eKinKal : { Upstream : true BackToTracker : false ToOPA : true - ToTS5 : false # record tracks that reach the TS5 face, just downstream of the TSDA (cosmic-like) + ToTS5 : false # record where the upstream extrapolation reaches the TSDA plane inside the DS bore (TS5_Face) ToCRV : false ToCaloD0 : true ToCaloD1 : true diff --git a/Mu2eKinKal/inc/KKExtrap.hh b/Mu2eKinKal/inc/KKExtrap.hh index bf648be084..fc52b9b707 100644 --- a/Mu2eKinKal/inc/KKExtrap.hh +++ b/Mu2eKinKal/inc/KKExtrap.hh @@ -199,8 +199,10 @@ namespace mu2e { tgts.push_back(tg); } if(toTS5_){ - // record-only: the TS5 face out to the DS inner radius, just downstream of the TSDA, crossed just before the TSDA ends the sweep. - // A crossing inside its bounds means the track reaches the TS end of the DS, which is highly cosmic-like. + // record-only: a disk out to the DS inner radius 1 mm downstream of the TSDA plane, crossed just before the TSDA plane + // ends the sweep. A crossing means the extrapolated helix reaches the TSDA plane inside the DS bore. For a downstream + // fit it comes from the backwards-in-time extrapolation, which for a conversion electron continues upstream past the + // stopping target, so it is not by itself a cosmic tag. SweepTarget ts5; ts5.sid_ = SurfaceId("TS5_Face"); ts5.surf_ = ds.ts5FacePtr().get(); diff --git a/Mu2eKinKal/inc/KKFitSettings.hh b/Mu2eKinKal/inc/KKFitSettings.hh index 6e9d9af356..ee944db444 100644 --- a/Mu2eKinKal/inc/KKFitSettings.hh +++ b/Mu2eKinKal/inc/KKFitSettings.hh @@ -129,7 +129,7 @@ namespace mu2e { fhicl::Atom ToTrackerPerimeter { Name("ToTrackerPerimeter"), Comment("Extrapolate tracks to the tracker perimeter (z-ends and outer wall)") }; fhicl::Atom Upstream { Name("Upstream"), Comment("Extrapolate tracks upstream") }; fhicl::Atom ToOPA { Name("ToOPA"), Comment("Test tracks for intersection with the OPA") }; - fhicl::Atom ToTS5 { Name("ToTS5"), Comment("Record upstream intersections with the TS5 face (out to the DS inner radius, just downstream of the TSDA); tracks reaching the TS are cosmic-like. Requires Upstream"), false }; + fhicl::Atom ToTS5 { Name("ToTS5"), Comment("Record where the upstream extrapolation reaches the TSDA plane inside the DS bore (TS5_Face: disk out to the DS inner radius, 1 mm downstream of the TSDA plane). For downstream fits this comes from the backwards extrapolation, so it is not by itself a cosmic tag. Requires Upstream"), false }; fhicl::Atom ToCRV { Name("ToCRV"), Comment("Extrapolate tracks to the CRV modules") }; fhicl::Atom ToCaloD0 { Name("ToCaloD0"), Comment("Extrapolate tracks to the calorimeter disk0 surfaces") }; fhicl::Atom ToCaloD1 { Name("ToCaloD1"), Comment("Extrapolate tracks to the calorimeter disk1 surfaces") }; diff --git a/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc b/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc index b43c4f9eec..5954eeaf28 100644 --- a/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc +++ b/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc @@ -739,7 +739,7 @@ namespace { require(limited == 1 && unlimited == 2,"notBefore crossings " + std::to_string(limited) + " and " + std::to_string(unlimited)); } - // The TS5 face (KKExtrap ToTS5): a record-only disk out to the DS inner radius just downstream of the TSDA. An upstream track + // The TS5 face (KKExtrap ToTS5): a record-only disk out to the DS inner radius 1 mm downstream of the TSDA plane. An upstream track // inside that radius records it just before the terminal TSDA plane, whether it then passes the TSDA hole, body or outside; // one beyond the DS inner radius records only the TSDA. Geometry literals follow KinKalGeomMaker::makeDS. template void ts5Face(TimeDir dir) { From 6c0ab8af21017f605218d26a1fa0ef8740b7042c Mon Sep 17 00:00:00 2001 From: michaelmackenzie Date: Fri, 13 Nov 2026 12:46:40 -0600 Subject: [PATCH 5/7] Enable ToTS5 by default in LHDRIFTXTRAP Turn on the TS5_Face record in the LoopHelix drift extrapolation settings, so the default LoopHelix fits and the Production regrows that use LHDRIFTXTRAP record it. The fhicl default stays false, so LHSEEDXTRAP, KLXTRAP and CHXTRAP (Upstream false) are unaffected. Co-Authored-By: Claude Opus 5.5 --- Mu2eKinKal/fcl/prolog.fcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mu2eKinKal/fcl/prolog.fcl b/Mu2eKinKal/fcl/prolog.fcl index cda8df68e9..8b79ed43b9 100644 --- a/Mu2eKinKal/fcl/prolog.fcl +++ b/Mu2eKinKal/fcl/prolog.fcl @@ -389,7 +389,7 @@ Mu2eKinKal : { Upstream : true BackToTracker : false ToOPA : true - ToTS5 : false # record where the upstream extrapolation reaches the TSDA plane inside the DS bore (TS5_Face) + ToTS5 : true # record where the upstream extrapolation reaches the TSDA plane inside the DS bore (TS5_Face); not by itself a cosmic tag ToCRV : false ToCaloD0 : true ToCaloD1 : true From 15c2e8a3baf062c42a8a69b9c9d5c9ab423a3f3e Mon Sep 17 00:00:00 2001 From: michaelmackenzie Date: Tue, 17 Nov 2026 10:00:24 -0600 Subject: [PATCH 6/7] Sample TS5_Face via SampleSurfaces; build TSDA and TS5_Face from TSdA geometry Per review: drop the KKExtrap ToTS5 sweep target and the DetectorSolenoid accessor, and get the TS5_Face intersection by adding it to SampleSurfaces (LHDriftFit and RegrowLH). Sampling runs after extrapolation over the extended trajectory, so the upstream sweep (which ends on the TSDA plane) covers it. Build the KinKal TSDA annulus and TS5_Face from GeomHandle instead of hard-coded numbers. TSdA gains rIn() (tsda.rin, or the TS5 inner cryostat radius), which constructTSdA now uses too. The TSDA plane stays at the absorber mid-plane; TS5_Face is a disk out to the DS inner radius on the absorber's downstream face. Geometries without a TSdA keep the nominal plane. Co-Authored-By: Claude Opus 5.5 --- BeamlineGeom/inc/TSdA.hh | 4 ++ BeamlineGeom/src/TSdA.cc | 2 +- DataProducts/inc/SurfaceId.hh | 2 +- GeometryService/inc/TSdAMaker.hh | 3 +- GeometryService/src/GeometryService.cc | 2 +- GeometryService/src/KinKalGeomMaker.cc | 29 +++++++--- GeometryService/src/TSdAMaker.cc | 12 +++- KinKalGeom/inc/DetectorSolenoid.hh | 7 +-- Mu2eG4/src/constructTSdA.cc | 10 +--- Mu2eKinKal/fcl/prolog.fcl | 7 ++- Mu2eKinKal/inc/KKExtrap.hh | 21 +------ Mu2eKinKal/inc/KKFitSettings.hh | 1 - Mu2eKinKal/src/ExtrapolateSweepTest_main.cc | 64 --------------------- 13 files changed, 52 insertions(+), 112 deletions(-) diff --git a/BeamlineGeom/inc/TSdA.hh b/BeamlineGeom/inc/TSdA.hh index c5eafb8a40..6797a617ef 100644 --- a/BeamlineGeom/inc/TSdA.hh +++ b/BeamlineGeom/inc/TSdA.hh @@ -16,6 +16,8 @@ namespace mu2e { class TSdA : virtual public Detector { public: + double rIn() const { return _rIn; } // inner (hole) radius + double r4() const { return _r4; } double halfLength4() const { return _halfLength4; } @@ -33,6 +35,8 @@ namespace mu2e { // Private ctr: the class should be only obtained via TSdA::TSdAMaker. TSdA(); + double _rIn; + double _r4; double _halfLength4; diff --git a/BeamlineGeom/src/TSdA.cc b/BeamlineGeom/src/TSdA.cc index d48233d4c6..3c4630922b 100644 --- a/BeamlineGeom/src/TSdA.cc +++ b/BeamlineGeom/src/TSdA.cc @@ -2,6 +2,6 @@ namespace mu2e { TSdA::TSdA() - : _r4(0.), _halfLength4(0.0) + : _rIn(0.), _r4(0.), _halfLength4(0.0) {} } diff --git a/DataProducts/inc/SurfaceId.hh b/DataProducts/inc/SurfaceId.hh index bcc5e09749..4b937e1bdf 100644 --- a/DataProducts/inc/SurfaceId.hh +++ b/DataProducts/inc/SurfaceId.hh @@ -21,7 +21,7 @@ namespace mu2e { DS_CryoInner, DS_CryoOuter, DS_ShieldInner, DS_ShieldOuter, DS_Coil, IPA=90, IPA_Front, IPA_Back, OPA=95, TSDA, // Absorbers in the DS - TS5_Face=97, // disk out to the DS inner radius 1 mm downstream of the KinKal TSDA plane (the TSDA mid-plane) + TS5_Face=97, // disk out to the DS inner radius on the downstream face of the TSDA ST_Front=100,ST_Back, ST_Inner, ST_Outer, ST_Foils, ST_Wires, // stopping target bounding surfaces and components TCRV=200, // CRV test plane (deprecated) CRV_EX=201, CRV_T1, CRV_T2, // keep values 201-203 for extracted geometry compatibility diff --git a/GeometryService/inc/TSdAMaker.hh b/GeometryService/inc/TSdAMaker.hh index e77f107782..20a8cd5c0a 100644 --- a/GeometryService/inc/TSdAMaker.hh +++ b/GeometryService/inc/TSdAMaker.hh @@ -6,11 +6,12 @@ namespace mu2e { class SimpleConfig; } namespace mu2e { class TSdA; } namespace mu2e { class DetectorSolenoid; } +namespace mu2e { class Beamline; } namespace mu2e { class TSdAMaker { public: - static std::unique_ptr make(const SimpleConfig& config, const DetectorSolenoid& ds); + static std::unique_ptr make(const SimpleConfig& config, const DetectorSolenoid& ds, const Beamline& beamline); }; } diff --git a/GeometryService/src/GeometryService.cc b/GeometryService/src/GeometryService.cc index 3336c7a307..874b9c2c60 100644 --- a/GeometryService/src/GeometryService.cc +++ b/GeometryService/src/GeometryService.cc @@ -301,7 +301,7 @@ namespace mu2e { } if(_config->getBool("hasTSdA",false)){ - addDetector( TSdAMaker::make(*_config,ds) ); + addDetector( TSdAMaker::make(*_config,ds,beamline) ); } if(_config->getBool("hasExternalShielding",false)) { diff --git a/GeometryService/src/KinKalGeomMaker.cc b/GeometryService/src/KinKalGeomMaker.cc index 1f9db78f60..a61feb81d0 100644 --- a/GeometryService/src/KinKalGeomMaker.cc +++ b/GeometryService/src/KinKalGeomMaker.cc @@ -22,6 +22,7 @@ #include "Offline/GeometryService/inc/DetectorSystem.hh" #include "Offline/DetectorSolenoidGeom/inc/DetectorSolenoid.hh" #include "Offline/StoppingTargetGeom/inc/StoppingTarget.hh" +#include "Offline/BeamlineGeom/inc/TSdA.hh" #include "CLHEP/Vector/ThreeVector.h" #include "CLHEP/Vector/TwoVector.h" #include "CLHEP/Vector/Rotation.h" @@ -372,12 +373,26 @@ namespace mu2e { auto ipafront= std::make_shared(ipa->frontDisk()); auto ipaback= std::make_shared(ipa->backDisk()); auto opa= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,-3766),454.0,728.4,2125.0); // inner surface - auto tsda= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,-5967),235.0,525.0); // mid-plane: TSdA_v02 spans z = -5991.8 to -5941.0 - // TS5 face: a disk out to the DS inner radius, 1 mm downstream of the KinKal TSDA plane (so inside the absorber), so an - // upstream-going extrapolation crosses it just before the TSDA plane. A crossing means the extrapolated helix reaches the - // TSDA plane inside the DS bore; it is not by itself a cosmic tag (see KKExtrap ToTS5) - static constexpr double ts5FaceOffset = 1.0; // mm - auto ts5face= std::make_shared(tsda->normal(),tsda->uDirection(),tsda->center()+VEC3(0.0,0.0,ts5FaceOffset),inner->radius()); + // TS downstream absorber (TSDA), from the TSdA geometry. The KinKal TSDA plane is the absorber mid-plane. + // Geometries without a TSdA keep the nominal (TSdA_v02-like) plane, as the upstream extrapolation ends on it. + double tsdaz(-5967.0), tsdarin(235.0), tsdarout(525.0), tsdahalfl(25.4); + art::ServiceHandle geomService; + if(geomService->hasElement()){ + GeomHandle tsdageom; + double zmu2e = tsdageom->position().z(); + // version 1 is placed at the front of DS2Vacuum, overriding its configured position (see constructTSdA) + if(tsdageom->version() <= 1) zmu2e = ds->vac_zLocDs23Split() - 2.0*ds->vac_halfLengthDs2() + tsdageom->halfLength4(); + tsdaz = toDetectorZ(zmu2e); + tsdarin = tsdageom->rIn(); + tsdarout = tsdageom->r4(); + tsdahalfl = tsdageom->halfLength4(); + } + auto tsda= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,tsdaz),tsdarin,tsdarout); // mid-plane + // TS5 face: a disk out to the DS inner radius on the downstream face of the TSDA. It is used as a sample surface (KKFit + // SampleSurfaces); the upstream extrapolation ends on the TSDA plane, so it covers the face. A crossing means the extrapolated + // helix reaches the TSDA inside the DS bore; for downstream fits it comes from the backwards extrapolation, so it is not + // by itself a cosmic tag. + auto ts5face= std::make_shared(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,tsdaz+tsdahalfl),inner->radius()); kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::DS_Front),std::static_pointer_cast(front))); kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::DS_Back),std::static_pointer_cast(back))); @@ -390,7 +405,7 @@ namespace mu2e { kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::TSDA),std::static_pointer_cast(tsda))); kkg_->map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::TS5_Face),std::static_pointer_cast(ts5face))); - kkg_->ds_ = std::make_unique(inner, outer, front, back, ipa, ipafront, ipaback, opa, tsda, ts5face, materialCylinders); + kkg_->ds_ = std::make_unique(inner, outer, front, back, ipa, ipafront, ipaback, opa, tsda, materialCylinders); } void KinKalGeomMaker::makeTarget() { diff --git a/GeometryService/src/TSdAMaker.cc b/GeometryService/src/TSdAMaker.cc index 1f5e9c08c1..105fd4c8f0 100644 --- a/GeometryService/src/TSdAMaker.cc +++ b/GeometryService/src/TSdAMaker.cc @@ -3,6 +3,8 @@ #include "Offline/ConfigTools/inc/checkForStale.hh" #include "Offline/DetectorSolenoidGeom/inc/DetectorSolenoid.hh" #include "Offline/BeamlineGeom/inc/TSdA.hh" +#include "Offline/BeamlineGeom/inc/Beamline.hh" +#include "Offline/BeamlineGeom/inc/StraightSection.hh" #include "Offline/GeometryService/inc/TSdAMaker.hh" // C++ includes @@ -18,12 +20,20 @@ namespace mu2e { - std::unique_ptr TSdAMaker::make(const SimpleConfig& c, const DetectorSolenoid& ds ) { + std::unique_ptr TSdAMaker::make(const SimpleConfig& c, const DetectorSolenoid& ds, const Beamline& beamline ) { checkForStale( "intneutronabs", c ); std::unique_ptr tsda ( new TSdA() ); + // inner radius: the TS5 inner cryostat radius if not provided + tsda->_rIn = c.getDouble("tsda.rin",0.0); + if ( tsda->_rIn < 1.0e-06 ) { + StraightSection const* ts5out = beamline.getTS().getTSCryo( TransportSolenoid::TSRegion::TS5, + TransportSolenoid::TSRadialPart::IN ); + tsda->_rIn = ts5out->rIn(); + } + tsda->_r4 = c.getDouble("tsda.r4"); tsda->_halfLength4 = c.getDouble("tsda.halfLength4"); diff --git a/KinKalGeom/inc/DetectorSolenoid.hh b/KinKalGeom/inc/DetectorSolenoid.hh index c16489d7af..c697d3b27e 100644 --- a/KinKalGeom/inc/DetectorSolenoid.hh +++ b/KinKalGeom/inc/DetectorSolenoid.hh @@ -32,9 +32,9 @@ namespace mu2e { // default constructor with nominal geometry DetectorSolenoid( CylPtr inner, CylPtr outer, DiskPtr front, DiskPtr back, CylPtr ipa, DiskPtr ipafront, DiskPtr ipaback, - FruPtr opa, AnnPtr tsda, DiskPtr ts5face, MaterialCylinderCollection const& materialCylinders = MaterialCylinderCollection()) : + FruPtr opa, AnnPtr tsda, MaterialCylinderCollection const& materialCylinders = MaterialCylinderCollection()) : inner_(inner) , outer_(outer), front_(front), back_(back), - ipa_(ipa), ipa_front_(ipafront), ipa_back_(ipaback), opa_(opa), tsda_(tsda), ts5face_(ts5face), + ipa_(ipa), ipa_front_(ipafront), ipa_back_(ipaback), opa_(opa), tsda_(tsda), materialCylinders_(materialCylinders) {} @@ -49,7 +49,6 @@ namespace mu2e { auto const& innerProtonAbsorberBack() const { return *ipa_back_; } auto const& outerProtonAbsorber() const { return *opa_; } auto const& upstreamAbsorber() const { return *tsda_; } - auto const& ts5Face() const { return *ts5face_; } // return by ptr auto const& outerPtr() const { return outer_; } auto const& innerPtr() const { return inner_; } @@ -60,7 +59,6 @@ namespace mu2e { auto const& innerProtonAbsorberBackPtr() const { return ipa_back_; } auto const& outerProtonAbsorberPtr() const { return opa_; } auto const& upstreamAbsorberPtr() const { return tsda_; } - auto const& ts5FacePtr() const { return ts5face_; } auto const& materialCylinders() const { return materialCylinders_; } private: CylPtr inner_; // inner cryostat cylinder boundary @@ -72,7 +70,6 @@ namespace mu2e { DiskPtr ipa_back_; FruPtr opa_; // outer proton absorber AnnPtr tsda_; // TS downstream absorber - DiskPtr ts5face_; // TS5 face: disk out to the DS inner radius, 1 mm downstream of the KinKal TSDA plane (inside the absorber) MaterialCylinderCollection materialCylinders_; // passive cylindrical material shells }; } diff --git a/Mu2eG4/src/constructTSdA.cc b/Mu2eG4/src/constructTSdA.cc index 20e41c6651..ee08358206 100644 --- a/Mu2eG4/src/constructTSdA.cc +++ b/Mu2eG4/src/constructTSdA.cc @@ -49,8 +49,6 @@ namespace mu2e { void constructTSdA(SimpleConfig const & _config){ int const verbosityLevel = _config.getInt("tsda.verbosityLevel",0); - double tmpRin = _config.getDouble("tsda.rin",0.0)*CLHEP::mm; - const auto geomOptions = art::ServiceHandle()->geomOptions(); geomOptions->loadEntry( _config, "tsda", "tsda"); @@ -71,13 +69,7 @@ namespace mu2e { GeomHandle atsd; int version = atsd->version(); - if ( tmpRin < 1.0e-06 ) { // just a check for zero - // TS5 outer radius - GeomHandle beamg; - const StraightSection * ts5out = beamg->getTS().getTSCryo( TransportSolenoid::TSRegion::TS5, - TransportSolenoid::TSRadialPart::IN ); - tmpRin = ts5out->rIn(); - } + double const tmpRin = atsd->rIn(); // TS5 inner cryostat radius if tsda.rin is not provided if ( verbosityLevel > 0) { cout << __func__ << " TSdA rin : "<< tmpRin << endl; cout << __func__ << " TSdA rout : "<< atsd->r4() << endl; diff --git a/Mu2eKinKal/fcl/prolog.fcl b/Mu2eKinKal/fcl/prolog.fcl index 8b79ed43b9..7ca294bd84 100644 --- a/Mu2eKinKal/fcl/prolog.fcl +++ b/Mu2eKinKal/fcl/prolog.fcl @@ -389,7 +389,6 @@ Mu2eKinKal : { Upstream : true BackToTracker : false ToOPA : true - ToTS5 : true # record where the upstream extrapolation reaches the TSDA plane inside the DS bore (TS5_Face); not by itself a cosmic tag ToCRV : false ToCaloD0 : true ToCaloD1 : true @@ -504,7 +503,9 @@ Mu2eKinKal : { @table::Mu2eKinKal.KKFIT MaxSeedStrawHitDt : 200.0 # ns; drop seed hits whose TOCA lands on another turn of the seed helix AddCaloMaterial : true - SampleSurfaces : ["ST_Outer","ST_Front","ST_Back"] # these are additional surfaces; surfaces used in extrapolation are also sampled + # these are additional surfaces; surfaces used in extrapolation are also sampled. TS5_Face records where the upstream + # extrapolation reaches the TSDA inside the DS bore; for downstream fits it comes from the backwards extrapolation, so it is not by itself a cosmic tag + SampleSurfaces : ["ST_Outer","ST_Front","ST_Back","TS5_Face"] # save trajectories in the Detector region SaveDomains : true SaveTrajectory : Detector @@ -667,7 +668,7 @@ Mu2eKinKal : { } KKFitSettings: { @table::Mu2eKinKal.KKFIT - SampleSurfaces : ["ST_Outer","ST_Inner","ST_Front","ST_Back"] + SampleSurfaces : ["ST_Outer","ST_Inner","ST_Front","ST_Back","TS5_Face"] AddHits : false SaveDomains : true SaveTrajectory : Full diff --git a/Mu2eKinKal/inc/KKExtrap.hh b/Mu2eKinKal/inc/KKExtrap.hh index fc52b9b707..c27f549be2 100644 --- a/Mu2eKinKal/inc/KKExtrap.hh +++ b/Mu2eKinKal/inc/KKExtrap.hh @@ -55,7 +55,7 @@ namespace mu2e { template bool reflect(ExtrapolateSweep& xs, KinKal::ParticleTrajectory const& ftraj, TimeDir tdir) const; int debug_; double btol_, intertol_, maxdt_, maxdtstep_, minv_; - bool backToTracker_, extrapolateOPA_, toTS5_, toTrackerPerimeter_, upstream_, toCRV_; + bool backToTracker_, extrapolateOPA_, toTrackerPerimeter_, upstream_, toCRV_; bool toCaloD0_, toCaloD1_, toCaloMaterial_; // nominal literal like the hard-coded KinKalGeom IPA surface (KinKalGeomMaker::makeDS); TODO: take it from the geometry service. // The ST foil thicknesses come from the geometry service (KKGeom::StoppingTarget::foilThickness) @@ -75,17 +75,13 @@ namespace mu2e { minv_(extrapconfig.MinV()), backToTracker_(extrapconfig.BackToTracker()), extrapolateOPA_(extrapconfig.ToOPA()), - toTS5_(extrapconfig.ToTS5()), toTrackerPerimeter_(extrapconfig.ToTrackerPerimeter()), upstream_(extrapconfig.Upstream()), toCRV_(extrapconfig.ToCRV()), toCaloD0_(extrapconfig.ToCaloD0()), toCaloD1_(extrapconfig.ToCaloD1()), toCaloMaterial_(extrapconfig.ToCaloMaterial()) - { - if(toTS5_ && !upstream_) - throw cet::exception("RECO") << "mu2e::KKExtrap: ToTS5 requires Upstream extrapolation" << std::endl; - } + {} inline void KKExtrap::checkConfig(KinKal::Config const& config) const { if(config.bfcorr_ && config.mindtstep_ > maxdtstep_) @@ -164,7 +160,7 @@ namespace mu2e { auto back = face("TT_Back",trk.backPtr().get()); tgts.push_back(back); } - // upstream: IPA, ST foils, optionally the TS5 face, TSDA (ends the sweep), OPA, and optionally the tracker entrance after a reflection + // upstream: IPA, ST foils, TSDA (ends the sweep), OPA, and optionally the tracker entrance after a reflection if(updir && upstream_){ auto const& ipa = ds.innerProtonAbsorberPtr(); SweepTarget ipatg; @@ -198,17 +194,6 @@ namespace mu2e { tg.zreglo_ = stzlo; tg.zreghi_ = stzhi; tgts.push_back(tg); } - if(toTS5_){ - // record-only: a disk out to the DS inner radius 1 mm downstream of the TSDA plane, crossed just before the TSDA plane - // ends the sweep. A crossing means the extrapolated helix reaches the TSDA plane inside the DS bore. For a downstream - // fit it comes from the backwards-in-time extrapolation, which for a conversion electron continues upstream past the - // stopping target, so it is not by itself a cosmic tag. - SweepTarget ts5; - ts5.sid_ = SurfaceId("TS5_Face"); - ts5.surf_ = ds.ts5FacePtr().get(); - ts5.drives_ = false; // the TSDA plane drives the extension - tgts.push_back(ts5); - } SweepTarget tsda; tsda.reach_ = SweepTarget::zplane; tsda.sid_ = SurfaceId("TSDA"); diff --git a/Mu2eKinKal/inc/KKFitSettings.hh b/Mu2eKinKal/inc/KKFitSettings.hh index ee944db444..33e65fa3a7 100644 --- a/Mu2eKinKal/inc/KKFitSettings.hh +++ b/Mu2eKinKal/inc/KKFitSettings.hh @@ -129,7 +129,6 @@ namespace mu2e { fhicl::Atom ToTrackerPerimeter { Name("ToTrackerPerimeter"), Comment("Extrapolate tracks to the tracker perimeter (z-ends and outer wall)") }; fhicl::Atom Upstream { Name("Upstream"), Comment("Extrapolate tracks upstream") }; fhicl::Atom ToOPA { Name("ToOPA"), Comment("Test tracks for intersection with the OPA") }; - fhicl::Atom ToTS5 { Name("ToTS5"), Comment("Record where the upstream extrapolation reaches the TSDA plane inside the DS bore (TS5_Face: disk out to the DS inner radius, 1 mm downstream of the TSDA plane). For downstream fits this comes from the backwards extrapolation, so it is not by itself a cosmic tag. Requires Upstream"), false }; fhicl::Atom ToCRV { Name("ToCRV"), Comment("Extrapolate tracks to the CRV modules") }; fhicl::Atom ToCaloD0 { Name("ToCaloD0"), Comment("Extrapolate tracks to the calorimeter disk0 surfaces") }; fhicl::Atom ToCaloD1 { Name("ToCaloD1"), Comment("Extrapolate tracks to the calorimeter disk1 surfaces") }; diff --git a/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc b/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc index 5954eeaf28..18a2c13a3f 100644 --- a/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc +++ b/Mu2eKinKal/src/ExtrapolateSweepTest_main.cc @@ -739,68 +739,6 @@ namespace { require(limited == 1 && unlimited == 2,"notBefore crossings " + std::to_string(limited) + " and " + std::to_string(unlimited)); } - // The TS5 face (KKExtrap ToTS5): a record-only disk out to the DS inner radius 1 mm downstream of the TSDA plane. An upstream track - // inside that radius records it just before the terminal TSDA plane, whether it then passes the TSDA hole, body or outside; - // one beyond the DS inner radius records only the TSDA. Geometry literals follow KinKalGeomMaker::makeDS. - template void ts5Face(TimeDir dir) { - double const ztsda = -5967.0, rin = 235.0, rout = 525.0, rface = 950.0, offset = 1.0; - KinKal::Annulus tsda(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,ztsda),rin,rout); - KinKal::Disk face(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,ztsda+offset),rface); - SweepTarget ts5; - ts5.sid_ = mu2e::SurfaceId(mu2e::SurfaceIdEnum::TS5_Face); - ts5.surf_ = &face; - ts5.drives_ = false; - SweepTarget tsdatg; - tsdatg.reach_ = SweepTarget::zplane; - tsdatg.sid_ = mu2e::SurfaceId(mu2e::SurfaceIdEnum::TSDA); - tsdatg.surf_ = &tsda; - tsdatg.zval_ = ztsda; - tsdatg.terminal_ = true; - tsdatg.inbounds_ = false; - bool forward = dir == TimeDir::forwards; - for(double radius : {0.0,100.0,400.0,700.0,1100.0}){ // TSDA hole, hole, body, outside the TSDA, beyond the DS inner radius - // the particle moves upstream (-z) along the sweep direction, from z = -5800 to z = -6100 - double zstart = forward ? -5800.0 : -6100.0; - KinKal::ParticleState state(VEC3(radius,0.0,zstart),VEC3(0.0,10.0,forward ? -100.0 : 100.0),0.0,105.658,-1); - KTRAJ traj0(state,VEC3(0.0,0.0,1.0),TimeRange(0.0,1.0)); - traj0.setRange(TimeRange(0.0,300.0/std::fabs(traj0.velocity(0.0).Z()))); - KinKal::ParticleTrajectory traj(traj0); - double rmin = 1.0e100, rmax = 0.0; - for(unsigned i = 0; i <= 200; ++i){ - double rho = traj.position3(traj.range().begin()+traj.range().range()*i/200.0).Rho(); - rmin = std::min(rmin,rho); rmax = std::max(rmax,rho); - } - bool onface = rmax < rface; - require(onface || rmin > rface,"TS5 fixture straddles the TS5 face edge"); - require(rmax < rin || rmin > rin,"TS5 fixture straddles the TSDA hole edge"); - SweepTargetCollection targets{ts5,tsdatg}; - ExtrapolateSweep sweep(targets,dir,1.0e6,1.0e6,1.0e-4,tol,1.0e-6,0); - sweep.start(forward ? traj.range().begin() : traj.range().end()); - sweep.limit(forward ? traj.range().end() : traj.range().begin(),false); - std::vector> found; - while(!sweep.needsExtrapolation(traj,dir) && sweep.hasCrossing()){ - auto const& tg = targets[sweep.crossing().itarget_]; - found.emplace_back(tg.sid_,sweep.crossing().inter_); - sweep.accept(); - if(tg.terminal_) break; - require(found.size() < 10,"runaway TS5 crossings"); - } - require(!sweep.failed(),"TS5 sweep failed: " + sweep.error()); - require(found.size() == (onface ? 2u : 1u),"TS5 sweep found " + std::to_string(found.size()) + " crossings at radius " + std::to_string(radius)); - require(found.back().first == tsdatg.sid_,"TS5 sweep did not end at the TSDA"); - require(std::fabs(found.back().second.pos_.Z()-ztsda) < 10.0*tol,"TSDA crossing off its plane"); - if(onface){ - auto const& inter = found.front().second; - require(found.front().first == ts5.sid_,"TS5 face not crossed first"); - require(inter.inbounds_ && inter.pos_.Rho() < rface,"TS5 crossing outside the DS inner radius"); - require(std::fabs(inter.pos_.Z()-(ztsda+offset)) < 10.0*tol,"TS5 crossing off its plane"); - double sgn = forward ? 1.0 : -1.0; - require(sgn*inter.pdir_.Z() < 0.0,"TS5 crossing not moving upstream along the sweep"); - require(sgn*(found.back().second.time_-inter.time_) > 0.0,"TS5 face not crossed before the TSDA"); - } - } - } - void emptySearch() { KinKal::ParticleState state(VEC3(0.0,0.0,0.0),VEC3(0.0,0.0,100.0),0.0,105.658,1); KinKal::KinematicLine line(state,VEC3(0.0,0.0,0.0),TimeRange(0.0,0.1)); @@ -832,8 +770,6 @@ int main() { reachBound(dir); shellIncidence(dir); notBefore(dir); - ts5Face(dir); - ts5Face(dir); invalidBoundaryInterior(dir,true); invalidBoundaryInterior(dir,false); closeCoplanar(dir); From 62591297a48828d9290b32d2fc1e5b6ba04460d6 Mon Sep 17 00:00:00 2001 From: michaelmackenzie Date: Tue, 17 Nov 2026 10:00:25 -0600 Subject: [PATCH 7/7] Restart the KKFit sample search for each surface KKFit::sampleFit carried the search start time from one sample surface to the next, so a surface crossed earlier than the previous surface's last crossing was never sampled (e.g. TS5_Face and ST_Front on downstream fits). Start each surface from the beginning of the range, as CentralHelixFit and KinematicLineFit already do. Co-Authored-By: Claude Opus 5.5 --- Mu2eKinKal/inc/KKFit.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Mu2eKinKal/inc/KKFit.hh b/Mu2eKinKal/inc/KKFit.hh index 9e69963a72..5a00dbb433 100644 --- a/Mu2eKinKal/inc/KKFit.hh +++ b/Mu2eKinKal/inc/KKFit.hh @@ -1040,10 +1040,11 @@ namespace mu2e { ranges.push_back(ptraj.range()); } for(auto range : ranges) { - double tbeg = range.begin(); double tend = range.end(); for(auto const& surf : tosample){ - // search for intersections with each surface within the specified time range, going forwards in time + // search for intersections with each surface within the specified time range, going forwards in time. + // Start each surface from the beginning of the range, so an earlier surface's crossings don't hide this one's + double tbeg = range.begin(); bool goodinter(true); size_t max_inter = 100; // limit the number of intersections size_t cur_inter = 0;