From c99a2c77b820b9fd5cf4a44c78fde17bf23141d8 Mon Sep 17 00:00:00 2001 From: Peter Onyisi <ponyisi@utexas.edu> Date: Tue, 18 Aug 2015 19:58:33 +0200 Subject: [PATCH] Include pixel postprocessing bug fix (DataQualityUtils-02-20-11) * Tag DataQualityUtils-02-20-11 2015-08-18 Daiki Yamaguchi <daiki.yamaguchi@cern.ch> * Fix the bugs in MonitoringFile_PixelPostProcess.cxx * Committed to the trunk 2015-08-16 Peter Onyisi * Revert changes to arguments on DQWebDisplay.py * Tag DataQualityUtils-02-20-10 2015-08-14 Marcin Nowak <Marcin.Nowak@cern.ch> * src\MonitoringFile_IDEnhancedPrimaryVertex.cxx: fix const errors showing up with ROOT6.4 2015-08-11 Yuriy Ilchenko * Tag DataQualityUtils-02-20-09 with Lu Yuan's and Daiki Yamaguchi's updates 2015-08-06 Yuriy Ilchenko * Tag DataQualityUtils-02-20-08 with Baojia's fixes ... (Long ChangeLog diff - truncated) --- .../DataQualityUtils/MonitoringFile.h | 5 + DataQuality/DataQualityUtils/cmt/requirements | 2 + .../python/DQPostProcessMod.py | 6 +- .../scripts/DQPostProcessTest.py | 4 +- .../DataQualityUtils/scripts/DQWebDisplay.py | 6 +- .../DataQualityUtils/scripts/hotSpotInTAG.py | 82 +++--- .../DataQualityUtils/scripts/pathExtract.py | 80 ++---- .../DataQualityUtils/scripts/readTier0HIST.py | 44 +++ .../DataQualityUtils/scripts/readTier0TAGs.py | 56 ++++ ...MonitoringFile_IDEnhancedPrimaryVertex.cxx | 6 +- .../src/MonitoringFile_MDTPostProcess.cxx | 23 +- .../MonitoringFile_MuonTrackPostProcess.cxx | 272 ++++++++++++++++++ .../src/MonitoringFile_PixelPostProcess.cxx | 181 ++++++++++++ .../src/MonitoringFile_TGCPostProcess.cxx | 51 ++-- 14 files changed, 680 insertions(+), 138 deletions(-) create mode 100644 DataQuality/DataQualityUtils/scripts/readTier0HIST.py create mode 100644 DataQuality/DataQualityUtils/scripts/readTier0TAGs.py create mode 100644 DataQuality/DataQualityUtils/src/MonitoringFile_MuonTrackPostProcess.cxx create mode 100644 DataQuality/DataQualityUtils/src/MonitoringFile_PixelPostProcess.cxx diff --git a/DataQuality/DataQualityUtils/DataQualityUtils/MonitoringFile.h b/DataQuality/DataQualityUtils/DataQualityUtils/MonitoringFile.h index c403adab772..d0bdc9e5e67 100644 --- a/DataQuality/DataQualityUtils/DataQualityUtils/MonitoringFile.h +++ b/DataQuality/DataQualityUtils/DataQualityUtils/MonitoringFile.h @@ -188,6 +188,10 @@ namespace dqutils { static Double_t MuonTrkPhys_BWgaus(Double_t *x, Double_t *par); static Double_t MuonTrkPhys_fitFunctionS(Double_t *x, Double_t *par); + // For MuonTrackMonitoring + static void MuonTrackPostProcess(std::string inFileName, bool isIncremental = false); + static void MuonTrack_Main(std::string inFileName, TString dirname); + //For Muon MDT static void MDTPostProcess(std::string inFilename, bool isIncremental = false, int txtFileOutputType = 0, bool useOfflineTubeID = false, bool makePDF = false, bool doAllPDF = true); static void MDTChamReAlign(std::string inFilename, std::string title="MDT"); @@ -351,6 +355,7 @@ namespace dqutils { int items, double threshold, int binSkip); // SCT + static void PixelPostProcess(std::string inFilename, bool isIncremental = false); static void SCTPostProcess(std::string inFilename, bool isIncremental = false); // Other helper methods diff --git a/DataQuality/DataQualityUtils/cmt/requirements b/DataQuality/DataQualityUtils/cmt/requirements index debb596a51f..fa84038d787 100644 --- a/DataQuality/DataQualityUtils/cmt/requirements +++ b/DataQuality/DataQualityUtils/cmt/requirements @@ -67,7 +67,9 @@ library DataQualityUtils $(lib_opts) "\ ../src/MonitoringFile_HLTCaloPostProcess.cxx\ ../src/MonitoringFile_HLTJetPostProcess.cxx\ ../src/MonitoringFile_HLTMinBiasMonPostProcess.cxx\ + ../src/MonitoringFile_PixelPostProcess.cxx\ ../src/MonitoringFile_SCTPostProcess.cxx\ + ../src/MonitoringFile_MuonTrackPostProcess.cxx\ ../src/MonitoringFile_MuonTrkPhys.cxx\ ../src/MonitoringFile_MergeAlgs.cxx\ ../src/StatusFlagCOOL.cxx\ diff --git a/DataQuality/DataQualityUtils/python/DQPostProcessMod.py b/DataQuality/DataQualityUtils/python/DQPostProcessMod.py index d6ea056ab67..fd05a709390 100644 --- a/DataQuality/DataQualityUtils/python/DQPostProcessMod.py +++ b/DataQuality/DataQualityUtils/python/DQPostProcessMod.py @@ -176,8 +176,12 @@ def DQPostProcess( outFileName, isIncremental=False ): ['ivana.hristova@cern.ch', 'pjwf@hep.ph.bham.ac.uk']), (mf.SCTPostProcess, ['masaki.endo@cern.ch']), + (mf.PixelPostProcess, + ['daiki.yamaguchi@cern.ch']), (mf.MuonTrkPhys, - ['austin.basye@cern.ch', 'rcyooper@uw.edu']) + ['austin.basye@cern.ch', 'rcyooper@uw.edu']), + (mf.MuonTrackPostProcess, + ['baojia.tong@cern.ch', 'alex.tuna@cern.ch']) ] for funcinfo in funclist: diff --git a/DataQuality/DataQualityUtils/scripts/DQPostProcessTest.py b/DataQuality/DataQualityUtils/scripts/DQPostProcessTest.py index 6ab86563d9c..d2cb6b0b886 100644 --- a/DataQuality/DataQualityUtils/scripts/DQPostProcessTest.py +++ b/DataQuality/DataQualityUtils/scripts/DQPostProcessTest.py @@ -3,7 +3,7 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration ## ***************************************************************************** -VERSION = '$Id: DQPostProcessTest.py 514510 2012-08-22 16:02:43Z vogel $' +VERSION = '$Id: DQPostProcessTest.py 686318 2015-07-29 14:47:05Z btong $' ## ***************************************************************************** #import DataQualityUtils.DQHistogramMergeMod as mod @@ -63,6 +63,7 @@ mf.HLTMuonPostProcess(outFile, isIncremental) mf.HLTTauPostProcess(outFile, isIncremental) mf.HLTMETPostProcess(outFile, isIncremental) mf.HLTJetPostProcess(outFile, isIncremental) +mf.MuonTrackPostProcess(outFile, isIncremental) mf.MuonTrkPhys(outFile, isIncremental) mf.BJetTaggingPostProcess(outFile, isIncremental) mf.L1CaloPostProcess(outFile, isIncremental) @@ -87,6 +88,7 @@ mf.HLTMuonPostProcess(outFile, isIncremental) mf.HLTTauPostProcess(outFile, isIncremental) mf.HLTMETPostProcess(outFile, isIncremental) mf.HLTJetPostProcess(outFile, isIncremental) +mf.MuonTrackPostProcess(outFile, isIncremental) mf.MuonTrkPhys(outFile, isIncremental) mf.BJetTaggingPostProcess(outFile, isIncremental) mf.L1CaloPostProcess(outFile, isIncremental) diff --git a/DataQuality/DataQualityUtils/scripts/DQWebDisplay.py b/DataQuality/DataQualityUtils/scripts/DQWebDisplay.py index a308f4176f3..04ddf299a69 100755 --- a/DataQuality/DataQualityUtils/scripts/DQWebDisplay.py +++ b/DataQuality/DataQualityUtils/scripts/DQWebDisplay.py @@ -4,7 +4,7 @@ # -*- coding: utf-8 -*- ## ***************************************************************************** -VERSION = '$Id: DQWebDisplay.py 587229 2014-03-11 23:26:39Z ponyisi $' +VERSION = '$Id: DQWebDisplay.py 689658 2015-08-16 14:57:56Z ponyisi $' ## ***************************************************************************** import os @@ -44,7 +44,8 @@ def usage(): print "" if __name__ == "__main__": - if len(sys.argv) < 4 or len(sys.argv) > 7: + print len(sys.argv) + if len(sys.argv) < 5 or len(sys.argv) > 7: usage() sys.exit(0) @@ -55,6 +56,7 @@ if __name__ == "__main__": runAccumulating = True if len(sys.argv) == 7: + print 'Setting condition', sys.argv[5] ROOT.gSystem.Load('libDataQualityInterfaces') ROOT.dqi.ConditionsSingleton.getInstance().setCondition(sys.argv[5]) diff --git a/DataQuality/DataQualityUtils/scripts/hotSpotInTAG.py b/DataQuality/DataQualityUtils/scripts/hotSpotInTAG.py index bfbeedb0b12..e312741f324 100644 --- a/DataQuality/DataQualityUtils/scripts/hotSpotInTAG.py +++ b/DataQuality/DataQualityUtils/scripts/hotSpotInTAG.py @@ -1,12 +1,9 @@ #!/usr/bin env python # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -# Author : Benjamin Trocme / Summer 2012 -# Make use of extractPath library to retrieve the correct castor path - # Script to browse a TAG file and extract LBs for which at least N occurences of an object is found # in a region defined as noisy. +# Uses the pathExtract library to extract the EOS path #Options: # -h, --help show this help message and exit # -r RUN, --run=RUN Run number @@ -14,17 +11,19 @@ # -a AMI, --amiTag=AMI ami Tag - Simply set x/f to choose express/bulk processing # -e ETA, --eta=ETA Eta of hot spot # -p PHI, --phi=PHI Phi of hot spot (or MET bump) -# -t THRESHOLD, --treshold=THRESHOLD Et/pt threshold (in MeV) +# -c THRESHOLD, --treshold=THRESHOLD Et/pt threshold (in MeV) # -d DELTA, --delta=DELTA Distance to look around hot spot (or MET bump) # -o OBJECT, --object=OBJECT TopoCluster/Jet/LoosePhoton/TauJet/MET # -m MIN, --min=MIN Min number of object in a LB # -n, --noplot Do not plot LB map -# The -h does not work. I should move to argpars... +# Author : Benjamin Trocme (LPSC Grenoble) / Summer 2012, updated in 2015 + import os, sys import string -import subprocess as sp from optparse import OptionParser +import argparse + #sys.path.append("/afs/cern.ch/user/t/trocme/public/libraries") import pathExtract @@ -69,7 +68,7 @@ def analyzeTree(): h0map.Fill(iCE[1],iCE[2]) if not (tree.LArFlags & 8): h0mapClean.Fill(iCE[1],iCE[2]) - if not ((not options.larcleaning) and tree.LArFlags & 8): # Explicit cut LArEventInfo != ERROR to remove noise bursts is larcleaning is false + if not ((not args.larcleaning) and tree.LArFlags & 8): # Explicit cut LArEventInfo != ERROR to remove noise bursts is larcleaning is false if (fabs(iCE[1]-etaSpot)<deltaSpot and fabs(iCE[2]-phiSpot)<deltaSpot): # A candidate has been found in suspicious region - Explict cut LArEventInfo != ERROR to remove noise bursts # if (fabs(iCE[1]-etaSpot)<deltaSpot and fabs(iCE[2]-phiSpot)<deltaSpot and not (tree.LArFlags & 8)): # A candidate has been found in suspicious region - Explict cut LArEventInfo != ERROR to remove noise bursts nbHitInHot[tree.LumiBlockN]=nbHitInHot[tree.LumiBlockN] + 1 @@ -81,33 +80,34 @@ def analyzeTree(): # Main=========================================================================================================== -usage = 'usage: %prog [options] arg' -parser = OptionParser(usage) -parser.add_option('-r','--run',type='str',dest='run',default='',help='Run number',action='store') -parser.add_option('-s','--stream',type='str',dest='streams',default='express',help='Data stream : express/CosmicCalo/JetTauEtmiss/Egamma',action='store') -parser.add_option('-a','--amiTag',type='str',dest='ami',default='f',help='ami Tag - Simply set x/f to choose express/bulk processing',action='store') -parser.add_option('-e','--eta',type='float',dest='eta',default='0.',help='Eta of hot spot',action='store') -parser.add_option('-p','--phi',type='float',dest='phi',default='0.',help='Phi of hot spot (or MET bump)',action='store') -parser.add_option('-t','--treshold',type='int',dest='threshold',default='1000',help='Et/pt threshold (in MeV)',action='store') -parser.add_option('-d','--delta',type='float',dest='delta',default='0.1',help='Distance to look around hot spot (or MET bump)',action='store') -parser.add_option('-o','--object',type='string',dest='object',default='TopoCluster',help='TopoCluster/Jet/LoosePhoton/TauJet/MET',action='store') -parser.add_option('-m','--min',type='int',dest='min',default='5',help='Min number of object in a LB',action='store') -parser.add_option('-n','--noplot',dest='noplot',help='Do not plot LB map',action='store_true') -parser.add_option('-l','--larcleaning',dest='larcleaning',help='Ignore LAr cleaning to find hot spot',action='store_true') +parser = argparse.ArgumentParser() +parser.add_argument('-r','--run',type=int,dest='runNumber',default='267599',help="Run number",action='store') +parser.add_argument('-s','--stream',dest='stream',default='express',help="Stream without prefix: express, CosmicCalo, Egamma...",action='store') +parser.add_argument('-t','--tag',dest='tag',default='data15_13TeV',help="DAQ tag: data12_8TeV, data12_calocomm...",action='store') +parser.add_argument('-a','--amiTag',dest='amiTag',default='x',help="First letter of AMI tag: x->express / f->bulk",action='store') +parser.add_argument('-e','--eta',type=float,dest='etaSpot',default='0',help='Eta of hot spot',action='store') +parser.add_argument('-p','--phi',type=float,dest='phiSpot',default='0.',help='Phi of hot spot (or MET bump)',action='store') +parser.add_argument('-c','--cut',type=int,dest='thresholdE',default='1000',help='Et/pt threshold (in MeV)',action='store') +parser.add_argument('-d','--delta',type=float,dest='deltaSpot',default='0.1',help='Distance to look around hot spot (or MET bump)',action='store') +parser.add_argument('-o','--object',dest='objectType',default='TopoCluster',help='TopoCluster/Jet/LoosePhoton/TauJet/MET',action='store') +parser.add_argument('-m','--min',type=int,dest='minInLB',default='5',help='Min number of object in a LB',action='store') +parser.add_argument('-n','--noplot',dest='noplot',help='Do not plot LB map',action='store_true') +parser.add_argument('-l','--larcleaning',dest='larcleaning',help='Ignore LAr cleaning to find hot spot',action='store_true') + +args = parser.parse_args() parser.print_help() -usage = 'usage: %prog [options] arg' -(options, args) = parser.parse_args() -run = options.run -stream = options.streams -amiTag = options.ami -etaSpot = options.eta -phiSpot = options.phi -deltaSpot = options.delta -objectType = options.object -minInLB = options.min -thresholdE = options.threshold +run = args.runNumber +stream = args.stream +tag = args.tag +amiTag = args.amiTag +etaSpot = args.etaSpot +phiSpot = args.phiSpot +thresholdE = args.thresholdE +deltaSpot = args.deltaSpot +objectType = args.objectType +minInLB = args.minInLB if ("MET" in objectType): etaSpot=0 @@ -117,15 +117,13 @@ print '---------------------------------' print "Investigation on run "+str(run)+"/"+stream+" stream with ami TAG "+amiTag listOfFiles = pathExtract.returnEosTagPath(run,stream,amiTag) -#listOfFiles=["root://eosatlas//eos/atlas/atlastier0/rucio/data15_comm/express_express/00265573/data15_comm.00265573.express_express.merge.TAG.f581_m1423_m1425/data15_comm.00265573.express_express.merge.TAG.f581_m1423_m1425._0001.1"] - tree = TChain("POOLCollectionTree") for files in listOfFiles: tree.AddFile("root://eosatlas/%s"%(files)) + print "I chained the file %s"%(files) entries = tree.GetEntries() -#entries = 100 nLB=2000 nbHitInHot = [0] * nLB @@ -139,16 +137,16 @@ if ("MET" in objectType): h0mapClean = TH1D("mapClean","General map of %s with MET > %d MeV - LArFlags != ERROR"%(objectType,thresholdE),64,-3.14,3.14) else: h0map = TH2D("map","General map of %s with Et/Pt > %d MeV"%(objectType,thresholdE),90,-4.5,4.5,64,-3.14,3.14) - h0mapClean = TH2D("mapClean","General map of %s with MET > %d MeV - LArFlags != ERROR"%(objectType,thresholdE),90,-4.5,4.5,64,-3.14,3.14) + h0mapClean = TH2D("mapClean","General map of %s with Et/Pt > %d MeV - LArFlags != ERROR"%(objectType,thresholdE),90,-4.5,4.5,64,-3.14,3.14) for jentry in xrange( entries ): # Loop on all events - if (jentry % 100000 == 0): + if (jentry % 10000 == 0): print "%d / %d evnt processed"%(jentry,entries) nb = tree.GetEntry( jentry ) analyzeTree() print "I have looked for LBs with at least %d %s in a region of %.2f around (%.2f,%.2f) and Et/Pt > %d MeV"%(minInLB,objectType,deltaSpot,etaSpot,phiSpot,thresholdE) -if (options.larcleaning): +if (args.larcleaning): print "WARNING : The LArCleaning for noise bursts (LArEventInfo != ERROR) has been DEACTIVATED!!!" else: print "The LArCleaning (LArEventInfo != ERROR) for noise bursts has been activated" @@ -164,7 +162,7 @@ for i in range(nLB): if i>upperLB : upperLB = i -if (options.larcleaning): +if (args.larcleaning): suffix = "NO LArFlags cut" else: suffix = "LArFlags != ERROR" @@ -203,13 +201,13 @@ else: h0mapClean.Draw("COLZ") # Plot individual map for each LB. Can be switched off with "-n" -if (not options.noplot): +if (not args.noplot): canvas = [] - for i in range(min(len(nLB_offending),2)): + for i in range(min(len(nLB_offending),4)): canvas.append(TCanvas()) iCurrent = len(canvas)-1 - if (options.larcleaning): + if (args.larcleaning): cutC = "1" # Accept all events else: cutC = "!(LArFlags & 8)" # Reject events flagged with LArEventInfo::ERROR diff --git a/DataQuality/DataQualityUtils/scripts/pathExtract.py b/DataQuality/DataQualityUtils/scripts/pathExtract.py index 0a18041e9f9..5ad1e062769 100644 --- a/DataQuality/DataQualityUtils/scripts/pathExtract.py +++ b/DataQuality/DataQualityUtils/scripts/pathExtract.py @@ -10,46 +10,27 @@ import subprocess as sp from ROOT import * from ROOT import gROOT, gDirectory, gPad - - # Return the path of the output of tier0 monitoring -def returnTier0HistPath(run,stream,amiTag,tag="data12_8TeV"): +def returnEosHistPath(run,stream,amiTag,tag="data15_cos"): os.putenv("STAGE_SVCCLASS","atlcal") - prefix = {'express':'express_','Egamma':'physics_','CosmicCalo':'physics_','JetTauEtmiss':'physics_'} - path="/castor/cern.ch/grid/atlas/tzero/prod1/perm/"+tag+"/"+prefix[stream]+stream+"/" - P = sp.Popen(['nsls',path],stdout=sp.PIPE,stderr=sp.PIPE) + prefix = {'express':'express_','Egamma':'physics_','CosmicCalo':'physics_','JetTauEtmiss':'physics_','Main':'physics_','ZeroBias':'physics_'} + path = '/eos/atlas/atlastier0/rucio/'+tag+'/'+prefix[stream]+stream+'/00'+str(run)+'/' + P = sp.Popen(['/afs/cern.ch/project/eos/installation/0.3.84-aquamarine/bin/eos.select','ls',path],stdout=sp.PIPE,stderr=sp.PIPE) p = P.communicate() - if p[1]=='': - listOfRuns = p[0].split('\n') - for iRun in listOfRuns: - if (str(run) in iRun): - path = "/castor/cern.ch/grid/atlas/tzero/prod1/perm/"+tag+"/"+prefix[stream]+stream+"/"+iRun - P = sp.Popen(['nsls',path],stdout=sp.PIPE,stderr=sp.PIPE) - p = P.communicate() - listOfDirs = p[0].split('\n') - for iDir in listOfDirs: - dotAmiTag=".%s"%(amiTag) - if ("HIST" in iDir and dotAmiTag in iDir): - path = "/castor/cern.ch/grid/atlas/tzero/prod1/perm/"+tag+"/"+prefix[stream]+stream+"/"+iRun+"/"+iDir - P = sp.Popen(['nsls',path],stdout=sp.PIPE,stderr=sp.PIPE) - p = P.communicate() - listOfFiles = p[0].split('\n') - path = "/castor/cern.ch/grid/atlas/tzero/prod1/perm/"+tag+"/"+prefix[stream]+stream+"/"+iRun+"/"+iDir+"/"+listOfFiles[0] - P = sp.Popen(['stager_get','-M',path],stdout=sp.PIPE,stderr=sp.PIPE) - p = P.communicate() - if p[1]=='': - if ("Insufficient" in p[0]): - print "File NOT STAGED : missing %s"%(path) - return "NOFILE" - else: - print "I found %s"%(path) - return path - print "Failed - Aborted at %s level"%(path) - return "NOFILE" + listOfFiles = p[0].split('\n') + for iFile in listOfFiles: + if ("HIST.%s"%(amiTag) in iFile): + path = '/eos/atlas/atlastier0/rucio/'+tag+'/'+prefix[stream]+stream+'/00'+str(run)+'/'+iFile + P = sp.Popen(['/afs/cern.ch/project/eos/installation/0.3.84-aquamarine/bin/eos.select','ls',path],stdout=sp.PIPE,stderr=sp.PIPE) + p = P.communicate() + path = '/eos/atlas/atlastier0/rucio/'+tag+'/'+prefix[stream]+stream+'/00'+str(run)+'/'+iFile+'/'+p[0] + return path + + return "FILE NOT FOUND" # Return the list of TAGs files on EOS -def returnEosTagPath(run,stream,amiTag="f",tag ="data15_comm"): - prefix = {'express':'express_','Egamma':'physics_','CosmicCalo':'physics_','JetTauEtmiss':'physics_'} +def returnEosTagPath(run,stream,amiTag="f",tag ="data15_13TeV"): + prefix = {'express':'express_','Egamma':'physics_','CosmicCalo':'physics_','JetTauEtmiss':'physics_','Main':'physics_'} found = False list = [] path = '/eos/atlas/atlastier0/rucio/'+tag+'/'+prefix[stream]+stream+'/00'+str(run)+'/' @@ -77,32 +58,3 @@ def returnEosTagPath(run,stream,amiTag="f",tag ="data15_comm"): pathFile = path+iFile list.append(pathFile) return list - -# Add new run to noise bursts TChain - 2012 data stored on EOS -def eosChainInclude(newRun,stream,chain): - path="/eos/atlas/atlasgroupdisk/det-larg/data12_8TeV/NTUP_LARNOISE/" - P = sp.Popen(["/afs/cern.ch/project/eos/installation/0.1.0-22d/bin/eos.select","ls",path],stdout=sp.PIPE,stderr=sp.PIPE) - p = P.communicate() - if p[1]=='': - tags = p[0] - tags = tags.split('\n') - for t in tags: - path='/eos/atlas/atlasgroupdisk/det-larg/data12_8TeV/NTUP_LARNOISE/'+t - P = sp.Popen(['/afs/cern.ch/project/eos/installation/0.1.0-22d/bin/eos.select','ls',path],stdout=sp.PIPE,stderr=sp.PIPE) - p = P.communicate() - if p[1]=='': - runs = p[0] - runs = runs.split('\n') - for iRun in runs: - if (str(newRun) in iRun) and (stream in iRun): - path='/eos/atlas/atlasgroupdisk/det-larg/data12_8TeV/NTUP_LARNOISE/'+t+'/'+iRun - P = sp.Popen(['/afs/cern.ch/project/eos/installation/0.1.0-22d/bin/eos.select','ls',path],stdout=sp.PIPE,stderr=sp.PIPE) - p = P.communicate() - if p[1]=='': - files = p[0] - files = files.split('\n') - for iFile in files: - if 'root' in iFile: - path='root://eosatlas//eos/atlas/atlasgroupdisk/det-larg/data12_8TeV/NTUP_LARNOISE/'+t+'/'+iRun+'/'+iFile - print "Adding %s"%(path) - chain.Add(path) diff --git a/DataQuality/DataQualityUtils/scripts/readTier0HIST.py b/DataQuality/DataQualityUtils/scripts/readTier0HIST.py new file mode 100644 index 00000000000..171505468de --- /dev/null +++ b/DataQuality/DataQualityUtils/scripts/readTier0HIST.py @@ -0,0 +1,44 @@ +#!/usr/bin env python + +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Simple script to extract the path of the HIST output of Tier0 monitoring, +# open it and open a TBrowser +# Uses the pathExtract library to extract the EOS path +# Options: +# -r RUNNUMBER, --run RUNNUMBER : Run number +# -s STREAM, --stream STREAM : Stream without prefix: express, CosmicCalo, Egamma... +# -t TAG, --tag TAG : DAQ tag: data12_8TeV, data12_calocomm... +# -a AMITAG, --amiTag AMITAG : First letter of AMI tag: x->express / f->bulk +# +# Author : Benjamin Trocme (LPSC Grenoble) / Summer 2012, updated in 2015 + + + +import os, sys +import argparse + +import pathExtract + +from ROOT import * + +# Main ================================================================ +gStyle.SetPalette(1) +gStyle.SetOptStat("emuo") + +parser = argparse.ArgumentParser() +parser.add_argument('-r','--run',type=int,dest='runNumber',default='267599',help="Run number",action='store') +parser.add_argument('-s','--stream',dest='stream',default='express',help="Stream without prefix: express, CosmicCalo, Egamma...",action='store') +parser.add_argument('-t','--tag',dest='tag',default='data15_13TeV',help="DAQ tag: data12_8TeV, data12_calocomm...",action='store') +parser.add_argument('-a','--amiTag',dest='amiTag',default='x',help="First letter of AMI tag: x->express / f->bulk",action='store') + +parser.print_help() + +args = parser.parse_args() + +path = "root://eosatlas.cern.ch/%s"%(pathExtract.returnEosHistPath(args.runNumber,args.stream,args.amiTag,args.tag)).rstrip() + +if ("NO FILE" not in path): + print "I am opening %s"%(path) + f = TFile.Open(path) + gStyle.SetPalette(1) + tb = TBrowser() diff --git a/DataQuality/DataQualityUtils/scripts/readTier0TAGs.py b/DataQuality/DataQualityUtils/scripts/readTier0TAGs.py new file mode 100644 index 00000000000..2b6676391c0 --- /dev/null +++ b/DataQuality/DataQualityUtils/scripts/readTier0TAGs.py @@ -0,0 +1,56 @@ +#!/usr/bin env python + +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Simple script to extract the path of the TAG outputs of Tier0 monitoring, +# open them and chain them in a single TChain +# Uses the pathExtract library to extract the EOS path +# Options: +# -r RUNNUMBER, --run RUNNUMBER : Run number +# -s STREAM, --stream STREAM : Stream without prefix: express, CosmicCalo, Egamma... +# -t TAG, --tag TAG : DAQ tag: data12_8TeV, data12_calocomm... +# -a AMITAG, --amiTag AMITAG : First letter of AMI tag: x->express / f->bulk +# Author : Benjamin Trocme / Summer 2012 + +import os, sys +import argparse + +import pathExtract + +from ROOT import * + +gROOT.Reset() +gStyle.SetPalette(1) +gStyle.SetOptStat("em") + + +# Main=========================================================================================================== +parser = argparse.ArgumentParser() +parser.add_argument('-r','--run',type=int,dest='runNumber',default='267599',help="Run number",action='store') +parser.add_argument('-s','--stream',dest='stream',default='express',help="Stream without prefix: express, CosmicCalo, Egamma...",action='store') +parser.add_argument('-t','--tag',dest='tag',default='data15_13TeV',help="DAQ tag: data12_8TeV, data12_calocomm...",action='store') +parser.add_argument('-a','--amiTag',dest='amiTag',default='x',help="First letter of AMI tag: x->express / f->bulk",action='store') + +parser.print_help() + +args = parser.parse_args() + +run = args.runNumber +stream = args.stream +tag = args.tag +amiTag = args.amiTag + +listOfFiles = pathExtract.returnEosTagPath(run,stream,amiTag,tag) + +tree = TChain("POOLCollectionTree") + +file = {} +for fileNames in listOfFiles: + print "Adding %s"%(fileNames) + tree.AddFile("root://eosatlas/%s"%(fileNames)) + +entries = tree.GetEntries() +if entries != 0: + print "The chained tree contains %d entries"%(entries) +else: + print "Empty chain..." + diff --git a/DataQuality/DataQualityUtils/src/MonitoringFile_IDEnhancedPrimaryVertex.cxx b/DataQuality/DataQualityUtils/src/MonitoringFile_IDEnhancedPrimaryVertex.cxx index 972ab6c8712..74b22a2fa7c 100644 --- a/DataQuality/DataQualityUtils/src/MonitoringFile_IDEnhancedPrimaryVertex.cxx +++ b/DataQuality/DataQualityUtils/src/MonitoringFile_IDEnhancedPrimaryVertex.cxx @@ -29,7 +29,7 @@ namespace dqutils { // define helper methods here rather then in this central MonitoringFile.h "beast" void plotResolution(const TString& coordinate, const TString& versus); void plotEfficiency(); -double error_func( float x, Double_t *par); +double error_func( float x, const Double_t *par); double scaleFactorFitFcn(double *x, double *par); std::vector<float> stableGaussianFit(TH1 * histo); @@ -221,7 +221,7 @@ plotResolution(const TString& coordinate="Z", const TString& versus="Ntrk") maxFitRange = 20.; } TF1 *kgs_z_ntrk_fit; - Double_t *kgs_z_ntrk_fit_er; + const Double_t *kgs_z_ntrk_fit_er; int fitResKFactorMethod = 2; // set by hand for now if (fitResKFactorMethod == 1) { //Fit with a pol2 @@ -436,7 +436,7 @@ std::vector<float> stableGaussianFit(TH1 * histo) return results; }//end of stableGaussian Fit function -double error_func( float x, Double_t *par) +double error_func( float x, const Double_t *par) { //calculating the square of the propagated error on the fit values return ( TMath::Power(par[0],2) + x * TMath::Power(par[1],2) + TMath::Power(x * par[2],2)) ; diff --git a/DataQuality/DataQualityUtils/src/MonitoringFile_MDTPostProcess.cxx b/DataQuality/DataQualityUtils/src/MonitoringFile_MDTPostProcess.cxx index f6bb6fa6365..1a12ffbdcda 100644 --- a/DataQuality/DataQualityUtils/src/MonitoringFile_MDTPostProcess.cxx +++ b/DataQuality/DataQualityUtils/src/MonitoringFile_MDTPostProcess.cxx @@ -519,9 +519,11 @@ namespace dqutils { TDirectory* dirChamb = mf.GetDirectory(chamber_Area+ecap_fullStr+"/Chambers/"+dirName); if(!dirChamb) continue; if(dirName=="BML6A13"||dirName=="BML6C13") continue;//These chambers do not exist - if(dirName(0,2)=="EE" && dirName(4,1) == "A"){// All EE C chambers are installed. Only 3, 5(1), 11, 13 exist on A + + /*if(dirName(0,2)=="EE" && dirName(4,1) == "A"){// All EE C chambers are installed. Only 3, 5(1), 11, 13 exist on A if(!(dirName(3,4)=="1A05" || dirName(5,2) == "03" || dirName(5,2)=="11" || dirName(5,2)=="13")) continue; - } + }*/ //They exist now! + //////////////////////////////////////////////////////////////////////////////////////////////////// //////Dead Noisy Tube Calculations //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -732,8 +734,13 @@ namespace dqutils { yAxis += dirName(2,1); } //BML[45][AC]13-->BML[56][AC]13 - if( dirName(0,3) == "BML" && TString(dirName(3,1)).Atoi() >= 4 && dirName(5,2) == "13" && VolumeMapBCap->GetNbinsY() >= 58 ) + if( dirName(0,3) == "BML" && TString(dirName(3,1)).Atoi() >= 4 && dirName(5,2) == "13" && VolumeMapBCap->GetNbinsY() >= 58 ){ xAxis = dirName(0,1) + dirName(4,1) + returnString( TString(dirName(3,1)).Atoi() + 1 ); + } + //BML1[AC]14-->BML4[AC]13 + if( dirName(0,3) == "BML" && TString(dirName(3,1)).Atoi() >= 4 && dirName(5,2) == "13" && VolumeMapBCap->GetNbinsY() >= 58 ){ + xAxis = dirName(0,1) + dirName(4,1) + returnString( 4 ); + } double tubeLength = 4.9615; // double maxTubeLengthBarrel = 4961.5; // just FYI // double maxTubeLengthEndcap = 5941.5; // just FYI @@ -1416,9 +1423,9 @@ namespace dqutils { if(dir_Overview){ dir_Overview->cd(); - sumt0->SetAxisRange(300,1000,"y"); + sumt0->SetAxisRange(0,300,"y"); sumtdrift->SetAxisRange(0,1200,"y"); - sumtmax->SetAxisRange(500,2200,"y"); + sumtmax->SetAxisRange(0,1500,"y"); MDTFinalizeWriteTH1FChar(sumt0); MDTFinalizeWriteTH1FChar(sumtdrift); MDTFinalizeWriteTH1FChar(sumtmax); @@ -1743,14 +1750,14 @@ namespace dqutils { t0 = tmax = 0; t0err = tmaxerr = 0; double up = h->GetBinCenter(h->GetMaximumBin()+1); - if( up > 1200 ) up = 1000; + if( up > 200 ) up = 200; double down = up + 650; - if( up < 300 ) up = 300; + if( up < 50 ) up = 50; double parESD0 = h->GetBinContent(h->GetMinimumBin()); double parESD1 = up; double parESD2 = 20; double parESD3 = h->GetBinContent(h->GetMaximumBin()) - h->GetBinContent(h->GetMinimumBin()); - TF1 func1("func1", &fittzero,(Double_t)(up-300),(Double_t)(up), 4); + TF1 func1("func1", &fittzero,(Double_t)(0.),(Double_t)(up), 4); func1.SetParameters(parESD0, parESD1, parESD2, parESD3); func1.SetLineColor(kBlue+2); if(h->GetEntries()>100){ diff --git a/DataQuality/DataQualityUtils/src/MonitoringFile_MuonTrackPostProcess.cxx b/DataQuality/DataQualityUtils/src/MonitoringFile_MuonTrackPostProcess.cxx new file mode 100644 index 00000000000..8dd541c89cd --- /dev/null +++ b/DataQuality/DataQualityUtils/src/MonitoringFile_MuonTrackPostProcess.cxx @@ -0,0 +1,272 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + + +/////////////////////////////////////////////////////////////////////////////////// +// +//Post processing algorithm for Muon Track Physics Monitoring +// +/////////////////////////////////////////////////////////////////////////////////// + +#include "DataQualityUtils/MonitoringFile.h" + +#include <iostream> +#include <algorithm> +#include <fstream> +#include <cmath> +#include <cstdlib> +#include <sstream> +#include <stdio.h> +#include <map> +#include <iomanip> +#include <set> + +#include "TH1F.h" +#include "TH2F.h" +#include "TFile.h" +#include "TClass.h" +#include "TKey.h" +#include "TMath.h" +#include "TF1.h" +#include "TTree.h" +#include "TBranch.h" +#include "TList.h" +#include "TProfile.h" +#include "TMinuit.h" + +void TwoDto2D_Eff(TH2 * Numerator, TH2 * Denominator, TH2 * Efficiency){ + //the input histograms must have the same dimension! + if (Numerator == NULL || Denominator == NULL || Efficiency == NULL) {return;} + // if(rebin2d){ + // Numerator->Rebin2D();//here change the default binnning of eta-phi + // Efficiency->Rebin2D();//here change the default binnning of eta-phi + // } + //then check the dimensions + int n_xbins = Numerator->GetNbinsX(); + if (Denominator->GetNbinsX() != n_xbins|| Efficiency->GetNbinsX() != n_xbins) {return;} + int n_ybins = Numerator->GetNbinsY(); + if (Denominator->GetNbinsY() != n_ybins|| Efficiency->GetNbinsY() != n_ybins) {return;} + + //after protection + for(int bin_itrX = 1; bin_itrX < Efficiency->GetNbinsX() + 1; bin_itrX++){ + for(int bin_itrY = 1; bin_itrY < Efficiency->GetNbinsY() + 1; bin_itrY++){ + if (Denominator->GetBinContent(bin_itrX, bin_itrY) == 0) continue; + Efficiency->SetBinContent(bin_itrX, bin_itrY, + Numerator->GetBinContent(bin_itrX, bin_itrY)/Denominator->GetBinContent(bin_itrX, bin_itrY)); + } + } + Efficiency->Write("",TObject::kOverwrite); + return; +} + +void TwoDto1D_Mean(TH2 * m_parent, TH1 * m_child, int rebinning = 2){ + //the input histograms must have the same dimension! + if (m_parent == NULL || m_child == NULL ) {return;} + if (m_parent->GetNbinsX() != m_child->GetNbinsX()){return;} + //after protection + for(int bin_itrX = 1; bin_itrX < m_parent->GetNbinsX() + 1; bin_itrX++){ + double parent_event = 0; + double parent_sum = 0; + for(int bin_itrY = 1; bin_itrY < m_parent->GetNbinsY() + 1; bin_itrY++){ + parent_event += m_parent->GetBinContent(bin_itrX, bin_itrY); + parent_sum += m_parent->GetBinContent(bin_itrX, bin_itrY) * m_parent->GetYaxis()->GetBinCenter(bin_itrY); + } + if (parent_event == 0){continue;} + m_child->SetBinContent(bin_itrX, parent_sum/parent_event); + } + TString sHistTitle = m_child->GetTitle(); + m_child->Rebin(rebinning); + m_child->SetTitle(sHistTitle + " per event"); + m_child->Write("",TObject::kOverwrite); + return; +} + +void TwoDto1D_Sum(TH2 * m_parent, TH1 * m_child, int rebinning = 2){ + //the input histograms must have the same dimension! + if (m_parent == NULL || m_child == NULL ) {return;} + if (m_parent->GetNbinsX() != m_child->GetNbinsX()){return;} + //after protection + for(int bin_itrX = 1; bin_itrX < m_parent->GetNbinsX() + 1; bin_itrX++){ + double parent_sum = 0; + for(int bin_itrY = 1; bin_itrY < m_parent->GetNbinsY() + 1; bin_itrY++){ + parent_sum += m_parent->GetBinContent(bin_itrX, bin_itrY) * m_parent->GetYaxis()->GetBinCenter(bin_itrY); + } + if(parent_sum == 0){continue;} + m_child->SetBinContent(bin_itrX, parent_sum); + } + m_child->Rebin(rebinning); + m_child->Write("",TObject::kOverwrite); + return; +} + +void SetMassInfo(int iBin, TH1* InputHist, TH1* OutMean, TH1* OutSigma){ + if (InputHist == NULL || OutMean == NULL || OutSigma == NULL) {return;} + OutMean-> SetBinContent(iBin, InputHist->GetMean(1)); + OutMean-> SetBinError( iBin, InputHist->GetMeanError(1)); + OutSigma->SetBinContent(iBin, InputHist->GetRMS(1)); + return; +} + +namespace dqutils { + + //main function + void MonitoringFile::MuonTrackPostProcess( std::string inFilename, bool isIncremental){ + if (isIncremental) {return;} + MonitoringFile::MuonTrack_Main( inFilename , ""); + MonitoringFile::MuonTrack_Main( inFilename, "NoTrig/"); + return; + } + + //subfunctions + void MonitoringFile::MuonTrack_Main(std::string inFilename, TString dirname){ + TString plotdirname = dirname;//set the plottting dir anme + plotdirname.ReplaceAll("/", "_");//name clean + dirname = "MuonPhysics/" + dirname;//give it the full path + TFile* f = TFile::Open(inFilename.c_str(),"UPDATE"); + + if (f == 0) { + std::cerr << "MuonTrackMonitoring(): " << "Input file not opened \n"; + return; + } + if(f->GetSize() < 1000.) { + std::cerr << "MuonTrackMonitoring(): " << "Input file empty \n"; + return; + } + // get run directory name + //Seemingly unnecessary lines are necessary + TIter nextcd0(gDirectory->GetListOfKeys()); + TKey *key0 = (TKey*)nextcd0(); + if (key0 == 0) return; + TDirectory *dir0= dynamic_cast<TDirectory*> (key0->ReadObj()); + if (dir0 == 0) return; + dir0->cd(); + TString runNumber = dir0->GetName(); + TString motherDir = runNumber + "/" + dirname; + ///finish getting basci information + + //Do the segment part + TString mDir = motherDir + "Segments/"; + if (! f->cd(mDir)) return; + TIter nextcd1(gDirectory->GetListOfKeys()); + while(TKey* key1 = dynamic_cast<TKey*>(nextcd1())) { + //While in the segments + TString recalg_path = key1->GetName(); + TString recalg_fullStr = mDir + key1->GetName(); + TDirectory* dir1 = f->GetDirectory(recalg_fullStr); + if(!dir1) continue; + dir1->cd(); + + // Divide the efficiency histograms + TH2F* m_EffNumerator = (TH2F*)dir1->Get(Form("%sSegments_%s_eff_chamberIndex_perSector_numerator", plotdirname.Data(), recalg_path.Data())); + TH2F* m_EffDenominator = (TH2F*)dir1->Get(Form("%sSegments_%s_eff_chamberIndex_perSector_denominator", plotdirname.Data(), recalg_path.Data())); + TH2F* m_Efficiency = (TH2F*)dir1->Get(Form("%sSegments_%s_eff_chamberIndex_perSector", plotdirname.Data(), recalg_path.Data())); + + TwoDto2D_Eff(m_EffNumerator, m_EffDenominator, m_Efficiency); + }//ends different subfolder for segment efficiency + + //Do the muon part + TString mDir_muons = motherDir + "Muons/"; + if (! f->cd(mDir_muons)) return; + TIter nextcd_muons(gDirectory->GetListOfKeys()); + while(TKey* key1 = dynamic_cast<TKey*>(nextcd_muons())){ + //While in the segments + TString recalg_path = key1->GetName(); + TString recalg_fullStr = mDir_muons + key1->GetName(); + TDirectory* dir1 = f->GetDirectory(recalg_fullStr); + if(!dir1) continue; + dir1->cd(); + + TString muonqualstr[4] = {"Tight", "Medium", "Loose", "Veryloose"}; + // Divide the efficiency histograms + TH2F* m_EffDenominator = (TH2F*)dir1->Get(Form("%sMuons_%s_eta_phi", plotdirname.Data(), recalg_path.Data())); + //m_EffDenominator->Rebin2D();//here change the default binnning of eta-phi + for (int i = 0; i < 4; i++){ + TH2F* m_EffNumerator = (TH2F*)dir1->Get(Form("%sMuons_%s_%s_eta_phi", plotdirname.Data(), recalg_path.Data(), muonqualstr[i].Data())); + TH2F* m_Efficiency = (TH2F*)dir1->Get(Form("%sMuons_%s_%s_eff", plotdirname.Data(), recalg_path.Data(), muonqualstr[i].Data())); + TwoDto2D_Eff(m_EffNumerator, m_EffDenominator, m_Efficiency);//here change the default binnning of eta-phi + } + }//ends different subfolder for muon efficiency + + + //Do the luminoisty part + TString mDir_lb = motherDir + "Overview/"; + if (! f->cd(mDir_lb)) return; + TIter nextcd_lb(gDirectory->GetListOfKeys()); + while(TKey* key1 = dynamic_cast<TKey*>(nextcd_lb())){ + //While in the segments + TString recalg_path = key1->GetName(); + TString recalg_fullStr = mDir_lb + key1->GetName(); + TDirectory* dir1 = f->GetDirectory(recalg_fullStr); + if(!dir1) continue; + dir1->cd(); + + TString montype[3] = {"Segment", "MuonTrack", "Muon"}; + // Divide the efficiency histograms + for (int i = 0; i < 3; i++){ + TH2F* m_parent_lb = (TH2F*)dir1->Get(Form("%sOverview_%s_n%s_LB_2D", plotdirname.Data(), recalg_path.Data(), montype[i].Data())); + TH1F* m_child_lb = (TH1F*)dir1->Get(Form("%sOverview_%s_n%s_LB", plotdirname.Data(), recalg_path.Data(), montype[i].Data())); + TH2F* m_parent_inst = (TH2F*)dir1->Get(Form("%sOverview_%s_n%s_Inst_2D", plotdirname.Data(), recalg_path.Data(), montype[i].Data())); + TH1F* m_child_inst = (TH1F*)dir1->Get(Form("%sOverview_%s_n%s_Inst", plotdirname.Data(), recalg_path.Data(), montype[i].Data())); + TH2F* m_parent_intlumi = (TH2F*)dir1->Get(Form("%sOverview_%s_n%s_IntLumi_2D", plotdirname.Data(), recalg_path.Data(), montype[i].Data())); + TH1F* m_child_intlumi = (TH1F*)dir1->Get(Form("%sOverview_%s_n%s_IntLumi", plotdirname.Data(), recalg_path.Data(), montype[i].Data())); + TwoDto1D_Mean(m_parent_lb, m_child_lb, 5); + TwoDto1D_Mean(m_parent_inst, m_child_inst); + TwoDto1D_Mean(m_parent_intlumi, m_child_intlumi); + } + TString resonance[2] = {"Z", "Jpsi"}; + // Divide the efficiency histograms + for (int i = 0; i < 2; i++){ + TH2F* m_parent_lb = (TH2F*)dir1->Get(Form("%sOverview_%s_n%s_LB_2D", plotdirname.Data(), recalg_path.Data(), resonance[i].Data())); + TH1F* m_child_lb = (TH1F*)dir1->Get(Form("%sOverview_%s_n%s_LB", plotdirname.Data(), recalg_path.Data(), resonance[i].Data())); + TH2F* m_parent_inst = (TH2F*)dir1->Get(Form("%sOverview_%s_n%s_Inst_2D", plotdirname.Data(), recalg_path.Data(), resonance[i].Data())); + TH1F* m_child_inst = (TH1F*)dir1->Get(Form("%sOverview_%s_n%s_Inst", plotdirname.Data(), recalg_path.Data(), resonance[i].Data())); + TH2F* m_parent_intlumi = (TH2F*)dir1->Get(Form("%sOverview_%s_n%s_IntLumi_2D", plotdirname.Data(), recalg_path.Data(), resonance[i].Data())); + TH1F* m_child_intlumi = (TH1F*)dir1->Get(Form("%sOverview_%s_n%s_IntLumi", plotdirname.Data(), recalg_path.Data(), resonance[i].Data())); + TwoDto1D_Sum(m_parent_lb, m_child_lb, 5); + TwoDto1D_Sum(m_parent_inst, m_child_inst); + TwoDto1D_Sum(m_parent_intlumi, m_child_intlumi); + } + }//ends different subfolder for luminosity + + + //Do the muon part; only for the main directory! + if (!dirname.Contains("NoTrig")){ + //std::cout << "get to trackphys " << std::endl; + TString mDir_phys = motherDir + "MuonTrkPhys/"; + if (! f->cd(mDir_phys)) return; + TIter nextcd_phys(gDirectory->GetListOfKeys()); + while(TKey* key1 = dynamic_cast<TKey*>(nextcd_phys())){ + //While in the segments + TString recalg_path = key1->GetName(); + TString recalg_fullStr = mDir_phys + key1->GetName(); + TDirectory* dir1 = f->GetDirectory(recalg_fullStr); + if(!dir1) continue; + dir1->cd(); + + TH1* m_Mass_Mean = (TH1F*)dir1->Get(Form("m_%s_M_Mean", recalg_path.Data())); + TH1* m_Mass_Sigma = (TH1F*)dir1->Get(Form("m_%s_M_Sigma", recalg_path.Data())); + // Get each of the mass histograms + TString det_region[4] = {"EC", "BC", "BA", "EA"}; + for (int i = 0; i < 4; i++){ + for(int j = 0; j< 4; j++){ + TH1* m_Mass_region = (TH1F*)dir1->Get(Form("m_%s_M_%s_%s", recalg_path.Data(), + det_region[i].Data(), det_region[j].Data())); + //std::cout << " bin " << i * 4 + (j + 1) << " content " << det_region[i] << " " << det_region[j] << std::endl; + SetMassInfo(i * 4 + (j + 1), m_Mass_region, m_Mass_Mean, m_Mass_Sigma); + } + } + if (m_Mass_Mean != NULL) m_Mass_Mean->Write("",TObject::kOverwrite); + if (m_Mass_Sigma != NULL) m_Mass_Sigma->Write("",TObject::kOverwrite); + } + }//ends different subfolder for muon efficiency + + f->Close(); + delete f; + return; + } //ends function + + + +} //namespace diff --git a/DataQuality/DataQualityUtils/src/MonitoringFile_PixelPostProcess.cxx b/DataQuality/DataQualityUtils/src/MonitoringFile_PixelPostProcess.cxx new file mode 100644 index 00000000000..8ffafc0cb1d --- /dev/null +++ b/DataQuality/DataQualityUtils/src/MonitoringFile_PixelPostProcess.cxx @@ -0,0 +1,181 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +///////////////////////////////////////////////////////////////////// +//Methods to process Pixel histograms after merging. +//Author: Masaki ENDO (masaki.endo@cern.ch) +//Date: Aug 2012 +///////////////////////////////////////////////////////////////////// + +#include "DataQualityUtils/MonitoringFile.h" + +#include <iostream> +#include <iomanip> +#include <algorithm> +#include <fstream> +#include <cmath> +#include <cstdlib> +#include <sstream> +#include <vector> +#include <utility> +#include <map> +#include <string> + +#include "TH1F.h" +#include "TH2F.h" +#include "TFile.h" +#include "TClass.h" +#include "TKey.h" +#include "TMath.h" +#include "TF1.h" +#include "TTree.h" +#include "TBranch.h" + + +namespace dqutils { + + static const bool rno_debug = false; + + void + MonitoringFile::PixelPostProcess( std::string inFilename, bool /* isIncremental */ ) + { + if (rno_debug) std::cout << "Start Pixel post-processing" <<std::endl; + + TFile *infile = TFile::Open(inFilename.c_str(),"UPDATE"); + if(infile==0 || ! infile->IsOpen()){ + std::cerr << "--> PixelPostProcess: Input file not opened" <<std::endl; + return; + } + if(infile->IsZombie()){ + std::cerr << "--> PixelPostProcess: Input file " << inFilename << " cannot be opened" <<std::endl; + return; + } + if(infile->GetSize()<1000){ + std::cerr << "--> PixelPostProcess: Input file empty " <<std::endl; + return; + } + + //start postprocessing + + TIter next_run(infile->GetListOfKeys()); + TKey *key_run(0); + key_run = (TKey*)next_run(); + TDirectory *dir0 = dynamic_cast<TDirectory*> (key_run->ReadObj()); + if (!dir0) return; // should never fail + dir0->cd(); + + TString run_dir; + int times = 1; + while (times--) { // just once + run_dir = dir0->GetName(); + + TString rno_dir = run_dir + "/Pixel/Hits/"; + TDirectory *dir = infile->GetDirectory(rno_dir); + if(!dir){ + std::cerr << "--> PixelPostProcess: directory " << rno_dir << " not found " <<std::endl; + return; + } + + TString clus_dir = run_dir + "/Pixel/Clusters/"; + TDirectory *clusdir = infile->GetDirectory(clus_dir); + if(!clusdir){ + std::cerr << "--> PixelPostProcess: directory " << clus_dir << " not found " <<std::endl; + return; + } + + TString err_dir = run_dir + "/Pixel/Errors/"; + TDirectory *errdir = infile->GetDirectory(err_dir); + if(!errdir){ + std::cerr << "--> PixelPostProcess: directory " << err_dir << " not found " <<std::endl; + return; + } + + TString norm_histName = rno_dir + "num_hits"; + TH1F *h_norm = (TH1F*)infile->Get(norm_histName); + if(!h_norm){ + std::cerr << "--> PixelPostProcess: could not find normalisation histogram " << norm_histName << std::endl; + return; + } + + const static int nlayer = 6; + float nevents = h_norm->Integral(); + TString layerName[nlayer] = {"IBL", "B0", "B1", "B2", "ECA", "ECC"}; + float npixel[nlayer] = {26880, 46080, 46080, 46080, 46080, 46080}; + + const static int nerror = 5; + TString errorName[nerror] = {"OpticalErrors_", "SEUErrors_", "SyncErrors_", "TimeoutErrors_", "TruncationErrors_"}; + + TH2F *h_occ[nlayer]; + TH2F *h_occ_new[nlayer]; + TH2F *h_clus[nlayer]; + TH2F *h_clus_new[nlayer]; + TH2F *h_err[nlayer][nerror]; + TH2F *h_err_new[nlayer][nerror]; + + for( int i=0; i<nlayer; i++){ + /// initialize + h_occ[i] = 0; h_occ_new[i] = 0; + h_clus[i] = 0; h_clus_new[i] = 0; + /// for hit occupancy + /// get histo + TString keyname = "Occupancy_"; + TString histName = rno_dir + keyname + layerName[i]; + h_occ[i] = (TH2F*)infile->Get(histName); + /// normalize + if( h_occ[i] ){ + TString tmpname = keyname + layerName[i] + "_byPostProcess"; + h_occ_new[i] = (TH2F*)h_occ[i]->Clone( tmpname ); + h_occ_new[i]->Scale( 1.0/(nevents*npixel[i]) ); + } + /// for cluster occupancy + /// get histo + keyname = "Cluster_Occupancy_"; + histName = clus_dir + keyname + layerName[i]; + h_clus[i] = (TH2F*)infile->Get(histName); + /// normalize + if( h_clus[i] ){ + TString tmpname = keyname + layerName[i] + "_byPostProcess"; + h_clus_new[i] = (TH2F*)h_clus[i]->Clone( tmpname ); + h_clus_new[i]->Scale( 1.0/nevents ); + } + /// for error map + for( int j=0; j<nerror; j++){ + /// initialize + h_err[i][j] = 0; h_err_new[i][j] = 0; + /// get histo + keyname = errorName[j]; + histName = err_dir + keyname + layerName[i]; + h_err[i][j] = (TH2F*)infile->Get(histName); + /// normalize + if( h_err[i][j] ){ + TString tmpname = keyname + layerName[i] + "_byPostProcess"; + h_err_new[i][j] = (TH2F*)h_err[i][j]->Clone( tmpname ); + h_err_new[i][j]->Scale( 1.0/nevents ); + } + } + } + + dir->cd(); + for( int i=0; i<nlayer; i++){ + if( h_occ_new[i] ) h_occ_new[i]->Write(); + } + + clusdir->cd(); + for( int i=0; i<nlayer; i++){ + if( h_clus_new[i] ) h_clus_new[i]->Write(); + } + + errdir->cd(); + for( int i=0; i<nlayer; i++){ + for( int j=0; j<nerror; j++){ + if( h_err_new[i][j] ) h_err_new[i][j]->Write(); + } + } + + infile->Write(); + + }//while + } + +}//namespace diff --git a/DataQuality/DataQualityUtils/src/MonitoringFile_TGCPostProcess.cxx b/DataQuality/DataQualityUtils/src/MonitoringFile_TGCPostProcess.cxx index 5045643f1ba..22cceaf71c4 100644 --- a/DataQuality/DataQualityUtils/src/MonitoringFile_TGCPostProcess.cxx +++ b/DataQuality/DataQualityUtils/src/MonitoringFile_TGCPostProcess.cxx @@ -224,11 +224,10 @@ namespace dqutils { for(int binx=1; binx<=nbinx; binx++){ for(int biny=1; biny<=nbiny; biny++){ - if( ws==1 && binx>=6 && binx<=10 ) continue;//skip strip for layer2 - if( ( binx==5 || binx==10 || binx==15 || - binx==21 || binx==27 || binx==33 || binx>=39 ) && + if( ws==1 && (binx==2||binx==9||binx==16||binx==23||binx==34) ) continue;//skip strip for layer2 + if( ( binx>=33 && binx<=43 ) && biny%2 == 0 )continue;// skip phi1,3 for forward region - if( ( binx ==40 || binx==42 ) && + if( ( binx ==40 || binx==41 ) && ( biny ==19 || biny==35 || biny==43 ) ) continue;//skip phi9,17,21 for EI double num = hprof->GetBinContent(binx,biny); @@ -484,11 +483,16 @@ namespace dqutils { for(int binx=1; binx<=nbinx; binx++){ for(int biny=1; biny<=nbiny; biny++){ - if( ( binx==5 || binx==10 || binx==15 || - binx==21 || binx==27 || binx==33 || binx>=39 ) && + //if( ( binx==5 || binx==10 || binx==15 || + // binx==21 || binx==27 || binx==33 || binx>=39 ) && + // biny%2 == 0 )continue;// skip phi1,3 for forward region + //if( ( binx ==40 || binx==42 ) && + // ( biny ==18 || biny==34 || biny==42 ) ) continue;//skip phi9,17,21 for EI + if( ( binx>=33 && binx<=43 ) && biny%2 == 0 )continue;// skip phi1,3 for forward region - if( ( binx ==40 || binx==42 ) && - ( biny ==18 || biny==34 || biny==42 ) ) continue;//skip phi9,17,21 for EI + if( ( binx ==40 || binx==41 ) && + ( biny ==19 || biny==35 || biny==43 ) ) continue;//skip phi9,17,21 for EI + double eff = heff->GetBinContent(binx,biny); double denom = 1; @@ -946,15 +950,28 @@ namespace dqutils { int layer=0; int eta = etac; int st =0; - if ( etac <= 4 ){ layer = 0; eta = 4 - etac; st = 42;} - else if ( etac <= 9 ){ layer = 1; eta = 9 - etac; st = 42;} - else if ( etac <= 14 ){ layer = 2; eta = 14 - etac; st = 42;} - else if ( etac <= 20 ){ layer = 3; eta = 20 - etac; st = 44;} - else if ( etac <= 26 ){ layer = 4; eta = 26 - etac; st = 44;} - else if ( etac <= 32 ){ layer = 5; eta = 32 - etac; st = 46;} - else if ( etac <= 38 ){ layer = 6; eta = 38 - etac; st = 46;} - else if ( etac <= 40 ){ layer = 7; eta = 40 - etac; st = 48;} - else if ( etac <= 42 ){ layer = 8; eta = 42 - etac; st = 48;} +// if ( etac <= 4 ){ layer = 0; eta = 4 - etac; st = 42;} +// else if ( etac <= 9 ){ layer = 1; eta = 9 - etac; st = 42;} +// else if ( etac <= 14 ){ layer = 2; eta = 14 - etac; st = 42;} +// else if ( etac <= 20 ){ layer = 3; eta = 20 - etac; st = 44;} +// else if ( etac <= 26 ){ layer = 4; eta = 26 - etac; st = 44;} +// else if ( etac <= 32 ){ layer = 5; eta = 32 - etac; st = 46;} +// else if ( etac <= 38 ){ layer = 6; eta = 38 - etac; st = 46;} +// else if ( etac <= 40 ){ layer = 7; eta = 40 - etac; st = 48;} +// else if ( etac <= 42 ){ layer = 8; eta = 42 - etac; st = 48;} + + int binx = etac+1; + if( binx%7>=1 && binx%7<=3 && binx<=28) {layer = (binx-1)%7; eta=4-(binx-1)/7; st = 42;} + else if( binx%7>=4 && binx%7<=5 && binx<=28) {layer = (binx-1)%7; eta=5-(binx-1)/7; st = 44;} + else if( (binx-1)%7>=5 && binx<=28) {layer = (binx-1)%7; eta=5-(binx-1)/7; st = 46;} + else if( binx>28 && binx<=30) {layer = binx-28+3-1; eta=1; st = 44; } + else if( binx>30 && binx<=32) {layer = binx-28+3-1; eta=1; st = 46; } + else if( binx>32 && binx<=35) {layer = binx-32-1; eta=0; st = 42; } + else if( binx>35 && binx<=37) {layer = binx-32-1; eta=0; st = 44; } + else if( binx>37 && binx<=39) {layer = binx-32-1; eta=0; st = 46; } + else if( binx>39 && binx<=41) {layer = binx-32-1; eta=1; st = 48; } + else if( binx>41 && binx<=43) {layer = binx-34-1; eta=0; st = 48; } + if( eta == 0 )st-=1; -- GitLab