diff --git a/offline/packages/CaloReco/CaloTowerStatus.cc b/offline/packages/CaloReco/CaloTowerStatus.cc index e90a839d07..01f8db2f60 100644 --- a/offline/packages/CaloReco/CaloTowerStatus.cc +++ b/offline/packages/CaloReco/CaloTowerStatus.cc @@ -2,6 +2,7 @@ #include "CaloTowerDefs.h" #include // for TowerInfo +#include #include #include #include @@ -215,6 +216,29 @@ int CaloTowerStatus::InitRun(PHCompositeNode *topNode) return Fun4AllReturnCodes::EVENT_OK; } +void CaloTowerStatus::emcal_propogate_isBadChi2(const std::vector> &badChi2_IB_vec, const std::vector> &towers_IB_vec) +{ + unsigned int ntowers = m_raw_towers->size(); + for (unsigned int channel = 0; channel < ntowers; channel++) + { + std::pair sector_ib = TowerInfoDefs::getEMCalSectorIB(channel); + int sector = sector_ib.first; + int ib = sector_ib.second; + int badChi2_towers = badChi2_IB_vec[sector][ib]; + int towers = towers_IB_vec[sector][ib]; + // if entire IB is bad then skip + if (towers == 0) + { + continue; + } + float badChi2_IB_frac = badChi2_towers * 1. / towers; + if(badChi2_IB_frac > m_badChi2_IB_threshold) + { + m_raw_towers->get_tower_at_channel(channel)->set_isBadChi2(true); + } + } +} + //____________________________________________________________________________.. int CaloTowerStatus::process_event(PHCompositeNode * /*topNode*/) { @@ -223,9 +247,22 @@ int CaloTowerStatus::process_event(PHCompositeNode * /*topNode*/) float mean_time = 0; int hotMap_val = 0; float z_score = 0; + + std::vector> badChi2_IB_vec(emcal_sector, std::vector(emcal_ib_per_sector, 0)); + std::vector> towers_IB_vec(emcal_sector, std::vector(emcal_ib_per_sector, 0)); + for (unsigned int channel = 0; channel < ntowers; channel++) { unsigned int key = m_raw_towers->encode_key(channel); + int sector = -1; + int ib = -1; + + if(m_dettype == CaloTowerDefs::CEMC) + { + std::pair sector_ib = TowerInfoDefs::getEMCalSectorIB(channel); + sector = sector_ib.first; + ib = sector_ib.second; + } // only reset what we will set m_raw_towers->get_tower_at_channel(channel)->set_isHot(false); m_raw_towers->get_tower_at_channel(channel)->set_isBadTime(false); @@ -272,11 +309,29 @@ int CaloTowerStatus::process_event(PHCompositeNode * /*topNode*/) { m_raw_towers->get_tower_at_channel(channel)->set_isHot(true); } + + if(m_dettype == CaloTowerDefs::CEMC && m_raw_towers->get_tower_at_channel(channel)->get_isGood()) + { + ++towers_IB_vec[sector][ib]; + } + if (chi2 > std::min(std::max(badChi2_treshold_const, adc * adc * badChi2_treshold_quadratic),badChi2_treshold_max)) { m_raw_towers->get_tower_at_channel(channel)->set_isBadChi2(true); + + if(m_dettype == CaloTowerDefs::CEMC) + { + ++badChi2_IB_vec[sector][ib]; + } } } + + // propagate the isBadChi2 status to entire interface board if threshold is exceeded + if (m_dettype == CaloTowerDefs::CEMC) + { + emcal_propogate_isBadChi2(badChi2_IB_vec, towers_IB_vec); + } + return Fun4AllReturnCodes::EVENT_OK; } diff --git a/offline/packages/CaloReco/CaloTowerStatus.h b/offline/packages/CaloReco/CaloTowerStatus.h index 21c9a5f229..872697e425 100644 --- a/offline/packages/CaloReco/CaloTowerStatus.h +++ b/offline/packages/CaloReco/CaloTowerStatus.h @@ -95,8 +95,16 @@ class CaloTowerStatus : public SubsysReco m_isSim = isSim; return; } + void set_badChi2_IB_threshold(float badChi2_IB_threshold) + { + m_badChi2_IB_threshold = badChi2_IB_threshold; + return; + } private: + + void emcal_propogate_isBadChi2(const std::vector> &badChi2_IB_vec, const std::vector> &towers_IB_vec); + TowerInfoContainer *m_raw_towers{nullptr}; CDBTTree *m_cdbttree_chi2{nullptr}; @@ -135,6 +143,10 @@ class CaloTowerStatus : public SubsysReco float z_score_threshold = {5}; float z_score_threshold_default = {5}; float time_cut = 2; // number of samples from the mean time for the channel in the run + + int emcal_sector = {64}; + int emcal_ib_per_sector = {6}; + float m_badChi2_IB_threshold = {0.5}; }; #endif // CALOTOWERBUILDER_H