Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 3-clustering-algorithm-for-calorimeter
  • 36-need-jug-run-executable-to-launch-full-reconstruction
  • 37-eta-and-phi-definition-in-merger
  • 73-add-rich-irt-algorithm
  • 79-testing-ci-for-alexander
  • 88-use-gsl-owner
  • 95-jugfast-matchclusters-needs-updating-for-edm4hep-migration
  • 96-implement-simtrackerhitsmerger-to-overlay-merge-background-events
  • 99-trackprojector-generalize-by-passing-target-surface-as-option
  • BHCalReco
  • Mriganka-master-patch-97470
  • acts-20
  • acts-seeding-21
  • acts_debug
  • algorithms
  • algorithms-integration-calorimeter-hit-digi
  • algorithms-service-proto
  • ayk-01
  • bebop_test
  • billlee77-master-patch-93524
  • brynnamoran-master-patch-77949
  • calorimeter-hit-digi
  • calorimeter-hit-digi-with-random-svc
  • debug_tracking
  • eicrecon-migration
  • feat-add-ActsSvc
  • feat-context-service-overhaul
  • fitting
  • imaging_cal_ML
  • irt-hepmc-jugpid
  • irt-init
  • irt-init-rebased
  • irt-init-v01
  • less-jug-xl-master
  • less_verbose_acts
  • lkosarzew-master-patch-18213
  • main
  • master
  • neutral_momentum
  • new_versions_fix
  • pid
  • pileup-tools
  • podio-data-svc-collections
  • re-update_ci
  • robin-ImagingDataShaper
  • silicon-tracker-digi
  • sim-tracker-hits-collector
  • source_link_debug
  • standalone
  • swapneshkhade-master-patch-93112
  • tensorflow
  • test-main
  • test-unstable-container
  • tflite-proof-of-concept
  • tof-pid-plugin
  • topo_cluster
  • track-param-imaging-cluster-init-phi-shift-to-ecal
  • track-projector-firstSmallerThanZ
  • track_projection
  • tracking_update
  • trackprojection_writeout
  • trajectory_info
  • update_imcal_alg
  • use-algorithms-library
  • use-eicrecon-algorithms
  • use-upstream-edm4hep
  • use_v3_image
  • vanekjan-master-patch-35348
  • wdconinc-main-patch-17306
  • wdconinc-main-patch-77189
  • wdconinc-main-patch-83553
  • wdconinc-main-patch-85492
  • wdconinc-master-patch-91743
  • 0.1
  • stable-1.2
  • v0.1
  • v0.3.1
  • v0.3.2
  • v0.3.3
  • v0.4.0
  • v0.4.1
  • v1.2.0
  • v1.5.0
  • v1.6.0
  • v1.8.0
  • v10.0.0
  • v10.0.1
  • v10.1.0
  • v11.0.0
  • v12.0.0
  • v13.0.0
  • v14.0.0
  • v14.0.1
  • v14.0.2
  • v14.0.3
  • v14.1.0
  • v14.2.0
  • v14.2.1
  • v14.2.2
  • v14.3.0
  • v15.0.0
  • v15.0.1
  • v15.0.2
  • v2.0.0
  • v3.0.0
  • v3.1.0
  • v3.2.0
  • v3.3.0
  • v3.3.1
  • v3.4.0
  • v3.5.0
  • v3.6.0
  • v4.0.0
  • v4.1.0
  • v4.2.0
  • v4.3.0
  • v4.4.0
  • v5.0.0
  • v6.0.0
  • v6.1.0
  • v7.0.0
  • v8.0.0
  • v8.0.1
  • v8.0.2
  • v9.0.0
  • v9.1.0
  • v9.2.0
  • v9.3.0
  • v9.4.0
129 results

Target

Select target project
  • EIC/juggler
  • nbrei/juggler
  • wdconinc/juggler
  • ylai/juggler
4 results
Select Git revision
  • 11-generic-3d-clustering-of-hits
  • 26-implement-3d-clustering-algorithm-for-sampling-calorimeter
  • 3-clustering-algorithm-for-calorimeter
  • downstream_pipelines
  • fitting
  • master
  • new_versions_fix
  • pages
  • pid
  • test-unstable
  • 0.1
  • stable-1.2
  • v0.1
  • v0.3.1
  • v0.3.2
  • v0.3.3
  • v0.4.0
  • v0.4.1
  • v1.2.0
