Index: trunk/modules/Hector.cc
===================================================================
--- trunk/modules/Hector.cc	(revision 1360)
+++ trunk/modules/Hector.cc	(revision 1361)
@@ -63,12 +63,16 @@
   fBeamLineLength = GetDouble("BeamLineLength", 430.0);
   fDistance = GetDouble("Distance", 420.0);
+  fOffsetX = GetDouble("OffsetX", 0.0);
+  fOffsetS = GetDouble("OffsetS", 120.0);
   fSigmaE = GetDouble("SigmaE", 0.0);
   fSigmaX = GetDouble("SigmaX", 0.0);
   fSigmaY = GetDouble("SigmaY", 0.0);
+  fSigmaT = GetDouble("SigmaT", 0.0);
   fEtaMin = GetDouble("EtaMin", 5.0);
 
   fBeamLine = new H_BeamLine(fDirection, fBeamLineLength + 0.1);
-  fBeamLine->fill(GetString("BeamLineFile", "examples/LHCB1IR5_5TeV.tfs"), fDirection, "IP5" );
+  fBeamLine->fill(GetString("BeamLineFile", "examples/LHCB1IR5_5TeV.tfs"), fDirection, GetString("IPName", "IP5"));
   fBeamLine->offsetElements(120, -0.097*fDirection);
+  fBeamLine->offsetElements(fOffsetS, fOffsetX);
   fBeamLine->calcMatrix();
 
@@ -80,5 +84,5 @@
   // create output array
 
-  fOutputArray = ExportArray(GetString("OutputArray", "stableParticles"));
+  fOutputArray = ExportArray(GetString("OutputArray", "hits"));
 }
 
@@ -97,5 +101,8 @@
   Candidate *candidate, *mother;
   Double_t pz;
-  Double_t x, y, z, tx, ty;
+  Double_t x, y, z, tx, ty, theta;
+  Double_t distance, time;
+
+  const Double_t c_light = 2.99792458E8;
 
   fItInputArray->Reset();
@@ -118,4 +125,8 @@
     ty = 0.0;
 
+    theta = TMath::Hypot(TMath::ATan(candidateMomentum.Px()/pz), TMath::ATan(candidateMomentum.Py()/pz));
+    distance = (fDistance - 1.0E-3 * candidatePosition.Z())/TMath::Cos(theta);
+    time = gRandom->Gaus((distance + 1.0E-3 * candidatePosition.T())/c_light, fSigmaT);
+
     H_BeamParticle particle(candidate->Mass, candidate->Charge);
     particle.set4Momentum(candidateMomentum);
@@ -133,5 +144,5 @@
     mother = candidate;
     candidate = static_cast<Candidate*>(candidate->Clone());
-    candidate->Position.SetXYZT(particle.getX(), particle.getY(), fDistance, 0.0);
+    candidate->Position.SetXYZT(particle.getX(), particle.getY(), particle.getS(), time);
     candidate->Momentum.SetPxPyPzE(particle.getTX(), particle.getTY(), 0.0, particle.getE());
     candidate->AddCandidate(mother);
Index: trunk/modules/Hector.h
===================================================================
--- trunk/modules/Hector.h	(revision 1360)
+++ trunk/modules/Hector.h	(revision 1361)
@@ -34,9 +34,10 @@
 
   Int_t fDirection;
-  
+
   Double_t fBeamLineLength, fDistance;
-  Double_t fSigmaE, fSigmaX, fSigmaY;
+  Double_t fOffsetX, fOffsetS;
+  Double_t fSigmaE, fSigmaX, fSigmaY, fSigmaT;
   Double_t fEtaMin;
-  
+
   H_BeamLine *fBeamLine;
 
Index: trunk/modules/TreeWriter.cc
===================================================================
--- trunk/modules/TreeWriter.cc	(revision 1360)
+++ trunk/modules/TreeWriter.cc	(revision 1361)
@@ -67,4 +67,5 @@
   fClassMap[Rho::Class()] = &TreeWriter::ProcessRho;
   fClassMap[Weight::Class()] = &TreeWriter::ProcessWeight;
+  fClassMap[HectorHit::Class()] = &TreeWriter::ProcessHectorHit;
 
   TBranchMap::iterator itBranchMap;
@@ -95,5 +96,5 @@
       continue;
     }
-    
+
     itClassMap = fClassMap.find(branchClass);
     if(itClassMap == fClassMap.end())
@@ -160,7 +161,7 @@
   GenParticle *entry = 0;
   Double_t pt, signPz, cosTheta, eta, rapidity;
-  
-  const Double_t c_light = 2.99792458E8;
-  
+
+  const Double_t c_light = 2.99792458E8;
+
   // loop over all particles
   iterator.Reset();
@@ -220,5 +221,5 @@
   Candidate *candidate = 0;
   Vertex *entry = 0;
-  
+
   const Double_t c_light = 2.99792458E8;
 
@@ -248,5 +249,5 @@
   Double_t pt, signz, cosTheta, eta, rapidity;
   const Double_t c_light = 2.99792458E8;
-  
+
   // loop over all tracks
   iterator.Reset();
@@ -310,5 +311,5 @@
   Double_t pt, signPz, cosTheta, eta, rapidity;
   const Double_t c_light = 2.99792458E8;
