31 const string myname =
"test_StickyCodeMetrics: ";
33 cout << myname <<
"NDEBUG must be off." <<
endl;
36 string line =
"-----------------------------";
38 cout << myname << line <<
endl;
40 cout << myname << line <<
endl;
41 cout << myname <<
"Create data." <<
endl;
60 TH1F* ph =
new TH1F(
"hraw",
"Input ADC distribution; ADC count; # entries", 4096, 0, 4096);
61 TH1F* ph2 =
new TH1F(
"hraw2",
"Input ADC distribution; ADC count; # entries", 30, 100, 130);
63 for ( BinCounter::value_type icnt : counts ) {
65 Index nval = icnt.second;
67 for (
Index ival=0; ival<nval; ++ival ) {
73 cout << myname <<
" Bin counter count: " << nadc <<
endl;
74 cout << myname <<
" Vector count: " << vals.size() <<
endl;
75 cout << myname <<
" Histogram count: " << ph->GetEntries() <<
endl;
76 assert( vals.size() == nadc );
77 assert( ph->GetEntries() == nadc );
81 cout << myname << line <<
endl;
82 cout << myname <<
"Bin Counter evaluation." <<
endl;
85 assert( scm.getHist() == nullptr );
86 assert( ! scm.getSharedHist() );
88 cout << myname << line <<
endl;
89 cout << myname <<
"ADC samples evaluation." <<
endl;
93 cout << myname << line <<
endl;
94 cout << myname <<
"Histogram evaluation." <<
endl;
98 cout << myname << line <<
endl;
99 cout << myname <<
"Limited-range histogram evaluation." <<
endl;
103 cout << myname << line <<
endl;
104 cout << myname <<
"Bin Counter data map." <<
endl;
105 scm.getMetrics().print();
107 TCanvas* pcan =
new TCanvas;
110 cout << myname << line <<
endl;
111 cout << myname <<
"Evaluation creating histogram." <<
endl;
113 assert( scmh.evaluate(counts) == 0 );
115 scmh.getMetrics().print();
116 assert( scmh.getHist() != nullptr );
117 scmh.getHist()->Print();
118 cout << myname <<
"Histogram integral: " << scmh.getHist()->Integral() <<
endl;
119 scmh.getHist()->Draw();
120 pcan->Print(
"test.png");
121 assert(
int(scmh.getHist()->Integral()+0.1) ==
int(nadc) );
123 cout << myname << line <<
endl;
124 cout << myname <<
"Evaluation creating wide histogram." <<
endl;
126 assert( scmhw.evaluate(counts) == 0 );
128 scmhw.getMetrics().print();
129 assert( scmhw.getHist() != nullptr );
130 scmhw.getHist()->Print();
131 cout << myname <<
"Histogram integral: " << scmhw.getHist()->Integral() <<
endl;
132 scmhw.getHist()->Draw();
133 pcan->Print(
"testw.png");
134 assert(
int(scmhw.getHist()->Integral()+0.1) ==
int(nadc) );
136 cout << myname << line <<
endl;
137 cout << myname <<
"Evaluation creating narrow histogram." <<
endl;
139 assert( scmh2.evaluate(counts) == 0 );
141 scmh2.getMetrics().print();
142 assert( scmh2.getHist() != nullptr );
143 scmh2.getHist()->Print();
144 cout << myname <<
"Histogram integral: " << scmh2.getHist()->Integral() <<
endl;
145 cout << myname <<
"Histogram undrflow: " << scmh2.getHist()->GetBinContent(16) <<
endl;
146 cout << myname <<
"Histogram overflow: " << scmh2.getHist()->GetBinContent(0) <<
endl;
147 scmh2.getHist()->Draw();
148 pcan->Print(
"test2.png");
152 for (
int iadc=110; iadc<125; ++iadc ) {
153 if ( counts.find(iadc) != counts.end() ) nadc2 += counts[iadc];
155 for (
int iadc=100; iadc<110; ++iadc ) {
156 if ( counts.find(iadc) != counts.end() ) nadc2u += counts[iadc];
158 for (
int iadc=125; iadc<135; ++iadc ) {
159 if ( counts.find(iadc) != counts.end() ) nadc2o += counts[iadc];
161 cout << myname <<
"Expect integral: " << nadc2 <<
endl;
162 cout << myname <<
"Expect undrflow: " << nadc2u <<
endl;
163 cout << myname <<
"Expect overflow: " << nadc2o <<
endl;
164 assert(
int(scmh2.getHist()->Integral()+0.1) ==
int(nadc2) );
168 cout << myname << line <<
endl;
169 cout << myname <<
"Done." <<
endl;
std::vector< AdcCount > AdcCountVector
counts_as<> counts
Number of ADC counts, represented by signed short int.
void line(double t, double *p, double &x, double &y, double &z)
std::map< Index, double > BinCounter
QTextStream & endl(QTextStream &s)