Index: readers/CMakeLists.txt
===================================================================
--- readers/CMakeLists.txt	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ 	(revision )
@@ -1,22 +1,0 @@
-include_directories(
-  ${CMAKE_SOURCE_DIR}
-  ${DelphesExternals_INCLUDE_DIR} 
-)
-
-file(GLOB executables RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
-
-# TODO: implement switch to enable CMSSW, ProMC and ProIO if present
-list(REMOVE_ITEM executables DelphesCMSFWLite.cpp)
-list(REMOVE_ITEM executables DelphesProMC.cpp)
-list(REMOVE_ITEM executables DelphesProIO.cpp)
-if(NOT PYTHIA8_FOUND)
-  list(REMOVE_ITEM executables DelphesPythia8.cpp)
-endif()
-
-# build all executables and put them into bin/
-foreach(sourcefile ${executables})
-  string(REPLACE ".cpp" "" name ${sourcefile})
-  add_executable(${name} ${sourcefile})
-  target_link_libraries(${name} Delphes)
-  install(TARGETS ${name} DESTINATION bin)
-endforeach()
Index: readers/DelphesCMSFWLite.cpp
===================================================================
--- readers/DelphesCMSFWLite.cpp	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ 	(revision )
@@ -1,450 +1,0 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <algorithm>
-#include <iostream>
-#include <memory>
-#include <sstream>
-#include <stdexcept>
-
-#include <map>
-#include <vector>
-
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "TApplication.h"
-#include "TROOT.h"
-
-#include "TDatabasePDG.h"
-#include "TFile.h"
-#include "TLorentzVector.h"
-#include "TObjArray.h"
-#include "TParticlePDG.h"
-#include "TStopwatch.h"
-
-#include "classes/DelphesClasses.h"
-#include "classes/DelphesFactory.h"
-#include "classes/DelphesStream.h"
-#include "modules/Delphes.h"
-
-#include "ExRootAnalysis/ExRootProgressBar.h"
-#include "ExRootAnalysis/ExRootTreeBranch.h"
-#include "ExRootAnalysis/ExRootTreeWriter.h"
-
-#include "DataFormats/FWLite/interface/Event.h"
-#include "DataFormats/FWLite/interface/Handle.h"
-#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
-#include "DataFormats/PatCandidates/interface/PackedGenParticle.h"
-#include "FWCore/FWLite/interface/FWLiteEnabler.h"
-#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
-#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
-#include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h"
-#include "SimDataFormats/GeneratorProducts/interface/WeightsInfo.h"
-
-using namespace std;
-
-//---------------------------------------------------------------------------
-
-void ConvertInput(fwlite::Event &event, Long64_t eventCounter,
-  ExRootTreeBranch *branchEvent, ExRootTreeBranch *branchWeight,
-  DelphesFactory *factory, TObjArray *allParticleOutputArray,
-  TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray, Bool_t firstEvent)
-{
-
-  fwlite::Handle<GenEventInfoProduct> handleGenEventInfo;
-  fwlite::Handle<LHEEventProduct> handleLHEEvent;
-  fwlite::Handle<vector<reco::GenParticle> > handleParticle;
-  fwlite::Handle<vector<pat::PackedGenParticle> > handlePackedParticle;
-
-  vector<reco::GenParticle>::const_iterator itParticle;
-  vector<pat::PackedGenParticle>::const_iterator itPackedParticle;
-
-  vector<const reco::Candidate *> vectorCandidate;
-  vector<const reco::Candidate *>::iterator itCandidate;
-
-  handleGenEventInfo.getByLabel(event, "generator");
-
-  if(!((handleLHEEvent.getBranchNameFor(event, "source")).empty()))
-  {
-    handleLHEEvent.getByLabel(event, "source");
-  }
-  else if(!((handleLHEEvent.getBranchNameFor(event, "externalLHEProducer")).empty()))
-  {
-    handleLHEEvent.getByLabel(event, "externalLHEProducer");
-  }
-  else if(firstEvent)
-  {
-    cout << "Wrong LHEEvent Label! Please, check the input file." << endl;
-  }
-
-  if(!((handleParticle.getBranchNameFor(event, "genParticles")).empty()))
-  {
-    handleParticle.getByLabel(event, "genParticles");
-  }
-  else if(!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && !((handleParticle.getBranchNameFor(event, "prunedGenParticles")).empty()))
-  {
-    handleParticle.getByLabel(event, "prunedGenParticles");
-    handlePackedParticle.getByLabel(event, "packedGenParticles");
-  }
-  else
-  {
-    std::cout << "Wrong GenParticle Label! Please, check the input file." << std::endl;
-    exit(-1);
-  }
-
-  Bool_t foundLHE = !((handleLHEEvent.getBranchNameFor(event, "source")).empty()) || !((handleLHEEvent.getBranchNameFor(event, "externalLHEProducer")).empty());
-  Bool_t isMiniAOD = !((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && ((handleParticle.getBranchNameFor(event, "genParticles")).empty());
-
-  HepMCEvent *element;
-  Weight *weight;
-  Candidate *candidate;
-  TDatabasePDG *pdg;
-  TParticlePDG *pdgParticle;
-  Int_t pdgCode;
-
-  Int_t pid, status;
-  Double_t px, py, pz, e, mass;
-  Double_t x, y, z;
-
-  element = static_cast<HepMCEvent *>(branchEvent->NewEntry());
-
-  element->Number = eventCounter;
-
-  element->ProcessID = handleGenEventInfo->signalProcessID();
-  element->MPI = 1;
-  element->Weight = handleGenEventInfo->weight();
-  element->Scale = handleGenEventInfo->qScale();
-  element->AlphaQED = handleGenEventInfo->alphaQED();
-  element->AlphaQCD = handleGenEventInfo->alphaQCD();
-
-  element->ID1 = 0;
-  element->ID2 = 0;
-  element->X1 = 0.0;
-  element->X2 = 0.0;
-  element->ScalePDF = 0.0;
-  element->PDF1 = 0.0;
-  element->PDF2 = 0.0;
-
-  element->ReadTime = 0.0;
-  element->ProcTime = 0.0;
-
-  if(foundLHE)
-  {
-    const vector<gen::WeightsInfo> &vectorWeightsInfo = handleLHEEvent->weights();
-    vector<gen::WeightsInfo>::const_iterator itWeightsInfo;
-
-    for(itWeightsInfo = vectorWeightsInfo.begin(); itWeightsInfo != vectorWeightsInfo.end(); ++itWeightsInfo)
-    {
-      weight = static_cast<Weight *>(branchWeight->NewEntry());
-      weight->Weight = itWeightsInfo->wgt;
-    }
-  }
-
-  pdg = TDatabasePDG::Instance();
-
-  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
-  {
-    const reco::GenParticle &particle = *itParticle;
-    if(!isMiniAOD || particle.status() != 1) vectorCandidate.push_back(&*itParticle);
-  }
-
-  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
-  {
-    const reco::GenParticle &particle = *itParticle;
-
-    pid = particle.pdgId();
-    status = particle.status();
-    if(isMiniAOD && particle.status() == 1) continue;
-    px = particle.px();
-    py = particle.py();
-    pz = particle.pz();
-    e = particle.energy();
-    mass = particle.mass();
-    x = particle.vx();
-    y = particle.vy();
-    z = particle.vz();
-
-    candidate = factory->NewCandidate();
-
-    candidate->PID = pid;
-    pdgCode = TMath::Abs(candidate->PID);
-
-    candidate->Status = status;
-
-    if(particle.mother())
-    {
-      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother());
-      if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
-    }
-
-    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
-    if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);
-
-    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
-    if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);
-
-    pdgParticle = pdg->GetParticle(pid);
-    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
-    candidate->Mass = mass;
-
-    candidate->Momentum.SetPxPyPzE(px, py, pz, e);
-
-    candidate->Position.SetXYZT(x * 10.0, y * 10.0, z * 10.0, 0.0);
-
-    allParticleOutputArray->Add(candidate);
-
-    if(!pdgParticle) continue;
-
-    if(status == 1)
-    {
-      // Prevent duplicated particle.
-      if(!isMiniAOD) stableParticleOutputArray->Add(candidate);
-      if (pdgCode == 11 || pdgCode == 13) partonOutputArray->Add(candidate);
-    }
-    //else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
-    else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 11 || pdgCode == 13 || pdgCode == 15)
-    {
-      partonOutputArray->Add(candidate);
-    }
-  }
-
-  if(!isMiniAOD) return;
-  // For MiniAOD sample,
-  // Only status==1 particles are saved to packedGenParticles.
-  for(itPackedParticle = handlePackedParticle->begin(); itPackedParticle != handlePackedParticle->end(); ++itPackedParticle)
-  {
-    vectorCandidate.push_back(&*itPackedParticle);
-  }
-
-  for(itPackedParticle = handlePackedParticle->begin(); itPackedParticle != handlePackedParticle->end(); ++itPackedParticle)
-  {
-    const pat::PackedGenParticle &particle = *itPackedParticle;
-
-    pid = particle.pdgId();
-    status = particle.status();
-    px = particle.px();
-    py = particle.py();
-    pz = particle.pz();
-    e = particle.energy();
-    mass = particle.mass();
-    x = particle.vx();
-    y = particle.vy();
-    z = particle.vz();
-
-    candidate = factory->NewCandidate();
-
-    candidate->PID = pid;
-    pdgCode = TMath::Abs(candidate->PID);
-
-    candidate->Status = status;
-
-    if(particle.mother(0))
-    {
-      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother(0));
-      if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
-    }
-
-    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
-    if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);
-
-    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
-    if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);
-
-    pdgParticle = pdg->GetParticle(pid);
-    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
-    candidate->Mass = mass;
-
-    candidate->Momentum.SetPxPyPzE(px, py, pz, e);
-
-    candidate->Position.SetXYZT(x * 10.0, y * 10.0, z * 10.0, 0.0);
-
-    allParticleOutputArray->Add(candidate);
-
-    if(!pdgParticle) continue;
-
-    if(status == 1)
-    {
-      stableParticleOutputArray->Add(candidate);
-    }
-  }
-}
-
-//---------------------------------------------------------------------------
-
-static bool interrupted = false;
-
-void SignalHandler(int sig)
-{
-  interrupted = true;
-}
-
-//---------------------------------------------------------------------------
-
-int main(int argc, char *argv[])
-{
-  char appName[] = "DelphesCMSFWLite";
-  stringstream message;
-  TFile *inputFile = 0;
-  TFile *outputFile = 0;
-  TStopwatch eventStopWatch;
-  ExRootTreeWriter *treeWriter = 0;
-  ExRootTreeBranch *branchEvent = 0, *branchWeight = 0;
-  ExRootConfReader *confReader = 0;
-  Delphes *modularDelphes = 0;
-  DelphesFactory *factory = 0;
-  TObjArray *allParticleOutputArray = 0, *stableParticleOutputArray = 0, *partonOutputArray = 0;
-  Int_t i, maxEvents, skipEvents;
-  Long64_t eventCounter, numberOfEvents;
-  Bool_t firstEvent = kTRUE;
-
-  if(argc < 4)
-  {
-    cout << " Usage: " << appName << " config_file"
-         << " output_file"
-         << " input_file(s)" << endl;
-    cout << " config_file - configuration file in Tcl format," << endl;
-    cout << " output_file - output file in ROOT format," << endl;
-    cout << " input_file(s) - input file(s) in ROOT format." << endl;
-    return 1;
-  }
-
-  signal(SIGINT, SignalHandler);
-
-  gROOT->SetBatch();
-
-  int appargc = 1;
-  char *appargv[] = {appName};
-  TApplication app(appName, &appargc, appargv);
-
-  FWLiteEnabler::enable();
-
-  try
-  {
-    outputFile = TFile::Open(argv[2], "CREATE");
-
-    if(outputFile == NULL)
-    {
-      message << "can't open " << argv[2] << endl;
-      throw runtime_error(message.str());
-    }
-
-    treeWriter = new ExRootTreeWriter(outputFile, "Delphes");
-
-    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
-    branchWeight = treeWriter->NewBranch("Weight", Weight::Class());
-
-    confReader = new ExRootConfReader;
-    confReader->ReadFile(argv[1]);
-    
-    maxEvents = confReader->GetInt("::MaxEvents", 0);
-    skipEvents = confReader->GetInt("::SkipEvents", 0);
-    
-    if(maxEvents < 0)
-    {
-      throw runtime_error("MaxEvents must be zero or positive");
-    }
-    
-    if(skipEvents < 0)
-    {
-      throw runtime_error("SkipEvents must be zero or positive");
-    }
-
-    modularDelphes = new Delphes("Delphes");
-    modularDelphes->SetConfReader(confReader);
-    modularDelphes->SetTreeWriter(treeWriter);
-
-    factory = modularDelphes->GetFactory();
-    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
-    stableParticleOutputArray = modularDelphes->ExportArray("stableParticles");
-    partonOutputArray = modularDelphes->ExportArray("partons");
-
-    modularDelphes->InitTask();
-
-    for(i = 3; i < argc && !interrupted; ++i)
-    {
-      cout << "** Reading " << argv[i] << endl;
-
-      inputFile = TFile::Open(argv[i]);
-
-      if(inputFile == NULL)
-      {
-        message << "can't open " << argv[i] << endl;
-        throw runtime_error(message.str());
-      }
-
-      fwlite::Event event(inputFile);
-
-      numberOfEvents = event.size();
-
-      if(numberOfEvents <= 0) continue;
-
-      // ExRootProgressBar progressBar(numberOfEvents - 1);
-      ExRootProgressBar progressBar(-1);
-
-      // Loop over all objects
-      eventCounter = 0;
-      modularDelphes->Clear();
-      treeWriter->Clear();
-
-      for(event.toBegin(); !event.atEnd() && !interrupted && (maxEvents <= 0 || eventCounter-skipEvents < maxEvents); ++event)
-      {
-        if(eventCounter >= skipEvents){
-          ConvertInput(event, eventCounter, branchEvent, branchWeight, factory,
-            allParticleOutputArray, stableParticleOutputArray, partonOutputArray, firstEvent);
-          modularDelphes->ProcessTask();
-
-          firstEvent = kFALSE;
-
-          treeWriter->Fill();
-
-          modularDelphes->Clear();
-          treeWriter->Clear();
-        }
-
-        progressBar.Update(eventCounter, eventCounter);
-        ++eventCounter;
-      }
-
-      progressBar.Update(eventCounter, eventCounter, kTRUE);
-      progressBar.Finish();
-
-      inputFile->Close();
-    }
-
-    modularDelphes->FinishTask();
-    treeWriter->Write();
-
-    cout << "** Exiting..." << endl;
-
-    delete modularDelphes;
-    delete confReader;
-    delete treeWriter;
-    delete outputFile;
-
-    return 0;
-  }
-  catch(runtime_error &e)
-  {
-    if(treeWriter) delete treeWriter;
-    if(outputFile) delete outputFile;
-    cerr << "** ERROR: " << e.what() << endl;
-    return 1;
-  }
-}
Index: readers/DelphesHepMC.cpp
===================================================================
--- readers/DelphesHepMC.cpp	(revision d7d2da362406b9e37fdf238970417c94779b54b0)
+++ readers/DelphesHepMC.cpp	(revision d7d2da362406b9e37fdf238970417c94779b54b0)
@@ -0,0 +1,203 @@
+#include <stdexcept>
+#include <iostream>
+#include <sstream>
+
+#include <signal.h>
+
+#include "TROOT.h"
+#include "TApplication.h"
+
+#include "TFile.h"
+#include "TObjArray.h"
+#include "TStopwatch.h"
+#include "TDatabasePDG.h"
+#include "TParticlePDG.h"
+#include "TLorentzVector.h"
+
+#include "modules/Delphes.h"
+#include "classes/DelphesClasses.h"
+#include "classes/DelphesFactory.h"
+#include "classes/DelphesHepMCReader.h"
+
+#include "ExRootAnalysis/ExRootTreeWriter.h"
+#include "ExRootAnalysis/ExRootTreeBranch.h"
+#include "ExRootAnalysis/ExRootProgressBar.h"
+
+using namespace std;
+
+//---------------------------------------------------------------------------
+
+static bool interrupted = false;
+
+void SignalHandler(int sig)
+{
+  interrupted = true;
+}
+
+//---------------------------------------------------------------------------
+
+int main(int argc, char *argv[])
+{
+  char appName[] = "DelphesHepMC";
+  stringstream message;
+  FILE *inputFile = 0;
+  TFile *outputFile = 0;
+  TStopwatch readStopWatch, procStopWatch;
+  ExRootTreeWriter *treeWriter = 0;
+  ExRootTreeBranch *branchEvent = 0;
+  ExRootConfReader *confReader = 0;
+  Delphes *modularDelphes = 0;
+  DelphesFactory *factory = 0;
+  TObjArray *stableParticleOutputArray = 0, *allParticleOutputArray = 0, *partonOutputArray = 0;
+  DelphesHepMCReader *reader = 0;
+  Int_t i;
+  Long64_t length, eventCounter;
+
+  if(argc < 3)
+  {
+    cout << " Usage: " << appName << " config_file" << " output_file" << " [input_file(s)]" << endl;
+    cout << " config_file - configuration file in Tcl format," << endl;
+    cout << " output_file - output file in ROOT format," << endl;
+    cout << " input_file(s) - input file(s) in HepMC format," << endl;
+    cout << " with no input_file, or when input_file is -, read standard input." << endl;
+    return 1;
+  }
+
+  signal(SIGINT, SignalHandler);
+
+  gROOT->SetBatch();
+
+  int appargc = 1;
+  char *appargv[] = {appName};
+  TApplication app(appName, &appargc, appargv);
+
+  try
+  {
+    outputFile = TFile::Open(argv[2], "CREATE");
+
+    if(outputFile == NULL)
+    {
+      message << "can't create output file " << argv[2];
+      throw runtime_error(message.str());
+    }
+
+    treeWriter = new ExRootTreeWriter(outputFile, "Delphes");
+
+    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
+
+    confReader = new ExRootConfReader;
+    confReader->ReadFile(argv[1]);
+
+    modularDelphes = new Delphes("Delphes");
+    modularDelphes->SetConfReader(confReader);
+    modularDelphes->SetTreeWriter(treeWriter);
+
+    factory = modularDelphes->GetFactory();
+    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
+    stableParticleOutputArray = modularDelphes->ExportArray("stableParticles");
+    partonOutputArray = modularDelphes->ExportArray("partons");
+
+    reader = new DelphesHepMCReader;
+
+    modularDelphes->InitTask();
+
+    i = 3;
+    do
+    {
+      if(interrupted) break;
+
+      if(i == argc || strncmp(argv[i], "-", 2) == 0)
+      {
+        cout << "** Reading standard input" << endl;
+        inputFile = stdin;
+        length = -1;
+      }
+      else
+      {
+        cout << "** Reading " << argv[i] << endl;
+        inputFile = fopen(argv[i], "r");
+
+        if(inputFile == NULL)
+        {
+          message << "can't open " << argv[i];
+          throw runtime_error(message.str());
+        }
+
+        fseek(inputFile, 0L, SEEK_END);
+        length = ftello(inputFile);
+        fseek(inputFile, 0L, SEEK_SET);
+
+        if(length <= 0)
+        {
+          fclose(inputFile);
+          ++i;
+          continue;
+        }
+      }
+
+      reader->SetInputFile(inputFile);
+
+      ExRootProgressBar progressBar(length);
+
+      // Loop over all objects
+      eventCounter = 0;
+      treeWriter->Clear();
+      modularDelphes->Clear();
+      reader->Clear();
+      readStopWatch.Start();
+      while(reader->ReadBlock(factory, allParticleOutputArray,
+        stableParticleOutputArray, partonOutputArray) && !interrupted)
+      {
+        if(reader->EventReady())
+        {
+          ++eventCounter;
+
+          readStopWatch.Stop();
+          procStopWatch.Start();
+          modularDelphes->ProcessTask();
+          procStopWatch.Stop();
+
+          reader->AnalyzeEvent(branchEvent, eventCounter, &readStopWatch, &procStopWatch);
+
+          treeWriter->Fill();
+
+          treeWriter->Clear();
+          modularDelphes->Clear();
+          reader->Clear();
+
+          readStopWatch.Start();
+        }
+        progressBar.Update(ftello(inputFile), eventCounter);
+      }
+
+      fseek(inputFile, 0L, SEEK_END);
+      progressBar.Update(ftello(inputFile), eventCounter, kTRUE);
+      progressBar.Finish();
+
+      if(inputFile != stdin) fclose(inputFile);
+
+      ++i;
+    }
+    while(i < argc);
+
+    modularDelphes->FinishTask();
+    treeWriter->Write();
+
+    cout << "** Exiting..." << endl;
+
+    delete reader;
+    delete modularDelphes;
+    delete confReader;
+    delete treeWriter;
+    delete outputFile;
+
+    return 0;
+  }
+  catch(runtime_error &e)
+  {
+    if(treeWriter) delete treeWriter;
+    if(outputFile) delete outputFile;
+    cerr << "** ERROR: " << e.what() << endl;
+    return 1;
+  }
+}
Index: readers/DelphesHepMC2.cpp
===================================================================
--- readers/DelphesHepMC2.cpp	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ 	(revision )
@@ -1,241 +1,0 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <iostream>
-#include <sstream>
-#include <stdexcept>
-
-#include <signal.h>
-
-#include "TApplication.h"
-#include "TROOT.h"
-
-#include "TDatabasePDG.h"
-#include "TFile.h"
-#include "TLorentzVector.h"
-#include "TObjArray.h"
-#include "TParticlePDG.h"
-#include "TStopwatch.h"
-
-#include "classes/DelphesClasses.h"
-#include "classes/DelphesFactory.h"
-#include "classes/DelphesHepMC2Reader.h"
-#include "modules/Delphes.h"
-
-#include "ExRootAnalysis/ExRootProgressBar.h"
-#include "ExRootAnalysis/ExRootTreeBranch.h"
-#include "ExRootAnalysis/ExRootTreeWriter.h"
-
-using namespace std;
-
-//---------------------------------------------------------------------------
-
-static bool interrupted = false;
-
-void SignalHandler(int sig)
-{
-  interrupted = true;
-}
-
-//---------------------------------------------------------------------------
-
-int main(int argc, char *argv[])
-{
-  char appName[] = "DelphesHepMC2";
-  stringstream message;
-  FILE *inputFile = 0;
-  TFile *outputFile = 0;
-  TStopwatch readStopWatch, procStopWatch;
-  ExRootTreeWriter *treeWriter = 0;
-  ExRootTreeBranch *branchEvent = 0, *branchWeight = 0;
-  ExRootConfReader *confReader = 0;
-  Delphes *modularDelphes = 0;
-  DelphesFactory *factory = 0;
-  TObjArray *stableParticleOutputArray = 0, *allParticleOutputArray = 0, *partonOutputArray = 0;
-  DelphesHepMC2Reader *reader = 0;
-  Int_t i, maxEvents, skipEvents;
-  Long64_t length, eventCounter;
-
-  if(argc < 3)
-  {
-    cout << " Usage: " << appName << " config_file"
-         << " output_file"
-         << " [input_file(s)]" << endl;
-    cout << " config_file - configuration file in Tcl format," << endl;
-    cout << " output_file - output file in ROOT format," << endl;
-    cout << " input_file(s) - input file(s) in HepMC format," << endl;
-    cout << " with no input_file, or when input_file is -, read standard input." << endl;
-    return 1;
-  }
-
-  signal(SIGINT, SignalHandler);
-
-  gROOT->SetBatch();
-
-  int appargc = 1;
-  char *appargv[] = {appName};
-  TApplication app(appName, &appargc, appargv);
-
-  try
-  {
-    outputFile = TFile::Open(argv[2], "CREATE");
-
-    if(outputFile == NULL)
-    {
-      message << "can't create output file " << argv[2];
-      throw runtime_error(message.str());
-    }
-
-    treeWriter = new ExRootTreeWriter(outputFile, "Delphes");
-
-    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
-    branchWeight = treeWriter->NewBranch("Weight", Weight::Class());
-
-    confReader = new ExRootConfReader;
-    confReader->ReadFile(argv[1]);
-
-    maxEvents = confReader->GetInt("::MaxEvents", 0);
-    skipEvents = confReader->GetInt("::SkipEvents", 0);
-
-    if(maxEvents < 0)
-    {
-      throw runtime_error("MaxEvents must be zero or positive");
-    }
-
-    if(skipEvents < 0)
-    {
-      throw runtime_error("SkipEvents must be zero or positive");
-    }
-
-    modularDelphes = new Delphes("Delphes");
-    modularDelphes->SetConfReader(confReader);
-    modularDelphes->SetTreeWriter(treeWriter);
-
-    factory = modularDelphes->GetFactory();
-    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
-    stableParticleOutputArray = modularDelphes->ExportArray("stableParticles");
-    partonOutputArray = modularDelphes->ExportArray("partons");
-
-    reader = new DelphesHepMC2Reader;
-
-    modularDelphes->InitTask();
-
-    i = 3;
-    do
-    {
-      if(interrupted) break;
-
-      if(i == argc || strncmp(argv[i], "-", 2) == 0)
-      {
-        cout << "** Reading standard input" << endl;
-        inputFile = stdin;
-        length = -1;
-      }
-      else
-      {
-        cout << "** Reading " << argv[i] << endl;
-        inputFile = fopen(argv[i], "r");
-
-        if(inputFile == NULL)
-        {
-          message << "can't open " << argv[i];
-          throw runtime_error(message.str());
-        }
-
-        fseek(inputFile, 0L, SEEK_END);
-        length = ftello(inputFile);
-        fseek(inputFile, 0L, SEEK_SET);
-
-        if(length <= 0)
-        {
-          fclose(inputFile);
-          ++i;
-          continue;
-        }
-      }
-
-      reader->SetInputFile(inputFile);
-
-      ExRootProgressBar progressBar(length);
-
-      // Loop over all objects
-      eventCounter = 0;
-      treeWriter->Clear();
-      modularDelphes->Clear();
-      reader->Clear();
-      readStopWatch.Start();
-      while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray) && !interrupted)
-      {
-        if(reader->EventReady())
-        {
-          ++eventCounter;
-
-          readStopWatch.Stop();
-
-          if(eventCounter > skipEvents)
-          {
-            procStopWatch.Start();
-            modularDelphes->ProcessTask();
-            procStopWatch.Stop();
-
-            reader->AnalyzeEvent(branchEvent, eventCounter, &readStopWatch, &procStopWatch);
-            reader->AnalyzeWeight(branchWeight);
-
-            treeWriter->Fill();
-
-            treeWriter->Clear();
-          }
-
-          modularDelphes->Clear();
-          reader->Clear();
-
-          readStopWatch.Start();
-        }
-        progressBar.Update(ftello(inputFile), eventCounter);
-      }
-
-      fseek(inputFile, 0L, SEEK_END);
-      progressBar.Update(ftello(inputFile), eventCounter, kTRUE);
-      progressBar.Finish();
-
-      if(inputFile != stdin) fclose(inputFile);
-
-      ++i;
-    } while(i < argc);
-
-    modularDelphes->FinishTask();
-    treeWriter->Write();
-
-    cout << "** Exiting..." << endl;
-
-    delete reader;
-    delete modularDelphes;
-    delete confReader;
-    delete treeWriter;
-    delete outputFile;
-
-    return 0;
-  }
-  catch(runtime_error &e)
-  {
-    if(treeWriter) delete treeWriter;
-    if(outputFile) delete outputFile;
-    cerr << "** ERROR: " << e.what() << endl;
-    return 1;
-  }
-}
Index: readers/DelphesHepMC3.cpp
===================================================================
--- readers/DelphesHepMC3.cpp	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ 	(revision )
@@ -1,241 +1,0 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <iostream>
-#include <sstream>
-#include <stdexcept>
-
-#include <signal.h>
-
-#include "TApplication.h"
-#include "TROOT.h"
-
-#include "TDatabasePDG.h"
-#include "TFile.h"
-#include "TLorentzVector.h"
-#include "TObjArray.h"
-#include "TParticlePDG.h"
-#include "TStopwatch.h"
-
-#include "classes/DelphesClasses.h"
-#include "classes/DelphesFactory.h"
-#include "classes/DelphesHepMC3Reader.h"
-#include "modules/Delphes.h"
-
-#include "ExRootAnalysis/ExRootProgressBar.h"
-#include "ExRootAnalysis/ExRootTreeBranch.h"
-#include "ExRootAnalysis/ExRootTreeWriter.h"
-
-using namespace std;
-
-//---------------------------------------------------------------------------
-
-static bool interrupted = false;
-
-void SignalHandler(int sig)
-{
-  interrupted = true;
-}
-
-//---------------------------------------------------------------------------
-
-int main(int argc, char *argv[])
-{
-  char appName[] = "DelphesHepMC3";
-  stringstream message;
-  FILE *inputFile = 0;
-  TFile *outputFile = 0;
-  TStopwatch readStopWatch, procStopWatch;
-  ExRootTreeWriter *treeWriter = 0;
-  ExRootTreeBranch *branchEvent = 0, *branchWeight = 0;
-  ExRootConfReader *confReader = 0;
-  Delphes *modularDelphes = 0;
-  DelphesFactory *factory = 0;
-  TObjArray *stableParticleOutputArray = 0, *allParticleOutputArray = 0, *partonOutputArray = 0;
-  DelphesHepMC3Reader *reader = 0;
-  Int_t i, maxEvents, skipEvents;
-  Long64_t length, eventCounter;
-
-  if(argc < 3)
-  {
-    cout << " Usage: " << appName << " config_file"
-         << " output_file"
-         << " [input_file(s)]" << endl;
-    cout << " config_file - configuration file in Tcl format," << endl;
-    cout << " output_file - output file in ROOT format," << endl;
-    cout << " input_file(s) - input file(s) in HepMC format," << endl;
-    cout << " with no input_file, or when input_file is -, read standard input." << endl;
-    return 1;
-  }
-
-  signal(SIGINT, SignalHandler);
-
-  gROOT->SetBatch();
-
-  int appargc = 1;
-  char *appargv[] = {appName};
-  TApplication app(appName, &appargc, appargv);
-
-  try
-  {
-    outputFile = TFile::Open(argv[2], "CREATE");
-
-    if(outputFile == NULL)
-    {
-      message << "can't create output file " << argv[2];
-      throw runtime_error(message.str());
-    }
-
-    treeWriter = new ExRootTreeWriter(outputFile, "Delphes");
-
-    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
-    branchWeight = treeWriter->NewBranch("Weight", Weight::Class());
-
-    confReader = new ExRootConfReader;
-    confReader->ReadFile(argv[1]);
-
-    maxEvents = confReader->GetInt("::MaxEvents", 0);
-    skipEvents = confReader->GetInt("::SkipEvents", 0);
-
-    if(maxEvents < 0)
-    {
-      throw runtime_error("MaxEvents must be zero or positive");
-    }
-
-    if(skipEvents < 0)
-    {
-      throw runtime_error("SkipEvents must be zero or positive");
-    }
-
-    modularDelphes = new Delphes("Delphes");
-    modularDelphes->SetConfReader(confReader);
-    modularDelphes->SetTreeWriter(treeWriter);
-
-    factory = modularDelphes->GetFactory();
-    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
-    stableParticleOutputArray = modularDelphes->ExportArray("stableParticles");
-    partonOutputArray = modularDelphes->ExportArray("partons");
-
-    reader = new DelphesHepMC3Reader;
-
-    modularDelphes->InitTask();
-
-    i = 3;
-    do
-    {
-      if(interrupted) break;
-
-      if(i == argc || strncmp(argv[i], "-", 2) == 0)
-      {
-        cout << "** Reading standard input" << endl;
-        inputFile = stdin;
-        length = -1;
-      }
-      else
-      {
-        cout << "** Reading " << argv[i] << endl;
-        inputFile = fopen(argv[i], "r");
-
-        if(inputFile == NULL)
-        {
-          message << "can't open " << argv[i];
-          throw runtime_error(message.str());
-        }
-
-        fseek(inputFile, 0L, SEEK_END);
-        length = ftello(inputFile);
-        fseek(inputFile, 0L, SEEK_SET);
-
-        if(length <= 0)
-        {
-          fclose(inputFile);
-          ++i;
-          continue;
-        }
-      }
-
-      reader->SetInputFile(inputFile);
-
-      ExRootProgressBar progressBar(length);
-
-      // Loop over all objects
-      eventCounter = 0;
-      treeWriter->Clear();
-      modularDelphes->Clear();
-      reader->Clear();
-      readStopWatch.Start();
-      while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray) && !interrupted)
-      {
-        if(reader->EventReady())
-        {
-          ++eventCounter;
-
-          readStopWatch.Stop();
-
-          if(eventCounter > skipEvents)
-          {
-            procStopWatch.Start();
-            modularDelphes->ProcessTask();
-            procStopWatch.Stop();
-
-            reader->AnalyzeEvent(branchEvent, eventCounter, &readStopWatch, &procStopWatch);
-            reader->AnalyzeWeight(branchWeight);
-
-            treeWriter->Fill();
-
-            treeWriter->Clear();
-          }
-
-          modularDelphes->Clear();
-          reader->Clear();
-
-          readStopWatch.Start();
-        }
-        progressBar.Update(ftello(inputFile), eventCounter);
-      }
-
-      fseek(inputFile, 0L, SEEK_END);
-      progressBar.Update(ftello(inputFile), eventCounter, kTRUE);
-      progressBar.Finish();
-
-      if(inputFile != stdin) fclose(inputFile);
-
-      ++i;
-    } while(i < argc);
-
-    modularDelphes->FinishTask();
-    treeWriter->Write();
-
-    cout << "** Exiting..." << endl;
-
-    delete reader;
-    delete modularDelphes;
-    delete confReader;
-    delete treeWriter;
-    delete outputFile;
-
-    return 0;
-  }
-  catch(runtime_error &e)
-  {
-    if(treeWriter) delete treeWriter;
-    if(outputFile) delete outputFile;
-    cerr << "** ERROR: " << e.what() << endl;
-    return 1;
-  }
-}
Index: readers/DelphesLHEF.cpp
===================================================================
--- readers/DelphesLHEF.cpp	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ readers/DelphesLHEF.cpp	(revision d7d2da362406b9e37fdf238970417c94779b54b0)
@@ -1,44 +1,26 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
+#include <stdexcept>
 #include <iostream>
 #include <sstream>
-#include <stdexcept>
 
 #include <signal.h>
 
+#include "TROOT.h"
 #include "TApplication.h"
-#include "TROOT.h"
-
+
+#include "TFile.h"
+#include "TObjArray.h"
+#include "TStopwatch.h"
 #include "TDatabasePDG.h"
-#include "TFile.h"
+#include "TParticlePDG.h"
 #include "TLorentzVector.h"
-#include "TObjArray.h"
-#include "TParticlePDG.h"
-#include "TStopwatch.h"
-
+
+#include "modules/Delphes.h"
 #include "classes/DelphesClasses.h"
 #include "classes/DelphesFactory.h"
 #include "classes/DelphesLHEFReader.h"
-#include "modules/Delphes.h"
-
+
+#include "ExRootAnalysis/ExRootTreeWriter.h"
+#include "ExRootAnalysis/ExRootTreeBranch.h"
 #include "ExRootAnalysis/ExRootProgressBar.h"
-#include "ExRootAnalysis/ExRootTreeBranch.h"
-#include "ExRootAnalysis/ExRootTreeWriter.h"
 
 using namespace std;
@@ -63,5 +45,5 @@
   TStopwatch readStopWatch, procStopWatch;
   ExRootTreeWriter *treeWriter = 0;
-  ExRootTreeBranch *branchEvent = 0, *branchWeight = 0;
+  ExRootTreeBranch *branchEvent = 0;
   ExRootConfReader *confReader = 0;
   Delphes *modularDelphes = 0;
