Skip to content

Commit 505d785

Browse files
author
Ishan Goel
committed
New changes
1 parent 80ba49a commit 505d785

File tree

2 files changed

+65
-49
lines changed

2 files changed

+65
-49
lines changed

offline/packages/tpc/TpcClusterizer.cc

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include <string>
6262
#include <utility> // for pair
6363
#include <vector>
64+
#include <unordered_set>
6465
// Terra incognita....
6566
#include <pthread.h>
6667

@@ -123,8 +124,8 @@ namespace
123124
double m_tdriftmax = 0;
124125

125126
// --- new members for dead/hot map ---
126-
hitMaskTpc *deadMap = nullptr;
127-
hitMaskTpc *hotMap = nullptr;
127+
hitMaskTpcSet *deadMap = nullptr;
128+
hitMaskTpcSet *hotMap = nullptr;
128129
bool maskDead = false;
129130
bool maskHot = false;
130131

@@ -605,43 +606,53 @@ namespace
605606

606607
TrkrDefs::hitsetkey tpcHitSetKey = TpcDefs::genHitSetKey(my_data.layer, my_data.sector, my_data.side);
607608

609+
// pads just outside the cluster in phi
610+
const int left_pad = phibinlo - 1;
611+
const int right_pad = phibinhi + 1;
612+
608613
// --- Dead channels ---
609-
if (my_data.maskDead && my_data.deadMap->count(tpcHitSetKey))
614+
if (my_data.maskDead)
615+
{
616+
auto it = my_data.deadMap->find(tpcHitSetKey);
617+
if (it != my_data.deadMap->end())
610618
{
611-
const auto &deadvec = (*my_data.deadMap)[tpcHitSetKey];
612-
613-
for (const auto &deadkey : deadvec)
614-
{
615-
int dphi = TpcDefs::getPad(deadkey);
619+
const auto &deadset = it->second;
616620

617-
bool touch = (dphi == phibinlo - 1 || dphi == phibinhi + 1);
621+
if (left_pad >= 0 &&
622+
deadset.count(TpcDefs::genHitKey(left_pad, 0)))
623+
{
624+
nedge++;
625+
}
618626

619-
if (touch)
620-
{
621-
nedge++;
622-
continue;
623-
}
624-
}
627+
if (right_pad < my_data.phibins &&
628+
deadset.count(TpcDefs::genHitKey(right_pad, 0)))
629+
{
630+
nedge++;
631+
}
625632
}
633+
}
626634

627635
// --- Hot channels ---
628-
if (my_data.maskHot && my_data.hotMap->count(tpcHitSetKey))
636+
if (my_data.maskHot)
637+
{
638+
auto it = my_data.hotMap->find(tpcHitSetKey);
639+
if (it != my_data.hotMap->end())
629640
{
630-
const auto &hotvec = (*my_data.hotMap)[tpcHitSetKey];
631-
632-
for (const auto &hotkey : hotvec)
633-
{
634-
int hphi = TpcDefs::getPad(hotkey);
641+
const auto &hotset = it->second;
635642

636-
bool touch = (hphi == phibinlo -1 || hphi == phibinhi + 1);
643+
if (left_pad >= 0 &&
644+
hotset.count(TpcDefs::genHitKey(left_pad, 0)))
645+
{
646+
nedge++;
647+
}
637648

638-
if (touch)
639-
{
640-
nedge++;
641-
continue;
642-
}
643-
}
649+
if (right_pad < my_data.phibins &&
650+
hotset.count(TpcDefs::genHitKey(right_pad, 0)))
651+
{
652+
nedge++;
653+
}
644654
}
655+
}
645656

