Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-17 07:50:49

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2026 Sebouh Paul, Baptiste Fraisse
0003 
0004 #pragma once
0005 #include <DD4hep/Detector.h>
0006 #include <algorithms/algorithm.h>
0007 #include <algorithms/geo.h>
0008 #include <edm4eic/ReconstructedParticleCollection.h>
0009 #include <spdlog/logger.h>
0010 #include <gsl/pointers>
0011 #include <memory>
0012 #include <string>      // for basic_string
0013 #include <string_view> // for string_view
0014 
0015 #include "algorithms/interfaces/WithPodConfig.h"
0016 #include "services/particle/ParticleSvc.h"
0017 #include "algorithms/reco/LambdaReconstructionConfig.h"
0018 
0019 namespace eicrecon {
0020 
0021 using LambdaReconstructionAlgorithm = algorithms::Algorithm<
0022     algorithms::Input<const edm4eic::ReconstructedParticleCollection,
0023                       const edm4eic::ReconstructedParticleCollection,
0024                       const edm4eic::ReconstructedParticleCollection,
0025                       const edm4eic::ReconstructedParticleCollection>,
0026     /*output collections contain the lambda candidates and their decay products in the CM frame*/
0027     algorithms::Output<edm4eic::ReconstructedParticleCollection,
0028                        edm4eic::ReconstructedParticleCollection>>;
0029 /**
0030  * Reconstruct far-forward Lambda candidates from neutral reconstructed particles.
0031  *
0032  * The reconstruction proceeds in five stages:
0033  * 1. collect photon and neutron candidates from the configured far-forward
0034  *   neutral collections and split them into detector categories;
0035  * 2. build pi0 candidates from all photon pairs passing the configured pi0
0036  *   invariant-mass window;
0037  * 3. combine accepted pi0 candidates with neutron candidates to form Lambda
0038  *   candidates passing the configured Lambda invariant-mass window;
0039  * 4. rank the surviving candidates according to detector-preference and
0040  *   mass-compatibility criteria;
0041  * 5. run the final Lambda reconstruction on the best candidate and store the
0042  *   resulting Lambda and decay products.
0043  *
0044  * The current ranking gives priority to candidates containing a ZDC neutron,
0045  * then to candidates containing more ZDC photons, followed by the combined
0046  * pi0/Lambda mass residual score and forward kinematics.
0047  */
0048 class LambdaReconstruction : public LambdaReconstructionAlgorithm,
0049                              public WithPodConfig<LambdaReconstructionConfig> {
0050 public:
0051   LambdaReconstruction(std::string_view name)
0052       : LambdaReconstructionAlgorithm{
0053             name,
0054 
0055             {"inputNeutralsHcal", "inputNeutralsB0", "inputNeutralsEcalEndCapP",
0056              "inputNeutralsLFHCAL"},
0057 
0058             {"outputLambdas", "outputLambdaDecayProductsCM"},
0059 
0060             "Reconstructs lambda candidates and their decay products (in the CM frame) from the "
0061             "reconstructed neutrons and photons"} {}
0062 
0063   void init() final;
0064   void process(const Input&, const Output&) const final;
0065 
0066 private:
0067   std::shared_ptr<spdlog::logger> m_log;
0068   const algorithms::ParticleSvc& m_particleSvc = algorithms::ParticleSvc::instance();
0069   const dd4hep::Detector* m_detector{algorithms::GeoSvc::instance().detector()};
0070   double m_zMax{0};
0071 
0072   bool reconstruct_from_triplet(const edm4eic::ReconstructedParticle& n_in,
0073                                 const edm4eic::ReconstructedParticle& g1_in,
0074                                 const edm4eic::ReconstructedParticle& g2_in,
0075                                 edm4eic::ReconstructedParticleCollection* out_lambdas,
0076                                 edm4eic::ReconstructedParticleCollection* out_decay_products) const;
0077 };
0078 } // namespace eicrecon