@@ -69,12 +51,10 @@
   TObjArray *stableParticleOutputArray = 0, *allParticleOutputArray = 0, *partonOutputArray = 0;
   DelphesLHEFReader *reader = 0;
-  Int_t i, maxEvents, skipEvents;
+  Int_t i;
   Long64_t length, eventCounter;
 
   if(argc < 3)
   {
-    cout << " Usage: " << appName << " config_file"
-         << " output_file"
-         << " [input_file(s)]" << endl;
+    cout << " Usage: " << appName << " config_file" << " output_file" << " [input_file(s)]" << endl;
     cout << " config_file - configuration file in Tcl format," << endl;
     cout << " output_file - output file in ROOT format," << endl;
@@ -105,21 +85,7 @@
 
     branchEvent = treeWriter->NewBranch("Event", LHEFEvent::Class());
-    branchWeight = treeWriter->NewBranch("Weight", LHEFWeight::Class());
 
     confReader = new ExRootConfReader;
     confReader->ReadFile(argv[1]);
-
-    maxEvents = confReader->GetInt("::MaxEvents", 0);
-    skipEvents = confReader->GetInt("::SkipEvents", 0);
-
-    if(maxEvents < 0)
-    {
-      throw runtime_error("MaxEvents must be zero or positive");
-    }
-
-    if(skipEvents < 0)
-    {
-      throw runtime_error("SkipEvents must be zero or positive");
-    }
 
     modularDelphes = new Delphes("Delphes");
@@ -180,5 +146,6 @@
       reader->Clear();
       readStopWatch.Start();
-      while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray) && !interrupted)
+      while(reader->ReadBlock(factory, allParticleOutputArray,
+        stableParticleOutputArray, partonOutputArray) && !interrupted)
       {
         if(reader->EventReady())
@@ -187,20 +154,13 @@
 
           readStopWatch.Stop();
-
-          if(eventCounter > skipEvents)
-          {
-            readStopWatch.Stop();
-            procStopWatch.Start();
-            modularDelphes->ProcessTask();
-            procStopWatch.Stop();
-
-            reader->AnalyzeEvent(branchEvent, eventCounter, &readStopWatch, &procStopWatch);
-            reader->AnalyzeWeight(branchWeight);
-
-            treeWriter->Fill();
-
-            treeWriter->Clear();
-          }
-
+          procStopWatch.Start();
+          modularDelphes->ProcessTask();
+          procStopWatch.Stop();
+
+          reader->AnalyzeEvent(branchEvent, eventCounter, &readStopWatch, &procStopWatch);
+
+          treeWriter->Fill();
+
+          treeWriter->Clear();
           modularDelphes->Clear();
           reader->Clear();
@@ -218,5 +178,6 @@
 
       ++i;
-    } while(i < argc);
+    }
+    while(i < argc);
 
     modularDelphes->FinishTask();
