Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-27 07:03:06

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