Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-02 08:13:03

0001 #include "CaloStatusSkimmer.h"
0002 
0003 #include <fun4all/Fun4AllReturnCodes.h>
0004 
0005 #include <phool/PHCompositeNode.h>
0006 #include <phool/getClass.h>
0007 #include <phool/phool.h>
0008 
0009 #include <calobase/TowerInfo.h>
0010 #include <calobase/TowerInfoContainer.h>
0011 
0012 #include <cstdint>
0013 #include <iostream>
0014 
0015 //____________________________________________________________________________..
0016 CaloStatusSkimmer::CaloStatusSkimmer(const std::string &name)
0017     : SubsysReco(name)
0018 {
0019   std::cout << "CaloStatusSkimmer::CaloStatusSkimmer(const std::string &name) ""Calling ctor" << std::endl;
0020 }
0021 
0022 //____________________________________________________________________________..
0023 int CaloStatusSkimmer::process_event(PHCompositeNode *topNode)
0024 {
0025   n_eventcounter++;
0026   if (m_EMC_skim_threshold > 0)
0027   {
0028     TowerInfoContainer *towers =
0029         findNode::getClass<TowerInfoContainer>(topNode, "TOWERS_CEMC");
0030     if (!towers)
0031     {
0032       n_notowernodecounter++;
0033       if (Verbosity() > 0)
0034       {
0035         std::cout << PHWHERE << "calostatuscheck::process_event: missing TOWERS_CEMC" << std::endl;
0036       }
0037       return Fun4AllReturnCodes::ABORTEVENT;
0038     }
0039     const uint32_t ntowers = towers->size();
0040     uint16_t notinstr_count = 0;
0041     for (uint32_t ch = 0; ch < ntowers; ++ch)
0042     {
0043       TowerInfo *tower = towers->get_tower_at_channel(ch);
0044       if (tower->get_isNotInstr())
0045       {
0046         ++notinstr_count;
0047       }
0048     }
0049     if (Verbosity() > 9)
0050     {
0051       std::cout << "CaloStatusSkimmer::process_event: event " << n_eventcounter << ", ntowers in EMCal = " << ntowers << ", not-instrumented(empty/missing pckt) towers in EMCal = " << notinstr_count << std::endl;
0052     }
0053 
0054     if (notinstr_count >= m_EMC_skim_threshold)
0055     {
0056       n_skimcounter++;
0057       return Fun4AllReturnCodes::ABORTEVENT;
0058     }
0059   }
0060 
0061   if (m_HCal_skim_threshold > 0)
0062   {
0063     TowerInfoContainer *hcalin_towers = findNode::getClass<TowerInfoContainer>(topNode, "TOWERS_HCALIN");
0064     TowerInfoContainer *hcalout_towers = findNode::getClass<TowerInfoContainer>(topNode, "TOWERS_HCALOUT");
0065     if (!hcalin_towers || !hcalout_towers)
0066     {
0067       n_notowernodecounter++;
0068       if (Verbosity() > 0)
0069       {
0070         std::cout << PHWHERE << "calostatuscheck::process_event: missing TOWERS_HCALIN or TOWERS_HCALOUT" << std::endl;
0071       }
0072       return Fun4AllReturnCodes::ABORTEVENT;
0073     }
0074 
0075     const uint32_t ntowers_hcalin = hcalin_towers->size();
0076     uint16_t notinstr_count_hcalin = 0;
0077     for (uint32_t ch = 0; ch < ntowers_hcalin; ++ch)
0078     {
0079       TowerInfo *tower_in = hcalin_towers->get_tower_at_channel(ch);
0080       if (tower_in->get_isNotInstr())
0081       {
0082         ++notinstr_count_hcalin;
0083       }
0084     }
0085 
0086     const uint32_t ntowers_hcalout = hcalout_towers->size();
0087     uint16_t notinstr_count_hcalout = 0;
0088     for (uint32_t ch = 0; ch < ntowers_hcalout; ++ch)
0089     {
0090       TowerInfo *tower_out = hcalout_towers->get_tower_at_channel(ch);
0091       if (tower_out->get_isNotInstr())
0092       {
0093         ++notinstr_count_hcalout;
0094       }
0095     }
0096 
0097     if (Verbosity() > 9)
0098     {
0099       std::cout << "CaloStatusSkimmer::process_event: event " << n_eventcounter << ", ntowers in HCalIn = " << ntowers_hcalin << ", not-instrumented(empty/missing pckt) towers in HCalIn = " << notinstr_count_hcalin << ", ntowers in HCalOut = " << ntowers_hcalout << ", not-instrumented(empty/missing pckt) towers in HCalOut = " << notinstr_count_hcalout << std::endl;
0100     }
0101 
0102     if (notinstr_count_hcalin >= m_HCal_skim_threshold ||
0103         notinstr_count_hcalout >= m_HCal_skim_threshold)
0104     {
0105       n_skimcounter++;
0106       return Fun4AllReturnCodes::ABORTEVENT;
0107     }
0108   }
0109 
0110   if (m_sEPD_skim_threshold > 0)
0111   {
0112     TowerInfoContainer *sepd_towers =
0113         findNode::getClass<TowerInfoContainer>(topNode, "TOWERS_SEPD");
0114     if (!sepd_towers)
0115     {
0116       n_notowernodecounter++;
0117       if (Verbosity() > 0)
0118       {
0119         std::cout << PHWHERE << "calostatuscheck::process_event: missing TOWERS_SEPD" << std::endl;
0120       }
0121       return Fun4AllReturnCodes::ABORTEVENT;
0122     }
0123     const uint32_t ntowers = sepd_towers->size();
0124     uint16_t notinstr_count = 0;
0125     for (uint32_t ch = 0; ch < ntowers; ++ch)
0126     {
0127       TowerInfo *tower = sepd_towers->get_tower_at_channel(ch);
0128       if (tower->get_isNotInstr())
0129       {
0130         ++notinstr_count;
0131       }
0132     }
0133 
0134     if (Verbosity() > 9)
0135     {
0136       std::cout << "CaloStatusSkimmer::process_event: event " << n_eventcounter << ", ntowers in sEPD = " << ntowers << ", not-instrumented(empty/missing pckt) towers in sEPD = " << notinstr_count << std::endl;
0137     }
0138 
0139     if (notinstr_count >= m_sEPD_skim_threshold)
0140     {
0141       n_skimcounter++;
0142       return Fun4AllReturnCodes::ABORTEVENT;
0143     }
0144   }
0145 
0146   if (m_ZDC_skim_threshold > 0)
0147   {
0148     TowerInfoContainer *zdc_towers =
0149         findNode::getClass<TowerInfoContainer>(topNode, "TOWERS_ZDC");
0150     if (!zdc_towers)
0151     {
0152       n_notowernodecounter++;
0153       if (Verbosity() > 0)
0154       {
0155         std::cout << PHWHERE << "calostatuscheck::process_event: missing TOWERS_ZDC" << std::endl;
0156       }
0157       return Fun4AllReturnCodes::ABORTEVENT;
0158     }
0159     const uint32_t ntowers = zdc_towers->size();
0160     uint16_t notinstr_count = 0;
0161     for (uint32_t ch = 0; ch < ntowers; ++ch)
0162     {
0163       TowerInfo *tower = zdc_towers->get_tower_at_channel(ch);
0164       if (tower->get_isNotInstr())
0165       {
0166         ++notinstr_count;
0167       }
0168     }
0169 
0170     if (Verbosity() > 9)
0171     {
0172       std::cout << "CaloStatusSkimmer::process_event: event " << n_eventcounter << ", ntowers in ZDC = " << ntowers << ", not-instrumented(empty/missing pckt) towers in ZDC = " << notinstr_count << std::endl;
0173     }
0174 
0175     if (notinstr_count >= m_ZDC_skim_threshold)
0176     {
0177       n_skimcounter++;
0178       return Fun4AllReturnCodes::ABORTEVENT;
0179     }
0180   }
0181 
0182   return Fun4AllReturnCodes::EVENT_OK;
0183 }
0184 
0185 //____________________________________________________________________________..
0186 int CaloStatusSkimmer::End([[maybe_unused]] PHCompositeNode *topNode)
0187 {
0188   std::cout << "CaloStatusSkimmer::End(PHCompositeNode *topNode) This is the End..." << std::endl;
0189   std::cout << "Total events processed: " << n_eventcounter << std::endl;
0190   std::cout << "Total events skimmed: " << n_skimcounter << std::endl;
0191   std::cout << "Total events with missing tower nodes: " << n_notowernodecounter << std::endl;
0192 
0193   return Fun4AllReturnCodes::EVENT_OK;
0194 }