Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-05 08:12:16

0001 #ifndef SEPDEVENTPLANECALIB_SEPDTREEGEN_H
0002 #define SEPDEVENTPLANECALIB_SEPDTREEGEN_H
0003 
0004 // -- sPHENIX
0005 #include <fun4all/SubsysReco.h>
0006 
0007 // -- c++
0008 #include <string>
0009 
0010 class EventPlaneData;
0011 class PHCompositeNode;
0012 class TH2;
0013 class TProfile;
0014 
0015 /**
0016  * @class sEPD_TreeGen
0017  * @brief SubsysReco module to produce flat TTrees and QA histograms for sEPD calibration.
0018  *
0019  * This module extracts event-level info (vertex, centrality) and sEPD tower-level info
0020  * (charge, phi, channel ID), applying basic event selections (Minimum Bias, Z-vertex)
0021  * and tower-level cuts (charge threshold, zero-suppression).
0022  */
0023 class sEPD_TreeGen : public SubsysReco
0024 {
0025  public:
0026  /**
0027    * @brief Constructor for sEPD_TreeGen.
0028    * @param name The name assigned to this SubsysReco module.
0029    */
0030   explicit sEPD_TreeGen(const std::string &name = "sEPD_TreeGen");
0031 
0032  /**
0033    * @brief Initializes the module and creates the output TTree and QA histograms.
0034    * @param topNode Pointer to the node tree.
0035    * @return Fun4All return code.
0036    */
0037   int Init(PHCompositeNode *topNode) override;
0038 
0039  /**
0040    * @brief Main event-by-event processing method.
0041    * @details Orchestrates event checks, centrality retrieval, sEPD tower processing,
0042    * and fills the TTree for valid events.
0043    * @param topNode Pointer to the node tree.
0044    * @return Fun4All return code.
0045    */
0046   int process_event(PHCompositeNode *topNode) override;
0047 
0048  /**
0049    * @brief Resets event-level data structures before the next event.
0050    * @param topNode Pointer to the node tree.
0051    * @return Fun4All return code.
0052    */
0053   int ResetEvent(PHCompositeNode *topNode) override;
0054 
0055  /**
0056    * @brief Prints the current state of the EventPlaneData object.
0057    * @param what Optional string to specify what to print (default "ALL").
0058    */
0059   void Print(const std::string &what = "ALL") const override;
0060 
0061  /**
0062    * @brief Sets the maximum allowed Z-vertex position for event selection.
0063    * @param zvtx_max Maximum vertex Z in cm.
0064    */
0065   void set_zvtx_max(double zvtx_max)
0066   {
0067     m_cuts.m_zvtx_max = zvtx_max;
0068   }
0069 
0070  /**
0071    * @brief Sets the minimum charge threshold for individual sEPD towers.
0072    * @param charge_min Minimum charge to include a tower in the TTree.
0073    */
0074   void set_sepd_charge_threshold(double charge_min)
0075   {
0076     m_cuts.m_sepd_charge_min = charge_min;
0077   }
0078 
0079  /**
0080    * @brief Sets the maximum centrality centile allowed for processing.
0081    * @param cent_max Maximum centile (e.g., 80 for 0-80%).
0082    */
0083   void set_cent_max(double cent_max)
0084   {
0085     m_cuts.m_cent_max = cent_max;
0086   }
0087 
0088  private:
0089  /**
0090    * @brief Validates event-level conditions (GlobalVertex, Minimum Bias).
0091    * @param topNode Pointer to the node tree.
0092    * @return Fun4All return code.
0093    */
0094   int process_event_check(PHCompositeNode *topNode);
0095 
0096  /**
0097    * @brief Processes individual sEPD towers and calculates total charge.
0098    * @details Applies tower cuts, fills QA histograms, and stores tower data in vectors.
0099    * @param topNode Pointer to the node tree.
0100    * @return Fun4All return code.
0101    */
0102   int process_sEPD(PHCompositeNode *topNode);
0103 
0104  /**
0105    * @brief Retrieves and validates centrality information.
0106    * @param topNode Pointer to the node tree.
0107    * @return Fun4All return code.
0108    */
0109   int process_centrality(PHCompositeNode *topNode);
0110 
0111   int m_event{0};
0112 
0113   static constexpr int PROGRESS_PRINT_INTERVAL = 20;
0114 
0115   // Cuts
0116   struct Cuts
0117   {
0118     double m_zvtx_max{10}; /*cm*/
0119     double m_sepd_charge_min{0.2};
0120     double m_cent_max{80};
0121   };
0122 
0123   Cuts m_cuts;
0124 
0125   struct EventData
0126   {
0127     int event_id{0};
0128     double event_centrality{9999};
0129   };
0130 
0131   EventData m_data;
0132   EventPlaneData* m_evtdata{nullptr};
0133 
0134   TProfile *hSEPD_Charge{nullptr};
0135   TH2 *h2SEPD_totalcharge_centrality{nullptr};
0136 };
0137 
0138 #endif // SEPDEVENTPLANECALIB_SEPDTREEGEN_H