Index: classes/DelphesPileUpWriter.cc
===================================================================
--- classes/DelphesPileUpWriter.cc	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ classes/DelphesPileUpWriter.cc	(revision d7d2da362406b9e37fdf238970417c94779b54b0)
@@ -1,23 +1,11 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
 
 /** \class DelphesPileUpWriter
  *
  *  Writes pile-up binary file
+ *
+ *
+ *  $Date$
+ *  $Revision$
+ *
  *
  *  \author P. Demin - UCL, Louvain-la-Neuve
@@ -27,12 +15,11 @@
 #include "classes/DelphesPileUpWriter.h"
 
+#include <stdexcept>
 #include <iostream>
 #include <sstream>
-#include <stdexcept>
 
-#include <stdint.h>
 #include <stdio.h>
-
-#include "classes/DelphesXDRWriter.h"
+#include <rpc/types.h>
+#include <rpc/xdr.h>
 
 using namespace std;
@@ -47,18 +34,17 @@
   fEntries(0), fEntrySize(0), fOffset(0),
   fPileUpFile(0), fIndex(0), fBuffer(0),
-  fOutputWriter(0), fIndexWriter(0), fBufferWriter(0)
+  fOutputXDR(0), fIndexXDR(0), fBufferXDR(0)
 {
   stringstream message;
 
-  fIndex = new uint8_t[kIndexSize * 8];
-  fBuffer = new uint8_t[kBufferSize * kRecordSize * 4];
-  fOutputWriter = new DelphesXDRWriter;
-  fIndexWriter = new DelphesXDRWriter;
-  fBufferWriter = new DelphesXDRWriter;
+  fIndex = new char[kIndexSize*8];
+  fBuffer = new char[kBufferSize*kRecordSize*4];
+  fOutputXDR = new XDR;
+  fIndexXDR = new XDR;
+  fBufferXDR = new XDR;
+  xdrmem_create(fIndexXDR, fIndex, kIndexSize*8, XDR_ENCODE);
+  xdrmem_create(fBufferXDR, fBuffer, kBufferSize*kRecordSize*4, XDR_ENCODE);
 
-  fIndexWriter->SetBuffer(fIndex);
-  fBufferWriter->SetBuffer(fBuffer);
-
-  fPileUpFile = fopen(fileName, "wb");
+  fPileUpFile = fopen(fileName, "w+");
 
   if(fPileUpFile == NULL)
@@ -68,5 +54,5 @@
   }
 
-  fOutputWriter->SetFile(fPileUpFile);
+  xdrstdio_create(fOutputXDR, fPileUpFile, XDR_ENCODE);
 }
 
@@ -75,8 +61,11 @@
 DelphesPileUpWriter::~DelphesPileUpWriter()
 {
+  xdr_destroy(fOutputXDR);
   if(fPileUpFile) fclose(fPileUpFile);
-  if(fBufferWriter) delete fBufferWriter;
-  if(fIndexWriter) delete fIndexWriter;
-  if(fOutputWriter) delete fOutputWriter;
+  xdr_destroy(fBufferXDR);
+  xdr_destroy(fIndexXDR);
+  if(fBufferXDR) delete fBufferXDR;
+  if(fIndexXDR) delete fIndexXDR;
+  if(fOutputXDR) delete fOutputXDR;
   if(fBuffer) delete[] fBuffer;
   if(fIndex) delete[] fIndex;
@@ -85,5 +74,5 @@
 //------------------------------------------------------------------------------
 
-void DelphesPileUpWriter::WriteParticle(int32_t pid,
+void DelphesPileUpWriter::WriteParticle(int pid,
   float x, float y, float z, float t,
   float px, float py, float pz, float e)
@@ -94,13 +83,13 @@
   }
 
-  fBufferWriter->WriteValue(&pid, 4);
-  fBufferWriter->WriteValue(&x, 4);
-  fBufferWriter->WriteValue(&y, 4);
-  fBufferWriter->WriteValue(&z, 4);
-  fBufferWriter->WriteValue(&t, 4);
-  fBufferWriter->WriteValue(&px, 4);
-  fBufferWriter->WriteValue(&py, 4);
-  fBufferWriter->WriteValue(&pz, 4);
-  fBufferWriter->WriteValue(&e, 4);
+  xdr_int(fBufferXDR, &pid);
+  xdr_float(fBufferXDR, &x);
+  xdr_float(fBufferXDR, &y);
+  xdr_float(fBufferXDR, &z);
+  xdr_float(fBufferXDR, &t);
+  xdr_float(fBufferXDR, &px);
+  xdr_float(fBufferXDR, &py);
+  xdr_float(fBufferXDR, &pz);
+  xdr_float(fBufferXDR, &e);
 
   ++fEntrySize;
@@ -116,13 +105,13 @@
   }
 
-  fOutputWriter->WriteValue(&fEntrySize, 4);
-  fOutputWriter->WriteRaw(fBuffer, fEntrySize * kRecordSize * 4);
+  xdr_int(fOutputXDR, &fEntrySize);
+  xdr_opaque(fOutputXDR, fBuffer, fEntrySize*kRecordSize*4);
 
-  fIndexWriter->WriteValue(&fOffset, 8);
-  fOffset += fEntrySize * kRecordSize * 4 + 4;
+  xdr_hyper(fIndexXDR, &fOffset);
+  fOffset += fEntrySize*kRecordSize*4 + 4;
 
-  fBufferWriter->SetOffset(0);
+  xdr_setpos(fBufferXDR, 0);
   fEntrySize = 0;
-
+        
   ++fEntries;
 }
@@ -132,6 +121,6 @@
 void DelphesPileUpWriter::WriteIndex()
 {
-  fOutputWriter->WriteRaw(fIndex, fEntries * 8);
-  fOutputWriter->WriteValue(&fEntries, 8);
+  xdr_opaque(fOutputXDR, fIndex, fEntries*8);
+  xdr_hyper(fOutputXDR, &fEntries);
 }
 
