Changes in classes/DelphesPileUpWriter.cc [1716933:cab38f6] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
classes/DelphesPileUpWriter.cc
r1716933 rcab38f6 33 33 34 34 #include <stdio.h> 35 #include <stdint.h> 36 37 #include "classes/DelphesXDRWriter.h" 35 #include <rpc/types.h> 36 #include <rpc/xdr.h> 38 37 39 38 using namespace std; … … 48 47 fEntries(0), fEntrySize(0), fOffset(0), 49 48 fPileUpFile(0), fIndex(0), fBuffer(0), 50 fOutput Writer(0), fIndexWriter(0), fBufferWriter(0)49 fOutputXDR(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 fOutputWriter = new DelphesXDRWriter; 57 fIndexWriter = new DelphesXDRWriter; 58 fBufferWriter = new DelphesXDRWriter; 59 60 fIndexWriter->SetBuffer(fIndex); 61 fBufferWriter->SetBuffer(fBuffer); 53 fIndex = new char[kIndexSize*8]; 54 fBuffer = new char[kBufferSize*kRecordSize*4]; 55 fOutputXDR = new XDR; 56 fIndexXDR = new XDR; 57 fBufferXDR = new XDR; 58 xdrmem_create(fIndexXDR, fIndex, kIndexSize*8, XDR_ENCODE); 59 xdrmem_create(fBufferXDR, fBuffer, kBufferSize*kRecordSize*4, XDR_ENCODE); 62 60 63 61 fPileUpFile = fopen(fileName, "w+"); … … 69 67 } 70 68 71 fOutputWriter->SetFile(fPileUpFile);69 xdrstdio_create(fOutputXDR, fPileUpFile, XDR_ENCODE); 72 70 } 73 71 … … 76 74 DelphesPileUpWriter::~DelphesPileUpWriter() 77 75 { 76 xdr_destroy(fOutputXDR); 78 77 if(fPileUpFile) fclose(fPileUpFile); 79 if(fBufferWriter) delete fBufferWriter; 80 if(fIndexWriter) delete fIndexWriter; 81 if(fOutputWriter) delete fOutputWriter; 78 xdr_destroy(fBufferXDR); 79 xdr_destroy(fIndexXDR); 80 if(fBufferXDR) delete fBufferXDR; 81 if(fIndexXDR) delete fIndexXDR; 82 if(fOutputXDR) delete fOutputXDR; 82 83 if(fBuffer) delete[] fBuffer; 83 84 if(fIndex) delete[] fIndex; … … 86 87 //------------------------------------------------------------------------------ 87 88 88 void DelphesPileUpWriter::WriteParticle(int 32_tpid,89 void DelphesPileUpWriter::WriteParticle(int pid, 89 90 float x, float y, float z, float t, 90 91 float px, float py, float pz, float e) … … 95 96 } 96 97 97 fBufferWriter->WriteValue(&pid, 4);98 fBufferWriter->WriteValue(&x, 4);99 fBufferWriter->WriteValue(&y, 4);100 fBufferWriter->WriteValue(&z, 4);101 fBufferWriter->WriteValue(&t, 4);102 fBufferWriter->WriteValue(&px, 4);103 fBufferWriter->WriteValue(&py, 4);104 fBufferWriter->WriteValue(&pz, 4);105 fBufferWriter->WriteValue(&e, 4);98 xdr_int(fBufferXDR, &pid); 99 xdr_float(fBufferXDR, &x); 100 xdr_float(fBufferXDR, &y); 101 xdr_float(fBufferXDR, &z); 102 xdr_float(fBufferXDR, &t); 103 xdr_float(fBufferXDR, &px); 104 xdr_float(fBufferXDR, &py); 105 xdr_float(fBufferXDR, &pz); 106 xdr_float(fBufferXDR, &e); 106 107 107 108 ++fEntrySize; … … 117 118 } 118 119 119 fOutputWriter->WriteValue(&fEntrySize, 4);120 fOutputWriter->WriteRaw(fBuffer, fEntrySize*kRecordSize*4);120 xdr_int(fOutputXDR, &fEntrySize); 121 xdr_opaque(fOutputXDR, fBuffer, fEntrySize*kRecordSize*4); 121 122 122 fIndexWriter->WriteValue(&fOffset, 8);123 xdr_hyper(fIndexXDR, &fOffset); 123 124 fOffset += fEntrySize*kRecordSize*4 + 4; 124 125 125 fBufferWriter->SetOffset(0);126 xdr_setpos(fBufferXDR, 0); 126 127 fEntrySize = 0; 127 128 128 129 ++fEntries; 129 130 } … … 133 134 void DelphesPileUpWriter::WriteIndex() 134 135 { 135 fOutputWriter->WriteRaw(fIndex, fEntries*8);136 fOutputWriter->WriteValue(&fEntries, 8);136 xdr_opaque(fOutputXDR, fIndex, fEntries*8); 137 xdr_hyper(fOutputXDR, &fEntries); 137 138 } 138 139
Note:
See TracChangeset
for help on using the changeset viewer.