Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions offline/packages/CaloReco/CaloTowerStatus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "CaloTowerDefs.h"

#include <calobase/TowerInfo.h> // for TowerInfo
#include <calobase/TowerInfoDefs.h>
#include <calobase/TowerInfoContainer.h>
#include <calobase/TowerInfoContainerv1.h>
#include <calobase/TowerInfoContainerv2.h>
Expand Down Expand Up @@ -215,6 +216,29 @@ int CaloTowerStatus::InitRun(PHCompositeNode *topNode)
return Fun4AllReturnCodes::EVENT_OK;
}

void CaloTowerStatus::emcal_propogate_isBadChi2(const std::vector<std::vector<int>> &badChi2_IB_vec, const std::vector<std::vector<int>> &towers_IB_vec)
{
unsigned int ntowers = m_raw_towers->size();
for (unsigned int channel = 0; channel < ntowers; channel++)
{
std::pair<int, int> 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*/)
{
Expand All @@ -223,9 +247,22 @@ int CaloTowerStatus::process_event(PHCompositeNode * /*topNode*/)
float mean_time = 0;
int hotMap_val = 0;
float z_score = 0;

std::vector<std::vector<int>> badChi2_IB_vec(emcal_sector, std::vector<int>(emcal_ib_per_sector, 0));
std::vector<std::vector<int>> towers_IB_vec(emcal_sector, std::vector<int>(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<int, int> 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);
Expand Down Expand Up @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions offline/packages/CaloReco/CaloTowerStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::vector<int>> &badChi2_IB_vec, const std::vector<std::vector<int>> &towers_IB_vec);

TowerInfoContainer *m_raw_towers{nullptr};

CDBTTree *m_cdbttree_chi2{nullptr};
Expand Down Expand Up @@ -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