All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
icarus::details::ROPandTPCsetBuildingAlg Class Reference

Extracts TPC sets and readout planes from a list of cryostats. More...

#include <ROPandTPCsetBuildingAlg.h>

Classes

struct  Results_t
 

Public Types

using TPCColl_t = icarus::details::TPCColl_t
 
using PlaneColl_t = icarus::details::PlaneColl_t
 
using ResultsBase_t = std::tuple< std::vector< unsigned int >, readout::TPCsetDataContainer< TPCColl_t >, readout::TPCsetDataContainer< unsigned int >, readout::ROPDataContainer< PlaneColl_t >, geo::TPCDataContainer< readout::TPCsetID >, geo::PlaneDataContainer< readout::ROPID > >
 Full group of results of the algorithm. More...
 

Public Member Functions

 ROPandTPCsetBuildingAlg ()=default
 Construction: use default configuration. More...
 
 ROPandTPCsetBuildingAlg (std::string const &logCategory)
 Construction: specify the algorithm configuration. More...
 
Results_t run (geo::GeometryData_t::CryostatList_t const &Cryostats)
 Runs the algorithm as configured from start to end. More...
 
template<typename Pred >
auto groupPlanesAndTPCs (Pred standalonePlane) -> std::vector< std::vector< PlaneColl_t >>
 
template<typename PlaneColl >
auto groupPlanesByDriftCoord (PlaneColl const &planes, double tolerance) -> std::vector< PlaneColl_t >
 

Private Member Functions

void clear ()
 Destroys all the result data members. More...
 
template<typename Pred >
std::vector< std::vector
< PlaneColl_t > > 
groupPlanesAndTPCs (Pred standalonePlane)
 Extracts composition of all readout planes. More...
 
std::vector< std::vector
< PlaneColl_t > > 
groupPlanesAndTPCs ()
 Extracts composition of all readout planes. More...
 
std::vector< std::vector
< std::vector< geo::TPCID > > > 
extractTPCsetsFromROPs (std::vector< std::vector< PlaneColl_t >> const &planes)
 Extracts all the TPC sets covered by any of the plane groups. More...
 
void fillTPCsInSet (std::vector< std::vector< std::vector< geo::TPCID >>> const &AllTPCsOnROPs)
 Extracts the final set of TPC sets. More...
 
readout::TPCsetDataContainer
< std::vector< PlaneColl_t > > 
groupPlanesIntoROPs (std::vector< std::vector< std::vector< geo::TPCID >>> const &AllTPCsOnROPs, std::vector< std::vector< PlaneColl_t >> &&AllPlanesInROPs)
 Assigns each of the readout planes to a TPC set. More...
 
void fillPlanesInROP (readout::TPCsetDataContainer< std::vector< PlaneColl_t >> const &PlanesInProtoROPs)
 Builds final readout plane information. More...
 
void fillTPCtoTPCsetMap ()
 Creates the map from each TPC to its TPC set. More...
 
void fillPlaneToROPmap ()
 Creates the map from each wire plane to its readout plane. More...
 
std::vector< PlaneColl_tsortByNormalCoordinate (std::vector< PlaneColl_t > const &planes) const
 Returns the planes sorted by decreasing normal coordinate. More...
 
void checkNormalDirection (std::vector< PlaneColl_t > const &planes) const
 Throws an exception if planes do not share the same normal direction. More...
 

Static Private Member Functions

template<typename PlaneColl >
static std::vector
< std::vector< geo::PlaneGeo
const * > > 
groupPlanesByDriftCoord (PlaneColl const &planes, double tolerance=0.1)
 Returns the planes grouped by their drift coordinate. More...
 
static std::vector< geo::TPCIDextractTPCIDs (std::vector< geo::PlaneGeo const * > const &planes)
 Returns a collection with a TPC ID for each plane in the list of planes. More...
 
static bool isROPinTPCset (std::vector< geo::TPCID > const &ROPTPCIDs, std::vector< geo::TPCID > const &TPCsetTPCIDs)
 Returns whether all the TPCs covered by a ROP are in a given TPC set. More...
 
static readout::ROPID::ROPID_t ROPnumberFromPlanes (PlaneColl_t const &planes)
 Returns ROP number matching the plane number shared by all planes. More...
 

Private Attributes

std::string fLogCategory = "ROPandTPCsetBuildingAlg"
 Category to write messages into. More...
 
geo::GeometryData_t::CryostatList_t
const * 
fCryostats = nullptr
 
unsigned int fMaxTPCsets = 0U
 Highest number of TPC sets in any cryostat. More...
 
unsigned int fMaxROPs = 0U
 Highest number of ROPs in any TPC set. More...
 
Output
std::vector< unsigned int > fTPCsetCount
 Output: number of TPC sets in each cryostat. More...
 
readout::TPCsetDataContainer
< TPCColl_t
fTPCsetTPCs
 Output: TPC's in each TPC set. More...
 
readout::TPCsetDataContainer
< unsigned int > 
fROPcount
 Output: number of readout planes in each TPC set. More...
 
readout::ROPDataContainer
< PlaneColl_t
fROPplanes
 Output: planes in each of the readout plane. More...
 
geo::TPCDataContainer
< readout::TPCsetID
fTPCtoTPCset
 Output: the TPC set each TPC belongs to. More...
 
geo::PlaneDataContainer
< readout::ROPID
fPlaneToROP
 Output: the ROP each wire plane belongs to. More...
 

Detailed Description

Extracts TPC sets and readout planes from a list of cryostats.

This algorithm parses the wire plane and TPC content of the cryostats and groups planes which share the same drift coordinate. Afterwards, it arranges them into LArSoft readout planes, defining at the same time the TPC sets that contain them.

Assignment of readout plane IDs

Readout planes closer to the cathode have lower ID.

Algorithm workflow

An example:

auto results = builder.run(Cryostats);
// planes in each ROP
= std::move(results.ROPplanes());

will run the algorithm on Cryostats and extract one of the results, the map of wire planes in each readout plane. It will use the default configuration of the algorithm, except for the message category being customized into "BuildingAlg".

Configuration

See the constructor documentation.

Definition at line 98 of file ROPandTPCsetBuildingAlg.h.

Member Typedef Documentation

Definition at line 104 of file ROPandTPCsetBuildingAlg.h.

Full group of results of the algorithm.

Definition at line 115 of file ROPandTPCsetBuildingAlg.h.

Definition at line 103 of file ROPandTPCsetBuildingAlg.h.

Constructor & Destructor Documentation

icarus::details::ROPandTPCsetBuildingAlg::ROPandTPCsetBuildingAlg ( )
default

Construction: use default configuration.

icarus::details::ROPandTPCsetBuildingAlg::ROPandTPCsetBuildingAlg ( std::string const &  logCategory)
inline

Construction: specify the algorithm configuration.

Parameters
logCategorymessage facility category to write messages into
usePlaneIDforROPIDwhether to use ROPnumberFromPlanes() algorithm

Configuration

  • logCategory (default: "ROPandTPCsetBuildingAlg"): name of the stream destination used for output messages via message facility

