VDColdboxChannelRanges_tool.cc
Go to the documentation of this file.
3 
4 using std::string;
5 using std::cout;
6 using std::endl;
7 
10 
12 : m_LogLevel(ps.get<int>("LogLevel")),
13  m_GhostRange(ps.get<IndexVector>("GhostRange")),
14  m_glo(0), m_ghi(0) {
15  const string myname = "VDColdboxChannelRanges::ctor: ";
16  const Index nu = 384;
17  const Index ny = 640;
18  const Index ntot = 3200;
19  const Index nhaf = ntot/2;
20  Index nfmb = 13;
21  const IndexVector fuEdges = {1600, 1632, 1664, 1700, 1738, 1778, 1817, 1856, 1896, 1936, 1975, 1984, 1984, 1984};
22  const IndexVector fyEdges = {1984, 2064, 2144, 2236, 2304, 0, 0, 0, 0, 0, 2624, 2560, 2432, 2304};
23  const IndexVector fzEdges = {2624, 2624, 2624, 2624, 2646, 2734, 2823, 2912, 3000, 3088, 3177, 3200, 3200, 3200};
24  if ( m_GhostRange.size() == 2 && m_GhostRange[1] >= m_GhostRange[0] ) {
25  m_glo = m_GhostRange[0];
26  m_ghi = m_GhostRange[1] + 1;
27  } else if ( m_GhostRange.size() ) {
28  cout << myname << "WARNING: " << "Ignoring invalid ghost range." << endl;
29  }
30  if ( m_LogLevel >= 1 ) {
31  cout << myname << " LogLevel: " << m_LogLevel << endl;
32  cout << myname << " Ghost range: [";
33  if ( m_ghi > m_glo ) cout << m_glo << ", " << m_ghi-1;
34  cout << "]" << endl;
35  }
36  // Build entries for detector, haves and planes.
37  insert("cru", 0, ntot, "CRU");
38  insert("crt", 0, nhaf, "CRT");
39  insert("crb", 1600, ntot, "CRB");
40  insert("crtu", 0, nu, "CRTu");
41  insert("crty", nu, nu+ny, "CRTy");
42  insert("crtz", nu+ny, nhaf, "CRTz");
43  insert("crbu", nhaf, nhaf+nu, "CRBu");
44  insert("crby", nhaf+nu, nhaf+nu+ny, "CRBy");
45  insert("crbz", nhaf+nu+ny, ntot, "CRBz");
46  insert("crbg", m_glo, m_ghi, "CRBghost");
47  // Build the FEMB-view entries.
48  for ( Index kfmb=0; kfmb<nfmb; ++kfmb ) {
49  Index ifmb = kfmb + 1;
50  Name sfmb = std::to_string(ifmb);
51  if ( sfmb.size() < 2 ) sfmb = "0" + sfmb;
52  Index ich1 = fuEdges[kfmb];
53  Index ich2 = fuEdges[kfmb+1];
54  if ( ich1 && ich2 && ich1 != ich2 ) {
55  if ( ich1 > ich2 ) std::swap(ich1, ich2);
56  insert("femb" + sfmb + "u", ich1, ich2, "FEMB " + sfmb + "U");
57  }
58  ich1 = fyEdges[kfmb];
59  ich2 = fyEdges[kfmb+1];
60  if ( ich1 && ich2 && ich1 != ich2 ) {
61  if ( ich1 > ich2 ) std::swap(ich1, ich2);
62  insert("femb" + sfmb + "y", ich1, ich2, "FEMB " + sfmb + "Y");
63  }
64  ich1 = fzEdges[kfmb];
65  ich2 = fzEdges[kfmb+1];
66  if ( ich1 && ich2 && ich1 != ich2 ) {
67  if ( ich1 > ich2 ) std::swap(ich1, ich2);
68  insert("femb" + sfmb + "z", ich1, ich2, "FEMB " + sfmb + "Z");
69  }
70  }
71 }
72 
73 
75  const string myname = "VDColdboxChannelRanges::get: ";
76  RangeMap::const_iterator iran = m_rans.find(sran);
77  if ( iran != m_rans.end() ) return iran->second;
78  if ( m_LogLevel >= 2 ) {
79  cout << myname << "Invalid channel range name: " << sran << endl;
80  }
81  return IndexRange(0, 0);
82 }
83 
84 void VDColdboxChannelRanges::insert(Name sran, Index ich1, Index ich2, Name slab1) {
85  m_rans[sran] = IndexRange(sran, ich1, ich2, slab1);
86 }
87 
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
intermediate_table::const_iterator const_iterator
unsigned int Index
void swap(Handle< T > &a, Handle< T > &b)
IndexRange::Name Name
static constexpr double ps
Definition: Units.h:99
void insert(Name sran, Index ich1, Index ich2, Name slab1)
VDColdboxChannelRanges(fhicl::ParameterSet const &ps)
IndexRange get(std::string range_name) const override
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
std::vector< Index > IndexVector
int ntot
Definition: train_cnn.py:133
if(!yymsg) yymsg
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
QTextStream & endl(QTextStream &s)