ATLAS Offline Software
AtlRunQuery.py
Go to the documentation of this file.
1 #!/bin/env python
2 #
3 # ----------------------------------------------------------------
4 # Script : AtlRunQuery.py
5 # Project: AtlRunQuery
6 # Purpose: Main
7 # Authors: Andreas Hoecker (CERN), Joerg Stelzer (DESY)
8 # Created: Nov 13, 2008
9 # ----------------------------------------------------------------
10 #
11 
12 import sys, getopt, os
13 
14 def main():
15  arguments = sys.argv
16 
17  if len(arguments) <= 1:
18  print('No query argument given')
19  return 1
20 
21  fileindex = None
22 
23  if arguments[1] == 'fileindex':
24  installpath = '/'.join(os.path.dirname(__file__).split('/')[:-1])
25  fileindex = arguments[2]
26  datapath = '/data/arq_%s/arq_%s' % (fileindex[:6],fileindex)
27  #queryfile = '%s/%s/query.txt' % (installpath,datapath)
28  queryfile = '%s/query.txt' % datapath
29  fh = open(queryfile,"r")
30  origQuery = fh.readline().strip()
31  fh.close()
32  arguments[1:] = origQuery.split()
33  else:
34  datapath='data'
35  origQuery = ' '.join(arguments[1:])
36 
37  ignoreParser = origQuery.startswith('--')
38 
39  from CoolRunQuery.AtlRunQueryOptions import AtlRunQueryOptions
40  if ignoreParser:
41 
42  (options, args) = AtlRunQueryOptions().parse()
43  atlqueryarg = origQuery
44 
45  else:
46 
47  from CoolRunQuery.AtlRunQueryParser import ArgumentParser
48  ap = ArgumentParser()
49 
50  # special treatment of some extra tools: pileup calc, det mask decoding, help(not implemented)
51  firstarg = arguments[1].lower()
52  if firstarg in ['pileup','detmask','help']:
53  tabletemplate = '<table class="othertable" style="width:60%%"><tr><th>Query result:</th></tr><tr><td>\n%s</td></tr></table><p></p><br><p></p>'
54  if firstarg == 'pileup':
55  from CoolRunQuery.AtlRunQueryUtils import Pileup
56  body = tabletemplate % (Pileup(arguments[2:]))
57  elif firstarg == 'detmask':
58  from CoolRunQuery.utils.AtlRunQueryLookup import DecodeDetectorMask
59  body = tabletemplate % ( DecodeDetectorMask( arguments[2], isRun2=True ))
60  else:
61  body = ''
62 
63  # return a default page
64  from CoolRunQuery.html.AtlRunQueryPageMaker import PageMaker
65  from CoolRunQuery.AtlRunQueryQueryConfig import QC
66  QC.datapath = datapath
67  PageMaker.makePage(body, origQuery, removeExamples=True)
68  return 0
69 
70  atlqueryarg = arguments[0].rsplit('/',1)[-1] + " " + ap.ParseArgument( ' '.join(arguments[1:]) )
71 
72  if '--verbose' in atlqueryarg:
73  print(atlqueryarg)
74 
75  (options, args) = AtlRunQueryOptions().parse(atlqueryarg)
76 
77 
78  from CoolRunQuery.AtlRunQueryLib import AtlRunQuery
79  print("Data path %s" % datapath)
80  AtlRunQuery(options, html="AUTO", origQuery=origQuery, datapath=datapath, parsedstring=atlqueryarg) # html can be "YES", "NO", "AUTO"
81  return 0
82 
83 if __name__ == '__main__':
84  #import cProfile
85  #cProfile.run('main()','prof')
86  import sys
87  sys.exit(main())
InDet::TrkOrigin::Pileup
@ Pileup
Definition: InDetTrackTruthOriginDefs.h:20
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:1054
AtlRunQuery
Definition: AtlRunQuery.py:1
python.utils.AtlRunQueryLookup.DecodeDetectorMask
def DecodeDetectorMask(mask, lhcRun=3, smart=False)
Definition: AtlRunQueryLookup.py:420
AtlRunQuery.main
def main()
Definition: AtlRunQuery.py:14
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
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
Trk::split
@ split
Definition: LayerMaterialProperties.h:38