19 #include "cetlib_except/exception.h" 23 #include "TGeoMatrix.h" 59 TGeoVolume *vc = node.GetVolume();
61 throw cet::exception(
"Geometry") <<
"cannot find detector outline volume - bail ungracefully\n";
67 int nd = vc->GetNdaughters();
68 TGeoNode
const* pActiveVolNode =
nullptr;
69 for(
int i = 0; i < nd; ++i){
70 if(strncmp(vc->GetNode(i)->GetName(),
"volTPCActive", 12) != 0)
continue;
72 pActiveVolNode = vc->GetNode(i);
73 TGeoVolume *vca = pActiveVolNode->GetVolume();
82 <<
"\ndetector active volume is " <<
fActiveVolume->GetName();
110 double Rxx, Rxy, Rxz, Ryx, Ryy, Ryz, Rzx, Rzy, Rzz;
112 (Rxx, Rxy, Rxz, Ryx, Ryy, Ryz, Rzx, Rzy, Rzz);
172 <<
"DetectDriftDirection(): no planes in TPC " <<
std::string(
ID())
179 auto const driftVector = PlaneCenter - TPCcenter;
185 return (driftVector.X() > 0)? +1: -1;
190 return (driftVector.Y() > 0)? +2: -2;
194 return (driftVector.Z() > 0)? +3: -3;
227 for (
unsigned int plane = 0; plane <
Nplanes(); ++plane) {
246 std::ostringstream sstr;
256 throw cet::exception(
"PlaneOutOfRange") <<
"Request for non-existant plane " << iplane <<
"\n";
268 <<
"TPCGeo[" << ((
void*)
this) <<
"]::Plane(): no plane for view #" 269 << (size_t) view <<
"\n";
283 auto smallestPlane = iPlane;
284 double smallestSurface = smallestPlane->Width() * smallestPlane->Depth();
285 while (++iPlane != pend) {
286 double const surface = iPlane->Width() * iPlane->Depth();
287 if (surface > smallestSurface)
continue;
288 smallestSurface = surface;
289 smallestPlane = iPlane;
291 return *smallestPlane;
298 unsigned int maxWires = 0;
300 unsigned int maxWiresInPlane = plane.Nwires();
301 if (maxWiresInPlane > maxWires) maxWires = maxWiresInPlane;
314 std::set<geo::View_t>
views;
340 geo::Point_t cathodeCenter = GetActiveVolumeCenter<geo::Point_t>();
356 cathodeCenter.SetZ(cathodeCenter.Z() +
ActiveLength() / 2.0);
359 cathodeCenter.SetZ(cathodeCenter.Z() -
ActiveLength() / 2.0);
365 <<
"CathodeCenter(): Can't determine the cathode plane (code=" 368 return cathodeCenter;
376 return { activeBox.CenterX(), activeBox.CenterY(), activeBox.MinZ() };
389 unsigned int p2)
const 405 switch (driftDirCode) {
438 <<
"Unable to detect drift direction (result: " << driftDirCode
477 auto const& activeCenter = GetActiveVolumeCenter<geo::Point_t>();
518 : fPlane0Pitch[
p-1] +
std::abs(center.X()-refPlaneCenter.X())
549 auto by_distance = [&TPCcenter, &driftAxis](
auto const&
a,
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.
Utilities to extend the interface of geometry vectors.
Vector DriftDir() const
Returns the direction of the drift (vector pointing toward the planes).
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
void UpdatePlaneCache()
Updates plane cached information.
void PrintTPCInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this TPC.
constexpr auto dot(Vector const &a, Vector const &b)
Return cross product of two vectors.
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.
Point GetCathodeCenter() const
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.
Point GetBoxCenter() const
Returns the centre of the box representing the plane.
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.
void sort_all(RandCont &)
TPCGeo(TGeoNode const &node, geo::TransformationMatrix &&trans, PlaneCollection_t &&planes)
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].
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.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
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.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
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
The data type to uniquely identify a TPC.
unsigned int MaxWires() const
Returns the largest number of wires among the planes in this TPC.
double Plane0Pitch(unsigned int p) const
void SortPlanes(std::vector< geo::PlaneGeo > &) const
Sorts (in place) the specified PlaneGeo objects by drift distance.
double ActiveLength() const
Length (associated with z coordinate) of active TPC volume [cm].
std::vector< std::vector< double > > fPlaneLocation
xyz locations of planes in the TPC.
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.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
std::string TPCInfo(std::string indent="", unsigned int verbosity=1) const
Returns a string with information about this TPC.
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.
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.
LArSoft geometry interface.
geo::Point_t fActiveCenter
Center of the active volume, in world coordinates [cm].
const double * PlaneLocation(unsigned int p) const
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.
Point GetCenter() const
Returns the center of the TPC volume in world coordinates [cm].