19 results
Show changes
Showing
with 311 additions and 1291 deletions
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2022 Sylvester Joosten
#include "ParticleSvc.h"
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
DECLARE_COMPONENT(ParticleSvc)
namespace {
const IParticleSvc::ParticleMap kParticleMap = {
{ 0, { 0, 0, 0.0 }}, // unknown
{ 11, { 11, -1, 0.000510998928 }}, // e-
{ -11, { -11, 1, 0.000510998928 }}, // e+
{ 13, { 13, -1, 0.105658357 }}, // mu-
{ -13, { -13, 1, 0.105658357 }}, // mu+
{ 22, { 22, 0, 0.0 }}, // gamma
{ 111, { 111, 0, 0.1349766 }}, // p0
{ 113, { 111, 0, 0.76850 }}, // rho(770)^0
{ 115, { 115, 0, 1.31800 }}, // a_2(1320)^0
{ 211, { 211, 1, 0.1395701 }}, // pi+
{ -211, { -211, -1, 0.1395701 }}, // pi-
{ 213, { 213, 1, 0.76690 }}, // rho+
{ -213, { -213, -1, 0.76690 }}, // rho-
{ 215, { 215, 1, 1.31800 }}, // a_2(1320)+
{ -215, { -215, -1, 1.31800 }}, // a_2(1320)-
{ 221, { 221, 0, 0.54745 }}, // eta
{ 223, { 223, 0, 0.78194 }}, // omega
{ 225, { 225, 0, 1.27500 }}, // f_2(1270)
{ 130, { 130, 0, 0.49767 }}, // KL_0
{ 310, { 310, 0, 0.49767 }}, // KS_0
{ 311, { 311, 0, 0.49767 }}, // K^0
{ -311, { -311, 0, 0.49767 }}, // K~^0
{ 313, { 313, 0, 0.89610 }}, // K*(892)^0
{ -313, { -313, 0, 0.89610 }}, // K*(892)~^0
{ 315, { 315, 0, 1.43200 }}, // K*_2(1430)^0
{ -315, { -315, 0, 1.43200 }}, // K*_2(1430)~^0
{ 321, { 321, 1, 0.49360 }}, // K^+
{ -321, { -321, -1, 0.49360 }}, // K^-
{ 323, { 323, 1, 0.89160 }}, // K*(892)^+
{ -323, { -323, -1, 0.89160 }}, // K*(892)^-
{ 325, { 325, 1, 1.42500 }}, // K*_2(1430)^+
{ -325, { -325, -1, 1.42500 }}, // K*_2(1430)^-
{ 331, { 331, 0, 0.95777 }}, // eta'(958)
{ 333, { 333, 0, 1.01940 }}, // phi(1020)
{ 335, { 335, 0, 1.52500 }}, // f'_2(1525)
{ 411, { 411, 1, 1.86930 }}, // D+
{ -411, { 411, -1, 1.86930 }}, // D-
{ 413, { 413, 1, 2.01000 }}, // D*(2010)^+
{ -413, { -413, -1, 2.01000 }}, // D*(2010)^-
{ 415, { 415, 1, 2.46000 }}, // D*_2(2460)^+
{ -415, { -415, -1, 2.46000 }}, // D*_2(2460)^-
{ 421, { 421, 0, 1.86450 }}, // D^0
{ -421, { -421, 0, 1.86450 }}, // D~^0
{ 423, { 423, 0, 2.00670 }}, // D*(2007)^0
{ -423, { -423, 0, 2.00670 }}, // D*(2007)~^0
{ 425, { 425, 0, 2.46000 }}, // D*_2(2460)^0
{ -425, { -425, 0, 2.46000 }}, // D*_2(2460)~^0
{ 431, { 431, 1, 1.96850 }}, // D_s^+
{ -431, { -431, -1, 1.96850 }}, // D_s^-
{ 433, { 433, 1, 2.11240 }}, // D*_s^+
{ -433, { -433, -1, 2.11240 }}, // D*_s^-
{ 435, { 435, 1, 2.57350 }}, // D*_s2(2573)^+
{ -435, { -435, -1, 2.57350 }}, // D*_s2(2573)^-
{ 441, { 441, 0, 2.97980 }}, // eta_c(1S)
{ 443, { 443, 0, 3.09688 }}, // J/psi(1S)
{ 445, { 445, 0, 3.55620 }}, // chi_c2(1P)
{ 511, { 511, 0, 5.27920 }}, // B^0
{ -511, { -511, 0, 5.27920 }}, // B~^0
{ 513, { 513, 0, 5.32480 }}, // B*^0
{ -513, { -513, 0, 5.32480 }}, // B*~^0
{ 515, { 515, 0, 5.83000 }}, // B*_2^0
{ -515, { -515, 0, 5.83000 }}, // B*_2~^0
{ 521, { 521, 1, 5.27890 }}, // B^+
{ -521, { -521, -1, 5.27890 }}, // B^-
{ 523, { 523, 1, 5.32480 }}, // B*^+
{ -523, { -523, -1, 5.32480 }}, // B*^-
{ 525, { 525, 1, 5.83000 }}, // B*_2^+
{ -525, { -525, -1, 5.83000 }}, // B*_2^-
{ 531, { 531, 0, 5.36930 }}, // B_s^0
{ -531, { -531, 0, 5.36930 }}, // B_s~^0
{ 533, { 533, 0, 5.41630 }}, // B*_s^0
{ -533, { -533, 0, 5.41630 }}, // B*_s~^0
{ 535, { 535, 0, 6.07000 }}, // B*_s2^0
{ -535, { -535, 0, 6.07000 }}, // B*_s2~^0
{ 541, { 541, 1, 6.59400 }}, // B_c^+
{ -541, { -541, -1, 6.59400 }}, // B_c^-
{ 543, { 543, 1, 6.60200 }}, // B*_c^+
{ -543, { -543, -1, 6.60200 }}, // B*_c^-
{ 545, { 545, 1, 7.35000 }}, // B*_c2^+
{ -545, { -545, -1, 7.35000 }}, // B*_c2^-
{ 551, { 551, 0, 9.40000 }}, // eta_b(1S)
{ 553, { 553, 0, 9.46030 }}, // Upsilon(1S)
{ 555, { 555, 0, 9.91320 }}, // chi_b2(1P)
{ 990, { 990, 0, 0.00000 }}, // pomeron
{ 1114, { 1114, -1, 1.23400 }}, // Delta^-
{ -1114, { -1114, 1, 1.23400 }}, // Delta~^+
{ 2112, { 2112, 0, 0.93957 }}, // n
{ -2112, { -2112, 0, 0.93957 }}, // n~^0
{ 2114, { 2114, 0, 1.23300 }}, // Delta^0
{ -2114, { -2114, 0, 1.23300 }}, // Delta~^0
{ 2212, { 2212, 1, 0.93827 }}, // p^+
{ -2212, { -2212, -1, 0.93827 }}, // p~^-
{ 2214, { 2214, 1, 1.23200 }}, // Delta^+
{ -2214, { -2214, -1, 1.23200 }}, // Delta~^-
{ 2224, { 2224, 2, 1.23100 }}, // Delta^++
{ -2224, { -2224, -2, 1.23100 }}, // Delta~^--
{ 3112, { 3112, -1, 1.19744 }}, // Sigma^-
{ -3112, { -3112, 1, 1.19744 }}, // Sigma~^+
{ 3114, { 3114, -1, 1.38720 }}, // Sigma*^-
{ -3114, { -3114, 1, 1.38720 }}, // Sigma*~^+
{ 3122, { 3122, 0, 1.11568 }}, // Lambda^0
{ -3122, { -3122, 0, 1.11568 }}, // Lambda~^0
{ 3212, { 3212, 0, 1.19255 }}, // Sigma^0
{ -3212, { -3212, 0, 1.19255 }}, // Sigma~^0
{ 3214, { 3214, 0, 1.38370 }}, // Sigma*^0
{ -3214, { -3214, 0, 1.38370 }}, // Sigma*~^0
{ 3222, { 3222, 1, 1.18937 }}, // Sigma^+
{ -3222, { -3222, -1, 1.18937 }}, // Sigma~^-
{ 3224, { 3224, 1, 1.38280 }}, // Sigma*^+
{ -3224, { -3224, -1, 1.38280 }}, // Sigma*~^-
{ 3312, { 3312, -1, 1.32130 }}, // Xi^-
{ -3312, { -3312, 1, 1.32130 }}, // Xi~^+
{ 3314, { 3314, -1, 1.53500 }}, // Xi*^-
{ -3314, { -3314, 1, 1.53500 }}, // Xi*~^+
{ 3322, { 3322, 0, 1.31490 }}, // Xi^0
{ -3322, { -3322, 0, 1.31490 }}, // Xi~^0
{ 3324, { 3324, 0, 1.53180 }}, // Xi*^0
{ -3324, { -3324, 0, 1.53180 }}, // Xi*~^0
{ 3334, { 3334, -1, 1.67245 }}, // Omega^-
{ -3334, { -3334, 1, 1.67245 }}, // Omega~^+
{ 4112, { 4112, 0, 2.45210 }}, // Sigma_c^0
{ -4112, { -4112, 0, 2.45210 }}, // Sigma_c~^0
{ 4114, { 4114, 0, 2.50000 }}, // Sigma*_c^0
{ -4114, { -4114, 0, 2.50000 }}, // Sigma*_c~^0
{ 4122, { 4122, 1, 2.28490 }}, // Lambda_c^+
{ -4122, { -4122, -1, 2.28490 }}, // Lambda_c~^-
{ 4132, { 4132, 0, 2.47030 }}, // Xi_c^0
{ -4132, { -4132, 0, 2.47030 }}, // Xi_c~^0
{ 4212, { 4212, 1, 2.45350 }}, // Sigma_c^+
{ -4212, { -4212, -1, 2.45350 }}, // Sigma_c~^-
{ 4214, { 4214, 1, 2.50000 }}, // Sigma*_c^+
{ -4214, { -4214, -1, 2.50000 }}, // Sigma*_c~^-
{ 4222, { 4222, 2, 2.45290 }}, // Sigma_c^++
{ -4222, { -4222, -2, 2.45290 }}, // Sigma_c~^--
{ 4224, { 4224, 2, 2.50000 }}, // Sigma*_c^++
{ -4224, { -4224, -2, 2.50000 }}, // Sigma*_c~^--
{ 4232, { 4232, 1, 2.46560 }}, // Xi_c^+
{ -4232, { -4232, -1, 2.46560 }}, // Xi_c~^-
{ 4312, { 4312, 0, 2.55000 }}, // Xi'_c^0
{ -4312, { -4312, 0, 2.55000 }}, // Xi'_c~^0
{ 4314, { 4314, 0, 2.63000 }}, // Xi*_c^0
{ -4314, { -4314, 0, 2.63000 }}, // Xi*_c~^0
{ 4322, { 4322, 1, 2.55000 }}, // Xi'_c^+
{ -4322, { -4322, -1, 2.55000 }}, // Xi'_c~^-
{ 4324, { 4324, 1, 2.63000 }}, // Xi*_c^+
{ -4324, { -4324, -1, 2.63000 }}, // Xi*_c~^-
{ 4332, { 4332, 0, 2.70400 }}, // Omega_c^0
{ -4332, { -4332, 0, 2.70400 }}, // Omega_c~^0
{ 4334, { 4334, 0, 2.80000 }}, // Omega*_c^0
{ -4334, { -4334, 0, 2.80000 }}, // Omega*_c~^0
{ 4412, { 4412, 1, 3.59798 }}, // Xi_cc^+
{ -4412, { -4412, -1, 3.59798 }}, // Xi_cc~^-
{ 4414, { 4414, 1, 3.65648 }}, // Xi*_cc^+
{ -4414, { -4414, -1, 3.65648 }}, // Xi*_cc~^-
{ 4422, { 4422, 2, 3.59798 }}, // Xi_cc^++
{ -4422, { -4422, -2, 3.59798 }}, // Xi_cc~^--
{ 4424, { 4424, 2, 3.65648 }}, // Xi*_cc^++
{ -4424, { -4424, -2, 3.65648 }}, // Xi*_cc~^--
{ 4432, { 4432, 1, 3.78663 }}, // Omega_cc^+
{ -4432, { -4432, -1, 3.78663 }}, // Omega_cc~^-
{ 4434, { 4434, 1, 3.82466 }}, // Omega*_cc^+
{ -4434, { -4434, -1, 3.82466 }}, // Omega*_cc~^-
{ 4444, { 4444, 2, 4.91594 }}, // Omega*_ccc^++
{ -4444, { -4444, -2, 4.91594 }}, // Omega*_ccc~^--
{ 5112, { 5112, -1, 5.80000 }}, // Sigma_b^-
{ -5112, { -5112, 1, 5.80000 }}, // Sigma_b~^+
{ 5114, { 5114, -1, 5.81000 }}, // Sigma*_b^-
{ -5114, { -5114, 1, 5.81000 }}, // Sigma*_b~^+
{ 5122, { 5122, 0, 5.64100 }}, // Lambda_b^0
{ -5122, { -5122, 0, 5.64100 }}, // Lambda_b~^0
{ 5132, { 5132, -1, 5.84000 }}, // Xi_b^-
{ -5132, { -5132, 1, 5.84000 }}, // Xi_b~^+
{ 5142, { 5142, 0, 7.00575 }}, // Xi_bc^0
{ -5142, { -5142, 0, 7.00575 }}, // Xi_bc~^0
{ 5212, { 5212, 0, 5.80000 }}, // Sigma_b^0
{ -5212, { -5212, 0, 5.80000 }}, // Sigma_b~^0
{ 5214, { 5214, 0, 5.81000 }}, // Sigma*_b^0
{ -5214, { -5214, 0, 5.81000 }}, // Sigma*_b~^0
{ 5222, { 5222, 1, 5.80000 }}, // Sigma_b^+
{ -5222, { -5222, -1, 5.80000 }}, // Sigma_b~^-
{ 5224, { 5224, 1, 5.81000 }}, // Sigma*_b^+
{ -5224, { -5224, -1, 5.81000 }}, // Sigma*_b~^-
{ 5232, { 5232, 0, 5.84000 }}, // Xi_b^0
{ -5232, { -5232, 0, 5.84000 }}, // Xi_b~^0
{ 5242, { 5242, 1, 7.00575 }}, // Xi_bc^+
{ -5242, { -5242, -1, 7.00575 }}, // Xi_bc~^-
{ 5312, { 5312, -1, 5.96000 }}, // Xi'_b^-
{ -5312, { -5312, 1, 5.96000 }}, // Xi'_b~^+
{ 5314, { 5314, -1, 5.97000 }}, // Xi*_b^-
{ -5314, { -5314, 1, 5.97000 }}, // Xi*_b~^+
{ 5322, { 5322, 0, 5.96000 }}, // Xi'_b^0
{ -5322, { -5322, 0, 5.96000 }}, // Xi'_b~^0
{ 5324, { 5324, 0, 5.97000 }}, // Xi*_b^0
{ -5324, { -5324, 0, 5.97000 }}, // Xi*_b~^0
{ 5332, { 5332, -1, 6.12000 }}, // Omega_b^-
{ -5332, { -5332, 1, 6.12000 }}, // Omega_b~^+
{ 5334, { 5334, -1, 6.13000 }}, // Omega*_b^-
{ -5334, { -5334, 1, 6.13000 }}, // Omega*_b~^+
{ 5342, { 5342, 0, 7.19099 }}, // Omega_bc^0
{ -5342, { -5342, 0, 7.19099 }}, // Omega_bc~^0
{ 5412, { 5412, 0, 7.03724 }}, // Xi'_bc^0
{ -5412, { -5412, 0, 7.03724 }}, // Xi'_bc~^0
{ 5414, { 5414, 0, 7.04850 }}, // Xi*_bc^0
{ -5414, { -5414, 0, 7.04850 }}, // Xi*_bc~^0
{ 5422, { 5422, 1, 7.03724 }}, // Xi'_bc^+
{ -5422, { -5422, -1, 7.03724 }}, // Xi'_bc~^-
{ 5424, { 5424, 1, 7.04850 }}, // Xi*_bc^+
{ -5424, { -5424, -1, 7.04850 }}, // Xi*_bc~^-
{ 5432, { 5432, 0, 7.21101 }}, // Omega'_bc^0
{ -5432, { -5432, 0, 7.21101 }}, // Omega'_bc~^0
{ 5434, { 5434, 0, 7.21900 }}, // Omega*_bc^0
{ -5434, { -5434, 0, 7.21900 }}, // Omega*_bc~^0
{ 5442, { 5442, 1, 8.30945 }}, // Omega_bcc^+
{ -5442, { -5442, -1, 8.30945 }}, // Omega_bcc~^-
{ 5444, { 5444, 1, 8.31325 }}, // Omega*_bcc^+
{ -5444, { -5444, -1, 8.31325 }}, // Omega*_bcc~^-
{ 5512, { 5512, -1, 10.42272 }}, // Xi_bb^-
{ -5512, { -5512, 1, 10.42272 }}, // Xi_bb~^+
{ 5514, { 5514, -1, 10.44144 }}, // Xi*_bb^-
{ -5514, { -5514, 1, 10.44144 }}, // Xi*_bb~^+
{ 5522, { 5522, 0, 10.42272 }}, // Xi_bb^0
{ -5522, { -5522, 0, 10.42272 }}, // Xi_bb~^0
{ 5524, { 5524, 0, 10.44144 }}, // Xi*_bb^0
{ -5524, { -5524, 0, 10.44144 }}, // Xi*_bb~^0
{ 5532, { 5532, -1, 10.60209 }}, // Omega_bb^-
{ -5532, { -5532, 1, 10.60209 }}, // Omega_bb~^+
{ 5534, { 5534, -1, 10.61426 }}, // Omega*_bb^-
{ -5534, { -5534, 1, 10.61426 }}, // Omega*_bb~^+
{ 5542, { 5542, 0, 11.70767 }}, // Omega_bbc^0
{ -5542, { -5542, 0, 11.70767 }}, // Omega_bbc~^0
{ 5544, { 5544, 0, 11.71147 }}, // Omega*_bbc^0
{ -5544, { -5544, 0, 11.71147 }}, // Omega*_bbc~^0
{ 5554, { 5554, -1, 15.11061 }}, // Omega*_bbb^-
{ -5554, { -5554, 1, 15.11061 }}, // Omega*_bbb~^+
{ 1000010020, { 1000010020, 1, 1.87561 }}, // Deuterium
{ 1000010030, { 1000010030, 1, 2.80925 }}, // Tritium
{ 1000020030, { 1000020030, 2, 2.80923 }}, // He-3
{ 1000020040, { 1000020040, 2, 3.72742 }}, // Alpha
};
}
ParticleSvc::ParticleSvc(const std::string& name, ISvcLocator* svc)
: base_class(name, svc), m_particleMap{kParticleMap} {}
ParticleSvc::~ParticleSvc() = default;
StatusCode ParticleSvc::initialize()
{
StatusCode sc = Service::initialize();
if (!sc.isSuccess())
{
fatal() << "Error initializing ParticleSvc" << endmsg;
return sc;
}
info() << "ParticleSvc initialized successfully" << endmsg;
return StatusCode::SUCCESS;
}
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2022 Whitney Armstrong, Sylvester Joosten
#ifndef PARTICLESVC_H
#define PARTICLESVC_H
#include <map>
#include "GaudiKernel/Service.h"
#include "JugBase/IParticleSvc.h"
/** Simple particle service.
*
* This meant to provide basic particle information for reconstruction purposes.
* If particle data is needed, be sure to grab everything you can in an initialization
* step. Currently the returned Particle/ParticleMap are by value.
*/
class ParticleSvc : public extends<Service, IParticleSvc> {
public:
using Particle = Jug::Base::ParticleData;
using ParticleMap = std::map<int, Particle>;
const ParticleMap m_particleMap;
public:
ParticleSvc(const std::string& name, ISvcLocator* svc);
virtual ~ParticleSvc();
virtual StatusCode initialize() final;
virtual StatusCode finalize() final { return StatusCode::SUCCESS; }
virtual ParticleMap particleMap() const { return m_particleMap; }
virtual Particle particle(int pdg) const {
if (m_particleMap.count(pdg) == 0) {
// error
return m_particleMap.at(0);
}
return m_particleMap.at(pdg);
}
};
#endif
#include "PileupDigiTrackHitMergeTool.h"
#include "podio/EventStore.h"
#include "datamodel/DigiTrackHitAssociationCollection.h"
#include "datamodel/MCParticle.h"
#include "datamodel/MCParticleCollection.h"
#include "datamodel/PositionedTrackHitCollection.h"
#include "datamodel/TrackHitCollection.h"
DECLARE_COMPONENT(PileupDigiTrackHitMergeTool)
DECLARE_COMPONENT_WITH_ID(PileupDigiTrackHitMergeTool, "PileupDigiTrackHitMergeTool")
PileupDigiTrackHitMergeTool::PileupDigiTrackHitMergeTool(const std::string& aType, const std::string& aName,
const IInterface* aParent)
: GaudiTool(aType, aName, aParent) {
declareInterface<IEDMMergeTool>(this);
declareProperty("signalPositionedHits", m_hitsSignal);
declareProperty("signalDigiHits", m_posHitsSignal);
declareProperty("signalParticles", m_particlesSignal);
declareProperty("mergedPositionedHits", m_hitsMerged);
declareProperty("mergedDigiHits", m_digiHitsMerged);
declareProperty("mergedParticles", m_particlesMerged);
}
StatusCode PileupDigiTrackHitMergeTool::initialize() { return StatusCode::SUCCESS; }
StatusCode PileupDigiTrackHitMergeTool::finalize() { return StatusCode::SUCCESS; }
StatusCode PileupDigiTrackHitMergeTool::readPileupCollection(podio::EventStore& store) {
// local pointers, to be filled by the event store
const fcc::PositionedTrackHitCollection* hitCollection;
const fcc::DigiTrackHitAssociationCollection* digiHitCollection;
const fcc::MCParticleCollection* particleCollection;
// get collection address and store it in container
bool hitCollectionPresent = store.get(m_pileupHitsBranchName, hitCollection);
if (hitCollectionPresent) {
m_hitCollections.push_back(hitCollection);
} else {
warning() << "No collection could be read from branch " << m_pileupHitsBranchName << endmsg;
return StatusCode::FAILURE;
}
/// as above, for the positioned collection
bool digiHitCollectionPresent = store.get(m_pileupPosHitsBranchName, digiHitCollection);
if (digiHitCollectionPresent) {
m_digiTrackHitsCollections.push_back(digiHitCollection);
} else {
warning() << "No collection could be read from branch " << m_pileupPosHitsBranchName << endmsg;
return StatusCode::FAILURE;
}
/// as above, for the particle collection (if wanted)
if (m_mergeParticles) {
bool particleCollectionPresent = store.get(m_pileupParticleBranchName, particleCollection);
if (particleCollectionPresent) {
m_particleCollections.push_back(particleCollection);
} else {
warning() << "No collection could be read from branch " << m_pileupParticleBranchName << endmsg;
return StatusCode::FAILURE;
}
}
return StatusCode::SUCCESS;
}
StatusCode PileupDigiTrackHitMergeTool::readSignal() {
// get collection from event store
auto collHitsSig = m_hitsSignal.get();
auto collPosHitsSig = m_posHitsSignal.get();
auto collPartSig = m_particlesSignal.get();
// store them in internal container
m_hitCollections.push_back(collHitsSig);
m_digiTrackHitsCollections.push_back(collPosHitsSig);
// check if particles should be merged
if (m_mergeParticles) {
m_particleCollections.push_back(collPartSig);
}
return StatusCode::SUCCESS;
}
StatusCode PileupDigiTrackHitMergeTool::mergeCollections() {
// ownership given to data service at end of execute
fcc::PositionedTrackHitCollection* collHitsMerged = new fcc::PositionedTrackHitCollection();
fcc::DigiTrackHitAssociationCollection* collDigiHitsMerged = new fcc::DigiTrackHitAssociationCollection();
fcc::MCParticleCollection* collParticlesMerged = new fcc::MCParticleCollection();
unsigned int collectionCounter = 0;
for (size_t j = 0; j < m_digiTrackHitsCollections.size(); j++) {
unsigned int trackIDCounter = 0;
std::unordered_map<unsigned, unsigned> oldToNewTrackIDs;
auto offset = collectionCounter * m_trackIDCollectionOffset;
auto digiHitColl = m_digiTrackHitsCollections.at(j);
auto hitColl = m_hitCollections.at(j);
for (int i = 0; i < digiHitColl->size(); i++) {
auto clon = hitColl->at(i).clone();
// add pileup vertex counter with an offset
// i.e. for the signal event, 'bits' is just the trackID taken from geant
// for the n-th pileup event, 'bits' is the trackID + n * offset
// offset needs to be big enough to ensure uniqueness of trackID
if (isTrackerHit(hitColl->at(i).cellId())) {
if (trackIDCounter > m_trackIDCollectionOffset) {
error() << "Event contains too many tracks to guarantee a unique trackID";
error() << " The offset width or trackID field size needs to be adjusted!" << endmsg;
return StatusCode::FAILURE;
}
auto search = oldToNewTrackIDs.find(clon.bits());
if (search != oldToNewTrackIDs.end()) {
// was already present - use already created new trackID
unsigned newTrackID = (search->second + offset);
clon.bits(newTrackID);
} else {
// was not already present - create new trackID
oldToNewTrackIDs[clon.bits()] = trackIDCounter;
unsigned newTrackID = (trackIDCounter + offset);
clon.bits(newTrackID);
trackIDCounter++;
}
}
auto newDigiHit = digiHitColl->at(i).clone();
newDigiHit.hit(clon);
collHitsMerged->push_back(clon);
collDigiHitsMerged->push_back(newDigiHit);
}
///@todo find possibility in case not only tracker hits are produced
if (m_mergeParticles) {
auto partColl = m_particleCollections.at(j);
for (int i = 0; i < partColl->size(); i++) {
auto clonParticle = partColl->at(i).clone();
auto search = oldToNewTrackIDs.find(clonParticle.bits());
if (search != oldToNewTrackIDs.end()) {
// was not already present - create new trackID
clonParticle.bits(search->second + offset);
} else {
// was not already present - create new trackID
// this can happen if particles do not reach the tracker
oldToNewTrackIDs[clonParticle.bits()] = trackIDCounter;
unsigned newTrackID = (trackIDCounter + offset);
clonParticle.bits(newTrackID);
trackIDCounter++;
}
collParticlesMerged->push_back(clonParticle);
}
}
++collectionCounter;
}
m_hitsMerged.put(collHitsMerged);
m_digiHitsMerged.put(collDigiHitsMerged);
m_particlesMerged.put(collParticlesMerged);
m_hitCollections.clear();
m_digiTrackHitsCollections.clear();
m_particleCollections.clear();
return StatusCode::SUCCESS;
}
#ifndef JUGBASE_PILEUPDIGITRACKERHITSMERGETOOL_H
#define JUGBASE_PILEUPDIGITRACKERHITSMERGETOOL_H
// Gaudi
#include "GaudiAlg/GaudiTool.h"
// FCCSW
#include "JugBase/DataHandle.h"
#include "JugBase/IEDMMergeTool.h"
namespace fcc {
class PositionedTrackHit;
class PositionedTrackHitCollection;
class DigiTrackHitAssociation;
class DigiTrackHitAssociationCollection;
class MCParticle;
class MCParticleCollection;
}
/** @class PileupDigiTrackHitMergeTool
*
* Implemenation of the MergeTool for Digitization hits and, if requested, simulated hits.
* While merging, this algorithm tries to keep the trackIDs unique by adding the pileup event number with an offset.
* This should be transparent, but the trackIDs will be non-consecutive.
*
*/
class PileupDigiTrackHitMergeTool : public GaudiTool, virtual public IEDMMergeTool {
public:
explicit PileupDigiTrackHitMergeTool(const std::string& aType, const std::string& aName, const IInterface* aParent);
virtual ~PileupDigiTrackHitMergeTool() = default;
virtual StatusCode initialize() override final;
virtual StatusCode finalize() override final;
/// fill the member containers of collection pointers in this class with a collection from the event store
virtual StatusCode readPileupCollection(podio::EventStore& store) override final;
/// merge the collections in the member container and put them on the event store
virtual StatusCode mergeCollections() override final;
/// fill the member container of collection pointer with a collection from the event store
virtual StatusCode readSignal() override final;
private:
/// Name of the branch from which to read pileup collection
Gaudi::Property<std::string> m_pileupHitsBranchName{this, "pileupHitsBranch", "positionedHits",
"Name of the branch from which to read pileup collection"};
/// Name of the branch from which to read pileup collection
Gaudi::Property<std::string> m_pileupPosHitsBranchName{this, "pileupDigiHitsBranch", "digiHits",
"Name of the branch from which to read pileup collection"};
/// Name of the branch from which to read pileup collection
Gaudi::Property<std::string> m_pileupParticleBranchName{this, "pileupParticleBranch", "simParticles",
"Name of the branch from which to read pileup collection"};
/// Flag indicating if particles are present and should be merged
Gaudi::Property<bool> m_mergeParticles{this, "mergeParticles", false,
"Flag indicating if particles are present and should be merged"};
/// internal container to keep of collections to be merged
std::vector<const fcc::PositionedTrackHitCollection*> m_hitCollections;
/// internal container to keep of collections to be merged
std::vector<const fcc::DigiTrackHitAssociationCollection*> m_digiTrackHitsCollections;
/// internal container to keep of collections to be merge
std::vector<const fcc::MCParticleCollection*> m_particleCollections;
/// Output of this tool: merged collection
DataHandle<fcc::PositionedTrackHitCollection> m_hitsMerged{"overlay/hits", Gaudi::DataHandle::Writer, this};
/// Output of this tool: merged collection
DataHandle<fcc::DigiTrackHitAssociationCollection> m_digiHitsMerged{"overlay/digiHits", Gaudi::DataHandle::Writer,
this};
/// Output of this tool: merged collection
DataHandle<fcc::MCParticleCollection> m_particlesMerged{"overlay/particles", Gaudi::DataHandle::Writer, this};
/// input to this tool: signal collection
DataHandle<fcc::PositionedTrackHitCollection> m_hitsSignal{"overlay/signalHits", Gaudi::DataHandle::Reader, this};
/// input to this tool: signal collection
DataHandle<fcc::DigiTrackHitAssociationCollection> m_posHitsSignal{"overlay/signalDigiHits",
Gaudi::DataHandle::Reader, this};
/// input to this tool: signal collection
DataHandle<fcc::MCParticleCollection> m_particlesSignal{"overlay/signalParticles", Gaudi::DataHandle::Reader, this};
/// offset with which the pileup event number is added to the trackID
const unsigned int m_trackIDCollectionOffset = 2.5e6;
/// Mask to obtain system ID
const unsigned long long m_systemMask = 0xf;
/// Private function internally used to check if a hit is a tracker hit
bool isTrackerHit(unsigned long long cellId) const;
};
inline bool PileupDigiTrackHitMergeTool::isTrackerHit(unsigned long long cellId) const {
return ((cellId & m_systemMask) < 5);
}
#endif // JUGBASE_PILEUPDIGITRACKERHITSMERGETOOL_H
#include "PileupHitMergeTool.h"
#include "podio/EventStore.h"
#include "datamodel/CaloHitCollection.h"
#include "datamodel/PositionedCaloHitCollection.h"
#include "datamodel/PositionedTrackHitCollection.h"
#include "datamodel/TrackHitCollection.h"
typedef PileupHitMergeTool<fcc::CaloHitCollection, fcc::PositionedCaloHitCollection> PileupCaloHitMergeTool;
typedef PileupHitMergeTool<fcc::TrackHitCollection, fcc::PositionedTrackHitCollection> PileupTrackHitMergeTool;
DECLARE_COMPONENT(PileupTrackHitMergeTool)
DECLARE_COMPONENT_WITH_ID(PileupTrackHitMergeTool, "PileupTrackHitMergeTool")
DECLARE_COMPONENT(PileupCaloHitMergeTool)
DECLARE_COMPONENT_WITH_ID(PileupCaloHitMergeTool, "PileupCaloHitMergeTool")
template <class Hits, class PositionedHits>
PileupHitMergeTool<Hits, PositionedHits>::PileupHitMergeTool(const std::string& aType, const std::string& aName,
const IInterface* aParent)
: GaudiTool(aType, aName, aParent) {
declareInterface<IEDMMergeTool>(this);
declareProperty("signalHits", m_hitsSignal);
declareProperty("signalPositionedHits", m_posHitsSignal);
declareProperty("mergedHits", m_hitsMerged);
declareProperty("mergedPositionedHits", m_posHitsMerged);
}
template <class Hits, class PositionedHits>
StatusCode PileupHitMergeTool<Hits, PositionedHits>::initialize() {
return StatusCode::SUCCESS;
}
template <class Hits, class PositionedHits>
StatusCode PileupHitMergeTool<Hits, PositionedHits>::finalize() {
return StatusCode::SUCCESS;
}
template <class Hits, class PositionedHits>
StatusCode PileupHitMergeTool<Hits, PositionedHits>::readPileupCollection(podio::EventStore& store) {
// local pointers, to be filled by the event store
const Hits* hitCollection;
const PositionedHits* posHitCollection;
// get collection address and store it in container
bool hitCollectionPresent = store.get(m_pileupHitsBranchName, hitCollection);
if (hitCollectionPresent) {
m_hitCollections.push_back(hitCollection);
} else {
warning() << "No collection could be read from branch " << m_pileupHitsBranchName << endmsg;
return StatusCode::FAILURE;
}
/// as above, for the positioned collection
bool posHitCollectionPresent = store.get(m_pileupPosHitsBranchName, posHitCollection);
if (posHitCollectionPresent) {
m_posHitCollections.push_back(posHitCollection);
} else {
warning() << "No collection could be read from branch " << m_pileupPosHitsBranchName << endmsg;
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
template <class Hits, class PositionedHits>
StatusCode PileupHitMergeTool<Hits, PositionedHits>::readSignal() {
// get collection from event sture
auto collHitsSig = m_hitsSignal.get();
auto collPosHitsSig = m_posHitsSignal.get();
// store them in internal container
m_hitCollections.push_back(collHitsSig);
m_posHitCollections.push_back(collPosHitsSig);
return StatusCode::SUCCESS;
}
template <class Hits, class PositionedHits>
StatusCode PileupHitMergeTool<Hits, PositionedHits>::mergeCollections() {
// ownership given to data service at end of execute
Hits* collHitsMerged = new Hits();
PositionedHits* collPosHitsMerged = new PositionedHits();
unsigned int collectionCounter = 0;
for (auto hitColl : m_hitCollections) {
// copy hits
for (const auto elem : *hitColl) {
auto clon = elem.clone();
// add pileup vertex counter with an offset
// i.e. for the signal event, 'bits' is just the trackID taken from geant
// for the n-th pileup event, 'bits' is the trackID + n * offset
// offset needs to be big enough to ensure uniqueness of trackID
if (elem.bits() > m_trackIDCollectionOffset) {
error() << "Event contains too many tracks to guarantee a unique trackID";
error() << " The offset width or trackID field size needs to be adjusted!" << endmsg;
return StatusCode::FAILURE;
}
clon.bits(clon.bits() + collectionCounter * m_trackIDCollectionOffset);
collHitsMerged->push_back(clon);
}
++collectionCounter;
}
for (auto posHitColl : m_posHitCollections) {
// copy positioned hits
for (const auto elem : *posHitColl) {
collPosHitsMerged->push_back(elem.clone());
}
}
m_hitsMerged.put(collHitsMerged);
m_posHitsMerged.put(collPosHitsMerged);
m_hitCollections.clear();
m_posHitCollections.clear();
return StatusCode::SUCCESS;
}
#ifndef JUGBASE_PILEUPTRACKERHITSMERGETOOL_H
#define JUGBASE_PILEUPTRACKERHITSMERGETOOL_H
// Gaudi
#include "GaudiAlg/GaudiTool.h"
// FCCSW
#include "JugBase/DataHandle.h"
#include "JugBase/IEDMMergeTool.h"
namespace fcc {
class HitCollection;
class PositionedHitCollection;
}
/** @class PileupHitMergeTool
*
* Implemenation of the MergeTool for *Hits and *PositionedHits, templated to give versions for Tracker / Calorimeter
* While merging, this algorithm tries to keep the trackIDs unique by adding the pileup event number with an offset.
* This should be transparent, but the trackIDs will be non-consecutive.
*
*
*/
template <class Hits, class PositionedHits>
class PileupHitMergeTool : public GaudiTool, virtual public IEDMMergeTool {
public:
explicit PileupHitMergeTool(const std::string& aType, const std::string& aName, const IInterface* aParent);
virtual ~PileupHitMergeTool() = default;
virtual StatusCode initialize() override final;
virtual StatusCode finalize() override final;
/// fill the member containers of collection pointers in this class with a collection from the event store
virtual StatusCode readPileupCollection(podio::EventStore& store) override final;
/// merge the collections in the member container and put them on the event store
virtual StatusCode mergeCollections() override final;
/// fill the member container of collection pointer with a collection from the event store
virtual StatusCode readSignal() override final;
private:
/// Name of the branch from which to read pileup collection
Gaudi::Property<std::string> m_pileupHitsBranchName{this, "pileupHitsBranch", "hits",
"Name of the branch from which to read pileup collection"};
/// Name of the branch from which to read pileup collection
Gaudi::Property<std::string> m_pileupPosHitsBranchName{this, "pileupPositionedHitsBranch", "positionedHits",
"Name of the branch from which to read pileup collection"};
/// internal container to keep of collections to be merged
std::vector<const Hits*> m_hitCollections;
/// internal container to keep of collections to be merged
std::vector<const PositionedHits*> m_posHitCollections;
/// Output of this tool: merged collection
DataHandle<Hits> m_hitsMerged{"overlay/hits", Gaudi::DataHandle::Writer, this};
/// Output of this tool: merged collection
DataHandle<PositionedHits> m_posHitsMerged{"overlay/positionedHits", Gaudi::DataHandle::Writer, this};
/// input to this tool: signal collection
DataHandle<Hits> m_hitsSignal{"overlay/signalHits", Gaudi::DataHandle::Reader, this};
/// input to this tool: signal collection
DataHandle<PositionedHits> m_posHitsSignal{"overlay/signalPositionedHits", Gaudi::DataHandle::Reader, this};
/// offset with which the pileup event number is added to the trackID
const unsigned int m_trackIDCollectionOffset = 2 << 20;
};
#endif // JUGBASE_PILEUPTRACKERHITSMERGETOOL_H
#include "PileupOverlayAlg.h"
#include "JugBase/IEDMMergeTool.h"
DECLARE_COMPONENT(PileupOverlayAlg)
PileupOverlayAlg::PileupOverlayAlg(const std::string& aName, ISvcLocator* aSvcLoc)
: GaudiAlgorithm(aName, aSvcLoc), m_store(), m_reader() {
declareProperty("PileUpTool", m_pileUpTool);
}
StatusCode PileupOverlayAlg::initialize() {
for (auto& toolname : m_saveToolNames) {
m_mergeTools.push_back(tool<IEDMMergeTool>(toolname));
}
m_minBiasEventIndex = 0;
StatusCode sc = GaudiAlgorithm::initialize();
IRndmGenSvc* randSvc = svc<IRndmGenSvc>("RndmGenSvc", true);
sc = m_flatDist.initialize(randSvc, Rndm::Flat(0., 1.));
m_pileupFileIndex = 0;
if (m_doShuffleInputFiles) {
m_pileupFileIndex = static_cast<unsigned int>(m_flatDist() * m_pileupFilenames.size());
}
m_reader.openFiles({m_pileupFilenames[m_pileupFileIndex]});
m_store.setReader(&m_reader);
return sc;
}
StatusCode PileupOverlayAlg::finalize() {
StatusCode sc = GaudiAlgorithm::finalize();
return sc;
}
StatusCode PileupOverlayAlg::execute() {
unsigned nEvents = m_reader.getEntries();
if (!m_noSignal) {
for (auto& tool : m_mergeTools) {
tool->readSignal();
}
}
const unsigned int numPileUp = m_pileUpTool->numberOfPileUp();
for (unsigned iev = 0; iev < numPileUp; ++iev) {
// introduce some randomness into min bias event selection
// to avoid bias
if (m_randomizePileup == true) {
if (m_flatDist() < m_skipProbability) {
++m_minBiasEventIndex;
}
}
m_reader.goToEvent(m_minBiasEventIndex);
verbose() << "Reading in pileup event #" << m_minBiasEventIndex << " from pool #" << m_pileupFileIndex << " ..."
<< endmsg;
for (auto& tool : m_mergeTools) {
tool->readPileupCollection(m_store);
}
m_minBiasEventIndex = (m_minBiasEventIndex + 1);
if (m_minBiasEventIndex >= nEvents) {
m_minBiasEventIndex = 0;
if (m_doShuffleInputFiles) {
m_pileupFileIndex = static_cast<unsigned int>(m_flatDist() * m_pileupFilenames.size());
} else {
m_pileupFileIndex = (m_pileupFileIndex + 1) % m_pileupFilenames.size();
}
m_store.clearCaches();
m_reader.closeFiles();
verbose() << "switching to pileup file " << m_pileupFilenames[m_pileupFileIndex] << endmsg;
m_reader.openFiles({m_pileupFilenames[m_pileupFileIndex]});
nEvents = m_reader.getEntries();
}
m_store.clearCaches();
}
for (auto& tool : m_mergeTools) {
tool->mergeCollections();
}
return StatusCode::SUCCESS;
}
#ifndef JUGBASE_PILEUPOVERLAYALG_H
#define JUGBASE_PILEUPOVERLAYALG_H
#include "JugBase/DataHandle.h"
#include "JugBase/IEDMMergeTool.h"
#include "JugBase/IPileUpTool.h"
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiKernel/RndmGenerators.h"
#include "podio/EventStore.h"
#include "podio/ROOTReader.h"
// forward declarations
class IEDMMergeTool;
/*** @class PileupOverlayAlg
* Algorithm for Pileup I/O and merging
*
* The main purpose of this class is to keep a list of merge tools corresponding to different
* datatypes, open a file and let the tools read pileup data and merge it with the signal.
* It is thus flexible with regards to the data collection types, as everything is delegated to
* tools with a very general interface. One thing this algorithm does do is keep track of the
* number of pileup events (via the pileup tool) and the current position in the minimum bias pool
* ( which can be randomized by skipping events with a probability that can be set in the options file ).
*
*/
class PileupOverlayAlg : public GaudiAlgorithm {
public:
explicit PileupOverlayAlg(const std::string&, ISvcLocator*);
virtual ~PileupOverlayAlg() = default;
virtual StatusCode initialize() override final;
virtual StatusCode execute() override final;
virtual StatusCode finalize() override final;
private:
/// flag to determine whether to randomly skipy events when reading the pileup store
Gaudi::Property<bool> m_randomizePileup{
this, "randomizePileup", false,
"flag to determine whether to randomly skip events when reading the pileup store"};
/// probability of skipping next event in randomized read
Gaudi::Property<float> m_skipProbability{this, "skipProbability", 0.5, "Probability with which to skip next event"};
/// random number generator for randomizing pileup reads
Rndm::Numbers m_flatDist;
/// Pileup Tool to specify the number of minimum bias events
ToolHandle<IPileUpTool> m_pileUpTool{"ConstPileUp/PileUpTool", this};
/// vector of tool interface pointers, to be replaced with ToolHandleArray
std::vector<IEDMMergeTool*> m_mergeTools;
/// names of the merge tools
Gaudi::Property<std::vector<std::string>> m_saveToolNames{this, "mergeTools", {}, "names of the merge tools"};
// list of minimum bias data readers / stores
// once the root reader supports multiple files
// this algo should take advantage of it
/// list of filenames for the minimum bias pools
Gaudi::Property<std::vector<std::string>> m_pileupFilenames{
this, "pileupFilenames", {"min_bias_pool.root"}, "Name of File containing pileup events"};
Gaudi::Property<bool> m_doShuffleInputFiles{this, "doShuffleInputFiles", false, "Shuffle list of input files for additional randomization"};
Gaudi::Property<bool> m_noSignal{this, "noSignal", false, "Set to true if you don't want to provide a signal collection"};
/// store for the minimum bias file
podio::EventStore m_store;
/// reader for the minimum bias file
podio::ROOTReader m_reader;
/// event index within current minimum bias pool
unsigned int m_minBiasEventIndex;
/// index of the current minimum bias pool
unsigned int m_pileupFileIndex;
};
#endif /* JUGBASE_PILEUPOVERLAYALG_H */
#include "PileupParticlesMergeTool.h"
#include "podio/EventStore.h"
#include "datamodel/GenVertexCollection.h"
#include "datamodel/MCParticleCollection.h"
DECLARE_COMPONENT(PileupParticlesMergeTool)
PileupParticlesMergeTool::PileupParticlesMergeTool(const std::string& aType, const std::string& aName,
const IInterface* aParent)
: GaudiTool(aType, aName, aParent) {
declareInterface<IEDMMergeTool>(this);
declareProperty("signalGenVertices", m_vertIn);
declareProperty("signalGenParticles", m_partIn);
declareProperty("mergedGenParticles", m_partOut);
declareProperty("mergedGenVertices", m_vertOut);
}
StatusCode PileupParticlesMergeTool::initialize() { return StatusCode::SUCCESS; }
StatusCode PileupParticlesMergeTool::finalize() { return StatusCode::SUCCESS; }
StatusCode PileupParticlesMergeTool::readPileupCollection(podio::EventStore& store) {
const fcc::MCParticleCollection* mcParticleCollection;
const fcc::GenVertexCollection* genVertexCollection;
bool mcParticleCollectionPresent = store.get(m_pileupGenParticlesBranchName, mcParticleCollection);
debug() << "size of collection about to be read " << mcParticleCollection->size() << endmsg;
if (mcParticleCollectionPresent) {
m_MCParticleCollections.push_back(mcParticleCollection);
} else {
warning() << "No collection could be read from branch " << m_pileupGenParticlesBranchName << endmsg;
}
bool genVertexCollectionPresent = store.get(m_pileupGenVerticesBranchName, genVertexCollection);
if (genVertexCollectionPresent) {
m_GenVertexCollections.push_back(genVertexCollection);
} else {
warning() << "No collection could be read from branch " << m_pileupGenVerticesBranchName << endmsg;
}
return StatusCode::SUCCESS;
}
StatusCode PileupParticlesMergeTool::readSignal() {
auto collVSig = m_vertIn.get();
auto collPSig = m_partIn.get();
m_MCParticleCollections.push_back(collPSig);
m_GenVertexCollections.push_back(collVSig);
return StatusCode::SUCCESS;
}
StatusCode PileupParticlesMergeTool::mergeCollections() {
debug() << "merge " << m_GenVertexCollections.size() << " collections ..." << endmsg;
// ownership given to data service at end of execute
fcc::MCParticleCollection* collPOut = new fcc::MCParticleCollection();
fcc::GenVertexCollection* collVOut = new fcc::GenVertexCollection();
// need to keep track of the accumulated length
// of collections already merged
unsigned int collectionOffset = 0;
// merge vertices
for (auto genVertexColl : m_GenVertexCollections) {
debug() << " traverse collection of size " << genVertexColl->size() << endmsg;
for (const auto elem : *genVertexColl) {
collVOut->push_back(elem.clone());
}
}
// merge particles, keeping the references up to date
for (unsigned int collCounter = 0; collCounter < m_MCParticleCollections.size(); ++collCounter) {
auto mcPartColl = m_MCParticleCollections[collCounter];
for (const auto elem : *mcPartColl) {
auto newPart = fcc::MCParticle(elem.core());
if (elem.startVertex().isAvailable()) {
// update reference: find new index in merged collection
// add offset since the signal particles are copied in new collection first
unsigned int newIdStart = elem.startVertex().getObjectID().index + collectionOffset;
// update startVertex
newPart.startVertex((*collVOut)[newIdStart]);
}
if (elem.endVertex().isAvailable()) {
// update reference: find new index in merged collection
// add offset since the signal particles are copied in new collection first
unsigned int newIdEnd = elem.endVertex().getObjectID().index + collectionOffset;
// update startVertex
newPart.endVertex((*collVOut)[newIdEnd]);
}
collPOut->push_back(newPart);
}
collectionOffset += m_GenVertexCollections[collCounter]->size();
}
m_vertOut.put(collVOut);
m_partOut.put(collPOut);
m_MCParticleCollections.clear();
m_GenVertexCollections.clear();
return StatusCode::SUCCESS;
}
#ifndef JUGBASE_PILEUPPARTICLESMERGETOOL_H
#define JUGBASE_PILEUPPARTICLESMERGETOOL_H
// Gaudi
#include "GaudiAlg/GaudiTool.h"
// FCCSW
#include "JugBase/DataHandle.h"
#include "JugBase/IEDMMergeTool.h"
namespace fcc {
class MCParticleCollection;
class GenVertexCollection;
}
/** @class PileupParticlesMergeTool
*
* Implementation of the EDMMergeTool interface used for pileup overlay
* of generated particles. Keeps track of the association between particles and vertices.
*/
class PileupParticlesMergeTool : public GaudiTool, virtual public IEDMMergeTool {
public:
explicit PileupParticlesMergeTool(const std::string& aType, const std::string& aName, const IInterface* aParent);
virtual ~PileupParticlesMergeTool() = default;
virtual StatusCode initialize() override final;
virtual StatusCode finalize() override final;
virtual StatusCode readPileupCollection(podio::EventStore& store) override final;
virtual StatusCode mergeCollections() override final;
virtual StatusCode readSignal() override final;
private:
Gaudi::Property<std::string> m_pileupGenParticlesBranchName{this, "genParticlesBranch", "genParticles", ""};
Gaudi::Property<std::string> m_pileupGenVerticesBranchName{this, "genVerticesBranch", "genVertices", ""};
std::vector<const fcc::MCParticleCollection*> m_MCParticleCollections;
std::vector<const fcc::GenVertexCollection*> m_GenVertexCollections;
DataHandle<fcc::GenVertexCollection> m_vertOut{"overlay/allGenVertices", Gaudi::DataHandle::Writer, this};
DataHandle<fcc::MCParticleCollection> m_partOut{"overlay/allGenParticles", Gaudi::DataHandle::Writer, this};
DataHandle<fcc::GenVertexCollection> m_vertIn{"overlay/signalGenVertices", Gaudi::DataHandle::Reader, this};
DataHandle<fcc::MCParticleCollection> m_partIn{"overlay/signalGenParticles", Gaudi::DataHandle::Reader, this};
};
#endif // JUGBASE_PILEUPPARTICLESMERGETOOL_H
#include "PodioInput.h"
#include "TFile.h"
#include "TROOT.h"
#include "JugBase/DataWrapper.h"
#include "JugBase/PodioDataSvc.h"
DECLARE_COMPONENT(PodioInput)
PodioInput::PodioInput(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) {}
StatusCode PodioInput::initialize() {
if (GaudiAlgorithm::initialize().isFailure()) return StatusCode::FAILURE;
// check whether we have the PodioEvtSvc active
m_podioDataSvc = dynamic_cast<PodioDataSvc*>(evtSvc().get());
if (nullptr == m_podioDataSvc) return StatusCode::FAILURE;
auto idTable = m_podioDataSvc->getCollectionIDs();
for (auto& name : m_collectionNames) {
debug() << "Finding collection " << name << " in collection registry." << endmsg;
if (!idTable->present(name)) {
error() << "Requested product " << name << " not found." << endmsg;
return StatusCode::FAILURE;
}
m_collectionIDs.push_back(idTable->collectionID(name));
}
return StatusCode::SUCCESS;
}
StatusCode PodioInput::execute() {
size_t cntr = 0;
// Re-create the collections from ROOT file
for (auto& id : m_collectionIDs) {
const std::string& collName = m_collectionNames.value().at(cntr++);
debug() << "Registering collection to read " << collName << " with id " << id << endmsg;
if (m_podioDataSvc->readCollection(collName, id).isFailure()) {
return StatusCode::FAILURE;
}
}
// Tell data service that we are done with requested collections
m_podioDataSvc->endOfRead();
return StatusCode::SUCCESS;
}
StatusCode PodioInput::finalize() {
if (GaudiAlgorithm::finalize().isFailure()) return StatusCode::FAILURE;
return StatusCode::SUCCESS;
}
#ifndef JUGBASE_PODIOINPUT_H
#define JUGBASE_PODIOINPUT_H
// Gaaudi
#include "GaudiAlg/GaudiAlgorithm.h"
// STL
#include <string>
#include <vector>
// forward declarations
// from JugBase:
class PodioDataSvc;
/** @class PodioInput JugBase/components/PodioInput.h PodioInput.h
*
* Class that allows to read ROOT files written with PodioOutput
*
* @author J. Lingemann
*/
class PodioInput : public GaudiAlgorithm {
public:
/// Constructor.
PodioInput(const std::string& name, ISvcLocator* svcLoc);
/// Initialization of PodioInput. Acquires the data service, opens root file and creates trees.
virtual StatusCode initialize();
/// Execute. Re-creates collections that are specified to be read and sets references.
virtual StatusCode execute();
/// Finalize. Closes ROOT file.
virtual StatusCode finalize();
private:
/// Name of collections to read. Set by option collections (this is temporary)
Gaudi::Property<std::vector<std::string>> m_collectionNames{this, "collections", {}, "Places of collections to read"};
/// Collection IDs (retrieved with CollectionIDTable from ROOT file, using collection names)
std::vector<int> m_collectionIDs;
/// Data service: needed to register objects and get collection IDs. Just an observing pointer.
PodioDataSvc* m_podioDataSvc;
};
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#include "RangePileUp.h"
DECLARE_COMPONENT(RangePileUp)
RangePileUp::RangePileUp(const std::string& type, const std::string& name, const IInterface* parent)
: GaudiTool(type, name, parent) {
declareInterface<IPileUpTool>(this);
}
RangePileUp::~RangePileUp() { ; }
StatusCode RangePileUp::initialize() {
StatusCode sc = GaudiTool::initialize();
if (sc.isFailure()) return sc;
return sc;
}
unsigned int RangePileUp::numberOfPileUp() {
m_currentNumPileUpEvents = m_pileupRange[m_rangeIndex];
m_rangeIndex = (m_rangeIndex + 1) % m_pileupRange.size();
return m_currentNumPileUpEvents;
}
double RangePileUp::getMeanPileUp() { return m_currentNumPileUpEvents; }
void RangePileUp::printPileUpCounters() {
info() << "Current number of pileup events: " << m_currentNumPileUpEvents << endmsg;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.