Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:19:50

0001 #ifndef CALORECO_PHOTONCLUSTERBUILDER_H
0002 #define CALORECO_PHOTONCLUSTERBUILDER_H
0003 
0004 #include <fun4all/SubsysReco.h>
0005 #include <calobase/RawTowerDefs.h>
0006 
0007 #include <memory>
0008 #include <string>
0009 #include <vector>
0010 
0011 class PHCompositeNode;
0012 class RawClusterContainer;
0013 class RawCluster;
0014 class PhotonClusterv1;
0015 class TowerInfoContainer;
0016 class RawTowerGeomContainer;
0017 class RawTowerGeom;
0018 
0019 namespace TMVA
0020 {
0021   namespace Experimental
0022   {
0023     class RBDT;
0024   }
0025 }  // namespace TMVA
0026 
0027 // Simple builder that wraps existing RawClusters above an energy threshold
0028 // into PhotonClusterv1 objects and stores them in a PhotonClusterContainer node.
0029 class PhotonClusterBuilder : public SubsysReco
0030 {
0031  public:
0032   explicit PhotonClusterBuilder(const std::string& name = "PhotonClusterBuilder");
0033   ~PhotonClusterBuilder() override = default;
0034 
0035   int InitRun(PHCompositeNode* topNode) override;
0036   int process_event(PHCompositeNode* topNode) override;
0037 
0038   void set_input_cluster_node(const std::string& n) { m_input_cluster_node = n; }
0039   void set_output_photon_node(const std::string& n) { m_output_photon_node = n; }
0040   void set_ET_threshold(float e) { m_min_cluster_et = e; }
0041   void set_shower_shape_min_tower_energy(float e) { m_shape_min_tower_E = e; }
0042   void set_bdt_model_file(const std::string& path) { m_bdt_model_file = path; }
0043   void set_bdt_feature_list(const std::vector<std::string>& features) { m_bdt_feature_list = features; }
0044   void set_do_bdt(bool do_bdt) { m_do_bdt = do_bdt; }
0045   const std::vector<std::string>& get_bdt_feature_list() const { return m_bdt_feature_list; }
0046 
0047  private:
0048   void CreateNodes(PHCompositeNode* topNode);
0049   void calculate_shower_shapes(RawCluster* rc, PhotonClusterv1* photon, float eta, float phi);
0050   void calculate_bdt_score(PhotonClusterv1* photon);
0051   double getTowerEta(RawTowerGeom* tower_geom, double vx, double vy, double vz);
0052   std::vector<int> find_closest_hcal_tower(float eta, float phi, RawTowerGeomContainer* geom, TowerInfoContainer* towerContainer, float vertex_z, bool isihcal);
0053   double deltaR(double eta1, double phi1, double eta2, double phi2);
0054   float calculate_layer_et(float seed_eta, float seed_phi, float radius, TowerInfoContainer* towerContainer, RawTowerGeomContainer* geomContainer, RawTowerDefs::CalorimeterId calo_id, float vertex_z);
0055   bool m_do_bdt{false};
0056 
0057   std::string m_input_cluster_node{"CLUSTERINFO_CEMC"};
0058   std::string m_output_photon_node{"PHOTONCLUSTER_CEMC"};
0059   float m_min_cluster_et{5.0f};
0060   float m_shape_min_tower_E{0.070f};
0061   std::string m_bdt_model_file{"myBDT_5.root"};
0062   std::vector<std::string> m_bdt_feature_list;
0063   float m_vertex{std::numeric_limits<float>::quiet_NaN()};
0064 
0065   RawClusterContainer* m_rawclusters{nullptr};
0066   RawClusterContainer* m_photon_container{nullptr};
0067   TowerInfoContainer* m_emc_tower_container{nullptr};
0068   RawTowerGeomContainer* m_geomEM{nullptr};
0069   TowerInfoContainer* m_ihcal_tower_container{nullptr};
0070   RawTowerGeomContainer* m_geomIH{nullptr};
0071   TowerInfoContainer* m_ohcal_tower_container{nullptr};
0072   RawTowerGeomContainer* m_geomOH{nullptr};
0073   std::unique_ptr<TMVA::Experimental::RBDT> m_bdt;
0074 };
0075 
0076 #endif  // CALORECO_PHOTONCLUSTERBUILDER_H