Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:20:29

0001 #ifndef SKIMMERS_CALOPACKETSKIMMER_H
0002 #define SKIMMERS_CALOPACKETSKIMMER_H
0003 
0004 #include <caloreco/CaloTowerDefs.h>
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <algorithm>
0009 #include <string>
0010 #include <utility>
0011 #include <vector>
0012 
0013 class PHCompositeNode;
0014 class TH1;
0015 
0016 class CaloPacketSkimmer : public SubsysReco
0017 {
0018  public:
0019   explicit CaloPacketSkimmer(const std::string& name = "CaloPacketSkimmer");
0020   ~CaloPacketSkimmer() override = default;
0021 
0022   int process_event(PHCompositeNode* /*topNode*/) override;
0023   int InitRun(PHCompositeNode* topNode) override;
0024 
0025   int EndRun(const int /*runnumber*/) override;
0026 
0027   void set_all_detectors_off() { m_CaloDetectors.clear(); }
0028 
0029   void set_all_detectors_on()
0030   {
0031     m_CaloDetectors = {CaloTowerDefs::CEMC, CaloTowerDefs::HCALIN,
0032                        CaloTowerDefs::HCALOUT, CaloTowerDefs::SEPD,
0033                        CaloTowerDefs::ZDC, CaloTowerDefs::MBD};
0034   }
0035 
0036   void set_detector_on(CaloTowerDefs::DetectorSystem det)
0037   {
0038     if (std::find(m_CaloDetectors.begin(), m_CaloDetectors.end(), det) == m_CaloDetectors.end())
0039     {
0040       m_CaloDetectors.push_back(det);
0041     }
0042   }
0043 
0044   void set_offlineflag(const bool f = true)
0045   {
0046     m_UseOfflinePacketFlag = f;
0047   }
0048 
0049  private:
0050   std::vector<CaloTowerDefs::DetectorSystem> m_CaloDetectors{
0051       CaloTowerDefs::CEMC, CaloTowerDefs::HCALIN, CaloTowerDefs::HCALOUT,
0052       CaloTowerDefs::SEPD, CaloTowerDefs::ZDC, CaloTowerDefs::MBD};
0053   bool m_UseOfflinePacketFlag{true};
0054   bool m_PacketNodesFlag{false};
0055 
0056   int processDetector(PHCompositeNode* topNode, CaloTowerDefs::DetectorSystem det);
0057 
0058   std::string getDetectorName(CaloTowerDefs::DetectorSystem det)
0059   {
0060     switch (det)
0061     {
0062     case CaloTowerDefs::CEMC:
0063       return "CEMC";
0064     case CaloTowerDefs::HCALIN:
0065       return "HCALIN";
0066     case CaloTowerDefs::HCALOUT:
0067       return "HCALOUT";
0068     case CaloTowerDefs::SEPD:
0069       return "SEPD";
0070     case CaloTowerDefs::ZDC:
0071       return "ZDC";
0072     case CaloTowerDefs::MBD:
0073       return "MBD";
0074     default:
0075       return "UNKNOWN";
0076     }
0077   }
0078 
0079   std::pair<int, int> getPacketRange(CaloTowerDefs::DetectorSystem det)
0080   {
0081     switch (det)
0082     {
0083     case CaloTowerDefs::CEMC:
0084       return {6001, 6128};
0085     case CaloTowerDefs::HCALIN:
0086       return {7001, 7008};
0087     case CaloTowerDefs::HCALOUT:
0088       return {8001, 8008};
0089     case CaloTowerDefs::SEPD:
0090       return {9001, 9006};
0091     case CaloTowerDefs::ZDC:
0092       return {12001, 12001};
0093     case CaloTowerDefs::MBD:
0094       return {1001, 1002};
0095     default:
0096       return {0, 0};  // Invalid range
0097     }
0098   }
0099 
0100   TH1* h_aborted_events{nullptr};
0101   TH1* h_kept_events{nullptr};
0102   TH1* h_missing_packets{nullptr};
0103   TH1* h_empty_packets{nullptr};
0104 };
0105 
0106 #endif