Fork me on GitHub

Changeset 0dc0eeb in git for classes/DelphesLHEFReader.cc


Ignore:
Timestamp:
Aug 16, 2013, 4:29:25 PM (11 years ago)
Author:
pavel <pavel@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
82e07cf
Parents:
0a0a5ef
Message:

read reweighting information from LHEF

File:
1 edited

Legend:

Unmodified
Added
Removed
  • classes/DelphesLHEFReader.cc

    r0a0a5ef r0dc0eeb  
    4141DelphesLHEFReader::DelphesLHEFReader() :
    4242  fInputFile(0), fBuffer(0), fPDG(0),
    43   fEventCounter(-1), fParticleCounter(-1)
     43  fEventReady(kFALSE), fEventCounter(-1), fParticleCounter(-1)
    4444{
    4545  fBuffer = new char[kBufferSize];
     
    6666void DelphesLHEFReader::Clear()
    6767{
     68  fEventReady = kFALSE;
    6869  fEventCounter = -1;
    6970  fParticleCounter = -1;
     71  fRwgtList.clear();
    7072}
    7173
     
    7476bool DelphesLHEFReader::EventReady()
    7577{
    76   return (fEventCounter == 0) && (fParticleCounter == 0);
     78  return fEventReady;
    7779}
    7880
     
    8587{
    8688  int rc;
     89  char *pch;
     90  double weight;
    8791
    8892  if(!fgets(fBuffer, kBufferSize, fInputFile)) return kFALSE;
    89 
    90   DelphesStream bufferStream(fBuffer);
    9193
    9294  if(strstr(fBuffer, "<event>"))
     
    9799  else if(fEventCounter > 0)
    98100  {
     101    DelphesStream bufferStream(fBuffer);
     102
    99103    rc = bufferStream.ReadInt(fParticleCounter)
    100104      && bufferStream.ReadInt(fProcessID)
     
    114118  else if(fParticleCounter > 0)
    115119  {
     120    DelphesStream bufferStream(fBuffer);
     121
    116122    rc = bufferStream.ReadInt(fPID)
    117123      && bufferStream.ReadInt(fStatus)
     
    137143    --fParticleCounter;
    138144  }
     145  else if(strstr(fBuffer, "<wgt"))
     146  {
     147    pch = strstr(fBuffer, ">");
     148    if(!pch)
     149    {
     150      cerr << "** ERROR: " << "invalid weight format" << endl;
     151      return kFALSE;
     152    }
     153
     154    DelphesStream bufferStream(pch + 1);
     155    rc = bufferStream.ReadDbl(weight);
     156
     157    if(!rc)
     158    {
     159      cerr << "** ERROR: " << "invalid weight format" << endl;
     160      return kFALSE;
     161    }
     162
     163    fRwgtList.push_back(weight);
     164  }
     165  else if(strstr(fBuffer, "</event>"))
     166  {
     167    fEventReady = kTRUE;
     168  }
    139169
    140170  return kTRUE;
     
    163193//---------------------------------------------------------------------------
    164194
     195void DelphesLHEFReader::AnalyzeRwgt(ExRootTreeBranch *branch)
     196{
     197  Weight *element;
     198  vector<double>::const_iterator itRwgtList;
     199
     200  for(itRwgtList = fRwgtList.begin(); itRwgtList != fRwgtList.end(); ++itRwgtList)
     201  {
     202    element = static_cast<Weight *>(branch->NewEntry());
     203
     204    element->Weight = *itRwgtList;
     205  }
     206}
     207
     208//---------------------------------------------------------------------------
     209
    165210void DelphesLHEFReader::AnalyzeParticle(DelphesFactory *factory,
    166211  TObjArray *allParticleOutputArray,
Note: See TracChangeset for help on using the changeset viewer.