Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-26 02:34:20

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