All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
GeoObjectSorterSBND.cxx File Reference

Algorithm class for sorting standard geo::XXXGeo objects for SBND. More...

#include "sbndcode/Geometry/GeoObjectSorterSBND.h"
#include "larcorealg/Geometry/CryostatGeo.h"
#include "larcorealg/Geometry/OpDetGeo.h"
#include "larcorealg/Geometry/TPCGeo.h"
#include "larcorealg/Geometry/PlaneGeo.h"
#include "larcorealg/Geometry/WireGeo.h"
#include "larcorealg/Geometry/AuxDetGeo.h"
#include "fhiclcpp/ParameterSet.h"
#include "cetlib_except/exception.h"
#include "cmath"

Go to the source code of this file.

Functions

bool equal (double a, double b)
 Comparison tolerance, in centimeters. More...
 
bool CryostatSorter (geo::CryostatGeo const &c1, geo::CryostatGeo const &c2)
 
static bool OpDetsSorter (geo::OpDetGeo const &t1, geo::OpDetGeo const &t2)
 
bool TPCSorter (geo::TPCGeo const &t1, geo::TPCGeo const &t2)
 
bool PlaneSorter (geo::PlaneGeo const &p1, geo::PlaneGeo const &p2)
 
bool WireSorter (geo::WireGeo const &w1, geo::WireGeo const &w2)
 

Variables

static const double tol = 1e-4
 

Detailed Description

Algorithm class for sorting standard geo::XXXGeo objects for SBND.

Date
April 6, 2017
Author
petri.nosp@m.llo@.nosp@m.fnal..nosp@m.gov

Definition in file GeoObjectSorterSBND.cxx.

Function Documentation

bool CryostatSorter ( geo::CryostatGeo const &  c1,
geo::CryostatGeo const &  c2 
)

Definition at line 38 of file GeoObjectSorterSBND.cxx.

38  {
39  //
40  // sort order for cryostats: by x
41  // (not that we have that many in SBND...)
42  //
43  return (c1.CenterX()) < (c2.CenterX());
44 
45 } // CryostatSorter()
bool equal ( double  a,
double  b 
)
inline

Comparison tolerance, in centimeters.

Returns whether the two values are equal (including some tolerance).

Definition at line 33 of file GeoObjectSorterSBND.cxx.

34  { return std::abs(a - b) <= tol; }
auto const tol
Definition: SurfXYZTest.cc:16
process_name gaushit a
T abs(T value)
static bool OpDetsSorter ( geo::OpDetGeo const &  t1,
geo::OpDetGeo const &  t2 
)
static

Definition at line 48 of file GeoObjectSorterSBND.cxx.

49 {
50  double xyz1[3] = {0.}, xyz2[3] = {0.};
51  double local[3] = {0.};
52  t1.LocalToWorld(local, xyz1);
53  t2.LocalToWorld(local, xyz2);
54 
55  if(xyz1[2] != xyz2[2])
56  return xyz1[2] < xyz2[2];
57  else if(xyz1[1] != xyz2[1])
58  return xyz1[1] < xyz2[1];
59  else
60  return xyz1[0] < xyz2[0];
61 } // OpDetsSorter
then local
bool PlaneSorter ( geo::PlaneGeo const &  p1,
geo::PlaneGeo const &  p2 
)

Definition at line 93 of file GeoObjectSorterSBND.cxx.

93  {
94 
95  /*
96  * Sort the wire planes so that the first faces the center of the TPC.
97  *
98  * This might be moved to geo::TPCGeo, which has all the information to
99  * enforce such a policy.
100  * In fact, we don't have as many here.
101  *
102  * We rely on a trick, that assumes the cathode to be located at x = 0,
103  * and we sort after |x| of the wire planes.
104  *
105  */
106  decltype(auto) p1c = p1.GetBoxCenter();
107  decltype(auto) p2c = p2.GetBoxCenter();
108 
109  /*
110  * #2 #1 #0 cathode #0 #1 #2
111  * | | | | | | |
112  * | | | | | | |
113  * | | | | | | |
114  * | | | | | | |
115  *
116  */
117  return std::abs(p1c.X()) < std::abs(p2c.X());
118 
119 } // PlaneSorter()
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
T abs(T value)
physics associatedGroupsWithLeft p1
bool TPCSorter ( geo::TPCGeo const &  t1,
geo::TPCGeo const &  t2 
)

Definition at line 64 of file GeoObjectSorterSBND.cxx.

64  {
65  //
66  // Define sort order for TPCs (in SBND case, by x).
67  //
68 
69  // The goal is to number TPCs first in the x direction so that,
70  // in the case of APA configuration, TPCs 2c and 2c+1 make up APA c.
71  // then numbering will go in y then in z direction.
72 
73  // First sort all TPCs belonging to different "z groups"
74  if (!equal(t1.CenterZ(), t2.CenterZ()))
75  return t1.CenterZ() < t2.CenterZ();
76 
77  // Within the same-z groups, sort TPCs belonging to different "y groups"
78  if (!equal(t1.CenterY(), t2.CenterY()))
79  return t1.CenterY() < t2.CenterY();
80 
81  // Within the same z and y groups, sort TPCs belonging to different
82  // "x groups";
83  // if the x is also the same, then t1 and t2 are the same TPC and strict
84  // ordering requires us to return false.
85  return t1.CenterX() < t2.CenterX();
86 
87 } // TPCSorter()
bool equal(double a, double b)
Comparison tolerance, in centimeters.
bool WireSorter ( geo::WireGeo const &  w1,
geo::WireGeo const &  w2 
)