Index: readers/DelphesProIO.cpp
===================================================================
--- readers/DelphesProIO.cpp	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ 	(revision )
@@ -1,437 +1,0 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *  @author S.Chekanov (ANL)
- */
-
-#include <iostream>
-#include <memory>
-#include <sstream>
-#include <stdexcept>
-
-#include <map>
-
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "TApplication.h"
-#include "TROOT.h"
-
-#include "TDatabasePDG.h"
-#include "TFile.h"
-#include "TLorentzVector.h"
-#include "TObjArray.h"
-#include "TParticlePDG.h"
-#include "TStopwatch.h"
-
-#include "classes/DelphesClasses.h"
-#include "classes/DelphesFactory.h"
-#include "classes/DelphesStream.h"
-#include "modules/Delphes.h"
-
-#include "ExRootAnalysis/ExRootProgressBar.h"
-#include "ExRootAnalysis/ExRootTreeBranch.h"
-#include "ExRootAnalysis/ExRootTreeWriter.h"
-
-#include <proio/event.h>
-#include <proio/model/mc.pb.h>
-#include <proio/reader.h>
-namespace model = proio::model::mc;
-
-using namespace std;
-
-//---------------------------------------------------------------------------
-// This method dynamically checks the message type (varint or not) depending on
-// non-zero value of units momentumUnit and positionUnit.
-void ConvertInput(proio::Event *event, double momentumUnit, double positionUnit,
-  ExRootTreeBranch *branch, DelphesFactory *factory,
-  TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray,
-  TObjArray *partonOutputArray, TStopwatch *readStopWatch, TStopwatch *procStopWatch)
-{
-
-  HepMCEvent *element;
-  Candidate *candidate;
-  TDatabasePDG *pdg;
-  TParticlePDG *pdgParticle;
-  Int_t pdgCode;
-
-  Int_t pid, status;
-  Double_t px, py, pz, mass;
-  Double_t x, y, z, t;
-
-  pdg = TDatabasePDG::Instance();
-
-  // event information
-  element = static_cast<HepMCEvent *>(branch->NewEntry());
-
-  int nID = 0;
-  double weight = 0;
-  int process_id = 0;
-  auto mcentries = event->TaggedEntries("MCParameters");
-  for(uint64_t mcentryID : mcentries)
-  {
-    auto mcpar = dynamic_cast<proio::model::mc::MCParameters *>(event->GetEntry(mcentryID));
-    nID = mcpar->number();
-    weight = mcpar->weight();
-    process_id = mcpar->processid();
-    break; // consider only most generic from 1st entry
-  };
-
-  element->Number = nID;
-  element->ProcessID = process_id;
-  element->Weight = weight;
-
-  /*
-  // Pythia8 specific
-  element->MPI = mutableEvent->mpi();
-  element->Scale = mutableEvent->scale();
-  element->AlphaQED = mutableEvent->alpha_qed();
-  element->AlphaQCD = mutableEvent->alpha_qcd();
-  element->ID1 = mutableEvent->id1();
-  element->ID2 = mutableEvent->id2();
-  element->X1 = mutableEvent->x1();
-  element->X2 = mutableEvent->x2();
-  element->ScalePDF = mutableEvent->scale_pdf();
-  element->PDF1 = mutableEvent->pdf1();
-  element->PDF2 = mutableEvent->pdf2();
-*/
-
-  element->ReadTime = readStopWatch->RealTime();
-  element->ProcTime = procStopWatch->RealTime();
-
-  if(momentumUnit > 0 && positionUnit > 0)
-  {
-
-    auto entries = event->TaggedEntries("VarintPackedParticles");
-
-    for(uint64_t entryID : entries)
-    {
-
-      auto mutableParticles = dynamic_cast<model::VarintPackedParticles *>(event->GetEntry(entryID));
-
-      for(int i = 0; i < mutableParticles->pdg_size(); ++i)
-      {
-        pid = mutableParticles->pdg(i);
-        status = mutableParticles->status(i);
-        px = mutableParticles->px(i) / momentumUnit;
-        py = mutableParticles->py(i) / momentumUnit;
-        pz = mutableParticles->pz(i) / momentumUnit;
-        mass = mutableParticles->mass(i) / momentumUnit;
-        x = mutableParticles->x(i) / positionUnit;
-        y = mutableParticles->y(i) / positionUnit;
-        z = mutableParticles->z(i) / positionUnit;
-        t = mutableParticles->t(i) / positionUnit;
-
-        candidate = factory->NewCandidate();
-        candidate->PID = pid;
-        pdgCode = TMath::Abs(candidate->PID);
-        candidate->Status = status;
-        candidate->M1 = mutableParticles->parent1(i);
-        candidate->M2 = mutableParticles->parent2(i);
-        candidate->D1 = mutableParticles->child1(i);
-        candidate->D2 = mutableParticles->child2(i);
-        pdgParticle = pdg->GetParticle(pid);
-        candidate->Charge = mutableParticles->charge(i) / 3.0;
-        //candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
-        candidate->Mass = mass;
-        candidate->Momentum.SetXYZM(px, py, pz, mass);
-        candidate->Position.SetXYZT(x, y, z, t);
-        allParticleOutputArray->Add(candidate);
-        if(!pdgParticle) continue;
-
-        if(status == 1)
-        {
-          stableParticleOutputArray->Add(candidate);
-        }
-        else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
-        {
-          partonOutputArray->Add(candidate);
-        }
-      }
-    }
-  }
-  else
-  {
-
-    auto entries = event->TaggedEntries("Particle");
-
-    for(uint64_t entryID : entries)
-    {
-      auto part = dynamic_cast<model::Particle *>(event->GetEntry(entryID));
-      pid = part->pdg();
-      status = part->status();
-      model::XYZF pvector = part->p();
-      px = pvector.x();
-      py = pvector.y();
-      pz = pvector.z();
-      mass = part->mass();
-      auto v = part->vertex();
-      x = v.x();
-      y = v.y();
-      z = v.z();
-      t = v.t();
-
-      candidate = factory->NewCandidate();
-      candidate->PID = pid;
-      pdgCode = TMath::Abs(candidate->PID);
-      candidate->Status = status;
-
-      int M1 = 0;
-      int M2 = 0;
-      for(int k1 = 0; k1 < part->parent_size(); k1++)
-      {
-        if(k1 == 0)
-        {
-          auto mother = dynamic_cast<model::Particle *>(event->GetEntry(part->parent(0)));
-          M1 = mother->barcode();
-        }
-        if(k1 == 1)
-        {
-          auto mother = dynamic_cast<model::Particle *>(event->GetEntry(part->parent(1)));
-          M2 = mother->barcode();
-        }
-      }
-
-      int D1 = 0;
-      int D2 = 0;
-      for(int k1 = 0; k1 < part->child_size(); k1++)
-      {
-        if(k1 == 0)
-        {
-          auto child = dynamic_cast<model::Particle *>(event->GetEntry(part->child(0)));
-          D1 = child->barcode();
-        }
-
-        if(k1 == 1)
-        {
-          auto child = dynamic_cast<model::Particle *>(event->GetEntry(part->child(1)));
-          D2 = child->barcode();
-        };
-      }
-
-      candidate->M1 = M1;
-      candidate->M2 = M2;
-      candidate->D1 = D1;
-      candidate->D2 = D2;
-
-      pdgParticle = pdg->GetParticle(pid);
-      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
-      candidate->Mass = mass;
-
-      candidate->Momentum.SetXYZM(px, py, pz, mass);
-
-      candidate->Position.SetXYZT(x, y, z, t);
-
-      allParticleOutputArray->Add(candidate);
-
-      if(!pdgParticle) continue;
-
-      if(status == 1)
-      {
-        stableParticleOutputArray->Add(candidate);
-      }
-      else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
-      {
-        partonOutputArray->Add(candidate);
-      }
-    }
-
-  } // end particle type
-}
-
-//---------------------------------------------------------------------------
-
-static bool interrupted = false;
-
-void SignalHandler(int sig)
-{
-  interrupted = true;
-}
-
-//---------------------------------------------------------------------------
-
-int main(int argc, char *argv[])
-{
-  char appName[] = "DelphesProIO";
-  stringstream message;
-  proio::Reader *inputFile = 0;
-  TFile *outputFile = 0;
-  TStopwatch readStopWatch, procStopWatch;
-  ExRootTreeWriter *treeWriter = 0;
-  ExRootTreeBranch *branchEvent = 0;
-  ExRootConfReader *confReader = 0;
-  Delphes *modularDelphes = 0;
-  DelphesFactory *factory = 0;
-  TObjArray *allParticleOutputArray = 0, *stableParticleOutputArray = 0, *partonOutputArray = 0;
-  Int_t i;
-  Long64_t eventCounter, numberOfEvents;
-
-  if(argc < 4)
-  {
-    cout << " Usage: " << appName << " config_file"
-         << " output_file"
-         << " input_file(s)" << endl;
-    cout << " config_file - configuration file in Tcl format," << endl;
-    cout << " output_file - output file in ROOT format," << endl;
-    cout << " input_file(s) - input file(s) in ProIO format." << endl;
-    return 1;
-  }
-
-  signal(SIGINT, SignalHandler);
-
-  gROOT->SetBatch();
-
-  int appargc = 1;
-  char *appargv[] = {appName};
-  TApplication app(appName, &appargc, appargv);
-
-  try
-  {
-    outputFile = TFile::Open(argv[2], "CREATE");
-
-    if(outputFile == NULL)
-    {
-      message << "can't open " << argv[2] << endl;
-      throw runtime_error(message.str());
-    }
-
-    treeWriter = new ExRootTreeWriter(outputFile, "Delphes");
-
-    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
-
-    confReader = new ExRootConfReader;
-    confReader->ReadFile(argv[1]);
-
-    modularDelphes = new Delphes("Delphes");
-    modularDelphes->SetConfReader(confReader);
-    modularDelphes->SetTreeWriter(treeWriter);
-
-    factory = modularDelphes->GetFactory();
-    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
-    stableParticleOutputArray = modularDelphes->ExportArray("stableParticles");
-    partonOutputArray = modularDelphes->ExportArray("partons");
-
-    modularDelphes->InitTask();
-
-    for(i = 3; i < argc && !interrupted; ++i)
-    {
-      cout << "** INFO: Reading " << argv[i] << endl;
-
-      inputFile = new proio::Reader(argv[i]);
-
-      if(inputFile == NULL)
-      {
-        message << "can't open " << argv[i] << endl;
-        throw runtime_error(message.str());
-      }
-
-      /*
-// this is slow method, but general
-      inputFile->SeekToStart(); 
-      int nn=0;
-      auto event = new proio::Event();
-      while(inputFile->Next(event)){
-            auto entries = event->TaggedEntries("Particle");
-            if (entries.size()>0) nn++;
-      }
-*/
-
-      auto event = new proio::Event();
-
-      double varint_energy = 0;
-      double varint_length = 0;
-
-      auto max_n_events = std::numeric_limits<uint64_t>::max();
-      auto nn = inputFile->Skip(max_n_events);
-      cout << "** INFO: " << nn - 1 << " events found in ProIO file" << endl;
-      inputFile->SeekToStart();
-      numberOfEvents = nn - 1; // last event has only metadata (no particle record)
-
-      if(numberOfEvents <= 0) continue;
-
-      ExRootProgressBar progressBar(numberOfEvents - 1);
-
-      // Loop over all objects
-      modularDelphes->Clear();
-      treeWriter->Clear();
-      readStopWatch.Start();
-
-      for(eventCounter = 0; eventCounter < numberOfEvents && !interrupted; ++eventCounter)
-      {
-        inputFile->Next(event);
-        if(event == 0) continue;
-
-        // get metadata
-        if(eventCounter == 0)
-        {
-          auto metadata = event->Metadata();
-          std::cout << "** INFO: ProIO file metadata:" << std::endl;
-          for(auto element : metadata)
-          {
-            string key = (string)element.first;
-            string value = (string)(*element.second);
-            std::cout << "** INFO:   " << key << " = " << value << std::endl;
-            if(key == "info:varint_energy") varint_energy = std::stod(value);
-            if(key == "info:varint_length") varint_length = std::stod(value);
-          }
-        }
-
-        readStopWatch.Stop();
-
-        procStopWatch.Start();
-
-        ConvertInput(event, varint_energy, varint_length,
-          branchEvent, factory,
-          allParticleOutputArray, stableParticleOutputArray,
-          partonOutputArray, &readStopWatch, &procStopWatch);
-
-        modularDelphes->ProcessTask();
-        procStopWatch.Stop();
-
-        treeWriter->Fill();
-
-        modularDelphes->Clear();
-        treeWriter->Clear();
-
-        readStopWatch.Start();
-        progressBar.Update(eventCounter);
-      }
-
-      progressBar.Update(eventCounter, eventCounter, kTRUE);
-      progressBar.Finish();
-
-      delete inputFile;
-    }
-
-    modularDelphes->FinishTask();
-    treeWriter->Write();
-
-    cout << "** Exiting..." << endl;
-
-    delete modularDelphes;
-    delete confReader;
-    delete treeWriter;
-    return 0;
-  }
-  catch(runtime_error &e)
-  {
-    if(treeWriter) delete treeWriter;
-    if(outputFile) delete outputFile;
-    cerr << "** ERROR: " << e.what() << endl;
-    return 1;
-  }
-}
Index: readers/DelphesProMC.cpp
===================================================================
--- readers/DelphesProMC.cpp	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ 	(revision )
@@ -1,315 +1,0 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <iostream>
-#include <memory>
-#include <sstream>
-#include <stdexcept>
-
-#include <map>
-
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "TApplication.h"
-#include "TROOT.h"
-
-#include "TDatabasePDG.h"
-#include "TFile.h"
-#include "TLorentzVector.h"
-#include "TObjArray.h"
-#include "TParticlePDG.h"
-#include "TStopwatch.h"
-
-#include "classes/DelphesClasses.h"
-#include "classes/DelphesFactory.h"
-#include "classes/DelphesStream.h"
-#include "modules/Delphes.h"
-
-#include "ExRootAnalysis/ExRootProgressBar.h"
-#include "ExRootAnalysis/ExRootTreeBranch.h"
-#include "ExRootAnalysis/ExRootTreeWriter.h"
-
-#include "ProMC.pb.h"
-#include "ProMCBook.h"
-#include "ProMCHeader.pb.h"
-
-using namespace std;
-
-//---------------------------------------------------------------------------
-
-void ConvertInput(ProMCEvent &event, double momentumUnit, double positionUnit,
-  ExRootTreeBranch *branch, DelphesFactory *factory,
-  TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray,
-  TObjArray *partonOutputArray, TStopwatch *readStopWatch, TStopwatch *procStopWatch)
-{
-  Int_t i;
-
-  ProMCEvent_Event *mutableEvent;
-  ProMCEvent_Particles *mutableParticles;
-
-  HepMCEvent *element;
-  Candidate *candidate;
-  TDatabasePDG *pdg;
-  TParticlePDG *pdgParticle;
-  Int_t pdgCode;
-
-  Int_t pid, status;
-  Double_t px, py, pz, mass;
-  Double_t x, y, z, t;
-
-  pdg = TDatabasePDG::Instance();
-
-  // event information
-  mutableEvent = event.mutable_event();
-
-  element = static_cast<HepMCEvent *>(branch->NewEntry());
-
-  element->Number = mutableEvent->number();
-
-  element->ProcessID = mutableEvent->process_id();
-  element->MPI = mutableEvent->mpi();
-  element->Weight = mutableEvent->weight();
-  element->Scale = mutableEvent->scale();
-  element->AlphaQED = mutableEvent->alpha_qed();
-  element->AlphaQCD = mutableEvent->alpha_qcd();
-
-  element->ID1 = mutableEvent->id1();
-  element->ID2 = mutableEvent->id2();
-  element->X1 = mutableEvent->x1();
-  element->X2 = mutableEvent->x2();
-  element->ScalePDF = mutableEvent->scale_pdf();
-  element->PDF1 = mutableEvent->pdf1();
-  element->PDF2 = mutableEvent->pdf2();
-
-  element->ReadTime = readStopWatch->RealTime();
-  element->ProcTime = procStopWatch->RealTime();
-
-  mutableParticles = event.mutable_particles();
-
-  for(i = 0; i < mutableParticles->pdg_id_size(); ++i)
-  {
-    pid = mutableParticles->pdg_id(i);
-    status = mutableParticles->status(i);
-
-    px = mutableParticles->px(i) / momentumUnit;
-    py = mutableParticles->py(i) / momentumUnit;
-    pz = mutableParticles->pz(i) / momentumUnit;
-    mass = mutableParticles->mass(i) / momentumUnit;
-    x = mutableParticles->x(i) / positionUnit;
-    y = mutableParticles->y(i) / positionUnit;
-    z = mutableParticles->z(i) / positionUnit;
-    t = mutableParticles->t(i) / positionUnit;
-
-    candidate = factory->NewCandidate();
-
-    candidate->PID = pid;
-    pdgCode = TMath::Abs(candidate->PID);
-
-    candidate->Status = status;
-
-    candidate->IsPU = 0;
-    if(mutableParticles->barcode(i) > 0) candidate->IsPU = 1; // pileup particle
-
-    candidate->M1 = mutableParticles->mother1(i);
-    candidate->M2 = mutableParticles->mother2(i);
-
-    candidate->D1 = mutableParticles->daughter1(i);
-    candidate->D2 = mutableParticles->daughter2(i);
-
-    pdgParticle = pdg->GetParticle(pid);
-    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
-    candidate->Mass = mass;
-
-    candidate->Momentum.SetXYZM(px, py, pz, mass);
-
-    candidate->Position.SetXYZT(x, y, z, t);
-
-    allParticleOutputArray->Add(candidate);
-
-    if(!pdgParticle) continue;
-
-    if(status == 1)
-    {
-      stableParticleOutputArray->Add(candidate);
-    }
-    else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
-    {
-      partonOutputArray->Add(candidate);
-    }
-  }
-}
-
-//---------------------------------------------------------------------------
-
-static bool interrupted = false;
-
-void SignalHandler(int sig)
-{
-  interrupted = true;
-}
-
-//---------------------------------------------------------------------------
-
-int main(int argc, char *argv[])
-{
-  char appName[] = "DelphesProMC";
-  stringstream message;
-  ProMCBook *inputFile = 0;
-  TFile *outputFile = 0;
-  TStopwatch readStopWatch, procStopWatch;
-  ExRootTreeWriter *treeWriter = 0;
-  ExRootTreeBranch *branchEvent = 0;
-  ExRootConfReader *confReader = 0;
-  Delphes *modularDelphes = 0;
-  DelphesFactory *factory = 0;
-  TObjArray *allParticleOutputArray = 0, *stableParticleOutputArray = 0, *partonOutputArray = 0;
-  Int_t i;
-  Long64_t eventCounter, numberOfEvents;
-  double momentumUnit = 1.0, positionUnit = 1.0;
-
-  if(argc < 4)
-  {
-    cout << " Usage: " << appName << " config_file"
-         << " output_file"
-         << " input_file(s)" << endl;
-    cout << " config_file - configuration file in Tcl format," << endl;
-    cout << " output_file - output file in ROOT format," << endl;
-    cout << " input_file(s) - input file(s) in ProMC format." << endl;
-    return 1;
-  }
-
-  signal(SIGINT, SignalHandler);
-
-  gROOT->SetBatch();
-
-  int appargc = 1;
-  char *appargv[] = {appName};
-  TApplication app(appName, &appargc, appargv);
-
-  try
-  {
-    outputFile = TFile::Open(argv[2], "CREATE");
-
-    if(outputFile == NULL)
-    {
-      message << "can't open " << argv[2] << endl;
-      throw runtime_error(message.str());
-    }
-
-    treeWriter = new ExRootTreeWriter(outputFile, "Delphes");
-
-    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
-
-    confReader = new ExRootConfReader;
-    confReader->ReadFile(argv[1]);
-
-    modularDelphes = new Delphes("Delphes");
-    modularDelphes->SetConfReader(confReader);
-    modularDelphes->SetTreeWriter(treeWriter);
-
-    factory = modularDelphes->GetFactory();
-    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
-    stableParticleOutputArray = modularDelphes->ExportArray("stableParticles");
-    partonOutputArray = modularDelphes->ExportArray("partons");
-
-    modularDelphes->InitTask();
-
-    for(i = 3; i < argc && !interrupted; ++i)
-    {
-      cout << "** Reading " << argv[i] << endl;
-
-      // use 64 bit
-      //inputFile = new ProMCBook(argv[i], "r", true);
-
-      //use 32 bit zip (faster but limitted to 64k events)
-      inputFile = new ProMCBook(argv[i], "r");
-
-      ProMCHeader header = inputFile->getHeader();
-
-      momentumUnit = static_cast<double>(header.momentumunit());
-      positionUnit = static_cast<double>(header.lengthunit());
-
-      if(inputFile == NULL)
-      {
-        message << "can't open " << argv[i] << endl;
-        throw runtime_error(message.str());
-      }
-
-      numberOfEvents = inputFile->getEvents();
-
-      if(numberOfEvents <= 0) continue;
-
-      ExRootProgressBar progressBar(numberOfEvents - 1);
-
-      // Loop over all objects
-      modularDelphes->Clear();
-      treeWriter->Clear();
-      readStopWatch.Start();
-      for(eventCounter = 0; eventCounter < numberOfEvents && !interrupted; ++eventCounter)
-      {
-        if(inputFile->next() != 0) continue;
-        ProMCEvent event = inputFile->get();
-
-        readStopWatch.Stop();
-
-        procStopWatch.Start();
-        ConvertInput(event, momentumUnit, positionUnit,
-          branchEvent, factory,
-          allParticleOutputArray, stableParticleOutputArray,
-          partonOutputArray, &readStopWatch, &procStopWatch);
-        modularDelphes->ProcessTask();
-        procStopWatch.Stop();
-
-        treeWriter->Fill();
-
-        modularDelphes->Clear();
-        treeWriter->Clear();
-
-        readStopWatch.Start();
-        progressBar.Update(eventCounter);
-      }
-
-      progressBar.Update(eventCounter, eventCounter, kTRUE);
-      progressBar.Finish();
-
-      inputFile->close();
-      delete inputFile;
-    }
-
-    modularDelphes->FinishTask();
-    treeWriter->Write();
-
-    cout << "** Exiting..." << endl;
-
-    delete modularDelphes;
-    delete confReader;
-    delete treeWriter;
-    delete outputFile;
-
-    return 0;
-  }
-  catch(runtime_error &e)
-  {
-    if(treeWriter) delete treeWriter;
-    if(outputFile) delete outputFile;
-    cerr << "** ERROR: " << e.what() << endl;
-    return 1;
-  }
-}
Index: readers/DelphesProMC.py
===================================================================
--- readers/DelphesProMC.py	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ 	(revision )
@@ -1,212 +1,0 @@
-#!/usr/bin/env python
-
-import sys
-
-import urllib2
-import zipfile
-
-import ROOT
-
-import ProMCHeader_pb2
-import ProMC_pb2
-
-################################################################################
-# HttpFile class is written by Eli Carter (retracile)
-# http://stackoverflow.com/a/7852229
-
-class HttpFile(object):
-  def __init__(self, url):
-    self.url = url
-    self.offset = 0
-    self.length = -1
-
-  def size(self):
-    if self.length < 0:
-      f = urllib2.urlopen(self.url)
-      self.length = int(f.headers["Content-length"])
-    return self.length
-
-  def read(self, count = -1):
-    req = urllib2.Request(self.url)
-    if count < 0:
-      end = self.size() - 1
-    else:
-      end = self.offset + count - 1
-    req.headers['Range'] = "bytes=%s-%s" % (self.offset, end)
-    f = urllib2.urlopen(req)
-    data = f.read()
-    # FIXME: should check that we got the range expected, etc.
-    chunk = len(data)
-    if count >= 0:
-      assert chunk == count
-    self.offset += chunk
-    return data
-
-  def seek(self, offset, whence = 0):
-    if whence == 0:
-      self.offset = offset
-    elif whence == 1:
-      self.offset += offset
-    elif whence == 2:
-      self.offset = self.size() + offset
-    else:
-      raise Exception("Invalid whence")
-
-  def tell(self):
-    return self.offset
-
-################################################################################
-
-def ConvertInput(name, momentumUnit, lengthUnit, branch, factory,
-  allParticleOutputArray, stableParticleOutputArray, partonOutputArray):
-
-  pdg = ROOT.TDatabasePDG.Instance()
-
-  data = ProMC_pb2.ProMCEvent()
-  data.ParseFromString(zip.read(name))
-
-  event = data.event
-  particles = data.particles
-
-  element = branch.NewEntry()
-
-  element.Number = event.Number[0] if event.Number else 0
-  element.ProcessID = event.Process_ID[0] if event.Process_ID else 0
-  element.MPI = event.MPI[0] if event.MPI else 0
-#  element.Weight = event.Weight[0] if event.Weight else 0
-  element.Scale = event.Scale[0] if event.Scale else 0
-  element.AlphaQED = event.Alpha_QED[0] if event.Alpha_QED else 0
-  element.AlphaQCD = event.Alpha_QCD[0] if event.Alpha_QCD else 0
-  element.ID1 = event.ID1[0] if event.ID1 else 0
-  element.ID2 = event.ID2[0] if event.ID2 else 0
-  element.X1 = event.X1[0] if event.X1 else 0
-  element.X2 = event.X2[0] if event.X2 else 0
-  element.ScalePDF = event.Scale_PDF[0] if event.Scale_PDF else 0
-  element.PDF1 = event.PDF1[0] if event.PDF1 else 0
-  element.PDF2 = event.PDF2[0] if event.PDF2 else 0
-
-  for i in range(len(particles.pdg_id)):
-    pid = particles.pdg_id[i]
-    status = particles.status[i]
-    px = particles.Px[i]
-    py = particles.Py[i]
-    pz = particles.Pz[i]
-    mass = particles.mass[i]
-
-    x = particles.X[i]
-    y = particles.Y[i]
-    z = particles.Z[i]
-    t = particles.T[i]
-
-    candidate = factory.NewCandidate()
-
-    candidate.PID = pid
-    pdgCode = ROOT.TMath.Abs(candidate.PID)
-
-    candidate.Status = status
-
-    candidate.M1 = particles.mother1[i] if particles.mother1[i] < sys.maxint else -1
-    candidate.M2 = particles.mother2[i] if particles.mother2[i] < sys.maxint else -1
-
-    candidate.D1 = particles.daughter1[i] if particles.daughter1[i] < sys.maxint else -1
-    candidate.D2 = particles.daughter2[i] if particles.daughter2[i] < sys.maxint else -1
-
-    candidate.Mass = mass
-
-    candidate.Momentum.SetXYZM(px, py, pz, mass)
-
-    candidate.Position.SetXYZT(x, y, z, t)
-
-    pdgParticle = pdg.GetParticle(pid)
-    if pdgParticle == None:
-      candidate.Charge = -999
-      continue
-    else:
-      candidate.Charge = int(pdgParticle.Charge()/3.0)
-
-    allParticleOutputArray.Add(candidate)
-
-    if status == 1:
-      stableParticleOutputArray.Add(candidate)
-    elif pdgCode <= 5 or pdgCode == 21 or pdgCode == 15:
-      partonOutputArray.Add(candidate)
-
-################################################################################
-
-if len(sys.argv) < 4:
-  print " Usage: DelphesProMC.py config_file output_file input_file(s)"
-  sys.exit(1)
-
-ROOT.gSystem.Load('libDelphes')
-
-outputFile = ROOT.TFile(sys.argv[2], "CREATE")
-
-if not outputFile.IsOpen():
-  print "** ERROR: can't open", sys.argv[2]
-  sys.exit(1)
-
-treeWriter = ROOT.ExRootTreeWriter(outputFile, "Delphes")
-
-branchEvent = treeWriter.NewBranch("Event", ROOT.HepMCEvent.Class())
-
-confReader = ROOT.ExRootConfReader()
-confReader.ReadFile(sys.argv[1])
-
-modularDelphes = ROOT.Delphes("Delphes")
-modularDelphes.SetConfReader(confReader)
-modularDelphes.SetTreeWriter(treeWriter)
-
-factory = modularDelphes.GetFactory()
-allParticleOutputArray = modularDelphes.ExportArray("allParticles")
-stableParticleOutputArray = modularDelphes.ExportArray("stableParticles")
-partonOutputArray = modularDelphes.ExportArray("partons")
-
-modularDelphes.InitTask()
-
-for fileName in sys.argv[3:]:
-  print "** Reading", fileName
-
-  if fileName.startswith("http://"):
-    file = HttpFile(fileName)
-  else:
-    file = open(fileName)
-
-  zip = zipfile.ZipFile(file)
-
-  numberOfEvents = len(zip.namelist())
-  if numberOfEvents <= 0: continue
-
-  progressBar = ROOT.ExRootProgressBar(numberOfEvents - 1)
-
-  # retrive information from the header file
-  header = ProMCHeader_pb2.ProMCHeader()
-  header.ParseFromString(zip.read("header"))
-  momentumUnit = float(header.MomentumUnit)
-  lengthUnit = float(header.LengthUnit)
-
-  modularDelphes.Clear()
-  treeWriter.Clear()
-  eventCounter = 0
-  for name in zip.namelist():
-    eventCounter += 1
-    if not name.isdigit(): continue
-
-    ConvertInput(name, momentumUnit, lengthUnit, branchEvent, factory,
-      allParticleOutputArray, stableParticleOutputArray, partonOutputArray)
-
-    modularDelphes.ProcessTask()
-
-    treeWriter.Fill()
-
-    modularDelphes.Clear()
-    treeWriter.Clear()
-    progressBar.Update(eventCounter)
-
-  progressBar.Update(eventCounter, eventCounter, ROOT.kTRUE)
-  progressBar.Finish()
-  zip.close()
-
-modularDelphes.FinishTask()
-treeWriter.Write()
-
-del treeWriter
Index: readers/DelphesPythia8.cpp
===================================================================
--- readers/DelphesPythia8.cpp	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ 	(revision )
@@ -1,447 +1,0 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <iostream>
-#include <sstream>
-#include <stdexcept>
-#include <string>
-
-#include <signal.h>
-
-#include "Pythia.h"
-#include "Pythia8Plugins/CombineMatchingInput.h"
-
-#include "TApplication.h"
-#include "TROOT.h"
-
-#include "TDatabasePDG.h"
-#include "TFile.h"
-#include "TLorentzVector.h"
-#include "TObjArray.h"
-#include "TParticlePDG.h"
-#include "TStopwatch.h"
-
-#include "classes/DelphesClasses.h"
-#include "classes/DelphesFactory.h"
-#include "classes/DelphesLHEFReader.h"
-#include "modules/Delphes.h"
-
-#include "ExRootAnalysis/ExRootProgressBar.h"
-#include "ExRootAnalysis/ExRootTreeBranch.h"
-#include "ExRootAnalysis/ExRootTreeWriter.h"
-
-using namespace std;
-
-//---------------------------------------------------------------------------
-
-void ConvertInput(Long64_t eventCounter, Pythia8::Pythia *pythia,
-  ExRootTreeBranch *branch, DelphesFactory *factory,
-  TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray,
-  TStopwatch *readStopWatch, TStopwatch *procStopWatch)
-{
-  int i;
-
-  HepMCEvent *element;
-  Candidate *candidate;
-  TDatabasePDG *pdg;
-  TParticlePDG *pdgParticle;
-  Int_t pdgCode;
-
-  Int_t pid, status;
-  Double_t px, py, pz, e, mass;
-  Double_t x, y, z, t;
-
-  // event information
-  element = static_cast<HepMCEvent *>(branch->NewEntry());
-
-  element->Number = eventCounter;
-
-  element->ProcessID = pythia->info.code();
-  element->MPI = 1;
-  element->Weight = pythia->info.weight();
-  element->Scale = pythia->info.QRen();
-  element->AlphaQED = pythia->info.alphaEM();
-  element->AlphaQCD = pythia->info.alphaS();
-
-  element->ID1 = pythia->info.id1();
-  element->ID2 = pythia->info.id2();
-  element->X1 = pythia->info.x1();
-  element->X2 = pythia->info.x2();
-  element->ScalePDF = pythia->info.QFac();
-  element->PDF1 = pythia->info.pdf1();
-  element->PDF2 = pythia->info.pdf2();
-
-  element->ReadTime = readStopWatch->RealTime();
-  element->ProcTime = procStopWatch->RealTime();
-
-  pdg = TDatabasePDG::Instance();
-
-  for(i = 1; i < pythia->event.size(); ++i)
-  {
-    Pythia8::Particle &particle = pythia->event[i];
-
-    pid = particle.id();
-    status = particle.statusHepMC();
-    px = particle.px();
-    py = particle.py();
-    pz = particle.pz();
-    e = particle.e();
-    mass = particle.m();
-    x = particle.xProd();
-    y = particle.yProd();
-    z = particle.zProd();
-    t = particle.tProd();
-
-    candidate = factory->NewCandidate();
-
-    candidate->PID = pid;
-    pdgCode = TMath::Abs(candidate->PID);
-
-    candidate->Status = status;
-
-    candidate->M1 = particle.mother1() - 1;
-    candidate->M2 = particle.mother2() - 1;
-
-    candidate->D1 = particle.daughter1() - 1;
-    candidate->D2 = particle.daughter2() - 1;
-
-    pdgParticle = pdg->GetParticle(pid);
-    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
-    candidate->Mass = mass;
-
-    candidate->Momentum.SetPxPyPzE(px, py, pz, e);
-
-    candidate->Position.SetXYZT(x, y, z, t);
-
-    allParticleOutputArray->Add(candidate);
-
-    if(!pdgParticle) continue;
-
-    if(status == 1)
-    {
-      stableParticleOutputArray->Add(candidate);
-    }
-    else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
-    {
-      partonOutputArray->Add(candidate);
-    }
-  }
-}
-
-//---------------------------------------------------------------------------
-
-static bool interrupted = false;
-
-void SignalHandler(int sig)
-{
-  interrupted = true;
-}
-
-//---------------------------------------------------------------------------
-
-/*
-Single-particle gun. The particle must be a colour singlet.
-Input: flavour, energy, direction (theta, phi).
-If theta < 0 then random choice over solid angle.
-Optional final argument to put particle at rest => E = m.
-from pythia8 example 21
-*/
-
-void fillParticle(int id, double pMax, double etaMax,
-  Pythia8::Event &event, Pythia8::ParticleData &pdt, Pythia8::Rndm &rndm)
-{
-  // Reset event record to allow for new event.
-  event.reset();
-
-  // Generate uniform pt and eta.
-  double pt, eta, phi, pp, ee, mm;
-
-  // pMin = 0.1 GeV for single particles
-  pp = pow(10, -1.0 + (log10(pMax) + 1.0) * rndm.flat());
-  eta = (2.0 * rndm.flat() - 1.0) * etaMax;
-  phi = 2.0 * M_PI * rndm.flat();
-  mm = pdt.mSel(id);
-  ee = Pythia8::sqrtpos(pp * pp + mm * mm);
-  pt = pp / cosh(eta);
-
-  // Store the particle in the event record.
-  event.append(id, 1, 0, 0, pt * cos(phi), pt * sin(phi), pt * sinh(eta), ee, mm);
-}
-
-//---------------------------------------------------------------------------
-
-void fillPartons(int id, double pMax, double etaMax,
-  Pythia8::Event &event, Pythia8::ParticleData &pdt, Pythia8::Rndm &rndm)
-{
-  // Reset event record to allow for new event.
-  event.reset();
-
-  // Generate uniform pt and eta.
-  double pt, eta, phi, pp, ee, mm;
-
-  // pMin = 1 GeV for jets
-  pp = pow(10, log10(pMax) * rndm.flat());
-  eta = (2.0 * rndm.flat() - 1.0) * etaMax;
-  phi = 2.0 * M_PI * rndm.flat();
-  mm = pdt.mSel(id);
-  ee = Pythia8::sqrtpos(pp * pp + mm * mm);
-  pt = pp / cosh(eta);
-
-  if((id == 4 || id == 5) && pt < 10.0) return;
-
-  if(id == 21)
-  {
-    event.append(21, 23, 101, 102, pt * cos(phi), pt * sin(phi), pt * sinh(eta), ee);
-    event.append(21, 23, 102, 101, -pt * cos(phi), -pt * sin(phi), -pt * sinh(eta), ee);
-  }
-  else
-  {
-    event.append(id, 23, 101, 0, pt * cos(phi), pt * sin(phi), pt * sinh(eta), ee, mm);
-    event.append(-id, 23, 0, 101, -pt * cos(phi), -pt * sin(phi), -pt * sinh(eta), ee, mm);
-  }
-}
-
-//---------------------------------------------------------------------------
-
-int main(int argc, char *argv[])
-{
-  char appName[] = "DelphesPythia8";
-  stringstream message;
-  FILE *inputFile = 0;
-  TFile *outputFile = 0;
-  TStopwatch readStopWatch, procStopWatch;
-  ExRootTreeWriter *treeWriter = 0;
-  ExRootTreeBranch *branchEvent = 0;
-  ExRootTreeBranch *branchEventLHEF = 0, *branchWeightLHEF = 0;
-  ExRootConfReader *confReader = 0;
-  Delphes *modularDelphes = 0;
-  DelphesFactory *factory = 0;
-  TObjArray *stableParticleOutputArray = 0, *allParticleOutputArray = 0, *partonOutputArray = 0;
-  TObjArray *stableParticleOutputArrayLHEF = 0, *allParticleOutputArrayLHEF = 0, *partonOutputArrayLHEF = 0;
-  DelphesLHEFReader *reader = 0;
-  Long64_t eventCounter, errorCounter;
-  Long64_t numberOfEvents, timesAllowErrors;
-  Bool_t spareFlag1;
-  Int_t spareMode1;
-  Double_t spareParm1, spareParm2;
-
-  Pythia8::Pythia *pythia = 0;
-
-  // for matching
-  Pythia8::CombineMatchingInput *combined = 0;
-  Pythia8::UserHooks *matching = 0;
-
-  if(argc != 4)
-  {
-    cout << " Usage: " << appName << " config_file"
-         << " pythia_card"
-         << " output_file" << endl;
-    cout << " config_file - configuration file in Tcl format," << endl;
-    cout << " pythia_card - Pythia8 configuration file," << endl;
-    cout << " output_file - output file in ROOT format." << endl;
-    return 1;
-  }
-
-  signal(SIGINT, SignalHandler);
-
-  gROOT->SetBatch();
-
-  int appargc = 1;
-  char *appargv[] = {appName};
-  TApplication app(appName, &appargc, appargv);
-
-  try
-  {
-    outputFile = TFile::Open(argv[3], "CREATE");
-
-    if(outputFile == NULL)
-    {
-      message << "can't create output file " << argv[3];
-      throw runtime_error(message.str());
-    }
-
-    treeWriter = new ExRootTreeWriter(outputFile, "Delphes");
-
-    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
-
-    confReader = new ExRootConfReader;
-    confReader->ReadFile(argv[1]);
-
-    modularDelphes = new Delphes("Delphes");
-    modularDelphes->SetConfReader(confReader);
-    modularDelphes->SetTreeWriter(treeWriter);
-
-    factory = modularDelphes->GetFactory();
-    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
-    stableParticleOutputArray = modularDelphes->ExportArray("stableParticles");
-    partonOutputArray = modularDelphes->ExportArray("partons");
-
-    // Initialize Pythia
-    pythia = new Pythia8::Pythia;
-
-    // jet matching
-#if PYTHIA_VERSION_INTEGER < 8300
-    matching = combined->getHook(*pythia);
-    if(!matching)
-    {
-      throw runtime_error("can't do matching");
-    }
-    pythia->setUserHooksPtr(matching);
-#endif
-
-    if(pythia == NULL)
-    {
-      throw runtime_error("can't create Pythia instance");
-    }
-
-    // Read in commands from configuration file
-    if(!pythia->readFile(argv[2]))
-    {
-      message << "can't read Pythia8 configuration file " << argv[2] << endl;
-      throw runtime_error(message.str());
-    }
-
-    // Extract settings to be used in the main program
-    numberOfEvents = pythia->mode("Main:numberOfEvents");
-    timesAllowErrors = pythia->mode("Main:timesAllowErrors");
-
-    spareFlag1 = pythia->flag("Main:spareFlag1");
-    spareMode1 = pythia->mode("Main:spareMode1");
-    spareParm1 = pythia->parm("Main:spareParm1");
-    spareParm2 = pythia->parm("Main:spareParm2");
-
-    // Check if particle gun
-    if(!spareFlag1)
-    {
-      inputFile = fopen(pythia->word("Beams:LHEF").c_str(), "r");
-      if(inputFile)
-      {
-        reader = new DelphesLHEFReader;
-        reader->SetInputFile(inputFile);
-
-        branchEventLHEF = treeWriter->NewBranch("EventLHEF", LHEFEvent::Class());
-        branchWeightLHEF = treeWriter->NewBranch("WeightLHEF", LHEFWeight::Class());
-
-        allParticleOutputArrayLHEF = modularDelphes->ExportArray("allParticlesLHEF");
-        stableParticleOutputArrayLHEF = modularDelphes->ExportArray("stableParticlesLHEF");
-        partonOutputArrayLHEF = modularDelphes->ExportArray("partonsLHEF");
-      }
-    }
-
-    modularDelphes->InitTask();
-
-    pythia->init();
-
-    // ExRootProgressBar progressBar(numberOfEvents - 1);
-    ExRootProgressBar progressBar(-1);
-
-    // Loop over all events
-    errorCounter = 0;
-    treeWriter->Clear();
-    modularDelphes->Clear();
-    readStopWatch.Start();
-    for(eventCounter = 0; eventCounter < numberOfEvents && !interrupted; ++eventCounter)
-    {
-      while(reader && reader->ReadBlock(factory, allParticleOutputArrayLHEF, stableParticleOutputArrayLHEF, partonOutputArrayLHEF) && !reader->EventReady())
-        ;
-
-      if(spareFlag1)
-      {
-        if((spareMode1 >= 1 && spareMode1 <= 5) || spareMode1 == 21)
-        {
-          fillPartons(spareMode1, spareParm1, spareParm2, pythia->event, pythia->particleData, pythia->rndm);
-        }
-        else
-        {
-          fillParticle(spareMode1, spareParm1, spareParm2, pythia->event, pythia->particleData, pythia->rndm);
-        }
-      }
-
-      if(!pythia->next())
-      {
-        // If failure because reached end of file then exit event loop
-        if(pythia->info.atEndOfFile())
-        {
-          cerr << "Aborted since reached end of Les Houches Event File" << endl;
-          break;
-        }
-
-        // First few failures write off as "acceptable" errors, then quit
-        if(++errorCounter > timesAllowErrors)
-        {
-          cerr << "Event generation aborted prematurely, owing to error!" << endl;
-          break;
-        }
-
-        modularDelphes->Clear();
-        reader->Clear();
-        continue;
-      }
-
-      readStopWatch.Stop();
-
-      procStopWatch.Start();
-      ConvertInput(eventCounter, pythia, branchEvent, factory,
-        allParticleOutputArray, stableParticleOutputArray, partonOutputArray,
-        &readStopWatch, &procStopWatch);
-      modularDelphes->ProcessTask();
-      procStopWatch.Stop();
-
-      if(reader)
-      {
-        reader->AnalyzeEvent(branchEventLHEF, eventCounter, &readStopWatch, &procStopWatch);
-        reader->AnalyzeWeight(branchWeightLHEF);
-      }
-
-      treeWriter->Fill();
-
-      treeWriter->Clear();
-      modularDelphes->Clear();
-      if(reader) reader->Clear();
-
-      readStopWatch.Start();
-      progressBar.Update(eventCounter, eventCounter);
-    }
-
-    progressBar.Update(eventCounter, eventCounter, kTRUE);
-    progressBar.Finish();
-
-    pythia->stat();
-
-    modularDelphes->FinishTask();
-    treeWriter->Write();
-
-    cout << "** Exiting..." << endl;
-
-    delete reader;
-    delete pythia;
-    delete modularDelphes;
-    delete confReader;
-    delete treeWriter;
-    delete outputFile;
-
-    return 0;
-  }
-  catch(runtime_error &e)
-  {
-    if(treeWriter) delete treeWriter;
-    if(outputFile) delete outputFile;
-    cerr << "** ERROR: " << e.what() << endl;
-    return 1;
-  }
-}
Index: readers/DelphesROOT.cpp
===================================================================
--- readers/DelphesROOT.cpp	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ 	(revision )
@@ -1,272 +1,0 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <algorithm>
-#include <iostream>
-#include <memory>
-#include <sstream>
-#include <stdexcept>
-
-#include <map>
-#include <vector>
-
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "TApplication.h"
-#include "TROOT.h"
-
-#include "TClonesArray.h"
-#include "TDatabasePDG.h"
-#include "TFile.h"
-#include "TLorentzVector.h"
-#include "TObjArray.h"
-#include "TParticlePDG.h"
-#include "TStopwatch.h"
-
-#include "classes/DelphesClasses.h"
-#include "classes/DelphesFactory.h"
-#include "classes/DelphesStream.h"
-#include "modules/Delphes.h"
-
-#include "ExRootAnalysis/ExRootProgressBar.h"
-#include "ExRootAnalysis/ExRootTreeBranch.h"
-#include "ExRootAnalysis/ExRootTreeReader.h"
-#include "ExRootAnalysis/ExRootTreeWriter.h"
-
-using namespace std;
-
-//---------------------------------------------------------------------------
-
-//---------------------------------------------------------------------------
-
-static bool interrupted = false;
-
-void SignalHandler(int sig)
-{
-  interrupted = true;
-}
-
-//---------------------------------------------------------------------------
-
-int main(int argc, char *argv[])
-{
-  char appName[] = "DelphesROOT";
-  stringstream message;
-  TFile *inputFile = 0;
-  TFile *outputFile = 0;
-  TStopwatch eventStopWatch;
-  ExRootTreeWriter *treeWriter = 0;
-  ExRootTreeBranch *branchEvent = 0;
-  ExRootConfReader *confReader = 0;
-  Delphes *modularDelphes = 0;
-  DelphesFactory *factory = 0;
-  GenParticle *gen;
-  HepMCEvent *element, *eve;
-  Candidate *candidate;
-  Int_t pdgCode;
-
-  const Double_t c_light = 2.99792458E8;
-
-  TObjArray *allParticleOutputArray = 0, *stableParticleOutputArray = 0, *partonOutputArray = 0;
-  Int_t i;
-  Long64_t eventCounter, numberOfEvents;
-
-  if(argc < 4)
-  {
-    cout << " Usage: " << appName << " config_file"
-         << " output_file"
-         << " input_file(s)" << endl;
-    cout << " config_file - configuration file in Tcl format," << endl;
-    cout << " output_file - output file in ROOT format," << endl;
-    cout << " input_file(s) - input file(s) in ROOT format." << endl;
-    return 1;
-  }
-
-  signal(SIGINT, SignalHandler);
-
-  gROOT->SetBatch();
-
-  int appargc = 1;
-  char *appargv[] = {appName};
-  TApplication app(appName, &appargc, appargv);
-
-  try
-  {
-    outputFile = TFile::Open(argv[2], "CREATE");
-
-    if(outputFile == NULL)
-    {
-      message << "can't open " << argv[2] << endl;
-      throw runtime_error(message.str());
-    }
-
-    treeWriter = new ExRootTreeWriter(outputFile, "Delphes");
-
-    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
-
-    confReader = new ExRootConfReader;
-    confReader->ReadFile(argv[1]);
-
-    modularDelphes = new Delphes("Delphes");
-    modularDelphes->SetConfReader(confReader);
-    modularDelphes->SetTreeWriter(treeWriter);
-
-    TChain *chain = new TChain("Delphes");
-
-    factory = modularDelphes->GetFactory();
-    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
-    stableParticleOutputArray = modularDelphes->ExportArray("stableParticles");
-    partonOutputArray = modularDelphes->ExportArray("partons");
-
-    modularDelphes->InitTask();
-
-    for(i = 3; i < argc && !interrupted; ++i)
-    {
-      cout << "** Reading " << argv[i] << endl;
-
-      chain->Add(argv[i]);
-      ExRootTreeReader *treeReader = new ExRootTreeReader(chain);
-
-      inputFile = TFile::Open(argv[i]);
-
-      if(inputFile == NULL)
-      {
-        message << "can't open " << argv[i] << endl;
-        throw runtime_error(message.str());
-      }
-
-      numberOfEvents = treeReader->GetEntries();
-      TClonesArray *branchParticle = treeReader->UseBranch("Particle");
-      TClonesArray *branchHepMCEvent = treeReader->UseBranch("Event");
-
-      if(numberOfEvents <= 0) continue;
-
-      // ExRootProgressBar progressBar(numberOfEvents - 1);
-      ExRootProgressBar progressBar(-1);
-
-      // Loop over all objects
-      eventCounter = 0;
-      modularDelphes->Clear();
-      treeWriter->Clear();
-      for(Int_t entry = 0; entry < numberOfEvents && !interrupted; ++entry)
-      {
-
-        treeReader->ReadEntry(entry);
-
-        // -- TBC need also to include event weights --
-
-        eve = (HepMCEvent *)branchHepMCEvent->At(0);
-        element = static_cast<HepMCEvent *>(branchEvent->NewEntry());
-
-        element->Number = eventCounter;
-
-        element->ProcessID = eve->ProcessID;
-        element->MPI = eve->MPI;
-        element->Weight = eve->Weight;
-        element->Scale = eve->Scale;
-        element->AlphaQED = eve->AlphaQED;
-        element->AlphaQCD = eve->AlphaQCD;
-
-        element->ID1 = eve->ID1;
-        element->ID2 = eve->ID2;
-        element->X1 = eve->X1;
-        element->X2 = eve->X2;
-        element->ScalePDF = eve->ScalePDF;
-        element->PDF1 = eve->PDF1;
-        element->PDF2 = eve->PDF2;
-
-        element->ReadTime = eve->ReadTime;
-        element->ProcTime = eve->ProcTime;
-
-        for(Int_t j = 0; j < branchParticle->GetEntriesFast(); j++)
-        {
-
-          gen = (GenParticle *)branchParticle->At(j);
-          candidate = factory->NewCandidate();
-
-          candidate->Momentum = gen->P4();
-          candidate->Position.SetXYZT(gen->X, gen->Y, gen->Z, gen->T * 1.0E3 * c_light);
-
-          candidate->PID = gen->PID;
-          candidate->Status = gen->Status;
-
-          candidate->M1 = gen->M1;
-          candidate->M2 = gen->M2;
-
-          candidate->D1 = gen->D1;
-          candidate->D2 = gen->D2;
-
-          candidate->Charge = gen->Charge;
-          candidate->Mass = gen->Mass;
-
-          allParticleOutputArray->Add(candidate);
-
-          pdgCode = TMath::Abs(gen->PID);
-
-          if(gen->Status == 1)
-          {
-            stableParticleOutputArray->Add(candidate);
-          }
-          else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
-          {
-            partonOutputArray->Add(candidate);
-          }
-        }
-
-        modularDelphes->ProcessTask();
-
-        treeWriter->Fill();
-
-        modularDelphes->Clear();
-        treeWriter->Clear();
-
-        progressBar.Update(eventCounter, eventCounter);
-        ++eventCounter;
-      }
-
-      progressBar.Update(eventCounter, eventCounter, kTRUE);
-      progressBar.Finish();
-
-      inputFile->Close();
-
-      delete treeReader;
-    }
-
-    modularDelphes->FinishTask();
-    treeWriter->Write();
-
-    cout << "** Exiting..." << endl;
-
-    delete modularDelphes;
-    delete confReader;
-    delete treeWriter;
-    delete outputFile;
-    delete chain;
-
-    return 0;
-  }
-  catch(runtime_error &e)
-  {
-    if(treeWriter) delete treeWriter;
-    if(outputFile) delete outputFile;
-    cerr << "** ERROR: " << e.what() << endl;
-    return 1;
-  }
-}
Index: readers/DelphesSTDHEP.cpp
===================================================================
--- readers/DelphesSTDHEP.cpp	(revision 4564cba9fa0180ca6c293da8cea545291a6d0116)
+++ readers/DelphesSTDHEP.cpp	(revision d7d2da362406b9e37fdf238970417c94779b54b0)
@@ -1,44 +1,26 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
+#include <stdexcept>
 #include <iostream>
 #include <sstream>
