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
7 changes: 4 additions & 3 deletions Mu2eKinKal/inc/KKFit.hh
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ namespace mu2e {
double addStrawMinDz_;
int strawNBuffer_;
bool saveHitCalib_;
KinKalGeom smap_;
SurfaceIdCollection ssids_;
};

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -866,8 +865,10 @@ namespace mu2e {
template <class KTRAJ> void KKFit<KTRAJ>::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<mu2e::KinKalGeom> 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<TimeRange> ranges;
Expand Down
23 changes: 12 additions & 11 deletions Mu2eKinKal/src/CentralHelixFit_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ namespace mu2e {
fhicl::Atom<float> sampleTBuff { Name("SampleTimeBuffer"), Comment("Time buffer for sample intersections (nsec)") };
fhicl::Atom<bool> 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<float> 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<KKCHModuleConfig> modSettings { Name("ModuleSettings") };
fhicl::Table<KKFitConfig> kkfitSettings { Name("KKFitSettings") };
fhicl::Table<KKConfig> fitSettings { Name("FitSettings") };
fhicl::Table<KKConfig> extSettings { Name("ExtensionSettings") };
fhicl::Table<KKMaterialConfig> matSettings { Name("MaterialSettings") };
// helix module specific config
// helix module specific config
};

class CentralHelixFit : public art::EDProducer {
Expand Down Expand Up @@ -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<double,KinKal::NParams()> paramconstraints_;
};
};

CentralHelixFit::CentralHelixFit(const Parameters& settings) : art::EDProducer{settings},
fitflag_(TrkFitFlag::KKCentralHelix),
Expand Down Expand Up @@ -218,14 +219,10 @@ namespace mu2e {
fixedfield_ = true;
kkbf_ = std::move(std::make_unique<KKConstantBField>(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) {
Expand All @@ -240,6 +237,10 @@ namespace mu2e {
kkbf_ = std::move(std::make_unique<KKBField>(*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<mu2e::KinKalGeom> kkg_h;
auto const& kkg = *kkg_h;
kkg.surfaces(ssids_,surfacess_to_sample_);
}

void CentralHelixFit::produce(art::Event& event ) {
Expand Down Expand Up @@ -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);
Expand Down
49 changes: 27 additions & 22 deletions Mu2eKinKal/src/KinematicLineFit_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -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<mu2e::KinKalGeom> 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_;


Expand All @@ -259,6 +255,10 @@ namespace mu2e {
GeomHandle<BFieldManager> bfmgr;
GeomHandle<DetectorSystem> det;
kkbf_ = std::make_unique<KKBField>(*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<mu2e::KinKalGeom> kkg_h;
auto const& kkg = *kkg_h;
kkg.surfaces(ssids_,surfacess_to_sample_);
}

void KinematicLineFit::produce(art::Event& event ) {
Expand Down Expand Up @@ -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);
Expand All @@ -411,6 +411,11 @@ namespace mu2e {
}

void KinematicLineFit::extrapolate(KKTRK& ktrk) const {
GeomHandle<mu2e::KinKalGeom> 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());
Expand All @@ -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<KKCRVXING>(TCRV_.module(), TCRVSID, *kkmat_.STMaterial(),TCRV_.intersection(),reftrajptr,tcrvthick_,TCRV_.interTolerance());
// TODO add DS and shielding material
KKCRVXINGPTR crvxingptr = std::make_shared<KKCRVXING>(TCRV.module(), TCRVSID, *kkmat_.STMaterial(),TCRV.intersection(),reftrajptr,tcrvthick_,TCRV.interTolerance());
ktrk.addTCRVXing(crvxingptr,tdir);
}
} while(hadintersection);
Expand Down