Definition at line 165 of file ROPandTPCsetBuildingAlg.h.

166  : fLogCategory(logCategory)
167  {}
std::string fLogCategory
Category to write messages into.

Member Function Documentation

void icarus::details::ROPandTPCsetBuildingAlg::checkNormalDirection ( std::vector< PlaneColl_t > const &  planes) const
private

Throws an exception if planes do not share the same normal direction.

Definition at line 979 of file ROPandTPCsetBuildingAlg.cxx.

980 {
981  /*
982  * Checks the normal direction of each plane in each ROP.
983  * Throws an exception when it finds two inconsistent ones.
984  */
985  if (ROPs.empty()) return;
986 
987  auto iROP = ROPs.begin();
988  assert(!iROP->empty()); // just be there already
989 
990  auto const& comp = lar::util::makeVector3DComparison(1.0e-4);
991 
992  geo::PlaneGeo const* const pFirstPlane = iROP->front();
993  auto const normDir = pFirstPlane->GetNormalDirection<geo::Vector_t>();
994 
995  for (PlaneColl_t const& ROP: ROPs) {
996  if (ROP.empty()) { // we do not accept this!
997  throw cet::exception(fLogCategory)
998  << "icarus::details::ROPandTPCsetBuildingAlg::checkNormalDirection(): "
999  "ROP must contain planes.\n"
1000  ;
1001  }
1002  for (geo::PlaneGeo const* plane: ROP) {
1003  if (comp.equal(normDir, plane->GetNormalDirection<geo::Vector_t>()))
1004  continue;
1005 
1006  throw cet::exception(fLogCategory)
1007  << "icarus::details::ROPandTPCsetBuildingAlg::checkNormalDirection(): "
1008  " plane " << plane->ID()
1009  << " has normal " << plane->GetNormalDirection<geo::Vector_t>()
1010  << ", " << normDir << " (as for " << pFirstPlane->ID()
1011  << ") expected.\n"
1012  ;
1013 
1014  } // for all planes in ROP
1015  } // for all ROPs
1016 
1017 } // icarus::details::ROPandTPCsetBuildingAlg::checkNormalDirection()
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
Vector GetNormalDirection() const
Returns the direction normal to the plane.
Definition: PlaneGeo.h:442
auto makeVector3DComparison(RealType threshold)
Creates a Vector3DComparison from a RealComparisons object.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
geo::PlaneID const & ID() const
Returns the identifier of this plane.
Definition: PlaneGeo.h:203
do i e
std::string fLogCategory
Category to write messages into.
void icarus::details::ROPandTPCsetBuildingAlg::clear ( )
private

Destroys all the result data members.

Definition at line 442 of file ROPandTPCsetBuildingAlg.cxx.

442  {
443  fTPCsetCount.clear();
444  fTPCsetTPCs.reset();
445  fROPcount.reset();
446  fROPplanes.reset();
448  fPlaneToROP.reset();
449  fMaxTPCsets = 0U;
450  fMaxROPs = 0U;
451 } // icarus::details::ROPandTPCsetBuildingAlg::clear()
void reset()
Sets all the elements to a default-constructed value_type.
readout::TPCsetDataContainer< TPCColl_t > fTPCsetTPCs
Output: TPC&#39;s in each TPC set.
unsigned int fMaxTPCsets
Highest number of TPC sets in any cryostat.
readout::TPCsetDataContainer< unsigned int > fROPcount
Output: number of readout planes in each TPC set.
std::vector< unsigned int > fTPCsetCount
Output: number of TPC sets in each cryostat.
unsigned int fMaxROPs
Highest number of ROPs in any TPC set.
geo::PlaneDataContainer< readout::ROPID > fPlaneToROP
Output: the ROP each wire plane belongs to.
readout::ROPDataContainer< PlaneColl_t > fROPplanes
Output: planes in each of the readout plane.
geo::TPCDataContainer< readout::TPCsetID > fTPCtoTPCset
Output: the TPC set each TPC belongs to.
std::vector< geo::TPCID > icarus::details::ROPandTPCsetBuildingAlg::extractTPCIDs ( std::vector< geo::PlaneGeo const * > const &  planes)
staticprivate

Returns a collection with a TPC ID for each plane in the list of planes.

Definition at line 1080 of file ROPandTPCsetBuildingAlg.cxx.

1081 {
1082  return transformCollection(planes,
1083  [](geo::PlaneGeo const* plane){ return plane->ID().asTPCID(); }
1084  );
1085 } // icarus::details::ROPandTPCsetBuildingAlg::extractTPCIDs()
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
constexpr TPCID const & asTPCID() const
Conversion to TPCID (for convenience of notation).
Definition: geo_types.h:446
geo::PlaneID const & ID() const
Returns the identifier of this plane.
Definition: PlaneGeo.h:203
std::vector< std::vector< std::vector< geo::TPCID > > > icarus::details::ROPandTPCsetBuildingAlg::extractTPCsetsFromROPs ( std::vector< std::vector< PlaneColl_t >> const &  planes)
private

Extracts all the TPC sets covered by any of the plane groups.

Parameters
groupedPlaneswire planes, grouped by cryostat.
Returns
TPC sets as sets of TPC IDs

The return value is a container that for each cryostat (first index), hosts a list of TPC sets (second index: TPC set within the cryostat), each listing its TPC (third index: runs through all TPCs). The order of the TPC sets within a cryostat is undefined. This function also fills fMaxTPCsets.

The input parameter groupedPlanes follows the same structure as the argument AllTPCsOnROPs of groupPlanesIntoROPs().

Definition at line 553 of file ROPandTPCsetBuildingAlg.cxx.

554 {
555 
556  // output: for each cryostat (first index),
557  // a list of TPC sets (second index: TPC set within the cryostat)
558  // each listing its TPC (third index: runs through all TPCs):
559  std::vector<std::vector<std::vector<geo::TPCID>>> AllTPCsOnROPs;
560 
561  //
562  // output
563  //
564  unsigned int& MaxTPCsets = fMaxTPCsets;
565 
566  MaxTPCsets = 0U;
567 
568  // extract the information one cryostat at a time
569  for (std::vector<PlaneColl_t> const& planeGroupsInCryostat: groupedPlanes) {
570 
571  //
572  // for each readout plane, collect the set of TPCs that contain its planes;
573  // keep them as IDs since they are easier to procure.
574  // Should these be sorted?
575  // (yes) because the set is the same regardless the order of TPCs => set
576  // (no) because we want to preserve the original order => vector
577  //
578  std::vector<std::vector<geo::TPCID>> TPCsOnROPs
579  = transformCollection(planeGroupsInCryostat, extractTPCIDs);
580 
581  // reduce the duplicate TPC sets and merge overlapping sets
582 // auto const iUniqueTPCend = std::unique(TPCsOnROPs.begin(), TPCsOnROPs.end());
583 // TPCsOnROPs.erase(iUniqueTPCend, TPCsOnROPs.end());
584 
585  TPCsOnROPs = icarus::details::stableMerge(TPCsOnROPs);
586 
587  //
588  // save the results of the cryostat to detector-level data collection
589  //
590  MaxTPCsets
591  = std::max(MaxTPCsets, static_cast<unsigned int>(TPCsOnROPs.size()));
592  AllTPCsOnROPs.push_back(std::move(TPCsOnROPs));
593 
594  } // for cryostats
595  mf::LogTrace("ICARUSChannelMapAlg")
596  << "The maximum number of TPC sets in any cryostat is " << MaxTPCsets;
597 
598  return AllTPCsOnROPs;
599 
600 } // icarus::details::ROPandTPCsetBuildingAlg::extractTPCsetsFromROPs()
unsigned int fMaxTPCsets
Highest number of TPC sets in any cryostat.
SetColl stableMerge(SetColl const &sets)
static std::vector< geo::TPCID > extractTPCIDs(std::vector< geo::PlaneGeo const * > const &planes)
Returns a collection with a TPC ID for each plane in the list of planes.
void icarus::details::ROPandTPCsetBuildingAlg::fillPlanesInROP ( readout::TPCsetDataContainer< std::vector< PlaneColl_t >> const &  PlanesInProtoROPs)
private

