Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:43

0001 #!/usr/bin/env python
0002 
0003 from __future__ import print_function
0004 import sys, os, string
0005 
0006 def usage():
0007     """ Usage: fixTrue <indir> <outdir> 
0008     Reads .out files in directory <indir> to determine L1 skimming efficiency
0009     """
0010     pass
0011 
0012 
0013 def OpenFile(file_in,iodir):
0014     """  file_in -- Input file name
0015          iodir   -- 'r' readonly  'r+' read+write """
0016     try:
0017         ifile=open(file_in, iodir)
0018         # print "Opened file: ",file_in," iodir ",iodir
0019     except:
0020         print("Could not open file: ",file_in)
0021         sys.exit(1)
0022     return ifile
0023 
0024 def CloseFile(ifile):
0025     ifile.close()
0026 
0027 def FixFile(ifile,ofile):
0028     
0029     infile =OpenFile(ifile,'r')
0030     outfile=OpenFile(ofile,'w')
0031     iline=0
0032 
0033     x = infile.readline()
0034 
0035     nFailed=-1
0036     nPassed=-1
0037     
0038     while x != "":
0039         iline+=1
0040         xx=string.rstrip(x)
0041         if xx.find("doMuonCuts = [true];")>-1:
0042             xx=" doMuonCuts = [ABCD];"
0043         if xx.find("doElecCuts = [false];")>-1:
0044             xx=" doElecCuts = [EFGH];"
0045         if xx.find("20130919_QCD")>-1:
0046             xx="    versionTag = \"VERSIONTAG\";"
0047         if xx.find("dcache:/pnfs/cms/WAX/11/store/user/lpctrig/ingabu/TMDNtuples/YYYY/")>-1:
0048             xx=" paths = [\"BASENAME\"];"
0049         outfile.write(xx + "\n")
0050         x = infile.readline() 
0051 
0052     outfile.write("\n")
0053     CloseFile(infile)
0054     CloseFile(outfile)
0055 
0056     return
0057 
0058 if __name__ == '__main__':
0059 
0060     narg=len(sys.argv)
0061     if narg < 3 :
0062         print(usage.__doc__)
0063         sys.exit(1)
0064 
0065 
0066     Dir1=sys.argv[1]
0067     Dir2=sys.argv[2]
0068 
0069     filelist=os.listdir(Dir1)
0070     for thefile in filelist:
0071         print(thefile)
0072         ifile=os.path.join(Dir1,thefile)
0073         ofile=os.path.join(Dir2,thefile)
0074         print("diff ",ifile,ofile)
0075         FixFile(ifile,ofile)