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 p110
ENVSET p111
# add Offline/bin to path
PATH bin
# recent commits can take enforce these flags
Expand Down
2 changes: 2 additions & 0 deletions Mu2eKinKal/inc/ExtrapolateSweep.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// - Limit: limit(t,recordonly) caps the search at t (optionally to record targets only); KKExtrap uses it for the fitted trajectory before the end piece, where no material can be added, and unlimit() removes the cap.
// - Re-crossing guard: a plane, CRV sector or foil is crossed again only after the trajectory has left the slab of half-width intertol around it (departed).
// - Planes: the signed plane distance of a helix or line is monotonic between the extrema of its normal velocity, which are known in closed form (visitPlaneExtrema), so plane roots are bracketed and bisected (planeCrossing); cylinders use KinKal::intersect.
// TEMPORARY: this works around KFTrack/KinKal#233 (KinKal::intersect can return a plane root outside the query). Once Offline uses a KinKal release
// with KFTrack/KinKal#235, remove visitPlaneExtrema and planeCrossing and use KinKal::intersect for planes too.
// Adding a material target: see KKExtrap::targets and KKExtrap::addCrossing.
#ifndef Mu2eKinKal_ExtrapolateSweep_hh
#define Mu2eKinKal_ExtrapolateSweep_hh
Expand Down
20 changes: 19 additions & 1 deletion Mu2eKinKal/inc/KKExtrap.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Offline/GeometryService/inc/GeometryService.hh"
#include <utility>
#include <algorithm>
#include <atomic>
#include <limits>
#include <cmath>
#include <iostream>
Expand All @@ -42,6 +43,8 @@ namespace mu2e {
// and, for a new Effect, a case in addCrossing that builds its KinKal material xing; a surface that is neither a Plane nor a Cylinder is searched with KinKal::intersect
// and is never cut by withinReach; add a case to ExtrapolateSweepTest and, if optional, a KKExtrapConfig switch.
SweepTargetCollection targets(bool updir) const;
// end of job: how many tracks ranged out, and in how many KinKal refused to truncate the trajectory at the stop
void printSummary(std::string const& label) const;
private:
// where a track entered a calorimeter crystal case inner support: the material still to cross at the carbon fiber ring inner radius
struct SupportEntry { double path_ = 0.0; KKGeom::CaloInnerSupport::Crossing xing_ = KKGeom::CaloInnerSupport::cfRing; double time_ = 0.0; };
Expand All @@ -54,6 +57,7 @@ namespace mu2e {
TimeDir tdir, SupportEntries& entries) const;
template <class KTRAJ> bool reflect(ExtrapolateSweep& xs, KinKal::ParticleTrajectory<KTRAJ> const& ftraj, TimeDir tdir) const;
int debug_;
mutable std::atomic<unsigned> nRangedOut_{0}, nNotTruncated_{0}; // counted in rangeOut, reported by printSummary
double btol_, intertol_, maxdt_, maxdtstep_, minv_;
bool backToTracker_, extrapolateOPA_, toTrackerPerimeter_, upstream_, toCRV_;
bool toCaloD0_, toCaloD1_, toCaloMaterial_;
Expand Down Expand Up @@ -121,13 +125,27 @@ namespace mu2e {
ktrk.addExtrapolationFailure(failure);
}

// The particle stops in this material: the forwards direction ends before it, keeping the crossings already added.
// The particle stops in this material: the forwards direction and the trajectory end at the crossing, keeping the crossings already added.
template <class KTRAJ> bool KKExtrap::rangeOut(KKTrack<KTRAJ>& ktrk, SweepTarget const& tg, KinKal::Intersection const& inter) const {
if(debug_ > 0) std::cout << "KKExtrap: ranged out in " << tg.sid_ << " at " << inter.time_ << std::endl;
ktrk.setRangedOut();
++nRangedOut_;
// the extension can run domains past the crossing; KinKal removes them, and refuses the cut if an active hit or material lies beyond it.
// A refused cut keeps the trajectory past the stop, so it is counted and reported at the end of the job (printSummary).
// KinKal currently also refuses for material sites the fit never processed (KFTrack/KinKal#234 review): if a later KinKal
// release stops doing that, the refused count should fall to zero and this check can be revisited
if(!ktrk.truncate(TimeDir::forwards,inter.time_)){
++nNotTruncated_;
if(debug_ > 0) std::cout << "KKExtrap: trajectory not truncated at " << inter.time_ << std::endl;
}
return false;
}

inline void KKExtrap::printSummary(std::string const& label) const {
if(nRangedOut_ > 0) std::cout << "KKExtrap " << label << ": " << nRangedOut_ << " tracks ranged out, " << nNotTruncated_
<< " of them not truncated at the stop (KinKal refused the cut)" << std::endl;
}

inline SweepTargetCollection KKExtrap::targets(bool updir) const {
GeomHandle<mu2e::KinKalGeom> kkg_h;
GeomHandle<mu2e::KKMaterial> kkmat_h;
Expand Down
5 changes: 5 additions & 0 deletions Mu2eKinKal/src/CentralHelixFit_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ namespace mu2e {
virtual ~CentralHelixFit() {}
void beginRun(art::Run& run) override;
void produce(art::Event& event) override;
void endJob() override;
protected:
bool goodFit(KKTRK const& ktrk) const;
void sampleFit(KKTRK& ktrk) const;
Expand Down Expand Up @@ -260,6 +261,10 @@ namespace mu2e {
kkg.surfaces(ssids_,surfacess_to_sample_);
}

void CentralHelixFit::endJob() {
if(extrap_) extrap_->printSummary(moduleDescription().moduleLabel());
}

void CentralHelixFit::produce(art::Event& event ) {
GeomHandle<Calorimeter> calo_h;
GeomHandle<mu2e::Tracker> nominalTracker_h;
Expand Down
5 changes: 5 additions & 0 deletions Mu2eKinKal/src/KKTruthSeed_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ namespace mu2e {
explicit KKTruthSeed(const Parameters& settings);
void beginRun(art::Run& run) override;
void produce(art::Event& event) override;
void endJob() override;

private:
// true muon state (pos, mom, time) from the MC trajectory point nearest a detector-frame location.
Expand Down Expand Up @@ -334,6 +335,10 @@ namespace mu2e {
return tsseed;
}

void KKTruthSeed::endJob() {
if(extrap_) extrap_->printSummary(moduleDescription().moduleLabel());
}

void KKTruthSeed::produce(art::Event& event) {
GeomHandle<Calorimeter> calo_h;
GeomHandle<mu2e::Tracker> nominalTracker_h;
Expand Down
5 changes: 5 additions & 0 deletions Mu2eKinKal/src/KinematicLineFit_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ namespace mu2e {
virtual ~KinematicLineFit();
void beginRun(art::Run& run) override;
void produce(art::Event& event) override;
void endJob() override;
private:
// utility functions
KTRAJ makeSeedTraj(CosmicTrackSeed const& hseed) const;
Expand Down Expand Up @@ -240,6 +241,10 @@ namespace mu2e {
kkg_h->surfaces(ssids_,surfacess_to_sample_);
}

void KinematicLineFit::endJob() {
if(extrap_) extrap_->printSummary(moduleDescription().moduleLabel());
}

void KinematicLineFit::produce(art::Event& event ) {
GeomHandle<mu2e::Calorimeter> calo_h;
GeomHandle<mu2e::Tracker> nominalTracker_h;
Expand Down
1 change: 1 addition & 0 deletions Mu2eKinKal/src/LoopHelixFit_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ namespace mu2e {
}

void LoopHelixFit::endJob() {
if(extrap_) extrap_->printSummary(moduleDescription().moduleLabel());
if(print_ > 0) {
printf("[LoopHelixFit::%s::%s] Saw %i helix seeds, %i had ambiguous dz/dt slopes, accepted %i downstream and %i upstream fits\n",
__func__, moduleDescription().moduleLabel().c_str(), nSeen_, nAmbiguous_, nDownstream_, nUpstream_);
Expand Down
4 changes: 3 additions & 1 deletion Mu2eKinKal/src/RegrowKinematicLine_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ namespace mu2e {
}

void RegrowKinematicLine::endJob()
{}
{
if(extrap_) extrap_->printSummary(moduleDescription().moduleLabel());
}

}
DEFINE_ART_MODULE(mu2e::RegrowKinematicLine)
4 changes: 3 additions & 1 deletion Mu2eKinKal/src/RegrowLoopHelix_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ namespace mu2e {
}

void RegrowLoopHelix::endJob()
{}
{
if(extrap_) extrap_->printSummary(moduleDescription().moduleLabel());
}

}
DEFINE_ART_MODULE(mu2e::RegrowLoopHelix)