Builds final readout plane information.

Parameters
PlanesInProtoROPsplane-to-ROP assignments in each TPC set

This function fills fROPcount and fROPplanes.

It requires fMaxROPs, fTPCsetTPCs and fTPCsetCount to have been computed already.

Definition at line 757 of file ROPandTPCsetBuildingAlg.cxx.

759  {
760  //
761  // sort out the readout plane assignments into the final sets
762  // (deliver G3 and G4: see `buildReadoutPlanes()`)
763  //
764 
765  assert(!fTPCsetTPCs.empty());
766  assert(!fTPCsetCount.empty());
767  assert(fMaxROPs > 0U);
768 
769  //
770  // prepare the input
771  //
772  auto const& TPCsetTPCs = fTPCsetTPCs;
773  auto const& TPCsetCount = fTPCsetCount;
774 
775  //
776  // prepare the output
777  //
778  // this is the actual number of readout planes in each TPC set: goal (G3)
779  fROPcount.resize(TPCsetTPCs.dimSize<0U>(), TPCsetTPCs.dimSize<1U>(), 0U);
781  (TPCsetTPCs.dimSize<0U>(), TPCsetTPCs.dimSize<1U>(), fMaxROPs); // goal (G4)
782 
783  auto& ROPcount = fROPcount;
784  auto& ROPplanes = fROPplanes;
785 
786  // assign the preferred numbers according to the first TPC set;
787  // before that, sort the planes in that TPC set by local drift coordinate
788  // (possibly different from the one used for the clustering by the verse)
789  std::vector<PlaneColl_t> const sortedTPCset0
790  = sortByNormalCoordinate(PlanesInProtoROPs[{ 0, 0 }]);
791 
793  { sortedTPCset0, fLogCategory };
794 
795  // (double) loop through all TPC sets:
796  for (auto [ c, nTPCsets ]: util::enumerate(TPCsetCount)) {
797  readout::CryostatID const cryoid
798  { static_cast<readout::CryostatID::CryostatID_t>(c) };
799  for (readout::TPCsetID::TPCsetID_t s = 0; s < nTPCsets; ++s) {
800  readout::TPCsetID const tpcsetid { cryoid, s };
801 
802  // all the ROPs in this TPC set, with their wire plane content:
803  std::vector<PlaneColl_t> const& ROPs = PlanesInProtoROPs[tpcsetid];
804 
805  ROPcount[tpcsetid] = ROPs.size();
806 
807  ROPIDdispatcher.setTPCset(tpcsetid);
808 
809  for (PlaneColl_t const& planes: ROPs) {
810 
811  readout::ROPID ropid = ROPIDdispatcher.assignID(planes);
812  {
813  mf::LogTrace log(fLogCategory);
814  log << "Readout plane " << ropid << " assigned with " << planes.size()
815  << " planes:";
816  for (geo::PlaneGeo const* plane: planes)
817  log << " (" << plane->ID() << ")";
818  }
819  if (!ROPplanes[ropid].empty()) {
820  //
821  // If this happens, it may be that the geometry is not compatible
822  // with the algorithm, or just a bug.
823  // Enabling the debug stream will show which planes are assigned
824  // each time, including the two conflicting assignments.
825  //
826  throw cet::exception(fLogCategory)
827  << "Logic error: ROPID " << ropid
828  << " has already been assigned!\n";
829  }
830  ROPplanes[ropid] = std::move(planes);
831 
832  } // for all ROPs in the TPC set
833  } // for all TPC sets in cryostat
834  } // for all cryostats
835 
836 } // icarus::details::ROPandTPCsetBuildingAlg::fillPlanesInROP()
readout::TPCsetDataContainer< TPCColl_t > fTPCsetTPCs
Output: TPC&#39;s in each TPC set.
readout::TPCsetDataContainer< unsigned int > fROPcount
Output: number of readout planes in each TPC set.
unsigned short TPCsetID_t
Type for the ID number.
Definition: readout_types.h:71
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
std::vector< unsigned int > fTPCsetCount
Output: number of TPC sets in each cryostat.
std::vector< PlaneColl_t > sortByNormalCoordinate(std::vector< PlaneColl_t > const &planes) const
Returns the planes sorted by decreasing normal coordinate.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
Algorithm assigning IDs to readout planes.
Class identifying a set of planes sharing readout channels.
unsigned int fMaxROPs
Highest number of ROPs in any TPC set.
BEGIN_PROLOG Z planes
readout::ROPDataContainer< PlaneColl_t > fROPplanes
Output: planes in each of the readout plane.
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:191
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
std::string fLogCategory
Category to write messages into.
bool empty() const
Returns whether the container has no elements (false by assumptions).
bool empty(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:555
void resize(std::initializer_list< unsigned int > dims)
Prepares the container with default-constructed data.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
void icarus::details::ROPandTPCsetBuildingAlg::fillPlaneToROPmap ( )
private

Creates the map from each wire plane to its readout plane.

This function fills fPlaneToROP.

It requires fCryostats and fROPplanes to have been computed already.

Definition at line 890 of file ROPandTPCsetBuildingAlg.cxx.

890  {
891 
892  //
893  // invert the TPC sets map content
894  //
895 
896  assert(!fCryostats->empty());
897  assert(!fROPplanes.empty());
898 
899  //
900  // prepare the input
901  //
902  auto const& Cryostats = *fCryostats;
903  auto const& ROPplanes = fROPplanes;
904 
905  //
906  // output
907  //
908  auto const [ NCryostats, MaxTPCs, MaxPlanes ]
909  = geo::details::extractMaxGeometryElements<3U>(Cryostats);
910 
911  MF_LOG_TRACE(fLogCategory)
912  << "Detected " << NCryostats << " cryostats."
913  << "\nDetected at most " << MaxTPCs << " TPCs per cryostat."
914  << "\nDetected at most " << MaxPlanes << " planes per TPC."
915  ;
916  fPlaneToROP.resize(NCryostats, MaxTPCs, MaxPlanes, {});
917 
918  for (auto c
919  : util::counter<geo::CryostatID::CryostatID_t>(ROPplanes.dimSize<0>())
920  )
921  {
922  geo::CryostatID const cid { c };
923  for (auto s: util::counter<readout::TPCsetID::TPCsetID_t>(ROPplanes.dimSize<1>()))
924  {
925  readout::TPCsetID const sid { cid, s };
926  for (auto r: util::counter<readout::ROPID::ROPID_t>(ROPplanes.dimSize<2>()))
927  {
928  readout::ROPID const rid { sid, r };
929 
930  for (geo::PlaneGeo const* plane: ROPplanes[rid]) {
931  assert(plane && plane->ID());
932  fPlaneToROP[plane->ID()] = rid;
933  MF_LOG_TRACE(fLogCategory) << plane->ID() << " => " << rid;
934  } // for planes in readout plane
935 
936  } // for readout planes in TPC set
937 
938  } // for TPC sets in cryostat
939 
940  } // for cryostats
941 
942 } // icarus::details::ROPandTPCsetBuildingAlg::fillPlaneToROPmap()
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
geo::GeometryData_t::CryostatList_t const * fCryostats
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
Class identifying a set of planes sharing readout channels.
geo::PlaneDataContainer< readout::ROPID > fPlaneToROP
Output: the ROP each wire plane belongs to.
readout::ROPDataContainer< PlaneColl_t > fROPplanes
Output: planes in each of the readout plane.
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
std::string fLogCategory
Category to write messages into.
bool empty() const
Returns whether the container has no elements (false by assumptions).
esac echo uname r
void resize(std::initializer_list< unsigned int > dims)
Prepares the container with default-constructed data.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
void icarus::details::ROPandTPCsetBuildingAlg::fillTPCsInSet ( std::vector< std::vector< std::vector< geo::TPCID >>> const &  AllTPCsOnROPs)
private

Extracts the final set of TPC sets.

Parameters
AllTPCsOnROPsgroups of TPC IDs planes in a readout planes belong to

The function collects sets of TPCs from all the ROP's. It fills fTPCsetCount and fTPCsetTPCs. It requires fMaxTPCsets to have been already set. The input argument AllTPCsOnROPs is a vector with index the number of cryostat. For each cryostat, a list of readout planes is presented (unsorted and unlabelled), in each of which the list of TPCs the planes in the readout planes belong to is stored.

Definition at line 605 of file ROPandTPCsetBuildingAlg.cxx.

606 {
607  /*
608  * extract the final set of TPC sets by collecting sets of TPCs
609  * from all the ROP's
610  * (deliver G1 and G2)
611  */
612 
613  //
614  // input check
615  //
616  assert(fCryostats);
618 
619  unsigned int const MaxTPCsets = fMaxTPCsets;
620 
621  //
622  // output
623  //
624  // actual size of each TPC set: goal (G1)
625  fTPCsetCount.clear();
626  fTPCsetCount.resize(AllTPCsOnROPs.size(), 0U);
627  std::vector<unsigned int>& TPCsetCount = fTPCsetCount;
628 
629  fTPCsetTPCs.resize(AllTPCsOnROPs.size(), MaxTPCsets); // goal (G2)
631  = fTPCsetTPCs;
632 
633  //
634  // algorithm
635  //
636  for (auto&& [ c, TPCsets ]: util::enumerate(AllTPCsOnROPs)) {
637  geo::CryostatGeo const& cryo = Cryostats[c];
638  TPCsetCount[c] = TPCsets.size();
639  mf::LogTrace("ICARUSChannelMapAlg")
640  << "Cryostat " << cryo.ID() << " has " << TPCsetCount[c] << " TPC sets";
641  for (auto&& [ s, TPCIDs ]: util::enumerate(TPCsets)) {
642 
643  // convert the IDs into pointers to the TPC objects
644  readout::TPCsetID const tpcsetid
645  { cryo.ID(), static_cast<readout::TPCsetID::TPCsetID_t>(s) };
646  TPCsetTPCs[tpcsetid] = transformCollection(
647  TPCIDs, [&cryo](geo::TPCID const& tpcid){ return &(cryo.TPC(tpcid)); }
648  );
649 
650  { // local block for debug output
651  auto const& TPCs = TPCsetTPCs[tpcsetid];
652  mf::LogTrace log("ICARUSChannelMapAlg");
653  log << tpcsetid << " has " << TPCs.size() << " TPCs:";
654  for (geo::TPCGeo const* tpc: TPCs) log << " " << tpc->ID() << ";";
655  } // local block for debug output
656 
657  } // for TPC sets
658  } // for cryostats
659 } // icarus::details::ROPandTPCsetBuildingAlg::fillTPCsInSet()
readout::TPCsetDataContainer< TPCColl_t > fTPCsetTPCs
Output: TPC&#39;s in each TPC set.
Container with one element per readout TPC set.
unsigned int fMaxTPCsets
Highest number of TPC sets in any cryostat.
BEGIN_PROLOG opflashtpc1 TPCs
unsigned short TPCsetID_t
Type for the ID number.
Definition: readout_types.h:71
Geometry information for a single TPC.
Definition: TPCGeo.h:38
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
std::vector< geo::CryostatGeo > CryostatList_t
Type of list of cryostats.
Definition: GeometryData.h:34
geo::GeometryData_t::CryostatList_t const * fCryostats
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
std::vector< unsigned int > fTPCsetCount
Output: number of TPC sets in each cryostat.
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
Definition: CryostatGeo.cxx:93
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
void resize(std::initializer_list< unsigned int > dims)
Prepares the container with default-constructed data.
geo::CryostatID const & ID() const
Returns the identifier of this cryostat.
Definition: CryostatGeo.h:132
void icarus::details::ROPandTPCsetBuildingAlg::fillTPCtoTPCsetMap ( )
private

Creates the map from each TPC to its TPC set.

This function fills fTPCtoTPCset.

It requires fCryostats and fTPCsetTPCs to have been computed already.

Definition at line 840 of file ROPandTPCsetBuildingAlg.cxx.

840  {
841 
842  //
843  // invert the TPC sets map content
844  //
845 
846  assert(!fCryostats->empty());
847  assert(!fTPCsetTPCs.empty());
848 
849  //
850  // prepare the input
851  //
852  auto const& Cryostats = *fCryostats;
853  auto const& TPCsetTPCs = fTPCsetTPCs;
854 
855  //
856  // output
857  //
858  auto const [ NCryostats, MaxTPCs ]
859  = geo::details::extractMaxGeometryElements<2U>(Cryostats);
860 
861  MF_LOG_TRACE(fLogCategory)
862  << "Detected " << NCryostats << " cryostats."
863  << "\nDetected at most " << MaxTPCs << " TPCs per cryostat."
864  ;
865  fTPCtoTPCset.resize(NCryostats, MaxTPCs, {});
866 
867  for (auto c
868  : util::counter<geo::CryostatID::CryostatID_t>(TPCsetTPCs.dimSize<0>())
869  )
870  {
871  geo::CryostatID const cid { c };
872  for (auto s: util::counter<readout::TPCsetID::TPCsetID_t>(TPCsetTPCs.dimSize<1>()))
873  {
874  readout::TPCsetID const sid { cid, s };
875 
876  for (geo::TPCGeo const* TPC: TPCsetTPCs[sid]) {
877  assert(TPC && TPC->ID());
878  fTPCtoTPCset[TPC->ID()] = sid;
879  MF_LOG_TRACE(fLogCategory) << TPC->ID() << " => " << sid;
880  } // for TPCs in TPC set
881 
882  } // for TPC sets in cryostat
883 
884  } // for cryostats
885 
886 } // icarus::details::ROPandTPCsetBuildingAlg::fillTPCtoTPCsetMap()
readout::TPCsetDataContainer< TPCColl_t > fTPCsetTPCs
Output: TPC&#39;s in each TPC set.
Geometry information for a single TPC.
Definition: TPCGeo.h:38
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
geo::GeometryData_t::CryostatList_t const * fCryostats
BEGIN_PROLOG TPC
geo::TPCDataContainer< readout::TPCsetID > fTPCtoTPCset
Output: the TPC set each TPC belongs to.
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
std::string fLogCategory
Category to write messages into.
bool empty() const
Returns whether the container has no elements (false by assumptions).
void resize(std::initializer_list< unsigned int > dims)
Prepares the container with default-constructed data.
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
template<typename Pred >
std::vector<std::vector<PlaneColl_t> > icarus::details::ROPandTPCsetBuildingAlg::groupPlanesAndTPCs ( Pred  standalonePlane)
private

Extracts composition of all readout planes.

Template Parameters
Predtype of the predicate pred with one geo::PlaneGeo argument
Parameters
standalonePlanepredicate to determine if a plane is stand-alone
Returns
readout plane composition

This function returns a list: for each cryostat (first index), a list of TPC sets (second index: TPC set within the cryostat) each listing its TPC (third index: runs through all TPCs).

If standalonePlane is specified, it is a functor that returns whether its argument, a geo::PlaneGeo object, should not be grouped at all (i.e., standalonePlane(plane) returns false if the plane can be grouped to others). Each plane for which standalonePlane evaluates true has their own "group" of one plane.

auto icarus::details::ROPandTPCsetBuildingAlg::groupPlanesAndTPCs ( )
private

Extracts composition of all readout planes.

Returns
readout plane composition

This function returns a list: for each cryostat (first index), a list of TPC sets (second index: TPC set within the cryostat) each listing its TPC (third index: runs through all TPCs).

Definition at line 545 of file ROPandTPCsetBuildingAlg.cxx.

547 { return groupPlanesAndTPCs([](geo::PlaneGeo const&){ return false; }); }
std::vector< std::vector< PlaneColl_t > > groupPlanesAndTPCs()
Extracts composition of all readout planes.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
template<typename Pred >
auto icarus::details::ROPandTPCsetBuildingAlg::groupPlanesAndTPCs ( Pred  standalonePlane) -> std::vector<std::vector<PlaneColl_t>>

Definition at line 457 of file ROPandTPCsetBuildingAlg.cxx.

459 {
460  /*
461  * extract the composition of all the readout planes
462  * and the TPCs each of them spans
463  */
464 
465  //
466  // input check
467  //
468  assert(fCryostats);
470 
471  //
472  // output
473  //
474 
475  // for each cryostat (first index),
476  // a list of readout plane candidates
477  // (second index: readout plane within the cryostat)
478  // each listing its wire planes (third index: runs through all wire planes):
479  std::vector<std::vector<PlaneColl_t>> AllPlanesInROPs;
480 
481  // debug
482  auto logPlanes = [this](PlaneColl_t const& planes)
483  {
484  mf::LogTrace log(fLogCategory);
485  log << "New group of " << planes.size() << " planes:";
486  for (geo::PlaneGeo const* plane: planes)
487  log << " <" << plane->ID() << ">";
488  };
489 
490  //
491  // the algorithm
492  //
493  // extract the information one cryostat at a time
494  for (geo::CryostatGeo const& cryo: Cryostats) {
495 
496  //
497  // connect all wire planes with the same drift direction to build
498  // readout plane sets
499  //
500  std::vector<geo::PlaneGeo const*> planes;
501  for (geo::TPCGeo const& tpc: cryo.IterateTPCs()) {
502  for (geo::PlaneGeo const& plane: tpc.IteratePlanes()) {
503  planes.push_back(&plane);
504  } // for planes
505  } // for TPCs
506 
507  std::vector<PlaneColl_t> protoGroups = groupPlanesByDriftCoord(planes);
508 
509  //
510  // Are all the planes in the groups expected to be grouped?
511  // if not, add them as their own group before the group.
512  // We could have filtered out the planes not to be grouped before grouping,
513  // which makes a lot of sense but complicates the sorting afterwards.
514  //
515  std::vector<PlaneColl_t> groupedPlanes;
516  for (PlaneColl_t const& protoGroup: protoGroups) {
517  if (protoGroup.empty()) continue;
519  for (geo::PlaneGeo const* plane: protoGroup) {
520  if (standalonePlane(*plane)) {
521  groupedPlanes.push_back({ plane });
522  logPlanes(groupedPlanes.back());
523  }
524  else group.push_back(plane);
525  }
526  if (!group.empty()) {
527  groupedPlanes.push_back(std::move(group));
528  logPlanes(groupedPlanes.back());
529  }
530  } // for protogroups
531 
532  //
533  // save the results of the cryostat to detector-level data collection
534  //
535  AllPlanesInROPs.push_back(std::move(groupedPlanes));
536 
537  } // for cryostats
538 
539  return AllPlanesInROPs;
540 
541 } // icarus::details::ROPandTPCsetBuildingAlg::groupPlanesAndTPCs()
Geometry information for a single TPC.
Definition: TPCGeo.h:38
static std::vector< std::vector< geo::PlaneGeo const * > > groupPlanesByDriftCoord(PlaneColl const &planes, double tolerance=0.1)
Returns the planes grouped by their drift coordinate.
std::vector< geo::CryostatGeo > CryostatList_t
Type of list of cryostats.
Definition: GeometryData.h:34
geo::GeometryData_t::CryostatList_t const * fCryostats
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
BEGIN_PROLOG Z planes
std::string fLogCategory
Category to write messages into.
template<typename PlaneColl >
static std::vector<std::vector<geo::PlaneGeo const*> > icarus::details::ROPandTPCsetBuildingAlg::groupPlanesByDriftCoord ( PlaneColl const &  planes,
double  tolerance = 0.1 
)
staticprivate

Returns the planes grouped by their drift coordinate.

Template Parameters
PlaneColla geo::PlaneGeo collection (forward-iterable)
Parameters
planescollection of the wire planes to be grouped
tolerancemaximum distance in drift for planes in a single group
Returns
a collection of groups of (pointers to) planes

The planes in the input collection are split into groups which share the same drift coordinate. The tolerance parameter defines how different that coordinate can be for planes to be grouped together. The result is expressed as a collection of collections of planes: each element of the outer collection is a group of constant pointers to geo::PlaneGeo objects representing all the planes with the same drift coordinate. The sorting algorithm is guaranteed to be stable, i.e. if any two planes A and B have the same drift coordinate and in the planes collection A is before B, in the resulting group A will also be before B.

In the current ICARUS geometry description the drift direction is on x axis, and x is the drift coordinate.

template<typename PlaneColl >
auto icarus::details::ROPandTPCsetBuildingAlg::groupPlanesByDriftCoord ( PlaneColl const &  planes,
double  tolerance 
) -> std::vector<PlaneColl_t>

Definition at line 1023 of file ROPandTPCsetBuildingAlg.cxx.

1025 {
1026  std::map<double, PlaneColl_t> groupedByDrift;
1027 
1028  geo::Vector_t const driftDir = geo::Xaxis();
1029 
1030  /*
1031  * we can't std::sort by drift coordinate because that would break the
1032  * stability of the sorting (we are guaranteeing that if plane _A_, drift
1033  * coordinate _x_, is before plane _B_, drift coordinate _x - epsilon_,
1034  * and _epsilon_ is smaller than `tolerance`, then in the group plane _A_
1035  * should still be of plane _B_.
1036  */
1037  for (geo::PlaneGeo const* plane: planes) {
1038 
1039  double const planeD = plane->GetCenter<geo::Point_t>().Dot(driftDir);
1040  // find the group before the plane
1041 
1042  auto iGroup = groupedByDrift.lower_bound(planeD);
1043 
1044  //
1045  // if the group we found is compatible with the plane, we add it in;
1046  // the key is the upper limit of the group coordinate range
1047  //
1048  if ((iGroup != groupedByDrift.end())
1049  && (iGroup->first - planeD <= tolerance))
1050  {
1051  iGroup->second.push_back(plane);
1052  continue;
1053  }
1054  //
1055  // the plane has a drift coordinate too small to join the group we found;
1056  // or we did not find any; so we create a new group centered on this plane;
1057  // the key is the right end of the allowed range, to simplify both search
1058  // and check
1059  //
1060  groupedByDrift.emplace_hint
1061  (iGroup, planeD + tolerance / 2.0, PlaneColl_t({ plane }));
1062 
1063  } // for
1064 
1065  //
1066  // moving the groups into the result structure; they'll be sorted by
1067  // increasing nominal drift coordinate
1068  //
1069  std::vector<PlaneColl_t> groups;
1070  groups.reserve(groupedByDrift.size());
1071  for (auto&& group: groupedByDrift)
1072  groups.push_back(std::move(std::get<1U>(group)));
1073  return groups;
1074 
1075 } // icarus::details::ROPandTPCsetBuildingAlg::groupPlanesByDriftCoord()
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
auto const tolerance
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
constexpr Vector Xaxis()
Returns a x axis vector of the specified type.
Definition: geo_vectors.h:215
BEGIN_PROLOG Z planes
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
auto icarus::details::ROPandTPCsetBuildingAlg::groupPlanesIntoROPs ( std::vector< std::vector< std::vector< geo::TPCID >>> const &  AllTPCsOnROPs,
std::vector< std::vector< PlaneColl_t >> &&  AllPlanesInROPs 
)
private

Assigns each of the readout planes to a TPC set.

Parameters
AllTPCsOnROPsgroups of TPC IDs planes in a readout planes belong to
AllPlanesInROPsplanes grouped by ROP
Returns
a map of readout planes in each TPC set, each with plane content

This function fills MaxROPs. In addition, it returns the list by TPC set of the groups of sensitive planes into each readout plane in the set. It requires fTPCsetTPCs to have been computed already.

The input argument AllTPCsOnROPs is a vector with index the number of cryostat. For each cryostat, a list of readout planes is presented (unsorted and unlabelled), in each of which the list of TPCs the planes in the readout planes belong to is stored.

Definition at line 663 of file ROPandTPCsetBuildingAlg.cxx.

668 {
669  /*
670  * assigns each of the readout planes to a TPC set
671  */
672 
673  //
674  // input check
675  //
676  assert(fCryostats);
678 
679  assert(!fTPCsetTPCs.empty());
681 
682  //
683  // output
684  //
686  (TPCsetTPCs.dimSize<0U>(), TPCsetTPCs.dimSize<1U>());
687  unsigned int& MaxROPs = fMaxROPs;
688 
689 
690  unsigned int nErrors = 0U; // count errors, then bail out at the end
691  // we still don't know the maximum number of ROPs in a TPC set
692  MaxROPs = 0U;
693  for (auto&& [ c, ROPs ]: util::enumerate(AllPlanesInROPs)) {
694  // find which TPC set number each ROP belongs to;
695  // brute force approach: check the content of each TPC set until we find
696  // one that matched; then we are happy.
697  // We assume that each ROP has one plane from *each* of the TPC's in a set.
698  geo::CryostatGeo const& cryo = Cryostats[c];
699  std::vector<std::vector<geo::TPCID>> const& TPCsets = AllTPCsOnROPs[c];
700  for (std::vector<geo::PlaneGeo const*>& ROPplanes: ROPs) {
701  std::vector<geo::TPCID> const ROPTPCIDs = extractTPCIDs(ROPplanes);
702 
703  // find the TPC set
704  readout::TPCsetID tpcsetid; // destination set, invalid by default
705  for (auto&& [ s, TPCset ]: util::enumerate(TPCsets)) {
706  // here is where we assume the ROP has one plane per TOC in the TPC set;
707  // we are also gambling that the order is the same
708  if (!isROPinTPCset(ROPTPCIDs, TPCset)) continue;
709  tpcsetid = { cryo.ID(), static_cast<readout::TPCsetID::TPCsetID_t>(s) };
710  break;
711  } // for all sets
712 
713  if (!tpcsetid) { // long error message to help debugging
714  mf::LogError log(fLogCategory);
715  log << "Candidate ROP did not match any TPC set.";
716  log << "\nROP planes:";
717  for (geo::PlaneGeo const* plane: ROPplanes)
718  log << " (" << plane->ID() << ")";
719  log << "\nAvailable TPC sets (" << TPCsets.size() << "):";
720  for (auto&& [ s, TPCset ]: util::enumerate(TPCsets)) {
721  readout::TPCsetID const tpcsetid
722  { cryo.ID(), static_cast<readout::TPCsetID::TPCsetID_t>(s) };
723  log << "\n - " << tpcsetid << ", " << TPCset.size() << " TPC's:";
724  for (geo::TPCID const& tpcid: TPCset) log << " (" << tpcid << ")";
725  } // for TPC sets
726  ++nErrors;
727  continue;
728  } // if no TPC set matched
729 
730  // we have found the (first) TPC set matching the set of TPCs in ROP;
731  // we store (move) the information into the proper cell
732  auto& TPCsetROPs = PlanesInProtoROPs[tpcsetid];
733  TPCsetROPs.push_back(std::move(ROPplanes));
734  MaxROPs = std::max(MaxROPs, static_cast<unsigned int>(TPCsetROPs.size()));
735 
736  } // for TPC sets
737  } // for cryostats
738 
739  AllPlanesInROPs.clear(); // we have already depleted it anyway
740 
741  if (nErrors > 0) {
742  throw cet::exception(fLogCategory)
743  << "Encountered " << nErrors
744  << " errors while assigning TPC sets to ROPs (see error messages above)\n"
745  ;
746  } // if errors
747 
748  mf::LogTrace(fLogCategory)
749  << "The maximum number of readout planes in any TPC set is " << MaxROPs;
750 
751  return PlanesInProtoROPs;
752 
753 } // icarus::details::ROPandTPCsetBuildingAlg::groupPlanesIntoROPs()
readout::TPCsetDataContainer< TPCColl_t > fTPCsetTPCs
Output: TPC&#39;s in each TPC set.
unsigned short TPCsetID_t
Type for the ID number.
Definition: readout_types.h:71
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
std::vector< geo::CryostatGeo > CryostatList_t
Type of list of cryostats.
Definition: GeometryData.h:34
geo::GeometryData_t::CryostatList_t const * fCryostats
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
static std::vector< geo::TPCID > extractTPCIDs(std::vector< geo::PlaneGeo const * > const &planes)
Returns a collection with a TPC ID for each plane in the list of planes.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
unsigned int fMaxROPs
Highest number of ROPs in any TPC set.
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
static bool isROPinTPCset(std::vector< geo::TPCID > const &ROPTPCIDs, std::vector< geo::TPCID > const &TPCsetTPCIDs)
Returns whether all the TPCs covered by a ROP are in a given TPC set.
std::string fLogCategory
Category to write messages into.
bool empty() const
Returns whether the container has no elements (false by assumptions).
geo::CryostatID const & ID() const
Returns the identifier of this cryostat.
Definition: CryostatGeo.h:132
bool icarus::details::ROPandTPCsetBuildingAlg::isROPinTPCset ( std::vector< geo::TPCID > const &  ROPTPCIDs,
std::vector< geo::TPCID > const &  TPCsetTPCIDs 
)
staticprivate

Returns whether all the TPCs covered by a ROP are in a given TPC set.

Definition at line 1111 of file ROPandTPCsetBuildingAlg.cxx.

1114  {
1115 
1116  for (geo::TPCID const& ROPTPC: ROPTPCIDs) {
1117  bool found = false;
1118  for (geo::TPCID const& TPC: TPCsetTPCIDs) {
1119  if (TPC != ROPTPC) continue;
1120  found = true;
1121  break;
1122  } // for all TPCs in set
1123  if (found) continue;
1124  return false;
1125  } // for all TPCs in ROP
1126  return true;
1127 } // icarus::details::ROPandTPCsetBuildingAlg::isROPinTPCset()
BEGIN_PROLOG TPC
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
readout::ROPID::ROPID_t icarus::details::ROPandTPCsetBuildingAlg::ROPnumberFromPlanes ( PlaneColl_t const &  planes)
staticprivate

Returns ROP number matching the plane number shared by all planes.

Returns
a ROP number, or readout::ROPID::getInvalidID() on failure

The algorithms verifies that all elements in planes have an ID() with the same plane number (geo::PlaneID::Plane), and returns it. If the plane list is empty or if not all planes in the list have the same plane number, readout::ROPID::getInvalidID() is returned.

Definition at line 1091 of file ROPandTPCsetBuildingAlg.cxx.

1092 {
1094  for (geo::PlaneGeo const* plane: planes) {
1095  if (!plane) continue;
1096 
1097  auto const fromPlane
1098  = static_cast<readout::ROPID::ROPID_t>(plane->ID().Plane);
1099 
1100  if (r == readout::ROPID::getInvalidID())
1101  r = fromPlane;
1102  else if (r != fromPlane)
1104 
1105  } // for
1106  return r;
1107 } // icarus::details::ROPandTPCsetBuildingAlg::ROPnumberFromPlanes()
static constexpr ROPID_t getInvalidID()
Return the value of the invalid ROP ID as a r-value.
unsigned int ROPID_t
Type for the ID number.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
BEGIN_PROLOG Z planes
esac echo uname r
auto icarus::details::ROPandTPCsetBuildingAlg::run ( geo::GeometryData_t::CryostatList_t const &  Cryostats)

Runs the algorithm as configured from start to end.

Returns
the results of the algorithm

Results are in the form of a tuple that can be used to construct variables with structured binding declarations, or saved to extract the results one by one (see Results_t for the interface).

Definition at line 353 of file ROPandTPCsetBuildingAlg.cxx.

354 {
355  /*
356  * The goals:
357  * (G1) number of actual TPC sets per cryostat
358  * (G2) composition in TPC's of each TPC set
359  * (G3) number of actual ROP's in each TPC set
360  * (G4) composition in readout planes of each ROP
361  *
362  * The plan:
363  *
364  * 1. extract the composition of all the readout planes
365  * and the TPCs each of them spans
366  * 2. extract the final set of TPC sets by collecting sets of TPCs
367  * from all the ROP's
368  * 3. assign each of the readout planes to a TPC set
369  * 4. sort out the readout plane assignments into the final sets
370  */
371 
372  //
373  // input and setup
374  //
375  mf::LogDebug(fLogCategory)
376  << "Building TPC sets and readout planes from " << Cryostats.size()
377  << " cryostats";
378 
379  fCryostats = &Cryostats;
380 
381  //
382  // output
383  //
384  clear();
385 
386  //
387  // 1. extract the composition of all the readout planes
388  // and the TPCs they span
389  //
390  auto standaloneHorizontalWires = [](geo::PlaneGeo const& plane)
391  { return std::abs(plane.ThetaZ()) < 1e-3; };
392 
393  std::vector<std::vector<PlaneColl_t>> AllPlanesInROPs
394  = groupPlanesAndTPCs(standaloneHorizontalWires);
395 
396  std::vector<std::vector<std::vector<geo::TPCID>>> const AllTPCsInTPCsets
397  = extractTPCsetsFromROPs(AllPlanesInROPs);
398 
399  //
400  // 2. extract the final set of TPC sets by collecting sets of TPCs
401  // from all the ROP's
402  //
403  fillTPCsInSet(AllTPCsInTPCsets);
404 
405  //
406  // 3. assign each of the readout planes to a TPC set
407  //
409  = groupPlanesIntoROPs(AllTPCsInTPCsets, std::move(AllPlanesInROPs));
410 
411  //
412  // 4. sort out the readout plane assignments into the final sets
413  //
414  fillPlanesInROP(PlanesInProtoROPs);
415 
416  //
417  // 5. invert the maps
418  //
421 
422  //
423  // output
424  //
425  assert(!fTPCsetCount.empty());
426  assert(!fTPCsetTPCs .empty());
427  assert(!fROPcount .empty());
428  assert(!fTPCtoTPCset.empty());
429  assert(!fPlaneToROP .empty());
430  return ResultsBase_t{
431  std::move(fTPCsetCount),
432  std::move(fTPCsetTPCs ),
433  std::move(fROPcount ),
434  std::move(fROPplanes ),
435  std::move(fTPCtoTPCset),
436  std::move(fPlaneToROP )
437  };
438 } // icarus::details::ROPandTPCsetBuildingAlg::run()
readout::TPCsetDataContainer< TPCColl_t > fTPCsetTPCs
Output: TPC&#39;s in each TPC set.
void fillTPCsInSet(std::vector< std::vector< std::vector< geo::TPCID >>> const &AllTPCsOnROPs)
Extracts the final set of TPC sets.
Container with one element per readout TPC set.
readout::TPCsetDataContainer< unsigned int > fROPcount
Output: number of readout planes in each TPC set.
geo::GeometryData_t::CryostatList_t const * fCryostats
std::vector< std::vector< PlaneColl_t > > groupPlanesAndTPCs()
Extracts composition of all readout planes.
void fillTPCtoTPCsetMap()
Creates the map from each TPC to its TPC set.
std::vector< unsigned int > fTPCsetCount
Output: number of TPC sets in each cryostat.
T abs(T value)
void fillPlanesInROP(readout::TPCsetDataContainer< std::vector< PlaneColl_t >> const &PlanesInProtoROPs)
Builds final readout plane information.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
std::vector< std::vector< std::vector< geo::TPCID > > > extractTPCsetsFromROPs(std::vector< std::vector< PlaneColl_t >> const &planes)
Extracts all the TPC sets covered by any of the plane groups.
readout::TPCsetDataContainer< std::vector< PlaneColl_t > > groupPlanesIntoROPs(std::vector< std::vector< std::vector< geo::TPCID >>> const &AllTPCsOnROPs, std::vector< std::vector< PlaneColl_t >> &&AllPlanesInROPs)
Assigns each of the readout planes to a TPC set.
std::tuple< std::vector< unsigned int >, readout::TPCsetDataContainer< TPCColl_t >, readout::TPCsetDataContainer< unsigned int >, readout::ROPDataContainer< PlaneColl_t >, geo::TPCDataContainer< readout::TPCsetID >, geo::PlaneDataContainer< readout::ROPID > > ResultsBase_t
Full group of results of the algorithm.
geo::PlaneDataContainer< readout::ROPID > fPlaneToROP
Output: the ROP each wire plane belongs to.
readout::ROPDataContainer< PlaneColl_t > fROPplanes
Output: planes in each of the readout plane.
geo::TPCDataContainer< readout::TPCsetID > fTPCtoTPCset
Output: the TPC set each TPC belongs to.
void fillPlaneToROPmap()
Creates the map from each wire plane to its readout plane.
do i e
std::string fLogCategory
Category to write messages into.
void clear()
Destroys all the result data members.
bool empty() const
Returns whether the container has no elements (false by assumptions).
bool empty(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:555
auto icarus::details::ROPandTPCsetBuildingAlg::sortByNormalCoordinate ( std::vector< PlaneColl_t > const &  planes) const
private

Returns the planes sorted by decreasing normal coordinate.

Definition at line 947 of file ROPandTPCsetBuildingAlg.cxx.

948 {
949  /*
950  * The `ROPs` are sorted in order of decreasing normal plane coordinate.
951  *
952  * 1. consistency of normal direction is first verified
953  * 2. the ROPs are sorted so that the center of the first sorted plane,
954  * projected on the normal direction of a reference plane, is the largest
955  * (plane closest to the cathode); sorting is stable.
956  *
957  */
958  assert(!ROPs.empty()); // don't waste our time!
959 
960  checkNormalDirection(ROPs); // throws on error
961 
962  geo::PlaneGeo const* const pRefPlane = ROPs.front().front();
963  auto sortedROPs { ROPs };
964  std::stable_sort(sortedROPs.begin(), sortedROPs.end(),
965  [pRefPlane](PlaneColl_t const& A, PlaneColl_t const& B) -> bool
966  {
967  return
968  pRefPlane->DistanceFromPlane(A.front()->GetCenter<geo::Point_t>())
969  > pRefPlane->DistanceFromPlane(B.front()->GetCenter<geo::Point_t>());
970  }
971  );
972 
973  return sortedROPs;
974 } // icarus::details::ROPandTPCsetBuildingAlg::sortByNormalCoordinate()
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
double DistanceFromPlane(geo::Point_t const &point) const
Returns the distance of the specified point from the wire plane.
Definition: PlaneGeo.h:621
float A
Definition: dedx.py:137
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
void checkNormalDirection(std::vector< PlaneColl_t > const &planes) const
Throws an exception if planes do not share the same normal direction.

Member Data Documentation

geo::GeometryData_t::CryostatList_t const* icarus::details::ROPandTPCsetBuildingAlg::fCryostats = nullptr
private

Definition at line 192 of file ROPandTPCsetBuildingAlg.h.

std::string icarus::details::ROPandTPCsetBuildingAlg::fLogCategory = "ROPandTPCsetBuildingAlg"
private

Category to write messages into.

Definition at line 187 of file ROPandTPCsetBuildingAlg.h.

unsigned int icarus::details::ROPandTPCsetBuildingAlg::fMaxROPs = 0U
private

Highest number of ROPs in any TPC set.

Definition at line 223 of file ROPandTPCsetBuildingAlg.h.

unsigned int icarus::details::ROPandTPCsetBuildingAlg::fMaxTPCsets = 0U
private

Highest number of TPC sets in any cryostat.

Definition at line 220 of file ROPandTPCsetBuildingAlg.h.

geo::PlaneDataContainer<readout::ROPID> icarus::details::ROPandTPCsetBuildingAlg::fPlaneToROP
private

Output: the ROP each wire plane belongs to.

Definition at line 214 of file ROPandTPCsetBuildingAlg.h.

readout::TPCsetDataContainer<unsigned int> icarus::details::ROPandTPCsetBuildingAlg::fROPcount
private

Output: number of readout planes in each TPC set.

Definition at line 205 of file ROPandTPCsetBuildingAlg.h.

readout::ROPDataContainer<PlaneColl_t> icarus::details::ROPandTPCsetBuildingAlg::fROPplanes
private

Output: planes in each of the readout plane.

Definition at line 208 of file ROPandTPCsetBuildingAlg.h.

std::vector<unsigned int> icarus::details::ROPandTPCsetBuildingAlg::fTPCsetCount
private

Output: number of TPC sets in each cryostat.

Definition at line 199 of file ROPandTPCsetBuildingAlg.h.

readout::TPCsetDataContainer<TPCColl_t> icarus::details::ROPandTPCsetBuildingAlg::fTPCsetTPCs
private

Output: TPC's in each TPC set.

Definition at line 202 of file ROPandTPCsetBuildingAlg.h.

geo::TPCDataContainer<readout::TPCsetID> icarus::details::ROPandTPCsetBuildingAlg::fTPCtoTPCset
private

Output: the TPC set each TPC belongs to.

Definition at line 211 of file ROPandTPCsetBuildingAlg.h.


The documentation for this class was generated from the following files: