Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-15 08:16:22

0001 // Copyright 2024, Simon Gardner
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 //
0004 //
0005 
0006 #include <JANA/JApplication.h>
0007 #include <edm4hep/MCParticleCollection.h>
0008 #include <fmt/core.h>
0009 #include <map>
0010 #include <memory>
0011 #include <string>
0012 #include <vector>
0013 
0014 #include "algorithms/interfaces/WithPodConfig.h"
0015 #include "algorithms/meta/SubDivideFunctors.h"
0016 #include "extensions/jana/JOmniFactoryGeneratorT.h"
0017 #include "factories/meta/CollectionCollector_factory.h"
0018 #include "factories/meta/SubDivideCollection_factory.h"
0019 
0020 extern "C" {
0021 void InitPlugin(JApplication* app) {
0022   InitJANAPlugin(app);
0023 
0024   using namespace eicrecon;
0025 
0026   // Divide MCParticle collection based on generator status and PDG
0027   std::vector<std::string> outCollections{"MCBeamElectrons",    "MCBeamProtons",
0028                                           "MCBeamNeutrons",     "MCScatteredElectrons",
0029                                           "MCScatteredProtons", "MCScatteredNeutrons"};
0030   std::vector<std::vector<int>> values{{4, 11}, {4, 2212}, {4, 2112},
0031                                        {1, 11}, {1, 2212}, {1, 2112}};
0032 
0033   app->Add(new JOmniFactoryGeneratorT<SubDivideCollection_factory<edm4hep::MCParticle>>(
0034       "BeamParticles", {"MCParticles"}, outCollections,
0035       {
0036           .function =
0037               ValueSplit<&edm4hep::MCParticle::getGeneratorStatus, &edm4hep::MCParticle::getPDG>{
0038                   values},
0039       },
0040       app));
0041 
0042   // Combine beam protons and neutrons into beam hadrons
0043   app->Add(new JOmniFactoryGeneratorT<CollectionCollector_factory<edm4hep::MCParticle, true>>(
0044       "MCBeamHadrons", {"MCBeamProtons", "MCBeamNeutrons"}, {"MCBeamHadrons"}, app));
0045 }
0046 }