Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • classes/DelphesPileUpReader.cc

    r1716933 rcab38f6  
    3333
    3434#include <stdio.h>
    35 #include <stdint.h>
    36 
    37 #include "classes/DelphesXDRReader.h"
     35#include <rpc/types.h>
     36#include <rpc/xdr.h>
    3837
    3938using namespace std;
     
    4847  fEntries(0), fEntrySize(0), fCounter(0),
    4948  fPileUpFile(0), fIndex(0), fBuffer(0),
    50   fInputReader(0), fIndexReader(0), fBufferReader(0)
     49  fInputXDR(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   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);
    6260
    6361  fPileUpFile = fopen(fileName, "r");
     
    6967  }
    7068
    71   fInputReader->SetFile(fPileUpFile);
     69  xdrstdio_create(fInputXDR, fPileUpFile, XDR_DECODE);
    7270
    7371  // read number of events
    7472  fseeko(fPileUpFile, -8, SEEK_END);
    75   fInputReader->ReadValue(&fEntries, 8);
     73  xdr_hyper(fInputXDR, &fEntries);
    7674
    7775  if(fEntries >= kIndexSize)
     
    8381  // read index of events
    8482  fseeko(fPileUpFile, -8 - 8*fEntries, SEEK_END);
    85   fInputReader->ReadRaw(fIndex, fEntries*8);
     83  xdr_opaque(fInputXDR, fIndex, fEntries*8);
    8684}
    8785
     
    9088DelphesPileUpReader::~DelphesPileUpReader()
    9189{
     90  xdr_destroy(fInputXDR);
    9291  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;
    9697  if(fBuffer) delete[] fBuffer;
    9798  if(fIndex) delete[] fIndex;
     
    100101//------------------------------------------------------------------------------
    101102
    102 bool DelphesPileUpReader::ReadParticle(int32_t &pid,
     103bool DelphesPileUpReader::ReadParticle(int &pid,
    103104  float &x, float &y, float &z, float &t,
    104105  float &px, float &py, float &pz, float &e)
     
    106107  if(fCounter >= fEntrySize) return false;
    107108
    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);
    117118
    118119  ++fCounter;
     
    123124//------------------------------------------------------------------------------
    124125
    125 bool DelphesPileUpReader::ReadEntry(int64_t entry)
     126bool DelphesPileUpReader::ReadEntry(quad_t entry)
    126127{
    127   int64_t offset;
     128  quad_t offset;
    128129
    129130  if(entry >= fEntries) return false;
    130131
    131132  // read event position
    132   fIndexReader->SetOffset(8*entry);
    133   fIndexReader->ReadValue(&offset, 8);
     133  xdr_setpos(fIndexXDR, 8*entry);
     134  xdr_hyper(fIndexXDR, &offset);
    134135
    135136  // read event
    136137  fseeko(fPileUpFile, offset, SEEK_SET);
    137   fInputReader->ReadValue(&fEntrySize, 4);
     138  xdr_int(fInputXDR, &fEntrySize);
    138139
    139140  if(fEntrySize >= kBufferSize)
     
    142143  }
    143144
    144   fInputReader->ReadRaw(fBuffer, fEntrySize*kRecordSize*4);
    145   fBufferReader->SetOffset(0);
     145  xdr_opaque(fInputXDR, fBuffer, fEntrySize*kRecordSize*4);
     146  xdr_setpos(fBufferXDR, 0);
    146147  fCounter = 0;
    147148
Note: See TracChangeset for help on using the changeset viewer.