You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::sort(trackletCounter.begin(), trackletCounter.end(), [](const auto&a, constauto&b) { returna.first<b.first; }); // sort by number of tracklets per MCM
70
-
floatmean=0;
71
-
intnActiveMcms=0;
72
-
for (intidx=0; idx<static_cast<int>(0.9* (constants::MAXHALFCHAMBER*constants::NMCMHCMAX)); ++idx) {
73
-
// get average number of tracklets discarding the 10% of MCMs with most entries
88
+
floatmean90=0;// mean excluding 10% of MCMs with most entries
89
+
intnActiveMcms90=0;
90
+
std::vector<int>nTrkltsPerActiveMcm; // for median calculation
91
+
for (intidx=0; idx<constants::MAXHALFCHAMBER*constants::NMCMHCMAX; ++idx) {
if (idx<static_cast<int>(0.9* (constants::MAXHALFCHAMBER*constants::NMCMHCMAX))) {
95
+
// for the average number of tracklets we exclude the 10% of MCMs with most entries
96
+
nActiveMcms90++;
97
+
mean90+=trackletCounter[idx].first;
98
+
}
77
99
}
78
100
}
79
-
if (!nActiveMcms) {
101
+
if (!nActiveMcms90) {
80
102
printf("ERROR: did not find any MCMs which sent tracklets. Aborting\n");
81
103
return;
82
104
}
83
-
mean /= nActiveMcms;
84
-
floatnoiseThreshold=10*mean;
85
105
86
-
for (const auto&counter : trackletCounter) {
87
-
if (counter.first>noiseThreshold) {
88
-
noiseMap.setIsNoisy(counter.second);
106
+
auto n=nTrkltsPerActiveMcm.size() / 2;
107
+
auto median=nTrkltsPerActiveMcm[n]; // the distinction between odd/even number of entries in the vector is irrelevant
108
+
mean90 /= nActiveMcms90;
109
+
auto noiseThreshold= (useMean) ? 100.f*mean90 : (float)totalTriggerCounter / 10.f;
110
+
111
+
setlocale(LC_NUMERIC, "en_US.utf-8");
112
+
printf("Info: Found in total %'lu MCMs which sent tracklets with a median of %i tracklets per MCM\n", nTrkltsPerActiveMcm.size(), median);
113
+
printf("Info: Excluding the 10%% of MCMs which sent the highest number of tracklets %'i MCMs remain with on average %.2f tracklets per MCM\n", nActiveMcms90, mean90);
114
+
printf("Important: Masking MCMs which sent more than %.2f tracklets for given period\n", noiseThreshold);
115
+
116
+
std::vector<int>nTrackletsFromNoisyMcm;
117
+
boolhasPrintedFirstNoisy= false;
118
+
for (intidx=0; idx<constants::MAXHALFCHAMBER*constants::NMCMHCMAX; ++idx) {
119
+
auto mcmIdx=trackletCounter[idx].second;
120
+
if (trackletCounter[idx].first>noiseThreshold) {
121
+
if (!hasPrintedFirstNoisy) {
122
+
printf("Info: The first masked MCM idx(%i) with glb idx %i sent %i trackelts\n", idx, mcmIdx, trackletCounter[idx].first);
printf("Found in total %lu noisy MCMs for %lu tracklets from %lu trigger records\n", noiseMap.getNumberOfNoisyMCMs(), totalTrackletCounter, trigIn.size());
151
+
printf("Info: Found in total %lu noisy MCMs for %'lu tracklets from %'lu triggers\n", noiseMap.getNumberOfNoisyMCMs(), totalTrackletCounter, totalTriggerCounter);
152
+
153
+
if (detailedOutput) {
154
+
size_tcountTrackletsFromNoisyMcms=0;
155
+
printf("Info: Number of tracklets sent per masked MCM: \n");
156
+
printf("----->\n");
157
+
for (intidx=0; idx<constants::MAXHALFCHAMBER*constants::NMCMHCMAX; ++idx) {
printf("Info: Number of tracklets sent from masked MCMs: %'lu (%.2f%%)\n", countTrackletsFromNoisyMcms, (float)countTrackletsFromNoisyMcms / totalTrackletCounter*100);
0 commit comments