diff --git a/.muse b/.muse index 983fc57704..595d8cfca7 100644 --- a/.muse +++ b/.muse @@ -1,5 +1,5 @@ # prefer to build with this environment -ENVSET p108 +ENVSET p109 # add Offline/bin to path PATH bin # recent commits can take enforce these flags diff --git a/Mu2eKinKal/fcl/prolog.fcl b/Mu2eKinKal/fcl/prolog.fcl index 65307a19bd..de0de63607 100644 --- a/Mu2eKinKal/fcl/prolog.fcl +++ b/Mu2eKinKal/fcl/prolog.fcl @@ -559,8 +559,15 @@ Mu2eKinKal : { SaveTrajectory : T0 SaveDomains : false } - FitSettings : @local::Mu2eKinKal.CHSEEDFIT - ExtensionSettings : @local::Mu2eKinKal.CHSEEDEXT + # straw hits keep the piece holding their hint time (TOCA); material crossings follow the closest approach (DOCA) + FitSettings : { + @table::Mu2eKinKal.CHSEEDFIT + HitReferencePiece : [ "TOCA", "TOCA", "TOCA", "TOCA" ] + } + ExtensionSettings : { + @table::Mu2eKinKal.CHSEEDEXT + HitReferencePiece : [ "TOCA", "TOCA", "TOCA", "TOCA" ] + } ModuleSettings : { @table::Mu2eKinKal.CENTRALHELIX @table::Mu2eKinKal.KKPrecursors @@ -574,8 +581,15 @@ Mu2eKinKal : { SaveTrajectory : Detector SaveDomains : true } - FitSettings : @local::Mu2eKinKal.CHSEEDFIT - ExtensionSettings : @local::Mu2eKinKal.CHDRIFTEXT + # straw hits keep the piece holding their hint time (TOCA); material crossings follow the closest approach (DOCA) + FitSettings : { + @table::Mu2eKinKal.CHSEEDFIT + HitReferencePiece : [ "TOCA", "TOCA", "TOCA", "TOCA" ] + } + ExtensionSettings : { + @table::Mu2eKinKal.CHDRIFTEXT + HitReferencePiece : [ "TOCA", "TOCA", "TOCA", "TOCA", "TOCA", "TOCA", "TOCA", "TOCA", "TOCA" ] + } ModuleSettings : { @table::Mu2eKinKal.CENTRALHELIX @table::Mu2eKinKal.KKPrecursors diff --git a/Mu2eKinKal/inc/KKCaloHit.hh b/Mu2eKinKal/inc/KKCaloHit.hh index 9dc2cb123d..9d45fe2b4e 100644 --- a/Mu2eKinKal/inc/KKCaloHit.hh +++ b/Mu2eKinKal/inc/KKCaloHit.hh @@ -48,7 +48,7 @@ namespace mu2e { unsigned nResid() const override { return 1; } // 1 time residual Residual const& refResidual(unsigned ires=0) const override; double time() const override { return ca_.particleToca(); } - void updateReference(PTRAJ const& ptraj) override; + void updateReference(PTRAJ const& ptraj, MetaIterConfig const&) override; // the hint is the measurement time, so the piece-move limit does not apply void updateState(MetaIterConfig const& config,bool first) override; KTRAJPTR refTrajPtr() const override { return ca_.particleTrajPtr(); } void print(std::ostream& ost=std::cout,int detail=0) const override; @@ -84,7 +84,7 @@ namespace mu2e { return rresid_; } - template void KKCaloHit::updateReference(PTRAJ const& ptraj) { + template void KKCaloHit::updateReference(PTRAJ const& ptraj, MetaIterConfig const&) { // compute PCA auto mtime = sensorAxis().measurementTime(); CAHint tphint(mtime,mtime); diff --git a/Mu2eKinKal/inc/KKFitSettings.hh b/Mu2eKinKal/inc/KKFitSettings.hh index 36a7d989ee..849234a5ab 100644 --- a/Mu2eKinKal/inc/KKFitSettings.hh +++ b/Mu2eKinKal/inc/KKFitSettings.hh @@ -41,6 +41,8 @@ namespace mu2e { // Updater settings using MetaIterationSettings = fhicl::Sequence>; MetaIterationSettings miConfig { Name("MetaIterationSettings"), Comment("Temperature (dimensionless), StrawHitUpdater algorithm") }; + fhicl::OptionalSequence hitRefPiece { Name("HitReferencePiece"), Comment("Per meta-iteration reference piece strategy for hits, DOCA or TOCA; one entry per MetaIterationSettings entry, absent = all DOCA") }; + fhicl::OptionalSequence xingRefPiece { Name("XingReferencePiece"), Comment("Per meta-iteration reference piece strategy for material crossings, DOCA or TOCA; one entry per MetaIterationSettings entry, absent = all DOCA") }; using CADSHUSettings = fhicl::OptionalSequence>; CADSHUSettings cadshuConfig{ Name("CADSHUSettings"), Comment(CADSHU::configDescription()) }; using DriftANNSHUSettings = fhicl::OptionalSequence>; diff --git a/Mu2eKinKal/inc/KKShellXing.hh b/Mu2eKinKal/inc/KKShellXing.hh index 135c88c9e1..c895bbe14f 100644 --- a/Mu2eKinKal/inc/KKShellXing.hh +++ b/Mu2eKinKal/inc/KKShellXing.hh @@ -36,7 +36,7 @@ namespace mu2e { return rv; }; // ElementXing interface - void updateReference(PTRAJ const& ptraj) override; + void updateReference(PTRAJ const& ptraj, MetaIterConfig const&) override; // the intersection time sets the piece, so the piece-move limit does not apply void updateState(MetaIterConfig const& config,bool first) override; Parameters params() const override; double time() const override { return inter_.time_; } @@ -77,7 +77,7 @@ namespace mu2e { } } - template void KKShellXing::updateReference(KinKal::ParticleTrajectory const& ptraj) { + template void KKShellXing::updateReference(KinKal::ParticleTrajectory const& ptraj, KinKal::MetaIterConfig const&) { auto const& neartrajptr = ptraj.nearestTraj(inter_.time_); if(neartrajptr != reftrajptr_){ // traj has changed; try intersecting with this piece diff --git a/Mu2eKinKal/inc/KKStrawHit.hh b/Mu2eKinKal/inc/KKStrawHit.hh index 4b8bc415a0..0a8ec619ba 100644 --- a/Mu2eKinKal/inc/KKStrawHit.hh +++ b/Mu2eKinKal/inc/KKStrawHit.hh @@ -83,7 +83,7 @@ namespace mu2e { auto const& timeResidual() const { return resids_[Mu2eKinKal::tresid];} auto const& distResidual() const { return resids_[Mu2eKinKal::dresid];} double time() const override { return ca_.particleToca(); } - void updateReference(PTRAJ const& ptraj) override; + void updateReference(PTRAJ const& ptraj, MetaIterConfig const& miconfig) override; KTRAJPTR refTrajPtr() const override { return ca_.particleTrajPtr(); } void print(std::ostream& ost=std::cout,int detail=0) const override; // re-override; even though this is implemented in the base class @@ -157,18 +157,19 @@ namespace mu2e { return CA(utraj,wirePtr(),ca.hint(),ca.precision()); } - template void KKStrawHit::updateReference(PTRAJ const& ptraj) { + template void KKStrawHit::updateReference(PTRAJ const& ptraj, MetaIterConfig const& miconfig) { // if we already computed PCA in the previous iteration, use that to set the hint. This speeds convergence // otherwise use the time at the center of the wire, corrected for drift auto mtime =wire().timeAtMidpoint(); + unsigned maxiter = miconfig.hitPieceIter(); CAHint tphint = ca_.usable() ? ca_.hint() : CAHint(mtime-chit_.driftTime(),mtime); - PCA pca(ptraj,wirePtr(),tphint,precision()); + PCA pca(ptraj,wirePtr(),tphint,precision(),maxiter); // check that we're on the right branch: we can move off if t0 changes a lot between iterations double dz = straw().origin().z() - pca.particlePoca().Z(); double maxdz(100.0);// need a better absolute scale; should come from KTRAJ FIXME if((!pca.usable()) || fabs(dz) > maxdz) { tphint = CAHint(Mu2eKinKal::zTime(ptraj,straw().origin().z(),mtime-chit_.driftTime()),mtime); - pca = PCA(ptraj,wirePtr(),tphint,precision()); + pca = PCA(ptraj,wirePtr(),tphint,precision(),maxiter); dz = straw().origin().z() - pca.particlePoca().Z(); if((!pca.usable()) || fabs(dz) > maxdz) whstate_.state_ = WireHitState::unusable;// give up on 2nd try } diff --git a/Mu2eKinKal/inc/KKStrawHitCluster.hh b/Mu2eKinKal/inc/KKStrawHitCluster.hh index 342c0bbe4c..7598587c2d 100644 --- a/Mu2eKinKal/inc/KKStrawHitCluster.hh +++ b/Mu2eKinKal/inc/KKStrawHitCluster.hh @@ -76,7 +76,7 @@ namespace mu2e { unsigned nDOF() const override { return 0; } KinKal::Weights const& weight() const override { return (*hits_.begin())->weight(); } double time() const override; - void updateReference(PTRAJ const& ptraj) override {} // nothing to do here, ref comes from individual hits + void updateReference(PTRAJ const& ptraj, KinKal::MetaIterConfig const&) override {} // nothing to do here, ref comes from individual hits KTRAJPTR refTrajPtr() const override { return (*hits_.begin())->refTrajPtr(); } // update the internals of the hit, specific to this meta-iteraion. This will affect the next fit iteration void updateState(KinKal::MetaIterConfig const& config,bool first) override; diff --git a/Mu2eKinKal/inc/KKStrawXing.hh b/Mu2eKinKal/inc/KKStrawXing.hh index 1cc2136616..fa65dd9e6e 100644 --- a/Mu2eKinKal/inc/KKStrawXing.hh +++ b/Mu2eKinKal/inc/KKStrawXing.hh @@ -67,7 +67,7 @@ namespace mu2e { return rv; }; // ElementXing interface - void updateReference(PTRAJ const& ptraj) override; + void updateReference(PTRAJ const& ptraj, MetaIterConfig const& miconfig) override; void updateState(MetaIterConfig const& config,bool first) override; Parameters params() const override; std::vectorconst& matXings() const override { return mxings_; } @@ -131,14 +131,14 @@ namespace mu2e { return active_ || (shptr_ && shptr_->hitState().active()); } - template void KKStrawXing::updateReference(PTRAJ const& ptraj) { + template void KKStrawXing::updateReference(PTRAJ const& ptraj, MetaIterConfig const& miconfig) { CAHint tphint(strawAxis()->timeAtMidpoint(),strawAxis()->timeAtMidpoint()); if(ca_.usable()){ tphint = ca_.hint(); }else if(shptr_ && shptr_->closestApproach().usable()){ tphint = shptr_->closestApproach().hint(); } - PCA pca(ptraj,strawAxis(),tphint,precision()); + PCA pca(ptraj,strawAxis(),tphint,precision(),miconfig.xingPieceIter()); ca_ = static_cast(pca); } diff --git a/Mu2eKinKal/src/KKFitSettings.cc b/Mu2eKinKal/src/KKFitSettings.cc index a8d78bce14..733c56ebe8 100644 --- a/Mu2eKinKal/src/KKFitSettings.cc +++ b/Mu2eKinKal/src/KKFitSettings.cc @@ -43,10 +43,28 @@ namespace mu2e { chi2shusettings = fitconfig.combishuConfig().value_or(chi2shusettings); // straw material updater must always be here auto const& sxusettings = fitconfig.sxuConfig(); + // reference piece strategies, one per meta-iteration; absent keeps every meta-iteration on DOCA + auto refpieces = [&fitconfig](std::vector const& names, const char* key) { + std::vector retval(fitconfig.miConfig().size(),KinKal::RefPieceStrategy::DOCA); + if(names.empty()) return retval; + if(names.size() != retval.size()) + throw cet::exception("RECO")<<"mu2e::KKFitSettings: " << key << " has " << names.size() << " entries but MetaIterationSettings has " << retval.size() << std::endl; + for(size_t imeta=0; imeta < names.size(); ++imeta) { + if(names[imeta] != "DOCA" && names[imeta] != "TOCA") + throw cet::exception("RECO")<<"mu2e::KKFitSettings: unknown " << key << " value " << names[imeta] << ", must be DOCA or TOCA" << std::endl; + retval[imeta] = KinKal::refPieceStrategy(names[imeta]); + } + return retval; + }; + std::vector hitrefnames, xingrefnames; + auto hitrefs = refpieces(fitconfig.hitRefPiece().value_or(hitrefnames),"HitReferencePiece"); + auto xingrefs = refpieces(fitconfig.xingRefPiece().value_or(xingrefnames),"XingReferencePiece"); // set the schedule for the meta-iterations unsigned ncadshu(0), nann(0), nbkg(0), ncomb(0), nnone(0), nsxu(0), npdiag(0); for(auto const& misetting : fitconfig.miConfig()) { MetaIterConfig miconfig(std::get<0>(misetting)); + miconfig.setHitRefPiece(hitrefs.at(config.schedule_.size())); + miconfig.setXingRefPiece(xingrefs.at(config.schedule_.size())); // parse StrawHit updaters, and add to the config of this meta-iteraion std::vector anames; splitLine( std::get<1>(misetting), ":", anames);