-#include <stdexcept>
 
 #include <signal.h>
 
+#include "TROOT.h"
 #include "TApplication.h"
-#include "TROOT.h"
-
+
+#include "TFile.h"
+#include "TObjArray.h"
+#include "TStopwatch.h"
 #include "TDatabasePDG.h"
-#include "TFile.h"
+#include "TParticlePDG.h"
 #include "TLorentzVector.h"
-#include "TObjArray.h"
-#include "TParticlePDG.h"
-#include "TStopwatch.h"
-
+
+#include "modules/Delphes.h"
 #include "classes/DelphesClasses.h"
 #include "classes/DelphesFactory.h"
 #include "classes/DelphesSTDHEPReader.h"
-#include "modules/Delphes.h"
-
+
+#include "ExRootAnalysis/ExRootTreeWriter.h"
+#include "ExRootAnalysis/ExRootTreeBranch.h"
 #include "ExRootAnalysis/ExRootProgressBar.h"
-#include "ExRootAnalysis/ExRootTreeBranch.h"
-#include "ExRootAnalysis/ExRootTreeWriter.h"
 
 using namespace std;
@@ -69,12 +51,10 @@
   TObjArray *stableParticleOutputArray = 0, *allParticleOutputArray = 0, *partonOutputArray = 0;
   DelphesSTDHEPReader *reader = 0;
