16 #include "cetlib_except/exception.h" 
   17 #include "messagefacility/MessageLogger/MessageLogger.h" 
   19 namespace fhicl { 
class ParameterSet; }
 
   35     std::vector<geo::CryostatGeo> 
const& cgeo = geodata.
cryostats;
 
   39     mf::LogInfo(
"ChannelMapStandardAlg") << 
"Initializing Standard ChannelMap...";
 
   56     for(
unsigned int cs = 0; cs != 
fNcryostat; ++cs){
 
   71       for(
unsigned int TPCCount = 0; TPCCount != 
fNTPC[cs]; ++TPCCount){
 
   73         unsigned int PlanesThisTPC = TPC.
Nplanes();
 
   78         fNPlanes[cs][TPCCount]=PlanesThisTPC;
 
   79         for(
unsigned int PlaneCount = 0; PlaneCount != PlanesThisTPC; ++PlaneCount){
 
   83           double ThisWirePitch = TPC.
WirePitch(PlaneCount);
 
   86           double  WireCentre1[3] = {0.,0.,0.};
 
   87           double  WireCentre2[3] = {0.,0.,0.};
 
   97           double OrthY = cth, OrthZ = -sth;
 
   98           if(((WireCentre2[1] - WireCentre1[1])*OrthY
 
   99               + (WireCentre2[2] - WireCentre1[2])*OrthZ) < 0){
 
  110           fOrthVectorsY[cs][TPCCount][PlaneCount] = OrthY / ThisWirePitch;
 
  111           fOrthVectorsZ[cs][TPCCount][PlaneCount] = OrthZ / ThisWirePitch;
 
  113           fFirstWireProj[cs][TPCCount][PlaneCount]  = WireCentre1[1]*OrthY + WireCentre1[2]*OrthZ;
 
  117           int WiresThisPlane = plane.
Nwires();
 
  121           RunningTotal += WiresThisPlane;
 
  134     MF_LOG_DEBUG(
"ChannelMapStandard") << 
"# of channels is " << 
fNchannels;
 
  148     std::vector< geo::WireID > AllSegments;
 
  149     unsigned int cstat = 0;
 
  150     unsigned int tpc   = 0;
 
  151     unsigned int plane = 0;
 
  152     unsigned int wire  = 0;
 
  156       throw cet::exception(
"Geometry") << 
"ILLEGAL CHANNEL ID for channel " << channel << 
"\n";
 
  159     bool foundWid(
false);
 
  160     for(
unsigned int csloop = 0; csloop != 
fNcryostat; ++csloop){
 
  161       for(
unsigned int tpcloop = 0; tpcloop != 
fNTPC[csloop]; ++tpcloop){
 
  180     AllSegments.push_back(CodeWire);
 
  195     if (!HasROP(ropid)) 
return 0;
 
  197     return WireCount(FirstWirePlaneInROP(ropid));
 
  208     return YPos*AccessElement(fOrthVectorsY, planeID)
 
  209          + ZPos*AccessElement(fOrthVectorsZ, planeID)
 
  210          - AccessElement(fFirstWireProj, planeID);
 
  223     int NearestWireNumber = int
 
  224       (0.5 + WireCoordinate(worldPos.Y(), worldPos.Z(), planeID));
 
  229     if(NearestWireNumber < 0 ||
 
  230        (
unsigned int) NearestWireNumber >= WireCount(planeID))
 
  232       int wireNumber = NearestWireNumber; 
 
  234       if(NearestWireNumber < 0 ) NearestWireNumber = 0;
 
  235       else                       NearestWireNumber = WireCount(planeID) - 1;
 
  238         << 
"Can't Find Nearest Wire for position (" 
  239         << worldPos[0] << 
"," << worldPos[1] << 
"," << worldPos[2] << 
")" 
  240         << 
" in plane " << std::string(planeID) << 
" approx wire number # " 
  241         << wireNumber << 
" (capped from " << NearestWireNumber << 
")\n";
 
  263     unsigned int const* pBaseLine = GetElementPtr(fPlaneBaselines, wireID);
 
  268       return *pBaseLine + wireID.
Wire;
 
  272       throw cet::exception(
"ChannelMapStandardAlg")
 
  273         << 
"NO CHANNEL FOUND for " << std::string(wireID);
 
  277     mf::LogWarning(
"ChannelMapStandardAlg") << 
"should not be at the point in the function, returning " 
  278                                             << 
"invalid channel";
 
  291     unsigned int tpc = channel / nChanPerTPC;
 
  293     unsigned int PlanesThisTPC = 
fNPlanes[0][tpc];
 
  303       mf::LogWarning(
"BadChannelSignalType") << 
"Channel " << channel
 
  304                                              << 
" not given signal type." << std::endl;
 
  346     return ConvertTPCtoTPCset(tpcid);
 
  354     std::vector<geo::TPCID> IDs;
 
  355     if (tpcsetid.
isValid) IDs.emplace_back(ConvertTPCsetToTPC(tpcsetid));
 
  364     return ConvertTPCsetToTPC(tpcsetid);
 
  371     unsigned int max = 0;
 
  372     for (
unsigned int nTPCs: 
fNTPC) 
if (nTPCs > max) max = nTPCs;
 
  381     if (!HasTPCset(tpcsetid)) 
return 0;
 
  382     return AccessElement(fNPlanes, FirstTPCinTPCset(tpcsetid));
 
  388     unsigned int max = 0;
 
  389     for (
auto const& cryo_tpc: 
fNPlanes)
 
  390       for (
unsigned int nPlanes: cryo_tpc)
 
  391         if (nPlanes > max) max = nPlanes;
 
  406     return ConvertWirePlaneToROP(planeid);
 
  414     std::vector<geo::PlaneID> IDs;
 
  415     if (ropid.
isValid) IDs.emplace_back(FirstWirePlaneInROP(ropid));
 
  424     std::vector<geo::TPCID> IDs;
 
  438     std::vector<geo::WireID> wires = ChannelToWire(channel);
 
  441     if (wires.empty()) 
return {}; 
 
  444     return WirePlaneToROP(wires[0]);
 
  454       AccessElement(fPlaneBaselines, ConvertROPtoWirePlane(ropid));
 
  462     return ConvertROPtoWirePlane(ropid);
 
  482     if (!tpcsetid.
isValid) 
return {};
 
  494     if (!planeid.
isValid) 
return {}; 
 
virtual void Initialize(GeometryData_t const &geodata) override
Geometry initialisation. 
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
TPCInfoMap_t< unsigned int > fNPlanes
PlaneInfoMap_t< float > fWireCounts
Encapsulate the construction of a single cyostat. 
virtual geo::TPCID FirstTPCinTPCset(readout::TPCsetID const &tpcsetid) const override
Returns the ID of the first TPC belonging to 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. 
WireGeo const & Wire(unsigned int iwire) const 
unsigned int Nplanes() const 
Number of planes in this tpc. 
unsigned int ROPID_t
Type for the ID number. 
unsigned short TPCsetID_t
Type for the ID number. 
unsigned int PlaneID_t
Type for the ID number. 
The data type to uniquely identify a Plane. 
bool isValid
Whether this ID points to a valid element. 
Geometry information for a single TPC. 
static geo::PlaneID ConvertROPtoWirePlane(readout::ROPID const &ropid)
Converts a wire plane ID into a ROP ID using the same numerical indices. 
Class identifying a set of TPC sharing readout channels. 
virtual double WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeID) const override
Returns the index of the wire nearest to the specified position. 
CryostatID_t Cryostat
Index of cryostat. 
WireID_t Wire
Index of the wire within its plane. 
CryostatList_t cryostats
The detector cryostats. 
virtual unsigned int NROPs(readout::TPCsetID const &tpcsetid) const override
Returns the total number of ROPs in the specified TPC set. 
Geometry information for a single cryostat. 
PlaneInfoMap_t< raw::ChannelID_t > fFirstChannelInThisPlane
PlaneInfoMap_t< float > fOrthVectorsZ
static readout::TPCsetID ConvertTPCtoTPCset(geo::TPCID const &tpcid)
Converts a TPC ID into a TPC set ID using the same numerical indices. 
virtual readout::TPCsetID TPCtoTPCset(geo::TPCID const &tpcid) const override
Returns the ID of the TPC set the specified TPC belongs to. 
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter. 
virtual std::set< PlaneID > const & PlaneIDs() const override
Returns a list of the plane IDs in the whole detector. 
virtual unsigned int MaxROPs() const override
Returns the largest number of ROPs a TPC set in the detector has. 
Access the description of detector geometry. 
static readout::ROPID ConvertWirePlaneToROP(geo::PlaneID const &planeid)
Converts a ROP ID into a wire plane ID using the same numerical indices. 
virtual geo::PlaneID FirstWirePlaneInROP(readout::ROPID const &ropid) const override
Returns the ID of the first plane belonging to the specified ROP. 
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. 
Collection of exceptions for Geometry system. 
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel. 
virtual bool HasTPCset(readout::TPCsetID const &tpcsetid) const override
unsigned int MaxTPCs() const 
Returns the largest number of TPCs in a single cryostat. 
ROPID_t ROP
Index of the readout plane within its TPC set. 
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter. 
Signal from induction planes. 
static geo::TPCID ConvertTPCsetToTPC(readout::TPCsetID const &tpcsetid)
Converts a TPC set ID into a TPC ID using the same numerical indices. 
virtual WireID NearestWireID(const TVector3 &worldPos, geo::PlaneID const &planeID) const override
Returns the ID of the wire nearest to the specified position. 
virtual raw::ChannelID_t PlaneWireToChannel(geo::WireID const &wireID) const override
Returns the channel ID a wire is connected to. 
enum geo::_plane_sigtype SigType_t
unsigned int fNcryostat
number of cryostats in the detector 
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. 
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
PlaneInfoMap_t< unsigned int > fPlaneBaselines
constexpr bool isValidChannelID(raw::ChannelID_t channel)
unsigned int NTPC() const 
Number of TPCs in this cryostat. 
PlaneInfoMap_t< unsigned int > fWiresPerPlane
double WirePitch(unsigned plane=0) const 
virtual std::vector< WireID > ChannelToWire(raw::ChannelID_t channel) const override
PlaneInfoMap_t< float > fFirstWireProj
The data type to uniquely identify a TPC. 
PlaneID_t Plane
Index of the plane within its TPC. 
std::set< PlaneID > fPlaneIDs
vector of the PlaneIDs present in the detector 
virtual readout::ROPID ChannelToROP(raw::ChannelID_t channel) const override
Returns the ID of the ROP the channel belongs to (invalid if none) 
Class identifying a set of planes sharing readout channels. 
unsigned int fNchannels
number of channels in the detector 
TPCsetID_t TPCset
Index of the TPC set within its cryostat. 
Encapsulate the geometry of a wire. 
unsigned int CryostatID_t
Type for the ID number. 
ChannelMapStandardAlg(fhicl::ParameterSet const &p)
virtual unsigned int Nchannels() const override
Returns the total number of channels present (not necessarily contiguous) 
unsigned int TPCID_t
Type for the ID number. 
Interface to algorithm class for a specific detector channel mapping. 
Encapsulate the construction of a single detector plane. 
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. 
virtual void Uninitialize() override
Deconfiguration: prepare for a following call of Initialize() 
unsigned int Nwires() const 
Number of wires in this plane. 
virtual readout::ROPID WirePlaneToROP(geo::PlaneID const &planeid) const override
Returns the ID of the ROP planeid belongs to, or invalid if none. 
PlaneInfoMap_t< float > fOrthVectorsY
Unit vectors orthogonal to wires in. 
virtual SigType_t SignalTypeForChannelImpl(raw::ChannelID_t const channel) const override
Return the signal type of the specified channel. 
virtual bool HasROP(readout::ROPID const &ropid) const override
raw::ChannelID_t fTopChannel
book keeping highest channel # 
unsigned int WireID_t
Type for the ID number. 
Exception thrown on invalid wire number (e.g. NearestWireID()) 
PlaneGeo const & Plane(geo::View_t view) const 
Return the plane in the tpc with View_t view. 
void GetCenter(double *xyz, double localz=0.0) const 
Fills the world coordinate of a point on the wire. 
Data in the geometry description. 
double CosThetaZ() const 
Returns trigonometric operations on ThetaZ() 
PlaneInfoMap_t< raw::ChannelID_t > fFirstChannelInNextPlane
unsigned int ChannelID_t
Type representing the ID of a readout channel. 
TPCID_t TPC
Index of the TPC within its cryostat. 
virtual unsigned int MaxTPCsets() const override
Returns the largest number of TPC sets any cryostat in the detector has. 
virtual std::vector< geo::TPCID > ROPtoTPCs(readout::ROPID const &ropid) const override
Returns a list of ID of TPCs the specified ROP spans. 
std::vector< unsigned int > fNTPC
number of TPCs in each cryostat 
constexpr TPCsetID const & asTPCsetID() const 
Conversion to TPCsetID (for convenience of notation). 
Encapsulate the construction of a single detector plane. 
The data type to uniquely identify a cryostat. 
Signal from collection planes.