17 #include "cetlib/container_algorithms.h" 18 #include "cetlib_except/exception.h" 23 #include "TGeoMatrix.h" 42 , fTrans(
std::move(trans))
43 , fPlanes(
std::move(planes))
55 TGeoVolume* vc = node.GetVolume();
58 <<
"cannot find detector outline volume - bail ungracefully\n";
64 int nd = vc->GetNdaughters();
65 TGeoNode
const* pActiveVolNode =
nullptr;
66 for (
int i = 0; i < nd; ++i) {
67 if (strncmp(vc->GetNode(i)->GetName(),
"volTPCActive", 12) != 0)
continue;
69 pActiveVolNode = vc->GetNode(i);
70 TGeoVolume* vca = pActiveVolNode->GetVolume();
79 <<
"\ndetector active volume is " <<
fActiveVolume->GetName();
104 double Rxx, Rxy, Rxz, Ryx, Ryy, Ryz, Rzx, Rzy, Rzz;
105 fTrans.
Matrix().Rotation().GetComponents(Rxx, Rxy, Rxz, Ryx, Ryy, Ryz, Rzx, Rzy, Rzz);
165 <<
"DetectDriftDirection(): no planes in TPC " << std::string(
ID()) <<
"\n";
171 auto const driftVector = PlaneCenter - TPCcenter;
176 return (driftVector.X() > 0) ? +1 : -1;
180 return (driftVector.Y() > 0) ? +2 : -2;
184 return (driftVector.Z() > 0) ? +3 : -3;
201 for (
size_t p = 0; p < this->
Nplanes(); ++p)
204 for (
size_t p = 0; p <
fPlanes.size(); ++p)
217 for (
unsigned int plane = 0; plane <
Nplanes(); ++plane) {
234 std::ostringstream sstr;
245 <<
"Request for non-existant plane " << iplane <<
"\n";
257 <<
"TPCGeo[" << ((
void*)
this) <<
"]::Plane(): no plane for view #" << (size_t)view <<
"\n";
271 auto smallestPlane = iPlane;
272 double smallestSurface = smallestPlane->Width() * smallestPlane->Depth();
273 while (++iPlane != pend) {
274 double const surface = iPlane->Width() * iPlane->Depth();
275 if (surface > smallestSurface)
continue;
276 smallestSurface = surface;
277 smallestPlane = iPlane;
279 return *smallestPlane;
286 unsigned int maxWires = 0;
288 unsigned int maxWiresInPlane = plane.Nwires();
289 if (maxWiresInPlane > maxWires) maxWires = maxWiresInPlane;
303 std::set<geo::View_t> views;
304 std::transform(
fPlanes.cbegin(),
306 std::inserter(views, views.begin()),
337 case +1: cathodeCenter.SetX(cathodeCenter.X() -
ActiveHalfWidth());
break;
340 case -3: cathodeCenter.SetZ(cathodeCenter.Z() +
ActiveLength() / 2.0);
break;
341 case +3: cathodeCenter.SetZ(cathodeCenter.Z() -
ActiveLength() / 2.0);
break;
349 return cathodeCenter;
357 return {activeBox.CenterX(), activeBox.CenterY(), activeBox.MinZ()};
378 switch (driftDirCode) {
410 mf::LogError(
"TPCGeo") <<
"Unable to detect drift direction (result: " << driftDirCode
469 for (
size_t p = 0; p <
Nplanes(); ++p)
485 for (
size_t p = 0; p <
Nplanes(); ++p) {
491 refPlaneCenter = center;
517 auto by_distance = [&TPCcenter, &driftAxis](
auto const& a,
auto const& b) {
521 cet::sort_all(planes, by_distance);
geo::TPCID const & ID() const
Returns the identifier of this TPC.
void InitTPCBoundaries()
Recomputes the TPC boundary.
geo::Point_t GetCathodeCenterImpl() const
void round01(Vector &v, Scalar tol)
Returns a vector with all components rounded if close to 0, -1 or +1.
Point_t GetCathodeCenter() const
geo::BoxBoundedGeo fActiveBox
Box of the active volume.
std::vector< double > fPlane0Pitch
Pitch between planes.
double PlanePitch(unsigned int p1=0, unsigned int p2=1) const
Returns the center of the TPC volume in world coordinates [cm].
void UpdatePlaneCache()
Updates plane cached information.
void PrintTPCInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this TPC.
Drift direction is unknown.
std::vector< geo::PlaneGeo > PlaneCollection_t
double fLength
Length of total volume.
geo::Point3DBase_t< TPCGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML TPC frame.
double ComputeDriftDistance() const
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
double ActiveHalfHeight() const
Half height (associated with y coordinate) of active TPC volume [cm].
Drift towards positive values.
unsigned int Nplanes() const
Number of planes in this tpc.
double fActiveHalfWidth
Half width of active volume.
geo::Point_t GetFrontFaceCenterImpl() const
unsigned int PlaneID_t
Type for the ID number.
The data type to uniquely identify a Plane.
constexpr Vector Yaxis()
Returns a y axis vector of the specified type.
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
constexpr auto abs(T v)
Returns the absolute value of the argument.
PlaneCollection_t fPlanes
List of planes in this plane.
geo::BoxBoundedGeo const & ActiveBoundingBox() const
Returns the box of the active volume of this TPC.
std::vector< geo::PlaneID::PlaneID_t > fViewToPlaneNumber
Index of the plane for each view (InvalidID if none).
double HalfLength() const
Length is associated with z coordinate [cm].
void UpdateAfterSorting(geo::TPCID tpcid)
Performs all updates after cryostat has sorted TPCs.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Drift towards negative X values.
void SortSubVolumes(geo::GeoObjectSorter const &sorter)
Apply sorting to the PlaneGeo objects.
geo::Vector_t fHeightDir
Direction height refers to.
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local TPC frame to world frame.
geo::TPCID fID
ID of this TPC.
Class for approximate comparisons.
unsigned int fillCoords(Coords &dest, Vector const &src)
Fills a coordinate array with the coordinates of a vector.
TPCGeo(TGeoNode const &node, geo::TransformationMatrix &&trans, PlaneCollection_t &&planes)
Point_t GetCenter() const
Returns the center of the TPC volume in world coordinates [cm].
View_t View() const
Which coordinate does this plane measure.
geo::Vector_t fWidthDir
Direction width refers to.
double ActiveHalfLength() const
Length (associated with z coordinate) of active TPC volume [cm].
Point_t GetBoxCenter() const
Returns the centre of the box representing the plane.
double fHalfWidth
Half width of total volume.
auto makeVector3DComparison(RealType threshold)
Creates a Vector3DComparison from a RealComparisons object.
geo::PlaneGeo const & SmallestPlane() const
Returns the wire plane with the smallest surface.
double fActiveLength
Length of active volume.
PlaneCollection_t const & ElementIteratorBox
Type returned by IterateElements().
double ActiveHalfWidth() const
Half width (associated with x coordinate) of active TPC volume [cm].
ElementIteratorBox IterateElements() const
Returns an object for iterating through all geo::PlaneGeo.
std::string indent(std::size_t const i)
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Utilities to extend the interface of geometry vectors.
void UpdatePlaneViewCache()
Refills the plane vs. view cache of the TPC.
constexpr Vector Xaxis()
Returns a x axis vector of the specified type.
decltype(auto) makeTransformationMatrix(Trans &&trans)
Converts a transformation matrix into a geo::TransformationMatrix.
TGeoVolume * fTotalVolume
Total volume of TPC, called volTPC in GDML file.
DriftDirection_t fDriftDirection
Direction of the electron drift in the TPC.
double WirePitch(unsigned plane=0) const
Returns the center of the TPC volume in world coordinates [cm].
The data type to uniquely identify a TPC.
constexpr auto dot(Vector const &a, OtherVector const &b)
Return cross product of two vectors.
unsigned int MaxWires() const
Returns the largest number of wires among the planes in this TPC.
double Plane0Pitch(unsigned int p) const
Returns the center of the TPC volume in world coordinates [cm].
void SortPlanes(std::vector< geo::PlaneGeo > &) const
Sorts (in place) the specified PlaneGeo objects by drift distance.
std::vector< std::vector< double > > fPlaneLocation
xyz locations of planes in the TPC.
Point_t GetActiveVolumeCenter() const
Returns the center of the TPC active volume in world coordinates [cm].
double ActiveLength() const
Length (associated with z coordinate) of active TPC volume [cm].
Encapsulate the geometry of a wire.
auto Xcoord(Vector &v)
Returns an object to manage the coordinate X of the vector v.
double HalfHeight() const
Height is associated with y coordinate [cm].
constexpr Vector Zaxis()
Returns a z axis vector of the specified type.
std::string TPCInfo(std::string indent="", unsigned int verbosity=1) const
Returns a string with information about this TPC.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
TGeoVolume * fActiveVolume
Active volume of LAr, called volTPCActive in GDML file.
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
Drift towards positive X values.
Encapsulate the construction of a single detector plane.
double DistanceFromPlane(geo::Point_t const &point) const
Returns the distance of the specified point from the wire plane.
PlaneGeo const * PlanePtr(unsigned int iplane) const
Returns the plane number iplane from this TPC.
void SetBoundaries(Coord_t x_min, Coord_t x_max, Coord_t y_min, Coord_t y_max, Coord_t z_min, Coord_t z_max)
Sets the boundaries in world coordinates as specified.
short int DetectDriftDirection() const
Returns the expected drift direction based on geometry.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
geo::Vector_t fLengthDir
Direction length refers to.
LocalTransformation_t fTrans
TPC-to-world transformation.
void ResetDriftDirection()
Recomputes the drift direction; needs planes to have been initialised.
Drift towards negative values.
geo::Vector_t fDriftDir
Direction electrons drift along.
std::set< geo::View_t > Views() const
Returns a set of all views covered in this TPC.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
static constexpr PlaneID_t InvalidID
Special code for an invalid ID.
Vector normalize(Vector const &v)
Returns a vector parallel to v and with norm 1.
Vector_t DriftDir() const
Returns the direction of the drift (vector pointing toward the planes).
Namespace collecting geometry-related classes utilities.
geo::Point_t fActiveCenter
Center of the active volume, in world coordinates [cm].
double fHalfHeight
Half height of total volume.
double HalfWidth() const
Width is associated with x coordinate [cm].
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
cet::coded_exception< error, detail::translate > exception
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Encapsulate the construction of a single detector plane.
double fActiveHalfHeight
Half height of active volume.