GeoApaChannelGroupService_service.cc
Go to the documentation of this file.
1 // GeoApaChannelGroupService.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_LogLevel(pset.get<int>("LogLevel")),
31  m_ApaRops(pset.get<vector<int>>("ApaRops")),
32  m_size(0) {
33  const string myname = "GeoApaChannelGroupService::ctor: ";
34  // Find the total # APAs and assign width for APA index.
35  Index ngrp = 0;
36  for ( const geo::CryostatID& cryid : m_pgeo->IterateCryostatIDs() ) {
37  ngrp += m_pgeo->NTPCsets(cryid);
38  }
39  unsigned int w = log10(ngrp-1) + 1;
40  m_names.resize(ngrp);
41  m_chanvecs.resize(ngrp);
42  Index igrp = 0;
43  Index ncry = m_pgeo->Ncryostats();
44  // Loop over cryostats.
45  for ( const geo::CryostatID& cryid : m_pgeo->IterateCryostatIDs() ) {
46  Index napa = m_pgeo->NTPCsets(cryid);
47  Index icry = cryid.Cryostat;
48  // Loop over APAs.
49  for ( Index iapa=0; iapa<napa; ++iapa, ++igrp ) {
50  APAID apaid(cryid, iapa);
51  Index nrop = m_pgeo->NROPs(apaid);
52  // Build name.
53  ostringstream ssname;
54  if ( ncry > 1 ) ssname << "cry" << icry << "-";
55  ssname << "apa" << setfill('0') << setw(w) << iapa;
56  m_names[igrp] = ssname.str();
57  // Loop over ROPs and fill channel vector.
58  vector<bool> skipRop(nrop, false);
59  Index naparop = m_ApaRops.size();
60  if ( naparop > 0 ) {
61  Index pat = m_ApaRops[iapa%naparop];
62  for ( Index irop=0; irop<nrop; ++irop ) {
63  Index mask = 1 << irop;
64  bool keep = mask & pat;
65  if ( ! keep ) skipRop[irop] = true;
66  }
67  }
68  Index nropUsed = 0;
69  for ( Index irop=0; irop<nrop; ++irop ) {
70  if ( skipRop[irop] ) continue;
71  ROPID ropid(apaid, irop);
72  // Find channels.
73  Index icha1 = m_pgeo->FirstChannelInROP(ropid);
74  Index icha2 = icha1 + m_pgeo->Nchannels(ropid);
75  for ( unsigned int icha=icha1; icha<icha2; ++icha ) m_chanvecs[igrp].push_back(icha);
76  ++nropUsed;
77  }
78  if ( m_LogLevel >= 1 ) {
79  cout << myname << "Group " << igrp << " (" << m_names[igrp] << ") has "
80  << m_chanvecs[igrp].size() << " channels from "
81  << nropUsed << "/" << nrop << " readout planes." << endl;
82  }
83  }
84  }
85  m_size = ngrp;
86 }
87 
88 //**********************************************************************
89 
92 : GeoApaChannelGroupService(pset) { }
93 
94 //**********************************************************************
95 
97  return m_size;
98 }
99 
100 //**********************************************************************
101 
103  if ( igrp < m_names.size() ) return m_names[igrp];
104  return "NoSuchApa";
105 }
106 
107 //**********************************************************************
108 
110  if ( igrp < m_chanvecs.size() ) return m_chanvecs[igrp];
111  static ChannelVector empty;
112  return empty;
113 }
114 
115 //**********************************************************************
116 
117 ostream& GeoApaChannelGroupService::print(ostream& out, string prefix) const {
118  out << prefix << "GeoApaChannelGroupService: " << endl;
119  out << prefix << " # ROP: " << size() << endl;
120  return out;
121 }
122 
123 //**********************************************************************
124 
126 
127 //**********************************************************************
ChannelGroupService::Name Name
std::string string
Definition: nybbler.cc:12
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.
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
readout::ROPID ROPID
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
ChannelGroupService::ChannelVector ChannelVector
raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const
Returns the ID of the first channel in the specified readout plane.
const ChannelVector & channels(Index igrp) const
Class identifying a set of planes sharing readout channels.
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
readout::TPCsetID APAID
GeoApaChannelGroupService(fhicl::ParameterSet const &pset)
ChannelGroupService::Index Index
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.
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
Interface to algorithm class for a specific detector channel mapping.
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
art::ServiceHandle< geo::Geometry > m_pgeo
std::vector< Channel > ChannelVector
#define DEFINE_ART_SERVICE_INTERFACE_IMPL(svc, iface)