44 const string myname =
"test_StandardRawDigitExtractService: ";
46 cout << myname <<
"NDEBUG must be off." <<
endl;
49 string line =
"-----------------------------";
51 cout << myname << line <<
endl;
52 cout << myname <<
"Create top-level FCL." <<
endl;
55 std::ostringstream oss;
56 oss <<
"#include \"dataprep_tools.fcl\"" <<
endl;
57 oss <<
"services.RawDigitExtractService: {" <<
endl;
58 oss <<
" service_provider: StandardRawDigitExtractService" <<
endl;
59 oss <<
" LogLevel: " << loglevel <<
endl;
60 oss <<
" DigitReadTool: digitReader" <<
endl;
61 oss <<
" PedestalOption: 1" <<
endl;
62 oss <<
" FlagStuckOff: true" <<
endl;
63 oss <<
" FlagStuckOn: true" <<
endl;
70 cout << myname << line <<
endl;
71 cout << myname <<
"Create a raw digit." <<
endl;
75 for (
int i=0; i<10; ++i ) sigsin.push_back(fac*i);
76 for (
int i=10; i>=0; --i ) sigsin.push_back(fac*i);
77 for (
int i=19; i>=0; --i ) sigsin.push_back(-sigsin[i]);
78 unsigned int nsig = 41;
79 assert(sigsin.size() == nsig);
81 unsigned int isig_stucklo = 5;
82 unsigned int isig_stuckhi = 15;
83 for (
unsigned int isig=0; isig<nsig; ++isig) {
86 if ( sig > 0.0 ) adc =
int(sig+0.5);
87 if ( adc > 4095 ) adc = 4095;
89 if ( isig == isig_stucklo ) adc = adchigh;
90 if ( isig == isig_stuckhi ) adc = adchigh + lowbits;
91 adcsin.push_back(adc);
93 assert(adcsin.size() == nsig);
94 unsigned int chan = 123;
97 cout << myname <<
" Compressed size: " << dig.NADC() <<
endl;
98 cout << myname <<
" Uncompressed size: " << dig.Samples() <<
endl;
99 cout << myname <<
" Pedestal: " << dig.GetPedestal() <<
endl;
100 cout << myname <<
" Channel: " << dig.Channel() <<
endl;
101 assert(dig.Samples() == nsig);
102 assert(dig.Channel() == chan);
103 assert(dig.GetPedestal() == ped);
105 cout << myname << line <<
endl;
106 cout << myname <<
"Create the expected flag vector." <<
endl;
108 for (
unsigned int isig=0; isig<nsig; ++isig) {
112 else if ( adc >= 4095 ) expflags[isig] =
AdcOverflow;
113 else if ( adclow == 0 ) expflags[isig] =
AdcStuckOff;
114 else if ( adclow == lowbits ) expflags[isig] =
AdcStuckOn;
117 cout << myname << line <<
endl;
118 cout << myname <<
"Fetch raw digit extract service." <<
endl;
122 cout << myname << line <<
endl;
123 cout << myname <<
"Extract data from digit." <<
endl;
126 assert( hrdx->
extract(acd) == 0 );
132 cout << myname <<
"Output raw vector size: " << sigs.size() <<
endl;
133 cout << myname <<
"Output prep vector size: " << sigs.size() <<
endl;
134 cout << myname <<
" Output flags size: " << flags.size() <<
endl;
135 cout << myname <<
" Pedestal: " << pedout <<
endl;
136 assert( raw.size() == nsig );
137 assert( sigs.size() == nsig );
138 assert( flags.size() == nsig );
139 assert( chanout == chan );
140 assert( pedout == ped );
141 for (
unsigned int isig=0; isig<nsig; ++isig ) {
142 cout <<
setw(4) << isig <<
": " <<
setw(4) << adcsin[isig]
144 <<
" [" << flags[isig] <<
"]" <<
endl;
145 if ( flags[isig] ==
AdcGood ) assert(
sigequal(sigs[isig], sigsin[isig]) );
146 assert( flags[isig] == expflags[isig] );
std::vector< AdcCount > AdcCountVector
Collection of charge vs time digitized from a single readout channel.
std::vector< AdcFlag > AdcFlagVector
const AdcFlag AdcUnderflow
const raw::RawDigit * digit
static void load_services(std::string const &config)
Q_EXPORT QTSManip setprecision(int p)
const AdcFlag AdcOverflow
Q_EXPORT QTSManip setw(int w)
const AdcFlag AdcStuckOff
void line(double t, double *p, double &x, double &y, double &z)
std::vector< AdcSignal > AdcSignalVector
bool sigequal(AdcSignal sig1, AdcSignal sig2)
QTextStream & endl(QTextStream &s)