-  
+
   // loop over all towers
   iterator.Reset();
@@ -317,5 +318,5 @@
     const TLorentzVector &momentum = candidate->Momentum;
     const TLorentzVector &position = candidate->Position;
-    
+
     pt = momentum.Pt();
     cosTheta = TMath::Abs(momentum.CosTheta());
@@ -339,7 +340,7 @@
     entry->Edges[2] = candidate->Edges[2];
     entry->Edges[3] = candidate->Edges[3];
-    
+
     entry->T = position.T()*1.0E-3/c_light;
-    
+
     FillParticles(candidate, &entry->Particles);
   }
@@ -355,5 +356,5 @@
   Double_t pt, signPz, cosTheta, eta, rapidity;
   const Double_t c_light = 2.99792458E8;
-  
+
   array->Sort();
 
@@ -365,5 +366,5 @@
     const TLorentzVector &momentum = candidate->Momentum;
     const TLorentzVector &position = candidate->Position;
-    
+
 
     pt = momentum.Pt();
@@ -379,7 +380,7 @@
     entry->PT = pt;
     entry->E = momentum.E();
-    
+
     entry->T = position.T()*1.0E-3/c_light;
-   
+
     entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad/candidate->Eem : 999.9;
 
@@ -397,5 +398,5 @@
   Double_t pt, signPz, cosTheta, eta, rapidity;
   const Double_t c_light = 2.99792458E8;
-  
+
   array->Sort();
 
@@ -406,5 +407,5 @@
     const TLorentzVector &momentum = candidate->Momentum;
     const TLorentzVector &position = candidate->Position;
-    
+
     pt = momentum.Pt();
     cosTheta = TMath::Abs(momentum.CosTheta());
@@ -418,7 +419,7 @@
     entry->Phi = momentum.Phi();
     entry->PT = pt;
-    
+
     entry->T = position.T()*1.0E-3/c_light;
-    
+
     entry->Charge = candidate->Charge;
 
@@ -437,7 +438,7 @@
   Muon *entry = 0;
   Double_t pt, signPz, cosTheta, eta, rapidity;
-  
-  const Double_t c_light = 2.99792458E8;
-  
+
+  const Double_t c_light = 2.99792458E8;
+
   array->Sort();
 
@@ -448,5 +449,5 @@
     const TLorentzVector &momentum = candidate->Momentum;
     const TLorentzVector &position = candidate->Position;
-    
+
 
     pt = momentum.Pt();
@@ -466,5 +467,5 @@
 
     entry->T = position.T()*1.0E-3/c_light;
-    
+
    // cout<<entry->PT<<","<<entry->T<<endl;
 
@@ -485,5 +486,5 @@
   Double_t ecalEnergy, hcalEnergy;
   const Double_t c_light = 2.99792458E8;
-  
+
   array->Sort();
 
@@ -493,8 +494,8 @@
   {
     TIter itConstituents(candidate->GetCandidates());
-    
-    const TLorentzVector &momentum = candidate->Momentum;
-    const TLorentzVector &position = candidate->Position;
-   
+
+    const TLorentzVector &momentum = candidate->Momentum;
+    const TLorentzVector &position = candidate->Position;
+
     pt = momentum.Pt();
     cosTheta = TMath::Abs(momentum.CosTheta());
@@ -510,5 +511,5 @@
 
     entry->T = position.T()*1.0E-3/c_light;
-    
+
     entry->Mass = momentum.M();
 
@@ -533,5 +534,5 @@
 
     entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy/ecalEnergy : 999.9;
-  
+
     //---   Pile-Up Jet ID variables ----
 
@@ -632,4 +633,34 @@
 //------------------------------------------------------------------------------
 
+void TreeWriter::ProcessHectorHit(ExRootTreeBranch *branch, TObjArray *array)
+{
+  TIter iterator(array);
+  Candidate *candidate = 0;
+  HectorHit *entry = 0;
+
+  // loop over all roman pot hits
+  iterator.Reset();
+  while((candidate = static_cast<Candidate*>(iterator.Next())))
+  {
+    const TLorentzVector &position = candidate->Position;
+    const TLorentzVector &momentum = candidate->Momentum;
+
+    entry = static_cast<HectorHit*>(branch->NewEntry());
+
+    entry->E = momentum.E();
+
+    entry->Tx = momentum.Px();
+    entry->Ty = momentum.Py();
+
+    entry->T = position.T();
+
+    entry->X = position.X();
+    entry->Y = position.Y();
+    entry->S = position.Z();
+  }
+}
+
+//------------------------------------------------------------------------------
+
 void TreeWriter::Process()
 {
Index: trunk/modules/TreeWriter.h
===================================================================
--- trunk/modules/TreeWriter.h	(revision 1360)
+++ trunk/modules/TreeWriter.h	(revision 1361)
@@ -53,4 +53,5 @@
   void ProcessRho(ExRootTreeBranch *branch, TObjArray *array);
   void ProcessWeight(ExRootTreeBranch *branch, TObjArray *array);
+  void ProcessHectorHit(ExRootTreeBranch *branch, TObjArray *array);
 
 #ifndef __CINT__
