Fork me on GitHub

Changeset 1129 in svn


Ignore:
Timestamp:
May 30, 2013, 12:47:35 AM (11 years ago)
Author:
Pavel Demin
Message:

use xdr_opaque when reading pipe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/classes/DelphesSTDHEPReader.cc

    r1120 r1129  
    2020
    2121#include <stdio.h>
     22#include <errno.h>
    2223#include <rpc/types.h>
    2324#include <rpc/xdr.h>
     
    8788  TObjArray *partonOutputArray)
    8889{
     90  bool skipNTuples = false;
     91
    8992  if(feof(fInputFile)) return kFALSE;
    9093
     
    9497
    9598  xdr_string(fInputXDR, &fBuffer, 100);
     99  if(strncmp(fBuffer, "2.00", 4) == 0)
     100  {
     101    skipNTuples = true;
     102  }
    96103
    97104  if(fBlockType == EVENTTABLE)
     
    101108  else if(fBlockType == EVENTHEADER)
    102109  {
    103     ReadSTDHEPHeader();
     110    ReadSTDHEPHeader(skipNTuples);
    104111  }
    105112  else if(fBlockType == MCFIO_STDHEPBEG ||
     
    116123  else if(fBlockType == MCFIO_STDHEP4)
    117124  {
    118     ReadSTDHEP4();
     125    ReadSTDHEP();
    119126    AnalyzeParticles(factory, allParticleOutputArray,
    120127      stableParticleOutputArray, partonOutputArray);
     128    ReadSTDHEP4();
    121129  }
    122130  else
     
    132140void DelphesSTDHEPReader::SkipBytes(u_int size)
    133141{
     142  int rc;
    134143  u_int rndup;
     144
    135145  rndup = size % 4;
    136146  if(rndup > 0)
     
    139149  }
    140150
    141   fseek(fInputFile, size + rndup, SEEK_CUR);
     151  rc = fseek(fInputFile, size + rndup, SEEK_CUR);
     152
     153  if(rc != 0 && errno == ESPIPE)
     154  {
     155    xdr_opaque(fInputXDR, fBuffer, size);
     156  }
    142157}
    143158
     
    239254//---------------------------------------------------------------------------
    240255
    241 void DelphesSTDHEPReader::ReadSTDHEPHeader()
     256void DelphesSTDHEPReader::ReadSTDHEPHeader(bool skipNTuples)
    242257{
    243258  SkipBytes(20);
     
    247262
    248263  u_int dimNTuples = 0;
    249   if(strncmp(fBuffer, "2.00", 4) == 0)
     264  if(skipNTuples)
    250265  {
    251266    SkipBytes(4);
     
    261276
    262277  // Processing blocks extraction
    263   if(dimNTuples > 0 && strncmp(fBuffer, "2.00", 4) == 0)
     278  if(skipNTuples && dimNTuples > 0)
    264279  {
    265280    SkipArray(4);
     
    342357{
    343358  u_int number;
    344 
    345   ReadSTDHEP();
    346359
    347360  // Extracting the event weight
Note: See TracChangeset for help on using the changeset viewer.