Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:29:24

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022-2025 Christopher Dilks, Simon Gardner
0003 
0004 #include <JANA/JApplicationFwd.h>
0005 #include <JANA/Utils/JTypeInfo.h>
0006 #include <edm4eic/MCRecoParticleAssociation.h>
0007 #include <edm4eic/ReconstructedParticle.h>
0008 #include <fmt/core.h>
0009 #include <cmath>
0010 #include <map>
0011 #include <memory>
0012 #include <string>
0013 #include <vector>
0014 
0015 #include "algorithms/pid_lut/PIDLookupConfig.h"
0016 #include "extensions/jana/JOmniFactoryGeneratorT.h"
0017 #include "factories/meta/CollectionCollector_factory.h"
0018 // factories
0019 #include "factories/pid_lut/PIDLookup_factory.h"
0020 
0021 extern "C" {
0022 void InitPlugin(JApplication* app) {
0023   InitJANAPlugin(app);
0024 
0025   using namespace eicrecon;
0026 
0027   //-------------------------------------------------------------------------
0028   // PFRICH PID
0029   //-------------------------------------------------------------------------
0030   PIDLookupConfig pfrich_pid_cfg{
0031       .filename       = "calibrations/pfrich.lut",
0032       .system         = "BackwardRICH_ID",
0033       .pdg_values     = {11, 211, 321, 2212},
0034       .charge_values  = {1},
0035       .momentum_edges = {0.4,  0.8,  1.2,  1.6, 2,    2.4,  2.8,  3.2,  3.6, 4,    4.4,  4.8, 5.2,
0036                          5.6,  6,    6.4,  6.8, 7.2,  7.6,  8,    8.4,  8.8, 9.2,  9.6,  10,  10.4,
0037                          10.8, 11.2, 11.6, 12,  12.4, 12.8, 13.2, 13.6, 14,  14.4, 14.8, 15.2},
0038       // NOLINTBEGIN(modernize-use-std-numbers)
0039       .polar_edges = {2.65,  2.6725, 2.695, 2.7175, 2.74,  2.7625, 2.785, 2.8075, 2.83,  2.8525,
0040                       2.875, 2.8975, 2.92,  2.9425, 2.965, 2.9875, 3.01,  3.0325, 3.055, 3.0775},
0041       // NOLINTEND(modernize-use-std-numbers)
0042       .azimuthal_binning            = {0., 2 * M_PI, 2 * M_PI / 120.}, // lower, upper, step
0043       .azimuthal_bin_centers_in_lut = true,
0044       .momentum_bin_centers_in_lut  = true,
0045       .polar_bin_centers_in_lut     = true,
0046       .use_radians                  = true,
0047   };
0048 
0049   app->Add(new JOmniFactoryGeneratorT<PIDLookup_factory>(
0050       "RICHEndcapNTruthSeededLUTPID",
0051       {
0052           "EventHeader",
0053           "ReconstructedTruthSeededChargedWithoutPIDParticles",
0054           "ReconstructedTruthSeededChargedWithoutPIDParticleAssociations",
0055       },
0056       {
0057           "ReconstructedTruthSeededChargedWithPFRICHPIDParticles",
0058           "ReconstructedTruthSeededChargedWithPFRICHPIDParticleAssociations",
0059           "RICHEndcapNTruthSeededParticleIDs",
0060       },
0061       pfrich_pid_cfg, app));
0062 
0063   app->Add(new JOmniFactoryGeneratorT<PIDLookup_factory>(
0064       "RICHEndcapNLUTPID",
0065       {
0066           "EventHeader",
0067           "ReconstructedChargedWithoutPIDParticles",
0068           "ReconstructedChargedWithoutPIDParticleAssociations",
0069       },
0070       {
0071           "ReconstructedChargedWithPFRICHPIDParticles",
0072           "ReconstructedChargedWithPFRICHPIDParticleAssociations",
0073           "RICHEndcapNParticleIDs",
0074       },
0075       pfrich_pid_cfg, app));
0076 
0077   //-------------------------------------------------------------------------
0078   // TOF PID
0079   //-------------------------------------------------------------------------
0080 
0081   PIDLookupConfig tof_pid_cfg{
0082       .filename       = "calibrations/tof.lut",
0083       .system         = "BarrelTOF_ID",
0084       .pdg_values     = {11, 211, 321, 2212},
0085       .charge_values  = {1},
0086       .momentum_edges = {0.0, 0.3, 0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4, 2.7, 3.0,
0087                          3.3, 3.6, 3.9, 4.2, 4.5, 4.8, 5.1, 5.4, 5.7, 6.0},
0088       .polar_edges    = {2.50, 10.95, 19.40, 27.85, 36.30, 44.75, 53.20, 61.65, 70.10, 78.55, 87.00,
0089                          95.45, 103.90, 112.35, 120.80, 129.25, 137.70, 146.15, 154.60},
0090       .azimuthal_binning           = {0., 360., 360.}, // lower, upper, step
0091       .momentum_bin_centers_in_lut = true,
0092       .polar_bin_centers_in_lut    = true,
0093   };
0094 
0095   app->Add(new JOmniFactoryGeneratorT<PIDLookup_factory>(
0096       "CombinedTOFTruthSeededLUTPID",
0097       {
0098           "EventHeader",
0099           "ReconstructedTruthSeededChargedWithPFRICHPIDParticles",
0100           "ReconstructedTruthSeededChargedWithPFRICHPIDParticleAssociations",
0101       },
0102       {
0103           "ReconstructedTruthSeededChargedWithPFRICHTOFPIDParticles",
0104           "ReconstructedTruthSeededChargedWithPFRICHTOFPIDParticleAssociations",
0105           "CombinedTOFTruthSeededParticleIDs",
0106       },
0107       tof_pid_cfg, app));
0108 
0109   app->Add(new JOmniFactoryGeneratorT<PIDLookup_factory>(
0110       "CombinedTOFLUTPID",
0111       {
0112           "EventHeader",
0113           "ReconstructedChargedWithPFRICHPIDParticles",
0114           "ReconstructedChargedWithPFRICHPIDParticleAssociations",
0115       },
0116       {
0117           "ReconstructedChargedWithPFRICHTOFPIDParticles",
0118           "ReconstructedChargedWithPFRICHTOFPIDParticleAssociations",
0119           "CombinedTOFParticleIDs",
0120       },
0121       tof_pid_cfg, app));
0122 
0123   //-------------------------------------------------------------------------
0124   // DIRC PID
0125   //-------------------------------------------------------------------------
0126 
0127   PIDLookupConfig dirc_pid_cfg{
0128       .filename       = "calibrations/hpdirc.lut.gz",
0129       .system         = "BarrelDIRC_ID",
0130       .pdg_values     = {11, 211, 321, 2212},
0131       .charge_values  = {-1, 1},
0132       .momentum_edges = {0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2,  2.4, 2.6,
0133                          2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8,  5.0, 5.2,
0134                          5.4, 5.6, 5.8, 6.0, 6.2, 6.4, 6.6, 6.8, 7.0, 7.2, 7.4,  7.6, 7.8,
0135                          8.0, 8.2, 8.4, 8.6, 8.8, 9.0, 9.2, 9.4, 9.6, 9.8, 10.0, 10.2},
0136       .polar_edges    = {25.0,  26.0,  27.0,  28.0,  29.0,  30.0,  31.0,  32.0,  33.0,  34.0,  35.0,
0137                          36.0,  37.0,  38.0,  39.0,  40.0,  41.0,  42.0,  43.0,  44.0,  45.0,  46.0,
0138                          47.0,  48.0,  49.0,  50.0,  51.0,  52.0,  53.0,  54.0,  55.0,  56.0,  57.0,
0139                          58.0,  59.0,  60.0,  61.0,  62.0,  63.0,  64.0,  65.0,  66.0,  67.0,  68.0,
0140                          69.0,  70.0,  71.0,  72.0,  73.0,  74.0,  75.0,  76.0,  77.0,  78.0,  79.0,
0141                          80.0,  81.0,  82.0,  83.0,  84.0,  85.0,  86.0,  87.0,  88.0,  89.0,  90.0,
0142                          91.0,  92.0,  93.0,  94.0,  95.0,  96.0,  97.0,  98.0,  99.0,  100.0, 101.0,
0143                          102.0, 103.0, 104.0, 105.0, 106.0, 107.0, 108.0, 109.0, 110.0, 111.0, 112.0,
0144                          113.0, 114.0, 115.0, 116.0, 117.0, 118.0, 119.0, 120.0, 121.0, 122.0, 123.0,
0145                          124.0, 125.0, 126.0, 127.0, 128.0, 129.0, 130.0, 131.0, 132.0, 133.0, 134.0,
0146                          135.0, 136.0, 137.0, 138.0, 139.0, 140.0, 141.0, 142.0, 143.0, 144.0, 145.0,
0147                          146.0, 147.0, 148.0, 149.0, 150.0, 151.0, 152.0, 153.0, 154.0, 155.0, 156.0,
0148                          157.0, 158.0, 159.0, 160.0},
0149       .azimuthal_binning = {0.0, 30.5, 0.5}, // lower, upper, step
0150   };
0151 
0152   app->Add(new JOmniFactoryGeneratorT<PIDLookup_factory>(
0153       "DIRCTruthSeededLUTPID",
0154       {
0155           "EventHeader",
0156           "ReconstructedTruthSeededChargedWithPFRICHTOFPIDParticles",
0157           "ReconstructedTruthSeededChargedWithPFRICHTOFPIDParticleAssociations",
0158       },
0159       {
0160           "ReconstructedTruthSeededChargedWithPFRICHTOFDIRCPIDParticles",
0161           "ReconstructedTruthSeededChargedWithPFRICHTOFDIRCPIDParticleAssociations",
0162           "DIRCTruthSeededParticleIDs",
0163       },
0164       dirc_pid_cfg, app));
0165 
0166   app->Add(new JOmniFactoryGeneratorT<PIDLookup_factory>(
0167       "DIRCLUTPID",
0168       {
0169           "EventHeader",
0170           "ReconstructedChargedWithPFRICHTOFPIDParticles",
0171           "ReconstructedChargedWithPFRICHTOFPIDParticleAssociations",
0172       },
0173       {
0174           "ReconstructedChargedWithPFRICHTOFDIRCPIDParticles",
0175           "ReconstructedChargedWithPFRICHTOFDIRCPIDParticleAssociations",
0176           "DIRCParticleIDs",
0177       },
0178       dirc_pid_cfg, app));
0179 
0180   // Inject particles from other sources without PID detectors so they are contained
0181   // as a particle in the ReconstructedChargedParticle collection rather than needing
0182   // a subset collection. This should be fixed in the future.
0183 
0184   app->Add(
0185       new JOmniFactoryGeneratorT<CollectionCollector_factory<edm4eic::ReconstructedParticle, true>>(
0186           "ReconstructedWithPFRICHTOFDIRCLOWQ2PIDChargedParticles",
0187           {"ReconstructedChargedWithPFRICHTOFDIRCPIDParticles",
0188            "TaggerTrackerReconstructedParticles"},
0189           {"ReconstructedWithPFRICHTOFDIRCLOWQ2PIDChargedParticles"}, app));
0190 
0191   app->Add(new JOmniFactoryGeneratorT<
0192            CollectionCollector_factory<edm4eic::MCRecoParticleAssociation, true>>(
0193       "ReconstructedChargedWithPFRICHTOFDIRCLOWQ2PIDParticleAssociations",
0194       {"ReconstructedChargedWithPFRICHTOFDIRCPIDParticleAssociations",
0195        "TaggerTrackerReconstructedParticleAssociations"},
0196       {"ReconstructedChargedWithPFRICHTOFDIRCLOWQ2PIDParticleAssociations"}, app));
0197 
0198   // And the same for truth seeded particles and associations
0199 
0200   app->Add(
0201       new JOmniFactoryGeneratorT<CollectionCollector_factory<edm4eic::ReconstructedParticle, true>>(
0202           "ReconstructedTruthSeededChargedWithPFRICHTOFDIRCLOWQ2PIDParticles",
0203           {"ReconstructedTruthSeededChargedWithPFRICHTOFDIRCPIDParticles",
0204            "TaggerTrackerReconstructedParticles"},
0205           {"ReconstructedTruthSeededChargedWithPFRICHTOFDIRCLOWQ2PIDParticles"}, app));
0206 
0207   app->Add(new JOmniFactoryGeneratorT<
0208            CollectionCollector_factory<edm4eic::MCRecoParticleAssociation, true>>(
0209       "ReconstructedTruthSeededChargedWithPFRICHTOFDIRCLOWQ2PIDParticleAssociations",
0210       {"ReconstructedTruthSeededChargedWithPFRICHTOFDIRCPIDParticleAssociations",
0211        "TaggerTrackerReconstructedParticleAssociations"},
0212       {"ReconstructedTruthSeededChargedWithPFRICHTOFDIRCLOWQ2PIDParticleAssociations"}, app));
0213 
0214   //-------------------------------------------------------------------------
0215   // DRICH PID
0216   //-------------------------------------------------------------------------
0217 
0218   PIDLookupConfig drich_pid_cfg{
0219       .filename       = "calibrations/drich.lut.gz",
0220       .system         = "ForwardRICH_ID",
0221       .pdg_values     = {211, 321, 2212},
0222       .charge_values  = {1},
0223       .momentum_edges = {0.75,  1.25,  1.75,  2.25,  2.75,  3.25,  3.75,  4.25,  4.75,  5.25,
0224                          5.75,  6.25,  6.75,  7.25,  7.75,  8.25,  8.75,  9.25,  9.75,  10.25,
0225                          10.75, 11.25, 11.75, 12.25, 12.75, 13.25, 13.75, 14.25, 14.75, 15.25,
0226                          15.75, 16.25, 16.75, 17.25, 17.75, 18.25, 18.75, 19.25, 19.75, 20.25,
0227                          20.75, 21.25, 21.75, 22.25, 22.75, 23.25, 23.75, 24.25, 24.75, 25.25,
0228                          25.75, 26.25, 26.75, 27.25, 27.75, 28.25, 28.75, 29.25, 29.75, 30.25,
0229                          30.75, 31.25, 33.00, 35.00, 37.00, 39.00, 41.00, 43.00, 45.00, 47.00,
0230                          49.00, 51.00, 59.00, 61.00},
0231 
0232       .polar_edges = {0.0635, 0.0702, 0.0776, 0.0858, 0.0948, 0.1047, 0.1157,
0233                       0.1278, 0.1412, 0.1560, 0.1724, 0.1904, 0.2103, 0.2322,
0234                       0.2564, 0.2830, 0.3123, 0.3445, 0.3799, 0.4188},
0235 
0236       .azimuthal_binning           = {0., 2 * M_PI, 2 * M_PI}, // lower, upper, step
0237       .momentum_bin_centers_in_lut = true,
0238       .polar_bin_centers_in_lut    = true,
0239       .use_radians                 = true,
0240       .missing_electron_prob       = true,
0241   };
0242 
0243   app->Add(new JOmniFactoryGeneratorT<PIDLookup_factory>(
0244       "DRICHTruthSeededLUTPID",
0245       {
0246           "EventHeader",
0247           "ReconstructedTruthSeededChargedWithPFRICHTOFDIRCLOWQ2PIDParticles",
0248           "ReconstructedTruthSeededChargedWithPFRICHTOFDIRCLOWQ2PIDParticleAssociations",
0249       },
0250       {
0251           "ReconstructedTruthSeededChargedParticles",
0252           "ReconstructedTruthSeededChargedParticleAssociations",
0253           "DRICHTruthSeededParticleIDs",
0254       },
0255       drich_pid_cfg, app));
0256 
0257   app->Add(new JOmniFactoryGeneratorT<PIDLookup_factory>(
0258       "DRICHLUTPID",
0259       {
0260           "EventHeader",
0261           "ReconstructedWithPFRICHTOFDIRCLOWQ2PIDChargedParticles",
0262           "ReconstructedChargedWithPFRICHTOFDIRCLOWQ2PIDParticleAssociations",
0263       },
0264       {
0265           "ReconstructedChargedParticles",
0266           "ReconstructedChargedParticleAssociations",
0267           "DRICHParticleIDs",
0268       },
0269       drich_pid_cfg, app));
0270 }
0271 }