Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • classes/DelphesPileUpWriter.cc

    r1716933 rcab38f6  
    3333
    3434#include <stdio.h>
    35 #include <stdint.h>
    36 
    37 #include "classes/DelphesXDRWriter.h"
     35#include <rpc/types.h>
     36#include <rpc/xdr.h>
    3837
    3938using namespace std;
     
    4847  fEntries(0), fEntrySize(0), fOffset(0),
    4948  fPileUpFile(0), fIndex(0), fBuffer(0),
    50   fOutputWriter(0), fIndexWriter(0), fBufferWriter(0)
     49  fOutputXDR(0), fIndexXDR(0), fBufferXDR(0)
    5150{
    5251  stringstream message;
    5352
    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);
    6260
    6361  fPileUpFile = fopen(fileName, "w+");
     
    6967  }
    7068
    71   fOutputWriter->SetFile(fPileUpFile);
     69  xdrstdio_create(fOutputXDR, fPileUpFile, XDR_ENCODE);
    7270}
    7371
     
    7674DelphesPileUpWriter::~DelphesPileUpWriter()
    7775{
     76  xdr_destroy(fOutputXDR);
    7877  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;
    8283  if(fBuffer) delete[] fBuffer;
    8384  if(fIndex) delete[] fIndex;
     
    8687//------------------------------------------------------------------------------
    8788
    88 void DelphesPileUpWriter::WriteParticle(int32_t pid,
     89void DelphesPileUpWriter::WriteParticle(int pid,
    8990  float x, float y, float z, float t,
    9091  float px, float py, float pz, float e)
     
    9596  }
    9697
    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);
    106107
    107108  ++fEntrySize;
     
    117118  }
    118119
    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);
    121122
    122   fIndexWriter->WriteValue(&fOffset, 8);
     123  xdr_hyper(fIndexXDR, &fOffset);
    123124  fOffset += fEntrySize*kRecordSize*4 + 4;
    124125
    125   fBufferWriter->SetOffset(0);
     126  xdr_setpos(fBufferXDR, 0);
    126127  fEntrySize = 0;
    127 
     128       
    128129  ++fEntries;
    129130}
     
    133134void DelphesPileUpWriter::WriteIndex()
    134135{
    135   fOutputWriter->WriteRaw(fIndex, fEntries*8);
    136   fOutputWriter->WriteValue(&fEntries, 8);
     136  xdr_opaque(fOutputXDR, fIndex, fEntries*8);
     137  xdr_hyper(fOutputXDR, &fEntries);
    137138}
    138139
Note: See TracChangeset for help on using the changeset viewer.