diff --git a/Mu2eKinKal/inc/KKFit.hh b/Mu2eKinKal/inc/KKFit.hh index 82a40a11b5..5b5077d35b 100644 --- a/Mu2eKinKal/inc/KKFit.hh +++ b/Mu2eKinKal/inc/KKFit.hh @@ -159,7 +159,6 @@ namespace mu2e { double addStrawMinDz_; int strawNBuffer_; bool saveHitCalib_; - KinKalGeom smap_; SurfaceIdCollection ssids_; }; @@ -207,7 +206,7 @@ namespace mu2e { } else { throw cet::exception("RECO")<<"mu2e::KKFit: unknown trajectory option "<< fitconfig.saveTraj() << endl; } - // Lookup surfaces to sample; this interface is deprecatecd and should be replaced with extrapolation TODO + // surfaces to sample; this interface is deprecatecd and should be replaced with extrapolation TODO for(auto const& sidname : fitconfig.sampleSurfaces()){ ssids_.push_back(SurfaceId(sidname,-1)); // match all elements } @@ -866,8 +865,10 @@ namespace mu2e { template void KKFit::sampleFit(KKTRK& kktrk) const { // translate the sample and extend surface names to actual surfaces using the KinKalGeom. This should come from the // extrapolation and sampling options + GeomHandle kkg_h; + auto const& kkg = *kkg_h; KinKalGeom::SurfacePairCollection tosample; // surfaces to sample the fit - smap_.surfaces(ssids_,tosample); + kkg.surfaces(ssids_,tosample); auto const& ptraj = kktrk.fitTraj(); std::vector ranges; diff --git a/Mu2eKinKal/src/CentralHelixFit_module.cc b/Mu2eKinKal/src/CentralHelixFit_module.cc index c319450e71..d45316dd45 100644 --- a/Mu2eKinKal/src/CentralHelixFit_module.cc +++ b/Mu2eKinKal/src/CentralHelixFit_module.cc @@ -121,7 +121,7 @@ namespace mu2e { fhicl::Atom sampleTBuff { Name("SampleTimeBuffer"), Comment("Time buffer for sample intersections (nsec)") }; fhicl::Atom useFitCharge { Name("UseFitCharge"), Comment("Set the PDG particle according to the fit charge; otherwise reject fits that don't agree with the PDG particle charge") }; fhicl::Atom minCenterRho { Name("MinCenterRho"), Comment("Minimum transverse distance from the helix axis to the Z axis to consider the fit non-degenerate (mm)") }; -}; + }; struct GlobalConfig { fhicl::Table modSettings { Name("ModuleSettings") }; @@ -129,7 +129,7 @@ namespace mu2e { fhicl::Table fitSettings { Name("FitSettings") }; fhicl::Table extSettings { Name("ExtensionSettings") }; fhicl::Table matSettings { Name("MaterialSettings") }; -// helix module specific config + // helix module specific config }; class CentralHelixFit : public art::EDProducer { @@ -170,9 +170,10 @@ namespace mu2e { bool useFitCharge_; // Set the PDG particle to agree with the fit charge double minCenterRho_; // min center distance to z axis bool sampleinrange_, sampleinbounds_; // require samples to be in range or on surface - KinKalGeom::SurfacePairCollection sample_; // surfaces to sample the fit + SurfaceIdCollection ssids_; + KinKalGeom::SurfacePairCollection surfacess_to_sample_; // surfaces to sample the fit std::array paramconstraints_; - }; + }; CentralHelixFit::CentralHelixFit(const Parameters& settings) : art::EDProducer{settings}, fitflag_(TrkFitFlag::KKCentralHelix), @@ -218,14 +219,10 @@ namespace mu2e { fixedfield_ = true; kkbf_ = std::move(std::make_unique(VEC3(0.0,0.0,bz))); } - SurfaceIdCollection ssids; + // surfaces to sample; this interface is deprecatecd and should be replaced with extrapolation TODO for(auto const& sidname : settings().modSettings().sampleSurfaces()) { - ssids.push_back(SurfaceId(sidname,-1)); // match all elements + ssids_.push_back(SurfaceId(sidname,-1)); // match all elements } - // translate the sample and extend surface names to actual surfaces using the KinKalGeom. This should come from the - // geometry service eventually, TODO - KinKalGeom smap; - smap.surfaces(ssids,sample_); } void CentralHelixFit::beginRun(art::Run& run) { @@ -240,6 +237,10 @@ namespace mu2e { kkbf_ = std::move(std::make_unique(*bfmgr,*det)); } if(print_ > 0) kkbf_->print(std::cout); + // translate the sample surface names to actual surfaces using the KinKalGeom. This must be done after construction as the KKGeom object now comes from GeometryService + GeomHandle kkg_h; + auto const& kkg = *kkg_h; + kkg.surfaces(ssids_,surfacess_to_sample_); } void CentralHelixFit::produce(art::Event& event ) { @@ -399,7 +400,7 @@ namespace mu2e { void CentralHelixFit::sampleFit(KKTRK& kktrk) const { auto const& ftraj = kktrk.fitTraj(); double tbeg = ftraj.range().begin(); - for(auto const& surf : sample_){ + for(auto const& surf : surfacess_to_sample_){ // search for intersections with each surface from the begining double tstart = tbeg - sampletbuff_; bool goodinter(true); diff --git a/Mu2eKinKal/src/KinematicLineFit_module.cc b/Mu2eKinKal/src/KinematicLineFit_module.cc index 5dd1ad5000..77cb6b665f 100644 --- a/Mu2eKinKal/src/KinematicLineFit_module.cc +++ b/Mu2eKinKal/src/KinematicLineFit_module.cc @@ -51,6 +51,7 @@ #include "Offline/Mu2eKinKal/inc/KKStrawHit.hh" #include "Offline/Mu2eKinKal/inc/KKBField.hh" #include "Offline/Mu2eKinKal/inc/KKFitUtilities.hh" +#include "Offline/Mu2eKinKal/inc/KKShellXing.hh" #include "Offline/Mu2eKinKal/inc/ExtrapolateTCRV.hh" // root #include "TH1F.h" @@ -171,10 +172,12 @@ namespace mu2e { double intertol_; // surface intersection tolerance (mm) double sampletbuff_; // simple time buffer; replace this with extrapolation TODO bool sampleinrange_, sampleinbounds_; // require samples to be in range or on surface - KinKalGeom::SurfacePairCollection sample_; // surfaces to sample the fit bool extrapolate_, toCRV_; - ExtrapolateTCRV TCRV_; // extrapolation predicate based on Z values - double tcrvthick_ = 0.1056; // st foil thickness: should come from geometry service TODO + double maxdt_ = 0.0, btol_ = 0.0, minv_ = 0.0; + SurfaceIdCollection ssids_; + KinKalGeom::SurfacePairCollection surfacess_to_sample_; // surfaces to sample the fit + int extrapdebug_ = 0; + double tcrvthick_ = 150.0; // CRV sector thickness: should come from geometry service TODO Config config_; // initial fit configuration object Config exconfig_; // extension configuration object }; @@ -221,28 +224,21 @@ namespace mu2e { }else{ throw cet::exception("RECO")<<"mu2e::KinematicLineFit: Parameter constraint configuration error"<< endl; } - SurfaceIdCollection ssids; for(auto const& sidname : settings().modSettings().sampleSurfaces()) { - ssids.push_back(SurfaceId(sidname,-1)); // match all elements + ssids_.push_back(SurfaceId(sidname,-1)); // match all elements } - // translate the sample and extend surface names to actual surfaces using the KinKalGeom. This should come from the - // geometry service eventually, TODO - GeomHandle kkg_h; - auto const& kkg = *kkg_h; - kkg.surfaces(ssids,sample_); // configure extrapolation if(settings().Extrapolation()){ extrapolate_ = true; toCRV_ = settings().Extrapolation()->ToCRV(); // global configs - double maxdt = settings().Extrapolation()->MaxDt(); - double btol = settings().extSettings().btol(); // use the same BField cor. tolerance as in fit extension - double minv = settings().Extrapolation()->MinV(); - int debug = settings().Extrapolation()->Debug(); - // extrapolate to the front of the tracker - TCRV_ = ExtrapolateTCRV(maxdt,btol,intertol_,minv,*kkg.TCRV(),debug); + maxdt_ = settings().Extrapolation()->MaxDt(); + btol_ = settings().extSettings().btol(); // use the same BField cor. tolerance as in fit extension + minv_ = settings().Extrapolation()->MinV(); + extrapdebug_ = settings().Extrapolation()->Debug(); } + if(print_ > 0) std::cout << config_; @@ -259,6 +255,10 @@ namespace mu2e { GeomHandle bfmgr; GeomHandle det; kkbf_ = std::make_unique(*bfmgr,*det); + // translate the sample surface names to actual surfaces using the KinKalGeom. This must be done after construction as the KKGeom object now comes from GeometryService + GeomHandle kkg_h; + auto const& kkg = *kkg_h; + kkg.surfaces(ssids_,surfacess_to_sample_); } void KinematicLineFit::produce(art::Event& event ) { @@ -385,7 +385,7 @@ namespace mu2e { kktrk.extendTraj(extrange); double tbeg = ftraj.range().begin(); - for(auto const& surf : sample_){ + for(auto const& surf : surfacess_to_sample_){ // search for intersections with each surface from the begining double tstart = tbeg; bool goodinter(true); @@ -411,6 +411,11 @@ namespace mu2e { } void KinematicLineFit::extrapolate(KKTRK& ktrk) const { + GeomHandle kkg_h; + auto const& kkg = *kkg_h; + // extrapolate to the extracted CRV. This function should be migrated to KKExtrap TODO + auto TCRV = ExtrapolateTCRV(maxdt_,btol_,intertol_,minv_,*kkg.TCRV(),extrapdebug_); + auto const& ftraj = ktrk.fitTraj(); static const SurfaceId TCRVSID("TCRV"); auto dir0 = ftraj.direction(ftraj.t0()); @@ -421,18 +426,18 @@ namespace mu2e { // iterate until the extrapolation condition is met double time = starttime; double tstart = time; - while(fabs(time-tstart) < TCRV_.maxDt() && TCRV_.needsExtrapolation(ftraj,tdir) ){ - TimeRange range = tdir == TimeDir::forwards ? TimeRange(time,time+TCRV_.step()) : TimeRange(time-TCRV_.step(),time); + while(fabs(time-tstart) < TCRV.maxDt() && TCRV.needsExtrapolation(ftraj,tdir) ){ + TimeRange range = tdir == TimeDir::forwards ? TimeRange(time,time+TCRV.step()) : TimeRange(time-TCRV.step(),time); ktrk.extendTraj(range); time = tdir == TimeDir::forwards ? range.end() : range.begin(); } hadintersection = false; - if (TCRV_.intersection().good()){ + if (TCRV.intersection().good()){ hadintersection = true; // we have a good intersection. Use this to create a Shell material Xing auto const& reftrajptr = tdir == TimeDir::backwards ? ftraj.frontPtr() : ftraj.backPtr(); - // FIXME material? - KKCRVXINGPTR crvxingptr = std::make_shared(TCRV_.module(), TCRVSID, *kkmat_.STMaterial(),TCRV_.intersection(),reftrajptr,tcrvthick_,TCRV_.interTolerance()); + // TODO add DS and shielding material + KKCRVXINGPTR crvxingptr = std::make_shared(TCRV.module(), TCRVSID, *kkmat_.STMaterial(),TCRV.intersection(),reftrajptr,tcrvthick_,TCRV.interTolerance()); ktrk.addTCRVXing(crvxingptr,tdir); } } while(hadintersection);