-  Int_t i, maxEvents, skipEvents;
+  Int_t i;
   Long64_t length, eventCounter;
 
   if(argc < 3)
   {
-    cout << " Usage: " << appName << " config_file"
-         << " output_file"
-         << " [input_file(s)]" << endl;
+    cout << " Usage: " << appName << " config_file" << " output_file" << " [input_file(s)]" << endl;
     cout << " config_file - configuration file in Tcl format," << endl;
     cout << " output_file - output file in ROOT format," << endl;
@@ -108,17 +88,4 @@
     confReader = new ExRootConfReader;
     confReader->ReadFile(argv[1]);
-
-    maxEvents = confReader->GetInt("::MaxEvents", 0);
-    skipEvents = confReader->GetInt("::SkipEvents", 0);
-
-    if(maxEvents < 0)
-    {
-      throw runtime_error("MaxEvents must be zero or positive");
-    }
-
-    if(skipEvents < 0)
-    {
-      throw runtime_error("SkipEvents must be zero or positive");
-    }
 
     modularDelphes = new Delphes("Delphes");
@@ -149,5 +116,5 @@
       {
         cout << "** Reading " << argv[i] << endl;
-        inputFile = fopen(argv[i], "rb");
+        inputFile = fopen(argv[i], "r");
 
         if(inputFile == NULL)
@@ -179,5 +146,6 @@
       reader->Clear();
       readStopWatch.Start();
-      while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray) && !interrupted)
+      while(reader->ReadBlock(factory, allParticleOutputArray,
+        stableParticleOutputArray, partonOutputArray) && !interrupted)
       {
         if(reader->EventReady())
@@ -186,18 +154,13 @@
 
           readStopWatch.Stop();
-
-          if(eventCounter > skipEvents)
-          {
-            procStopWatch.Start();
-            modularDelphes->ProcessTask();
-            procStopWatch.Stop();
-
-            reader->AnalyzeEvent(branchEvent, eventCounter, &readStopWatch, &procStopWatch);
-
-            treeWriter->Fill();
-
-            treeWriter->Clear();
-          }
-
+          procStopWatch.Start();
+          modularDelphes->ProcessTask();
+          procStopWatch.Stop();
+
+          reader->AnalyzeEvent(branchEvent, eventCounter, &readStopWatch, &procStopWatch);
+
+          treeWriter->Fill();
+
+          treeWriter->Clear();
           modularDelphes->Clear();
           reader->Clear();
@@ -215,5 +178,6 @@
 
       ++i;
-    } while(i < argc);
+    }
+    while(i < argc);
 
     modularDelphes->FinishTask();
