Index: trunk/src/LHCOConverter.cc
===================================================================
--- trunk/src/LHCOConverter.cc	(revision 275)
+++ trunk/src/LHCOConverter.cc	(revision 284)
@@ -75,4 +75,6 @@
 }
 
+
+
 void LHCOConverter::CopyRunLogFile() {
   if(!valid_) {/*cout << "Nothing done\n";*/ return; }
@@ -98,4 +100,6 @@
 }
 
+
+
 void LHCOConverter::ConvertExRootAnalysisToLHCO() {
   if(!valid_) {/*cout << "Nothing done\n";*/ return; }
@@ -105,5 +109,5 @@
   //#  typ      eta    phi      pt    jmas  ntrk  btag   had/em  dum1  dum2
   outfile << " ## More info on LHCO files: http://cp3wks05.fynu.ucl.ac.be/Manual/lhco.html\n  #" << endl;
-  outfile << "  #  typ    eta    phi      pt    jmas  ntrk  btag   had/em  dum1  dum2" << endl;
+  outfile << "  #  typ   eta     phi     pt     jmas    ntrk    btag   had/em    dum1   dum2" << endl;
 
   // input files
@@ -130,10 +134,12 @@
     analysisTree->ReadEntry(event);
     triggerTree->ReadEntry(event);
- //TRIGT->GetGlobalResult(branchElecTrig, branchMuonTrig,branchJetTrig, branchTauJetTrig,branchPhotonTrig, branchETmisTrig,branchTrigger);
     unsigned int triginfo = 0;
     unsigned int line =0;
+
     outfile << setw(3) << line++  << setw(4) << " " << setw(7) << event << setw(7) << triginfo << endl;
+    outfile.close();
 
     // 0 photon data
+    //outfile << BranchReader(branchPhoton,line,lhcoPhotonID);
     BranchReader(branchPhoton,line,lhcoPhotonID);
 
@@ -155,5 +161,4 @@
   } // event loop
 
-  outfile.close();
   delete triggerTree;
   delete analysisTree;
@@ -161,27 +166,49 @@
 
 
+//ostringstream LHCOConverter::BranchReader(const TClonesArray* branch, unsigned int& line, unsigned short int lhcoID) const {
 void LHCOConverter::BranchReader(const TClonesArray* branch, unsigned int& line, unsigned short int lhcoID) const {
-  ofstream outfile( outputfilename_.c_str(),ios_base::app);
-    
+    //ostringstream outfile;
+    ofstream outfile( outputfilename_.c_str(),ios_base::app);
     unsigned int branch_size = branch->GetEntries();
     TRootParticle * particle = 0;
     for (unsigned int i=0; i< branch_size; i++) {
-	double jmass =0;
+        particle = (TRootParticle*) branch->At(i);
+	double temp =  sqrt(particle->PT*particle->PT + particle->Pz * particle->Pz);
+	double jmass = (particle->E - temp) * (particle->E + temp); // prevents some numerical sensitivity
+	TLorentzVector pmu;
+	pmu.SetPtEtaPhiE(particle->PT, particle->Eta, particle->Phi, particle->E);
+	jmass = pmu.M();
 	unsigned int ntrk = 0;
-	unsigned short int btag =0;
+	float btag =0;
 	double ratioE = 0;
-        particle = (TRootParticle*) branch->At(i);
-        outfile << setw(3) << line++    // line counter
-                << setw(4) << lhcoID    // object ID in lhco format
-                << setw(7) << particle->Eta
-//                << setw(7) << fixed(3) << particle->Eta
-                << setw(7) << particle->Phi
-                << setw(7) << particle->PT
-		<< setw(7) << jmass 	// invariant mass
-		<< setw(7) << ntrk	// number of tracks
-		<< setw(7) << btag	
-		<< setw(7) << ratioE	// E_had/E_em
+	if(lhcoID != lhcoETmisID) {
+        outfile << fixed << setprecision(3)
+		<< setw(3) << line++    // line counter
+                << setw(4) << lhcoID << " "   // object ID in lhco format
+                << setw(7) << particle->Eta <<" "
+                << setw(7) << particle->Phi <<" "
+                << setw(7) << particle->PT  <<" "
+		<< setw(7) << jmass <<" "	// invariant mass
+		<< setw(7) << ntrk  <<" "	// number of tracks
+		<< setw(7) << btag  <<" "	
+		<< setw(7) << ratioE <<" "	// E_had/E_em
+		<< setw(7) << 0.0 << setw(7) << 0.0  // dummy/dummy
                 << endl;
+	} else {
+        outfile << fixed << setprecision(3)
+		<< setw(3) << line++    // line counter
+                << setw(4) << lhcoID << " "   // object ID in lhco format
+                << setw(7) << 0.000 <<" "
+                << setw(7) << particle->Phi <<" "
+                << setw(7) << particle->PT  <<" "
+                << setw(7) << 0. <<" "       // invariant mass
+                << setw(7) << 0  <<" "       // number of tracks
+                << setw(7) << 0.  <<" "
+                << setw(7) << 0. <<" "      // E_had/E_em
+		<< setw(7) << 0.0 << setw(7) << 0.0  // dummy/dummy
+		<< endl;
+	}
     }
-  outfile.close();
-}
+    outfile.close();
+    // return outfile;
+}
