42 DuneApaChannelMapAlg::
50 if ( sdet.substr(0,7) ==
"dune35t" ) fOpDetFlag = 1;
64 vector<CryostatGeo>
const& crygeos = geodata.
cryostats;
65 Index ncry = crygeos.size();
68 mf::LogError(
"DuneApaChannelMapAlg") <<
"No cryostats found.";
73 mf::LogInfo(
"DuneApaChannelMapAlg") <<
"Initializing channel map...";
98 for (
Index icry=0; icry<ncry; ++icry ) {
99 Index ntpc = crygeos[icry].NTPC();
123 for (
Index itpc=0; itpc<ntpc; ++itpc ) {
127 <<
"# planes/TPC is " << npla <<
" rather than 3 " <<
" for TPC " << itpc;
139 for (
Index ipla=0; ipla<npla; ++ipla ) {
145 for (
Index iapa=0; iapa<napa; ++iapa ) {
148 fApaTpcs[icry][iapa].push_back(itpc);
149 fApaTpcs[icry][iapa].push_back(itpc+1);
154 fRopTpc[icry][iapa].resize(nrop);
158 for (
Index irop=0; irop<2; ++irop ) {
160 fRopTpc[icry][iapa][irop].push_back(itpc);
161 fRopTpc[icry][iapa][irop].push_back(itpc+1);
162 fRopPlane[icry][iapa][irop].push_back(ipla);
163 fRopPlane[icry][iapa][irop].push_back(ipla);
167 for (
Index irop=2; irop<4; ++irop ) {
169 fRopTpc[icry][iapa][irop].push_back(itpc);
170 fRopPlane[icry][iapa][irop].push_back(ipla);
185 for (
Index icry=0; icry!=ncry; ++icry ) {
187 for (
Index iapa=0; iapa!=napa; ++iapa ) {
189 for (
Index irop=0; irop!=nrop; ++irop ) {
192 for (
Index irpl=0; irpl!=nrpl; ++irpl ) {
198 const PlaneGeo& plageo = crygeos[icry].TPC(itpc).Plane(ipla);
204 if ( view != eview[ipla] ) {
206 <<
": View " << view <<
" is not the expected " << eview[ipla];
208 double xyz[3] = {0.};
209 double xyz_next[3] = {0.};
210 Index nAnchoredWires = 0;
213 if ( view == geo::kZ ) {
214 nAnchoredWires = nwir;
217 for (
unsigned int iwir=0; iwir+1<nwir; ++iwir ) {
220 if ( xyz[2] == xyz_next[2] ) {
221 nAnchoredWires = iwir;
228 icha += nAnchoredWires;
241 for (
Index icry=0; icry<ncry; ++icry ) {
244 for (
Index itpc=0; itpc<ntpc; ++itpc ) {
245 fPlaneData[icry][itpc].resize(crygeos[icry].
TPC(itpc).Nplanes());
246 for (
Index ipla=0; ipla<crygeos[icry].TPC(itpc).Nplanes(); ++ipla ) {
248 const PlaneGeo& thePlane = crygeos[icry].TPC(itpc).Plane(ipla);
264 PlaneData.
fYmax = endpoint[1];
265 PlaneData.
fYmin = endpoint[1];
266 PlaneData.
fZmax = endpoint[2];
267 PlaneData.
fZmin = endpoint[2];
269 for (
unsigned int iwire=0;iwire<
nwires;iwire++){
292 for (
Index ipla=0; ipla<npla; ++ipla ) {
299 for (
Index icry=0; icry<ncry; ++icry ) {
325 vector< WireID > wirids;
334 for ( icry=0; icry<ncry; ++icry ) {
336 for ( iapa=0; iapa<napa; ++iapa ) {
338 for ( irop=0; irop<nrop; ++irop ) {
341 found = icha >= icha1 && icha < icha2;
343 ichaRop = icha - icha1;
351 if ( icry >= ncry ) {
352 mf::LogError(
"DuneApaChannelMapAlg") <<
"Unable to find APA plane for channel " << icha;
353 throw cet::exception(
"DuneApaChannelMapAlg") << __func__ <<
": Unable to find APA plane for channel " << icha;
358 if ( nrpl == 0 )
throw cet::exception(
"DuneApaChannelMapAlg") << __func__ <<
": No TPC planes.";
359 if ( nrpl > 2 )
throw cet::exception(
"DuneApaChannelMapAlg") << __func__ <<
": Too many TPC planes.";
362 Index itpc2 = (nrpl > 1 ) ?
fRopTpc[icry][iapa][irop][1] : itpc1;
364 bool wrapped = ipla < 2;
365 if ( wrapped && itpc2 == itpc1 )
366 throw cet::exception(
"DuneApaChannelMapAlg") << __func__ <<
": 2nd plane not found for wrapped ROP";
367 if ( wrapped && ipla !=
fRopPlane[icry][iapa][irop][1] )
368 throw cet::exception(
"DuneApaChannelMapAlg") << __func__ <<
": Wrapped planes have inconsistent indices.";
372 throw cet::exception(
"DuneApaChannelMapAlg") << __func__ <<
": Planes have inconsistent anchor counts.";
376 Index iwir = ichaRop;
377 if ( wrapped && iwir >= nAnchored ) {
381 if ( iwir >= nAnchored ) {
382 throw cet::exception(
"DuneApaChannelMapAlg") << __func__ <<
": Invalid channel: iwir =" << iwir;
386 WireID wirid(icry, itpc, ipla, iwir);
387 wirids.push_back(wirid);
389 itpc = (itpc == itpc1) ? itpc2 : itpc1;
408 return icha2 - icha1;
414 WireCoordinate(
double YPos,
double ZPos,
unsigned int PlaneNo,
unsigned int TPCNo,
415 unsigned int cstat)
const {
431 double backsign = (
fPlaneRopIndex[icry][itpc][ipla] == 1) ? -1.0 : 1.0;
458 Index iwir = (iwirSigned < 0) ? 0 : iwirSigned;
463 if ( iwir > iwirMax ) iwir = iwirMax;
464 return WireID(plaid, iwir);
493 Index icha = icha1 + ichaRop%ncha;
501 for (
Index icry=0; icry<ncry; ++icry ) {
503 for (
Index iapa=0; iapa<napa; ++iapa ) {
505 for (
Index irop=0; irop<nrop; ++irop ) {
508 if ( icha >= icha1 && icha < icha2 ) {
562 if (opDet == 0 || opDet == 4 || opDet == 6)
return 8;
564 if (opDet == 2)
return 2;
576 return uniqueChannel;
630 vector<TPCID> tpcids;
642 return TPCID(icry, itpc);
674 return ROPID(icry, iapa, irop);
680 vector<PlaneID> plaids;
685 for (
Index irpl=0; irpl<nrpl; ++irpl ) {
688 plaids.push_back(
PlaneID(icry, itpc, ipla));
696 vector<TPCID> tpcids;
698 for (
const PlaneID& plaid : plaids ) {
700 if ( find(tpcids.begin(), tpcids.end(), tpcid) == tpcids.end() ) tpcids.push_back(tpcid);
709 for (
Index icry=0; icry<ncry; ++icry ) {
711 for (
Index iapa=0; iapa<napa; ++iapa ) {
713 for (
Index irop=0; irop<nrop; ++irop ) {
716 if ( icha >= icha1 && icha < icha2 )
return ROPID(icry, iapa, irop);
726 throw cet::exception(
"DuneApaChannelMapAlg") << __func__ <<
": Sorter is missing.";
744 if ( plaids.size() )
return plaids[0];
unsigned int Nchannels() const override
Returns the total number of channels present (not necessarily contiguous)
unsigned int fNApaMax
Max # TPCs in any cryostat.
void GetStart(double *xyz) const
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
unsigned int fNRopMax
Max # ROPs in any APA.
bool HasCryostat(CryostatID const &cid) const
Returns whether the specified ID represents a valid cryostat.
virtual readout::ROPID WirePlaneToROP(geo::PlaneID const &planeid) const override
Returns the ID of the ROP planeid belongs to, or invalid if none.
std::set< PlaneID > fPlaneIDs
vector of the PlaneIDs present in the detector
static constexpr TPCID_t InvalidID
Special code for an invalid ID.
Encapsulate the construction of a single cyostat.
unsigned int OpDetFromOpChannel(unsigned int opChannel) const override
Returns the optical detector the specified optical channel belongs.
virtual geo::PlaneID FirstWirePlaneInROP(readout::ROPID const &ropid) const override
Returns the ID of the first plane belonging to the specified ROP.
float fWireSortingInZ
+1 if the wire ID order follow z (larger z, or smaller intercept => larger wire ID); -1 otherwise ...
std::vector< double > fOrientation
SigType_t SignalTypeForChannelImpl(raw::ChannelID_t const channel) const override
Return the signal type of the specified channel.
WireGeo const & Wire(unsigned int iwire) const
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
ThreeVector< unsigned int > fApaTpcs
TPCs for each APA.
ThreeVector< unsigned int > fChannelsPerRop
channels for each Rop
unsigned int Nplanes() const
Number of planes in this tpc.
std::vector< double > fCosOrientation
PlaneInfoMap_t< raw::ChannelID_t > fFirstChannelInThisRop
(cry, apa, rop)
The data type to uniquely identify a Plane.
double WireCoordinate(double YPos, double ZPos, unsigned int PlaneNo, unsigned int TPCNo, unsigned int cstat) const override
Returns the index of the wire nearest to the specified position.
all data we need for each APA
Class identifying a set of TPC sharing readout channels.
virtual WireID NearestWireID(const TVector3 &worldPos, unsigned int PlaneNo, unsigned int TPCNo, unsigned int cstat) const override
Returns the ID of the wire nearest to the specified position.
const geo::GeoObjectSorter * fSorter
sorts geo::XXXGeo objects
CryostatID_t Cryostat
Index of cryostat.
Planes which measure Z direction.
virtual unsigned int MaxROPs() const override
WireID_t Wire
Index of the wire within its plane.
Interface to algorithm class for a specific detector channel mapping.
T const & AccessElement(TPCInfoMap_t< T > const &map, geo::TPCID const &id) const
Returns the specified element of the TPC map.
CryostatList_t cryostats
The detector cryostats.
ThreeVector< unsigned int > fPlaneRop
ROP for each TPC plane (cry, tpc, pla)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Geometry information for a single cryostat.
PlaneInfoMap_t< raw::ChannelID_t > fFirstChannelInThisPlane
ThreeVector< unsigned int > fAnchoredWires
anchored wires for each (cry, tpc, pla)
virtual geo::GeoObjectSorter const & Sorter() const override
Returns the object to sort geometry with.
unsigned int NOpChannels(unsigned int NOpDets) const override
Returns the number of optical channels contained in some detectors.
virtual unsigned int MaxTPCsets() const override
double ThetaZ() const
Returns angle of wire with respect to z axis in the Y-Z plane in radians.
std::vector< double > fWirePitch
void setSorter(const geo::GeoObjectSorter &sort)
PlaneInfoMap_t< PlaneData_t > fPlaneData
TwoVector< unsigned int > fPlanesPerTpc
planes for each (cry, tpc)
TPCInfoMap_t< std::vector< T >> PlaneInfoMap_t
Data type for per-plane information.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
ThreeVector< unsigned int > fPlaneApa
APA for each TPC plane (cry, tpc, pla)
TwoVector< unsigned int > fChannelsPerApa
channels for each APA
View_t View() const
Which coordinate does this plane measure.
virtual unsigned int NROPs(readout::TPCsetID const &tpcsetid) const override
Returns the total number of ROP 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.
ROPID_t ROP
Index of the readout plane within its TPC set.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
unsigned int fChannelsPerOpDet
Flag for OpDet channel map.
Signal from induction planes.
void swap(Handle< T > &a, Handle< T > &b)
void Initialize(GeometryData_t const &geodata) override
Geometry initialisation.
enum geo::_plane_sigtype SigType_t
IDparameter< readout::TPCsetID > TPCsetID
Member type of validated readout::TPCsetID parameter.
FourVector< unsigned int > fRopPlane
TPC plane index for each (cry, apa, rop, rpl)
unsigned int OpChannel(unsigned int detNum, unsigned int channel=0) const override
Returns the channel ID of the specified hardware channel.
std::vector< WireID > ChannelToWire(raw::ChannelID_t channel) const override
T get(std::string const &key) const
std::vector< unsigned int > fNApa
number of APAs in each cryostat
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
virtual readout::ROPID ChannelToROP(raw::ChannelID_t channel) const override
Encapsulate the geometry of an auxiliary detector.
ThreeVector< unsigned int > fPlanesPerRop
TPC planes for each (cry, apa, rop)
unsigned int fNcryostat
number of cryostats in the detector
double WirePitch(unsigned plane=0) const
std::vector< double > fSinOrientation
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
static int max(int a, int b)
The data type to uniquely identify a TPC.
PlaneID_t Plane
Index of the plane within its TPC.
Class identifying a set of planes sharing readout channels.
TPCsetID_t TPCset
Index of the TPC set within its cryostat.
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.
FourVector< unsigned int > fRopTpc
TPC planes for each (cry, apa, rop, rpl)
Encapsulate the geometry of a wire.
void Uninitialize() override
Deconfiguration: prepare for a following call of Initialize()
virtual readout::TPCsetID TPCtoTPCset(geo::TPCID const &tpcid) const override
Returns the ID of the TPC set the specified TPC belongs to.
virtual bool HasTPCset(readout::TPCsetID const &tpcsetid) const override
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.
virtual raw::ChannelID_t PlaneWireToChannel(unsigned int plane, unsigned int wire, unsigned int tpc, unsigned int cstat) const override
Returns the channel ID a wire is connected to.
unsigned int fChannelsPerAPA
number of channels in each APA
ThreeVector< unsigned int > fPlaneRopIndex
Index in ROP for each TPC plane (cry, tpc, pla)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Encapsulate the construction of a single detector plane.
unsigned int fNchannels
number of channels in the detector
unsigned int HardwareChannelFromOpChannel(unsigned int opChannel) const override
Returns the hardware channel number of specified optical channel.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
virtual unsigned int NTPCsets(readout::CryostatID const &cryoid) const override
Returns the total number of TPC sets in the specified cryostat.
void GetEnd(double *xyz) const
std::optional< T > get_if_present(std::string const &key) const
unsigned int Nwires() const
Number of wires in this plane.
bool WireIDincreasesWithZ() const
Returns whether the higher z wires have higher wire ID.
unsigned int NOpHardwareChannels(unsigned int opDet) const override
Returns the number of channels in the specified optical detectors.
TwoVector< unsigned int > fRopsPerApa
ROPs for each (cry, apa)
std::set< PlaneID > const & PlaneIDs() const override
Returns a list of the plane IDs in the whole detector.
Access the description of detector geometry.
unsigned int fNTpcMax
Max # TPCs in any cryostat.
detail::Node< FrameID, bool > PlaneID
raw::ChannelID_t fTopChannel
book keeping highest channel #
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
static constexpr CryostatID_t InvalidID
Special code for an invalid ID.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
ThreeVector< unsigned int > fWiresPerPlane
wires/TPC plane for each (cry, tpc, pla)
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Data in the geometry description.
PlaneInfoMap_t< raw::ChannelID_t > fFirstChannelInNextPlane
static constexpr PlaneID_t InvalidID
Special code for an invalid ID.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
TPCID_t TPC
Index of the TPC within its cryostat.
std::vector< unsigned int > fNTpc
number of TPCs in each cryostat
virtual bool HasROP(readout::ROPID const &ropid) const override
static constexpr ROPID_t InvalidID
Special code for an invalid ID.
cet::coded_exception< error, detail::translate > exception
virtual geo::TPCID FirstTPCinTPCset(readout::TPCsetID const &tpcsetid) const override
QTextStream & endl(QTextStream &s)
virtual std::vector< geo::TPCID > ROPtoTPCs(readout::ROPID const &ropid) const override
Returns a list of ID of TPCs the specified ROP spans.
Encapsulate the construction of a single detector plane.
The data type to uniquely identify a cryostat.
Signal from collection planes.
ThreeVector< unsigned int > fAnchoredPlaneRop
ROP holding the anchored wires for (cry, tpc, pla)
PlaneInfoMap_t< raw::ChannelID_t > fFirstChannelInNextRop
(cry, apa, rop)