CMS 3D CMS Logo

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