Skip to content

Commit f01b9d3

Browse files
authored
Merge pull request #1595 from brownd1978/kseed
Support for regrowing KKTrack fits from KalSeed objects
2 parents 02a3be8 + c77e11d commit f01b9d3

36 files changed

+1802
-832
lines changed

.muse

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# prefer to build with this environment
2-
ENVSET p084
2+
ENVSET p086
33
# add Offline/bin to path
44
PATH bin
55
# recent commits can take enforce these flags

CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cet_set_compiler_flags(DIAGS VIGILANT
3030
-Wno-unused-parameter
3131
-Wno-non-virtual-dtor
3232
-Wno-extra
33+
-Wreorder
3334
)
3435

3536
if(DEFINED Offline_UPS_QUALIFIER_STRING)
@@ -54,7 +55,7 @@ endif()
5455

5556
message("Creating link from ${CMAKE_CURRENT_SOURCE_DIR} to ${CMAKE_CURRENT_SOURCE_DIR}/Offline to satisfy includes")
5657
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Offline SYMBOLIC)
57-
58+
5859
find_package(art_root_io REQUIRED EXPORT)
5960
find_package(GSL REQUIRED EXPORT)
6061
find_package(PostgreSQL REQUIRED EXPORT)
@@ -64,8 +65,8 @@ find_package(XercesC REQUIRED EXPORT)
6465
find_package(BLAS REQUIRED EXPORT)
6566
find_package(artdaq-core-mu2e REQUIRED EXPORT)
6667
find_package(TRACE REQUIRED EXPORT)
67-
if( ${WITH_G4} )
68-
message("--> ADDING G4 LIBS")
68+
if( ${WITH_G4} )
69+
message("--> ADDING G4 LIBS")
6970
find_package(Geant4 REQUIRED EXPORT)
7071

7172
# TODO: Find or implement FindCRY.cmake
@@ -142,7 +143,7 @@ add_subdirectory(MCDataProducts)
142143
add_subdirectory(MECOStyleProtonAbsorberGeom)
143144
add_subdirectory(Mu2e)
144145
add_subdirectory(Mu2eBTrk)
145-
if( ${WITH_G4} )
146+
if( ${WITH_G4} )
146147
message("---> ADDING G4 DIRS")
147148
add_subdirectory(EventGenerator)
148149
add_subdirectory(Mu2eG4)

DataProducts/inc/IndexMap.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ namespace mu2e {
4848
ost << std::endl;
4949
}
5050
}
51+
auto const& map() const { return _theMap; }
5152

5253
private:
5354
std::map<FullIndex, CondensedIndex> _theMap; // FullIndex is first, CondensedIndex is second

EventDisplay/src/DataInterface.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ void DataInterface::fillEvent(boost::shared_ptr<ContentSelector> const &contentS
10031003
{
10041004
const mu2e::TrkStrawHitSeed &hit = hits.at(j);
10051005
int sid = hit.strawId().asUint16();
1006-
double time = hit.hitTime();
1006+
double time = hit.time();
10071007

10081008
std::map<int,boost::shared_ptr<Straw> >::iterator straw=_straws.find(sid);
10091009
if(straw!=_straws.end() && !std::isnan(time))

Mu2eKinKal/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,19 @@ cet_build_plugin(LoopHelixFit art::module
7272
Offline::TrkReco
7373

7474
)
75+
cet_build_plugin(RegrowLoopHelix art::module
76+
REG_SOURCE src/RegrowLoopHelix_module.cc
77+
LIBRARIES REG
78+
Offline::Mu2eKinKal
79+
Offline::TrkReco
80+
)
7581

82+
cet_build_plugin(RegrowKinematicLine art::module
83+
REG_SOURCE src/RegrowKinematicLine_module.cc
84+
LIBRARIES REG
85+
Offline::Mu2eKinKal
86+
Offline::TrkReco
87+
)
7688

7789
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/data/TrainBkgFinal.dat ${CURRENT_BINARY_DIR} data/TrainBkgFinal.dat COPYONLY)
7890
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/data/TrainBkgSeed.dat ${CURRENT_BINARY_DIR} data/TrainBkgSeed.dat COPYONLY)

