Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 /// ===========================================================================
0002 /*! \file    BeamBackgroundFilter.h
0003  *  \authors Derek Anderson
0004  *  \date    11.01.2024
0005  *
0006  *  Part of the BeamBackgroundFilterAndQA module, this
0007  *  is an abstract template for any filters run as
0008  *  part of the module.
0009  */
0010 /// ===========================================================================
0011 
0012 #ifndef BASEBEAMBACKGROUNDFILTER_H
0013 #define BASEBEAMBACKGROUNDFILTER_H
0014 
0015 // f4a libraries
0016 #include <fun4all/Fun4AllHistoManager.h>
0017 #include <fun4all/Fun4AllReturnCodes.h>
0018 
0019 // root libraries
0020 #include <TH1.h>
0021 
0022 // c++ utilities
0023 #include <map>
0024 #include <string>
0025 
0026 // forward declarations
0027 class PHCompositeNode;
0028 
0029 // ============================================================================
0030 //! Base beam background filter
0031 // ============================================================================
0032 /*! Base class for filters to be applied in the BeamBackgroundFilterAndQA
0033  *  module. Defines all the machinery common between filters.
0034  */
0035 class BaseBeamBackgroundFilter
0036 {
0037  public:
0038   // ------------------------------------------------------------------------
0039   //! Apply filter
0040   // ------------------------------------------------------------------------
0041   /*! Applies the filter. Should return true if filter finds beam
0042    *  background, and false if not.
0043    */
0044   virtual bool ApplyFilter(PHCompositeNode* /*topNode*/) { return false; }
0045 
0046   // ------------------------------------------------------------------------
0047   //! Build associated histograms
0048   // ------------------------------------------------------------------------
0049   /*! Collects all definitions of histograms.
0050    */
0051   virtual void BuildHistograms(const std::string& /*module*/, const std::string& /*tag*/) { return; }
0052 
0053   ///! register histograms
0054   inline void RegisterHistograms(Fun4AllHistoManager* manager)
0055   {
0056     for (auto& hist : m_hists)
0057     {
0058       manager->registerHisto(hist.second);
0059     }
0060     return;
0061   }
0062 
0063   ///! Set filter name
0064   void SetName(const std::string& name) { m_name = name; }
0065 
0066   ///! Get filter name
0067   std::string GetName() { return m_name; }
0068 
0069   ///! default ctor/dtor
0070   BaseBeamBackgroundFilter(const std::string& name)
0071     : m_name(name){};
0072   virtual ~BaseBeamBackgroundFilter() = default;
0073 
0074  protected:
0075   // ------------------------------------------------------------------------
0076   //! Grab relevant input nodes
0077   // ------------------------------------------------------------------------
0078   /*! Collects all calls to `findNode`.
0079    */
0080   virtual void GrabNodes(PHCompositeNode* /*topNode*/) { return; }
0081 
0082   // ------------------------------------------------------------------------
0083   //! Histograms
0084   // ------------------------------------------------------------------------
0085   /*! All QA histograms for a given filter should be defined in this
0086    *  map, e.g.
0087    *
0088    *  m_hists["hNStreakPhi"] = new TH2D("hNStreakPhi", "", 64, 0., 64., 10, 0., 10.);
0089    */
0090   std::map<std::string, TH1*> m_hists;
0091 
0092   ///! filter name
0093   std::string m_name;
0094 
0095 };  // end BaseBeamBackgroundFilter
0096 
0097 #endif
0098 
0099 // end ========================================================================