From 0a8230bbf41b89a39230b9b2efac36bca1ddd061 Mon Sep 17 00:00:00 2001
From: Benjamin Trocme <benjamin.trocme@cern.ch>
Date: Thu, 27 Jul 2017 11:54:05 +0200
Subject: [PATCH] Minor modif of hotSpotInHIST to have sorted output

Former-commit-id: 10b0f4c4ff05ec064d004d2058170e9df2d24a68
---
 .../DataQualityUtils/scripts/hotSpotInHIST.py  | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py b/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py
index e37323117de..33d9e356be7 100644
--- a/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py
+++ b/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py
@@ -1,6 +1,4 @@
 #!/usr/bin env python
-
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 # Script to browse the unmerged HIST files and extract LBs for which at least N occurences of an object is found
 # at a position foundas noisy
 # Uses the pathExtract library to extract the EOS path
@@ -441,18 +439,30 @@ for iHisto in histoKeys:
   totalInRegionRecomp[iHisto] = 0
   totalInRegion[iHisto] = 0
 # Then count the number of events and check if equal
+# Also sort the LB to highlight most problematic LB
+sortedLB = {}
+
 for iHisto in histoKeys:
   print "======= ",histoLegend[iHisto]
   for iBin in regionBins[iHisto]:
     totalInRegion[iHisto] = totalInRegion[iHisto] + histo[iHisto].GetBinContent(iBin)
+  
+  sortedLB[iHisto] = [0] * nLB
   for i in range(nLB):
     totalInRegionRecomp[iHisto] = totalInRegionRecomp[iHisto] + nbHitInHot[iHisto][i]
+    
+    sortedLB[iHisto][i] = i
     if (nbHitInHot[iHisto][i]>=minInLB):
-      print "LB: %d -> %d hits"%(i,nbHitInHot[iHisto][i])
+#      print "LB: %d -> %d hits"%(i,nbHitInHot[iHisto][i])
       suspiciousLBlist.append(i)
     if (nbHitInHot[iHisto][i]>maxNbInHot):
       maxNbInHot = nbHitInHot[iHisto][i]
-
+      
+  sortedLB[iHisto].sort(key=dict(zip(sortedLB[iHisto],nbHitInHot[iHisto])).get,reverse=True)
+  for i in range(nLB):
+    if nbHitInHot[iHisto][sortedLB[iHisto][i]]>=minInLB:
+      print "%d-LB: %d -> %d hits"%(i,sortedLB[iHisto][i],nbHitInHot[iHisto][sortedLB[iHisto][i]])
+ 
   print "In the whole run, there are %d entries"%(totalInRegion[iHisto])
   if (totalInRegionRecomp[iHisto] != totalInRegion[iHisto]):
     print "To be compared with %d entries cumulated from unmerged files"%(totalInRegionRecomp[iHisto])
-- 
GitLab