Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:21:18

0001 /// ===========================================================================
0002 /*! \file   CaloStatusMapper.h
0003  *  \author Derek Anderson
0004  *  \date   05.22.2024
0005  *
0006  *  A Fun4All QA module to plot no. of towers per event
0007  *  and vs. eta, phi as a function of status.
0008  */
0009 /// ===========================================================================
0010 
0011 #ifndef CLUSTERSTATUSMAPPER_H
0012 #define CLUSTERSTATUSMAPPER_H
0013 
0014 // module definitions
0015 #include "CaloStatusMapperDefs.h"
0016 
0017 // jet qa
0018 #include <jetqa/JetQADefs.h>
0019 
0020 // calo base
0021 // f4a libraries
0022 #include <fun4all/SubsysReco.h>
0023 
0024 // c++ utilities
0025 #include <cstdint>
0026 #include <map>
0027 #include <string>
0028 #include <utility>
0029 #include <vector>
0030 
0031 // forward declarations
0032 class PHCompositeNode;
0033 class Fun4AllHistoManager;
0034 class TH1;
0035 class TowerInfoContainer;
0036 class TriggerAnalyzer;
0037 
0038 
0039 
0040 // ============================================================================
0041 //! Map Status of Calo Towers
0042 // ============================================================================
0043 /*! This Fun4all modules ingests calorimeter towers, and then plots
0044  *  the no. of towers per event and vs. eta/phi for a given status.
0045  */
0046 class CaloStatusMapper : public SubsysReco
0047 {
0048 
0049   public:
0050 
0051     // ========================================================================
0052     //! Options for CaloStatusMapper module
0053     // ========================================================================
0054     struct Config
0055     {
0056 
0057       ///! turn debug messages on/off
0058       bool debug {true};
0059 
0060       ///! turn normalizing histograms on/off
0061       bool doNorm {false};
0062 
0063       ///! turn optional histograms on/off
0064       bool doOptHist {false};
0065 
0066       ///! module name
0067       std::string moduleName {"CaloStatusMapper"};
0068 
0069       ///! histogram tag
0070       std::string histTag {""};
0071 
0072       ///! input nodes and what type of calo they are
0073       std::vector<CaloStatusMapperDefs::NodeDef> inNodeNames
0074       {
0075         {"TOWERINFO_CALIB_CEMC",    CaloStatusMapperDefs::Calo::EMCal},
0076         {"TOWERINFO_CALIB_HCALIN",  CaloStatusMapperDefs::Calo::HCal},
0077         {"TOWERINFO_CALIB_HCALOUT", CaloStatusMapperDefs::Calo::HCal}
0078       };
0079 
0080      ///! turn trigger selection on/off
0081      bool doTrgSelect {false};
0082 
0083      ///! trigger to select
0084      uint32_t trgToSelect {JetQADefs::GL1::MBDNSJet1};
0085 
0086     };  // end Config
0087 
0088     // ctor/dtor
0089     CaloStatusMapper(const std::string& modulename = "CaloStatusMapper", const bool debug = false);
0090     CaloStatusMapper(const Config& config);
0091     ~CaloStatusMapper() override;
0092 
0093     // setters
0094     void SetConfig(const Config& config) {m_config = config;}
0095 
0096     // getters
0097     const Config& GetConfig() {return m_config;}
0098 
0099     // f4a methods
0100     int Init(PHCompositeNode* /*topNode*/) override;
0101     int process_event(PHCompositeNode* topNode) override;
0102     int End(PHCompositeNode* /*topNode*/) override;
0103 
0104   private:
0105 
0106     // private methods
0107     void InitHistManager();
0108     void BuildHistograms();
0109     void GrabNodes(PHCompositeNode* topNode);
0110     std::string MakeBaseName(const std::string& base, const std::string& node, const std::string& stat = "") const;
0111 
0112     ///! module configuration
0113     Config m_config;
0114 
0115     ///! histogram manager
0116     Fun4AllHistoManager* m_manager {nullptr};
0117 
0118     ///! for checking which trigger fired
0119     TriggerAnalyzer* m_analyzer {nullptr};
0120 
0121   ///! output histograms
0122   std::map<std::string, TH1*> m_hists;
0123   TH1 *allCaloEnergy {nullptr};
0124 
0125     ///! input nodes
0126     std::vector<TowerInfoContainer*> m_inNodes;
0127 
0128     ///! no. of events processed
0129     uint64_t m_nEvent {0};
0130 
0131     ///! total bins for status histograms
0132     std::map<std::string, int> m_totalBin;
0133   
0134 };  // end CaloStatusMapper
0135 
0136 #endif
0137 
0138 // end ========================================================================