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