Index: trunk/Delphes.cpp
===================================================================
--- trunk/Delphes.cpp	(revision 64)
+++ trunk/Delphes.cpp	(revision 65)
@@ -30,4 +30,5 @@
 #include "interface/JetUtils.h"
 
+#include "Utilities/FROG/Examples/Sim_Delphes/FrogUtil.h"
 
 #include <vector>
@@ -232,7 +233,5 @@
             { 
             genMomentum.SetPxPyPzE(particle->Px, particle->Py, particle->Pz, particle->E);
-//cout<<"avant "<<genMomentum.Pt()<<endl;
-            TRACP->Propagation(particle,genMomentum);
-//cout<<"apres "<<genMomentum.Pt()<<endl;
+            //TRACP->Propagation(particle,genMomentum);
             float eta=fabs(genMomentum.Eta());
             switch(pid) {
@@ -241,6 +240,4 @@
               DET->SmearElectron(genMomentum);
 	      electron.push_back(genMomentum);
-  //            cout<<"apres le smearing "<<genMomentum.Pt()<<endl;
-
               elecPID.push_back(particle->PID);
 	      break; // case pE
@@ -276,5 +273,4 @@
 		// back of the input_particles vector
 		input_particles.push_back(fastjet::PseudoJet(genMomentum.Px(),genMomentum.Py(),genMomentum.Pz(), genMomentum.E())); 
-            //   cout<<"on remplie avec "<<pid<<" Pt "<<genMomentum.Pt()<<" Eta "<<genMomentum.Eta()<<" Phi "<<genMomentum.Eta()<<endl;
   
                 genMomentumCalo.SetPxPyPzE(CaloTower.fourVector.px,CaloTower.fourVector.py,CaloTower.fourVector.pz,CaloTower.fourVector.E);
@@ -310,5 +306,19 @@
 	  
 	} // while
-// cout<<"*************"<<endl;     
+
+   // computes the Missing Transverse Momentum
+   TLorentzVector Att(0.,0.,0.,0.);
+   for(unsigned int i=0; i < towers.size(); i++)
+     {
+        Att.SetPxPyPzE(towers[i].fourVector.px,towers[i].fourVector.py,towers[i].fourVector.pz,towers[i].fourVector.E);
+        PTmis = PTmis + Att;
+     }
+   elementEtmis = (TRootETmis*) branchETmis->NewEntry();
+   elementEtmis->ET = (PTmis).Pt();
+   elementEtmis->Phi = (-PTmis).Phi();
+   elementEtmis->Px = (-PTmis).Px();
+   elementEtmis->Py = (-PTmis).Py();
+   //*****************************
+   
       for(unsigned int i=0; i < electron.size(); i++) {
 	if(electron[i].E()!=0 && fabs(electron[i].Eta()) < DET->MAX_TRACKER && electron[i].Pt() > DET->ELEC_pt)
@@ -330,20 +340,4 @@
       }
       
-      // computes the Missing Transverse Momentum
-      TLorentzVector Att(0.,0.,0.,0.);
-      for(unsigned int i=0; i < towers.size(); i++)
-        {
-          Att.SetPxPyPzE(towers[i].fourVector.px,towers[i].fourVector.py,towers[i].fourVector.pz,towers[i].fourVector.E);
-          PTmis = PTmis + Att;
-        }
-      elementEtmis = (TRootETmis*) branchETmis->NewEntry();
-      elementEtmis->ET = (PTmis).Pt();
-      elementEtmis->Phi = (-PTmis).Phi();
-      elementEtmis->Px = (-PTmis).Px();
-      elementEtmis->Py = (-PTmis).Py();
-
-      //*****************************
-      treeWriter->Fill();
-      
       sorted_jets=JETRUN->RunJets(input_particles);
       JETRUN->RunJetBtagging(treeWriter, branchJet,sorted_jets,NFCentralQ);
@@ -352,12 +346,38 @@
       // Add here the trigger
       // Should test all the trigger table on the event, based on reconstructed objects
+      treeWriter->Fill();
      
     } // Loop over all events
 
+
   treeWriter->Write();
-  
+  delete treeWriter;
+
+/*  if(DET->DOTRIGGER == 1) 
+    {
+//      TChain chainT("Analysis");
+//      chainT.Add(outputfilename.c_str());
+      ExRootTreeReader *treeReaderT = new ExRootTreeReader("Analysis");
+
+
+      const TClonesArray *branchElecTrig = treeReaderT->UseBranch("Electron");
+      const TClonesArray *branchMuonTrig = treeReaderT->UseBranch("Muon");
+      const TClonesArray *branchJetTrig = treeReaderT->UseBranch("Jet");
+      const TClonesArray *branchTauJetTrig = treeReaderT->UseBranch("TauJet");
+      const TClonesArray *branchPhotonTrig = treeReaderT->UseBranch("Photon");
+      const TClonesArray *branchETmisTrig = treeReaderT->UseBranch("ETmis");
+   
+     // Loop over all events
+     Long64_t entryT, allEntriesT = treeReaderT->GetEntries();
+      cout << "** Chain contains " << allEntriesT << " events" << endl;
+     for(entryT = 0; entryT < allEntriesT; ++entryT)
+        {
+//cout<<"entry "<<entryT<<endl;
+        }
+   }
+*/
+
   cout << "** Exiting..." << endl;
   
-  delete treeWriter;
   delete treeReader;
   delete DET;
Index: trunk/src/JetUtils.cc
===================================================================
--- trunk/src/JetUtils.cc	(revision 64)
+++ trunk/src/JetUtils.cc	(revision 65)
@@ -106,5 +106,4 @@
       }
   } // for itJet : loop on all jets
- treeWriter->Fill();
   
 }
@@ -131,5 +130,4 @@
   } // for itJet : loop on all jets
   
-  treeWriter->Fill();
   
 }
Index: trunk/src/VeryForward.cc
===================================================================
--- trunk/src/VeryForward.cc	(revision 64)
+++ trunk/src/VeryForward.cc	(revision 65)
@@ -80,5 +80,4 @@
     elementZdc->side = sign(eta);
     
-    treeWriter->Fill();
     
   }
@@ -140,5 +139,4 @@
 
       }
-     treeWriter->Fill();
       //                if(p1.stopped(beamline) && (p1.getStoppingElement()->getS() > 100))
       //                        cout << "Eloss ="  << 7000.-p1.getE() << " ; " << p1.getStoppingElement()->getName() << endl;
