10 MAX_ARG_STRLEN = 131072
13 '''add pck files in directories idirs to a directory outdir. 14 All dirs in idirs must have the same subdirectory structure. 15 Each pickle file will be opened, and the corresponding objects added to a destination pickle in odir. 19 fileName = file.replace( idirs[0], dir )
20 pckfile = open(fileName)
21 obj = pickle.load(pckfile)
31 oFileName = file.replace( idirs[0], odir )
32 pckfile = open(oFileName,
'w')
33 pickle.dump(sum, pckfile)
34 txtFileName = oFileName.replace(
'.pck',
'.txt')
35 txtFile = open(txtFileName,
'w')
36 txtFile.write(
str(sum) )
41 def hadd(file, odir, idirs, appx=''):
42 if file.endswith(
'.pck'):
48 elif not file.endswith(
'.root'):
51 haddCmd.append( file.replace( idirs[0], odir ).
replace(
'.root', appx+
'.root') )
53 haddCmd.append( file.replace( idirs[0], dir ) )
55 cmd =
' '.
join(haddCmd)
57 if len(cmd) > MAX_ARG_STRLEN:
58 print 'Command longer than maximum unix string length; dividing into 2' 59 hadd(file, odir, idirs[:len(idirs)/2],
'1')
60 hadd(file.replace(idirs[0], idirs[len(idirs)/2]), odir, idirs[len(idirs)/2:],
'2')
62 haddCmd.append( file.replace( idirs[0], odir ).
replace(
'.root', appx+
'.root') )
63 haddCmd.append( file.replace( idirs[0], odir ).
replace(
'.root',
'1.root') )
64 haddCmd.append( file.replace( idirs[0], odir ).
replace(
'.root',
'2.root') )
65 cmd =
' '.
join(haddCmd)
66 print 'Running merge cmd:', cmd
76 cmd =
' '.
join( [
'mkdir', odir])
83 print 'ERROR: directory in the way. Maybe you ran hadd already in this directory? Remove it and try again' 86 for root,dirs,files
in os.walk( idirs[0] ):
89 dir =
'/'.
join([root, dir])
90 dir = dir.replace(idirs[0], odir)
96 hadd(
'/'.
join([root, file]), odir, idirs)
98 def haddChunks(idir, removeDestDir, cleanUp=False, odir_cmd='./'):
100 for file
in sorted(os.listdir(idir)):
101 filepath =
'/'.
join( [idir, file] )
103 if os.path.isdir(filepath):
106 prefix,num = compdir.split(
'_Chunk')
111 chunks.setdefault( prefix,
list() ).
append(filepath)
113 print 'warning: no chunk found.' 115 for comp, cchunks
in chunks.iteritems():
116 odir = odir_cmd+
'/'+
'/'.
join( [idir, comp] )
119 if os.path.isdir( odir ):
124 if os.path.isdir(
'Chunks'):
125 shutil.rmtree(chunkDir)
128 for comp, chunks
in chunks.iteritems():
130 shutil.move(chunk, chunkDir)
133 if __name__ ==
'__main__':
137 from optparse
import OptionParser
139 parser = OptionParser()
142 Find chunks in dir, and run recursive hadd to group all chunks. 144 DYJets_Chunk0/, DYJets_Chunk1/ ... -> hadd -> DYJets/ 145 WJets_Chunk0/, WJets_Chunk1/ ... -> hadd -> WJets/ 147 parser.add_option(
"-r",
"--remove", dest=
"remove",
148 default=
False,action=
"store_true",
149 help=
"remove existing destination directories.")
150 parser.add_option(
"-c",
"--clean", dest=
"clean",
151 default=
False,action=
"store_true",
152 help=
"move chunks to Chunks/ after processing.")
154 (options,args) = parser.parse_args()
157 print 'provide at most 2 directory as arguments: first the source, then the destination (optional)' 166 haddChunks(dir, options.remove, options.clean, odir)
def hadd(file, odir, idirs, appx='')
def haddPck(file, odir, idirs)
def replace(string, replacements)
def haddChunks(idir, removeDestDir, cleanUp=False, odir_cmd='./')
static std::string join(char **cmd)
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