GeoRopChannelGroupService_service.cc
Go to the documentation of this file.
1 // GeoRopChannelGroupService.cxx
2 
5 #include <sstream>
6 #include <iomanip>
9 
10 using std::cout;
11 using std::ostream;
12 using std::endl;
13 using std::string;
14 using std::ostringstream;
15 using std::setfill;
16 using std::setw;
17 using std::vector;
18 
22 
25 
26 //**********************************************************************
27 
30 : m_size(0) {
31  // Find the total # APAs and assign width for APA index.
32  Index napatot = 0;
33  for ( const geo::CryostatID& cryid : m_pgeo->IterateCryostatIDs() ) {
34  napatot += m_pgeo->NTPCsets(cryid);
35  }
36  unsigned int w = log10(napatot-1) + 1;
37  // Loop over cryostats.
38  Index krop = 0;
39  for ( const geo::CryostatID& cryid : m_pgeo->IterateCryostatIDs() ) {
40  Index napa = m_pgeo->NTPCsets(cryid);
41  // Loop over APAs.
42  for ( Index iapa=0; iapa<napa; ++iapa ) {
43  APAID apaid(cryid, iapa);
44  Index nrop = m_pgeo->NROPs(apaid);
45  // Loop over ROPs.
46  unsigned int nvu = 0;
47  unsigned int nvv = 0;
48  unsigned int nvz = 0;
49  // First pass to get the number of each view.
50  for ( Index irop=0; irop<nrop; ++irop ) {
51  ROPID ropid(apaid, irop);
52  geo::View_t view = m_pgeo->View(ropid);
53  if ( view == geo::kU ) ++nvu;
54  else if ( view == geo::kV ) ++nvv;
55  else if ( view == geo::kZ ) ++nvz;
56  }
57  unsigned int ivu = 0;
58  unsigned int ivv = 0;
59  unsigned int ivz = 0;
60  // Loop over ROPs, assign name and fill channel vector.
61  for ( Index irop=0; irop<nrop; ++irop ) {
62  ROPID ropid(apaid, irop);
63  m_names.resize(krop+1);
64  m_chanvecs.resize(krop+1);
65  // Build name.
66  ostringstream ssname;
67  ssname << "apa" << setfill('0') << setw(w) << iapa;
68  geo::View_t view = m_pgeo->View(ropid);
69  if ( view == geo::kU ) {
70  ssname << "u";
71  ++ivu;
72  if ( nvu > 1 ) ssname << ivu;
73  } else if ( view == geo::kV ) {
74  ssname << "v";
75  ++ivv;
76  if ( nvv > 1 ) ssname << ivv;
77  } else if ( view == geo::kZ ) {
78  ssname << "z";
79  ++ivz;
80  if ( nvz > 1 ) ssname << ivz;
81  } else {
82  ssname << "UnknownView";
83  }
84  m_names[krop] = ssname.str();
85  // Find channels.
86  Index icha1 = m_pgeo->FirstChannelInROP(ropid);
87  Index icha2 = icha1 + m_pgeo->Nchannels(ropid);
88  for ( unsigned int icha=icha1; icha<icha2; ++icha ) m_chanvecs[krop].push_back(icha);
89  ++krop;
90  }
91  }
92  }
93  m_size = krop;
94 }
95 
96 //**********************************************************************
97 
100 : GeoRopChannelGroupService(pset) { }
101 
102 //**********************************************************************
103 
105  return m_size;
106 }
107 
108 //**********************************************************************
109 
111  if ( igrp < m_names.size() ) return m_names[igrp];
112  return "NoSuchRop";
113 }
114 
115 //**********************************************************************
116 
118  if ( igrp < m_chanvecs.size() ) return m_chanvecs[igrp];
119  static ChannelVector empty;
120  return empty;
121 }
122 
123 //**********************************************************************
124 
125 ostream& GeoRopChannelGroupService::print(ostream& out, string prefix) const {
126  out << prefix << "GeoRopChannelGroupService: " << endl;
127  out << prefix << " # ROP: " << size() << endl;
128  return out;
129 }
130 
131 //**********************************************************************
132 
134 
135 //**********************************************************************
art::ServiceHandle< geo::Geometry > m_pgeo
const ChannelVector & channels(Index igrp) const
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::string string
Definition: nybbler.cc:12
Planes which measure V.
Definition: geo_types.h:130
ChannelGroupService::ChannelVector ChannelVector
struct vector vector
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
unsigned int NTPCsets(readout::CryostatID const &cryoid) const
Returns the total number of TPC sets in the specified cryostat.
Planes which measure Z direction.
Definition: geo_types.h:132
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
ChannelGroupService::Name Name
ChannelGroupService::Index Index
Planes which measure U.
Definition: geo_types.h:129
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const
Returns the ID of the first channel in the specified readout plane.
readout::TPCsetID APAID
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Class identifying a set of planes sharing readout channels.
readout::ROPID ROPID
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
IteratorBox< cryostat_id_iterator,&GeometryCore::begin_cryostat_id,&GeometryCore::end_cryostat_id > IterateCryostatIDs() const
Enables ranged-for loops on all cryostat IDs of the detector.
Access the description of detector geometry.
unsigned int NROPs(readout::TPCsetID const &tpcsetid) const
Returns the total number of ROP in the specified TPC set.
Interface to algorithm class for a specific detector channel mapping.
GeoRopChannelGroupService(fhicl::ParameterSet const &pset)
Q_EXPORT QTSManip setfill(int f)
Definition: qtextstream.h:337
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
QTextStream & endl(QTextStream &s)
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
std::vector< Channel > ChannelVector
#define DEFINE_ART_SERVICE_INTERFACE_IMPL(svc, iface)