15#ifndef O2_MCH_CONTOUR_CONTOURCREATOR_INL
16#define O2_MCH_CONTOUR_CONTOURCREATOR_INL
46 auto x1 = e1.begin().x;
47 auto x2 = e2.begin().x;
52 if (areEqual(x1, x2)) {
53 if (isLeftEdge(e1) && isRightEdge(e2)) {
56 if (isRightEdge(e1) && isLeftEdge(e2)) {
72 auto y2 = edge.
end().y;
80 std::vector<VerticalEdge<T>>
edges;
81 for (
auto i = 0;
i < polygon.
size() - 1; ++
i) {
82 auto current = polygon[
i];
83 auto next = polygon[
i + 1];
84 if (current.x == next.x) {
85 edges.push_back({ current.x, current.y, next.y });
94 std::vector<VerticalEdge<T>>
edges;
95 for (
const auto& p : polygons) {
121 for (
auto i = 0;
i < polygons.size(); ++
i) {
122 for (
auto j = 0;
j < polygons[
i].size(); ++
j) {
123 ypos.push_back(
func(polygons[
i][
j]));
126 std::sort(ypos.begin(), ypos.end());
127 auto last = std::unique(ypos.begin(), ypos.end(), [](
const T&
a,
const T&
b) { return areEqual(a, b); });
128 ypos.erase(last, ypos.end());
147 std::vector<VerticalEdge<T>> contourVerticalEdges;
149 std::vector<Interval<T>> edgeStack;
151 for (
auto i = 0;
i < polygonVerticalEdges.size(); ++
i) {
153 const auto& edge = polygonVerticalEdges[
i];
166 if (
i < polygonVerticalEdges.size() - 1) {
167 e1 = polygonVerticalEdges[
i + 1];
171 (
i == polygonVerticalEdges.size() - 1)) {
172 for (
auto es : edgeStack) {
180 return contourVerticalEdges;
194 std::vector<HorizontalEdge<T>> horizontals(verticals.size());
196 using VertexWithRef = std::pair<Vertex<T>, T>;
197 std::vector<VertexWithRef> vertices;
199 for (
auto i = 0;
i < verticals.size(); ++
i) {
200 const auto& edge = verticals[
i];
201 vertices.push_back({ edge.begin(),
i });
202 vertices.push_back({ edge.end(),
i });
205 std::sort(vertices.begin(), vertices.end(),
206 [](
const VertexWithRef&
v1,
const VertexWithRef&
v2) { return v1.first < v2.first; });
208 for (
auto i = 0;
i < vertices.size() / 2; ++
i) {
209 const auto&
p1 = vertices[2 *
i];
210 const auto&
p2 = vertices[2 *
i + 1];
220 int preceding =
p1.second;
221 int next =
p2.second;
223 std::swap(preceding, next);
225 horizontals[preceding] =
h;
234 if (verticals.size() != horizontals.size()) {
235 throw std::invalid_argument(
"should get the same number of verticals and horizontals");
238 for (
auto i = 0;
i < verticals.size(); ++
i) {
239 if (horizontals[
i].begin() != verticals[
i].
end()) {
240 throw std::invalid_argument(
"got an horizontal edge not connected to its (supposedly) preceding vertical edge");
244 std::vector<ManhattanEdge<T>> all;
246 for (
auto i = 0;
i < verticals.size(); ++
i) {
247 all.push_back(verticals[
i]);
248 all.push_back(horizontals[
i]);
253 std::vector<bool> alreadyAdded(all.size(),
false);
254 std::vector<int> inorder;
261 while (nofUsed < all.size()) {
264 inorder.push_back(iCurrent);
265 alreadyAdded[iCurrent] =
true;
268 if (inorder.empty()) {
269 throw std::runtime_error(
"got an empty polygon");
271 std::vector<Vertex<T>> vertices;
272 vertices.reserve(inorder.size());
273 for (
auto i : inorder) {
274 vertices.push_back(all[
i].begin());
276 Polygon<T> polygon(vertices.begin(), vertices.end());
278 iCurrent = std::distance(alreadyAdded.begin(), std::find_if(alreadyAdded.begin(), alreadyAdded.end(),
279 [](
bool a) { return a == false; }));
280 if (iCurrent<all.size()) {
286 for (
auto i = 0;
i < alreadyAdded.size(); ++
i) {
287 if (
i != iCurrent && alreadyAdded[
i] ==
false) {
288 if (currentSegment.end() == all[
i].begin()) {
bool areEqual(double a, double b)
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
constexpr int p1()
constexpr to accelerate the coordinates changing
std::vector< LocalPoint > getPositions(int npoints)
std::vector< SidecarEdge > edges
Class for time synchronization of RawReader instances.
Contour< T > & addPolygon(const Polygon< T > &polygon)
Vertex< T > begin() const
void insertInterval(Interval< T > i)
void deleteInterval(Interval< T > i)
void contribution(Interval< T > i, std::vector< o2::mch::contour::impl::Interval< T > > &edgeStack)
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLfloat GLfloat GLfloat x1
GLdouble GLdouble GLdouble GLdouble top
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLfloat GLfloat GLfloat v2
bool isLeftEdge(const VerticalEdge< T > &edge)
std::vector< VerticalEdge< T > > sweep(Node< T > *segmentTree, const std::vector< VerticalEdge< T > > &polygonVerticalEdges)
std::vector< VerticalEdge< T > > getVerticalEdges(const Polygon< T > &polygon)
Interval< T > interval(const VerticalEdge< T > &edge)
bool isRightEdge(const VerticalEdge< T > &edge)
std::vector< HorizontalEdge< T > > verticalsToHorizontals(const std::vector< VerticalEdge< T > > &verticals)
Contour< T > finalizeContour(const std::vector< VerticalEdge< T > > &verticals, const std::vector< HorizontalEdge< T > > &horizontals)
T(*)(const Vertex< T > &) GetVertexPosFunc
std::vector< T > getYPositions(const std::vector< Polygon< T > > &polygons)
std::vector< T > getXPositions(const std::vector< Polygon< T > > &polygons)
void sortVerticalEdges(std::vector< VerticalEdge< T > > &edges)
Polygon< T > close(Polygon< T > polygon)
double * getX(double *xyDxy, int N)
double * getY(double *xyDxy, int N)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...