Fork me on GitHub

Changeset 1716933 in git


Ignore:
Timestamp:
May 25, 2018, 8:56:33 AM (6 years ago)
Author:
Pavel Demin <pavel-demin@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
7d0eb75
Parents:
792092a
Message:

add DelphesXDRReader and DelphesXDRWriter

Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r792092a r1716933  
    1515PcmSuf = _rdict.pcm
    1616
    17 CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl -I/usr/include/tirpc
     17CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl
    1818DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
    1919DISPLAY_LIBS = $(shell $(RC) --evelibs) -lGuiHtml $(SYSLIBS)
     
    481481tmp/classes/DelphesPileUpReader.$(ObjSuf): \
    482482        classes/DelphesPileUpReader.$(SrcSuf) \
    483         classes/DelphesPileUpReader.h
     483        classes/DelphesPileUpReader.h \
     484        classes/DelphesXDRReader.h
    484485tmp/classes/DelphesPileUpWriter.$(ObjSuf): \
    485486        classes/DelphesPileUpWriter.$(SrcSuf) \
    486         classes/DelphesPileUpWriter.h
     487        classes/DelphesPileUpWriter.h \
     488        classes/DelphesXDRWriter.h
    487489tmp/classes/DelphesSTDHEPReader.$(ObjSuf): \
    488490        classes/DelphesSTDHEPReader.$(SrcSuf) \
     
    490492        classes/DelphesClasses.h \
    491493        classes/DelphesFactory.h \
     494        classes/DelphesXDRReader.h \
    492495        external/ExRootAnalysis/ExRootTreeBranch.h
    493496tmp/classes/DelphesStream.$(ObjSuf): \
     
    497500        classes/DelphesTF2.$(SrcSuf) \
    498501        classes/DelphesTF2.h
     502tmp/classes/DelphesXDRReader.$(ObjSuf): \
     503        classes/DelphesXDRReader.$(SrcSuf) \
     504        classes/DelphesXDRReader.h
     505tmp/classes/DelphesXDRWriter.$(ObjSuf): \
     506        classes/DelphesXDRWriter.$(SrcSuf) \
     507        classes/DelphesXDRWriter.h
    499508tmp/external/ExRootAnalysis/ExRootConfReader.$(ObjSuf): \
    500509        external/ExRootAnalysis/ExRootConfReader.$(SrcSuf) \
     
    10041013        tmp/classes/DelphesStream.$(ObjSuf) \
    10051014        tmp/classes/DelphesTF2.$(ObjSuf) \
     1015        tmp/classes/DelphesXDRReader.$(ObjSuf) \
     1016        tmp/classes/DelphesXDRWriter.$(ObjSuf) \
    10061017        tmp/external/ExRootAnalysis/ExRootConfReader.$(ObjSuf) \
    10071018        tmp/external/ExRootAnalysis/ExRootFilter.$(ObjSuf) \
     
    20182029        @touch $@
    20192030
     2031classes/DelphesSTDHEPReader.h: \
     2032        classes/DelphesXDRReader.h
     2033        @touch $@
     2034
    20202035external/fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh: \
    20212036        external/fastjet/JetDefinition.hh
  • classes/DelphesPileUpReader.cc

    r792092a r1716933  
    3333
    3434#include <stdio.h>
    35 #include <rpc/types.h>
    36 #include <rpc/xdr.h>
     35#include <stdint.h>
     36
     37#include "classes/DelphesXDRReader.h"
    3738
    3839using namespace std;
     
    4748  fEntries(0), fEntrySize(0), fCounter(0),
    4849  fPileUpFile(0), fIndex(0), fBuffer(0),
    49   fInputXDR(0), fIndexXDR(0), fBufferXDR(0)
     50  fInputReader(0), fIndexReader(0), fBufferReader(0)
    5051{
    5152  stringstream message;
    5253
    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);
     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);
    6062
    6163  fPileUpFile = fopen(fileName, "r");
     
    6769  }
    6870
    69   xdrstdio_create(fInputXDR, fPileUpFile, XDR_DECODE);
     71  fInputReader->SetFile(fPileUpFile);
    7072
    7173  // read number of events
    7274  fseeko(fPileUpFile, -8, SEEK_END);
    73   xdr_hyper(fInputXDR, &fEntries);
     75  fInputReader->ReadValue(&fEntries, 8);
    7476
    7577  if(fEntries >= kIndexSize)
     
    8183  // read index of events
    8284  fseeko(fPileUpFile, -8 - 8*fEntries, SEEK_END);
    83   xdr_opaque(fInputXDR, fIndex, fEntries*8);
     85  fInputReader->ReadRaw(fIndex, fEntries*8);
    8486}
    8587
     
    8890DelphesPileUpReader::~DelphesPileUpReader()
    8991{
    90   xdr_destroy(fInputXDR);
    9192  if(fPileUpFile) fclose(fPileUpFile);
    92   xdr_destroy(fBufferXDR);
    93   xdr_destroy(fIndexXDR);
    94   if(fBufferXDR) delete fBufferXDR;
    95   if(fIndexXDR) delete fIndexXDR;
    96   if(fInputXDR) delete fInputXDR;
     93  if(fBufferReader) delete fBufferReader;
     94  if(fIndexReader) delete fIndexReader;
     95  if(fInputReader) delete fInputReader;
    9796  if(fBuffer) delete[] fBuffer;
    9897  if(fIndex) delete[] fIndex;
     
    101100//------------------------------------------------------------------------------
    102101
    103 bool DelphesPileUpReader::ReadParticle(int &pid,
     102bool DelphesPileUpReader::ReadParticle(int32_t &pid,
    104103  float &x, float &y, float &z, float &t,
    105104  float &px, float &py, float &pz, float &e)
     
    107106  if(fCounter >= fEntrySize) return false;
    108107
    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);
     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);
    118117
    119118  ++fCounter;
     
    124123//------------------------------------------------------------------------------
    125124
    126 bool DelphesPileUpReader::ReadEntry(quad_t entry)
     125bool DelphesPileUpReader::ReadEntry(int64_t entry)
    127126{
    128   quad_t offset;
     127  int64_t offset;
    129128
    130129  if(entry >= fEntries) return false;
    131130
    132131  // read event position
    133   xdr_setpos(fIndexXDR, 8*entry);
    134   xdr_hyper(fIndexXDR, &offset);
     132  fIndexReader->SetOffset(8*entry);
     133  fIndexReader->ReadValue(&offset, 8);
    135134
    136135  // read event
    137136  fseeko(fPileUpFile, offset, SEEK_SET);
    138   xdr_int(fInputXDR, &fEntrySize);
     137  fInputReader->ReadValue(&fEntrySize, 4);
    139138
    140139  if(fEntrySize >= kBufferSize)
     
    143142  }
    144143
    145   xdr_opaque(fInputXDR, fBuffer, fEntrySize*kRecordSize*4);
    146   xdr_setpos(fBufferXDR, 0);
     144  fInputReader->ReadRaw(fBuffer, fEntrySize*kRecordSize*4);
     145  fBufferReader->SetOffset(0);
    147146  fCounter = 0;
    148147
  • classes/DelphesPileUpReader.h

    r792092a r1716933  
    2929
    3030#include <stdio.h>
    31 #include <rpc/types.h>
    32 #include <rpc/xdr.h>
     31#include <stdint.h>
     32
     33class DelphesXDRReader;
    3334
    3435class DelphesPileUpReader
     
    4041  ~DelphesPileUpReader();
    4142
    42   bool ReadParticle(int &pid,
     43  bool ReadParticle(int32_t &pid,
    4344    float &x, float &y, float &z, float &t,
    4445    float &px, float &py, float &pz, float &e);
    4546
    46   bool ReadEntry(quad_t entry);
     47  bool ReadEntry(int64_t entry);
    4748
    48   quad_t GetEntries() const { return fEntries; }
     49  int64_t GetEntries() const { return fEntries; }
    4950
    5051private:
    5152
    52   quad_t fEntries;
     53  int64_t fEntries;
    5354
    54   int fEntrySize;
    55   int fCounter;
     55  int32_t fEntrySize;
     56  int32_t fCounter;
    5657
    5758  FILE *fPileUpFile;
    58   char *fIndex;
    59   char *fBuffer;
     59  uint8_t *fIndex;
     60  uint8_t *fBuffer;
    6061
    61   XDR *fInputXDR;
    62   XDR *fIndexXDR;
    63   XDR *fBufferXDR;
     62  DelphesXDRReader *fInputReader;
     63  DelphesXDRReader *fIndexReader;
     64  DelphesXDRReader *fBufferReader;
    6465};
    6566
    6667#endif // DelphesPileUpReader_h
    67 
    68 
  • classes/DelphesPileUpWriter.cc

    r792092a r1716933  
    3333
    3434#include <stdio.h>
    35 #include <rpc/types.h>
    36 #include <rpc/xdr.h>
     35#include <stdint.h>
     36
     37#include "classes/DelphesXDRWriter.h"
    3738
    3839using namespace std;
     
    4748  fEntries(0), fEntrySize(0), fOffset(0),
    4849  fPileUpFile(0), fIndex(0), fBuffer(0),
    49   fOutputXDR(0), fIndexXDR(0), fBufferXDR(0)
     50  fOutputWriter(0), fIndexWriter(0), fBufferWriter(0)
    5051{
    5152  stringstream message;
    5253
    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);
    6062
    6163  fPileUpFile = fopen(fileName, "w+");
     
    6769  }
    6870
    69   xdrstdio_create(fOutputXDR, fPileUpFile, XDR_ENCODE);
     71  fOutputWriter->SetFile(fPileUpFile);
    7072}
    7173
     
    7476DelphesPileUpWriter::~DelphesPileUpWriter()
    7577{
    76   xdr_destroy(fOutputXDR);
    7778  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;
    8382  if(fBuffer) delete[] fBuffer;
    8483  if(fIndex) delete[] fIndex;
     
    8786//------------------------------------------------------------------------------
    8887
    89 void DelphesPileUpWriter::WriteParticle(int pid,
     88void DelphesPileUpWriter::WriteParticle(int32_t pid,
    9089  float x, float y, float z, float t,
    9190  float px, float py, float pz, float e)
     
    9695  }
    9796
    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);
    107106
    108107  ++fEntrySize;
     
    118117  }
    119118
    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);
    122121
    123   xdr_hyper(fIndexXDR, &fOffset);
     122  fIndexWriter->WriteValue(&fOffset, 8);
    124123  fOffset += fEntrySize*kRecordSize*4 + 4;
    125124
    126   xdr_setpos(fBufferXDR, 0);
     125  fBufferWriter->SetOffset(0);
    127126  fEntrySize = 0;
    128        
     127
    129128  ++fEntries;
    130129}
     
    134133void DelphesPileUpWriter::WriteIndex()
    135134{
    136   xdr_opaque(fOutputXDR, fIndex, fEntries*8);
    137   xdr_hyper(fOutputXDR, &fEntries);
     135  fOutputWriter->WriteRaw(fIndex, fEntries*8);
     136  fOutputWriter->WriteValue(&fEntries, 8);
    138137}
    139138
  • classes/DelphesPileUpWriter.h

    r792092a r1716933  
    2929
    3030#include <stdio.h>
    31 #include <rpc/types.h>
    32 #include <rpc/xdr.h>
     31#include <stdint.h>
     32
     33class DelphesXDRWriter;
    3334
    3435class DelphesPileUpWriter
     
    4041  ~DelphesPileUpWriter();
    4142
    42   void WriteParticle(int pid,
     43  void WriteParticle(int32_t pid,
    4344    float x, float y, float z, float t,
    4445    float px, float py, float pz, float e);
     
    5051private:
    5152
    52   quad_t fEntries;
    53   int fEntrySize;
    54   quad_t fOffset;
     53  int64_t fEntries;
     54  int32_t fEntrySize;
     55  int64_t fOffset;
    5556
    5657  FILE *fPileUpFile;
    57   char *fIndex;
    58   char *fBuffer;
     58  uint8_t *fIndex;
     59  uint8_t *fBuffer;
    5960
    60   XDR *fOutputXDR;
    61   XDR *fIndexXDR;
    62   XDR *fBufferXDR;
     61  DelphesXDRWriter *fOutputWriter;
     62  DelphesXDRWriter *fIndexWriter;
     63  DelphesXDRWriter *fBufferWriter;
    6364};
    6465
    6566#endif // DelphesPileUpWriter_h
    66 
    67 
  • classes/DelphesSTDHEPReader.cc

    r792092a r1716933  
    3434#include <stdio.h>
    3535#include <errno.h>
    36 #include <rpc/types.h>
    37 #include <rpc/xdr.h>
     36#include <stdint.h>
     37#include <string.h>
    3838
    3939#include "TObjArray.h"
     
    4545#include "classes/DelphesClasses.h"
    4646#include "classes/DelphesFactory.h"
     47#include "classes/DelphesXDRReader.h"
    4748
    4849#include "ExRootAnalysis/ExRootTreeBranch.h"
     
    5556
    5657DelphesSTDHEPReader::DelphesSTDHEPReader() :
    57   fInputFile(0), fInputXDR(0), fBuffer(0), fPDG(0), fBlockType(-1)
    58 {
    59   fInputXDR = new XDR;
    60   fBuffer = new char[kBufferSize*96 + 24];
     58  fInputFile(0), fBuffer(0), fPDG(0), fBlockType(-1)
     59{
     60  fBuffer = new uint8_t[kBufferSize*96 + 24];
    6161
    6262  fPDG = TDatabasePDG::Instance();
     
    6868{
    6969  if(fBuffer) delete fBuffer;
    70   if(fInputXDR) delete fInputXDR;
    7170}
    7271
     
    7675{
    7776  fInputFile = inputFile;
    78   xdrstdio_create(fInputXDR, inputFile, XDR_DECODE);
     77  fReader[0].SetFile(inputFile);
    7978}
    8079
     
    10099  TObjArray *partonOutputArray)
    101100{
     101  fReader[0].ReadValue(&fBlockType, 4);
     102
    102103  if(feof(fInputFile)) return kFALSE;
    103 
    104   xdr_int(fInputXDR, &fBlockType);
    105104
    106105  SkipBytes(4);
     
    146145//---------------------------------------------------------------------------
    147146
    148 void DelphesSTDHEPReader::SkipBytes(u_int size)
     147void DelphesSTDHEPReader::SkipBytes(int size)
    149148{
    150149  int rc;
    151   u_int rndup;
     150  int rndup;
    152151
    153152  rndup = size % 4;
     
    161160  if(rc != 0 && errno == ESPIPE)
    162161  {
    163     xdr_opaque(fInputXDR, fBuffer, size);
    164   }
    165 }
    166 
    167 //---------------------------------------------------------------------------
    168 
    169 void DelphesSTDHEPReader::SkipArray(u_int elsize)
    170 {
    171   u_int size;
    172   xdr_u_int(fInputXDR, &size);
     162    fReader[0].ReadRaw(fBuffer, size);
     163  }
     164}
     165
     166//---------------------------------------------------------------------------
     167
     168void DelphesSTDHEPReader::SkipArray(int elsize)
     169{
     170  uint32_t size;
     171  fReader[0].ReadValue(&size, 4);
    173172  SkipBytes(size*elsize);
    174173}
     
    178177void DelphesSTDHEPReader::ReadFileHeader()
    179178{
    180   u_int i;
     179  uint32_t i;
    181180  enum STDHEPVersion {UNKNOWN, V1, V2, V21} version;
    182181
    183182  // version
    184   xdr_string(fInputXDR, &fBuffer, 100);
     183  fReader[0].ReadString(fBuffer, 100);
    185184  if(fBuffer[0] == '\0' || fBuffer[1] == '\0') version = UNKNOWN;
    186185  else if(fBuffer[0] == '1') version = V1;
    187   else if(strncmp(fBuffer, "2.01", 4) == 0) version = V21;
     186  else if(strncmp((char *)fBuffer, "2.01", 4) == 0) version = V21;
    188187  else if(fBuffer[0] == '2') version = V2;
    189188  else version = UNKNOWN;
     
    207206
    208207  // Number of events
    209   xdr_u_int(fInputXDR, &fEntries);
     208  fReader[0].ReadValue(&fEntries, 4);
    210209
    211210  SkipBytes(8);
    212211
    213212  // Number of blocks
    214   u_int nBlocks = 0;
    215   xdr_u_int(fInputXDR, &nBlocks);
     213  uint32_t nBlocks = 0;
     214  fReader[0].ReadValue(&nBlocks, 4);
    216215
    217216  // Number of NTuples
    218   u_int nNTuples = 0;
     217  uint32_t nNTuples = 0;
    219218  if(version != V1)
    220219  {
    221     xdr_u_int(fInputXDR, &nNTuples);
     220    fReader[0].ReadValue(&nNTuples, 4);
    222221  }
    223222
     
    244243{
    245244  // version
    246   xdr_string(fInputXDR, &fBuffer, 100);
    247   if(strncmp(fBuffer, "1.00", 4) == 0)
     245  fReader[0].ReadString(fBuffer, 100);
     246  if(strncmp((char *)fBuffer, "1.00", 4) == 0)
    248247  {
    249248    SkipBytes(8);
     
    255254    SkipArray(4);
    256255  }
    257   else if(strncmp(fBuffer, "2.00", 4) == 0)
     256  else if(strncmp((char *)fBuffer, "2.00", 4) == 0)
    258257  {
    259258    SkipBytes(12);
     
    272271{
    273272  bool skipNTuples = false;
    274   u_int skipSize = 4;
     273  int skipSize = 4;
    275274
    276275  // version
    277   xdr_string(fInputXDR, &fBuffer, 100);
    278   if(strncmp(fBuffer, "2.00", 4) == 0)
     276  fReader[0].ReadString(fBuffer, 100);
     277  if(strncmp((char *)fBuffer, "2.00", 4) == 0)
    279278  {
    280279    skipNTuples = true;
    281280  }
    282   else if(strncmp(fBuffer, "3.00", 4) == 0)
     281  else if(strncmp((char *)fBuffer, "3.00", 4) == 0)
    283282  {
    284283    skipNTuples = true;
     
    288287  SkipBytes(20);
    289288
    290   u_int dimBlocks = 0;
    291   xdr_u_int(fInputXDR, &dimBlocks);
    292 
    293   u_int dimNTuples = 0;
     289  uint32_t dimBlocks = 0;
     290  fReader[0].ReadValue(&dimBlocks, 4);
     291
     292  uint32_t dimNTuples = 0;
    294293  if(skipNTuples)
    295294  {
    296295    SkipBytes(4);
    297     xdr_u_int(fInputXDR, &dimNTuples);
     296    fReader[0].ReadValue(&dimNTuples, 4);
    298297  }
    299298
     
    318317{
    319318  // version
    320   xdr_string(fInputXDR, &fBuffer, 100);
     319  fReader[0].ReadString(fBuffer, 100);
    321320
    322321  // skip 5*4 + 2*8 = 36 bytes
    323322  SkipBytes(36);
    324323
    325   if((strncmp(fBuffer, "1.", 2) == 0) || (strncmp(fBuffer, "2.", 2) == 0) ||
    326      (strncmp(fBuffer, "3.", 2) == 0) || (strncmp(fBuffer, "4.", 2) == 0) ||
    327      (strncmp(fBuffer, "5.00", 4) == 0))
     324  if((strncmp((char *)fBuffer, "1.", 2) == 0) || (strncmp((char *)fBuffer, "2.", 2) == 0) ||
     325     (strncmp((char *)fBuffer, "3.", 2) == 0) || (strncmp((char *)fBuffer, "4.", 2) == 0) ||
     326     (strncmp((char *)fBuffer, "5.00", 4) == 0))
    328327  {
    329328    return;
     
    333332  SkipArray(1);
    334333
    335   if(strncmp(fBuffer, "5.01", 4) == 0)
     334  if(strncmp((char *)fBuffer, "5.01", 4) == 0)
    336335  {
    337336    return;
     
    345344void DelphesSTDHEPReader::ReadSTDHEP()
    346345{
    347   u_int idhepSize, isthepSize, jmohepSize, jdahepSize, phepSize, vhepSize;
     346  uint32_t idhepSize, isthepSize, jmohepSize, jdahepSize, phepSize, vhepSize;
    348347
    349348  // version
    350   xdr_string(fInputXDR, &fBuffer, 100);
     349  fReader[0].ReadString(fBuffer, 100);
    351350
    352351  // Extracting the event number
    353   xdr_int(fInputXDR, &fEventNumber);
     352  fReader[0].ReadValue(&fEventNumber, 4);
    354353
    355354  // Extracting the number of particles
    356   xdr_int(fInputXDR, &fEventSize);
     355  fReader[0].ReadValue(&fEventSize, 4);
    357356
    358357  if(fEventSize >= kBufferSize)
     
    364363  // 4 + 4 + 4 + 4 + 4 + 4 = 96*n + 24
    365364
    366   xdr_opaque(fInputXDR, fBuffer, 96*fEventSize + 24);
    367 
    368   idhepSize = ntohl(*(u_int*)(fBuffer));
    369   isthepSize = ntohl(*(u_int*)(fBuffer + 4*1 + 4*1*fEventSize));
    370   jmohepSize = ntohl(*(u_int*)(fBuffer + 4*2 + 4*2*fEventSize));
    371   jdahepSize = ntohl(*(u_int*)(fBuffer + 4*3 + 4*4*fEventSize));
    372   phepSize = ntohl(*(u_int*)(fBuffer + 4*4 + 4*6*fEventSize));
    373   vhepSize = ntohl(*(u_int*)(fBuffer + 4*5 + 4*16*fEventSize));
     365  fReader[0].ReadRaw(fBuffer, 96*fEventSize + 24);
     366
     367  fReader[1].SetBuffer(fBuffer);
     368  fReader[2].SetBuffer(fBuffer + 4*1 + 4*1*fEventSize);
     369  fReader[3].SetBuffer(fBuffer + 4*2 + 4*2*fEventSize);
     370  fReader[4].SetBuffer(fBuffer + 4*3 + 4*4*fEventSize);
     371  fReader[5].SetBuffer(fBuffer + 4*4 + 4*6*fEventSize);
     372  fReader[6].SetBuffer(fBuffer + 4*5 + 4*16*fEventSize);
     373
     374  fReader[1].ReadValue(&idhepSize, 4);
     375  fReader[2].ReadValue(&isthepSize, 4);
     376  fReader[3].ReadValue(&jmohepSize, 4);
     377  fReader[4].ReadValue(&jdahepSize, 4);
     378  fReader[5].ReadValue(&phepSize, 4);
     379  fReader[6].ReadValue(&vhepSize, 4);
    374380
    375381  if(fEventSize < 0 ||
     
    392398void DelphesSTDHEPReader::ReadSTDHEP4()
    393399{
    394   u_int number;
     400  uint32_t number;
    395401
    396402  // Extracting the event weight
    397   xdr_double(fInputXDR, &fWeight);
     403  fReader[0].ReadValue(&fWeight, 8);
    398404
    399405  // Extracting alpha QED
    400   xdr_double(fInputXDR, &fAlphaQED);
     406  fReader[0].ReadValue(&fAlphaQED, 8);
    401407
    402408  // Extracting alpha QCD
    403   xdr_double(fInputXDR, &fAlphaQCD);
     409  fReader[0].ReadValue(&fAlphaQCD, 8);
    404410
    405411  // Extracting the event scale
    406   xdr_u_int(fInputXDR, &fScaleSize);
     412  fReader[0].ReadValue(&fScaleSize, 4);
    407413  for(number = 0; number < fScaleSize; ++number)
    408414  {
    409     xdr_double(fInputXDR, &fScale[number]);
     415    fReader[0].ReadValue(&fScale[number], 8);
    410416  }
    411417
     
    450456
    451457  int number;
    452   int pid, status, m1, m2, d1, d2;
     458  int32_t pid, status, m1, m2, d1, d2;
    453459  double px, py, pz, e, mass;
    454460  double x, y, z, t;
    455461
    456   XDR bufferXDR[6];
    457   xdrmem_create(&bufferXDR[0], fBuffer + 4*1, 4*fEventSize, XDR_DECODE);
    458   xdrmem_create(&bufferXDR[1], fBuffer + 4*2 + 4*1*fEventSize, 4*fEventSize, XDR_DECODE);
    459   xdrmem_create(&bufferXDR[2], fBuffer + 4*3 + 4*2*fEventSize, 8*fEventSize, XDR_DECODE);
    460   xdrmem_create(&bufferXDR[3], fBuffer + 4*4 + 4*4*fEventSize, 8*fEventSize, XDR_DECODE);
    461   xdrmem_create(&bufferXDR[4], fBuffer + 4*5 + 4*6*fEventSize, 40*fEventSize, XDR_DECODE);
    462   xdrmem_create(&bufferXDR[5], fBuffer + 4*6 + 4*16*fEventSize, 32*fEventSize, XDR_DECODE);
    463 
    464462  for(number = 0; number < fEventSize; ++number)
    465463  {
    466     xdr_int(&bufferXDR[0], &status);
    467     xdr_int(&bufferXDR[1], &pid);
    468     xdr_int(&bufferXDR[2], &m1);
    469     xdr_int(&bufferXDR[2], &m2);
    470     xdr_int(&bufferXDR[3], &d1);
    471     xdr_int(&bufferXDR[3], &d2);
    472 
    473     xdr_double(&bufferXDR[4], &px);
    474     xdr_double(&bufferXDR[4], &py);
    475     xdr_double(&bufferXDR[4], &pz);
    476     xdr_double(&bufferXDR[4], &e);
    477     xdr_double(&bufferXDR[4], &mass);
    478 
    479     xdr_double(&bufferXDR[5], &x);
    480     xdr_double(&bufferXDR[5], &y);
    481     xdr_double(&bufferXDR[5], &z);
    482     xdr_double(&bufferXDR[5], &t);
     464    fReader[1].ReadValue(&status, 4);
     465    fReader[2].ReadValue(&pid, 4);
     466    fReader[3].ReadValue(&m1, 4);
     467    fReader[3].ReadValue(&m2, 4);
     468    fReader[4].ReadValue(&d1, 4);
     469    fReader[4].ReadValue(&d2, 4);
     470
     471    fReader[5].ReadValue(&px, 8);
     472    fReader[5].ReadValue(&py, 8);
     473    fReader[5].ReadValue(&pz, 8);
     474    fReader[5].ReadValue(&e, 8);
     475    fReader[5].ReadValue(&mass, 8);
     476
     477    fReader[6].ReadValue(&x, 8);
     478    fReader[6].ReadValue(&y, 8);
     479    fReader[6].ReadValue(&z, 8);
     480    fReader[6].ReadValue(&t, 8);
    483481
    484482    candidate = factory->NewCandidate();
  • classes/DelphesSTDHEPReader.h

    r792092a r1716933  
    2929
    3030#include <stdio.h>
    31 #include <rpc/types.h>
    32 #include <rpc/xdr.h>
     31#include <stdint.h>
     32
     33#include "classes/DelphesXDRReader.h"
    3334
    3435class TObjArray;
     
    3738class ExRootTreeBranch;
    3839class DelphesFactory;
     40class DelphesXDRReader;
    3941
    4042class DelphesSTDHEPReader
     
    7678    TObjArray *partonOutputArray);
    7779
    78   void SkipBytes(u_int size);
    79   void SkipArray(u_int elsize);
     80  void SkipBytes(int size);
     81  void SkipArray(int elsize);
    8082
    8183  void ReadFileHeader();
     
    8890  FILE *fInputFile;
    8991
    90   XDR *fInputXDR;
     92  DelphesXDRReader fReader[7];
    9193
    92   char *fBuffer;
     94  uint8_t *fBuffer;
    9395
    9496  TDatabasePDG *fPDG;
    9597
    96   u_int fEntries;
    97   int fBlockType, fEventNumber, fEventSize;
     98  uint32_t fEntries;
     99  int32_t fBlockType, fEventNumber, fEventSize;
    98100  double fWeight, fAlphaQCD, fAlphaQED;
    99101
    100   u_int fScaleSize;
     102  uint32_t fScaleSize;
    101103  double fScale[10];
    102104};
    103105
    104106#endif // DelphesSTDHEPReader_h
    105 
    106 
  • doc/genMakefile.tcl

    r792092a r1716933  
    208208PcmSuf = _rdict.pcm
    209209
    210 CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl -I/usr/include/tirpc
     210CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl
    211211DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
    212212DISPLAY_LIBS = $(shell $(RC) --evelibs) -lGuiHtml $(SYSLIBS)
Note: See TracChangeset for help on using the changeset viewer.