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 d38fb54b9a..4b937e1bdf 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, // 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 @@ -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/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 883edfa50a..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,7 +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); // back surface + // 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))); @@ -383,6 +403,7 @@ 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); } 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/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 c6e5ae4e23..7ca294bd84 100644 --- a/Mu2eKinKal/fcl/prolog.fcl +++ b/Mu2eKinKal/fcl/prolog.fcl @@ -503,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 @@ -666,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/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;