CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
heppy_hadd Namespace Reference

Functions

def hadd
 
def haddChunks
 
def haddPck
 
def haddRec
 

Variables

string default = "store_true"
 
list dir = args[0]
 
string help = "remove existing destination directories."
 
list odir = args[1]
 
tuple parser = OptionParser()
 

Function Documentation

def heppy_hadd.hadd (   file,
  odir,
  idirs 
)

Definition at line 39 of file heppy_hadd.py.

References haddPck(), and join().

Referenced by haddRec().

39 
40 def hadd(file, odir, idirs):
41  if file.endswith('.pck'):
42  try:
43  haddPck( file, odir, idirs)
44  except ImportError:
45  pass
46  return
47  elif not file.endswith('.root'):
48  return
49  haddCmd = ['hadd']
50  haddCmd.append( file.replace( idirs[0], odir ) )
51  for dir in idirs:
52  haddCmd.append( file.replace( idirs[0], dir ) )
53  # import pdb; pdb.set_trace()
54  cmd = ' '.join(haddCmd)
55  print cmd
56  os.system(cmd)
57 
def haddPck
Definition: heppy_hadd.py:10
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def heppy_hadd.haddChunks (   idir,
  removeDestDir,
  cleanUp = False,
  odir_cmd = './' 
)

Definition at line 84 of file heppy_hadd.py.

References bitset_utilities.append(), haddRec(), join(), and list().

84 
85 def haddChunks(idir, removeDestDir, cleanUp=False, odir_cmd='./'):
86  chunks = {}
87  for file in sorted(os.listdir(idir)):
88  filepath = '/'.join( [idir, file] )
89  # print filepath
90  if os.path.isdir(filepath):
91  compdir = file
92  try:
93  prefix,num = compdir.split('_Chunk')
94  except ValueError:
95  # ok, not a chunk
96  continue
97  # print prefix, num
98  chunks.setdefault( prefix, list() ).append(filepath)
99  if len(chunks)==0:
100  print 'warning: no chunk found.'
101  return
102  for comp, cchunks in chunks.iteritems():
103  odir = odir_cmd+'/'+'/'.join( [idir, comp] )
104  print odir, cchunks
105  if removeDestDir:
106  if os.path.isdir( odir ):
107  shutil.rmtree(odir)
108  haddRec(odir, cchunks)
109  if cleanUp:
110  chunkDir = 'Chunks'
111  if os.path.isdir('Chunks'):
112  shutil.rmtree(chunkDir)
113  os.mkdir(chunkDir)
114  print chunks
115  for comp, chunks in chunks.iteritems():
116  for chunk in chunks:
117  shutil.move(chunk, chunkDir)
118 
def haddChunks
Definition: heppy_hadd.py:84
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def haddRec
Definition: heppy_hadd.py:58
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 10 of file heppy_hadd.py.

Referenced by hadd().

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

Definition at line 58 of file heppy_hadd.py.

References hadd(), and join().

Referenced by haddChunks().

58 
59 def haddRec(odir, idirs):
60  print 'adding', idirs
61  print 'to', odir
62 
63  cmd = ' '.join( ['mkdir', odir])
64  # import pdb; pdb.set_trace()
65  # os.system( cmd )
66  try:
67  os.mkdir( odir )
68  except OSError:
69  print
70  print 'ERROR: directory in the way. Maybe you ran hadd already in this directory? Remove it and try again'
71  print
72  raise
73  for root,dirs,files in os.walk( idirs[0] ):
74  # print root, dirs, files
75  for dir in dirs:
76  dir = '/'.join([root, dir])
77  dir = dir.replace(idirs[0], odir)
78  cmd = 'mkdir ' + dir
79  # print cmd
80  # os.system(cmd)
81  os.mkdir(dir)
82  for file in files:
83  hadd('/'.join([root, file]), odir, idirs)
def haddRec
Definition: heppy_hadd.py:58
static std::string join(char **cmd)
Definition: RemoteFile.cc:18

Variable Documentation

string heppy_hadd.default = "store_true"

Definition at line 134 of file heppy_hadd.py.

list heppy_hadd.dir = args[0]

Definition at line 146 of file heppy_hadd.py.

string heppy_hadd.help = "remove existing destination directories."

Definition at line 135 of file heppy_hadd.py.

string heppy_hadd.odir = args[1]

Definition at line 148 of file heppy_hadd.py.

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

tuple heppy_hadd.parser = OptionParser()

Definition at line 125 of file heppy_hadd.py.