ATLAS Offline Software
readTier0HIST.py
Go to the documentation of this file.
1 #!/usr/bin env python
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 # Simple script to extract the path of the HIST output of Tier0 monitoring,
5 # open it and open a TBrowser
6 # Uses the pathExtract library to extract the EOS path
7 # Options:
8 # -r RUNNUMBER, --run RUNNUMBER : Run number
9 # -s STREAM, --stream STREAM : Stream without prefix: express, CosmicCalo, Egamma...
10 # -t TAG, --tag TAG : DAQ tag: data12_8TeV, data12_calocomm...
11 # -a AMITAG, --amiTag AMITAG : First letter of AMI tag: x->express / f->bulk
12 #
13 # Author : Benjamin Trocme (LPSC Grenoble) / Summer 2012, updated in 2015
14 
15 
16 
17 import os, sys
18 import argparse
19 from six.moves import xmlrpc_client as xmlrpclib
20 
21 from DataQualityUtils import pathExtract
22 
23 from ROOT import TFile,TBrowser
24 from ROOT import gStyle
25 
26 # Main ================================================================
27 gStyle.SetPalette(1)
28 gStyle.SetOptStat("emuo")
29 
30 parser = argparse.ArgumentParser()
31 parser.add_argument('-r','--run',type=int,dest='runNumber',default='267599',help="Run number",action='store')
32 parser.add_argument('-s','--stream',dest='stream',default='express',help="Stream without prefix: express, CosmicCalo, Egamma...",action='store')
33 parser.add_argument('-t','--tag',dest='tag',default='',help="DAQ tag: data12_8TeV, data12_calocomm...By default retrieve it via atlasdqm",action='store')
34 parser.add_argument('-a','--amiTag',dest='amiTag',default='x',help="First letter of AMI tag: x->express / f->bulk",action='store')
35 parser.add_argument('-l','--lumiblock',type=int,dest='lumiblock',default='0',help="if none empty, try to get unmerged HIST files for a specific LB",action='store')
36 
37 parser.print_help()
38 
39 args = parser.parse_args()
40 
41 runNumber = args.runNumber
42 LB = args.lumiblock
43 stream = args.stream
44 if args.tag != "":
45  tag = args.tag
46 else: # Try to retrieve the data project tag via atlasdqm
47  if (not os.path.isfile("atlasdqmpass.txt")):
48  print("To retrieve the data project tag, you need to generate an atlasdqm key and store it in this directory as atlasdqmpass.txt (yourname:key)")
49  print("To generate a kay, go here : https://atlasdqm.cern.ch/dqauth/")
50  print("You can also define by hand the data project tag wit hthe option -t")
51  sys.exit()
52  passfile = open("atlasdqmpass.txt")
53  passwd = passfile.read().strip(); passfile.close()
54  passurl = 'https://%s@atlasdqm.cern.ch'%passwd
55  s = xmlrpclib.ServerProxy(passurl)
56  run_spec = {'stream': 'physics_CosmicCalo', 'proc_ver': 1,'source': 'tier0', 'low_run': runNumber, 'high_run':runNumber}
57  run_info= s.get_run_information(run_spec)
58  if '%d'%runNumber not in run_info.keys() or len(run_info['%d'%runNumber])<2:
59  print("Unable to retrieve the data project tag via atlasdqm... Please double check your atlasdqmpass.txt or define it by hand with -t option")
60  sys.exit()
61  tag = run_info['%d'%runNumber][1]
62 
63 amiTag = args.amiTag
64 
65 
66 path = []
67 
68 if args.lumiblock == 0:
69  path.append("root://eosatlas.cern.ch/%s"%(pathExtract.returnEosHistPath(args.runNumber,args.stream,args.amiTag,tag)).rstrip())
70 else:
71  allUnmerged = pathExtract.returnEosHistPathLB(runNumber,LB,LB,stream,amiTag,tag)
72  for iFile in allUnmerged:
73  path.append("root://eosatlas.cern.ch/%s"%(iFile).rstrip())
74 # path.add("root://eosatlas.cern.ch/%s"%(.rstrip())
75 
76 
77 file = []
78 for iPath in path:
79  if ("NO FILE" not in iPath):
80  print("I am opening %s"%(iPath))
81  file.append( TFile.Open(iPath))
82 
83 gStyle.SetPalette(1)
84 tb = TBrowser()
Trk::open
@ open
Definition: BinningType.h:40
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70