646657
// This is the global position
647658
double clusiphi = iphi_sum / adc_sum;
@@ -843,24 +854,28 @@ namespace
843854
// Helper function to check if a pad is masked
844855
auto is_pad_masked = [&](int abs_pad) -> bool
845856
{
846-
if (my_data->maskDead && my_data->deadMap->count(tpcHitSetKey))
857+
TrkrDefs::hitkey key = TpcDefs::genHitKey(abs_pad, 0);
858+
859+
if (my_data->maskDead)
860+
{
861+
auto it = my_data->deadMap->find(tpcHitSetKey);
862+
if (it != my_data->deadMap->end() &&
863+
it->second.count(key))
847864
{
848-
const auto &deadvec = (*my_data->deadMap)[tpcHitSetKey];
849-
for (const auto &deadkey : deadvec)
850-
{
851-
if (TpcDefs::getPad(deadkey) == abs_pad)
852-
return true;
853-
}
865+
return true;
854866
}
855-
if (my_data->maskHot && my_data->hotMap->count(tpcHitSetKey))
867+
}
868+
869+
if (my_data->maskHot)
870+
{
871+
auto it = my_data->hotMap->find(tpcHitSetKey);
872+
if (it != my_data->hotMap->end() &&
873+
it->second.count(key))
856874
{
857-
const auto &hotvec = (*my_data->hotMap)[tpcHitSetKey];
858-
for (const auto &hotkey : hotvec)
859-
{
860-
if (TpcDefs::getPad(hotkey) == abs_pad)
861-
return true;
862-
}
875+
return true;
863876
}
877+
}
878+
864879
return false;
865880
};
866881

@@ -1806,7 +1821,7 @@ int TpcClusterizer::End(PHCompositeNode * /*topNode*/)
18061821
return Fun4AllReturnCodes::EVENT_OK;
18071822
}
18081823

1809-
void TpcClusterizer::makeChannelMask(hitMaskTpc &aMask, const std::string &dbName, const std::string &totalChannelsToMask)
1824+
void TpcClusterizer::makeChannelMask(hitMaskTpcSet &aMask, const std::string &dbName, const std::string &totalChannelsToMask)
18101825
{
18111826
CDBTTree *cdbttree;
18121827
if (m_maskFromFile)
@@ -1837,7 +1852,7 @@ void TpcClusterizer::makeChannelMask(hitMaskTpc &aMask, const std::string &dbNam
18371852

18381853
TrkrDefs::hitsetkey DeadChannelHitKey = TpcDefs::genHitSetKey(Layer, Sector, Side);
18391854
TrkrDefs::hitkey DeadHitKey = TpcDefs::genHitKey((unsigned int) Pad, 0);
1840-
aMask[DeadChannelHitKey].push_back(DeadHitKey);
1855+
aMask[DeadChannelHitKey].insert(DeadHitKey);
18411856
}
18421857

18431858
delete cdbttree;

offline/packages/tpc/TpcClusterizer.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
#include <fun4all/SubsysReco.h>
55
#include <trackbase/ActsGeometry.h>
66
#include <trackbase/TrkrCluster.h>
7+
#include <trackbase/TrkrDefs.h>
78

89
#include <map>
910
#include <string>
10-
#include <vector>
11+
#include <unordered_set>
1112

12-
typedef std::map<TrkrDefs::hitsetkey, std::vector<TrkrDefs::hitkey>> hitMaskTpc;
13+
typedef std::map<TrkrDefs::hitsetkey, std::unordered_set<TrkrDefs::hitkey>> hitMaskTpcSet;
1314

1415
class ClusHitsVerbosev1;
1516
class PHCompositeNode;
@@ -94,7 +95,7 @@ class TpcClusterizer : public SubsysReco
9495
bool is_in_sector_boundary(int phibin, int sector, PHG4TpcGeom *layergeom) const;
9596
bool record_ClusHitsVerbose{false};
9697

97-
void makeChannelMask(hitMaskTpc& aMask, const std::string& dbName, const std::string& totalChannelsToMask);
98+
void makeChannelMask(hitMaskTpcSet& aMask, const std::string& dbName, const std::string& totalChannelsToMask);
9899

99100
TrkrHitSetContainer *m_hits = nullptr;
100101
RawHitSetContainer *m_rawhits = nullptr;
@@ -128,8 +129,8 @@ class TpcClusterizer : public SubsysReco
128129

129130
TrainingHitsContainer *m_training;
130131

131-
hitMaskTpc m_deadChannelMap;
132-
hitMaskTpc m_hotChannelMap;
132+
hitMaskTpcSet m_deadChannelMap;
133+
hitMaskTpcSet m_hotChannelMap;
133134

134135
bool m_maskDeadChannels {false};
135136
bool m_maskHotChannels {false};

0 commit comments

Comments
 (0)