CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
mps_monitormerge.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import os
4 import subprocess
5 import argparse
6 import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass as mpslib
7 
8 # setup argument parser
9 parser = argparse.ArgumentParser(description='Merge millePedeMonitor-root-files from eos, that are from the same dataset.',
11 # positional argument: config file
12 parser.add_argument('eosDir',
13  action='store',
14  help = 'path of the eos directory')
15 # parse argument
16 args = parser.parse_args()
17 eosDir = args.eosDir
18 
19 # read mps.db
20 lib = mpslib.jobdatabase()
21 lib.read_db()
22 for i in xrange(lib.nJobs):
23  print lib.JOBSP3[i]
24 
25 # count how much jobs there are of each dataset
26 occurences = []
27 items = []
28 for i in xrange(lib.nJobs):
29  if lib.JOBSP3[i] not in items:
30  items.append(lib.JOBSP3[i])
31 
32 for i in xrange(len(items)):
33  occurences.append(lib.JOBSP3.count(items[i]))
34 
35 # copy files from eos and combine root-files of each dataset with "hadd"
36 eos = '/afs/cern.ch/project/eos/installation/cms/bin/eos.select'
37 counter = 0
38 for i in xrange(len(items)):
39  command = 'hadd '
40  command += 'monitormerge_'+items[i]+'.root '
41  for j in xrange(occurences[i]):
42  os.system(eos+' cp /eos/cms'+eosDir+'/millePedeMonitor%03d.root .' % (counter+j+1))
43  command += 'millePedeMonitor%03d.root ' % (counter+j+1)
44  os.system(command)
45  for j in xrange(occurences[i]):
46  os.system('rm millePedeMonitor%03d.root' % (counter+j+1))
47  counter += occurences[i]
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62