Index: trunk/Delphes.cpp
===================================================================
--- trunk/Delphes.cpp	(revision 349)
+++ trunk/Delphes.cpp	(revision 350)
@@ -46,4 +46,5 @@
 #include "HEPEVTConverter.h"
 #include "LHEFConverter.h"
+#include "HepMCConverter.h"
 #include "STDHEPConverter.h"
 #include "LHCOConverter.h"
@@ -273,9 +274,9 @@
       converter = new HEPEVTConverter(inputFileList,outputfilename);//case ntpl file in input list
     }
-  else if(line.length() == 1+line.find_last_of(".hepmc")) 
-    {
-      cout <<"**                   hepmc file format detected                    **"<<endl;
-      cout <<"**               Delphes can not yet used this format              **"<<endl;
-	return -1;
+  else if(line.length() == 1+line.find_last_of(".hepmc"))
+    {
+      cout <<"**                HepMC ASCII file format detected                 **"<<endl;
+      cout <<"**                  This can take several minutes                  **"<< endl;
+      converter = new HepMCConverter(inputFileList,outputfilename);
     }
   else {
@@ -332,5 +333,5 @@
   vector<int> NTrackJet;
 
-  TSimpleArray<GenParticle> NFCentralQ;
+  TSimpleArray<TRootC::GenParticle> NFCentralQ;
   
   D_CaloList list_of_calorimeters;
@@ -392,6 +393,6 @@
       // 2.1a Loop over all particles in event, to fill the towers
       itGen.Reset();
-      GenParticle *particleG; 
-      while( (particleG = (GenParticle*) itGen.Next()) ) 
+      TRootC::GenParticle *particleG; 
+      while( (particleG = (TRootC::GenParticle*) itGen.Next()) ) 
 	{
 	  TRootGenParticle *particle = new TRootGenParticle(particleG);
Index: trunk/Examples/src/Analysis_Ex.cc
===================================================================
--- trunk/Examples/src/Analysis_Ex.cc	(revision 349)
+++ trunk/Examples/src/Analysis_Ex.cc	(revision 350)
@@ -145,7 +145,7 @@
       //*****************************************************
       TIter itGen((TCollection*)GEN);
-      GenParticle *gen;
+      TRootC::GenParticle *gen;
       itGen.Reset();
-      while( (gen = (GenParticle*) itGen.Next()) )
+      while( (gen = (TRootC::GenParticle*) itGen.Next()) )
 	{
           PID      = gen->PID;      // particle HEP ID number 
Index: trunk/Makefile
===================================================================
--- trunk/Makefile	(revision 349)
+++ trunk/Makefile	(revision 350)
@@ -16,5 +16,5 @@
 SrcSuf = cc
 
-CXXFLAGS += $(ROOTCFLAGS) -DDROP_CGAL -I. -Iinterface -IUtilities/mcfio -IUtilities/stdhep -IUtilities/Hector/include -IUtilities/CDFCones/interface -IExamples -IUtilities/FROG/Includes/FROG -IUtilities/ExRootAnalysis/interface -IUtilities/Fastjet/include/fastjet -IUtilities/Fastjet/plugins/CDFCones -IUtilities/Fastjet/plugins/CDFCones/interface -IUtilities/Fastjet/plugins/SISCone -IUtilities/CLHEP/Units
+CXXFLAGS += $(ROOTCFLAGS) -DDROP_CGAL -I. -Iinterface -IUtilities/mcfio -IUtilities/stdhep -IUtilities/Hector/include -IUtilities/CDFCones/interface -IExamples -IUtilities/FROG/Includes/FROG -IUtilities/ExRootAnalysis/interface -IUtilities/Fastjet/include/fastjet -IUtilities/Fastjet/plugins/CDFCones -IUtilities/Fastjet/plugins/CDFCones/interface -IUtilities/Fastjet/plugins/SISCone -IUtilities/CLHEP/Units -IUtilities/HepMC/interface
 # -pg -g
 LIBS = $(ROOTLIBS) -lEG $(SYSLIBS)
@@ -121,4 +121,6 @@
 tmp/src/LHEFConverter.$(ObjSuf): \
 	src/LHEFConverter.$(SrcSuf)
+tmp/src/HepMCConverter.$(ObjSuf): \
+	src/HepMCConverter.$(SrcSuf)
 tmp/src/FrogUtil.$(ObjSuf): \
 	src/FrogUtil.$(SrcSuf)
@@ -129,4 +131,6 @@
 tmp/src/D_Constants.$(ObjSuf): \
 	src/D_Constants.$(SrcSuf)
+tmp/src/HEPMCConverter.$(ObjSuf): \
+	src/HEPMCConverter.$(SrcSuf)
 tmp/src/TreeClasses.$(ObjSuf): \
 	src/TreeClasses.$(SrcSuf)
@@ -304,4 +308,32 @@
 	Examples/src/Analysis_Ex.$(SrcSuf) \
 	Examples/interface/Analysis_Ex.h
+tmp/Utilities/HepMC/src/SearchVector.$(ObjSuf): \
+	Utilities/HepMC/src/SearchVector.$(SrcSuf)
+tmp/Utilities/HepMC/src/Units.$(ObjSuf): \
+	Utilities/HepMC/src/Units.$(SrcSuf)
+tmp/Utilities/HepMC/src/Polarization.$(ObjSuf): \
+	Utilities/HepMC/src/Polarization.$(SrcSuf)
+tmp/Utilities/HepMC/src/ParticleData.$(ObjSuf): \
+	Utilities/HepMC/src/ParticleData.$(SrcSuf)
+tmp/Utilities/HepMC/src/IO_PDG_ParticleDataTable.$(ObjSuf): \
+	Utilities/HepMC/src/IO_PDG_ParticleDataTable.$(SrcSuf)
+tmp/Utilities/HepMC/src/Flow.$(ObjSuf): \
+	Utilities/HepMC/src/Flow.$(SrcSuf)
+tmp/Utilities/HepMC/src/GenEvent.$(ObjSuf): \
+	Utilities/HepMC/src/GenEvent.$(SrcSuf)
+tmp/Utilities/HepMC/src/IO_Ascii.$(ObjSuf): \
+	Utilities/HepMC/src/IO_Ascii.$(SrcSuf)
+tmp/Utilities/HepMC/src/GenParticle.$(ObjSuf): \
+	Utilities/HepMC/src/GenParticle.$(SrcSuf)
+tmp/Utilities/HepMC/src/IO_GenEvent.$(ObjSuf): \
+	Utilities/HepMC/src/IO_GenEvent.$(SrcSuf)
+tmp/Utilities/HepMC/src/GenVertex.$(ObjSuf): \
+	Utilities/HepMC/src/GenVertex.$(SrcSuf)
+tmp/Utilities/HepMC/src/CompareGenEvent.$(ObjSuf): \
+	Utilities/HepMC/src/CompareGenEvent.$(SrcSuf)
+tmp/Utilities/HepMC/src/IO_AsciiParticles.$(ObjSuf): \
+	Utilities/HepMC/src/IO_AsciiParticles.$(SrcSuf)
+tmp/Utilities/HepMC/src/CommonIO.$(ObjSuf): \
+	Utilities/HepMC/src/CommonIO.$(SrcSuf)
 SOURCE_OBJ =  \
 	tmp/src/JetsUtil.$(ObjSuf) \
@@ -312,8 +344,10 @@
 	tmp/src/VeryForward.$(ObjSuf) \
 	tmp/src/LHEFConverter.$(ObjSuf) \
+	tmp/src/HepMCConverter.$(ObjSuf) \
 	tmp/src/FrogUtil.$(ObjSuf) \
 	tmp/src/STDHEPConverter.$(ObjSuf) \
 	tmp/src/HEPEVTConverter.$(ObjSuf) \
 	tmp/src/D_Constants.$(ObjSuf) \
+	tmp/src/HEPMCConverter.$(ObjSuf) \
 	tmp/src/TreeClasses.$(ObjSuf) \
 	tmp/src/LHCOConverter.$(ObjSuf) \
@@ -400,5 +434,19 @@
 	tmp/Utilities/Fastjet/plugins/SISCone/src/momentum.$(ObjSuf) \
 	tmp/Utilities/Fastjet/plugins/SISCone/src/quadtree.$(ObjSuf) \
-	tmp/Examples/src/Analysis_Ex.$(ObjSuf)
+	tmp/Examples/src/Analysis_Ex.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/SearchVector.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/Units.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/Polarization.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/ParticleData.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/IO_PDG_ParticleDataTable.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/Flow.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/GenEvent.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/IO_Ascii.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/GenParticle.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/IO_GenEvent.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/GenVertex.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/CompareGenEvent.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/IO_AsciiParticles.$(ObjSuf) \
+	tmp/Utilities/HepMC/src/CommonIO.$(ObjSuf)
 
 tmp/Utilities/mcfio/mcfio_UserDictionary.$(ObjSuf): \
Index: trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h
===================================================================
--- trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h	(revision 349)
+++ trunk/Utilities/ExRootAnalysis/interface/BlockClasses.h	(revision 350)
@@ -177,4 +177,6 @@
 //--------------------------------------------------------------------------
 class TRootGenParticle;
+
+namespace TRootC {
 class GenParticle: public TRootParticle {
 
@@ -202,4 +204,5 @@
   ClassDef(GenParticle, 1)
 };
+}
 
 //---------------------------------------------------------------------------
@@ -210,5 +213,5 @@
   TRootGenParticle() {_initialised=false;}
   TRootGenParticle(const int pid): PID(pid) {_initialised=false;}
-  TRootGenParticle(GenParticle* part);
+  TRootGenParticle(TRootC::GenParticle* part);
 
   int PID; // particle HEP ID number [RawHepEventParticle::pid()]
Index: trunk/genMakefile.tcl
===================================================================
--- trunk/genMakefile.tcl	(revision 349)
+++ trunk/genMakefile.tcl	(revision 350)
@@ -217,5 +217,5 @@
 SrcSuf = cc
 
-CXXFLAGS += $(ROOTCFLAGS) -DDROP_CGAL -I. -Iinterface -IUtilities/mcfio -IUtilities/stdhep -IUtilities/Hector/include -IUtilities/CDFCones/interface -IExamples -IUtilities/FROG/Includes/FROG -IUtilities/ExRootAnalysis/interface -IUtilities/Fastjet/include/fastjet -IUtilities/Fastjet/plugins/CDFCones -IUtilities/Fastjet/plugins/CDFCones/interface -IUtilities/Fastjet/plugins/SISCone -IUtilities/CLHEP/Units
+CXXFLAGS += $(ROOTCFLAGS) -DDROP_CGAL -I. -Iinterface -IUtilities/mcfio -IUtilities/stdhep -IUtilities/Hector/include -IUtilities/CDFCones/interface -IExamples -IUtilities/FROG/Includes/FROG -IUtilities/ExRootAnalysis/interface -IUtilities/Fastjet/include/fastjet -IUtilities/Fastjet/plugins/CDFCones -IUtilities/Fastjet/plugins/CDFCones/interface -IUtilities/Fastjet/plugins/SISCone -IUtilities/CLHEP/Units -IUtilities/HepMC/interface
 # -pg -g
 LIBS = $(ROOTLIBS) -lEG $(SYSLIBS)
@@ -239,5 +239,5 @@
 dictDeps {DICT} {Utilities/ExRootAnalysis/src/*LinkDef.h} {src/*LinkDef.h} {Examples/src/*LinkDef.h}
 
-sourceDeps {SOURCE} {src/*.cc} {Utilities/ExRootAnalysis/src/*.cc} {Utilities/Hector/src/*.cc} {Utilities/CDFCones/src/*cc} {Utilities/Fastjet/src/*.cc} {Utilities/Fastjet/plugins/CDFCones/*.cc} {Utilities/Fastjet/plugins/CDFCones/src/*.cc} {Utilities/Fastjet/plugins/SISCone/*.cc} {Utilities/Fastjet/plugins/SISCone/src/*.cc} {Examples/src/*.cc}
+sourceDeps {SOURCE} {src/*.cc} {Utilities/ExRootAnalysis/src/*.cc} {Utilities/Hector/src/*.cc} {Utilities/CDFCones/src/*cc} {Utilities/Fastjet/src/*.cc} {Utilities/Fastjet/plugins/CDFCones/*.cc} {Utilities/Fastjet/plugins/CDFCones/src/*.cc} {Utilities/Fastjet/plugins/SISCone/*.cc} {Utilities/Fastjet/plugins/SISCone/src/*.cc} {Examples/src/*.cc} {Utilities/HepMC/src/*.cc}
 
 stdhepDeps
Index: trunk/interface/JetsUtil.h
===================================================================
--- trunk/interface/JetsUtil.h	(revision 349)
+++ trunk/interface/JetsUtil.h	(revision 350)
@@ -83,5 +83,5 @@
   vector<fastjet::PseudoJet> RunJetsResol(const vector<fastjet::PseudoJet>&  input_particles);
   
-  void RunJetBtagging(ExRootTreeWriter *treeWriter, ExRootTreeBranch *branchJet,const vector<fastjet::PseudoJet> & sorted_jets,const TSimpleArray<GenParticle> & NFCentralQ, const vector<int> &NTrackJet, const vector<float> &EHADEEM);
+  void RunJetBtagging(ExRootTreeWriter *treeWriter, ExRootTreeBranch *branchJet,const vector<fastjet::PseudoJet> & sorted_jets,const TSimpleArray<TRootC::GenParticle> & NFCentralQ, const vector<int> &NTrackJet, const vector<float> &EHADEEM);
   
   void RunTauJets(ExRootTreeWriter *treeWriter, ExRootTreeBranch *branchTauJet,const vector<fastjet::PseudoJet> & sorted_jets,const vector<PhysicsTower> & towers, const vector<TRootTracks> & TrackCentral, const vector<int> &NTrackJet, const vector<float> &EHADEEM);
Index: trunk/interface/SmearUtil.h
===================================================================
--- trunk/interface/SmearUtil.h	(revision 349)
+++ trunk/interface/SmearUtil.h	(revision 350)
@@ -227,8 +227,8 @@
 
   /// b-jets
-  int Bjets(const TSimpleArray<GenParticle> &subarray, const float& eta, const float& phi);
+  int Bjets(const TSimpleArray<TRootC::GenParticle> &subarray, const float& eta, const float& phi);
   
   /// b-tag efficiency and misidentification
-  bool Btaggedjet(const TLorentzVector &JET, const TSimpleArray<GenParticle> &subarray);
+  bool Btaggedjet(const TLorentzVector &JET, const TSimpleArray<TRootC::GenParticle> &subarray);
 
   /// Lepton isolation based on tracking
Index: trunk/src/HEPEVTConverter.cc
===================================================================
--- trunk/src/HEPEVTConverter.cc	(revision 349)
+++ trunk/src/HEPEVTConverter.cc	(revision 350)
@@ -176,5 +176,5 @@
 
   ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputFileName, "GEN");
-  ExRootTreeBranch *branchGen = treeWriter->NewBranch("Particle", GenParticle::Class());
+  ExRootTreeBranch *branchGen = treeWriter->NewBranch("Particle", TRootC::GenParticle::Class());
   
   ifstream infile(inputFileList.c_str());
@@ -211,5 +211,5 @@
       Float_t signEta;
       
-      GenParticle *element;
+      TRootC::GenParticle *element;
       
       // Loop over all events
@@ -222,5 +222,5 @@
 	  for(particle = 0; particle < event.Nhep; ++particle)
 	    {
-	      element = (GenParticle*) branchGen->NewEntry();
+	      element = (TRootC::GenParticle*) branchGen->NewEntry();
 	      
 	      element->PID = event.Idhep[particle];	
Index: trunk/src/HEPMCConverter.cc
===================================================================
--- trunk/src/HEPMCConverter.cc	(revision 349)
+++ trunk/src/HEPMCConverter.cc	(revision 350)
@@ -55,5 +55,5 @@
   ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputFileName, "GEN");
   ExRootTreeBranch *branchGenEvent = treeWriter->NewBranch("Event", TRootGenEvent::Class());
-  ExRootTreeBranch *branchGenParticle = treeWriter->NewBranch("Particle", GenParticle::Class());
+  ExRootTreeBranch *branchGenParticle = treeWriter->NewBranch("Particle", TRootC::GenParticle::Class());
   
   // Open the datafile list
Index: trunk/src/HepMCConverter.cc
===================================================================
--- trunk/src/HepMCConverter.cc	(revision 350)
+++ trunk/src/HepMCConverter.cc	(revision 350)
@@ -0,0 +1,301 @@
+/***********************************************************************
+**                                                                    **
+**          /----------------------------------------------\          **
+**         |  Delphes, a framework for the fast simulation  |         **
+**         |       of a  generic collider experiment        |         **
+**          \----------------------------------------------/          **
+**                                                                    **
+**                                                                    **
+**   This package uses:                                               **
+**   ------------------                                               **
+**   FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210]      ** 
+**   Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2]       ** 
+**   FROG: [hep-ex/0901.2718v1]                                       **
+**                                                                    **
+** ------------------------------------------------------------------ **
+**                                                                    **
+**   Main authors:                                                    **
+**   -------------                                                    **
+**                                                                    **
+**                Severine Ovyn                Xavier Rouby           ** 
+**          severine.ovyn@uclouvain.be      xavier.rouby@cern         ** 
+**                                                                    ** 
+**         Center for Particle Physics and Phenomenology (CP3)        ** 
+**                Universite catholique de Louvain (UCL)              **       
+**                     Louvain-la-Neuve, Belgium                      **            
+**                                                                    **
+**                      Copyright (C) 2008-2009,                      **
+**                        All rights reserved.                        **  
+  //
+**                                                                    **
+***********************************************************************/
+
+
+#include <iostream>
+#include <fstream>
+#include "TLorentzVector.h"
+#include "BlockClasses.h"
+
+#include "ExRootTreeWriter.h"
+#include "ExRootTreeBranch.h"
+#include "HepMCConverter.h"
+
+#include "GenParticle.h"
+#include "GenVertex.h"
+#include "IO_Ascii.h"
+#include "IO_GenEvent.h"
+
+//-------------------------------------------------------------------------
+int HepMCConverter::find_in_map( const std::map<HepMC::GenParticle*,int>& m, HepMC::GenParticle *p) const
+{
+  std::map<HepMC::GenParticle*,int>::const_iterator iter = m.find(p);
+  return (iter == m.end()) ? 0 : iter->second;
+}
+
+//--------------------------------------------------------------------------
+void  HepMCConverter::ReadStats()
+{
+
+ unsigned int particle_counter=0;
+ index_to_particle.reserve(evt->particles_size()); 
+ index_to_particle[0] = 0; 
+ HepMC::GenEvent::vertex_const_iterator v;
+ for (v = evt->vertices_begin(); v != evt->vertices_end(); ++v ) 
+   {
+     // making a list of incoming particles of the vertices
+     // so that the mother indices in HEPEVT can be filled properly
+     HepMC::GenVertex::particles_out_const_iterator p1;
+     for (p1 = (*v)->particles_in_const_begin();p1 != (*v)->particles_in_const_end(); ++p1 ) 
+       {
+
+	 ++particle_counter;
+	 //particle_counter can be very large for heavy ions
+	 if(particle_counter >= index_to_particle.size() ) 
+	   {
+	     //make it large enough to hold up to this index
+	     index_to_particle.resize(particle_counter+1);
+	   }                 
+	 index_to_particle[particle_counter] = *p1;
+	 particle_to_index[*p1] = particle_counter;
+       }   
+     // daughters are entered only if they aren't a mother of
+     // another vertex
+   HepMC::GenVertex::particles_out_const_iterator p2;
+     for (p2 = (*v)->particles_out_const_begin();p2 != (*v)->particles_out_const_end(); ++p2) 
+       {
+	 if (!(*p2)->end_vertex()) 
+	   {
+	     ++particle_counter;
+	     //particle_counter can be very large for heavy ions
+	     if(particle_counter  >= index_to_particle.size() ) 
+	       {        
+		 //make it large enough to hold up to this index
+		 index_to_particle.resize(particle_counter+1);
+	       }                   
+	     index_to_particle[particle_counter] = *p2;
+	     particle_to_index[*p2] = particle_counter;
+	   }
+       }
+
+   } 
+}
+
+
+//-------------------------------------------------------------------------
+void HepMCConverter::getStatsFromTuple(int &mo1, int &mo2, int &da1, int &da2, int &status, int &pid, int j) const
+{
+  if (!evt) 
+    {
+      cout <<  "HepMCFileReader: Got no event :-(  Game over already  ?" <<endl; 
+    } 
+  else 
+    {
+      status =  index_to_particle[j]->status();
+      pid = index_to_particle[j]->pdg_id();
+      if ( index_to_particle[j]->production_vertex() ) 
+	{
+            //HepLorentzVector p = index_to_particle[j]->production_vertex()->position();
+      
+	  int num_mothers = index_to_particle[j]->production_vertex()->particles_in_size();
+	  int first_mother = find_in_map( particle_to_index,*(index_to_particle[j]->production_vertex()->particles_in_const_begin()));
+	  int last_mother = first_mother + num_mothers - 1;
+	  if ( first_mother == 0 ) last_mother = 0;
+	  mo1=first_mother;
+	  mo2=last_mother;
+	} 
+      else 
+	{
+	  mo1 =0;
+	  mo2 =0;
+	}   
+       if (index_to_particle[j]->end_vertex())
+	{
+	  //find # of 1. daughter
+	  int first_daughter = find_in_map( particle_to_index,*(index_to_particle[j]->end_vertex()->particles_begin(HepMC::children)));
+	  //cout <<"first_daughter "<< first_daughter <<  "num_daughters " << num_daughters << endl; 
+	  HepMC::GenVertex::particle_iterator ic;
+	  int last_daughter=0;
+	  //find # of last daughter
+	  for (ic = index_to_particle[j]->end_vertex()->particles_begin(HepMC::children);ic != index_to_particle[j]->end_vertex()->particles_end(HepMC::children); ++ic) 
+	    last_daughter= find_in_map( particle_to_index,*ic);       
+	  
+	  if (first_daughter== 0) last_daughter = 0;
+	  da1=first_daughter;
+	  da2=last_daughter;
+	} 
+      else 
+	{
+	  da1=0;
+	  da2=0;
+	}
+    } 
+} 
+
+
+
+//---------------------------------------------------------------------------
+
+void HepMCConverter::AnalyseEvent(ExRootTreeBranch *branch,HepMC::GenEvent& evt,const Long64_t eventNumber)
+{
+  TRootLHEFEvent *element;
+  
+  element = static_cast<TRootLHEFEvent*>(branch->NewEntry());
+  element->Number = eventNumber;
+  element->Nparticles = evt.particles_size();
+  element->ProcessID = evt.signal_process_id();
+  //  element->Weight = hepeup.XWGTUP;
+  element->ScalePDF = evt.event_scale();
+  element->CouplingQED = evt.alphaQED();
+  element->CouplingQCD = evt.alphaQCD();
+  
+}
+
+//---------------------------------------------------------------------------
+
+void HepMCConverter::AnalyseParticles(ExRootTreeBranch *branch,HepMC::GenEvent& evt)
+{
+  TRootC::GenParticle *element;
+
+  TLorentzVector momentum;
+  Double_t signPz;
+
+  ReadStats();
+  for(int n=1; n<=evt.particles_size(); n++)
+    {
+      getStatsFromTuple( mo1,mo2,da1,da2,status,pid,n);
+    
+      element = static_cast<TRootC::GenParticle*>(branch->NewEntry());
+
+      element->PID = pid;
+      element->Status = status;
+      element->M1 = mo1;
+      element->M2 = mo2;
+      element->D1 = da1;
+      element->D2 = da2;
+      element->Charge = pid;
+
+      element->E = index_to_particle[n]->momentum().e();
+      element->Px = index_to_particle[n]->momentum().px();
+      element->Py = index_to_particle[n]->momentum().py();
+      element->Pz = index_to_particle[n]->momentum().pz();
+      element->M =  index_to_particle[n]->momentum().m();
+
+      float PT = sqrt(pow(element->Px,2)+pow(element->Py,2));
+      element->PT = PT;
+      momentum.SetPxPyPzE(element->Px, element->Py, element->Pz, element->E);
+      signPz = (element->Pz >= 0.0) ? 1.0 : -1.0;
+      element->Eta = element->PT == 0.0 ? signPz*999.9 : momentum.Eta();
+      element->Phi = index_to_particle[n]->momentum().phi();
+ 
+    //In particle at vertex
+    HepMC::GenVertex* vrtI = (index_to_particle[n])->production_vertex();
+    HepMC::GenVertex::particles_in_const_iterator partI;
+    element = static_cast<TRootC::GenParticle*>(branch->NewEntry());
+
+    if(vrtI)
+      {
+        element->T = vrtI->position().t();
+        element->X = vrtI->position().x();
+        element->Y = vrtI->position().y();
+        element->Z = vrtI->position().z();
+      }
+    else
+     {
+        element->T = 0.;
+        element->X = 0.;
+        element->Y = 0.;
+        element->Z = 0.;
+     }  
+  }
+}
+
+//
+
+//------------------------------------------------------------------------------
+
+HepMCConverter::~HepMCConverter()
+{
+}
+
+//------------------------------------------------------------------------------
+
+HepMCConverter::HepMCConverter(const string& inputFileList, const string& outputFileName, const int& Nevents) : DataConverter(Nevents)
+{
+  
+  ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputFileName, "GEN");
+  // information about generated event
+  ExRootTreeBranch *branchGenEvent = treeWriter->NewBranch("Event", TRootLHEFEvent::Class());
+  // generated particles from HEPEVT
+  ExRootTreeBranch *branchGenParticle = treeWriter->NewBranch("Particle", TRootC::GenParticle::Class());
+  
+  // Open a stream connected to an event file:
+  ifstream infile(inputFileList.c_str());
+  string filename;
+  if(!infile.is_open()) {
+     cerr << left  << setw(30) <<"**   ERROR: Can't open     "<<""
+          << left  << setw(20) << inputFileList                        <<""
+          << right << setw(19) <<"for input **"<<""<<endl;
+     exit(1);
+  }
+ 
+  while(1)
+    {
+      infile >> filename;
+      if(!infile.good()) break;
+      ifstream checking_the_file(filename.c_str());
+      if(!checking_the_file.good()) 
+	{ 
+	  cerr << left  << setw(30) <<"**   ERROR: Can't find file  "<<""
+	       << left  << setw(20) << filename                      <<""
+	       << right << setw(19) <<"for input **"<<""<<endl;
+	  continue;
+	}
+      else checking_the_file.close();
+      
+      //Open the file
+      HepMC::IO_GenEvent ascii_in(filename,std::ios::in);
+      // get the first event
+      evt = ascii_in.read_next_event();
+      
+      Long64_t entry = 0;
+      while ( evt ) 
+	{
+	  treeWriter->Clear();
+	  AnalyseEvent(branchGenEvent, *evt,entry+1);
+	  AnalyseParticles(branchGenParticle, *evt);      
+	  delete evt;
+	  // read the next event
+	  ascii_in >> evt;
+	  treeWriter->Fill();
+	  ++entry;
+        }
+    }
+  
+  treeWriter->Write();
+  delete treeWriter;
+  
+}
+
+
+
+
Index: trunk/src/JetsUtil.cc
===================================================================
--- trunk/src/JetsUtil.cc	(revision 349)
+++ trunk/src/JetsUtil.cc	(revision 350)
@@ -190,5 +190,5 @@
 
 
-void JetsUtil::RunJetBtagging(ExRootTreeWriter *treeWriter, ExRootTreeBranch *branchJet,const vector<fastjet::PseudoJet> & sorted_jets,const TSimpleArray<GenParticle>& NFCentralQ, const vector<int> &NTrackJet, const vector<float> &EHADEEM)
+void JetsUtil::RunJetBtagging(ExRootTreeWriter *treeWriter, ExRootTreeBranch *branchJet,const vector<fastjet::PseudoJet> & sorted_jets,const TSimpleArray<TRootC::GenParticle>& NFCentralQ, const vector<int> &NTrackJet, const vector<float> &EHADEEM)
 {
   TRootJet *elementJet;
Index: trunk/src/STDHEPConverter.cc
===================================================================
--- trunk/src/STDHEPConverter.cc	(revision 349)
+++ trunk/src/STDHEPConverter.cc	(revision 350)
@@ -62,5 +62,5 @@
   else Nmax = myhepevt.nhep;
 
-  GenParticle *element;
+  TRootC::GenParticle *element;
 
   Double_t signPz;
@@ -70,5 +70,5 @@
   for(number = 0; number < Nmax; ++number)
   {
-    element = static_cast<GenParticle*>(branch->NewEntry());
+    element = static_cast<TRootC::GenParticle*>(branch->NewEntry());
 
     element->PID = myhepevt.idhep[number];
@@ -119,5 +119,5 @@
   ExRootTreeBranch *branchGenEvent = treeWriter->NewBranch("Event", TRootGenEvent::Class());
   // generated particles from HEPEVT
-  ExRootTreeBranch *branchGenParticle = treeWriter->NewBranch("Particle", GenParticle::Class());
+  ExRootTreeBranch *branchGenParticle = treeWriter->NewBranch("Particle", TRootC::GenParticle::Class());
   
   // Open a stream connected to an event file:
Index: trunk/src/SmearUtil.cc
===================================================================
--- trunk/src/SmearUtil.cc	(revision 349)
+++ trunk/src/SmearUtil.cc	(revision 350)
@@ -1064,5 +1064,5 @@
 //used by Btaggedjet
 ///// Attention : bug removed => CONERADIUS/2 -> CONERADIUS !!
-int RESOLution::Bjets(const TSimpleArray<GenParticle> &subarray, const float& eta, const float& phi) {
+int RESOLution::Bjets(const TSimpleArray<TRootC::GenParticle> &subarray, const float& eta, const float& phi) {
   float emax=0;
   int Ppid=0;
@@ -1081,5 +1081,5 @@
 
 //******************** Simulates the b-tagging efficiency for real bjet, or the misendentification for other jets****************
-bool RESOLution::Btaggedjet(const TLorentzVector &JET, const TSimpleArray<GenParticle> &subarray) {
+bool RESOLution::Btaggedjet(const TLorentzVector &JET, const TSimpleArray<TRootC::GenParticle> &subarray) {
   if(      rand()%100 < (BTAG_b+1)    && Bjets(subarray,JET.Eta(),JET.Phi())==pB ) return true; // b-tag of b-jets is 40%
   else if( rand()%100 < (BTAG_mistag_c+1) && Bjets(subarray,JET.Eta(),JET.Phi())==pC ) return true; // b-tag of c-jets is 10%
