Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-08 08:26:09

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 <JANA/JApplicationFwd.h>
0008 #include <JANA/Utils/JTypeInfo.h>
0009 #include <edm4hep/MCParticleCollection.h>
0010 #include <functional>
0011 #include <memory>
0012 #include <string>
0013 #include <vector>
0014 
0015 #include "algorithms/meta/SubDivideFunctors.h"
0016 #include "extensions/jana/JOmniFactoryGeneratorT.h"
0017 #include "factories/meta/Cloner_factory.h"
0018 #include "factories/meta/CollectionCollector_factory.h"
0019 #include "factories/meta/SubDivideCollection_factory.h"
0020 
0021 extern "C" {
0022 void InitPlugin(JApplication* app) {
0023   InitJANAPlugin(app);
0024 
0025   using namespace eicrecon;
0026 
0027   // Divide MCParticle collection based on generator status and PDG
0028   std::vector<std::string> outCollections{"MCBeamElectrons",    "MCBeamProtons",
0029                                           "MCBeamNeutrons",     "MCScatteredElectrons",
0030                                           "MCScatteredProtons", "MCScatteredNeutrons"};
0031   std::vector<std::vector<int>> values{{4, 11}, {4, 2212}, {4, 2112},
0032                                        {1, 11}, {1, 2212}, {1, 2112}};
0033 
0034   app->Add(new JOmniFactoryGeneratorT<SubDivideCollection_factory<edm4hep::MCParticle>>(
0035       "BeamParticles", {"MCParticles"}, outCollections,
0036       {
0037           .function =
0038               ValueSplit<&edm4hep::MCParticle::getGeneratorStatus, &edm4hep::MCParticle::getPDG>{
0039                   values},
0040       },
0041       app));
0042 
0043   // Combine beam protons and neutrons into beam hadrons
0044   app->Add(new JOmniFactoryGeneratorT<CollectionCollector_factory<edm4hep::MCParticle, true>>(
0045       "MCBeamHadrons", {"MCBeamProtons", "MCBeamNeutrons"}, {"MCBeamHadrons"}, app));
0046 
0047   // Clone MCBeamElectrons and MCBeamProtons for easier downstream analysis.
0048   // This creates non-subset collections of the beam particles.
0049   app->Add(new JOmniFactoryGeneratorT<Cloner_factory<edm4hep::MCParticle>>(
0050       "MCBeamElectronsCloned", {"MCBeamElectrons"}, {"MCBeamElectronsCloned"}, app));
0051   app->Add(new JOmniFactoryGeneratorT<Cloner_factory<edm4hep::MCParticle>>(
0052       "MCBeamProtonsCloned", {"MCBeamProtons"}, {"MCBeamProtonsCloned"}, app));
0053 }
0054 }