diff --git a/DataQuality/DataQualityUtils/scripts/checkCorrelInHIST.py b/DataQuality/DataQualityUtils/scripts/checkCorrelInHIST.py new file mode 100644 index 0000000000000000000000000000000000000000..ed0e8c7a6237721ca11d020bb4fdf8315dab082a --- /dev/null +++ b/DataQuality/DataQualityUtils/scripts/checkCorrelInHIST.py @@ -0,0 +1,233 @@ +#!/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 +# See the twiki: https://twiki.cern.ch/twiki/bin/viewauth/Atlas/UsingDQInframerge +#Options: +# -r ARG1, --run ARG1 Run number +# -ll ARG2, --lowerlb ARG2 +# Lower lb +# -ul ARG3, --upperlb ARG3 +# Upper lb +# -s ARG4, --stream ARG4 +# Stream without prefix: express/CosmicCalo/Main/ZeroBias/MinBias +# -t ARG5, --tag ARG5 DAQ tag: data16_13TeV, data16_cos... +# -a ARG6, --amiTag ARG6 +# First letter of AMI tag: x->express / f->bulk +# -e ARG7, --eta ARG7 Eta of hot spot +# -p ARG8, --phi ARG8 Phi of hot spot +# -ia ARG9, --integralAbove ARG9 +# Lower bound of integral +# -d ARG10, --delta ARG10 +# Distance to look around hot spot +# -o ARG11, --object ARG11 +# 2D OCCUPANCY: TopoClusters,EMTopoClusters, +# EMTopoJets,TightFwdElectrons +# 1D OCCUPANCY: EMTopoJets_eta +# INTEGRAL : NumberTau,NumberTightElectrons,NumberHLTJet +# -m ARG12, --min ARG12 +# Min number of occurences in a LB +# -g, --grl Look for Calo/LAr/Tile defects set in suspicious LBs +# Author : Benjamin Trocme (LPSC Grenoble) / 2015-2016 + +import os, sys +import string +import argparse +from argparse import RawTextHelpFormatter + +import pathExtract + +import ROOT +from ROOT import * +ROOT.PyConfig.IgnoreCommandLineOptions = True + +gROOT.Reset() +gStyle.SetPalette(1) +gStyle.SetOptStat("em") + +def lbStr(lb): + if (lb<10): + lbString = "_lb000%d"%(lb) + elif (lb<100): + lbString = "_lb00%d"%(lb) + elif (lb<1000): + lbString = "_lb0%d"%(lb) + else: + lbString = "_lb%d"%(lb) + return lbString + + +# Main=========================================================================================================== +parser = argparse.ArgumentParser(description='Process some integers.',formatter_class=RawTextHelpFormatter) +parser.add_argument('-r','--run',type=int,dest='arg1',default='267599',help="Run number",action='store') +parser.add_argument('-ll','--lowerlb',type=int,dest='arg2',default='0',help="Lower lb",action='store') +parser.add_argument('-ul','--upperlb',type=int,dest='arg3',default='999999',help="Upper lb",action='store') +parser.add_argument('-s','--stream',dest='arg4',default='Main',help="Stream without prefix: express/CosmicCalo/Main/ZeroBias/MinBias",action='store') +parser.add_argument('-t','--tag',dest='arg5',default='data17_13TeV',help="DAQ tag: data16_13TeV, data16_cos...",action='store') +parser.add_argument('-a','--amiTag',dest='arg6',default='f',help="First letter of AMI tag: x->express / f->bulk",action='store') +parser.add_argument('-x','--globalX',type=float,dest='arg7',default='-999.',help='X region common to all histos',action='store') +parser.add_argument('-y','--globalY',type=float,dest='arg8',default='-999.',help='Y region common to all histos',action='store') +parser.add_argument('-ia','--integralAbove',type=float,dest='arg9',default='-999.',help='Lower bound of integral - Not sued so far',action='store') +parser.add_argument('-d','--globalDelta',type=float,dest='arg10',default='0.1',help='Distance to look around x/(x;y) for 1d/2d plot',action='store') +parser.add_argument('--histo',dest='arg11',default='',help='As many histograms as you want with : [type("2d" only so far)] [root path] [x] [y] [delta] (if not provided use global)',action='store',nargs="*") + +args = parser.parse_args() + +parser.print_help() + +runNumber = args.arg1 +lowerLumiBlock = args.arg2 +upperLumiBlock = args.arg3 +stream = args.arg4 +tag = args.arg5 +amiTag = args.arg6 +globalX = args.arg7 +globalY = args.arg8 +integralAbove = args.arg9 +globalDelta = args.arg10 + +hArgs = args.arg11 +histos = {} +# Histograms must be necessary of this predefined type +histoTypes = ["2d"] + + +runFilePath = "root://eosatlas.cern.ch/%s"%(pathExtract.returnEosHistPath(runNumber,stream,amiTag,tag)).rstrip() +if ("FILE NOT FOUND" in runFilePath): + print "No merged file found..." + sys.exit() + +f = TFile.Open(runFilePath) + +# Display the Tier0 merged histograms +c = {} +box = {} +line = {} +line2 = {} +arrow = {} +histoMerged = {} +nLB=2500 +nbHitInHot = {} + +for iArg in xrange(len(hArgs)): + if hArgs[iArg] == "2d": + regionBins = [] + tmp_type = hArgs[iArg] + tmp_path = hArgs[iArg+1] + if (iArg+2>=len(hArgs) or hArgs[iArg+2] in histoTypes): # No x,y,delta for this histogram choose default + tmp_x = globalX + tmp_y = globalY + tmp_delta = globalDelta + iArg = iArg +2 + else: + tmp_x = float(hArgs[iArg+2]) + tmp_y = float(hArgs[iArg+3]) + tmp_delta = float(hArgs[iArg+4]) + iArg+5 + + histoMerged[tmp_path] = f.Get("run_%d/%s"%(runNumber,tmp_path)) + histoMerged[tmp_path].SetTitle("%s - Run %d"%(histoMerged[tmp_path].GetTitle(),runNumber)) + + c[tmp_path] = TCanvas(tmp_path) + c[tmp_path].SetLogz(1) + gStyle.SetPalette(1) + gStyle.SetOptStat("") + histoMerged[tmp_path].Draw("COLZ") + box[tmp_path] = TBox(tmp_x-tmp_delta,tmp_y-tmp_delta,tmp_x+tmp_delta,tmp_y+tmp_delta) + box[tmp_path].SetLineColor(kRed+1) + box[tmp_path].SetLineWidth(3) + box[tmp_path].SetFillStyle(0) + box[tmp_path].Draw() + +# Extract the list of bins where to count. +# Scans the window to find all bins that fall in the window +# The regionBins is defined for each histogram allowing different binning + + nSteps = 1000 + subStep = 2*tmp_delta/nSteps + for ix in range(nSteps): + iX = tmp_x - tmp_delta + ix * subStep + for iy in range (nSteps): + iY = tmp_y - tmp_delta + iy * subStep + tmp_bin = histoMerged[tmp_path].FindBin(iX,iY) + if (tmp_bin not in regionBins): + regionBins.append(tmp_bin) + + histos[tmp_path]={'type':tmp_type,'regionBins':regionBins} + nbHitInHot[tmp_path] = [0.] * nLB + +print histos + +# Extract all the unmerged files available with the LB range +lbFilePathList = pathExtract.returnEosHistPathLB(runNumber,lowerLumiBlock,upperLumiBlock,stream,amiTag,tag) + +print "I have found the merged HIST file %s"%(runFilePath) +print "I have found %d unmerged HIST files"%(len(lbFilePathList)) +print "The first one is root://eosatlas.cern.ch/%s"%(lbFilePathList[0]) +print "The last one is root://eosatlas.cern.ch/%s"%(lbFilePathList[-1]) + +# Loop on all unmerged files +fLB = {} +listLB = [] +for count,lbFile in enumerate(lbFilePathList): + lbFilePath = "root://eosatlas.cern.ch/%s"%(lbFile).rstrip() + # Extract lb from the filename and display it + ilb = int((lbFile.split("_lb")[1]).split("._")[0]) + if ilb not in listLB: + listLB.append(ilb) + if (count%100 == 0): + sys.stdout.write("\n I processed %d/%d files \n LBs:"%(count,len(lbFilePathList))) + sys.stdout.write("%d "%(ilb)) + sys.stdout.flush() + fLB[lbFile] = TFile.Open(lbFilePath) + histoLB = {} + for iPath in histos.keys(): + histoLB[iPath] = fLB[lbFile].Get("run_%d/%s"%(runNumber,iPath)) + for iBin in histos[iPath]['regionBins']: + nbHitInHot[iPath][ilb] = nbHitInHot[iPath][ilb] + histoLB[iPath].GetBinContent(iBin) + + fLB[lbFile].Close() + +# Finally create final histograms to be displayed +hCorrel = {} +cCorrel = {} +legCorrel = {} + +hRatio = {} +cRatio = {} +nbHitRatio = {} +legCorrel = {} + +for iPath in histos.keys(): + for iPath2 in histos.keys(): + corr = "%s_%s"%(iPath,iPath2) + if (iPath != iPath2):# and "%s_%s"%(iPath2,iPath) not in hCorrel.keys()): + print "====== I am checking correlation between %s and %s"%(iPath.split("/")[-1],iPath2.split("/")[-1]) + + hCorrel[corr] = TH2D("Correlation_%s"%corr,"Correlation_%s"%corr,50,min(nbHitInHot[iPath])-1,max(nbHitInHot[iPath])+1,50,min(nbHitInHot[iPath2])-1,max(nbHitInHot[iPath2])+1) + hCorrel[corr].SetXTitle(iPath.split("/")[-1]) + hCorrel[corr].SetYTitle(iPath2.split("/")[-1]) + + nbHitRatio[corr] = [-999.]*nLB + for iLB in listLB: + if (nbHitInHot[iPath2][iLB] !=0): + nbHitRatio[corr][iLB] = nbHitInHot[iPath][iLB]/nbHitInHot[iPath2][iLB] + + hRatio[corr] = TH1D("Ratio_%s"%corr,"Ratio_%s"%corr,50,-1.,max(nbHitRatio[corr])+1) + hRatio[corr].SetXTitle("%s/%s"%(iPath.split("/")[-1],iPath2.split("/")[-1])) + + for iLB in listLB: + if (nbHitInHot[iPath][iLB] !=0 or nbHitInHot[iPath2][iLB] != 0.): + hCorrel[corr].Fill(nbHitInHot[iPath][iLB],nbHitInHot[iPath2][iLB]) + print "LB: %d -> %.2f / %.2f"%(iLB,nbHitInHot[iPath][iLB],nbHitInHot[iPath2][iLB]) + hRatio[corr].Fill(nbHitRatio[corr][iLB]) + + cCorrel[corr] = TCanvas() + hCorrel[corr].Draw("COLZ") + legCorrel[corr] = TLegend(0.12,0.75,0.75,0.85) + legCorrel[corr].SetHeader("Run %d / %d LB in total - %d LB with correl"%(runNumber,len(listLB),hCorrel[corr].GetEntries())) + legCorrel[corr].Draw() + + cRatio[corr] = TCanvas() + hRatio[corr].Draw("COLZ") diff --git a/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py b/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py index 66dd8f405fb52aed41a1314ebb9689a0a2420973..0dcc6cd7adf8301bed6c4f797aeece861ea1efcd 100644 --- a/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py +++ b/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py @@ -25,7 +25,7 @@ # 2D OCCUPANCY: TopoClusters,EMTopoClusters, # EMTopoJets,TightFwdElectrons # 1D OCCUPANCY: EMTopoJets_eta -# INTEGRAL : NumberTau,NumberTightElectrons +# INTEGRAL : NumberTau,NumberTightElectrons,NumberHLTJet # -m ARG12, --min ARG12 # Min number of occurences in a LB # -g, --grl Look for Calo/LAr/Tile defects set in suspicious LBs @@ -64,14 +64,16 @@ parser.add_argument('-r','--run',type=int,dest='arg1',default='267599',help="Run parser.add_argument('-ll','--lowerlb',type=int,dest='arg2',default='0',help="Lower lb",action='store') parser.add_argument('-ul','--upperlb',type=int,dest='arg3',default='999999',help="Upper lb",action='store') parser.add_argument('-s','--stream',dest='arg4',default='Main',help="Stream without prefix: express/CosmicCalo/Main/ZeroBias/MinBias",action='store') -parser.add_argument('-t','--tag',dest='arg5',default='data16_13TeV',help="DAQ tag: data16_13TeV, data16_cos...",action='store') +parser.add_argument('-t','--tag',dest='arg5',default='data17_13TeV',help="DAQ tag: data16_13TeV, data16_cos...",action='store') parser.add_argument('-a','--amiTag',dest='arg6',default='f',help="First letter of AMI tag: x->express / f->bulk",action='store') parser.add_argument('-e','--eta',type=float,dest='arg7',default='-999.',help='Eta of hot spot',action='store') parser.add_argument('-p','--phi',type=float,dest='arg8',default='-999.',help='Phi of hot spot',action='store') +parser.add_argument('-x','--x',type=float,dest='arg71',default='-999.',help='X of hot spot',action='store') +parser.add_argument('-y','--y',type=float,dest='arg81',default='-999.',help='Y of hot spot',action='store') parser.add_argument('-ia','--integralAbove',type=float,dest='arg9',default='-999.',help='Lower bound of integral',action='store') parser.add_argument('-d','--delta',type=float,dest='arg10',default='0.1',help='Distance to look around hot spot',action='store') -parser.add_argument('-o','--object',dest='arg11',default='TopoClusters',help='2D OCCUPANCY: TopoClusters,EMTopoClusters,\n EMTopoJets,TightFwdElectrons,Tau \n1D OCCUPANCY: EMTopoJets_eta,Tau_eta,Tau_phi \nINTEGRAL : NumberTau,NumberTightFwdElectrons',action='store') -parser.add_argument('-m','--min',type=int,dest='arg12',default='5',help='Min number of occurences in a LB',action='store') +parser.add_argument('-o','--object',dest='arg11',default='TopoClusters',help='2D OCCUPANCY: TopoClusters,EMTopoClusters,\n EMTopoJets,TightFwdElectrons,Tau \n1D OCCUPANCY: EMTopoJets_eta,Tau_eta,Tau_phi \nINTEGRAL : NumberTau,NumberTightFwdElectrons,NumberHLTJet',action='store') +parser.add_argument('-m','--min',type=float,dest='arg12',default='5',help='Min number of occurences in a LB',action='store') parser.add_argument('-g','--grl',dest='arg13',help='Look for Calo/LAr/Tile defects set in suspicious LBs',action='store_true') args = parser.parse_args() @@ -86,6 +88,8 @@ tag = args.arg5 amiTag = args.arg6 etaSpot = args.arg7 phiSpot = args.arg8 +xSpot = args.arg71 +ySpot = args.arg81 integralAbove = args.arg9 deltaSpot = args.arg10 objectType = args.arg11 @@ -119,11 +123,12 @@ if (objectType == "TopoClusters"): "Et25GeV", "Et50GeV"] # Types of plot - # 2d_hotSpot : 2D occupancy plots: (eta/phi) required + # 2d_etaPhiHotSpot : 2D occupancy plots: (eta/phi) required + # 2d_xyHotSpot : any 2D plots: (x/y) required # 1d_etaHotSpot : 1D occupancy plot along eta: (eta) required # 1d_phiHotSpot : 1D occupancy plot along phi: (phi) required - # 1d_integralAbove: integral between (integralAbove) and infinity. (integralAbove) required - histoType = "2d_hotSpot" + # 1d_integralAbove : integral between (integralAbove) and infinity. (integralAbove) required + histoType = "2d_etaPhiHotSpot" # Name of object histoName = "TopoClusters" if (objectType == "EMTopoClusters"): @@ -139,7 +144,7 @@ if (objectType == "EMTopoClusters"): histoKeys = ["Et4GeV", "Et10GeV", "Et25GeV"] - histoType = "2d_hotSpot" + histoType = "2d_etaPhiHotSpot" histoName = "EMTopoClusters" # EMTopojets if (objectType == "EMTopoJets"): @@ -163,7 +168,7 @@ if (objectType == "EMTopoJets"): "cut2", "cut3", "cut4"] - histoType = "2d_hotSpot" + histoType = "2d_etaPhiHotSpot" histoName = "EMTopoJets" if (objectType == "EMTopoJets_eta"): histoPath = {"cut1":"run_%d/Jets/AntiKt4EMTopoJets/etasel_20000_inf_pt_inf_500000"%(runNumber), @@ -198,7 +203,7 @@ if (objectType == "Tau"): histoKeys = ["NoCut", "Et15GeV", "Et15GeVBdtLoose"] - histoType = "2d_hotSpot" + histoType = "2d_etaPhiHotSpot" histoName = "Tau" if (objectType == "Tau_phi"): histoPath = {"single":"run_%d/Tau/tauPhi"%(runNumber)} @@ -231,7 +236,7 @@ if (objectType == "TightFwdElectrons"): histoLegend = {"single":"10GeV"} histoColor = {"single":color0} histoKeys = ["single"] - histoType = "2d_hotSpot" + histoType = "2d_etaPhiHotSpot" histoName = "Tight electrons" if (objectType == "NumberTightFwdElectrons"): histoPath = {"single":"run_%d/egamma/forwardElectrons/forwardElectronTightN"%(runNumber)} @@ -240,33 +245,78 @@ if (objectType == "NumberTightFwdElectrons"): histoKeys = ["single"] histoType = "1d_integralAbove" histoName = "Number of tight forward electrons" +# HLT Jet +if (objectType == "NumberHLTJet"): + histoPath = {"HLTJet":"run_%d/HLT/JetMon/HLT/10j40_L14J20/HLTJet_n"%(runNumber)} + histoLegend = {"HLTJet":"All candidates"} + histoColor = {"HLTJet":color1} + histoKeys = ["HLTJet"] + histoType = "1d_integralAbove" + histoName = "Number of HLT jets - 10J40_L14J20 trigger" +# LAr digits +if (objectType == "LArDigits"): + histoPath = {"Null-EMBA":"run_%d/LAr/Digits/Barrel/NullDigitChan_BarrelA"%(runNumber), + "Satu-EMBA":"run_%d/LAr/Digits/Barrel/SaturationChan_BarrelA"%(runNumber), + "Null-EMBC":"run_%d/LAr/Digits/Barrel/NullDigitChan_BarrelC"%(runNumber), + "Satu-EMBC":"run_%d/LAr/Digits/Barrel/SaturationChan_BarrelC"%(runNumber), + } + histoLegend = {"Null-EMBA":"Null digit - EMBA", + "Satu-EMBA":"Saturated digit - EMBA", + "Null-EMBC":"Null digit - EMBC", + "Satu-EMBC":"Saturated digit - EMBC",} + histoColor = {"Null-EMBA":color0, + "Satu-EMBA":color1, + "Null-EMBC":color2, + "Satu-EMBC":color3} + histoKeys = ["Null-EMBA", + "Satu-EMBA", + "Null-EMBC", + "Satu-EMBC"] + histoType = "2d_xyHotSpot" + histoName = "LAr saturated/null digits" + # Depending of the histo/check type, define the summary title and # check that the position of the "hot spot" (or lower bound of the integral) is defined -if histoType == "2d_hotSpot": +b_wholeHisto = False +b_ValueNotEntries = False + +if histoType == "2d_etaPhiHotSpot": summaryTitle = "Nb of hits in a region of %.2f around the position (%.2f,%.2f) - %s"%(deltaSpot,etaSpot,phiSpot,histoName) - statement = "I have looked for LBs with at least %d entries at position (%.2f,%.2f) in %s histogram"%(minInLB,etaSpot,phiSpot,histoName) + statement = "I have looked for LBs with at least %.0f entries at position (%.2f,%.2f) in %s histogram"%(minInLB,etaSpot,phiSpot,histoName) if (etaSpot==-999. or phiSpot==-999.): - print "You must define eta/phi of hot spot" - sys.exit() + print "No eta/phi defined -> whole histogram considered!" + b_wholeHisto = True +if histoType == "2d_xyHotSpot": + b_ValueNotEntries = True + if (deltaSpot != 0): + print "Warning: you have been summing over several bins a variable that may be not summable (different from summing hits!)" + summaryTitle = "Value in a region of %.2f around the position (%.2f,%.2f) - %s"%(deltaSpot,xSpot,ySpot,histoName) + statement = "I have looked for LBs with at least variable > %.2f at position (%.2f,%.2f) in %s histogram"%(minInLB,xSpot,ySpot,histoName) + if (xSpot==-999. or ySpot==-999.): + print "No x/y defined -> whole histogram considered!" + print "Warning: you have been summing over several bins a variable that may be not summable (different from summing hits!)" + b_wholeHisto = True elif histoType == "1d_etaHotSpot": summaryTitle = "Nb of hits in a region of %.2f around the eta position %.2f - %s"%(deltaSpot,etaSpot,histoName) - statement = "I have looked for LBs with at least %d entries at eta position %.2f in %s histogram"%(minInLB,etaSpot,histoName) + statement = "I have looked for LBs with at least %.0f entries at eta position %.2f in %s histogram"%(minInLB,etaSpot,histoName) if (etaSpot==-999.): - print "You must define eta of hot spot" - sys.exit() + print "No eta/phi -> whole histogram considered!" + b_wholeHisto = True elif histoType == "1d_phiHotSpot": summaryTitle = "Nb of hits in a region of %.2f around the phi position %.2f - %s"%(deltaSpot,phiSpot,histoName) - statement = "I have looked for LBs with at least %d entries at phi position %.2f in %s histogram"%(minInLB,phiSpot,histoName) + statement = "I have looked for LBs with at least %.0f entries at phi position %.2f in %s histogram"%(minInLB,phiSpot,histoName) if (phiSpot==-999.): - print "You must define eta of phi spot" - sys.exit() + print "No eta/phi defined -> whole histogram considered!" + b_wholeHisto = True elif histoType == "1d_integralAbove": summaryTitle = "Nb of hits in the band above %.2f - %s"%(integralAbove,histoName) - statement = "I have looked for LBs with at least %d entries in band above %.2f in %s histogram"%(minInLB,integralAbove,histoName) + statement = "I have looked for LBs with at least %.0f entries in band above %.2f in %s histogram"%(minInLB,integralAbove,histoName) if (integralAbove==-999.): - print "You must define the lower bound of your integral" - sys.exit() + print "No lwoer bound defined -> whole histogram considered!" + b_wholeHisto = True +# print "You must define the lower bound of your integral" +# sys.exit() # Definition of Canvas option depending on histogram type if (objectType == "NumberTightFwdElectrons" or objectType == "NumberTau"): canvasOption = "logy" @@ -298,42 +348,55 @@ for iHisto in histoKeys: if "logy" in canvasOption: c[iHisto].SetLogy(1) # draw line, arrows, box to highlight the suspicious region considered - if (histoType == "2d_hotSpot"): + if (histoType == "2d_etaPhiHotSpot"): + gStyle.SetPalette(1) + gStyle.SetOptStat("") + histo[iHisto].Draw("COLZ") + if not b_wholeHisto: + box[iHisto] = TBox(etaSpot-deltaSpot,phiSpot-deltaSpot,etaSpot+deltaSpot,phiSpot+deltaSpot) + box[iHisto].SetLineColor(kRed+1) + box[iHisto].SetLineWidth(3) + box[iHisto].SetFillStyle(0) + box[iHisto].Draw() + elif (histoType == "2d_xyHotSpot"): gStyle.SetPalette(1) gStyle.SetOptStat("") histo[iHisto].Draw("COLZ") - box[iHisto] = TBox(etaSpot-deltaSpot,phiSpot-deltaSpot,etaSpot+deltaSpot,phiSpot+deltaSpot) - box[iHisto].SetLineColor(kRed+1) - box[iHisto].SetLineWidth(3) - box[iHisto].SetFillStyle(0) - box[iHisto].Draw() + if not b_wholeHisto: + box[iHisto] = TBox(xSpot-deltaSpot,ySpot-deltaSpot,xSpot+deltaSpot,ySpot+deltaSpot) + box[iHisto].SetLineColor(kRed+1) + box[iHisto].SetLineWidth(3) + box[iHisto].SetFillStyle(0) + box[iHisto].Draw() elif (histoType == "1d_etaHotSpot" or histoType == "1d_phiHotSpot"): minH = histo[iHisto].GetMinimum()*0.8 maxH = histo[iHisto].GetMaximum()*1.2 histo[iHisto].SetMinimum(minH) histo[iHisto].SetMaximum(maxH) histo[iHisto].Draw() - if maxH >0.: - if histoType == "1d_etaHotSpot": - box[iHisto] = TBox(etaSpot-deltaSpot,minH,etaSpot+deltaSpot,maxH) - if histoType == "1d_phiHotSpot": - box[iHisto] = TBox(phiSpot-deltaSpot,minH,phiSpot+deltaSpot,maxH) - box[iHisto].SetLineColor(kRed+1) - box[iHisto].SetLineWidth(3) - box[iHisto].SetFillStyle(0) - box[iHisto].Draw() + if not b_wholeHisto: + if maxH >0.: + if histoType == "1d_etaHotSpot": + box[iHisto] = TBox(etaSpot-deltaSpot,minH,etaSpot+deltaSpot,maxH) + if histoType == "1d_phiHotSpot": + box[iHisto] = TBox(phiSpot-deltaSpot,minH,phiSpot+deltaSpot,maxH) + box[iHisto].SetLineColor(kRed+1) + box[iHisto].SetLineWidth(3) + box[iHisto].SetFillStyle(0) + box[iHisto].Draw() elif (histoType == "1d_integralAbove"): maxH = histo[iHisto].GetMaximum()*1.2 histo[iHisto].SetMaximum(maxH) histo[iHisto].Draw() - line[iHisto] = TLine(integralAbove,0,integralAbove,maxH) - line[iHisto].SetLineColor(kRed+1) - line[iHisto].SetLineWidth(3) - line[iHisto].Draw() - arrow[iHisto] = TArrow(integralAbove,0.2*histo[iHisto].GetMaximum(),histo[iHisto].GetBinLowEdge(histo[iHisto].GetNbinsX()),0.2*histo[iHisto].GetMaximum(),0.02,">") - arrow[iHisto].SetLineColor(kRed+1) - arrow[iHisto].SetLineWidth(3) - arrow[iHisto].Draw() + if not b_wholeHisto: + line[iHisto] = TLine(integralAbove,0,integralAbove,maxH) + line[iHisto].SetLineColor(kRed+1) + line[iHisto].SetLineWidth(3) + line[iHisto].Draw() + arrow[iHisto] = TArrow(integralAbove,0.2*histo[iHisto].GetMaximum(),histo[iHisto].GetBinLowEdge(histo[iHisto].GetNbinsX()),0.2*histo[iHisto].GetMaximum(),0.02,">") + arrow[iHisto].SetLineColor(kRed+1) + arrow[iHisto].SetLineWidth(3) + arrow[iHisto].Draw() ######################################################################### # Extract the list of bins where to count. @@ -341,39 +404,59 @@ for iHisto in histoKeys: # The regionBins is defined for each histogram allowing different binning regionBins = {} for iHisto in histoKeys: - if (histoType == "2d_hotSpot"): - nSteps = 1000 - subStep = 2*deltaSpot/nSteps + if b_wholeHisto: regionBins[iHisto] = [] - for ix in range(nSteps):# Assume that eta is on x axis - iEta = etaSpot - deltaSpot + ix * subStep - for iy in range (nSteps): - iPhi = phiSpot - deltaSpot + iy * subStep - tmpBin = histo[iHisto].FindBin(iEta,iPhi) + if ("2d" in histoType): + maxBin = (histo[iHisto].GetNbinsX()+2)*(histo[iHisto].GetNbinsY()+2) + else: + maxBin = (histo[iHisto].GetNbinsX()+2) + for iBin in range(maxBin): + regionBins[iHisto].append(iBin) + else: + if (histoType == "2d_etaPhiHotSpot"): + nSteps = 1000 + subStep = 2*deltaSpot/nSteps + regionBins[iHisto] = [] + for ix in range(nSteps):# Assume that eta is on x axis + iEta = etaSpot - deltaSpot + ix * subStep + for iy in range (nSteps): + iPhi = phiSpot - deltaSpot + iy * subStep + tmpBin = histo[iHisto].FindBin(iEta,iPhi) + if (tmpBin not in regionBins[iHisto]): + regionBins[iHisto].append(tmpBin) + elif (histoType == "2d_xyHotSpot"): + nSteps = 1000 + subStep = 2*deltaSpot/nSteps + regionBins[iHisto] = [] + for ix in range(nSteps): + iX = xSpot - deltaSpot + ix * subStep + for iy in range (nSteps): + iY = ySpot - deltaSpot + iy * subStep + tmpBin = histo[iHisto].FindBin(iX,iY) + if (tmpBin not in regionBins[iHisto]): + regionBins[iHisto].append(tmpBin) + elif (histoType == "1d_etaHotSpot"): + nSteps = 1000 + subStep = 2*deltaSpot/nSteps + regionBins[iHisto] = [] + for ix in range(nSteps): + iEta = etaSpot - deltaSpot + ix * subStep + tmpBin = histo[iHisto].FindBin(iEta) if (tmpBin not in regionBins[iHisto]): - regionBins[iHisto].append(tmpBin) - elif (histoType == "1d_etaHotSpot"): - nSteps = 1000 - subStep = 2*deltaSpot/nSteps - regionBins[iHisto] = [] - for ix in range(nSteps): - iEta = etaSpot - deltaSpot + ix * subStep - tmpBin = histo[iHisto].FindBin(iEta) - if (tmpBin not in regionBins[iHisto]): - regionBins[iHisto].append(tmpBin) - elif (histoType == "1d_phiHotSpot"): - nSteps = 1000 - subStep = 2*deltaSpot/nSteps - regionBins[iHisto] = [] - for ix in range(nSteps): - iPhi = phiSpot - deltaSpot + ix * subStep - tmpBin = histo[iHisto].FindBin(iPhi) - if (tmpBin not in regionBins[iHisto]): - regionBins[iHisto].append(tmpBin) - elif (histoType == "1d_integralAbove"): - regionBins[iHisto] = [] - for iBin in range(histo[iHisto].FindBin(integralAbove),histo[iHisto].GetNbinsX()): - regionBins[iHisto].append(iBin) + regionBins[iHisto].append(tmpBin) + elif (histoType == "1d_phiHotSpot"): + nSteps = 1000 + subStep = 2*deltaSpot/nSteps + regionBins[iHisto] = [] + for ix in range(nSteps): + iPhi = phiSpot - deltaSpot + ix * subStep + tmpBin = histo[iHisto].FindBin(iPhi) + if (tmpBin not in regionBins[iHisto]): + regionBins[iHisto].append(tmpBin) + elif (histoType == "1d_integralAbove"): + regionBins[iHisto] = [] + for iBin in range(histo[iHisto].FindBin(integralAbove),histo[iHisto].GetNbinsX()): + regionBins[iHisto].append(iBin) # Extract all the unmerged files available with the LB range lbFilePathList = pathExtract.returnEosHistPathLB(runNumber,lowerLumiBlock,upperLumiBlock,stream,amiTag,tag) @@ -382,7 +465,7 @@ nbHitInHot = [] nLB=2500 nbHitInHot = {} for iHisto in histoKeys: - nbHitInHot[iHisto] = [0] * nLB + nbHitInHot[iHisto] = [0.] * nLB lowerLB = 2500 upperLB = 0 lbCanvas = [] @@ -461,16 +544,22 @@ for iHisto in histoKeys: 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]) - if (totalInRegionRecomp[iHisto] < totalInRegion[iHisto]): - print "This is normal only if you restricted the LB range..." - if (totalInRegionRecomp[iHisto] > totalInRegion[iHisto]): - print "This can be also caused by multiple processing, try to filter with -a option" - print "File path of the first file:",lbFilePathList[0] + if not b_ValueNotEntries: + print "%d-LB: %d -> %d hits"%(i,sortedLB[iHisto][i],nbHitInHot[iHisto][sortedLB[iHisto][i]]) + else: + print "%d-LB: %d -> %.2f"%(i,sortedLB[iHisto][i],nbHitInHot[iHisto][sortedLB[iHisto][i]]) + + if not b_ValueNotEntries: + 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]) + if (totalInRegionRecomp[iHisto] < totalInRegion[iHisto]): + print "This is normal only if you restricted the LB range..." + if (totalInRegionRecomp[iHisto] > totalInRegion[iHisto]): + print "This can be also caused by multiple processing, try to filter with -a option" + print "File path of the first file:",lbFilePathList[0] + else: + print "In the whole run, the value is %.2f"%(totalInRegion[iHisto]) ######################################################################### ## Plot evolution vs LB @@ -480,12 +569,13 @@ leg.SetHeader("Run %d"%runNumber) if (upperLB>=lowerLB): # check that at least one noisy LB was found c0 = TCanvas() gStyle.SetOptStat("") - c0.SetLogy(1) + if histoType != "2d_xyHotSpot": + c0.SetLogy(1) h0Evol = {} first = True for iHisto in histoKeys: h0Evol[iHisto] = TH1I("h0Evol%s"%(iHisto),summaryTitle,upperLB-lowerLB+1,lowerLB-0.5,upperLB+0.5) - h0Evol[iHisto].SetXTitle("LumiBlock (Only LB with >= %d entries)"%(minInLB)) + h0Evol[iHisto].SetXTitle("LumiBlock (Only LB with >= %.0f entries)"%(minInLB)) h0Evol[iHisto].SetLineColor(histoColor[iHisto]) h0Evol[iHisto].SetMarkerColor(histoColor[iHisto]) h0Evol[iHisto].SetMarkerStyle(20) @@ -494,8 +584,9 @@ if (upperLB>=lowerLB): # check that at least one noisy LB was found h0Evol[iHisto].Fill(i,nbHitInHot[iHisto][i]) if first: h0Evol[iHisto].Draw("P HIST") - h0Evol[iHisto].SetMinimum(minInLB-1) - h0Evol[iHisto].SetMaximum(maxNbInHot*1.5) + if histoType != "2d_xyHotSpot": + h0Evol[iHisto].SetMinimum(minInLB-0.8) + h0Evol[iHisto].SetMaximum(maxNbInHot*1.5) first = False else: h0Evol[iHisto].Draw("PSAME HIST")