From b9051b49104c8f14d6d859da22b7642422dd5f96 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Fri, 16 Dec 2022 15:13:40 -0600 Subject: [PATCH 1/3] Initialize members in CSCDQM_StripClusterFinder - initialized member data - removed unused member data - moved member data to be stack variables passed to the functions --- .../plugins/CSCDQM_StripClusterFinder.cc | 138 +++++++++--------- .../plugins/CSCDQM_StripClusterFinder.h | 16 +- 2 files changed, 79 insertions(+), 75 deletions(-) diff --git a/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc b/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc index 6011e680ca170..35c3f2bdf549e 100644 --- a/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc +++ b/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc @@ -15,11 +15,12 @@ namespace cscdqm { if (cf == 7) { is7DCFEBs = true; isME11 = true; + } else { + is7DCFEBs = false; } } void StripClusterFinder::DoAction(int LayerId, float* Cathodes) { int TimeId, StripId; - this->LId = LayerId; MEStripClusters.clear(); StripClusterFitData PulseHeightMapTMP; @@ -41,7 +42,7 @@ namespace cscdqm { if (thePulseHeightMap.empty()) return; - SearchMax(); + SearchMax(LayerId); SearchBorders(); Match(); RefindMax(); @@ -63,9 +64,9 @@ namespace cscdqm { float sumtime; float sumheight; - for (i = 0; i < MEStripClusters.size(); i++) { + for (uint32_t i = 0; i < MEStripClusters.size(); i++) { MEStripClusters[i].ClusterPulseMapHeight.clear(); - for (j = 0; j < thePulseHeightMap.size(); j++) { + for (uint32_t j = 0; j < thePulseHeightMap.size(); j++) { if (thePulseHeightMap[j].channel_ >= MEStripClusters[i].LFTBNDStrip && thePulseHeightMap[j].channel_ <= MEStripClusters[i].IRTBNDStrip) MEStripClusters[i].ClusterPulseMapHeight.push_back(thePulseHeightMap[j]); @@ -90,12 +91,12 @@ namespace cscdqm { return; } - void StripClusterFinder::SearchMax(void) { + void StripClusterFinder::SearchMax(int32_t layerId) { StripCluster tmpCluster; - for (i = 1; i < (thePulseHeightMap.size() - 1); i++) { + for (uint32_t i = 1; i < (thePulseHeightMap.size() - 1); i++) { if (isME11 && (thePulseHeightMap[i].channel_ == 63 || thePulseHeightMap[i].channel_ == 64)) continue; - for (j = 1; j < 15; j++) { + for (uint32_t j = 1; j < 15; j++) { if (thePulseHeightMap[i].height_[j] > thePulseHeightMap[i - 1].height_[j] && thePulseHeightMap[i].height_[j] > thePulseHeightMap[i + 1].height_[j] && thePulseHeightMap[i].height_[j] > thePulseHeightMap[i].height_[j - 1] && @@ -108,7 +109,7 @@ namespace cscdqm { localMaxTMP.Strip = i; localMaxTMP.Time = j; tmpCluster.localMax.push_back(localMaxTMP); - tmpCluster.LayerId = this->LId; + tmpCluster.LayerId = layerId; tmpCluster.LFTBNDTime = -100; tmpCluster.LFTBNDStrip = -100; tmpCluster.IRTBNDTime = -100; @@ -124,7 +125,7 @@ namespace cscdqm { // SEARCHING PARAMETERS OF THE CLASTERS (LEFT DOWN & RIGHT UP) - for (i = 0; i < MEStripClusters.size(); i++) { + for (uint32_t i = 0; i < MEStripClusters.size(); i++) { if (MEStripClusters[i].localMax.empty()) { std::cout << "!!!Warning Cluster has'nt local Maxima" << std::endl; continue; @@ -189,29 +190,31 @@ namespace cscdqm { bool StripClusterFinder::FindAndMatch(void) { // Find clusters to match - icstart = 0; //!!!??? - for (ic1 = icstart; ic1 < MEStripClusters.size(); ic1++) { - IC1MIN = MEStripClusters[ic1].LFTBNDStrip; - IC1MAX = MEStripClusters[ic1].IRTBNDStrip; - JC1MIN = MEStripClusters[ic1].LFTBNDTime; - JC1MAX = MEStripClusters[ic1].IRTBNDTime; - for (ic2 = ic1 + 1; ic2 < MEStripClusters.size(); ic2++) { - IC2MIN = MEStripClusters[ic2].LFTBNDStrip; - IC2MAX = MEStripClusters[ic2].IRTBNDStrip; - JC2MIN = MEStripClusters[ic2].LFTBNDTime; - JC2MAX = MEStripClusters[ic2].IRTBNDTime; - if ((IC2MIN >= IC1MIN && IC2MIN <= IC1MAX && JC2MIN >= JC1MIN && JC2MIN <= JC1MAX) || - (IC2MIN >= IC1MIN && IC2MIN <= IC1MAX && JC2MAX >= JC1MIN && JC2MAX <= JC1MAX) || - (IC2MAX >= IC1MIN && IC2MAX <= IC1MAX && JC2MIN >= JC1MIN && JC2MIN <= JC1MAX) || - (IC2MAX >= IC1MIN && IC2MAX <= IC1MAX && JC2MAX >= JC1MIN && JC2MAX <= JC1MAX)) { - KillCluster(); + uint32_t icstart = 0; //!!!??? + for (uint32_t ic1 = icstart; ic1 < MEStripClusters.size(); ic1++) { + C1 c1; + c1.IC1MIN = MEStripClusters[ic1].LFTBNDStrip; + c1.IC1MAX = MEStripClusters[ic1].IRTBNDStrip; + c1.JC1MIN = MEStripClusters[ic1].LFTBNDTime; + c1.JC1MAX = MEStripClusters[ic1].IRTBNDTime; + for (uint32_t ic2 = ic1 + 1; ic2 < MEStripClusters.size(); ic2++) { + C2 c2; + c2.IC2MIN = MEStripClusters[ic2].LFTBNDStrip; + c2.IC2MAX = MEStripClusters[ic2].IRTBNDStrip; + c2.JC2MIN = MEStripClusters[ic2].LFTBNDTime; + c2.JC2MAX = MEStripClusters[ic2].IRTBNDTime; + if ((c2.IC2MIN >= c1.IC1MIN && c2.IC2MIN <= c1.IC1MAX && c2.JC2MIN >= c1.JC1MIN && c2.JC2MIN <= c1.JC1MAX) || + (c2.IC2MIN >= c1.IC1MIN && c2.IC2MIN <= c1.IC1MAX && c2.JC2MAX >= c1.JC1MIN && c2.JC2MAX <= c1.JC1MAX) || + (c2.IC2MAX >= c1.IC1MIN && c2.IC2MAX <= c1.IC1MAX && c2.JC2MIN >= c1.JC1MIN && c2.JC2MIN <= c1.JC1MAX) || + (c2.IC2MAX >= c1.IC1MIN && c2.IC2MAX <= c1.IC1MAX && c2.JC2MAX >= c1.JC1MIN && c2.JC2MAX <= c1.JC1MAX)) { + icstart = KillCluster(ic1, ic2, c1, c2); return true; } else { - if ((IC1MIN >= IC2MIN && IC1MIN <= IC2MAX && JC1MIN >= JC2MIN && JC1MIN <= JC2MAX) || - (IC1MIN >= IC2MIN && IC1MIN <= IC2MAX && JC1MAX >= JC2MIN && JC1MAX <= JC2MAX) || - (IC1MAX >= IC2MIN && IC1MAX <= IC2MAX && JC1MIN >= JC2MIN && JC1MIN <= JC2MAX) || - (IC1MAX >= IC2MIN && IC1MAX <= IC2MAX && JC1MAX >= JC2MIN && JC1MAX <= JC2MAX)) { - KillCluster(); + if ((c1.IC1MIN >= c2.IC2MIN && c1.IC1MIN <= c2.IC2MAX && c1.JC1MIN >= c2.JC2MIN && c1.JC1MIN <= c2.JC2MAX) || + (c1.IC1MIN >= c2.IC2MIN && c1.IC1MIN <= c2.IC2MAX && c1.JC1MAX >= c2.JC2MIN && c1.JC1MAX <= c2.JC2MAX) || + (c1.IC1MAX >= c2.IC2MIN && c1.IC1MAX <= c2.IC2MAX && c1.JC1MIN >= c2.JC2MIN && c1.JC1MIN <= c2.JC2MAX) || + (c1.IC1MAX >= c2.IC2MIN && c1.IC1MAX <= c2.IC2MAX && c1.JC1MAX >= c2.JC2MIN && c1.JC1MAX <= c2.JC2MAX)) { + icstart = KillCluster(ic1, ic2, c1, c2); return true; } } @@ -219,54 +222,52 @@ namespace cscdqm { } return false; } - void StripClusterFinder::KillCluster(void) { + uint32_t StripClusterFinder::KillCluster(uint32_t ic1, uint32_t ic2, C1 const& c1, C2 const& c2) { // Match Clusters and kill one of clusters. - if (IC1MIN < IC2MIN) - MEStripClusters[ic1].LFTBNDStrip = IC1MIN; + if (c1.IC1MIN < c2.IC2MIN) + MEStripClusters[ic1].LFTBNDStrip = c1.IC1MIN; else - MEStripClusters[ic1].LFTBNDStrip = IC2MIN; - if (JC1MIN < JC2MIN) - MEStripClusters[ic1].LFTBNDTime = JC1MIN; + MEStripClusters[ic1].LFTBNDStrip = c2.IC2MIN; + if (c1.JC1MIN < c2.JC2MIN) + MEStripClusters[ic1].LFTBNDTime = c1.JC1MIN; else - MEStripClusters[ic1].LFTBNDTime = JC2MIN; - if (IC1MAX > IC2MAX) - MEStripClusters[ic1].IRTBNDStrip = IC1MAX; + MEStripClusters[ic1].LFTBNDTime = c2.JC2MIN; + if (c1.IC1MAX > c2.IC2MAX) + MEStripClusters[ic1].IRTBNDStrip = c1.IC1MAX; else - MEStripClusters[ic1].IRTBNDStrip = IC2MAX; - if (JC1MAX > JC2MAX) - MEStripClusters[ic1].IRTBNDTime = JC1MAX; + MEStripClusters[ic1].IRTBNDStrip = c2.IC2MAX; + if (c1.JC1MAX > c2.JC2MAX) + MEStripClusters[ic1].IRTBNDTime = c1.JC1MAX; else - MEStripClusters[ic1].IRTBNDTime = JC2MAX; + MEStripClusters[ic1].IRTBNDTime = c2.JC2MAX; MEStripClusters.erase(MEStripClusters.begin() + ic2); - icstart = ic1; - - return; + return ic1; } void StripClusterFinder::RefindMax(void) { - int iLS, iRS, iLT, iRT; - int iS, jT; - int ilocal; - float GlobalMax; - bool Erased; + //int iLS, iRS, iLT, iRT; + //int iS, jT; + //int ilocal; + //float GlobalMax; + //bool Erased; // SEARCHING EXTREMUMS IN THE CLASTERS - for (i = 0; i < MEStripClusters.size(); i++) { + for (uint32_t i = 0; i < MEStripClusters.size(); i++) { MEStripClusters[i].localMax.clear(); - ilocal = 0; - iLS = MEStripClusters[i].LFTBNDStrip; - iRS = MEStripClusters[i].IRTBNDStrip; - iLT = MEStripClusters[i].LFTBNDTime; - iRT = MEStripClusters[i].IRTBNDTime; + int ilocal = 0; + int iLS = MEStripClusters[i].LFTBNDStrip; + int iRS = MEStripClusters[i].IRTBNDStrip; + int iLT = MEStripClusters[i].LFTBNDTime; + int iRT = MEStripClusters[i].IRTBNDTime; /* for(iS=iLS+1;iS<=iRS-1;iS++){ for(jT=iLT+1;jT<=iRT-1;jT++){ */ - for (iS = iLS; iS <= iRS; iS++) { + for (int iS = iLS; iS <= iRS; iS++) { if (isME11 && (thePulseHeightMap[iS].channel_ == 63 || thePulseHeightMap[iS].channel_ == 64)) continue; - for (jT = iLT; jT <= iRT; jT++) { + for (int jT = iLT; jT <= iRT; jT++) { if (iS == 0 || jT == 0 || (!is7DCFEBs && (iS == 79)) || (is7DCFEBs && (iS == 111)) || jT == 7) continue; if (thePulseHeightMap[iS].height_[jT] > thePulseHeightMap[iS - 1].height_[jT] && @@ -286,13 +287,13 @@ namespace cscdqm { } // kill local maximums rellated to noise, maximums with pulse height less then 10% of Global max of clust. //fing Global Max - GlobalMax = 0; + float GlobalMax = 0; if (!MEStripClusters[i].localMax.empty()) { //std::cout << "Cluster: " << i << " Number of local maximums before erase: " // << MEStripClusters[i].localMax.size() << std::endl; - for (j = 0; j < MEStripClusters[i].localMax.size(); j++) { - iS = MEStripClusters[i].localMax[j].Strip; - jT = MEStripClusters[i].localMax[j].Time; + for (uint32_t j = 0; j < MEStripClusters[i].localMax.size(); j++) { + int iS = MEStripClusters[i].localMax[j].Strip; + int jT = MEStripClusters[i].localMax[j].Time; /* std::cout << "Current Max:" << " " << iS @@ -304,11 +305,12 @@ namespace cscdqm { } GlobalMax = (float)(GlobalMax / 10.); //erase noise localMaximums + bool Erased; do { Erased = false; - for (j = 0; j < MEStripClusters[i].localMax.size(); j++) { - iS = MEStripClusters[i].localMax[j].Strip; - jT = MEStripClusters[i].localMax[j].Time; + for (uint32_t j = 0; j < MEStripClusters[i].localMax.size(); j++) { + int iS = MEStripClusters[i].localMax[j].Strip; + int jT = MEStripClusters[i].localMax[j].Time; if (thePulseHeightMap[iS].height_[jT] < GlobalMax) { MEStripClusters[i].localMax.erase(MEStripClusters[i].localMax.begin() + j); Erased = true; @@ -337,12 +339,12 @@ namespace cscdqm { int iS, jT; std::cout << "====================================================================" << std::endl; std::cout << "debug information from StripClusterFinder" << std::endl; - for (i = 0; i < MEStripClusters.size(); i++) { + for (uint32_t i = 0; i < MEStripClusters.size(); i++) { if (MEStripClusters[i].localMax.empty()) continue; std::cout << " Cluster: " << i + 1 << " Number of local Maximums " << MEStripClusters[i].localMax.size() << std::endl; - for (j = 0; j < MEStripClusters[i].localMax.size(); j++) { + for (uint32_t j = 0; j < MEStripClusters[i].localMax.size(); j++) { iS = MEStripClusters[i].localMax[j].Strip; jT = MEStripClusters[i].localMax[j].Time; diff --git a/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.h b/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.h index 930dba80a4367..f109fbe2dd226 100644 --- a/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.h +++ b/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.h @@ -37,16 +37,18 @@ namespace cscdqm { std::vector getClusters() { return MEStripClusters; } private: - int32_t LId; - uint32_t i; - uint32_t j; - uint32_t ic1, IC1MIN, IC1MAX, JC1MIN, JC1MAX, ic2, IC2MIN, IC2MAX, JC2MIN, JC2MAX, icstart; - int LayerNmb, TimeSliceNmb, StripNmb, AnodeGroupNmb, AFEBSliceNmb; - void SearchMax(void); + struct C1 { + uint32_t IC1MIN, IC1MAX, JC1MIN, JC1MAX; + }; + struct C2 { + uint32_t IC2MIN, IC2MAX, JC2MIN, JC2MAX; + }; + int LayerNmb, TimeSliceNmb, StripNmb; + void SearchMax(int32_t layerId); void SearchBorders(void); void Match(void); bool FindAndMatch(void); - void KillCluster(void); + uint32_t KillCluster(uint32_t ic1, uint32_t ic2, C1 const&, C2 const&); void RefindMax(void); bool is7DCFEBs; bool isME11; From f23c250c5b01e3f83efd9bdc0813992ef5d6bea9 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 9 Jan 2023 11:08:54 -0600 Subject: [PATCH 2/3] Removed commented out code. --- .../plugins/CSCDQM_StripClusterFinder.cc | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc b/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc index 35c3f2bdf549e..0f6329f25075a 100644 --- a/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc +++ b/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc @@ -245,12 +245,7 @@ namespace cscdqm { return ic1; } void StripClusterFinder::RefindMax(void) { - //int iLS, iRS, iLT, iRT; - //int iS, jT; - //int ilocal; - //float GlobalMax; - //bool Erased; - // SEARCHING EXTREMUMS IN THE CLASTERS + // SEARCHING EXTREMUMS IN THE CLUSTERS for (uint32_t i = 0; i < MEStripClusters.size(); i++) { MEStripClusters[i].localMax.clear(); @@ -260,10 +255,6 @@ namespace cscdqm { int iLT = MEStripClusters[i].LFTBNDTime; int iRT = MEStripClusters[i].IRTBNDTime; - /* - for(iS=iLS+1;iS<=iRS-1;iS++){ - for(jT=iLT+1;jT<=iRT-1;jT++){ - */ for (int iS = iLS; iS <= iRS; iS++) { if (isME11 && (thePulseHeightMap[iS].channel_ == 63 || thePulseHeightMap[iS].channel_ == 64)) continue; From d48adf76310de4229f36b852642b39cfb8145dfd Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Mon, 9 Jan 2023 11:21:32 -0600 Subject: [PATCH 3/3] Switched to edm::LogWarning --- DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc b/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc index 0f6329f25075a..c6b81a0891854 100644 --- a/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc +++ b/DQM/CSCMonitorModule/plugins/CSCDQM_StripClusterFinder.cc @@ -1,5 +1,6 @@ #include "CSCDQM_StripClusterFinder.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" namespace cscdqm { @@ -127,7 +128,7 @@ namespace cscdqm { for (uint32_t i = 0; i < MEStripClusters.size(); i++) { if (MEStripClusters[i].localMax.empty()) { - std::cout << "!!!Warning Cluster has'nt local Maxima" << std::endl; + edm::LogWarning("NoLocalMax") << "Cluster " << i << " has no local Maxima"; continue; } iS = MEStripClusters[i].localMax[0].Strip;