Definition at line 123 of file GeoObjectSorterSBND.cxx.

123  {
124 
125  /*
126  * Wire comparison algorithm: compare wire centers:
127  *
128  * 1. if they have different z, sort by increasing z
129  * 2. if they have different y, sort by y:
130  * 1. increasing y if thetaZ is larger than 0
131  * 2. decreasing y if thetaZ is smaller than 0
132  * 3. if they have different x, sort by increasing x
133  * 4. otherwise, they are the same wire: return false
134  *
135  * This is strict weak ordering, as required by std::sort().
136  *
137  * The definition of "different" is that the difference is
138  * larger than the chosen tolerance.
139  *
140  * The wire plane dimensions are roughly 5 x 4 meters.
141  * The angle from z axis is +/- pi/6 for the inclined wires.
142  * The same angle for the diagonal of the plane is roughly pi/5.
143  * Therefore, the TPC is so "narrow" that there are wires connected to both
144  * sides, whose z is the same:
145  * ,------,-------,-----. ,--------------------.
146  * | ,.-' ,.-' ,.| uD |., |
147  * vA |-' ,.-' ,.-' | | `-., |
148  * | ,.-' ,.-' ,.| uC |., '-., | y
149  * vB |-' ,.-' ,.-' | | '-., '-., | ^
150  * | ,.-' ,.-' | uB |., '-., '-., | |
151  * vC |-' ,.-' | | '-., '-., '-| |
152  * | ,.-' | uA |., '-., '-., | ---+----> z
153  * vD |-' | | '-., '-., '-| |
154  * `--------------------' `------^-------^-----'
155  *
156  * This cartoon shows two views on the same APA, facing the same drift
157  * volume.
158  * We ask for wires to be sorted by increasing z coordinate.
159  * In the left view (V) the order should be vA, vB, vC, vD, that is left to
160  * right. That is also top to bottom.
161  * In the right view (U) the order should be uA, uB, uC, uD, that is left to
162  * right. In this case that is instead bottom to top.
163  * Wires can inform us of their start, end and middle. Start and end might
164  * be arbitrarily swapped and are not a reliable starting point. In the
165  * order we seek, the middle point ("center") monotonically increases with
166  * z, but because the plane is "narrow", some wires can cross it completely
167  * (vC and vD). In that case, the z coordinate of the center will be the
168  * same and it's not resolving the ambiguity. The y coordinate, on the other
169  * end, is always decreasing, and it may be relied upon for all wires.
170  * On the other view, the situation is similar, with the ambiguity on wires
171  * uC and uD resolved by y coordinate, but in this case the condition is for
172  * increasing y coordinate.
173  * The algorithm needs to figure out which is the right y direction from
174  * just the two wires being compared. The observation is that wires with
175  * angle larger than 0 with z are in planes with the leftmost disposition
176  * and need a decreasing y coordinate, while the others need an increasing
177  * y coordinate.
178  *
179  * In the case of a "short" TPC, the role of z and y would be swapped.
180  *
181  * This is stubbornly pretending there is no discontinuity in the wire plane
182  * (that is, it is ignoring the junction half way along z.
183  */
184  decltype(auto) c1 = w1.GetCenter(), c2 = w2.GetCenter();
185 
186  //
187  // we do z first, which easily resolves the vertical wires:
188  //
189  if (!equal(c1.Z(), c2.Z())) return c1.Z() < c2.Z();
190 
191  //
192  // here, z is the same: sort by y
193  //
194  if (!equal(c1.Y(), c2.Y())) {
195  // need to figure out the angle of the wires (we assume both share the same)
196  decltype(auto) e1 = w1.GetEnd();
197 
198  //
199  // We work with end - center (e1 - c1):
200  // * if its delta y and delta z have the same sign, thetaZ is positive and
201  // we need a decreasing y
202  // * otherwise, we want increasing y
203  //
204  bool const decreasingY = ((e1.Y() - c1.Y()) > 0) == ((e1.Z() - c1.Z()) > 0);
205  if (decreasingY) return c1.Y() > c2.Y(); // decreasing => first upper wires
206  else return c1.Y() < c2.Y(); // increasing => first lower wires
207  } // if same y
208 
209  //
210  // also y is the same... go check x
211  //
212  if (!equal(c1.X(), c2.X())) {
213  // mmh... here we are well beyond SBND realm.
214  throw cet::exception("GeoObjectSorterSBND")
215  << "Wires differ only for x coordinate... this is not SBND any more!\n";
216  // return c1.X() < c2.X();
217  }
218 
219  //
220  // same center, same wire; strict ordering requires us to return false
221  //
222  return false;
223 
224 } // WireSorter()
then if[["$THISISATEST"==1]]
Definition: neoSmazza.sh:95
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
bool equal(double a, double b)
Comparison tolerance, in centimeters.
physics pm2 e1

Variable Documentation

const double tol = 1e-4
static

Definition at line 29 of file GeoObjectSorterSBND.cxx.