Changeset 1716933 in git for classes/DelphesPileUpWriter.cc
- Timestamp:
- May 25, 2018, 8:56:33 AM (6 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 7d0eb75
- Parents:
- 792092a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
classes/DelphesPileUpWriter.cc
r792092a 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/DelphesXDRWriter.h" 37 38 38 39 using namespace std; … … 47 48 fEntries(0), fEntrySize(0), fOffset(0), 48 49 fPileUpFile(0), fIndex(0), fBuffer(0), 49 fOutput XDR(0), fIndexXDR(0), fBufferXDR(0)50 fOutputWriter(0), fIndexWriter(0), fBufferWriter(0) 50 51 { 51 52 stringstream message; 52 53 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); 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); 60 62 61 63 fPileUpFile = fopen(fileName, "w+"); … … 67 69 } 68 70 69 xdrstdio_create(fOutputXDR, fPileUpFile, XDR_ENCODE);71 fOutputWriter->SetFile(fPileUpFile); 70 72 } 71 73 … … 74 76 DelphesPileUpWriter::~DelphesPileUpWriter() 75 77 { 76 xdr_destroy(fOutputXDR);77 78 if(fPileUpFile) fclose(fPileUpFile); 78 xdr_destroy(fBufferXDR); 79 xdr_destroy(fIndexXDR); 80 if(fBufferXDR) delete fBufferXDR; 81 if(fIndexXDR) delete fIndexXDR; 82 if(fOutputXDR) delete fOutputXDR; 79 if(fBufferWriter) delete fBufferWriter; 80 if(fIndexWriter) delete fIndexWriter; 81 if(fOutputWriter) delete fOutputWriter; 83 82 if(fBuffer) delete[] fBuffer; 84 83 if(fIndex) delete[] fIndex; … … 87 86 //------------------------------------------------------------------------------ 88 87 89 void DelphesPileUpWriter::WriteParticle(int pid,88 void DelphesPileUpWriter::WriteParticle(int32_t pid, 90 89 float x, float y, float z, float t, 91 90 float px, float py, float pz, float e) … … 96 95 } 97 96 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);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); 107 106 108 107 ++fEntrySize; … … 118 117 } 119 118 120 xdr_int(fOutputXDR, &fEntrySize);121 xdr_opaque(fOutputXDR,fBuffer, fEntrySize*kRecordSize*4);119 fOutputWriter->WriteValue(&fEntrySize, 4); 120 fOutputWriter->WriteRaw(fBuffer, fEntrySize*kRecordSize*4); 122 121 123 xdr_hyper(fIndexXDR, &fOffset);122 fIndexWriter->WriteValue(&fOffset, 8); 124 123 fOffset += fEntrySize*kRecordSize*4 + 4; 125 124 126 xdr_setpos(fBufferXDR,0);125 fBufferWriter->SetOffset(0); 127 126 fEntrySize = 0; 128 127 129 128 ++fEntries; 130 129 } … … 134 133 void DelphesPileUpWriter::WriteIndex() 135 134 { 136 xdr_opaque(fOutputXDR,fIndex, fEntries*8);137 xdr_hyper(fOutputXDR, &fEntries);135 fOutputWriter->WriteRaw(fIndex, fEntries*8); 136 fOutputWriter->WriteValue(&fEntries, 8); 138 137 } 139 138
Note:
See TracChangeset
for help on using the changeset viewer.