@@ -22,6 +22,8 @@ namespace KinKal {
2222 using CA = ClosestApproach<KTRAJ,SensorLine>;
2323 using KTRAJPTR = std::shared_ptr<KTRAJ>;
2424 using PTRAJ = ParticleTrajectory<KTRAJ>;
25+ using STRAJPTR = std::shared_ptr<SensorLine>;
26+
2527 enum Dimension { dresid=0 , tresid=1 }; // residual dimensions
2628
2729 SimpleWireHit (BFieldMap const & bfield, PCA const & pca, WireHitState const & whstate, double mindoca,
@@ -32,13 +34,7 @@ namespace KinKal {
3234 ResidualHit<KTRAJ>(rhs),
3335 bfield_ (rhs.bfield()),
3436 whstate_ (rhs.hitState()),
35- wire_ (rhs.wire()),
36- ca_ (
37- rhs.closestApproach().particleTraj(),
38- wire_,
39- rhs.closestApproach().hint(),
40- rhs.closestApproach().precision()
41- ),
37+ tpca_ (rhs.tpca_),
4238 rresid_ (rhs.residuals()),
4339 mindoca_ (rhs.minDOCA()),
4440 dvel_ (driftVelocity()),
@@ -57,11 +53,11 @@ namespace KinKal {
5753 rv->setClosestApproach (ca);
5854 return rv;
5955 };
60- double time () const override { return ca_ .particleToca (); }
56+ double time () const override { return tpca_ .particleToca (); }
6157 VEC3 dRdX (unsigned ires) const ;
6258 Residual const & refResidual (unsigned ires=dresid) const override ;
6359 void updateReference (PTRAJ const & ptraj) override ;
64- KTRAJPTR const & refTrajPtr () const override { return ca_ .particleTrajPtr (); }
60+ KTRAJPTR refTrajPtr () const override { return tpca_ .particleTrajPtr (); }
6561 void print (std::ostream& ost=std::cout,int detail=0 ) const override ;
6662 // Use dedicated updater
6763 void updateState (MetaIterConfig const & config,bool first) override ;
@@ -73,24 +69,23 @@ namespace KinKal {
7369 double minDOCA () const { return mindoca_; }
7470 int id () const { return id_; }
7571 CA unbiasedClosestApproach () const ;
76- auto const & closestApproach () const { return ca_ ; }
72+ auto const & closestApproach () const { return tpca_ ; }
7773 auto const & hitState () const { return whstate_; }
78- auto const & wire () const { return wire_; }
7974 auto const & bfield () const { return bfield_; }
80- auto precision () const { return ca_ .precision (); }
75+ auto precision () const { return tpca_ .precision (); }
8176 auto const & residuals () const { return rresid_; }
8277 double tot () const { return tot_; }
8378 double totVariance () const { return totvar_; }
79+ auto wire () const { return tpca_.sensorTrajPtr (); }
8480
8581 private:
8682 BFieldMap const & bfield_; // drift calculation requires the BField for ExB effects
8783 WireHitState whstate_; // current state
88- SensorLine wire_; // local linear approximation to the wire of this hit, encoding all (local) position and time information.
8984 // the start time is the measurement time, the direction is from
9085 // the physical source of the signal (particle) to the measurement recording location (electronics), the direction magnitude
9186 // is the effective signal propagation velocity along the wire, and the time range describes the active wire length
9287 // (when multiplied by the propagation velocity).
93- CA ca_ ; // reference time and position of closest approach to the wire; this is generally biased by the hit
88+ CA tpca_ ; // reference time and position of closest approach to the wire; this is generally biased by the hit
9489 std::array<Residual,2 > rresid_; // residuals WRT most recent reference
9590 double mindoca_; // effective minimum DOCA used when assigning LR ambiguity, used to define null hit properties
9691 double dvel_; // constant drift speed
@@ -101,7 +96,7 @@ namespace KinKal {
10196 void updateResiduals ();
10297
10398 // modifiers to support cloning
104- void setClosestApproach (const CA& ca){ ca_ = ca; }
99+ void setClosestApproach (const CA& ca){ tpca_ = ca; }
105100 };
106101
107102 // trivial 'updater' that sets the wire hit state to null
@@ -113,18 +108,18 @@ namespace KinKal {
113108 template <class KTRAJ > SimpleWireHit<KTRAJ>::SimpleWireHit(BFieldMap const & bfield, PCA const & pca, WireHitState const & whstate,
114109 double mindoca, double driftspeed, double tvar, double tot, double totvar, double rcell, int id) :
115110 bfield_ (bfield),
116- whstate_(whstate), wire_(pca.sensorTraj()),
117- ca_(pca.localTraj(),wire_, pca.precision(),pca.tpData(),pca.dDdP(),pca.dTdP()), // must be explicit to get the right sensor traj reference
111+ whstate_(whstate),
112+ tpca_( static_cast <CA const &>( pca)),
118113 mindoca_(mindoca), dvel_(driftspeed), tvar_(tvar), tot_(tot), totvar_(totvar), rcell_(rcell), id_(id) {
119114 }
120115
121116 template <class KTRAJ > void SimpleWireHit<KTRAJ>::updateReference(PTRAJ const & ptraj) {
122117 // if we already computed PCA in the previous iteration, use that to set the hint. This speeds convergence
123118 // otherwise use the time at the center of the wire
124- CAHint tphint = ca_ .usable () ? ca_ .hint () : CAHint (wire_. timeAtMidpoint (),wire_. timeAtMidpoint ());
125- PCA pca (ptraj,wire_ ,tphint,precision ());
126- ca_ = pca. localClosestApproach ( );
127- if (!ca_ .usable ())throw std::runtime_error (" WireHit TPOCA failure" );
119+ CAHint tphint = tpca_ .usable () ? tpca_ .hint () : CAHint (wire ()-> timeAtMidpoint (),wire ()-> timeAtMidpoint ());
120+ PCA pca (ptraj,wire () ,tphint,precision ());
121+ tpca_ = static_cast <CA>(pca );
122+ if (!tpca_ .usable ())throw std::runtime_error (" WireHit TPOCA failure" );
128123 }
129124
130125 template <class KTRAJ > void SimpleWireHit<KTRAJ>::updateState(MetaIterConfig const & miconfig, bool first) {
@@ -148,16 +143,16 @@ namespace KinKal {
148143 }
149144 rresid_[tresid] = rresid_[dresid] = Residual ();
150145 if (whstate_.active ()){
151- rresid_[tresid] = Residual (ca_ .deltaT () - tot_, totvar_,0.0 ,ca_ .dTdP ()); // always constrain to TOT; this stabilizes the fit
146+ rresid_[tresid] = Residual (tpca_ .deltaT () - tot_, totvar_,0.0 ,tpca_ .dTdP ()); // always constrain to TOT; this stabilizes the fit
152147 if (whstate_.useDrift ()){
153148 // translate PCA to residual. Use ambiguity assignment to convert drift time to a drift radius
154- double dr = dvel_*whstate_.lrSign ()*ca_ .deltaT () -ca_ .doca ();
155- DVEC dRdP = dvel_*whstate_.lrSign ()*ca_ .dTdP () -ca_ .dDdP ();
149+ double dr = dvel_*whstate_.lrSign ()*tpca_ .deltaT () -tpca_ .doca ();
150+ DVEC dRdP = dvel_*whstate_.lrSign ()*tpca_ .dTdP () -tpca_ .dDdP ();
156151 rresid_[dresid] = Residual (dr,tvar_*dvel_*dvel_,0.0 ,dRdP);
157152 } else {
158153 // interpret DOCA against the wire directly as a residuals
159- double nulldvar = dvel_*dvel_*(ca_ .deltaT ()*ca_ .deltaT ()+0.8 );
160- rresid_[dresid] = Residual (ca_ .doca (),nulldvar,0.0 ,ca_ .dDdP ());
154+ double nulldvar = dvel_*dvel_*(tpca_ .deltaT ()*tpca_ .deltaT ()+0.8 );
155+ rresid_[dresid] = Residual (tpca_ .doca (),nulldvar,0.0 ,tpca_ .dDdP ());
161156 }
162157 }
163158 // now update the weight
@@ -168,9 +163,9 @@ namespace KinKal {
168163 if (whstate_.active ()){
169164 if (ires == dresid){
170165 if (whstate_.useDrift ()){
171- return ca_ .lSign ()*ca_ .delta ().Vect ().Unit ();
166+ return tpca_ .lSign ()*tpca_ .delta ().Vect ().Unit ();
172167 }else {
173- return -1 *ca_ .lSign ()*ca_ .delta ().Vect ().Unit ();
168+ return -1 *tpca_ .lSign ()*tpca_ .delta ().Vect ().Unit ();
174169 }
175170 }
176171 }
@@ -186,7 +181,7 @@ namespace KinKal {
186181 // compute the unbiased closest approach; this is brute force, but works
187182 auto const & ca = this ->closestApproach ();
188183 auto uparams = HIT::unbiasedParameters ();
189- KTRAJ utraj (uparams,ca.particleTraj ());
184+ auto utraj = std::make_shared<KTRAJ> (uparams,ca.particleTraj ());
190185 return CA (utraj,this ->wire (),ca.hint (),ca.precision ());
191186 }
192187
@@ -214,7 +209,7 @@ namespace KinKal {
214209 ost << std::endl;
215210 }
216211 if (detail > 1 ) {
217- ost << " Approximate Propagation speed " << wire_. speed (100 ) << " TPOCA " << ca_ .tpData () << std::endl;
212+ ost << " Approximate Propagation speed " << wire ()-> speed (100 ) << " TPOCA " << tpca_ .tpData () << std::endl;
218213 }
219214 }
220215
0 commit comments