81 double ApileMin = 30.;
82 double ApileMax = 400.;
83 double AinTime = 100.;
84 double digSigma = 1.6;
98 const int ncodeSize = 8;
100 int ncodeg[ncodeSize];
101 int ncodeb[ncodeSize];
102 for (
int i = 0;
i < ncodeSize;
i++) {
127 for (
int i = 0;
i < 12;
i++) {
133 for (
int ievent = 0; ievent < nEvent; ievent++) {
134 if (ievent > 5)
m_debug =
false;
136 if (ievent == 9) lPrint =
true;
137 if (ievent == 23) lPrint =
true;
138 if (ievent == 235) lPrint =
true;
139 if (ievent == 372) lPrint =
true;
140 if (ievent == 460) lPrint =
true;
141 if (ievent == 483) lPrint =
true;
142 if (ievent == 501) lPrint =
true;
143 if (ievent == 823) lPrint =
true;
144 if (ievent == 959) lPrint =
true;
145 if (ievent == 1220) lPrint =
true;
151 std::cout <<
" TileFilterTester: Start new event; ievent=" << ievent <<
", Fmode=" <<
m_filterMode <<
", Cmode="
156 double Ranflat = RandFlat::shoot();
157 iConfig = (
int) (Ranflat * Nindex);
164 for (
int ipileup = 0; ipileup <
m_nPileup; ipileup++) {
165 double Ranflat = RandFlat::shoot();
166 m_ampVec[ipileup + 1] = ApileMin + Ranflat * (ApileMax - ApileMin);
171 for (
int iAmp = 0; iAmp <
m_nAmp; iAmp++) {
172 std::cout <<
" i=" << iAmp <<
", ipar=" <<
m_iAmpVec[iAmp] <<
", Amp=" <<
m_ampVec[iAmp] << std::endl;
179 std::vector<float> digits(Ndig);
180 HepVector Param(Nparam);
181 HepMatrix SPD(Nparam, Ndig);
183 double chisqGen = 0.;
184 for (
int i = 1;
i < Nparam;
i++) {
189 HepMatrix SDP = SPD.T();
191 digitsHep = SDP * Param;
195 double sigmaGen = 1.6;
196 for (
int idig = 0; idig < Ndig; idig++) {
197 double rang = RandGauss::shoot();
198 double noise = rang * sigmaGen;
199 chisqGen += rang * rang;
200 digits[idig] = digitsHep[idig] +
noise;
208 if (lPrint) std::cout <<
"TileFilterTester.GenEvents: ievent=" << ievent <<
", icode=" << icode << std::endl;
211 std::vector<int>& vcross = tResult.getVcrossRef();
213 int ncrrec = vcross.size();
214 NampFinal[ncrrec] += 1;
215 int& iFitIndex = tResult.getFitIndexRef();
218 double Qerr = sigmaGen * fitterErr[1];
221 bool lconfigOK = (ncrrec == ncrgen);
222 if (iConfig != iFitIndex) lconfigOK =
false;
224 for (
int icr = 0; icr < ncrgen; icr++) {
225 if (
m_iAmpVec[icr] != vcross[icr]) lconfigOK =
false;
232 if (nPrint2 > 100) lPrint2 =
false;
234 std::cout << std::endl;
235 std::cout <<
" Discrepancy: ievent=" << ievent <<
", ncrgen=" << ncrgen <<
", ncrrec=" << ncrrec <<
", icode="
236 << icode <<
" iConfig=" << iConfig <<
", iFitIndex=" << iFitIndex << std::endl;
237 std::cout <<
" icrGen=";
238 for (
int i = 0;
i < ncrgen;
i++) {
241 std::cout <<
" icrRec=";
242 for (
int i = 0;
i < ncrrec;
i++) {
243 std::cout <<
" " << vcross[
i];
245 double& chisq = tResult.getChi2Ref();
246 std::cout <<
" (chi2=" << chisq <<
", chi2G=" << chisqGen <<
")" << std::endl;
248 for (
int iAmp = 0; iAmp <
m_nAmp; iAmp++) {
249 std::cout <<
" i=" << iAmp <<
", ipar=" <<
m_iAmpVec[iAmp] <<
", Amp=" <<
m_ampVec[iAmp] << std::endl;
253 std::cout <<
" digits=";
254 for (
int idig = 0; idig < Ndig; idig++) {
255 std::cout <<
" " << std::setw(6) << std::setprecision(2) << digits[idig];
257 std::cout << std::endl;
258 tResult.printFitParam();
260 std::cout << std::endl;
261 if (nPrint > 10) lPrint =
false;
267 tResult.printFitParam();
268 if (nPrint2 > 20) lPrint =
false;
270 double& chisq = tResult.getChi2Ref();
272 HepVector& fitParam = tResult.getParamRef();
273 HepVector& fitErr = tResult.getErrRef();
274 double diff_ch = fitParam[1] -
m_ampVec[0];
275 int Npar = fitParam.num_row();
280 if (icode >= 0) ncode[icode] += 1;
282 D2sum += diff_ch * diff_ch;
287 if (icode >= 0) ncodeg[icode] += 1;
289 D2sumg += diff_ch * diff_ch;
293 if (ncrrec > ncrgen) Nover += 1;
294 if (ncrrec < ncrgen) Nunder += 1;
295 if (ncrrec == ncrgen) Nmixed += 1;
296 if (icode >= 0) ncodeb[icode] += 1;
297 D2sumb += diff_ch * diff_ch;
302 std::cout <<
"TileFilterTester event: Npar=" << Npar <<
", diff_ch =" << std::setw(6) << std::setprecision(2)
303 << diff_ch <<
" +-" << fitErr[1] <<
", chi2=" << chisq <<
", chi2Gen=" << chisqGen << std::endl << std::endl;
306 std::cout << std::endl;
307 std::cout <<
" *** TileFilterTester Summary: Fmode=" <<
m_filterMode <<
", Ftest=" <<
m_filterTest <<
", NparamGen ="
308 <<
m_nPileup + 2 <<
", Cmode=" <<
m_cMode <<
", Nevent=" << nEvent << std::endl;
312 std::cout <<
" Cuts applied: rchisqCut=" << rchisqCut <<
", chiCut=" << chiCut << std::endl;
313 std::cout <<
" ApileMin=" << ApileMin <<
", ApileMax=" << ApileMax <<
", AmpInTime=" << AinTime << std::endl;
314 std::cout <<
" Compare difference (rec-gen) for: Ngen=" << Ngen <<
", Nrec=" << Nrec << std::endl;
316 int den = Nrec ? Nrec : 1;
317 double rm = Dsum / den;
318 double errsig =
pow(E2sum / den, 0.5);
319 double rsig =
pow(D2sum / den, 0.5);
321 std::cout <<
" All configurations: N=" << std::setw(7) << Nrec <<
", Diff =" << std::setw(6)
322 << std::setprecision(3) << rm <<
", sig =" << rsig <<
" (errsig=" << errsig <<
")" << std::endl;
325 double rmg = Dsumg / Nrecg;
326 double errsigg =
pow(E2sumg / Nrecg, 0.5);
327 double rsigg =
pow(D2sumg / Nrecg, 0.5);
329 std::cout <<
" Good configurations: N=" << std::setw(7) << Nrecg <<
", Diff =" << std::setw(6)
330 << std::setprecision(3) << rmg <<
", sig =" << rsigg <<
" (errsig=" << errsigg <<
")" << std::endl;
334 double rmb = Dsumg / Nrecb;
335 double errsigb =
pow(E2sumb / Nrecb, 0.5);
336 double rsigb =
pow(D2sumb / Nrecb, 0.5);
339 std::cout <<
" Bad configurations: N=" << std::setw(7) << Nrecb <<
", Diff =" << std::setw(6)
340 << std::setprecision(3) << rmb <<
", sig =" << rsigb <<
" (errsig=" << errsigb <<
")" << std::endl;
343 std::cout <<
" Nover=" << Nover <<
", Nunder=" << Nunder <<
", Nmixed=" << Nmixed << std::endl;
345 std::cout << std::endl;
347 for (
int i = 0;
i < ncodeSize;
i++) {
348 std::cout <<
" icode=" <<
i <<
" ==> ncnt=" << std::setw(7) << ncode[
i] <<
", ncntg=" << ncodeg[
i]
349 <<
", ncntb=" << ncodeb[
i] << std::endl;
351 std::cout << std::endl;
353 std::cout <<
" Number of final amplitudes:" << std::endl;
354 for (
int i = 0;
i < 12;
i++) {
355 if (NampFinal[
i] != 0) std::cout <<
" Namp=" <<
i <<
" =>" << NampFinal[
i] <<
" events" << std::endl;