Skip to content

Commit 3386063

Browse files
ENH: reorder pos.push_back and adjust_path_length; add comments;
1 parent 352ead7 commit 3386063

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

include/trackcpp/tracking.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ Status::type track_linepass (
164164
// syntactic-sugar for read-only access to element object parameters
165165
const Element& element = line[element_offset];
166166

167-
// stores trajectory at entrance of each element
168-
if (indcs[i]) pos.push_back(orig_pos);
169-
170167
// adjust dl to keep the arrival-time in sync with wall clock
168+
// note: for performance reasons, the adjustment of the path length
169+
// is done only at the beginning of "time aware" elements (e.g. RF cavities)
171170
adjust_path_length(accelerator, element_offset, orig_pos);
171+
172+
// stores trajectory at entrance of each element
173+
if (indcs[i]) pos.push_back(orig_pos);
172174

173175
status = track_elementpass(accelerator, element, orig_pos);
174176
lost_plane = check_particle_loss(accelerator, element, orig_pos);

src/tracking.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ Status::type track_findm66 (Accelerator& accelerator,
7171

7272
tm.clear(); tm.reserve(indices.size());
7373
for(unsigned int i=0; i<lattice.size(); ++i) {
74-
// const Element& element = lattice[i];
74+
// note: for performance reasons, the adjustment of the path length
75+
// is done only at the beginning of "time aware" elements (e.g. RF cavities)
76+
adjust_path_length(accelerator, i, map);
7577
if (indcs[i]){
7678
Matrix m (6);
7779
m[0][0] = map.rx.c[1]; m[0][1] = map.rx.c[2]; m[0][2] = map.rx.c[3];
@@ -88,7 +90,6 @@ Status::type track_findm66 (Accelerator& accelerator,
8890
m[5][3] = map.dl.c[4]; m[5][4] = map.dl.c[5]; m[5][5] = map.dl.c[6];
8991
tm.push_back(std::move(m));
9092
}
91-
adjust_path_length(accelerator, i, map);
9293
// track through element
9394
if ((status = track_elementpass(accelerator, lattice[i], map)) != Status::success) return status;
9495
}

0 commit comments

Comments
 (0)