- Timestamp:
- Aug 14, 2013, 11:07:05 PM (11 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 9394cbd
- Parents:
- 298a8fb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
readers/DelphesProMC.py
r298a8fb r154d5da 3 3 import urllib2 4 4 import cStringIO 5 import zipfile 5 import zipfile 6 6 7 7 import ROOT … … 11 11 12 12 ################################################################################ 13 # HttpFile class is written by Eli Carter (retracile) 14 # http://stackoverflow.com/a/7852229 13 15 14 16 class HttpFile(object): … … 62 64 data = ProMC_pb2.ProMCEvent() 63 65 data.ParseFromString(zip.read(name)) 64 66 65 67 event = data.event 66 68 particles = data.particles … … 68 70 element = branch.NewEntry() 69 71 70 71 # element.Number = event.Number 72 # element.ProcessID = event.Process_ID 73 # element.MPI = event.MPI 74 # element.Weight = event.Weight 75 # element.Scale = event.Scale 76 # element.AlphaQED = event.Alpha_QED 77 # element.AlphaQCD = event.Alpha_QCD 78 # element.ID1 = event.ID1 79 # element.ID2 = event.ID2 80 # element.X1 = event.X1 81 # element.X2 = event.X2 82 # element.ScalePDF = event.Scale_PDF 83 # element.PDF1 = event.PDF1 84 # element.PDF2 = event.PDF2 72 element.Number = event.Number[0] if event.Number else 0 73 element.ProcessID = event.Process_ID[0] if event.Process_ID else 0 74 element.MPI = event.MPI[0] if event.MPI else 0 75 # element.Weight = event.Weight[0] if event.Weight else 0 76 element.Scale = event.Scale[0] if event.Scale else 0 77 element.AlphaQED = event.Alpha_QED[0] if event.Alpha_QED else 0 78 element.AlphaQCD = event.Alpha_QCD[0] if event.Alpha_QCD else 0 79 element.ID1 = event.ID1[0] if event.ID1 else 0 80 element.ID2 = event.ID2[0] if event.ID2 else 0 81 element.X1 = event.X1[0] if event.X1 else 0 82 element.X2 = event.X2[0] if event.X2 else 0 83 element.ScalePDF = event.Scale_PDF[0] if event.Scale_PDF else 0 84 element.PDF1 = event.PDF1[0] if event.PDF1 else 0 85 element.PDF2 = event.PDF2[0] if event.PDF2 else 0 85 86 86 87 for i in range(len(particles.pdg_id)): … … 104 105 candidate.Status = status 105 106 106 #candidate.M1 = particles.mother1[i]107 #candidate.M2 = particles.mother2[i]108 109 #candidate.D1 = particles.daughter1[i]110 #candidate.D2 = particles.daughter2[i]107 candidate.M1 = particles.mother1[i] 108 candidate.M2 = particles.mother2[i] 109 110 candidate.D1 = particles.daughter1[i] 111 candidate.D2 = particles.daughter2[i] 111 112 112 113 candidate.Mass = mass … … 141 142 142 143 if not outputFile.IsOpen(): 143 print "** ERROR: can't open 144 print "** ERROR: can't open", sys.argv[2] 144 145 sys.exit(1) 145 146 … … 163 164 164 165 for fileName in sys.argv[3:]: 165 print "** Reading " + fileName 166 167 file = HttpFile(fileName) 166 print "** Reading", fileName 167 168 if fileName.startswith("http://"): 169 file = HttpFile(fileName) 170 else: 171 file = open(fileName) 172 168 173 zip = zipfile.ZipFile(file) 174 175 numberOfEvents = len(zip.namelist()) 176 if numberOfEvents <= 0: continue 177 178 progressBar = ROOT.ExRootProgressBar(numberOfEvents - 1) 169 179 170 180 # retrive information from the header file … … 176 186 modularDelphes.Clear() 177 187 treeWriter.Clear() 188 eventCounter = 0 178 189 for name in zip.namelist(): 179 if name.isdigit(): 180 ConvertInput(name, momentumUnit, lengthUnit, branchEvent, factory, 181 allParticleOutputArray, stableParticleOutputArray, partonOutputArray) 182 183 modularDelphes.ProcessTask() 184 185 treeWriter.Fill() 186 187 modularDelphes.Clear() 188 treeWriter.Clear() 189 190 eventCounter += 1 191 if not name.isdigit(): continue 192 193 ConvertInput(name, momentumUnit, lengthUnit, branchEvent, factory, 194 allParticleOutputArray, stableParticleOutputArray, partonOutputArray) 195 196 modularDelphes.ProcessTask() 197 198 treeWriter.Fill() 199 200 modularDelphes.Clear() 201 treeWriter.Clear() 202 progressBar.Update(eventCounter) 203 204 progressBar.Update(eventCounter, eventCounter, ROOT.kTRUE) 205 progressBar.Finish() 190 206 zip.close() 191 207
Note:
See TracChangeset
for help on using the changeset viewer.