@@ -164,10 +164,10 @@ namespace KinKal {
164164 // minimal constructor for subclasses. The resulting object has no fit.
165165 template <class KTRAJ > Track<KTRAJ >::Track(Config const & cfg, BFieldMap const & bfield) :
166166 config_{cfg}, bfield_(bfield)
167- {
168- if (config ().schedule ().size () ==0 )throw std::invalid_argument (" Invalid configuration: no schedule" );
169- history_.push_back (Status (0 ,0 ,Status::unfit, " Construction" ));
170- }
167+ {
168+ if (config ().schedule ().size () ==0 )throw std::invalid_argument (" Invalid configuration: no schedule" );
169+ history_.push_back (Status (0 ,0 ,Status::unfit, " Construction" ));
170+ }
171171
172172 // construct from configuration, reference (seed) fit, hits,and materials specific to this fit. This will compute the domains according to the configuration before fitting.
173173 //
@@ -198,26 +198,28 @@ namespace KinKal {
198198 fittraj_ = std::move (fittraj); // steal the underlying object
199199 // truncate the domains and fit trajectory to be within the detector range
200200 auto detrange = detectorRange (hits,exings,true );
201- auto idom = domains.begin ();
202- // stop at the 1st domain overlaping the detector range, and erase all elements up to that point
203- while (idom != domains.end () && !(detrange.overlaps ((*idom)->range ())))++idom;
204- if (idom != domains.begin ())domains.erase (domains.begin (),--idom);// leave the overlapping piece
205- auto jdom= domains.rbegin ();
206- while (jdom != domains.rend () && !(detrange.overlaps ((*jdom)->range ())))++jdom;
207- domains.erase (jdom.base (),domains.end ()); // base points 1 past the reverse iterator
208- // trim the trajectory to this range
209- detrange.combine ((*domains.begin ())->range ());
210- detrange.combine ((*domains.rbegin ())->range ());
201+ if (domains.size () > 0 ){
202+ auto idom = domains.begin ();
203+ // stop at the 1st domain overlaping the detector range, and erase all elements up to that point
204+ while (idom != domains.end () && !(detrange.overlaps ((*idom)->range ())))++idom;
205+ if (idom != domains.begin ())domains.erase (domains.begin (),--idom);// leave the overlapping piece
206+ auto jdom= domains.rbegin ();
207+ while (jdom != domains.rend () && !(detrange.overlaps ((*jdom)->range ())))++jdom;
208+ domains.erase (jdom.base (),domains.end ()); // base points 1 past the reverse iterator
209+ // trim the trajectory to this range
210+ detrange.combine ((*domains.begin ())->range ());
211+ detrange.combine ((*domains.rbegin ())->range ());
212+ }
211213 fittraj_->setRange (detrange,true );
212214 createEffects (hits,exings,domains);
213215 fit ();
214216 }
215217
216218 // copy constructor
217219 template <class KTRAJ > Track<KTRAJ >::Track(const Track& rhs, CloneContext& context) :
218- config_ (rhs.configs()),
219- bfield_(rhs.bfield()),
220- history_(rhs.history())
220+ config_ (rhs.configs()),
221+ bfield_(rhs.bfield()),
222+ history_(rhs.history())
221223 {
222224 fittraj_ = std::make_unique<PKTRAJ >(rhs.fitTraj ());
223225 hits_.reserve (rhs.hits ().size ());
@@ -231,12 +233,12 @@ namespace KinKal {
231233 exings_.push_back (xng);
232234 }
233235 for (const auto & ptr: rhs.domains ()){
234- auto dmn = context.get (ptr);
235- domains_.insert (dmn);
236+ auto dmn = context.get (ptr);
237+ domains_.insert (dmn);
236238 }
237239 for (const auto & ptr: rhs.effects ()){
238- auto eff = ptr->clone (context);
239- effects_.push_back (std::move (eff));
240+ auto eff = ptr->clone (context);
241+ effects_.push_back (std::move (eff));
240242 }
241243 };
242244
0 commit comments