BeamlineChannelMap_service.cc
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 /// \file BeamlineChannelMap_service.cc
3 /// \brief Channel mapping service which may be used to interpret the
4 /// channels which are read out by the various beamline detector
5 /// elements.
6 /// NB/ Consider moving to fragments package, which is a
7 /// dependence for both the online and offline software bases,
8 /// so online processes (e.g. online monitoring) may use it.
9 /// \author Mike Wallbank (University of Cincinnati) <wallbank@fnal.gov>
10 /// \date August 2019
11 ////////////////////////////////////////////////////////////////////////////
12 
13 #include "BeamlineChannelMap.h"
14 
21 
22 // -----------------------------------------------------------------------
24  fhicl::ParameterSet channel_map = pset.get<fhicl::ParameterSet>("ChannelMap");
25  this->FillBeamlineChannels(channel_map);
26 }
27 
28 // -----------------------------------------------------------------------
30  : BeamlineChannelMap(pset) {
31 }
32 
33 // -----------------------------------------------------------------------
35 
36  // cherenkov
37  unsigned int cherenkov_channel
38  = map.get<unsigned int>("CherenkovChannel");
39  ChannelID cherenkovchan(BeamlineSystem::Cherenkov, 0, 0);
40  fDigitOnlineToOffline[cherenkov_channel] = cherenkovchan;
41  fDigitOfflineToOnline[cherenkovchan] = cherenkov_channel;
42 
43  // tof
44  fhicl::ParameterSet tof_channels = map.get<fhicl::ParameterSet>("ToFChannels");
45  for (std::map<ToFCounter, std::string>::const_iterator tofCounterIt = beamlinegeo::ToFCounterNames.begin();
46  tofCounterIt != beamlinegeo::ToFCounterNames.end(); ++tofCounterIt) {
47  DetectorID tofdet(BeamlineSystem::ToF, tofCounterIt->first);
48  fhicl::ParameterSet tofdet_channels = tof_channels.get<fhicl::ParameterSet>(tofCounterIt->second);
49  for (std::map<ToFChannel, std::string>::const_iterator tofChannelIt = beamlinegeo::ToFChannelNames.begin();
50  tofChannelIt != beamlinegeo::ToFChannelNames.end(); ++tofChannelIt) {
51  ChannelID tofchan(tofdet, tofChannelIt->first);
52  unsigned int online_chan = tofdet_channels.get<unsigned int>(tofChannelIt->second);
53  fDigitOnlineToOffline[online_chan] = tofchan;
54  fDigitOfflineToOnline[tofchan] = online_chan;
55  }
56  }
57 
58  // muon stack
59  std::vector<unsigned int> muonstack_channels
60  = map.get<std::vector<unsigned int> >("MuonStackChannels");
61  for (unsigned int muonstack_chan = 0; muonstack_chan < muonstack_channels.size(); ++muonstack_chan) {
62  ChannelID muonstackchan(BeamlineSystem::MuonStack, 0, muonstack_chan);
63  unsigned int online_chan = muonstack_channels[muonstack_chan];
64  fDigitOnlineToOffline[online_chan] = muonstackchan;
65  fDigitOfflineToOnline[muonstackchan] = online_chan;
66  }
67 
68  // paddle
69  std::vector<unsigned int> paddle_channels
70  = map.get<std::vector<unsigned int> >("PaddlesChannels");
71  for (unsigned int paddle_chan = 0; paddle_chan < paddle_channels.size(); ++paddle_chan) {
72  ChannelID paddlechan(BeamlineSystem::Paddle, 0, paddle_chan);
73  unsigned int online_chan = paddle_channels[paddle_chan];
74  fDigitOnlineToOffline[online_chan] = paddlechan;
75  fDigitOfflineToOnline[paddlechan] = online_chan;
76  }
77 
78  // wc
79  std::vector<unsigned int> wc_channels
80  = map.get<std::vector<unsigned int> >("WCChannels");
81  for (unsigned int wc_chan = 0; wc_chan < wc_channels.size(); ++wc_chan) {
82  ChannelID wcdigitchan(BeamlineSystem::WCDigit, 0, wc_chan);
83  unsigned int online_chan = wc_channels[wc_chan];
84  fDigitOnlineToOffline[online_chan] = wcdigitchan;
85  fDigitOfflineToOnline[wcdigitchan] = online_chan;
86  }
87 
88  // other
89  std::vector<unsigned int> other_channels
90  = map.get<std::vector<unsigned int> >("OtherChannels");
91  for (unsigned int other_chan = 0; other_chan < other_channels.size(); ++other_chan) {
92  ChannelID otherchan(BeamlineSystem::Other, 0, other_chan);
93  unsigned int online_chan = other_channels[other_chan];
94  fDigitOnlineToOffline[online_chan] = otherchan;
95  fDigitOfflineToOnline[otherchan] = online_chan;
96  }
97 
98  return;
99 
100 }
101 
102 // -----------------------------------------------------------------------
104  return fDigitOnlineToOffline.count(channel);
105 }
106 
107 // -----------------------------------------------------------------------
109  if (!fDigitOnlineToOffline.count(channel))
110  throw cet::exception("BeamlineChannelMap")
111  << "Requested online digitizer channel number " << channel << " unknown.";
112  return fDigitOnlineToOffline.at(channel).GetSystemID();
113 }
114 
115 // -----------------------------------------------------------------------
117  if (!fDigitOnlineToOffline.count(channel))
118  throw cet::exception("BeamlineChannelMap")
119  << "Requested online digitizer channel number " << channel << " unknown.";
120  return fDigitOnlineToOffline.at(channel).GetDetectorID();
121 }
122 
123 // -----------------------------------------------------------------------
125  if (!fDigitOnlineToOffline.count(channel))
126  throw cet::exception("BeamlineChannelMap")
127  << "Requested online digitizer channel number " << channel << " unknown.";
128  return fDigitOnlineToOffline.at(channel);
129 }
130 
131 // -----------------------------------------------------------------------
133  if (!fDigitOfflineToOnline.count(channel))
134  throw cet::exception("BeamlineChannelMap")
135  << "Requested offline digitizer channel " << channel << " unknown.";
136  return fDigitOfflineToOnline.at(channel);
137 }
138 
139 // -----------------------------------------------------------------------
141  return DetectorID(BeamlineSystem::WC, detector);
142 }
143 
144 // -----------------------------------------------------------------------
147 }
148 
149 // -----------------------------------------------------------------------
150 std::vector<SystemID> beamlineutil::BeamlineChannelMap::SystemIDs() const {
151  std::vector<SystemID> systemIDs;
152  for (const auto& online : fDigitOnlineToOffline)
153  if (std::find(systemIDs.begin(), systemIDs.end(), online.second.GetSystemID()) == systemIDs.end())
154  systemIDs.emplace_back(online.second.System);
155  return systemIDs;
156 }
157 
158 // -----------------------------------------------------------------------
159 std::vector<DetectorID> beamlineutil::BeamlineChannelMap::DetectorIDs() const {
160  std::vector<DetectorID> detectorIDs;
161  for (const auto& online : fDigitOnlineToOffline)
162  if (std::find(detectorIDs.begin(), detectorIDs.end(), online.second.GetDetectorID()) == detectorIDs.end())
163  detectorIDs.emplace_back(online.second.System, online.second.Detector);
164  return detectorIDs;
165 }
166 
167 // -----------------------------------------------------------------------
168 std::vector<ChannelID> beamlineutil::BeamlineChannelMap::ChannelIDs() const {
169  std::vector<ChannelID> channelIDs;
170  for (const auto& online : fDigitOnlineToOffline)
171  if (std::find(channelIDs.begin(), channelIDs.end(), online.second) == channelIDs.end())
172  channelIDs.push_back(online.second);
173  return channelIDs;
174 }
175 
DetectorID TrigDetector() const
Offline DetectorID for trigger.
std::vector< SystemID > SystemIDs() const
All the SystemIDs in this channel mapping.
#define DEFINE_ART_SERVICE(svc)
Definition: ServiceMacros.h:88
std::vector< ChannelID > ChannelIDs() const
All the ChannelIDs in this channel mapping.
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::map< ChannelID, unsigned int > fDigitOfflineToOnline
unsigned int OnlineDigitChannel(ChannelID channel) const
Online digiziter channel number for this offline ChannelID.
void FillBeamlineChannels(const fhicl::ParameterSet &map)
T get(std::string const &key) const
Definition: ParameterSet.h:231
bool ActiveDigitChannel(unsigned int channel) const
Enquire whether this online digitizer channel is active.
DetectorID DigitDetector(unsigned int channel) const
Offline DetectorID for this online digitizer channel.
std::vector< DetectorID > DetectorIDs() const
All the DetectorIDs in this channel mapping.
std::map< unsigned int, ChannelID > fDigitOnlineToOffline
SystemID DigitSystem(unsigned int channel) const
Offline SystemID for this online digitizer channel.
ChannelID DigitChannel(unsigned int channel) const
Offline ChannelID for this online digitizer channel.
const std::map< ToFChannel, std::string > ToFChannelNames
const std::map< ToFCounter, std::string > ToFCounterNames
Channel mapping service which may be used to interpret the channels which are read out by the various...
BeamlineChannelMap(fhicl::ParameterSet const &pset)
DetectorID WCDetector(unsigned int detector) const
Offline DetectorID for this online WC detector.