Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:13:11

0001 /// ===========================================================================
0002 /*! \file    BeamBackgroundFilterAndQA.h
0003  *  \authors Hanpu Jiang, Derek Anderson
0004  *  \date    10.21.2024
0005  *
0006  *  A F4A module to filter out events with significant
0007  *  beam background (the so-called "streaky events")
0008  *  and produce some relevant QA histograms.
0009  */
0010 /// ===========================================================================
0011 
0012 #ifndef BEAMBACKGROUNDFILTERANDQA_H
0013 #define BEAMBACKGROUNDFILTERANDQA_H
0014 
0015 // module components
0016 #include "BaseBeamBackgroundFilter.h"
0017 #include "NullFilter.h"
0018 #include "StreakSidebandFilter.h"
0019 
0020 // f4a libraries
0021 #include <fun4all/SubsysReco.h>
0022 
0023 // phparameters libraries
0024 #include <phparameter/PHParameters.h>
0025 
0026 // c++ utilities
0027 #include <map>
0028 #include <memory>
0029 #include <string>
0030 #include <vector>
0031 
0032 // forward declarations
0033 class Fun4AllHistoManager;
0034 class PHCompositeNode;
0035 class QAHistManagerHistDef;
0036 class TowerInfoContainer;
0037 
0038 
0039 
0040 // ============================================================================
0041 //! Filter beam background events and create QA
0042 // ============================================================================
0043 /*! A F4A module to filter out events with significant
0044  *  beam background and produce some relevant QA
0045  *  histograms. 
0046  */
0047 class BeamBackgroundFilterAndQA : public SubsysReco {
0048 
0049   public:
0050 
0051     // ========================================================================
0052     //! User options for module
0053     // =======================================================================
0054     struct Config
0055     {
0056 
0057       // turn modes on/off
0058       bool debug      = true;
0059       bool doQA       = true;
0060       bool doEvtAbort = false;
0061 
0062       ///! module name
0063       std::string moduleName = "BeamBackgroundFilterAndQA";
0064 
0065       ///! flag prefix
0066       std::string flagPrefix = "HasBeamBackground";
0067 
0068       ///! histogram tags
0069       std::string histTag = "";
0070 
0071       ///! which filters to apply
0072       std::vector<std::string> filtersToApply = {"Null", "StreakSideband"};
0073 
0074       ///! filter configurations
0075       NullFilter::Config null;
0076       StreakSidebandFilter::Config sideband;
0077       //... add other configurations here ...//
0078 
0079     };
0080 
0081     // ctor/dtor
0082     BeamBackgroundFilterAndQA(const std::string& name = "BeamBackgroundFilterAndQA", const bool debug = false);
0083     BeamBackgroundFilterAndQA(const Config& config); 
0084     ~BeamBackgroundFilterAndQA() override;
0085 
0086     // setters
0087     void SetConfig(const Config& config) {m_config = config;}
0088 
0089     // getters
0090     Config GetConfig() const {return m_config;}
0091 
0092     // f4a methods
0093     int Init(PHCompositeNode* topNode) override;
0094     int process_event(PHCompositeNode* topNode) override;
0095     int End(PHCompositeNode* /*topNode*/) override;
0096 
0097   private:
0098 
0099     // private methods
0100     void InitFilters();
0101     void InitFlags(PHCompositeNode* topNode);
0102     void InitHistManager();
0103     void BuildHistograms();
0104     void RegisterHistograms();
0105     void SetDefaultFlags();
0106     void UpdateFlags(PHCompositeNode* topNode);
0107     bool ApplyFilters(PHCompositeNode* topNode);
0108     std::string MakeFlagName(const std::string& filter = "");
0109 
0110     ///! histogram manager
0111     Fun4AllHistoManager* m_manager;
0112 
0113     ///! background flags
0114     PHParameters m_flags;
0115 
0116     ///! module-wide histograms
0117     std::map<std::string, TH1*> m_hists;
0118 
0119     ///! module configuration
0120     Config m_config;
0121 
0122     ///! filters
0123     std::map<std::string, std::unique_ptr<BaseBeamBackgroundFilter>> m_filters;
0124 
0125 };  // end BeamBackgroundFilterAndQA
0126 
0127 #endif
0128 
0129 // end ========================================================================