Changes in classes/DelphesPileUpReader.cc [cab38f6:1716933] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
classes/DelphesPileUpReader.cc
rcab38f6 r1716933 33 33 34 34 #include <stdio.h> 35 #include <rpc/types.h> 36 #include <rpc/xdr.h> 35 #include <stdint.h> 36 37 #include "classes/DelphesXDRReader.h" 37 38 38 39 using namespace std; … … 47 48 fEntries(0), fEntrySize(0), fCounter(0), 48 49 fPileUpFile(0), fIndex(0), fBuffer(0), 49 fInput XDR(0), fIndexXDR(0), fBufferXDR(0)50 fInputReader(0), fIndexReader(0), fBufferReader(0) 50 51 { 51 52 stringstream message; 52 53 53 fIndex = new char[kIndexSize*8]; 54 fBuffer = new char[kBufferSize*kRecordSize*4]; 55 fInputXDR = new XDR; 56 fIndexXDR = new XDR; 57 fBufferXDR = new XDR; 58 xdrmem_create(fIndexXDR, fIndex, kIndexSize*8, XDR_DECODE); 59 xdrmem_create(fBufferXDR, fBuffer, kBufferSize*kRecordSize*4, XDR_DECODE); 54 fIndex = new uint8_t[kIndexSize*8]; 55 fBuffer = new uint8_t[kBufferSize*kRecordSize*4]; 56 fInputReader = new DelphesXDRReader; 57 fIndexReader = new DelphesXDRReader; 58 fBufferReader = new DelphesXDRReader; 59 60 fIndexReader->SetBuffer(fIndex); 61 fBufferReader->SetBuffer(fBuffer); 60 62 61 63 fPileUpFile = fopen(fileName, "r"); … … 67 69 } 68 70 69 xdrstdio_create(fInputXDR, fPileUpFile, XDR_DECODE);71 fInputReader->SetFile(fPileUpFile); 70 72 71 73 // read number of events 72 74 fseeko(fPileUpFile, -8, SEEK_END); 73 xdr_hyper(fInputXDR, &fEntries);75 fInputReader->ReadValue(&fEntries, 8); 74 76 75 77 if(fEntries >= kIndexSize) … … 81 83 // read index of events 82 84 fseeko(fPileUpFile, -8 - 8*fEntries, SEEK_END); 83 xdr_opaque(fInputXDR,fIndex, fEntries*8);85 fInputReader->ReadRaw(fIndex, fEntries*8); 84 86 } 85 87 … … 88 90 DelphesPileUpReader::~DelphesPileUpReader() 89 91 { 90 xdr_destroy(fInputXDR);91 92 if(fPileUpFile) fclose(fPileUpFile); 92 xdr_destroy(fBufferXDR); 93 xdr_destroy(fIndexXDR); 94 if(fBufferXDR) delete fBufferXDR; 95 if(fIndexXDR) delete fIndexXDR; 96 if(fInputXDR) delete fInputXDR; 93 if(fBufferReader) delete fBufferReader; 94 if(fIndexReader) delete fIndexReader; 95 if(fInputReader) delete fInputReader; 97 96 if(fBuffer) delete[] fBuffer; 98 97 if(fIndex) delete[] fIndex; … … 101 100 //------------------------------------------------------------------------------ 102 101 103 bool DelphesPileUpReader::ReadParticle(int &pid,102 bool DelphesPileUpReader::ReadParticle(int32_t &pid, 104 103 float &x, float &y, float &z, float &t, 105 104 float &px, float &py, float &pz, float &e) … … 107 106 if(fCounter >= fEntrySize) return false; 108 107 109 xdr_int(fBufferXDR, &pid);110 xdr_float(fBufferXDR, &x);111 xdr_float(fBufferXDR, &y);112 xdr_float(fBufferXDR, &z);113 xdr_float(fBufferXDR, &t);114 xdr_float(fBufferXDR, &px);115 xdr_float(fBufferXDR, &py);116 xdr_float(fBufferXDR, &pz);117 xdr_float(fBufferXDR, &e);108 fBufferReader->ReadValue(&pid, 4); 109 fBufferReader->ReadValue(&x, 4); 110 fBufferReader->ReadValue(&y, 4); 111 fBufferReader->ReadValue(&z, 4); 112 fBufferReader->ReadValue(&t, 4); 113 fBufferReader->ReadValue(&px, 4); 114 fBufferReader->ReadValue(&py, 4); 115 fBufferReader->ReadValue(&pz, 4); 116 fBufferReader->ReadValue(&e, 4); 118 117 119 118 ++fCounter; … … 124 123 //------------------------------------------------------------------------------ 125 124 126 bool DelphesPileUpReader::ReadEntry( quad_t entry)125 bool DelphesPileUpReader::ReadEntry(int64_t entry) 127 126 { 128 quad_t offset;127 int64_t offset; 129 128 130 129 if(entry >= fEntries) return false; 131 130 132 131 // read event position 133 xdr_setpos(fIndexXDR,8*entry);134 xdr_hyper(fIndexXDR, &offset);132 fIndexReader->SetOffset(8*entry); 133 fIndexReader->ReadValue(&offset, 8); 135 134 136 135 // read event 137 136 fseeko(fPileUpFile, offset, SEEK_SET); 138 xdr_int(fInputXDR, &fEntrySize);137 fInputReader->ReadValue(&fEntrySize, 4); 139 138 140 139 if(fEntrySize >= kBufferSize) … … 143 142 } 144 143 145 xdr_opaque(fInputXDR,fBuffer, fEntrySize*kRecordSize*4);146 xdr_setpos(fBufferXDR,0);144 fInputReader->ReadRaw(fBuffer, fEntrySize*kRecordSize*4); 145 fBufferReader->SetOffset(0); 147 146 fCounter = 0; 148 147
Note:
See TracChangeset
for help on using the changeset viewer.