26 using std::istringstream;
39 const string myname =
"test_StandardAdcWireBuildingService: ";
41 cout << myname <<
"NDEBUG must be off." <<
endl;
44 string line =
"-----------------------------";
46 cout << myname << line <<
endl;
47 cout << myname <<
"Create top-level FCL." <<
endl;
49 std::ostringstream oss;
50 oss <<
"#include \"services_dune.fcl\"" <<
endl;
51 oss <<
"services: @local::dune35t_services_legacy" <<
endl;
52 oss <<
"services.AdcWireBuildingService: {" <<
endl;
53 oss <<
" service_provider: StandardAdcWireBuildingService" <<
endl;
54 oss <<
" LogLevel: " << a_LogLevel <<
endl;
58 cout << myname << line <<
endl;
60 cout << myname <<
"Create a response function." <<
endl;
61 const int nsigshape = 10;
63 for (
unsigned int isig=0; isig<5; ++isig ) sigshape.push_back(fac*isig);
64 for (
unsigned int isig=0; isig<5; ++isig ) sigshape.push_back(-sigshape.at(5-isig-1));
65 assert( sigshape.size() == nsigshape );
67 cout << myname << line <<
endl;
68 cout << myname <<
"Create digits." <<
endl;
69 const unsigned int ndig = 4;
70 const unsigned int ntrk = 3;
71 cout << myname <<
" Digit count: " << ndig <<
endl;
72 cout << myname <<
" Track count: " << ntrk <<
endl;
73 std::vector<raw::RawDigit> digits;
75 unsigned int sigoff[ntrk][ndig];
88 unsigned int nsig = 80;
89 float ped[ndig] = {2000.2, 2000.4, 2001.0, 1999.5};
90 unsigned int chan[ndig] = {120, 121, 122, 123};
93 for (
unsigned int idig=0; idig<ndig; ++idig ) {
94 cout << myname <<
" Digit " << idig <<
endl;
95 for (
int isig=0; isig<10; ++isig ) {
96 sigsin[sigoff[0][idig]+isig] += sigshape[isig];
97 sigsin[sigoff[1][idig]+isig] += sigshape[isig];
98 sigsin[sigoff[2][idig]+isig] += sigshape[isig];
100 assert(sigsin.size() == nsig);
102 for (
unsigned int isig=0; isig<nsig; ++isig) {
103 AdcSignal sig = sigsin[isig] + ped[idig];
105 if ( sig > 0.0 ) adc =
int(sig+0.5);
106 if ( adc > 4095 ) adc = 4095;
107 adcsin.push_back(adc);
109 assert(adcsin.size() == nsig);
111 dig.SetPedestal(ped[idig]);
112 cout << myname <<
" Compressed size: " << dig.NADC() <<
endl;
113 cout << myname <<
" Uncompressed size: " << dig.Samples() <<
endl;
114 cout << myname <<
" Pedestal: " << dig.GetPedestal() <<
endl;
115 cout << myname <<
" Channel: " << dig.Channel() <<
endl;
116 assert(dig.Samples() == nsig);
117 assert(dig.Channel() == chan[idig]);
118 assert(dig.GetPedestal() == ped[idig]);
120 rois.push_back(
AdcRoi(sigoff[0][idig], sigoff[0][idig]+nsigshape));
121 rois.push_back(
AdcRoi(sigoff[1][idig], sigoff[1][idig]+nsigshape));
122 rois.push_back(
AdcRoi(sigoff[2][idig], sigoff[2][idig]+nsigshape));
123 cout << myname <<
" ROI count: " << rois.size() <<
endl;
124 for (
const AdcRoi& roi : rois ) {
125 cout << myname <<
" (" << roi.first <<
", " << roi.second <<
")" <<
endl;
127 cout << myname <<
" ROI count: " << rois.size() <<
endl;
133 acd.
digit = &digits.back();
135 cout << myname <<
" Moved data channel: " << chan[idig] <<
" ?= " << acdMoved.
channel()
139 cout << myname << line <<
endl;
140 cout << myname <<
"Fetch wire building service." <<
endl;
142 hwib->
print(cout, myname);
144 cout << myname << line <<
endl;
145 cout << myname <<
"Build wires." <<
endl;
148 for ( AdcChannelDataMap::value_type& iacd : acds ) {
150 assert( acd.
channel() == iacd.first );
152 int rstat = hwib->
build(acd, &wires);
153 cout << myname <<
"Channel: " << acd.
channel()
154 <<
", # samples: " << acd.
samples.size()
155 <<
", # ROI: " << acd.
rois.size()
156 <<
", wire: " << acd.
wire 157 <<
", " << &(wires.back()) << endl;
158 assert( rstat == 0 );
159 cout << myname <<
" Size of Wire: " <<
sizeof(wires[0]) << endl;
160 for (
unsigned int iwir=0; iwir<wires.size(); ++iwir ) {
161 cout << myname <<
" Wire " << iwir <<
": " << &(wires[iwir])
162 <<
" is for channel " << wires[iwir].Channel() <<
endl;
166 cout << myname << line <<
endl;
167 cout << myname <<
"Check wires." <<
endl;
168 cout << myname <<
"Wire count: " << wires.size() <<
endl;
169 assert( wires.size() == ndig );
170 for (
unsigned int idig=0; idig<ndig; ++idig ) {
171 const Wire& wire = wires[idig];
173 cout << myname <<
" Wire " << idig <<
endl;
174 cout << myname <<
" Channel " << wire.
Channel() <<
endl;
175 cout << myname <<
" Signal count: " << wire.
NSignal() <<
endl;
177 cout << myname <<
" Wire: " << acd.
wire <<
" ?= " << &(wires[idig]) << endl;
184 cout << myname << line <<
endl;
185 cout << myname <<
"Done." <<
endl;
194 istringstream ssarg(argv[1]);
std::vector< AdcCount > AdcCountVector
size_type n_ranges() const
Returns the internal list of non-void ranges.
Collection of charge vs time digitized from a single readout channel.
size_type size() const
Returns the size of the vector.
ChannelID_t Channel() const
DAQ channel this raw data was read from.
std::pair< AdcIndex, AdcIndex > AdcRoi
const raw::RawDigit * digit
static void load_services(std::string const &config)
Q_EXPORT QTSManip setprecision(int p)
virtual int build(AdcChannelData &data, WireVector *wires) const =0
void setChannelInfo(ChannelInfoPtr pchi)
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
int main(int argc, char *argv[])
const RegionsOfInterest_t & SignalROI() const
Returns the list of regions of interest.
Q_EXPORT QTSManip setw(int w)
std::vector< AdcRoi > AdcRoiVector
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const =0
int test_StandardAdcWireBuildingService(int a_LogLevel=1)
void line(double t, double *p, double &x, double &y, double &z)
Class holding the regions of interest of signal from a channel.
std::vector< AdcSignal > AdcSignalVector
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
vector< unsigned int > IndexVector
QTextStream & endl(QTextStream &s)
std::size_t NSignal() const
Returns the number of time ticks, or samples, in the channel.