MegaAnodePlane.cxx
Go to the documentation of this file.
3 #include <string>
4 
5 
8 
9 using namespace WireCell;
10 using namespace std;
11 
12 WireCell::Configuration Gen::MegaAnodePlane::default_configuration() const
13 {
15  /// These must be provided
16  cfg["anodes_tn"] = Json::arrayValue;
17 
18  return cfg;
19 }
20 
22 {
23  m_anodes.clear();
24  auto anodes_tn = cfg["anodes_tn"];
25  for (auto anode_tn: anodes_tn) {
26  auto anode = Factory::find_tn<IAnodePlane>(anode_tn.asString());
27  m_anodes.push_back(anode);
28  // std::cout << "MegaAnodePlane: adding anode " << anode_tn << std::endl;
29  // for(int channel: anode->channels()){
30  // cout << channel << " ";
31  // }
32  }
33 }
34 
36 {
37  // cout << "MegaAnodePlane: resolve channel " << channel << endl;
38  const WirePlaneId bogus(0xFFFFFFFF); // -1 is unknown
39 
40  for(auto& anode: m_anodes){
41  WirePlaneId planeId = anode->resolve(channel);
42  if(planeId.index() > -1){
43  // std::cout << "MegaAnodePlane: plane index " << planeId.index() << "for channel " << channel << std::endl;
44  return planeId;
45  }
46  }
47  // cout << "MegaAnodePlane: unknown plane for channel " << channel << endl;
48  return bogus;
49 }
50 
51 std::vector<int> Gen::MegaAnodePlane::channels() const
52 {
53  std::vector<int> ret;
54  for(auto& anode: m_anodes) {
55  auto chans = anode->channels();
56  ret.insert(ret.end(), chans.begin(), chans.end());
57  }
58  return ret;
59 }
60 
62 {
63  for(auto& anode: m_anodes) {
64  auto ch = anode->channel(chident);
65  if (ch == nullptr) { continue; }
66  return ch;
67  }
68  return nullptr;
69 }
70 
71 IWire::vector Gen::MegaAnodePlane::wires(int channel) const
72 {
73  for(auto& anode: m_anodes) {
74  auto ws = anode->wires(channel);
75  if (ws.empty()) { continue; }
76  return ws;
77  }
78  return IWire::vector();
79 }
80 
std::shared_ptr< const IChannel > pointer
Definition: IData.h:19
struct vector vector
STL namespace.
cfg
Definition: dbjson.py:29
std::vector< pointer > vector
Definition: IData.h:21
def configure(cfg)
Definition: cuda.py:34
Definition: Main.h:22
Json::Value Configuration
Definition: Configuration.h:50
WIRECELL_FACTORY(MegaAnodePlane, WireCell::Gen::MegaAnodePlane, WireCell::IAnodePlane, WireCell::IConfigurable) using namespace WireCell
std::string resolve(const std::string &filename)
Definition: Persist.cxx:99
int index() const
Layer as index number (0,1 or 2). -1 if unknown.
Definition: WirePlaneId.cxx:34