211 if(m_eventStat.m_events<=0)
return StatusCode::SUCCESS;
212 const auto & w13 = std::setw(13);
213 const auto & p5 = std::setprecision(5);
214 const auto topNtail=[](
const std::string &
str){
return "|" +
str +
"|";};
215 const std::string lineSeparator(83,
'-');
216 const std::string spaceSeparator(83,
' ');
217 std::stringstream
out;
219 out<<topNtail(lineSeparator)<<
"\n";
220 out<<
"| TrackClusterAssValidation statistic for charge truth particles with |\n";
221 out<<topNtail(spaceSeparator)<<
"\n";
222 out<<
"| pT >="<<w13<<p5<<
m_ptcut<<
" MeV"<<
" |\n";
227 out<<
"| max vertex radius <="<<w13<<p5<<
m_rmax<<
" mm"<<
" |\n";
228 out<<
"| min vertex radius >="<<w13<<p5<<
m_rmin<<
" mm"<<
" |\n";
229 out<<
"| particles pdg ="<<std::setw(8)<<
m_pdg<<
" |\n";
231 auto yesNo=[](
const bool predicate){
return predicate ?
"yes" :
"no ";};
232 out<<
"| use Pixels information "<<yesNo(
m_usePIX)<<
" |\n";
233 out<<
"| use SCT information "<<yesNo(
m_useSCT)<<
" |\n";
234 out<<
"| use TRT information "<<yesNo(
m_useTRT)<<
" |\n";
236 out<<topNtail(spaceSeparator)<<
"\n";
239 auto incrementArray=[](
auto &
array,
const int idx){
for (
int j{};j!=NRegions;++j)
array[
idx][j] +=
array[
idx+1][j];};
240 for(
int i=48;
i>=0; --
i) {
241 m_eventStat.m_particleClusters [
i] +=m_eventStat.m_particleClusters [
i+1];
242 incrementArray(m_eventStat.m_particleClustersBTE,
i);
243 m_eventStat.m_particleSpacePoints [
i] +=m_eventStat.m_particleSpacePoints [
i+1];
244 incrementArray(m_eventStat.m_particleSpacePointsBTE,
i);
246 auto coerceToOne=[](
const double & initialVal)->
double {
return (initialVal<1.) ? 1. : initialVal; };
253 double pa = coerceToOne(m_eventStat.m_particleClusters[0]);
254 std::array<double, 10> pc2ff{};
255 size_t clusterIdx = 2;
256 for (
auto & thisCluster: pc2ff){
257 thisCluster =
double(m_eventStat.m_particleClusters[ clusterIdx++ ])/ pa;
260 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][
Barrel]);
261 std::array<double, 10> pcBarrel2ff{};
262 size_t clusterBarrelIdx = 2;
263 for (
auto & thisClusterB: pcBarrel2ff){
264 thisClusterB =
double(m_eventStat.m_particleClustersBTE[ clusterBarrelIdx++ ][
Barrel])/ pa;
267 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Transition]);
268 std::array<double, 10> pcTransition2ff{};
269 size_t clusterTransitionIdx = 2;
270 for (
auto & thisClusterT: pcTransition2ff){
271 thisClusterT =
double(m_eventStat.m_particleClustersBTE[ clusterTransitionIdx++ ][Transition])/ pa;
274 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][
Endcap]);
275 std::array<double, 10> pcEndcap2ff{};
276 size_t clusterEndcapIdx = 2;
277 for (
auto & thisClusterE: pcEndcap2ff){
278 thisClusterE =
double(m_eventStat.m_particleClustersBTE[ clusterEndcapIdx++ ][
Endcap])/ pa;
281 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][3]);
282 std::array<double, 10> pcFwd2ff{};
283 size_t clusterFwdIdx = 2;
284 for (
auto & thisClusterD: pcFwd2ff){
285 thisClusterD =
double(m_eventStat.m_particleClustersBTE[ clusterFwdIdx++ ][Forward])/ pa;
291 pa = coerceToOne(m_eventStat.m_particleSpacePoints[0]);
292 std::array<double, 10> sp2ff{};
293 size_t spacepointIdx = 2;
294 for (
auto & thisSpacepoint: sp2ff){
295 thisSpacepoint =
double(m_eventStat.m_particleSpacePoints[ spacepointIdx++ ])/ pa;
298 pa = coerceToOne(m_eventStat.m_particleSpacePointsBTE[0][
Barrel]);
299 std::array<double, 10> spBarrel2ff{};
300 size_t spacepointBarrelIdx = 2;
301 for (
auto & thisSpacepoint: spBarrel2ff){
302 thisSpacepoint =
double(m_eventStat.m_particleSpacePointsBTE[ spacepointBarrelIdx++ ][
Barrel])/ pa;
305 pa = coerceToOne(m_eventStat.m_particleSpacePointsBTE[0][Transition]);
306 std::array<double, 10> spTransition2ff{};
307 size_t spacepointTransitionIdx = 2;
308 for (
auto & thisSpacepoint: spTransition2ff){
309 thisSpacepoint =
double(m_eventStat.m_particleSpacePointsBTE[ spacepointTransitionIdx++ ][Transition])/ pa;
312 pa = coerceToOne(m_eventStat.m_particleSpacePointsBTE[0][
Endcap]);
313 std::array<double, 10> spEndcap2ff{};
314 size_t spacepointEndcapIdx = 2;
315 for (
auto & thisSpacepoint: spEndcap2ff){
316 thisSpacepoint =
double(m_eventStat.m_particleSpacePointsBTE[ spacepointEndcapIdx++ ][
Endcap])/ pa;
319 pa = coerceToOne(m_eventStat.m_particleSpacePointsBTE[0][Forward]);
320 std::array<double, 10> spFwd2ff{};
321 size_t spacepointFwdIdx = 2;
322 for (
auto & thisSpacepoint: spFwd2ff){
323 thisSpacepoint =
double(m_eventStat.m_particleSpacePointsBTE[ spacepointFwdIdx++ ][Forward])/ pa;
325 auto w8=std::setw(8);
326 out<<
"| Probability for such charge particles to have some number silicon |\n";
327 out<<
"| clusters | space points |\n";
328 out<<
"| Total Barrel Transi Endcap Forward | Total Barrel Transi Endcap Forward |\n";
331 out<<
"| >= "<<
idx+2<< std::string((
idx<8)?
" ":
" ")
333 <<w8<<p5<<pcBarrel2ff[
idx]
334 <<w8<<p5<<pcTransition2ff[
idx]
335 <<w8<<p5<<pcEndcap2ff[
idx]
336 <<w8<<p5<<pcFwd2ff[
idx]<<
" | "
339 <<w8<<p5<<spBarrel2ff[
idx]
340 <<w8<<p5<<spTransition2ff[
idx]
341 <<w8<<p5<<spEndcap2ff[
idx]
342 <<w8<<p5<<spFwd2ff[
idx]
346 out<<topNtail(spaceSeparator)<<
"\n";
347 out<<
"| Additional cuts for truth particles are |\n";
348 out<<
"| number silicon clusters >="<<w13<<
m_clcut<<
" |\n";
350 out<<
"| number space points >="<<w13<<
m_spcut<<
" |\n";
352 pa = coerceToOne(m_eventStat.m_particleClusters[0]);
353 out<<
"| Probability find truth particles with this cuts is "<<w8<<p5<<
double(m_eventStat.m_events)/pa<<
" |\n";
354 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][
Barrel]);
355 out<<
"| For barrel region "<<w8<<p5<<
double(m_eventStat.m_eventsBTE[
Barrel])/pa<<
" |\n";
356 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Transition]);
357 out<<
"| For transition region "<<w8<<p5<<
double(m_eventStat.m_eventsBTE[Transition])/pa<<
" |\n";
358 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][
Endcap]);
359 out<<
"| For endcap region "<<w8<<p5<<
double(m_eventStat.m_eventsBTE[
Endcap])/pa<<
" |\n";
360 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Forward]);
361 out<<
"| For forward region "<<w8<<p5<<
double(m_eventStat.m_eventsBTE[Forward])/pa<<
" |\n";
363 pa = coerceToOne(m_eventStat.m_nclustersNegBP);
364 double ratio =
double(m_eventStat.m_nclustersPosBP)/pa;
366 out<<
"| Ratio barrel pixels clusters for +/- particles ="<<w8<<p5<<
ratio<<
" +-"<<w8<<p5<<
eratio<<
" |\n";
367 pa = coerceToOne(m_eventStat.m_nclustersNegEP);
370 out<<
"| Ratio endcap pixels clusters for +/- particles ="<<w8<<p5<<
ratio<<
" +-"<<w8<<p5<<
eratio<<
" |\n";
371 pa = coerceToOne(m_eventStat.m_nclustersNegBS);
374 out<<
"| Ratio barrel SCT clusters for +/- particles ="<<w8<<p5<<
ratio<<
" +-"<<w8<<p5<<
eratio<<
" |\n";
375 pa = coerceToOne(m_eventStat.m_nclustersNegES);
378 out<<
"| Ratio endcap SCT clusters for +/- particles ="<<w8<<p5<<
ratio<<
" +-"<<w8<<p5<<
eratio<<
" |\n";
379 pa =
double(m_eventStat.m_eventsNEG);
if(pa < 1.) pa = 1.;
382 out<<
"| Number truth particles and +/- ratio ="<<std::setw(10)<<m_eventStat.m_events<<w8<<p5<<
ratio<<
" +-"<<w8<<p5<<
eratio<<
" |\n";
384 if(m_eventStat.m_nclustersPTOT!=0)
ratio =
double(m_eventStat.m_nclustersPTOTt)/
double(m_eventStat.m_nclustersPTOT);
386 out<<
"| Number pix clusters, truth clusters and ratio = "
387 <<std::setw(10)<<m_eventStat.m_nclustersPTOT
388 <<std::setw(10)<<m_eventStat.m_nclustersPTOTt
389 <<std::setw(12)<<std::setprecision(5)<<
ratio<<
" |\n";
391 if(m_eventStat.m_nclustersSTOT!=0)
ratio =
double(m_eventStat.m_nclustersSTOTt)/
double(m_eventStat.m_nclustersSTOT);
392 out<<
"| Number sct clusters, truth clusters and ratio = "
393 <<std::setw(10)<<m_eventStat.m_nclustersSTOT
394 <<std::setw(10)<<m_eventStat.m_nclustersSTOTt
395 <<std::setw(12)<<std::setprecision(5)<<
ratio<<
" |\n";
397 out<<
"|-----------------------------------------------------------------------------------|\n\n";
402 int n = 47-(
t->key().size());
403 std::string
s1;
for(
int i=0;
i<
n; ++
i)
s1.append(
" ");
s1.append(
"|");
406 out<<
"|-----------------------------------------------------------------------------------|\n";
407 out<<
"| Statistic for "<<(
t->key())<<
s1<<
"\n";
409 double ne =
double(m_eventStat.m_events);
if(ne < 1.) ne = 1.;
410 double ef [6];
for(
int i=0;
i!=6; ++
i)
ef [
i] =
double(m_trackCollectionStat[
nc].m_efficiency [
i]) /ne;
411 double ef0[6];
for(
int i=0;
i!=6; ++
i) ef0[
i] =
double(m_trackCollectionStat[
nc].m_efficiencyN [
i][0])/ne;
412 double ef1[6];
for(
int i=0;
i!=6; ++
i) ef1[
i] =
double(m_trackCollectionStat[
nc].m_efficiencyN [
i][1])/ne;
413 double ef2[6];
for(
int i=0;
i!=6; ++
i) ef2[
i] =
double(m_trackCollectionStat[
nc].m_efficiencyN [
i][2])/ne;
416 using EffArray_t = std::array<double, 6>;
418 auto makeEffArray = [](
const auto & threeDimArray,
const size_t secondIdx,
const size_t thirdIdx,
const double denom){
421 auto invDenom = 1./
denom;
423 entry = threeDimArray[
idx++][secondIdx][thirdIdx]*invDenom;
428 const auto & efficiencyArrayInput = m_trackCollectionStat[
nc].m_efficiencyBTE;
430 double neBTE = coerceToOne(m_eventStat.m_eventsBTE[
Barrel]);
431 const EffArray_t efB0 = makeEffArray(efficiencyArrayInput,0,
Barrel,neBTE);
432 const EffArray_t efB1 = makeEffArray(efficiencyArrayInput,1,
Barrel,neBTE);
433 const EffArray_t efB2 = makeEffArray(efficiencyArrayInput,2,
Barrel,neBTE);
434 const EffArray_t efB3 = makeEffArray(efficiencyArrayInput,3,
Barrel,neBTE);
435 const EffArray_t efB4 = makeEffArray(efficiencyArrayInput,4,
Barrel,neBTE);
437 neBTE = coerceToOne(m_eventStat.m_eventsBTE[Transition]);
438 const EffArray_t efT0 = makeEffArray(efficiencyArrayInput,0,Transition,neBTE);
439 const EffArray_t efT1 = makeEffArray(efficiencyArrayInput,1,Transition,neBTE);
440 const EffArray_t efT2 = makeEffArray(efficiencyArrayInput,2,Transition,neBTE);
441 const EffArray_t efT3 = makeEffArray(efficiencyArrayInput,3,Transition,neBTE);
442 const EffArray_t efT4 = makeEffArray(efficiencyArrayInput,4,Transition,neBTE);
444 neBTE = coerceToOne(m_eventStat.m_eventsBTE[
Endcap]);
445 const EffArray_t efE0 = makeEffArray(efficiencyArrayInput,0,
Endcap,neBTE);
446 const EffArray_t efE1 = makeEffArray(efficiencyArrayInput,1,
Endcap,neBTE);
447 const EffArray_t efE2 = makeEffArray(efficiencyArrayInput,2,
Endcap,neBTE);
448 const EffArray_t efE3 = makeEffArray(efficiencyArrayInput,3,
Endcap,neBTE);
449 const EffArray_t efE4 = makeEffArray(efficiencyArrayInput,4,
Endcap,neBTE);
451 neBTE = coerceToOne(m_eventStat.m_eventsBTE[Forward]);
452 const EffArray_t efD0 = makeEffArray(efficiencyArrayInput,0,Forward,neBTE);
453 const EffArray_t efD1 = makeEffArray(efficiencyArrayInput,1,Forward,neBTE);
454 const EffArray_t efD2 = makeEffArray(efficiencyArrayInput,2,Forward,neBTE);
455 const EffArray_t efD3 = makeEffArray(efficiencyArrayInput,3,Forward,neBTE);
456 const EffArray_t efD4 = makeEffArray(efficiencyArrayInput,4,Forward,neBTE);
459 double efrec = ef0[0]+ef0[1]+ef0[2]+ef1[0]+ef1[1]+ef2[0];
460 double efrecB = efB0[0]+efB0[1]+efB0[2]+efB1[0]+efB1[1]+efB2[0];
461 double efrecT = efT0[0]+efT0[1]+efT0[2]+efT1[0]+efT1[1]+efT2[0];
462 double efrecE = efE0[0]+efE0[1]+efE0[2]+efE1[0]+efE1[1]+efE2[0];
463 double efrecD = efD0[0]+efD0[1]+efD0[2]+efD1[0]+efD1[1]+efD2[0];
465 ne = coerceToOne(m_eventStat.m_eventsPOS);
466 double efP[6];
for(
int i=0;
i!=6; ++
i) efP[
i] =
double(m_trackCollectionStat[
nc].m_efficiencyPOS[
i])/ne;
467 ne = coerceToOne(m_eventStat.m_eventsNEG);
468 double efN[6];
for(
int i=0;
i!=6; ++
i) efN[
i] =
double(m_trackCollectionStat[
nc].m_efficiencyNEG[
i])/ne;
470 out<<
"|-----------------------------------------------------------------------------------|\n";
471 out<<
"| Probability to lose 0 1 2 3 4 >=5 clusters |\n";
472 out<<
"|-----------------------------------------------------------------------------------|\n";
474 auto formattedOutput=[&
out](
auto & effArray){
475 for (
size_t i{};
i!=6;++
i){
476 out<<std::setw(9)<<std::setprecision(4)<<effArray[
i];
481 out<<
"| For all particles ";
483 out<<
"| For + particles ";
484 formattedOutput(efP);
485 out<<
"| For - particles ";
486 formattedOutput(efN);
487 out<<
"|-----------------------------------------------------------------------------------|\n";
488 out<<
"| Barrel region |\n";
489 out<<
"| 0 wrong clusters ";
490 formattedOutput(efB0);
491 out<<
"| 1 wrong clusters ";
492 formattedOutput(efB1);
493 out<<
"| 2 wrong clusters ";
494 formattedOutput(efB2);
495 out<<
"| 3 wrong clusters ";
496 formattedOutput(efB3);
497 out<<
"| >=4 wrong clusters ";
498 formattedOutput(efB4);
499 out<<
"|-----------------------------------------------------------------------------------|\n";
500 out<<
"| Transition region |\n";
501 out<<
"| 0 wrong clusters ";
502 formattedOutput(efT0);
503 out<<
"| 1 wrong clusters ";
504 formattedOutput(efT1);
505 out<<
"| 2 wrong clusters ";
506 formattedOutput(efT2);
507 out<<
"| 3 wrong clusters ";
508 formattedOutput(efT3);
509 out<<
"| >=4 wrong clusters ";
510 formattedOutput(efT4);
511 out<<
"|-----------------------------------------------------------------------------------|\n";
512 out<<
"| Endcap region |\n";
513 out<<
"| 0 wrong clusters ";
514 formattedOutput(efE0);
515 out<<
"| 1 wrong clusters ";
516 formattedOutput(efE1);
517 out<<
"| 2 wrong clusters ";
518 formattedOutput(efE2);
519 out<<
"| 3 wrong clusters ";
520 formattedOutput(efE3);
521 out<<
"| >=4 wrong clusters ";
522 formattedOutput(efE4);
523 out<<
"|-----------------------------------------------------------------------------------|\n";
524 out<<
"| Forward region |\n";
525 out<<
"| 0 wrong clusters ";
526 formattedOutput(efD0);
527 out<<
"| 1 wrong clusters ";
528 formattedOutput(efD1);
529 out<<
"| 2 wrong clusters ";
530 formattedOutput(efD2);
531 out<<
"| 3 wrong clusters ";
532 formattedOutput(efD3);
533 out<<
"| >=4 wrong clusters ";
534 formattedOutput(efD4);
536 out<<
"|-----------------------------------------------------------------------------------|\n";
537 pa = coerceToOne(m_eventStat.m_particleClusters[0]);
538 out<<
"| Efficiency reconstruction (number lose+wrong < 3) = "
539 <<std::setw(9)<<std::setprecision(5)<<efrec
541 <<std::setw(9)<<std::setprecision(5)<<efrec*
double(m_eventStat.m_events)/pa
544 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][
Barrel]);
545 out<<
"| For barrel region = "
546 <<std::setw(9)<<std::setprecision(5)<<efrecB
548 <<std::setw(9)<<std::setprecision(5)<<efrecB*
double(m_eventStat.m_eventsBTE[
Barrel])/pa
551 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Transition]);
552 out<<
"| For transition region = "
553 <<std::setw(9)<<std::setprecision(5)<<efrecT
555 <<std::setw(9)<<std::setprecision(5)<<efrecT*
double(m_eventStat.m_eventsBTE[Transition])/pa
558 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][
Endcap]);
559 out<<
"| For endcap region = "
560 <<std::setw(9)<<std::setprecision(5)<<efrecE
562 <<std::setw(9)<<std::setprecision(5)<<efrecE*
double(m_eventStat.m_eventsBTE[
Endcap])/pa
565 pa = coerceToOne(m_eventStat.m_particleClustersBTE[0][Forward]);
566 out<<
"| For forward region = "
567 <<std::setw(9)<<std::setprecision(5)<<efrecD
569 <<std::setw(9)<<std::setprecision(5)<<efrecD*
double(m_eventStat.m_eventsBTE[Forward])/pa
573 out<<
"|-----------------------------------------------------------------------------------|\n";
574 out<<
"| Reconstructed tracks + - +/-ratio error |\n";
575 out<<
"|-----------------------------------------------------------------------------------|\n";
577 pa = coerceToOne(m_trackCollectionStat[
nc].m_ntracksNEGB);
582 <<std::setw(10)<<m_trackCollectionStat[
nc].m_ntracksPOSB
583 <<std::setw(11)<<m_trackCollectionStat[
nc].m_ntracksNEGB
584 <<std::setw(11)<<std::setprecision(5)<<
ratio
585 <<std::setw(11)<<std::setprecision(5)<<
eratio<<
" |\n";
586 pa = coerceToOne(m_trackCollectionStat[
nc].m_ntracksNEGE);
591 <<std::setw(10)<<m_trackCollectionStat[
nc].m_ntracksPOSE
592 <<std::setw(11)<<m_trackCollectionStat[
nc].m_ntracksNEGE
593 <<std::setw(11)<<std::setprecision(5)<<
ratio
594 <<std::setw(11)<<std::setprecision(5)<<
eratio<<
" |\n";
595 pa = coerceToOne(m_trackCollectionStat[
nc].m_ntracksNEGFWD);
596 ratio =
double(m_trackCollectionStat[
nc].m_ntracksPOSFWD)/pa;
600 <<std::setw(10)<<m_trackCollectionStat[
nc].m_ntracksPOSFWD
601 <<std::setw(11)<<m_trackCollectionStat[
nc].m_ntracksNEGFWD
602 <<std::setw(11)<<std::setprecision(5)<<
ratio
603 <<std::setw(11)<<std::setprecision(5)<<
eratio<<
" |\n";
610 for(
int k = 0;
k!=50; ++
k) {
611 nt+=m_trackCollectionStat[
nc].m_total[
k];
612 ft+=m_trackCollectionStat[
nc].m_fake [
k];
613 if(!kf &&
nt) kf =
k;
618 out<<
"|-----------------------------------------------------------------------------------|\n";
619 out<<
"| Fake tracks rate for different number of clusters on track |\n";
620 out<<
"|-----------------------------------------------------------------------------------|\n";
622 for(
int k = kf;
k!=kf+6; ++
k) {
623 out<<
"| >= "<<std::setw(2)<<
k<<
" ";
627 for(
int k = kf;
k!=kf+6; ++
k) {
629 out<<
"|"<<std::setw(12)<<std::setprecision(5)<<
eff<<
" ";
630 nt-=m_trackCollectionStat[
nc].m_total[
k];
631 ft-=m_trackCollectionStat[
nc].m_fake [
k];
634 out<<
"|-----------------------------------------------------------------------------------|\n";
639 return StatusCode::SUCCESS;