41 void insertFlags(std::vector<double> &flags, std::shared_ptr<Component> element);
47 totalPathLength_m(0.0)
54 out << std::fixed << std::setprecision(6);
61 for (; mapIti != mapItf; mapIti++) {
62 const key_t key = (*mapIti).first;
63 const value_t val = (*mapIti).second;
65 << std::setw(numDigits + 7) << std::right << key.
begin
67 << std::setw(numDigits + 7) << std::right << key.
end
68 <<
") number of overlapping elements " << val.size() <<
"\n";
70 for (
auto element: val) {
71 out <<
"* " << std::setw(25 + 2 * numDigits) <<
" " << element->getName() <<
"\n";
77 const double lowerLimit = s - ds;
83 throw OutOfBounds(
"IndexMap::query",
"out of bounds");
89 for (; it !=
end; ++
it) {
90 const double low = (*it).first.begin;
91 const double high = (*it).first.end;
93 if (lowerLimit < high && upperLimit >= low)
break;
96 if (it == end)
return elementSet;
99 for (; last !=
end; ++ last) {
100 const double low = (*last).first.begin;
102 if (upperLimit < low)
break;
105 for (; it != last; ++
it) {
106 const value_t &a = (*it).second;
107 elementSet.insert(a.cbegin(), a.cend());
114 if (initialS > finalS) {
115 std::swap(initialS, finalS);
125 for (; setIt != setEnd; ++ setIt) {
131 bool extendedExisting =
false;
132 for (
auto it = itpair.first;
it != itpair.second; ++
it) {
133 key_t ¤tRange =
it->second;
136 currentRange.
end = key.end;
137 extendedExisting =
true;
141 if (!extendedExisting) {
152 (*rit).second.empty() &&
153 zstop > (*rit).first.begin) {
180 std::vector<std::tuple<double, std::vector<double>, std::string> > sectors;
192 for (; mapIti != mapItf; mapIti++) {
193 const auto §orElements = (*mapIti).second;
194 if (sectorElements.empty())
197 const auto §orRange = (*mapIti).first;
199 double sectorBegin = sectorRange.begin;
200 double sectorEnd = sectorRange.end;
202 std::vector<std::tuple<double, std::vector<double>, std::string> > currentSector(4);
203 std::get<0>(currentSector[0]) = sectorBegin;
204 std::get<0>(currentSector[1]) = sectorBegin;
205 std::get<0>(currentSector[2]) = sectorEnd;
206 std::get<0>(currentSector[3]) = sectorEnd;
208 for (
unsigned short i = 0; i < 4; ++ i) {
209 auto &flags = std::get<1>(currentSector[i]);
210 flags.resize(
SIZE, 0);
213 for (
auto element: sectorElements) {
215 auto passage = elementPassages.first;
216 auto end = elementPassages.second;
217 for (; passage !=
end; ++ passage) {
218 const auto &elementRange = (*passage).second;
219 double elementBegin = elementRange.begin;
220 double elementEnd = elementRange.end;
222 if (elementBegin <= sectorBegin &&
223 elementEnd >= sectorEnd) {
228 const auto &elementRange = (*passage).second;
229 if (elementRange.begin < sectorBegin) {
230 ::insertFlags(std::get<1>(currentSector[0]), element);
231 std::get<2>(currentSector[0]) += element->getName() +
", ";
234 ::insertFlags(std::get<1>(currentSector[1]), element);
235 std::get<2>(currentSector[1]) += element->getName() +
", ";
237 ::insertFlags(std::get<1>(currentSector[2]), element);
238 std::get<2>(currentSector[2]) += element->getName() +
", ";
240 if (elementRange.end > sectorEnd) {
241 ::insertFlags(std::get<1>(currentSector[3]), element);
242 std::get<2>(currentSector[3]) += element->getName() +
", ";
246 for (
unsigned short i = 0; i < 4; ++ i) {
247 sectors.push_back(currentSector[i]);
252 const unsigned int numEntries = sectors.size();
256 auto element = (*it).first;
257 auto name = element->getName();
258 auto type = element->getType();
264 auto range = (*it).second;
267 for (; i < numEntries; ++ i) {
268 if (std::get<0>(sectors[i]) >= range.begin) {
273 if (i == numEntries)
continue;
275 unsigned int j = ++ i;
276 while (std::get<0>(sectors[j]) < range.end) {
280 double length = range.end - range.begin;
281 for (; i <= j; ++ i) {
282 double pos = std::get<0>(sectors[i]);
283 auto &items = std::get<1>(sectors[i]);
285 items[
RFCAVITY] = 1.0 - 2 * (pos - range.begin) / length;
290 if (!sectors.empty() &&
291 std::get<0>(sectors[0]) > initialPathLength) {
293 sectors = std::vector<std::tuple<double, std::vector<double>, std::string> >(1);
294 std::get<0>(sectors[0]) = initialPathLength;
295 std::get<1>(sectors[0]).resize(
SIZE, 0.0);
297 sectors.insert(sectors.end(), tmp.begin(), tmp.end());
306 for (
auto sector: sectors) {
307 std::string
names = std::get<2>(sector);
308 if (!names.empty()) {
309 names = names.substr(0, names.length() - 2);
311 names =
"\"" + names +
"\"";
312 writer.addRow(std::get<0>(sector),
319 void insertFlags(std::vector<double> &flags, std::shared_ptr<Component> element) {
320 switch (element->getType()) {
324 const Bend2D* bend =
static_cast<const Bend2D*
>(element.get());
376 double position)
const {
378 key_t range{0.0, 0.0};
379 const std::pair<invertedMap_t::const_iterator, invertedMap_t::const_iterator> its =
mapElement2Range_m.equal_range(element);
380 if (std::distance(its.first, its.second) == 0)
382 "Element \"" + element->getName() +
"\" not registered");
384 for (invertedMap_t::const_iterator
it = its.first;
it != its.second; ++
it) {
386 std::abs((*it).second.end - position));
387 if (distance < minDistance) {
388 minDistance = distance;
389 range = (*it).second;
401 for (; it !=
end; ++
it) {
404 touchingElements.insert((it->second).begin(), (it->second).
end());
407 return touchingElements;
411 return (
std::abs(x - y) < std::numeric_limits<double>::epsilon() *
std::abs(x + y) * 2 ||
static OpalData * getInstance()
void print(std::ostream &) const
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of it
value_t getTouchingElements(const key_t &range) const
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
bool isFocusing(unsigned int component) const
std::set< std::shared_ptr< Component > > value_t
Interface for general multipole.
constexpr double pi
The value of .
Inform & endl(Inform &inf)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
key_t getRange(const IndexMap::value_t::value_type &element, double position) const
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
std::string::iterator iterator
value_t query(key_t::first_type s, key_t::second_type ds)
void tidyUp(double zstop)
The base class for all OPAL exceptions.
std::string getAuxiliaryOutputDirectory() const
get the name of the the additional data directory
invertedMap_t mapElement2Range_m
static const double oneMinusEpsilon_m
double getRotationAboutZ() const
void saveSDDS(double startS) const
Tps< T > log(const Tps< T > &x)
Natural logarithm.
std::string combineFilePath(std::initializer_list< std::string > ilist)
T * value_type(const SliceIterator< T > &)
std::string getInputBasename()
get input file name without extension
static bool almostEqual(double, double)
size_t getMaxNormalComponentIndex() const
PETE_TUTree< FnFloor, typename T::PETE_Expr_t > floor(const PETE_Expr< T > &l)
void add(key_t::first_type initialStep, key_t::second_type finalStep, const value_t &val)