Fork me on GitHub

Changeset 1265 in svn for trunk


Ignore:
Timestamp:
Aug 16, 2013, 4:29:25 PM (11 years ago)
Author:
Pavel Demin
Message:

read reweighting information from LHEF

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/classes/DelphesLHEFReader.cc

    r1189 r1265  
    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,
  • trunk/readers/DelphesLHEF.cpp

    r1130 r1265  
    4545  TStopwatch readStopWatch, procStopWatch;
    4646  ExRootTreeWriter *treeWriter = 0;
    47   ExRootTreeBranch *branchEvent = 0;
     47  ExRootTreeBranch *branchEvent = 0, *branchRwgt = 0;
    4848  ExRootConfReader *confReader = 0;
    4949  Delphes *modularDelphes = 0;
     
    8585
    8686    branchEvent = treeWriter->NewBranch("Event", LHEFEvent::Class());
     87    branchRwgt = treeWriter->NewBranch("Rwgt", Weight::Class());
    8788
    8889    confReader = new ExRootConfReader;
     
    177178
    178179            reader->AnalyzeEvent(branchEvent, eventCounter, &readStopWatch, &procStopWatch);
     180            reader->AnalyzeRwgt(branchRwgt);
    179181
    180182            treeWriter->Fill();
Note: See TracChangeset for help on using the changeset viewer.