27 #include "cetlib_except/exception.h" 70 <<
"Initializing ColdBoxChannelMapAlg channel mapping algorithm.";
76 <<
"ColdBoxChannelMapAlg::Initialize() completed.";
102 std::vector<geo::WireID> AllSegments;
107 ChannelToWireMap::ChannelsInROPStruct
const* channelInfo
111 <<
"geo::ColdBoxChannelMapAlg::ChannelToWire(" << channel
112 <<
"): invalid channel requested (must be lower than " 124 AllSegments.reserve(planes.size());
125 for (
auto const pid: planes) {
130 if (!channelRange.
contains(channel))
continue;
131 AllSegments.emplace_back
132 (
pid, static_cast<geo::WireID::WireID_t>(channel - channelRange.
begin()));
152 ChannelToWireMap::ChannelsInROPStruct
const* ROPinfo
167 e <<
"ColdBoxChannelMapAlg does not support `WireCoordinate()` call." 168 "\nPlease update calling software to use geo::PlaneGeo::WireCoordinate()`:" 186 e <<
"ColdBoxChannelMapAlg does not support `NearestWireID()` call." 187 "\nPlease update calling software to use geo::PlaneGeo::NearestWireID()`:" 212 e <<
"ColdBoxChannelMapAlg does not support `PlaneIDs()` call." 213 "\nPlease update calling software to use geo::GeometryCore::IteratePlanes()`" 262 std::vector<geo::TPCID> TPCs;
263 if (!tpcsetid)
return TPCs;
273 if (!tpcsetid)
return {};
276 return TPClist.empty()?
geo::TPCID{}: TPClist.front();
326 std::vector<geo::PlaneID> Planes;
327 if (!ropid)
return Planes;
336 std::vector<geo::TPCID> TPCs;
337 if (!ropid)
return TPCs;
339 auto const& PlaneList =
ROPplanes(ropid);
340 TPCs.reserve(PlaneList.size());
341 for(
auto const pid : PlaneList ){
342 TPCs.push_back(
pid );
355 ChannelToWireMap::ChannelsInROPStruct
const*
info 367 ChannelToWireMap::ChannelsInROPStruct
const*
info 377 if (!ropid)
return {};
401 assert(!Cryostats.empty());
408 std::array<unsigned int, 3U> maxSizes
409 = geo::details::extractMaxGeometryElements<3U>(Cryostats);
411 fPlaneInfo.resize(maxSizes[0U], maxSizes[1U], maxSizes[2U]);
432 log <<
"ROP: " << rid
436 assert(!plane_ids.empty());
437 log <<
" (" << plane_ids.size() <<
" planes):";
439 std::vector<geo::PlaneGeo const*> planes;
440 planes.reserve( plane_ids.size() );
441 for(
auto const pid : plane_ids ){
442 planes.push_back( cryo.TPC(
pid ).PlanePtr(
pid ) );
451 nextChannel += (*iPlane)->Nwires();
454 log <<
" [" << (*iPlane)->ID() <<
"] " 456 <<
" -- " <<
fPlaneInfo[(*iPlane)->ID()].lastChannel() <<
";";
460 while (++iPlane != pend) {
486 auto const nWires = plane.
Nwires();
488 (r == 0)?((nextChannel - 1) - lastMatchedWireID.
Wire):nextChannel;
490 nextChannel = firstChannel + nWires;
492 fPlaneInfo[plane.
ID()] = { { firstChannel, nextChannel }, rid };
493 log <<
" [" << plane.
ID() <<
"] " 502 unsigned int const nChannels = nextChannel - firstROPchannel;
505 <<
" => " << nChannels <<
" channels starting at " << firstROPchannel;
524 auto const [ NCryostats, MaxTPCs, MaxPlanes ]
525 = geo::details::extractMaxGeometryElements<3U>(Cryostats);
531 if( Cryostats.size() > 1 ){
533 <<
"geo::ColdBoxChannelMapAlg::buildReadoutPlanes " << Cryostats.size()
534 <<
": more than one cryostat is currently not supported\n";
537 if( Cryostats[0].NTPC() != 4 ){
539 <<
"geo::ColdBoxChannelMapAlg::buildReadoutPlanes " << Cryostats[0].NTPC()
540 <<
": more than four TPCs is currently not supported\n";
544 auto cryo = Cryostats[0];
550 std::vector<std::vector<const geo::TPCGeo*>> AllTPCsInTPCsets( MaxTPCsets );
552 AllTPCsInTPCsets[0] = {cryo.TPCPtr(0), cryo.TPCPtr(2)};
553 AllTPCsInTPCsets[1] = {cryo.TPCPtr(1), cryo.TPCPtr(3)};
560 std::vector<geo::TPCID> TPCs;
561 TPCs.reserve(TPClist.size());
562 std::transform(TPClist.begin(), TPClist.end(), std::back_inserter(TPCs),
582 ROPcount[tpcsetid] = nROP;
584 auto TPCs = AllTPCsInTPCsets[
s];
585 for(
unsigned r = 0;
r<nROP;++
r ){
590 planes.push_back(
TPC->Plane(
r).ID() );
594 log <<
"Readout plane " << ropid <<
" assigned with " << planes.size()
596 for (
auto const plane: planes)
597 log <<
" (" << plane <<
")";
599 if(!ROPplanes[ropid].
empty()) {
607 <<
"Logic error: ROPID " << ropid
608 <<
" has already been assigned!\n";
611 ROPplanes[ ropid ] =
std::move( planes );
619 TPCtoTPCset.
resize( NCryostats, MaxTPCs, {});
621 : util::counter<geo::CryostatID::CryostatID_t>(TPCsetTPCs.
dimSize<0>())){
624 for (
auto s: util::counter<readout::TPCsetID::TPCsetID_t>(TPCsetTPCs.
dimSize<1>()))
627 for (
auto const TPCid: TPCsetTPCs[sid]) {
628 TPCtoTPCset[TPCid] = sid;
636 PlaneToROP.
resize( NCryostats, MaxTPCs, MaxPlanes, {} );
638 : util::counter<geo::CryostatID::CryostatID_t>(ROPplanes.
dimSize<0>())
642 for (
auto s: util::counter<readout::TPCsetID::TPCsetID_t>(ROPplanes.
dimSize<1>()))
645 for (
auto r: util::counter<readout::ROPID::ROPID_t>(ROPplanes.
dimSize<2>()))
648 for (
auto const plane: ROPplanes[rid]) {
650 PlaneToROP[plane] = rid;
690 if (
auto const planeNo = planes.front().Plane; planeNo < PlaneTypes.size())
691 return PlaneTypes[planeNo];
701 ChannelToWireMap::ChannelsInROPStruct
const* channelInfo
geo::TPCID const & ID() const
Returns the identifier of this TPC.
virtual geo::TPCID FirstTPCinTPCset(readout::TPCsetID const &tpcsetid) const override
Returns the ID of the first TPC belonging to the specified TPC set.
readout::TPCsetDataContainer< TPCColl_t > const & TPCsetTPCs() const
All geo::TPCGeo objects in each TPC set.
virtual unsigned int NROPs(readout::TPCsetID const &tpcsetid) const override
Returns the total number of readout planes in the specified TPC set.
virtual raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const override
Returns the ID of the first channel in the specified readout plane.
void addROP(readout::ROPID const &rid, raw::ChannelID_t firstROPchannel, unsigned int nChannels)
void clear()
Frees the memory and leaves the object unusable until next set().
unsigned int nChannels() const
Returns the number of mapped channels.
virtual void Uninitialize() override
Frees the resources of this algorithm.
Encapsulate the construction of a single cyostat.
Definition of util::enumerate().
readout::ROPID ropid
ID of the ROP we cover.
void clear()
Resets the data of the map to like just constructed.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
PlaneType_t findPlaneType(readout::ROPID const &ropid) const
Returns the "type" of readout plane.
virtual std::vector< geo::TPCID > ROPtoTPCs(readout::ROPID const &ropid) const override
Returns a list of ID of TPCs the specified ROP spans.
unsigned int ROPID_t
Type for the ID number.
virtual raw::ChannelID_t PlaneWireToChannel(geo::WireID const &wireID) const override
Returns the channel ID a wire is connected to.
unsigned short TPCsetID_t
Type for the ID number.
The data type to uniquely identify a Plane.
Geometry information for a single TPC.
Class identifying a set of TPC sharing readout channels.
raw::ChannelID_t firstChannel
std::vector< unsigned int > const & TPCsetCount() const
Returns the number of TPC sets in each cryostat.
std::vector< geo::CryostatGeo > CryostatList_t
Type of list of cryostats.
CryostatID_t Cryostat
Index of cryostat.
virtual std::set< geo::PlaneID > const & PlaneIDs() const override
Returns a list of the plane IDs in the whole detector.
virtual readout::ROPID WirePlaneToROP(geo::PlaneID const &planeid) const override
Returns the ID of the ROP planeid belongs to, or invalid if none.
void resize(unsigned int nCryo, unsigned int nTPCsets)
Prepares the container with default-constructed data.
static constexpr PlaneType_t kUnknownType
Identifier for unknown plane type.
virtual bool HasTPCset(readout::TPCsetID const &tpcsetid) const override
WireID_t Wire
Index of the wire within its plane.
geo::PlaneDataContainer< PlaneInfo_t > fPlaneInfo
Range of channels covered by each of the wire planes.
CryostatList_t cryostats
The detector cryostats.
static std::string PlaneTypeName(PlaneType_t planeType)
Returns the name of the specified plane type.
Container with one element per geometry wire plane.
Geometry information for a single cryostat.
unsigned int NCryostats() const
virtual geo::PlaneID FirstWirePlaneInROP(readout::ROPID const &ropid) const override
Returns the ID of the first plane belonging to the specified ROP.
Functions to help debugging by instrumenting code.
void resize(unsigned int nCryo, unsigned int nTPCs)
Prepares the container with default-constructed data.
ColdBoxChannelMapAlg(fhicl::ParameterSet const &p)
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
virtual std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t channel) const override
Returns a collection of ID of wires connected to the channel.
constexpr bool contains(raw::ChannelID_t channel) const
Returns whether this range includes the specified channel.
void resize(unsigned int nCryo, unsigned int nTPCsets, unsigned int nROPs)
Prepares the container with default-constructed data.
virtual unsigned int MaxROPs() const override
Returns the largest number of ROPs a TPC set in the detector has.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
geo::dune::vd::ChannelToWireMap fChannelToWireMap
Mapping of channels and ROP's.
virtual readout::ROPID ChannelToROP(raw::ChannelID_t channel) const override
Returns the ID of the ROP the channel belongs to (invalid if none).
unsigned int MaxTPCsets() const
bool HasCryostat(readout::CryostatID const &cryoid) const
Returns whether the specified cryostat is known to the mapping.
virtual unsigned int Nchannels() const override
Returns the number of readout channels (ID's go 0 to Nchannels()).
void buildReadoutPlanes(geo::GeometryData_t::CryostatList_t const &Cryostats)
Fills information about the TPC set and readout plane structure.
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
ROPID_t ROP
Index of the readout plane within its TPC set.
Channel mapping algorithms for VD ColdBox CRP.
geo::WireID NearestWireID(geo::Point_t const &pos) const
Returns the ID of wire closest to the specified position.
Signal from induction planes.
enum geo::_plane_sigtype SigType_t
std::vector< geo::PlaneID > PlaneColl_t
void fillChannelToWireMap(geo::GeometryData_t::CryostatList_t const &Cryostats)
Fills the information about readout channel mapping.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
void setEndChannel(raw::ChannelID_t channel)
Sets the ID of the channels after the last valid one.
constexpr bool isValidChannelID(raw::ChannelID_t channel)
geo::PlaneDataContainer< readout::ROPID > const & PlaneToROP() const
The readout plane including each wire plane.
virtual std::vector< geo::PlaneID > ROPtoWirePlanes(readout::ROPID const &ropid) const override
Returns a list of ID of wire planes belonging to the specified ROP.
ReadoutMappingInfo_t fReadoutMapInfo
Information about TPC sets and readout planes in the geometry.
readout::TPCsetDataContainer< unsigned int > const & ROPcount() const
Number of readout planes in each TPC set.
Test of util::counter and support utilities.
The data type to uniquely identify a TPC.
static constexpr PlaneType_t kSecondInductionType
Identifier for second induction plane type.
virtual geo::WireID NearestWireID(const TVector3 &worldPos, geo::PlaneID const &planeID) const override
Returns the ID of the wire nearest to the specified position.
Class identifying a set of planes sharing readout channels.
static constexpr PlaneType_t kCollectionType
Identifier for collection plane type.
virtual std::vector< geo::TPCID > TPCsetToTPCs(readout::TPCsetID const &tpcsetid) const override
Returns a list of ID of TPCs belonging to the specified TPC set.
TPCsetID_t TPCset
Index of the TPC set within its cryostat.
void set(std::vector< unsigned int > &&TPCsetCount, readout::TPCsetDataContainer< TPCColl_t > &&TPCsetTPCs, readout::TPCsetDataContainer< unsigned int > &&ROPcount, readout::ROPDataContainer< PlaneColl_t > &&ROPplanes, geo::TPCDataContainer< readout::TPCsetID > &&TPCtoTPCset, geo::PlaneDataContainer< readout::ROPID > &&PlaneToROP)
readout::ROPDataContainer< PlaneColl_t > const & ROPplanes() const
All geo::PlaneGeo objects in each readout plane.
virtual bool HasROP(readout::ROPID const &ropid) const override
constexpr raw::ChannelID_t begin() const
Returns the ID of the first channel in the range.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
virtual unsigned int MaxTPCsets() const override
Returns the largest number of TPC sets any cryostat in the detector has.
virtual unsigned int NTPCsets(readout::CryostatID const &cryoid) const override
Returns the total number of TPC sets in the specified cryostat.
unsigned int CryostatID_t
Type for the ID number.
auto array(Array const &a)
Returns a manipulator which will print the specified array.
unsigned int MaxROPs() const
virtual geo::SigType_t SignalTypeForChannelImpl(raw::ChannelID_t const channel) const override
Returns the type of signal on the specified channel.
void resize(unsigned int nCryo, unsigned int nTPCs, unsigned int nPlanes)
Prepares the container with default-constructed data.
Encapsulate the construction of a single detector plane.
geo::PlaneID const & ID() const
Returns the identifier of this plane.
virtual void Initialize(geo::GeometryData_t const &geodata) override
Prepares the algorithm extracting information from the geometry.
unsigned int Nwires() const
Number of wires in this plane.
Functions pulling in STL customization if available.
geo::TPCDataContainer< readout::TPCsetID > const & TPCtoTPCset() const
The TPC set including each TPC.
Definitions of geometry vector data types.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Data in the geometry description.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Containers to hold one datum per TPC set or readout plane.
const WireGeo & LastWire() const
Return the last wire in the plane.
LArSoft geometry interface.
unsigned int dimSize() const
Dimensions of the Level dimension of this container.
std::string to_string(ModuleType const mt)
std::size_t PlaneType_t
Type for plane type identifier.
static constexpr PlaneType_t kFirstInductionType
Identifier for first induction plane type.
cet::coded_exception< error, detail::translate > exception
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
virtual double WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeID) const override
Returns the index of the wire nearest to the specified position.
Encapsulate the construction of a single detector plane.
The data type to uniquely identify a cryostat.
Signal from collection planes.
ChannelsInROPStruct const * find(raw::ChannelID_t channel) const
Returns data of the ROP including channel, nullptr if none.