CMS 3D CMS Logo

Functions | Variables
heppy_hadd Namespace Reference

Functions

def hadd (file, odir, idirs, appx='')
 
def haddChunks (idir, removeDestDir, cleanUp=False, odir_cmd='./')
 
def haddPck (file, odir, idirs)
 
def haddRec (odir, idirs)
 

Variables

 action
 
 args
 
 default
 
 dest
 
 dir
 
 False
 
 help
 
 MAX_ARG_STRLEN
 
 odir
 
 options
 
 parser
 
 usage
 

Function Documentation

def heppy_hadd.hadd (   file,
  odir,
  idirs,
  appx = '' 
)

Definition at line 43 of file heppy_hadd.py.

References haddPck(), join(), edm.print(), and python.rootplot.root2matplotlib.replace().

Referenced by haddRec().

43 def hadd(file, odir, idirs, appx=''):
44  if file.endswith('.pck'):
45  try:
46  haddPck( file, odir, idirs)
47  except ImportError:
48  pass
49  return
50  elif not file.endswith('.root'):
51  return
52  haddCmd = ['hadd']
53  haddCmd.append( file.replace( idirs[0], odir ).replace('.root', appx+'.root') )
54  for dir in idirs:
55  haddCmd.append( file.replace( idirs[0], dir ) )
56  # import pdb; pdb.set_trace()
57  cmd = ' '.join(haddCmd)
58  print(cmd)
59  if len(cmd) > MAX_ARG_STRLEN:
60  print('Command longer than maximum unix string length; dividing into 2')
61  hadd(file, odir, idirs[:len(idirs)/2], '1')
62  hadd(file.replace(idirs[0], idirs[len(idirs)/2]), odir, idirs[len(idirs)/2:], '2')
63  haddCmd = ['hadd']
64  haddCmd.append( file.replace( idirs[0], odir ).replace('.root', appx+'.root') )
65  haddCmd.append( file.replace( idirs[0], odir ).replace('.root', '1.root') )
66  haddCmd.append( file.replace( idirs[0], odir ).replace('.root', '2.root') )
67  cmd = ' '.join(haddCmd)
68  print('Running merge cmd:', cmd)
69  os.system(cmd)
70  else:
71  os.system(cmd)
72 
73 
def hadd(file, odir, idirs, appx='')
Definition: heppy_hadd.py:43
def haddPck(file, odir, idirs)
Definition: heppy_hadd.py:14
def replace(string, replacements)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def heppy_hadd.haddChunks (   idir,
  removeDestDir,
  cleanUp = False,
  odir_cmd = './' 
)

Definition at line 100 of file heppy_hadd.py.

References mps_setup.append, haddRec(), join(), list(), and edm.print().

100 def haddChunks(idir, removeDestDir, cleanUp=False, odir_cmd='./'):
101  chunks = {}
102  for file in sorted(os.listdir(idir)):
103  filepath = '/'.join( [idir, file] )
104  # print filepath
105  if os.path.isdir(filepath):
106  compdir = file
107  try:
108  prefix,num = compdir.split('_Chunk')
109  except ValueError:
110  # ok, not a chunk
111  continue
112  # print prefix, num
113  chunks.setdefault( prefix, list() ).append(filepath)
114  if len(chunks)==0:
115  print('warning: no chunk found.')
116  return
117  for comp, cchunks in six.iteritems(chunks):
118  odir = odir_cmd+'/'+'/'.join( [idir, comp] )
119  print(odir, cchunks)
120  if removeDestDir:
121  if os.path.isdir( odir ):
122  shutil.rmtree(odir)
123  haddRec(odir, cchunks)
124  if cleanUp:
125  chunkDir = 'Chunks'
126  if os.path.isdir('Chunks'):
127  shutil.rmtree(chunkDir)
128  os.mkdir(chunkDir)
129  print(chunks)
130  for comp, chunks in six.iteritems(chunks):
131  for chunk in chunks:
132  shutil.move(chunk, chunkDir)
133 
134 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def haddRec(odir, idirs)
Definition: heppy_hadd.py:74
def haddChunks(idir, removeDestDir, cleanUp=False, odir_cmd='./')
Definition: heppy_hadd.py:100
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def heppy_hadd.haddPck (   file,
  odir,
  idirs 
)
add pck files in directories idirs to a directory outdir.
All dirs in idirs must have the same subdirectory structure.
Each pickle file will be opened, and the corresponding objects added to a destination pickle in odir.

