Skip to content

Commit 05e472a

Browse files
committed
proper ClosestApproach reinstantation in examples
1 parent 07025b0 commit 05e472a

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

Examples/ScintHit.hh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,28 @@ namespace KinKal {
1717
using RESIDHIT = ResidualHit<KTRAJ>;
1818
using HIT = Hit<KTRAJ>;
1919
using KTRAJPTR = std::shared_ptr<KTRAJ>;
20-
// clone op for reinstantiation
20+
// copy constructor
2121
ScintHit(ScintHit<KTRAJ> const& rhs):
2222
ResidualHit<KTRAJ>(rhs),
2323
saxis_(rhs.sensorAxis()),
2424
tvar_(rhs.timeVariance()),
2525
wvar_(rhs.widthVariance()),
26-
tpca_(rhs.closestApproach()),
26+
tpca_(
27+
rhs.closestApproach().particleTraj(),
28+
saxis_,
29+
rhs.closestApproach().hint(),
30+
rhs.closestApproach().precision()
31+
),
2732
rresid_(rhs.refResidual()){
2833
/**/
2934
};
35+
// clone op for reinstantiation
3036
std::shared_ptr< Hit<KTRAJ> > clone(CloneContext& context) const override{
3137
auto rv = std::make_shared< ScintHit<KTRAJ> >(*this);
38+
auto ca = rv->closestApproach();
39+
auto trajectory = std::make_shared<KTRAJ>(ca.particleTraj());
40+
ca.setTrajectory(trajectory);
41+
rv->setClosestApproach(ca);
3242
return rv;
3343
};
3444
// ResidualHit interface implementation
@@ -54,6 +64,9 @@ namespace KinKal {
5464
double wvar_; // variance in transverse position of the sensor/measurement in mm. Assumes cylindrical error, could be more general
5565
CA tpca_; // reference time and position of closest approach to the axis
5666
Residual rresid_; // residual WRT most recent reference parameters
67+
68+
// modifiers to support cloning
69+
void setClosestApproach(const CA& ca){ tpca_ = ca; }
5770
};
5871

5972
template <class KTRAJ> ScintHit<KTRAJ>::ScintHit(PCA const& pca, double tvar, double wvar) :

Examples/SimpleWireHit.hh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ namespace KinKal {
8181
auto const& residuals() const { return rresid_; }
8282
double tot() const { return tot_; }
8383
double totVariance() const { return totvar_; }
84-
// other accessors
85-
void setClosestApproach(const CA& ca){ ca_ = ca; }
84+
8685
private:
8786
BFieldMap const& bfield_; // drift calculation requires the BField for ExB effects
8887
WireHitState whstate_; // current state
@@ -100,6 +99,9 @@ namespace KinKal {
10099
double rcell_; // straw radius
101100
int id_; // id
102101
void updateResiduals();
102+
103+
// modifiers to support cloning
104+
void setClosestApproach(const CA& ca){ ca_ = ca; }
103105
};
104106

105107
//trivial 'updater' that sets the wire hit state to null

Examples/StrawXing.hh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,23 @@ namespace KinKal {
2222
StrawXing(PCA const& pca, StrawMaterial const& smat);
2323
virtual ~StrawXing() {}
2424
// copy constructor
25-
StrawXing(StrawXing const& rhs) = default;
25+
StrawXing(StrawXing const& rhs):
26+
ElementXing<KTRAJ>(rhs),
27+
axis_(rhs.axis_),
28+
smat_(rhs.smat_),
29+
tpca_(
30+
rhs.closestApproach().particleTraj(),
31+
axis_,
32+
rhs.closestApproach().hint(),
33+
rhs.closestApproach().precision()
34+
),
35+
toff_(rhs.toff_),
36+
sxconfig_(rhs.sxconfig_),
37+
varscale_(rhs.varscale_),
38+
mxings_(rhs.mxings_),
39+
fparams_(rhs.fparams_){
40+
/**/
41+
}
2642
// clone op for reinstantiation
2743
std::shared_ptr< ElementXing<KTRAJ> > clone(CloneContext& context) const override{
2844
auto rv = std::make_shared< StrawXing<KTRAJ> >(*this);
@@ -46,8 +62,7 @@ namespace KinKal {
4662
auto const& strawMaterial() const { return smat_; }
4763
auto const& config() const { return sxconfig_; }
4864
auto precision() const { return tpca_.precision(); }
49-
// other accessors
50-
void setClosestApproach(const CA& ca){ tpca_ = ca; }
65+
5166
private:
5267
SensorLine axis_; // straw axis, expressed as a timeline
5368
StrawMaterial const& smat_;
@@ -57,6 +72,9 @@ namespace KinKal {
5772
double varscale_; // variance scale
5873
std::vector<MaterialXing> mxings_;
5974
Parameters fparams_; // parameter change for forwards time
75+
76+
// modifiers to support cloning
77+
void setClosestApproach(const CA& ca){ tpca_ = ca; }
6078
};
6179

6280
template <class KTRAJ> StrawXing<KTRAJ>::StrawXing(PCA const& pca, StrawMaterial const& smat) :

0 commit comments

Comments
 (0)