File indexing completed on 2025-12-17 09:20:29
0001
0002 #include "JetDSTSkimmer.h"
0003
0004 #include <fun4all/Fun4AllReturnCodes.h>
0005
0006 #include <jetbase/Jet.h>
0007 #include <jetbase/JetContainer.h>
0008
0009 #include <calobase/RawCluster.h>
0010 #include <calobase/RawClusterContainer.h>
0011
0012 #include <phool/getClass.h>
0013
0014 #include <iostream> // for operator<<, basic_ostream
0015 #include <map> // for operator!=, _Rb_tree_iterator
0016 #include <utility> // for pair
0017
0018
0019 JetDSTSkimmer::JetDSTSkimmer(const std::string &name)
0020 : SubsysReco(name)
0021 {
0022 }
0023
0024
0025 int JetDSTSkimmer::process_event(PHCompositeNode *topNode)
0026 {
0027
0028 if (m_JetNodePts.empty() && m_ClusterNodePts.empty())
0029 {
0030 return Fun4AllReturnCodes::EVENT_OK;
0031 }
0032
0033
0034 bool passedJet = false;
0035 for (const auto &jetNodeAndThreshold : m_JetNodePts)
0036 {
0037 const std::string &jetNodeName = jetNodeAndThreshold.first;
0038 const float jetThreshold = jetNodeAndThreshold.second;
0039
0040 JetContainer *jets = findNode::getClass<JetContainer>(topNode, jetNodeName);
0041 if (!jets)
0042 {
0043 if (Verbosity() > 0)
0044 {
0045 std::cout << "JetDSTSkimmer::process_event - Warning - Can't find Jet Node Not Skimming on this: " << jetNodeName << std::endl;
0046 }
0047 continue;
0048 }
0049 for (auto *jet : *jets)
0050 {
0051 if (jet->get_pt() > jetThreshold)
0052 {
0053 passedJet = true;
0054 break;
0055 }
0056 }
0057 if (passedJet)
0058 {
0059 break;
0060 }
0061 }
0062
0063
0064 bool passedCluster = false;
0065 for (const auto &clusterNodeAndThreshold : m_ClusterNodePts)
0066 {
0067 const std::string &clusterNodeName = clusterNodeAndThreshold.first;
0068 const float clusterThreshold = clusterNodeAndThreshold.second;
0069
0070 RawClusterContainer *clusters = findNode::getClass<RawClusterContainer>(topNode, clusterNodeName);
0071 if (!clusters)
0072 {
0073 if (Verbosity() > 0)
0074 {
0075 std::cout << "JetDSTSkimmer::process_event - Warning - Can't find Cluster Node " << clusterNodeName << std::endl;
0076 }
0077 continue;
0078 }
0079 RawClusterContainer::Map clusterMap = clusters->getClustersMap();
0080 for (auto &clusterPair : clusterMap)
0081 {
0082 RawCluster *recoCluster = (clusterPair.second);
0083 if (recoCluster->get_energy() > clusterThreshold)
0084 {
0085 passedCluster = true;
0086 break;
0087 }
0088 }
0089 if (passedCluster)
0090 {
0091 break;
0092 }
0093 }
0094
0095
0096 bool isBackground = isBackgroundEvent();
0097
0098 bool keepEvent = (passedJet || passedCluster);
0099 if (isBackground)
0100 {
0101 keepEvent = false;
0102 if (Verbosity() > 1)
0103 {
0104 std::cout << "JetDSTSkimmer::process_event - Event Rejected - Background Event" << std::endl;
0105 }
0106 }
0107
0108 if (!keepEvent)
0109 {
0110 if (Verbosity() > 1)
0111 {
0112 std::cout << "JetDSTSkimmer::process_event - Event Rejected - No jets or clusters above thresholds" << std::endl;
0113 }
0114 return Fun4AllReturnCodes::ABORTEVENT;
0115 }
0116
0117 return Fun4AllReturnCodes::EVENT_OK;
0118 }
0119
0120 bool JetDSTSkimmer::isBackgroundEvent()
0121 {
0122
0123 return false;
0124 }