Definition at line 14 of file heppy_hadd.py.

References str.

Referenced by hadd().

14 def haddPck(file, odir, idirs):
15  '''add pck files in directories idirs to a directory outdir.
16  All dirs in idirs must have the same subdirectory structure.
17  Each pickle file will be opened, and the corresponding objects added to a destination pickle in odir.
18  '''
19  sum = None
20  for dir in idirs:
21  fileName = file.replace( idirs[0], dir )
22  pckfile = open(fileName)
23  obj = pickle.load(pckfile)
24  if sum is None:
25  sum = obj
26  else:
27  try:
28  sum += obj
29  except TypeError:
30  # += not implemented, nevermind
31  pass
32 
33  oFileName = file.replace( idirs[0], odir )
34  pckfile = open(oFileName, 'w')
35  pickle.dump(sum, pckfile)
36  txtFileName = oFileName.replace('.pck','.txt')
37  txtFile = open(txtFileName, 'w')
38  txtFile.write( str(sum) )
39  txtFile.write( '\n' )
40  txtFile.close()
41 
42 
def haddPck(file, odir, idirs)
Definition: heppy_hadd.py:14
#define str(s)
def heppy_hadd.haddRec (   odir,
  idirs 
)

Definition at line 74 of file heppy_hadd.py.

References hadd(), join(), and edm.print().

Referenced by haddChunks().

74 def haddRec(odir, idirs):
75  print('adding', idirs)
76  print('to', odir)
77 
78  cmd = ' '.join( ['mkdir', odir])
79  # import pdb; pdb.set_trace()
80  # os.system( cmd )
81  try:
82  os.mkdir( odir )
83  except OSError:
84  print()
85  print('ERROR: directory in the way. Maybe you ran hadd already in this directory? Remove it and try again')
86  print()
87  raise
88  for root,dirs,files in os.walk( idirs[0] ):
89  # print root, dirs, files
90  for dir in dirs:
91  dir = '/'.join([root, dir])
92  dir = dir.replace(idirs[0], odir)
93  cmd = 'mkdir ' + dir
94  # print cmd
95  # os.system(cmd)
96  os.mkdir(dir)
97  for file in files:
98  hadd('/'.join([root, file]), odir, idirs)
99 
def hadd(file, odir, idirs, appx='')
Definition: heppy_hadd.py:43
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def haddRec(odir, idirs)
Definition: heppy_hadd.py:74
static std::string join(char **cmd)
Definition: RemoteFile.cc:18

Variable Documentation

heppy_hadd.action

Definition at line 150 of file heppy_hadd.py.

heppy_hadd.args

Definition at line 156 of file heppy_hadd.py.

heppy_hadd.default

Definition at line 150 of file heppy_hadd.py.

heppy_hadd.dest

Definition at line 149 of file heppy_hadd.py.

heppy_hadd.dir

Definition at line 162 of file heppy_hadd.py.

heppy_hadd.False

Definition at line 150 of file heppy_hadd.py.

heppy_hadd.help

Definition at line 151 of file heppy_hadd.py.

heppy_hadd.MAX_ARG_STRLEN

Definition at line 12 of file heppy_hadd.py.

heppy_hadd.odir

Definition at line 164 of file heppy_hadd.py.

Referenced by ClusterShape.determineShape(), and ClusterShape.processColumn().

heppy_hadd.options

Definition at line 156 of file heppy_hadd.py.

heppy_hadd.parser

Definition at line 141 of file heppy_hadd.py.

heppy_hadd.usage

Definition at line 142 of file heppy_hadd.py.