Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .muse
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 18 additions & 4 deletions Mu2eKinKal/fcl/prolog.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Mu2eKinKal/inc/KKCaloHit.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -84,7 +84,7 @@ namespace mu2e {
return rresid_;
}

template <class KTRAJ> void KKCaloHit<KTRAJ>::updateReference(PTRAJ const& ptraj) {
template <class KTRAJ> void KKCaloHit<KTRAJ>::updateReference(PTRAJ const& ptraj, MetaIterConfig const&) {
// compute PCA
auto mtime = sensorAxis().measurementTime();
CAHint tphint(mtime,mtime);
Expand Down
2 changes: 2 additions & 0 deletions Mu2eKinKal/inc/KKFitSettings.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ namespace mu2e {
// Updater settings
using MetaIterationSettings = fhicl::Sequence<fhicl::Tuple<float,std::string>>;
MetaIterationSettings miConfig { Name("MetaIterationSettings"), Comment("Temperature (dimensionless), StrawHitUpdater algorithm") };
fhicl::OptionalSequence<std::string> 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<std::string> 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<fhicl::Tuple<float,float,float,float,std::string,std::string,std::string,int>>;
CADSHUSettings cadshuConfig{ Name("CADSHUSettings"), Comment(CADSHU::configDescription()) };
using DriftANNSHUSettings = fhicl::OptionalSequence<fhicl::Tuple<std::string,float,std::string,float,float,std::string,std::string,int>>;
Expand Down
4 changes: 2 additions & 2 deletions Mu2eKinKal/inc/KKShellXing.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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_; }
Expand Down Expand Up @@ -77,7 +77,7 @@ namespace mu2e {
}
}

template <class KTRAJ,class SURF> void KKShellXing<KTRAJ,SURF>::updateReference(KinKal::ParticleTrajectory<KTRAJ> const& ptraj) {
template <class KTRAJ,class SURF> void KKShellXing<KTRAJ,SURF>::updateReference(KinKal::ParticleTrajectory<KTRAJ> const& ptraj, KinKal::MetaIterConfig const&) {
auto const& neartrajptr = ptraj.nearestTraj(inter_.time_);
if(neartrajptr != reftrajptr_){
// traj has changed; try intersecting with this piece
Expand Down
9 changes: 5 additions & 4 deletions Mu2eKinKal/inc/KKStrawHit.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -157,18 +157,19 @@ namespace mu2e {
return CA(utraj,wirePtr(),ca.hint(),ca.precision());
}

template <class KTRAJ> void KKStrawHit<KTRAJ>::updateReference(PTRAJ const& ptraj) {
template <class KTRAJ> void KKStrawHit<KTRAJ>::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
}
Expand Down
2 changes: 1 addition & 1 deletion Mu2eKinKal/inc/KKStrawHitCluster.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions Mu2eKinKal/inc/KKStrawXing.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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::vector<MaterialXing>const& matXings() const override { return mxings_; }
Expand Down Expand Up @@ -131,14 +131,14 @@ namespace mu2e {
return active_ || (shptr_ && shptr_->hitState().active());
}

template <class KTRAJ> void KKStrawXing<KTRAJ>::updateReference(PTRAJ const& ptraj) {
template <class KTRAJ> void KKStrawXing<KTRAJ>::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<CA>(pca);
}

Expand Down
18 changes: 18 additions & 0 deletions Mu2eKinKal/src/KKFitSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> const& names, const char* key) {
std::vector<KinKal::RefPieceStrategy> 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<std::string> 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<std::string> anames;
splitLine( std::get<1>(misetting), ":", anames);
Expand Down