Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:00

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   // here we are basically going to see if the max cluster pT or max jet pT is above a certain threshold, otherwise we will abort the event
0028   // jet loop
0029   JetContainer *jets = findNode::getClass<JetContainer>(topNode, m_JetNodeName);
0030   if (!jets)
0031   {
0032     std::cout << "JetDSTSkimmer::process_event - Error - Can't find Jet Node " << m_JetNodeName << " therefore no selection can be made" << std::endl;
0033     return Fun4AllReturnCodes::ABORTEVENT;
0034   }
0035   float maxjetpt = 0;
0036   for (auto jet : *jets)
0037   {
0038     if (jet->get_pt() > maxjetpt)
0039     {
0040       maxjetpt = jet->get_pt();
0041     }
0042   }
0043 
0044   RawClusterContainer *_clusters = findNode::getClass<RawClusterContainer>(topNode, m_ClusterNodeName);
0045   if (!_clusters)
0046   {
0047     std::cout << "JetDSTSkimmer::process_event - Error - Can't find Cluster Node " << m_ClusterNodeName << " therefore no selection can be made" << std::endl;
0048     return Fun4AllReturnCodes::ABORTEVENT;
0049   }
0050   float maxclusterpt = 0;
0051   RawClusterContainer::Map clusterMap = _clusters->getClustersMap();
0052   for (auto &clusterPair : clusterMap)
0053   {
0054     RawCluster *recoCluster = (clusterPair.second);
0055     if (recoCluster->get_energy() > maxclusterpt)
0056     {
0057       maxclusterpt = recoCluster->get_energy();
0058     }
0059   }
0060   // place holder for identifying background events
0061   bool isBackground = isBackgroundEvent();
0062 
0063   bool keepEvent = false;
0064   if (maxjetpt > m_minJetPt || maxclusterpt > m_minClusterPt)
0065   {
0066     keepEvent = true;
0067   }
0068   else
0069   {
0070     // verbose output, verbose 2 also will show the event abortion by this module
0071     if (Verbosity() > 1)
0072     {
0073       std::cout << "JetDSTSkimmer::process_event - Event Rejected - Max Jet pT: " << maxjetpt << " Max Cluster pT: " << maxclusterpt << std::endl;
0074     }
0075   }
0076   if (isBackground)
0077   {
0078     keepEvent = false;
0079     if (Verbosity() > 1)
0080     {
0081       std::cout << "JetDSTSkimmer::process_event - Event Rejected - Background Event" << std::endl;
0082     }
0083   }
0084   if (!keepEvent)
0085   {
0086     return Fun4AllReturnCodes::ABORTEVENT;
0087   }
0088 
0089   return Fun4AllReturnCodes::EVENT_OK;
0090 }
0091 
0092 bool JetDSTSkimmer::isBackgroundEvent()
0093 {
0094   // place holder for identifying background events
0095   return false;
0096 }