Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 08:59:58

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 - 2024, Dmitry Romanov, Nathan Brei, Tooba Ali, Wouter Deconinck, Dmitry Kalinkin, John Lajoie, Simon Gardner, Tristan Protzman, Daniel Brandenburg, Derek M Anderson, Sebouh Paul, Tyler Kutz, Alex Jentsch, Jihee Kim, Brian Page
0003 
0004 
0005 #include <Evaluator/DD4hepUnits.h>
0006 #include <JANA/JApplication.h>
0007 #include <edm4eic/Cluster.h>
0008 #include <edm4eic/EDM4eicVersion.h>
0009 #include <edm4eic/InclusiveKinematics.h>
0010 #include <edm4eic/MCRecoClusterParticleAssociation.h>
0011 #include <edm4eic/MCRecoParticleAssociation.h>
0012 #include <edm4eic/ReconstructedParticle.h>
0013 #include <edm4hep/MCParticle.h>
0014 #include <fmt/core.h>
0015 #include <map>
0016 #include <memory>
0017 
0018 #include "algorithms/interfaces/WithPodConfig.h"
0019 
0020 #if EDM4EIC_VERSION_MAJOR >= 6
0021 #include "algorithms/reco/HadronicFinalState.h"
0022 #include "algorithms/reco/InclusiveKinematicsDA.h"
0023 #include "algorithms/reco/InclusiveKinematicsESigma.h"
0024 #include "algorithms/reco/InclusiveKinematicsElectron.h"
0025 #include "algorithms/reco/InclusiveKinematicsJB.h"
0026 #include "algorithms/reco/InclusiveKinematicsSigma.h"
0027 #endif
0028 #include "extensions/jana/JOmniFactoryGeneratorT.h"
0029 #include "factories/meta/CollectionCollector_factory.h"
0030 #include "factories/meta/FilterMatching_factory.h"
0031 #include "factories/reco/FarForwardNeutronReconstruction_factory.h"
0032 #ifdef USE_ONNX
0033 #include "factories/reco/InclusiveKinematicsML_factory.h"
0034 #endif
0035 #if EDM4EIC_VERSION_MAJOR >= 6
0036 #include "factories/reco/InclusiveKinematicsReconstructed_factory.h"
0037 #endif
0038 #include "factories/reco/InclusiveKinematicsTruth_factory.h"
0039 #include "factories/reco/JetReconstruction_factory.h"
0040 #include "factories/reco/TransformBreitFrame_factory.h"
0041 #if EDM4EIC_VERSION_MAJOR >= 6
0042 #include "factories/reco/HadronicFinalState_factory.h"
0043 #endif
0044 #include "factories/reco/UndoAfterBurnerMCParticles_factory.h"
0045 #include "global/reco/ChargedReconstructedParticleSelector_factory.h"
0046 #include "global/reco/MC2SmearedParticle_factory.h"
0047 #include "global/reco/MatchClusters_factory.h"
0048 #include "global/reco/PrimaryVertices_factory.h"
0049 #include "global/reco/ReconstructedElectrons_factory.h"
0050 #include "global/reco/ScatteredElectronsEMinusPz_factory.h"
0051 #include "global/reco/ScatteredElectronsTruth_factory.h"
0052 
0053 extern "C" {
0054 void InitPlugin(JApplication *app) {
0055     InitJANAPlugin(app);
0056 
0057     using namespace eicrecon;
0058 
0059     // Finds associations matched to initial scattered electrons
0060     app->Add(new JOmniFactoryGeneratorT<FilterMatching_factory< edm4eic::MCRecoParticleAssociation,
0061                                                                 [](auto* obj) { return obj->getSim().getObjectID();},
0062                                                                 edm4hep::MCParticle,
0063                                                                 [](auto* obj) { return obj->getObjectID(); }>>(
0064           "MCScatteredElectronAssociations",
0065           {"ReconstructedChargedParticleAssociations","MCScatteredElectrons"},
0066           {"MCScatteredElectronAssociations","MCNonScatteredElectronAssociations"},
0067           app
0068     ));
0069 
0070     app->Add(new JOmniFactoryGeneratorT<MC2SmearedParticle_factory>(
0071             "GeneratedParticles",
0072             {"MCParticles"},
0073             {"GeneratedParticles"},
0074             app
0075             ));
0076 
0077     app->Add(new JOmniFactoryGeneratorT<CollectionCollector_factory<edm4eic::Cluster>>(
0078         "EcalClusters",
0079         {
0080           "EcalEndcapNClusters",
0081           "EcalBarrelScFiClusters",
0082           "EcalEndcapPClusters",
0083         },
0084         {"EcalClusters"},
0085         app));
0086 
0087     app->Add(new JOmniFactoryGeneratorT<CollectionCollector_factory<edm4eic::MCRecoClusterParticleAssociation>>(
0088         "EcalClusterAssociations",
0089         {
0090           "EcalEndcapNClusterAssociations",
0091           "EcalBarrelScFiClusterAssociations",
0092           "EcalEndcapPClusterAssociations",
0093         },
0094         {"EcalClusterAssociations"},
0095         app));
0096 
0097     app->Add(new JOmniFactoryGeneratorT<MatchClusters_factory>(
0098         "ReconstructedParticlesWithAssoc",
0099         {
0100           "MCParticles",
0101           "ReconstructedChargedParticles",
0102           "ReconstructedChargedParticleAssociations",
0103           "EcalClusters",
0104           "EcalClusterAssociations",
0105         },
0106         { "ReconstructedParticles",           // edm4eic::ReconstructedParticle
0107           "ReconstructedParticleAssociations" // edm4eic::MCRecoParticleAssociation
0108         },
0109         app
0110     ));
0111 
0112 
0113     app->Add(new JOmniFactoryGeneratorT<InclusiveKinematicsTruth_factory>(
0114         "InclusiveKinematicsTruth",
0115         {
0116           "MCParticles"
0117         },
0118         {
0119           "InclusiveKinematicsTruth"
0120         },
0121         app
0122     ));
0123 
0124 #if EDM4EIC_VERSION_MAJOR >= 6
0125     app->Add(new JOmniFactoryGeneratorT<InclusiveKinematicsReconstructed_factory<InclusiveKinematicsElectron>>(
0126         "InclusiveKinematicsElectron",
0127         {
0128           "MCParticles",
0129           "ScatteredElectronsTruth",
0130           "HadronicFinalState"
0131         },
0132         {
0133           "InclusiveKinematicsElectron"
0134         },
0135         app
0136     ));
0137 
0138     app->Add(new JOmniFactoryGeneratorT<InclusiveKinematicsReconstructed_factory<InclusiveKinematicsJB>>(
0139         "InclusiveKinematicsJB",
0140         {
0141           "MCParticles",
0142           "ScatteredElectronsTruth",
0143           "HadronicFinalState"
0144         },
0145         {
0146           "InclusiveKinematicsJB"
0147         },
0148         app
0149     ));
0150 
0151     app->Add(new JOmniFactoryGeneratorT<InclusiveKinematicsReconstructed_factory<InclusiveKinematicsDA>>(
0152         "InclusiveKinematicsDA",
0153         {
0154           "MCParticles",
0155           "ScatteredElectronsTruth",
0156           "HadronicFinalState"
0157         },
0158         {
0159           "InclusiveKinematicsDA"
0160         },
0161         app
0162     ));
0163 
0164     app->Add(new JOmniFactoryGeneratorT<InclusiveKinematicsReconstructed_factory<InclusiveKinematicsESigma>>(
0165         "InclusiveKinematicsESigma",
0166         {
0167           "MCParticles",
0168           "ScatteredElectronsTruth",
0169           "HadronicFinalState"
0170         },
0171         {
0172           "InclusiveKinematicsESigma"
0173         },
0174         app
0175     ));
0176 
0177     // InclusiveKinematicseSigma is deprecated and will be removed, use InclusiveKinematicsESigma instead
0178     app->Add(new JOmniFactoryGeneratorT<CollectionCollector_factory<edm4eic::InclusiveKinematics>>(
0179         "InclusiveKinematicseSigma_legacy",
0180         {
0181           "InclusiveKinematicsESigma"
0182         },
0183         {
0184           "InclusiveKinematicseSigma"
0185         },
0186         app
0187     ));
0188 
0189 
0190     app->Add(new JOmniFactoryGeneratorT<InclusiveKinematicsReconstructed_factory<InclusiveKinematicsSigma>>(
0191         "InclusiveKinematicsSigma",
0192         {
0193           "MCParticles",
0194           "ScatteredElectronsTruth",
0195           "HadronicFinalState"
0196         },
0197         {
0198           "InclusiveKinematicsSigma"
0199         },
0200         app
0201     ));
0202 
0203 #ifdef USE_ONNX
0204     app->Add(new JOmniFactoryGeneratorT<InclusiveKinematicsML_factory>(
0205         "InclusiveKinematicsML",
0206         {
0207           "InclusiveKinematicsElectron",
0208           "InclusiveKinematicsDA"
0209         },
0210         {
0211           "InclusiveKinematicsML"
0212         },
0213         app
0214     ));
0215 #endif
0216 #endif
0217 
0218     app->Add(new JOmniFactoryGeneratorT<ReconstructedElectrons_factory>(
0219         "ReconstructedElectrons",
0220         {"ReconstructedParticles"},
0221         {"ReconstructedElectrons"},
0222         {},
0223         app
0224     ));
0225 
0226     app->Add(new JOmniFactoryGeneratorT<ReconstructedElectrons_factory>(
0227         "ReconstructedElectronsForDIS",
0228         {"ReconstructedParticles"},
0229         {"ReconstructedElectronsForDIS"},
0230         {
0231           .min_energy_over_momentum = 0.7, // GeV
0232           .max_energy_over_momentum = 1.3  // GeV
0233         },
0234         app
0235     ));
0236 
0237     app->Add(new JOmniFactoryGeneratorT<JetReconstruction_factory<edm4eic::ReconstructedParticle>>(
0238             "GeneratedJets",
0239             {"GeneratedParticles"},
0240             {"GeneratedJets"},
0241             {},
0242             app
0243     ));
0244 
0245     app->Add(new JOmniFactoryGeneratorT<JetReconstruction_factory<edm4eic::ReconstructedParticle>>(
0246             "ReconstructedJets",
0247             {"ReconstructedParticles"},
0248             {"ReconstructedJets"},
0249             {},
0250             app
0251     ));
0252 
0253     app->Add(new JOmniFactoryGeneratorT<ChargedReconstructedParticleSelector_factory>(
0254             "GeneratedChargedParticles",
0255             {"GeneratedParticles"},
0256             {"GeneratedChargedParticles"},
0257             app
0258     ));
0259 
0260     app->Add(new JOmniFactoryGeneratorT<JetReconstruction_factory<edm4eic::ReconstructedParticle>>(
0261             "GeneratedChargedJets",
0262             {"GeneratedChargedParticles"},
0263             {"GeneratedChargedJets"},
0264             {},
0265             app
0266     ));
0267 
0268     app->Add(new JOmniFactoryGeneratorT<JetReconstruction_factory<edm4eic::ReconstructedParticle>>(
0269             "ReconstructedChargedJets",
0270             {"ReconstructedChargedParticles"},
0271             {"ReconstructedChargedJets"},
0272             {},
0273             app
0274     ));
0275 
0276     app->Add(new JOmniFactoryGeneratorT<ScatteredElectronsTruth_factory>(
0277         "ScatteredElectronsTruth",
0278         {
0279           "MCParticles",
0280           "ReconstructedChargedParticles",
0281           "ReconstructedChargedParticleAssociations"
0282         },
0283         {
0284           "ScatteredElectronsTruth"
0285         },
0286         app
0287     ));
0288 
0289     app->Add(new JOmniFactoryGeneratorT<ScatteredElectronsEMinusPz_factory>(
0290         "ScatteredElectronsEMinusPz",
0291         {
0292           "ReconstructedChargedParticles",
0293           "ReconstructedElectronsForDIS"
0294         },
0295         {
0296           "ScatteredElectronsEMinusPz"
0297         },
0298         {
0299           .minEMinusPz = 0, // GeV
0300           .maxEMinusPz = 10000000.0 // GeV
0301         },
0302         app
0303     ));
0304 
0305     app->Add(new JOmniFactoryGeneratorT<TransformBreitFrame_factory>(
0306             "ReconstructedBreitFrameParticles",
0307             {"MCParticles","InclusiveKinematicsElectron","ReconstructedParticles"},
0308             {"ReconstructedBreitFrameParticles"},
0309             {},
0310             app
0311     ));
0312     app->Add(new JOmniFactoryGeneratorT<FarForwardNeutronReconstruction_factory>(
0313            "ReconstructedFarForwardZDCNeutrons",
0314            {"HcalFarForwardZDCClusters","EcalFarForwardZDCClusters"},  // edm4eic::ClusterCollection
0315           {"ReconstructedFarForwardZDCNeutrons"}, // edm4eic::ReconstrutedParticleCollection,
0316           {
0317             .scale_corr_coeff_hcal={-0.0756, -1.91, 2.30},
0318             .scale_corr_coeff_ecal={-0.352, -1.34, 1.61}
0319           },
0320           app   // TODO: Remove me once fixed
0321     ));
0322 #if EDM4EIC_VERSION_MAJOR >= 6
0323     app->Add(new JOmniFactoryGeneratorT<HadronicFinalState_factory<HadronicFinalState>>(
0324         "HadronicFinalState",
0325         {
0326           "MCParticles",
0327           "ReconstructedParticles",
0328           "ReconstructedParticleAssociations"
0329         },
0330         {
0331           "HadronicFinalState"
0332         },
0333         app
0334     ));
0335 #endif
0336 
0337     app->Add(new JOmniFactoryGeneratorT<TransformBreitFrame_factory>(
0338             "GeneratedBreitFrameParticles",
0339             {"MCParticles","InclusiveKinematicsElectron","GeneratedParticles"},
0340             {"GeneratedBreitFrameParticles"},
0341             {},
0342             app
0343     ));
0344 
0345     app->Add(new JOmniFactoryGeneratorT<JetReconstruction_factory<edm4eic::ReconstructedParticle>>(
0346             "GeneratedCentauroJets",
0347             {"GeneratedBreitFrameParticles"},
0348             {"GeneratedCentauroJets"},
0349             {
0350              .rJet = 0.8,
0351              .jetAlgo = "plugin_algorithm",
0352              .jetContribAlgo = "Centauro"
0353             },
0354             app
0355     ));
0356 
0357     app->Add(new JOmniFactoryGeneratorT<JetReconstruction_factory<edm4eic::ReconstructedParticle>>(
0358             "ReconstructedCentauroJets",
0359             {"ReconstructedBreitFrameParticles"},
0360             {"ReconstructedCentauroJets"},
0361             {
0362              .rJet = 0.8,
0363              .jetAlgo = "plugin_algorithm",
0364              .jetContribAlgo = "Centauro"
0365             },
0366             app
0367     ));
0368 
0369 
0370     //Full correction for MCParticles --> MCParticlesHeadOnFrame
0371     app->Add(new JOmniFactoryGeneratorT<UndoAfterBurnerMCParticles_factory>(
0372             "MCParticlesHeadOnFrameNoBeamFX",
0373             {
0374                 "MCParticles"
0375             },
0376             {
0377                 "MCParticlesHeadOnFrameNoBeamFX"
0378             },
0379             {
0380               .m_pid_assume_pion_mass = false,
0381               .m_crossing_angle = -0.025 * dd4hep::rad,
0382               .m_pid_purity = 0.51, //dummy value for MC truth information
0383               .m_correct_beam_FX = true,
0384               .m_pid_use_MC_truth = true,
0385             },
0386             app
0387     ));
0388 
0389     app->Add(new JOmniFactoryGeneratorT<PrimaryVertices_factory>(
0390         "PrimaryVertices",
0391         {
0392           "CentralTrackVertices"
0393         },
0394         {
0395           "PrimaryVertices"
0396         },
0397         {
0398         },
0399         app
0400     ));
0401 
0402 
0403 }
0404 } // extern "C"