22 (
const std::string&
name,ISvcLocator* pSvcLocator)
24 m_spacepointsSCTname(
"SCT_SpacePoints"),
25 m_spacepointsPixelname(
"PixelSpacePoints"),
26 m_spacepointsOverlapname(
"OverlapSpacePoints"),
27 m_clustersSCTname(
"SCT_Clusters"),
28 m_clustersPixelname(
"PixelClusters"),
29 m_clustersTRTname(
"TRT_DriftCircles"),
30 m_truth_locationPixel(
"PRD_MultiTruthPixel" ),
31 m_truth_locationSCT(
"PRD_MultiTruthSCT" ),
32 m_truth_locationTRT(
"PRD_MultiTruthTRT" )
150 std::vector<SG::ReadHandle<PRD_MultiTruthCollection> > read_handle;
151 read_handle.reserve(3);
154 if (not read_handle.back().isValid()) {
156 return StatusCode::FAILURE;
158 event_data.
m_truthPIX = &(*read_handle.back());
163 if (not read_handle.back().isValid()) {
165 return StatusCode::FAILURE;
167 event_data.
m_truthSCT = &(*read_handle.back());
172 if (not read_handle.back().isValid()) {
174 return StatusCode::FAILURE;
176 event_data.
m_truthTRT = &(*read_handle.back());
193 for (
unsigned int i=0;
i< m_trackCollectionStat.size(); ++
i ) {
203 return StatusCode::SUCCESS;
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";
238 enum Regions{Barrel, Transition, Endcap, Forward, NRegions};
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;
652 out<<
"|--------------------------------------------------------------------------------------------------------------------|\n";
654 n = 65-
t->key().size();
655 std::string s1;
for(
int i=0;
i<
n; ++
i) s1.append(
" "); s1.append(
"|");
656 out<<
"| Location of input tracks | "<<
t->key()<<s1<<
"\n";
658 auto padString = [](
const std::string &
s){
659 const int n = 65 -
s.size();
660 return s + std::string(
n,
' ');
675 out<<
"| Pixel space points | "<<
s2<<
"|\n";
676 out<<
"| SCT space points | "<<
s3<<
"|\n";
677 out<<
"| Overlap space points | "<<
s4<<
"|\n";
678 out<<
"| Pixel clusters | "<<s5<<
"|\n";
679 out<<
"| SCT clusters | "<<s6<<
"|\n";
680 out<<
"| TRT clusters | "<<s9<<
"|\n";
681 out<<
"| Truth location for pixels | "<<s7<<
"|\n";
682 out<<
"| Truth location for sct | "<<s8<<
"|\n";
683 out<<
"| Truth location for trt | "<<s10<<
"|\n";
685 <<std::setw(14)<<std::setprecision(5)<<
m_ptcut
687 out<<
"| max pT cut | "
688 <<std::setw(14)<<std::setprecision(5)<<
m_ptcutmax
690 out<<
"| rapidity cut | "
691 <<std::setw(14)<<std::setprecision(5)<<
m_rapcut
693 out<<
"| min Radius | "
694 <<std::setw(14)<<std::setprecision(5)<<
m_rmin
696 out<<
"| max Radius | "
697 <<std::setw(14)<<std::setprecision(5)<<
m_rmax
699 out<<
"| Min. number clusters for generated track | "
700 <<std::setw(14)<<std::setprecision(5)<<
m_clcut
702 out<<
"| Min. number sp.points for generated track | "
703 <<std::setw(14)<<std::setprecision(5)<<
m_spcut
705 out<<
"| Min. number TRT clusters for generated track | "
706 <<std::setw(14)<<std::setprecision(5)<<
m_clcutTRT
708 out<<
"|--------------------------------------------------------------------------------------------------------------------|\n";
719 auto formatOutput = [&
out](
const auto val){
723 out<<
"|---------------------------------------------------------------------|\n";
724 out<<
"| m_nspacepoints | ";
726 out<<
"| m_nclusters | ";
728 out<<
"| Kine-Clusters size | ";
730 out<<
"| Kine-TRTClusters size | ";
732 out<<
"| Kine-SpacePoints size | ";
734 out<<
"| Number good kine tracks | ";
736 out<<
"|---------------------------------------------------------------------|\n";
751 std::unique_ptr<SG::ReadHandle<SiClusterContainer> > pixelcontainer;
752 std::unique_ptr<SG::ReadHandle<SiClusterContainer> > sctcontainer;
753 std::unique_ptr<SG::ReadHandle<TRT_DriftCircleContainer> > trtcontainer;
756 pixelcontainer = std::make_unique<SG::ReadHandle<SiClusterContainer> >(
m_clustersPixelname,ctx);
763 sctcontainer = std::make_unique<SG::ReadHandle<SiClusterContainer> >(
m_clustersSCTname,ctx);
770 trtcontainer = std::make_unique<SG::ReadHandle<TRT_DriftCircleContainer> >(
m_clustersTRTname,ctx);
779 if(pixelcontainer && pixelcontainer->isValid()) {
780 InDet::SiClusterContainer::const_iterator
w = (*pixelcontainer)->begin();
781 InDet::SiClusterContainer::const_iterator we = (*pixelcontainer)->end ();
785 InDet::SiClusterCollection::const_iterator
c = (*w)->begin();
786 InDet::SiClusterCollection::const_iterator ce = (*w)->end ();
791 ++m_eventStat.m_nclustersPTOT;
792 if(
isTruth(event_data,(*
c))) ++m_eventStat.m_nclustersPTOTt;
795 int nk =
kine(event_data,(*
c),Kine,999);
796 for(
int i=0;
i!=nk; ++
i) {
809 if(sctcontainer && sctcontainer->isValid()) {
810 InDet::SiClusterContainer::const_iterator
w = (*sctcontainer)->begin();
811 InDet::SiClusterContainer::const_iterator we = (*sctcontainer)->end ();
815 InDet::SiClusterCollection::const_iterator
c = (*w)->begin();
816 InDet::SiClusterCollection::const_iterator ce = (*w)->end ();
821 ++m_eventStat.m_nclustersSTOT;
822 if(
isTruth(event_data,(*
c))) ++m_eventStat.m_nclustersSTOTt;
824 int nk =
kine(event_data,(*
c),Kine,999);
825 for(
int i=0;
i!=nk; ++
i) {
833 if(trtcontainer && trtcontainer->isValid()) {
836 InDet::TRT_DriftCircleContainer::const_iterator
w = (*trtcontainer)->begin();
837 InDet::TRT_DriftCircleContainer::const_iterator we = (*trtcontainer)->end ();
841 InDet::TRT_DriftCircleCollection::const_iterator
c = (*w)->begin();
842 InDet::TRT_DriftCircleCollection::const_iterator ce = (*w)->end ();
847 int nk =
kine(event_data,(*
c),Kine,999);
872 for(; spc != spce; ++spc) {
876 for(; sp != spe; ++sp) {
879 int nk =
kine(event_data,(*sp)->clusterList().first,Kine,999);
880 for(
int i=0;
i!=nk; ++
i) {
901 for(; spc != spce; ++spc) {
906 for(; sp != spe; ++sp) {
910 int nk =
kine(event_data,(*sp)->clusterList().first,(*sp)->clusterList().second,Kine,999);
911 for(
int i=0;
i!=nk; ++
i) {
931 for (; sp!=spe; ++sp) {
934 int nk =
kine(event_data,(*sp)->clusterList().first,(*sp)->clusterList().second,Kine,999);
935 for(
int i=0;
i!=nk; ++
i) {
966 std::list<int> worskine;
972 unsigned int nc = 1 ;
974 auto coerceTo49 = [] (
const size_t idx){
975 return (
idx<50) ?
idx : 49;
980 if((*c).first==
k0) {++
nc;
continue;}
983 const size_t clusterIdx =coerceTo49(
nc);
988 const size_t spacepointIdx =coerceTo49(
ns);
1016 for(
auto & pThisCluster: worskine) {
1027 if (not de)
continue;
1031 if(de->isBarrel()) {
1040 if(de->isBarrel()) {
1069 if(++
nc >= 100)
return;
1081 int KINE[200],NKINE[200];
1086 se = (*t)->trackStateOnSurfaces()->end();
1095 const AmgVector(5)& Vpf = tpf ->parameters ();
1096 double pTf = std::abs(
std::sin(Vpf[3])/Vpf[4]);
1140 int Kine[1000], nk=
kine0(event_data,rd,Kine,999); ++
NC;
if(!nk) ++N0;
1142 for(
int k = 0;
k!=nk; ++
k) {
1145 for(;
n!=NK; ++
n) {
if(Kine[
k]==KINE[
n]) {++NKINE[
n];
break;}}
1146 if(
n==NK) {KINE[NK] = Kine[
k]; NKINE[NK] = 1;
if (NK < 200) ++NK;}
1148 for(
int n=0;
n!=NK; ++
n) {
if(NKINE[
n]>nkm) nkm = NKINE[
n];}
1151 for(
int n=0;
n!=NK; ++
n) {
1153 int NQ = 1000*NKINE[
n]+(
NC-NKINE[
n]);
1155 event_data.
m_tracks[
nc].insert(std::make_pair(KINE[
n],NQ));
1179 std::multimap<int,int>::const_iterator
t, te = event_data.
m_tracks[
nc].end();
1190 int ts = (*t).second/1000;
1191 int ws = (*t).second%1000;
1192 if (
ts >
m ) {
m =
ts;
w = ws;}
1193 else if(
ts==
m &&
w > ws) {
w = ws;}
1195 int d =
n-
m;
if(
d<0)
d = 0;
else if(
d > 5)
d=5;
if(
w>4)
w = 4;
1200 int ch = (*p).charge();
1223 int Kine1[1000],Kine2[1000];
1225 int n2 =
kine(event_data,
d2,Kine2,
nmax);
if(!n2)
return nkine;
1227 for(
int i = 0;
i!=
n1; ++
i) {
1228 for(
int j = 0; j!=n2; ++j) {
1229 if(Kine1[
i]==Kine2[j]) {Kine[nkine++] = Kine1[
i];
break;}
1243 PRD_MultiTruthCollection::const_iterator mce;
1244 PRD_MultiTruthCollection::const_iterator
mc =
findTruth(event_data,
d,mce);
1249 for(;
mc!=mce; ++
mc) {
1251 if( (*mc).first !=
ID )
return nkine;
1256 if(!pa or !pa->production_vertex())
continue;
1258 int pdg = std::abs(pa->pdg_id());
if(
m_pdg &&
m_pdg != pdg )
continue;
1260 if (std::abs(
MC::charge(pdg)) < .5) {
continue; }
1264 double px = pa->momentum().px();
1265 double py = pa->momentum().py();
1266 double pz = pa->momentum().pz();
1268 if( pt < m_ptcut || pt >
m_ptcutmax)
continue;
1272 double t = std::abs(
pz)/
pt;
1277 double vx = pa->production_vertex()->position().x();
1278 double vy = pa->production_vertex()->position().y();
1279 double r = std::sqrt(vx*vx+vy*vy);
1280 if( r < m_rmin || r >
m_rmax)
continue;
1295 PRD_MultiTruthCollection::const_iterator mce;
1296 PRD_MultiTruthCollection::const_iterator
mc =
findTruth(event_data,
d,mce);
1301 for(;
mc!=mce; ++
mc) {
1303 if( (*mc).first !=
ID )
return nkine;
1318 PRD_MultiTruthCollection::const_iterator mce;
1319 PRD_MultiTruthCollection::const_iterator
mc =
findTruth(event_data,
d,mce);
1330 std::multimap<int,const Trk::PrepRawData*>::const_iterator
k = event_data.
m_kinecluster.find(K);
1333 if((*k).first!= K)
return false;
1334 if(
d->detectorElement()==(*k).second->detectorElement())
return true;
1349 std::multimap<int,const Trk::SpacePoint*>::const_iterator
k = event_data.
m_kinespacepoint.find(K);
1354 if((*k).first!= K)
return false;
1359 if(
p1->detectorElement() ==
n1->detectorElement())
return true;
1367 if((*k).first!= K)
return false;
1372 if(
p1->detectorElement() ==
n1->detectorElement())
return true;
1373 if(
p2->detectorElement() ==
n1->detectorElement())
return true;
1393 std::list<int>::const_iterator dif = event_data.
m_difference[
nc].begin();
1395 std::multimap<int,const Trk::PrepRawData*>::const_iterator
c,ce = event_data.
m_kinecluster.end();
1398 std::string s1;
for(
int i=0;
i<
n; ++
i) s1.append(
" "); s1.append(
"|");
1399 std::stringstream
out;
1400 out<<
"|----------------------------------------------------------------------------------------|\n";
1402 out<<
"|----------------------------------------------------------------------------------------|\n";
1403 out<<
"| # pdg kine Ncl Ntr Nsp Lose pT(MeV) rapidity radius z |\n";
1404 out<<
"|----------------------------------------------------------------------------------------|\n";
1414 PRD_MultiTruthCollection::const_iterator mce;
1415 PRD_MultiTruthCollection::const_iterator
mc =
findTruth(event_data,
d,mce);
1419 for(;
mc!=mce; ++
mc) {
1420 if((*mc).first !=
ID)
break;
1428 double px = pa->momentum().px();
1429 double py = pa->momentum().py();
1430 double pz = pa->momentum().pz();
1431 double vx = pa->production_vertex()->position().x();
1432 double vy = pa->production_vertex()->position().y();
1433 double vz = pa->production_vertex()->position().z();
1435 double t = std::atan2(
pt,
pz);
1437 double r = std::sqrt(vx*vx+vy*vy);
1441 <<std::setw(6)<<pa->pdg_id()
1446 <<std::setw(4)<<(*dif)
1447 <<std::setw(12)<<std::setprecision(5)<<
pt
1448 <<std::setw(12)<<std::setprecision(5)<<ra
1449 <<std::setw(12)<<std::setprecision(5)<<
r
1450 <<std::setw(12)<<std::setprecision(5)<<vz
1455 out<<
"|----------------------------------------------------------------------------------------|\n";
1465 PRD_MultiTruthCollection::const_iterator
1469 PRD_MultiTruthCollection::const_iterator& mce)
1475 PRD_MultiTruthCollection::const_iterator
mc;
1482 for (
int i=0;
i<3;
i++) {
1484 mce=truth[
i]->end();
1485 return truth[
i]->end();
1488 throw std::runtime_error(
"Neither Pixel, SCT nor TRT truth.");
1501 PRD_MultiTruthCollection::const_iterator mce;
1502 PRD_MultiTruthCollection::const_iterator
mc =
findTruth(event_data,
d,mce);
1504 for(;
mc!=mce; ++
mc) {
1510 double px =
pat->momentum().px();
1511 double py =
pat->momentum().py();
1512 double pz =
pat->momentum().pz();
1514 double t = std::atan2(
pt,
pz) ;
1521 ra > 1.6 ? rap = 2 : ra > .8 ? rap = 1 : rap = 0;
1523 int pdg =
pat->pdg_id();
1526 if(
ch > .5)
return 1;
1527 if(
ch < -.5)
return -1;