Mu2eKinKal/fcl/prolog.fcl

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ Mu2eKinKal : {
4343
MaxStrawDOCA : 5.0 # mm
4444
MaxStrawDOCAConsistency : 1.0 # units of chi
4545
MaxStrawUposBuffer : 0.0 # units of mm
46+
IntersectionTolerance : 0.1 # tolerance for intersections (mm)
47+
SampleInRange : true # require sample be in time range
48+
SampleInBounds : true # require sample be in surface bounds
49+
SampleSurfaces : [] # specific to the fit type
4650
SaveHitCalibInfo : false
51+
SaveDomains : false
4752
}
4853

4954
CHSEEDFIT: {
@@ -185,7 +190,7 @@ Mu2eKinKal : {
185190
]
186191
}
187192

188-
SEEDFIT: {
193+
LHSEEDFIT: {
189194
PrintLevel : 0
190195
MinNDOF : 1
191196
MaxNIter : 10
@@ -194,7 +199,7 @@ Mu2eKinKal : {
194199
DivergenceDeltaChisq : 10.0
195200
DivergenceDeltaParams : 1e6
196201
DivergenceGap : 10 # mm
197-
BFieldCorrection : false
202+
BFieldCorrection : true
198203
BCorrTolerance : 1e-2 # momemntum fraction
199204
ProcessEnds : false
200205
MetaIterationSettings : [
@@ -234,7 +239,7 @@ Mu2eKinKal : {
234239
StrawXingUpdaterSettings : []
235240
}
236241

237-
SEEDEXT: {
242+
LHSEEDEXT: {
238243
PrintLevel : 0
239244
MinNDOF : 1
240245
MaxNIter : 10
@@ -346,24 +351,45 @@ Mu2eKinKal : {
346351
CaloClusterCollection : "CaloClusterMaker"
347352
}
348353

349-
LOOPHELIX : {
354+
# Minimal common configuration for regrowing KalSeeds
355+
REGROW : {
356+
PrintLevel : 0
357+
MinNDOF : 1
358+
MaxNIter : 10
359+
Deweight : 1.0e6
360+
ConvergenceDeltaChisq : 0.1
361+
DivergenceDeltaChisq : 10.0
362+
DivergenceDeltaParams : 1e6
363+
DivergenceGap : 100 # mm
364+
ProcessEnds : true
365+
BCorrTolerance : 1e-4
366+
MetaIterationSettings : [ [ 0.0, "" ] ]
367+
CADSHUSettings : [ ]
368+
BkgANNSHUSettings : [ ]
369+
DriftANNSHUSettings : [ ]
370+
Chi2SHUSettings : [ ]
371+
StrawXingUpdaterSettings : [ [-1.0, 1.0, false, 0 ] ]
372+
}
373+
374+
LHHELIX : {
350375
SeedErrors : [5.0, 5.0, 5.0, 5.0, 0.02, 5.0] # R(mm), Lambda(mm), Cx(mm), Cy(mm), phi0, t0 (ns)
351376
SeedFlags : [ "HelixOK" ]
352-
IntersectionTolerance : 0.1 # tolerance for intersections (mm)
353-
SampleInRange : true # require sample be in time range
354-
SampleInBounds : true # require sample be in surface bounds
355377
}
356378

357-
LOOPEXTRAPOLATION : {
379+
LHDRIFTXTRAP : {
380+
IntersectionTolerance : 0.1
358381
MaxDt : 200.0 # (ns)
382+
BCorrTolerance : 1e-4 # momemntum fraction
359383
ToTrackerEnds : true
360384
Upstream : true
361385
BackToTracker : false
362386
ToOPA : true
363387
}
364388

365-
SEEDEXTRAPOLATION : {
389+
LHSEEDXTRAP : {
390+
IntersectionTolerance : 0.1
366391
MaxDt : 200.0 # (ns)
392+
BCorrTolerance : 1e-2 # momemntum fraction
367393
ToTrackerEnds : true
368394
Upstream : false
369395
BackToTracker : false
@@ -416,16 +442,16 @@ Mu2eKinKal : {
416442
MaterialSettings : @local::Mu2eKinKal.MAT
417443
KKFitSettings: {
418444
@table::Mu2eKinKal.KKFIT
445+
SaveDomains : false
419446
SaveTrajectory : Detector
420447
}
421-
FitSettings : @local::Mu2eKinKal.SEEDFIT
422-
ExtensionSettings : @local::Mu2eKinKal.SEEDEXT
448+
FitSettings : @local::Mu2eKinKal.LHSEEDFIT
449+
ExtensionSettings : @local::Mu2eKinKal.LHSEEDEXT
423450
ModuleSettings : {
424-
@table::Mu2eKinKal.LOOPHELIX
451+
@table::Mu2eKinKal.LHHELIX
425452
@table::Mu2eKinKal.KKPrecursors
426-
SampleSurfaces : []
427453
}
428-
Extrapolation : @local::Mu2eKinKal.SEEDEXTRAPOLATION
454+
ExtrapolationSettings : @local::Mu2eKinKal.LHSEEDXTRAP
429455
UsePDGCharge: false
430456
HelixMask: {
431457
MinHelixMom : 0
@@ -437,17 +463,20 @@ Mu2eKinKal : {
437463
MaterialSettings : @local::Mu2eKinKal.MAT
438464
KKFitSettings : {
439465
@table::Mu2eKinKal.KKFIT
466+
SampleSurfaces : ["ST_Outer","ST_Front","ST_Back"] # these are additional surfaces; surfaces used in extrapolation are also sampled
440467
# save trajectories in the Detector region
468+
SaveDomains : true
441469
SaveTrajectory : Full
442470
}
443-
FitSettings : @local::Mu2eKinKal.SEEDFIT
471+
FitSettings : {
472+
@table::Mu2eKinKal.LHSEEDFIT
473+
}
444474
ExtensionSettings : @local::Mu2eKinKal.LHDRIFTEXT
445475
ModuleSettings : {
446-
@table::Mu2eKinKal.LOOPHELIX
476+
@table::Mu2eKinKal.LHHELIX
447477
@table::Mu2eKinKal.KKPrecursors
448-
SampleSurfaces : ["ST_Outer","ST_Front","ST_Back"] # these are additional surfaces; surfaces used in extrapolation are also sampled
449478
}
450-
Extrapolation : @local::Mu2eKinKal.LOOPEXTRAPOLATION
479+
ExtrapolationSettings : @local::Mu2eKinKal.LHDRIFTXTRAP
451480
UsePDGCharge: false
452481
HelixMask: {
453482
MinHelixMom : 0
@@ -459,7 +488,10 @@ Mu2eKinKal : {
459488
MaterialSettings : @local::Mu2eKinKal.MAT
460489
KKFitSettings: @local::Mu2eKinKal.KKFIT
461490
FitSettings : @local::Mu2eKinKal.CHSEEDFIT
462-
ExtensionSettings : @local::Mu2eKinKal.CHSEEDEXT
491+
ExtensionSettings : {
492+
@table::Mu2eKinKal.CHSEEDEXT
493+
BFieldCorrection : false
494+
}
463495
ModuleSettings : {
464496
@table::Mu2eKinKal.KINEMATICLINE
465497
@table::Mu2eKinKal.KKPrecursors
@@ -478,6 +510,7 @@ Mu2eKinKal : {
478510
MaxCaloClusterDt: 8
479511
# save the full trajectory
480512
SaveTrajectory: Full
513+
SaveDomains : false # meaningless for Linefit
481514
}
482515
FitSettings : @local::Mu2eKinKal.CHSEEDFIT
483516
ExtensionSettings : @local::Mu2eKinKal.CHDRIFTEXT
@@ -494,6 +527,7 @@ Mu2eKinKal : {
494527
KKFitSettings: {
495528
@table::Mu2eKinKal.KKFIT
496529
SaveTrajectory : T0
530+
SaveDomains : false
497531
}
498532
FitSettings : @local::Mu2eKinKal.CHSEEDFIT
499533
ExtensionSettings : @local::Mu2eKinKal.CHSEEDEXT
@@ -509,6 +543,7 @@ Mu2eKinKal : {
509543
KKFitSettings: {
510544
@table::Mu2eKinKal.KKFIT
511545
SaveTrajectory : Full
546+
SaveDomains : true
512547
}
513548
FitSettings : @local::Mu2eKinKal.CHSEEDFIT
514549
ExtensionSettings : @local::Mu2eKinKal.CHDRIFTEXT
@@ -538,15 +573,11 @@ Mu2eKinKal : {
538573
KKUmu: @local::Mu2eKinKal.LHDriftFit
539574
}
540575
}
541-
# Extrapolate upstream fits back to the tracker entrance
542-
Mu2eKinKal.producers.KKUe.Extrapolation.BackToTracker : true
543-
Mu2eKinKal.producers.KKUmu.Extrapolation.BackToTracker : true
544-
576+
# update directions and particles as needed
545577
Mu2eKinKal.producers.KKCHSeedFitmuM.ModuleSettings.FitParticle : @local::Particle.muminus
546578
Mu2eKinKal.producers.KKCHSeedFitmuP.ModuleSettings.FitParticle : @local::Particle.muplus
547579
Mu2eKinKal.producers.KKCHmu.ModuleSettings.FitParticle : @local::Particle.muminus # charge floats in the fit, this just determines the mass
548580

549-
Mu2eKinKal.producers.KLSeedFit.ExtensionSettings.BFieldCorrection : false
550581
Mu2eKinKal.producers.KLSeedFit.ModuleSettings.FitParticle : @local::Particle.muminus
551582
Mu2eKinKal.producers.KKLine.ModuleSettings.FitParticle : @local::Particle.muminus
552583

@@ -563,17 +594,15 @@ Mu2eKinKal.producers.KKUmuSeedFit.FitDirection : @local::FitDir.downstream
563594
# save trajectories in the Detector region for downstream fits, just the T0 segment for the rest
564595
Mu2eKinKal.producers.KKDe.ModuleSettings.FitParticle : @local::Particle.eminus
565596
Mu2eKinKal.producers.KKDe.FitDirection : @local::FitDir.downstream
566-
Mu2eKinKal.producers.KKDe.KKFitSettings.SaveTrajectory : "Detector"
567597
Mu2eKinKal.producers.KKDmu.ModuleSettings.FitParticle : @local::Particle.muminus
568598
Mu2eKinKal.producers.KKDmu.FitDirection : @local::FitDir.downstream
569-
Mu2eKinKal.producers.KKDmu.KKFitSettings.SaveTrajectory : "Detector"
570599
Mu2eKinKal.producers.KKUe.ModuleSettings.FitParticle : @local::Particle.eminus
571600
Mu2eKinKal.producers.KKUe.FitDirection : @local::FitDir.upstream
572-
Mu2eKinKal.producers.KKUe.KKFitSettings.SaveTrajectory : "Detector"
573601
Mu2eKinKal.producers.KKUmu.ModuleSettings.FitParticle : @local::Particle.muminus
574602
Mu2eKinKal.producers.KKUmu.FitDirection : @local::FitDir.upstream
575-
Mu2eKinKal.producers.KKUmu.KKFitSettings.SaveTrajectory : "Detector"
576-
# extrapolate upstream fits back to the tracker
577-
physics.producers.KKUmu.Extrapolation.BackToTracker : true
578-
physics.producers.KKUe.Extrapolation.BackToTracker : true
603+
# propagate upstream fits back to the tracker
604+
Mu2eKinKal.producers.KKUe.ExtrapolationSettings.BackToTracker : true
605+
Mu2eKinKal.producers.KKUmu.ExtrapolationSettings.BackToTracker : true
606+
607+
#
579608
END_PROLOG

Mu2eKinKal/inc/Chi2SHU_updateCluster.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace mu2e {
7272
pvar = resid.parameterVariance();
7373
}
7474
// Use the unbiased residual to compute the chisq
75-
Residual uresid(uresidval,resid.variance(),pvar,resid.active(),resid.dRdP());
75+
Residual uresid(uresidval,resid.variance(),pvar,resid.dRdP(),resid.active());
7676
chisq += uresid.chisq();
7777
++ndof;
7878
}

Mu2eKinKal/inc/ExtrapolateIPA.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace mu2e {
5757
if(ktraj.range().range() <= epsilon) return true; // keep going if the step is very small
5858
auto stime = tdir == TimeDir::forwards ? ktraj.range().begin()+epsilon : ktraj.range().end()-epsilon;
5959
auto etime = tdir == TimeDir::forwards ? ktraj.range().end() : ktraj.range().begin();
60-
auto vel = ktraj.speed(stime)*ktraj.axis(stime).direction();// use helix axis to define the velocity
60+
auto vel = ktraj.speed(stime)*ktraj.linearize(stime).direction();// use hlinear approximation
6161
auto spos = ktraj.position3(stime);
6262
auto epos = ktraj.position3(etime);
6363
double zvel = vel.Z()*timeDirSign(tdir); // sign by extrapolation direction

Mu2eKinKal/inc/KKCaloHit.hh

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ namespace mu2e {
2626
using CA = KinKal::ClosestApproach<KTRAJ,SensorLine>;
2727
using HIT = KinKal::Hit<KTRAJ>;
2828
using KTRAJPTR = std::shared_ptr<KTRAJ>;
29+
// clone op for reinstantiation
30+
KKCaloHit(KKCaloHit<KTRAJ> const& rhs):
31+
caloCluster_(rhs.caloCluster()),
32+
axis_(rhs.sensorAxis()),
33+
tvar_(rhs.timeVariance()),
34+
wvar_(rhs.widthVariance()),
35+
ca_(
36+
rhs.closestApproach().particleTraj(),
37+
axis_,
38+
rhs.closestApproach().hint(),
39+
rhs.closestApproach().precision()
40+
),
41+
rresid_(rhs.timeResidual()){
42+
/**/
43+
};
44+
std::shared_ptr< KinKal::Hit<KTRAJ> > clone(CloneContext& context) const override{
45+
auto rv = std::make_shared< KKCaloHit<KTRAJ> >(*this);
46+
auto ca = rv->closestApproach();
47+
auto trajectory = std::make_shared<KTRAJ>(ca.particleTraj());
48+
ca.setTrajectory(trajectory);
49+
rv->setClosestApproach(ca);
50+
return rv;
51+
};
2952
// Hit interface overrrides
3053
unsigned nResid() const override { return 1; } // 1 time residual
3154
Residual const& refResidual(unsigned ires=0) const override;
@@ -54,6 +77,8 @@ namespace mu2e {
5477
double wvar_; // variance in transverse position of the sensor/measurement in mm. Assumes cylindrical error, could be more general
5578
CA ca_; // reference time and distance of closest approach to the axis
5679
Residual rresid_; // residual WRT most recent reference parameters
80+
// clone support
81+
void setClosestApproach(const CA& ca){ ca_ = ca; }
5782
};
5883

5984
template <class KTRAJ> KKCaloHit<KTRAJ>::KKCaloHit(CCPtr caloCluster, PCA const& pca, double tvar, double wvar) : caloCluster_(caloCluster), axis_(pca.sensorTraj()), tvar_(tvar), wvar_(wvar),
@@ -73,7 +98,7 @@ namespace mu2e {
7398
// if(ca_.usable()) tphint = CAHint(ca_.particleToca(),ca_.sensorToca());
7499
PCA pca(ptraj,axis_,tphint,precision());
75100
ca_ = pca.localClosestApproach();
76-
if(!ca_.usable())rresid_ = Residual(rresid_.value(),rresid_.variance(),0.0,false,rresid_.dRdP());
101+
rresid_ = Residual(rresid_.value(),rresid_.variance(),0.0,rresid_.dRdP(),ca_.usable());
77102
}
78103

79104
template <class KTRAJ> void KKCaloHit<KTRAJ>::updateState(MetaIterConfig const& miconfig,bool first) {
@@ -112,9 +137,9 @@ namespace mu2e {
112137
double invvar2 = std::max(s2*sint2/(cost2*wvar_), 12/(ldt*ldt));
113138
totvar += 1.0/invvar2;
114139
}
115-
rresid_ = Residual(ca_.deltaT(),totvar,0.0,true,ca_.dTdP());
140+
rresid_ = Residual(ca_.deltaT(),totvar,0.0,ca_.dTdP());
116141
} else {
117-
rresid_ = Residual(rresid_.value(),rresid_.variance(),0.0,false,rresid_.dRdP());
142+
rresid_ = Residual(rresid_.value(),rresid_.variance(),0.0,rresid_.dRdP(),false);
118143
}
119144
// finally update the weight
120145
this->updateWeight(miconfig);

0 commit comments

Comments
 (0)