diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/bin/beamspotman.py b/InnerDetector/InDetExample/InDetBeamSpotExample/bin/beamspotman.py
index 117dd1c37deb411e302e0b4b8ede1531d648ec2e..bf13101653535e0eeb66c2c5743eaa78b7590384 100755
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/bin/beamspotman.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/bin/beamspotman.py
@@ -5,7 +5,7 @@
 beamspotman is a command line utility to do typical beam spot related tasks.
 """
 __author__  = 'Juerg Beringer'
-__version__ = '$Id: beamspotman.py 759523 2016-07-04 12:49:24Z amorley $'
+__version__ = '$Id: beamspotman.py 780766 2016-10-27 14:03:02Z amorley $'
 __usage__   = '''%prog [options] command [args ...]
 
 Commands are:
@@ -47,6 +47,7 @@ mctag STATUS POSX POSY POSZ             Create an sqlite file containing a MC ta
 # - authorize USERID
 # - deauthorize USERID
 
+
 proddir = '/afs/cern.ch/user/a/atlidbs/jobs'
 produserfile = '/private/produsers.dat'
 prodcoolpasswdfile = '/private/coolinfo.dat'
@@ -1349,11 +1350,15 @@ if cmd=='runaod' and len(args)==5:
     elif os.path.isfile(inputdata):
         # read in the file names from the text file
         for line in open(inputdata,'r'):
+          
+          if line.split('/')[1] == 'castor': 
+            files.append('root://castoratlas/'+line.rstrip())
+          else:
             files.append('root://eosatlas/'+line.rstrip())
-
+    
     # Check if files, matching pattern, exist
     if not files: sys.exit('No files existing in directory %s matching "%s"' % (inputdata, options.filter))
-        
+
     # Get file-LB mapping
     lbMap = {}
     if options.lbfilemap:
@@ -1375,14 +1380,14 @@ if cmd=='runaod' and len(args)==5:
     jobFileDict = {}
     jobLBDict   = {}
     jobParams   = {}
-    
+
     if options.pseudoLbFile:
         # Extract start and end times of real LBs
         from InDetBeamSpotExample.COOLUtils import COOLQuery
         coolQuery = COOLQuery()
         from InDetBeamSpotExample.Utils import getRunFromName        
         lbTimes = coolQuery.getLbTimes( getRunFromName(dsname, None, True) ) 
-
+           
         # Loop over pseudo LBs
         with open(options.pseudoLbFile) as pLbFile:            
             for line in pLbFile:
@@ -1412,7 +1417,6 @@ if cmd=='runaod' and len(args)==5:
                     if not sum([lb for lb in lbs if lb in rlbs]): continue
 
                     filenames.append(f)
-
                 try:
                     jobLBDict[jobId].extend([lb for lb in rlbs if not lb in jobLBDict[jobId]])
                     jobFileDict[jobId].extend([f for f in filenames if not f in jobFileDict[jobId]])                     
@@ -1441,7 +1445,7 @@ if cmd=='runaod' and len(args)==5:
                     if not f in jobFileDict[jobId]:
                         jobFileDict[jobId].append(f)
                     jobLBDict[jobId].append(lbnr)
-
+    
     # Submit bunched jobs
     for i in  sorted(jobFileDict.keys()):
         jobnr = i*lbperjob+1  # use first LB number as job number
@@ -1469,7 +1473,7 @@ if cmd=='runaod' and len(args)==5:
                                            inputfiles=files,
                                            joboptionpath=jobopts,
                                            filesperjob=len(files),
-                                           batchqueue='1nw' if options.pseudoLbFile else 'atlasb1', # run on different queue for VdM scans to avoid cloggin up normal queue # '1nw' '2nd'
+                                           batchqueue='atlasb1_long' if options.pseudoLbFile else 'atlasb1', # run on different queue for VdM scans to avoid cloggin up normal queue # '1nw' '2nd'
                                            addinputtopoolcatalog=True,
                                            taskpostprocsteps=options.postprocsteps,
                                            autoconfparams='DetDescrVersion',
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/bin/beamspotnt.py b/InnerDetector/InDetExample/InDetBeamSpotExample/bin/beamspotnt.py
index 52fdbebe6dcb5accd9e1993cc383715d0937fe9c..bca59a5fda0408ead6fb499609cff94f809b53e9 100755
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/bin/beamspotnt.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/bin/beamspotnt.py
@@ -5,7 +5,7 @@
 beamspotnt is a command line utility for beam spot ntuples.
 """
 __author__  = 'Juerg Beringer'
-__version__ = '$Id: beamspotnt.py 759523 2016-07-04 12:49:24Z amorley $'
+__version__ = '$Id: beamspotnt.py 780766 2016-10-27 14:03:02Z amorley $'
 __usage__   = '''%prog [options] command [args ...]
 
 Commands are:
@@ -362,9 +362,13 @@ def fillInMissingLbs(allBSResultsInNt, lbSize):
           
         if(lastValidEntry >= 0):
           if allBSResultsInNt[nextValidEntry].lbStart !=  allBSResultsInNt[lastValidEntry].lbEnd + 1:
-            print "Missing Lumi block from {:>5d} to {:>5d}".format( allBSResultsInNt[lastValidEntry].lbEnd, allBSResultsInNt[nextValidEntry].lbStart + 1)
+            print "Missing Lumi block from {:>5d} to {:>5d}".format( allBSResultsInNt[lastValidEntry].lbEnd + 1 , allBSResultsInNt[nextValidEntry].lbStart)
+            
+            
             if allBSResultsInNt[nextValidEntry].lbStart -  allBSResultsInNt[lastValidEntry].lbEnd + 1 > lbSize:
               print "--Lumi block gap too large wont fill in the gap"           
+            elif (allBSResultsInNt[nextValidEntry].lbStart-1) -  (allBSResultsInNt[lastValidEntry].lbEnd+1) < 0 :
+              print "Missing Lumi block is invalid from {:>5d} to {:>5d}".format( allBSResultsInNt[lastValidEntry].lbEnd+1, allBSResultsInNt[nextValidEntry].lbStart -1)
             else:
               varList = ['posX','posY','posZ','sigmaX','sigmaY','sigmaZ','tiltX','tiltY','rhoXY','sigmaXY']
               calc = BeamSpotAverage(varList ,weightedAverage=True)
@@ -1190,6 +1194,7 @@ if cmd=='merge' and len(args)==2:
     allBSResultsInNt.sort()  
     if options.useAve:
         cleanUpLowStat( allBSResultsInNt, averagenVtx, lbSize * 10)
+        allBSResultsInNt.sort()
         fillInMissingLbs(allBSResultsInNt, lbSize * 10)
                    
     for b in allBSResultsInNt:
@@ -1370,8 +1375,6 @@ if cmd=='ave' and len(args)==1:
 
     cmdOk = True
 
-
-
 #
 # Different histograms of beam spot variables
 #
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/cron/cronsetup.sh b/InnerDetector/InDetExample/InDetBeamSpotExample/cron/cronsetup.sh
index 32fbc13b1bd26d68cf7a591d349ddb4c9aff27d3..e29de1e7928682ba73d16602b5a7c59e720c207f 100755
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/cron/cronsetup.sh
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/cron/cronsetup.sh
@@ -14,13 +14,14 @@ echo "------------------------------"
 echo "Host name = ${HOSTNAME}"
 echo "------------------------------"
 echo "/usr/kerberos/bin/klist:"
-/usr/kerberos/bin/klist
+#/usr/kerberos/bin/klist
+/usr/bin/klist
 echo "------------------------------"
 echo "/usr/kerberos/bin/kvno host/lxadm10.cern.ch"
-/usr/kerberos/bin/kvno host/lxadm10.cern.ch
+/usr/bin/kvno host/lxadm10.cern.ch
 echo "------------------------------"
 echo "/usr/sue/bin/tokens"
-/usr/sue/bin/tokens
+/usr/bin/tokens
 echo "------------------------------"
 echo "/usr/bin/id"
 /usr/bin/id
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/python/BeamSpotData.py b/InnerDetector/InDetExample/InDetBeamSpotExample/python/BeamSpotData.py
index 5f4a4c864f170dc10c924643462cdf28aff6adbb..10b4a85d09e5aac2851a1b3c6497ab0f5c984281 100644
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/python/BeamSpotData.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/python/BeamSpotData.py
@@ -9,7 +9,7 @@ Frontier outside of CERN. For example:
 setenv FRONTIER_SERVER "(serverurl=http://squid-frontier.usatlas.bnl.gov:23128/frontieratbnl)"
 """
 __author__  = 'Juerg Beringer'
-__version__ = '$Id: BeamSpotData.py 759523 2016-07-04 12:49:24Z amorley $'
+__version__ = '$Id: BeamSpotData.py 759522 2016-07-04 12:47:58Z amorley $'
 
 import time
 import copy
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/python/COOLUtils.py b/InnerDetector/InDetExample/InDetBeamSpotExample/python/COOLUtils.py
index 5b1075c9405d7d29ea19c3cb6c78a1a58139939a..ab3a004cee245f8ea3532c0acea4463b58e59603 100644
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/python/COOLUtils.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/python/COOLUtils.py
@@ -1,11 +1,11 @@
 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 
-# $Id: COOLUtils.py 667995 2015-05-19 06:01:05Z mhance $
+# $Id: COOLUtils.py 780766 2016-10-27 14:03:02Z amorley $
 """
 Miscellaneous utilities related to COOL.
 """
 __author__  = 'Juerg Beringer'
-__version__ = '$Id: COOLUtils.py 667995 2015-05-19 06:01:05Z mhance $'
+__version__ = '$Id: COOLUtils.py 780766 2016-10-27 14:03:02Z amorley $'
 
 import os, time,sys
 
@@ -97,8 +97,6 @@ def writeBeamSpotEntry(folderHandle, tag='nominal',
     payload['tiltYErr'] = float(tiltYErr)
     payload['sigmaXYErr'] = float(sigmaXYErr)
 
-
-
     if tag=='HEAD':
         folderHandle[1].storeObject(since,until,payload,0)
     else:
@@ -122,7 +120,7 @@ def COOLToUnixTime(coolTime):
 #
 class COOLQuery:
     """Utility to query COOL to retrieve start and end time of run and LBs."""
-    def __init__(self,useOracle=True,debug=True):
+    def __init__(self,useOracle=False,debug=True):
 
         self.tdaqdbname='COOLONL_TDAQ/CONDBR2'
         self.coolpath='/TDAQ/RunCtrl'
@@ -136,10 +134,13 @@ class COOLQuery:
         self.oracle = useOracle
         self.debug = debug
 
+        print 'open cool db' 
         self.cooldb = AtlCoolLib.indirectOpen(self.tdaqdbname, True, self.oracle, self.debug)
+        print 'open cooltrig db'
         self.cooltrigdb = AtlCoolLib.indirectOpen(self.trigdbname, True, self.oracle, self.debug)
+        print 'open cooldcs db'
         self.cooldcsdb = AtlCoolLib.indirectOpen(self.dcsdbname, True, self.oracle, self.debug)
-
+         
         self.lbDictCache = {'runnr': None, 'lbDict': None}
 
     def __del__(self):
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/python/ExtractLBFileMap.py b/InnerDetector/InDetExample/InDetBeamSpotExample/python/ExtractLBFileMap.py
index c02d265a5bb3aad6f3a6866300a1e4b2a8fcf84c..eba583f8922d036a2f6a20ce656580685f33ca0a 100755
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/python/ExtractLBFileMap.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/python/ExtractLBFileMap.py
@@ -78,7 +78,6 @@ def extractFromFiles(fileNames):
         try:
             f = ROOT.TFile.Open (fileName)
             assert f.IsOpen()
-
             isNewDataHdr = True
             tree = f.Get ('MetaDataHdr')
 
@@ -128,6 +127,7 @@ def extractFromFiles(fileNames):
                             lbDict[fname].append(lb) 
                         except KeyError:
                             lbDict[fname] = [lb]
+                    #print 'Added lbs for Dict'
 
             except Exception, e:
                 print "## Caught exception [%s] !!" % str(e.__class__)
@@ -149,5 +149,4 @@ def extractFromFiles(fileNames):
             print sys.exc_info()[1]
             sc = 1
             pass
-
     return lbDict
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/python/JobRunner.py b/InnerDetector/InDetExample/InDetBeamSpotExample/python/JobRunner.py
index c0a7be46d4e8b7d3915a6980e3557782935f2e05..f0584c834abdbb11d0251ca37f384d7ec5d5241d 100644
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/python/JobRunner.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/python/JobRunner.py
@@ -11,7 +11,7 @@ Jobs can run interactively, on different batch systems, or on the Grid.
 Written by Juerg Beringer (LBNL) in 2008.
 """
 __author__  = 'Juerg Beringer'
-__version__ = '$Id: JobRunner.py 759523 2016-07-04 12:49:24Z amorley $'
+__version__ = '$Id: JobRunner.py 747883 2016-05-18 06:58:10Z amorley $'
 
 import math
 import os
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/python/PostProcessing.py b/InnerDetector/InDetExample/InDetBeamSpotExample/python/PostProcessing.py
index 1b32e24c727b993930671b206bfbb531d0eff388..361fb537458e6ec2243d0e5fa1df8af0738bc3ec 100644
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/python/PostProcessing.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/python/PostProcessing.py
@@ -61,6 +61,8 @@ def doPostProcessing(taskman,taskDict,postprocSteps,postprocLib,forceRun=False,j
     if not postprocSteps:
         return []   # nothing to do
 
+    #update again from DataBase
+    prePostProcStatus = taskman.getStatus(dsName,taskName)
     # Don't run postprocessing if status is already postprocessing
     if prePostProcStatus>=TaskManager.StatusCodes['POSTPROCRUNNING'] and not forceRun:
         print 'Exiting postprocessing without doing anything: task %s/%s status is %s\n' % (dsName,taskName,getKey(TaskManager.StatusCodes,prePostProcStatus))
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/python/ROOTUtils.py b/InnerDetector/InDetExample/InDetBeamSpotExample/python/ROOTUtils.py
index adc2fa19e3b4fec48ba3785bb2c5c475c4d0220c..e23d107be089966d370f04af5896e8fc7159d2b3 100644
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/python/ROOTUtils.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/python/ROOTUtils.py
@@ -1,11 +1,11 @@
 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 
-# $Id: ROOTUtils.py 721731 2016-02-03 22:26:53Z beringer $
+# $Id: ROOTUtils.py 759047 2016-07-01 00:45:13Z beringer $
 """
 Miscellaneous utilities for PyROOT.
 """
 __author__  = 'Juerg Beringer'
-__version__ = '$Id: ROOTUtils.py 721731 2016-02-03 22:26:53Z beringer $'
+__version__ = '$Id: ROOTUtils.py 759047 2016-07-01 00:45:13Z beringer $'
 
 
 import ROOT
@@ -311,26 +311,19 @@ def atlasLabel(x,y,isPreliminary=False,color=1,offset=0.115,isForApproval=False,
     l.SetTextSize(size)
     l.SetTextColor(color)
     l.DrawLatex(x,y,"ATLAS")
+
+    p = ROOT.TLatex()
+    p.SetNDC()
+    p.SetTextFont(42)
+    p.SetTextSize(size)
+    p.SetTextColor(color)
+
     if customstring != "":
-        p = ROOT.TLatex()
-        p.SetNDC()
-        p.SetTextFont(42)
-        p.SetTextColor(color)
         p.DrawLatex(x+offset,y,customstring)
     else:
         if (isPreliminary):
-            p = ROOT.TLatex()
-            p.SetNDC()
-            p.SetTextFont(42)
-            p.SetTextSize(size)
-            p.SetTextColor(color)
             p.DrawLatex(x+offset,y,"Preliminary")
         if (isForApproval):
-            p = ROOT.TLatex()
-            p.SetNDC()
-            p.SetTextFont(42)
-            p.SetTextSize(size)
-            p.SetTextColor(color)
             #p.DrawLatex(x+offset,y,"Internal for approval")
             p.DrawLatex(x+offset,y,"Internal")
     
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/roofit/ROOTUtils.py b/InnerDetector/InDetExample/InDetBeamSpotExample/roofit/ROOTUtils.py
index adc2fa19e3b4fec48ba3785bb2c5c475c4d0220c..e23d107be089966d370f04af5896e8fc7159d2b3 100644
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/roofit/ROOTUtils.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/roofit/ROOTUtils.py
@@ -1,11 +1,11 @@
 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 
-# $Id: ROOTUtils.py 721731 2016-02-03 22:26:53Z beringer $
+# $Id: ROOTUtils.py 759047 2016-07-01 00:45:13Z beringer $
 """
 Miscellaneous utilities for PyROOT.
 """
 __author__  = 'Juerg Beringer'
-__version__ = '$Id: ROOTUtils.py 721731 2016-02-03 22:26:53Z beringer $'
+__version__ = '$Id: ROOTUtils.py 759047 2016-07-01 00:45:13Z beringer $'
 
 
 import ROOT
@@ -311,26 +311,19 @@ def atlasLabel(x,y,isPreliminary=False,color=1,offset=0.115,isForApproval=False,
     l.SetTextSize(size)
     l.SetTextColor(color)
     l.DrawLatex(x,y,"ATLAS")
+
+    p = ROOT.TLatex()
+    p.SetNDC()
+    p.SetTextFont(42)
+    p.SetTextSize(size)
+    p.SetTextColor(color)
+
     if customstring != "":
-        p = ROOT.TLatex()
-        p.SetNDC()
-        p.SetTextFont(42)
-        p.SetTextColor(color)
         p.DrawLatex(x+offset,y,customstring)
     else:
         if (isPreliminary):
-            p = ROOT.TLatex()
-            p.SetNDC()
-            p.SetTextFont(42)
-            p.SetTextSize(size)
-            p.SetTextColor(color)
             p.DrawLatex(x+offset,y,"Preliminary")
         if (isForApproval):
-            p = ROOT.TLatex()
-            p.SetNDC()
-            p.SetTextFont(42)
-            p.SetTextSize(size)
-            p.SetTextColor(color)
             #p.DrawLatex(x+offset,y,"Internal for approval")
             p.DrawLatex(x+offset,y,"Internal")
     
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/share/ReadInDetRecFragment.py b/InnerDetector/InDetExample/InDetBeamSpotExample/share/ReadInDetRecFragment.py
index 5cc476c19943e96e35732d1fb4675ffbef14655c..e79da5cfbaeebbd04edfa7ef2d8aa146da68a76f 100644
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/share/ReadInDetRecFragment.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/share/ReadInDetRecFragment.py
@@ -1,4 +1,4 @@
-# $Id: ReadInDetRecFragment.py 714548 2015-12-14 16:30:23Z amorley $
+# $Id: ReadInDetRecFragment.py 780766 2016-10-27 14:03:02Z amorley $
 #
 # Job option fragment for JobRunner templates to setup InDet
 # environment following InDetRecExample/ReadInDet_jobOptions.py
@@ -9,7 +9,7 @@
 #
 # Written by Juerg Beringer in November 2009.
 #
-print "InDetBeamSpotExample INFO Using $Id: ReadInDetRecFragment.py 714548 2015-12-14 16:30:23Z amorley $"
+print "InDetBeamSpotExample INFO Using $Id: ReadInDetRecFragment.py 780766 2016-10-27 14:03:02Z amorley $"
 
 
 # Default values (please put a default for EACH jobConfig parameter
@@ -63,7 +63,7 @@ if not 'griduser' in jobConfig:                      jobConfig['griduser'] = ''
 readESD = jobConfig['doPatternRecoAndTracking'] or jobConfig['doPrimaryVertexing']
 readAOD = not readESD
 doWriteESD = False and readESD
-doWriteAOD = jobConfig['doPatternRecoAndTracking'] or jobConfig['doPrimaryVertexing'] or jobConfig['doForceWriteDPD']
+doWriteAOD = False # jobConfig['doPatternRecoAndTracking'] or jobConfig['doPrimaryVertexing'] or jobConfig['doForceWriteDPD']
 
 
 print jobConfig['inputfiles']
@@ -80,9 +80,9 @@ doRefitTracks = False and readESD
 # --- redo the pattern reco and the tracking (do not use that in conjunction with doRefitTracks above)
 redoPatternRecoAndTracking = jobConfig['doPatternRecoAndTracking'] and not doRefitTracks and readESD
 # --- redo primary vertexing (will be set to true later automatically if you redid the tracking and want to redo the TrackParticle creation)
-reDoPrimaryVertexing = jobConfig['doPrimaryVertexing'] or redoPatternRecoAndTracking or jobConfig['doVertexStandalone']
+reDoPrimaryVertexing = False #jobConfig['doPrimaryVertexing'] or redoPatternRecoAndTracking or jobConfig['doVertexStandalone']
 # --- redo particle creation (recommended after revertexing on ESD, otherwise trackparticles are inconsistent)
-reDoParticleCreation = (redoPatternRecoAndTracking or reDoPrimaryVertexing) and not jobConfig['doVertexStandalone']
+reDoParticleCreation = False #(redoPatternRecoAndTracking or reDoPrimaryVertexing) and not jobConfig['doVertexStandalone']
 # --- redo conversion finding
 reDoConversions = False
 # --- redo V0 finding
@@ -172,8 +172,8 @@ if not jobConfig['hasMag']:
 from AthenaCommon.DetFlags import DetFlags 
 from InDetRecExample.InDetJobProperties import InDetFlags
 # --- switch on InnerDetector
-#DetFlags.ID_setOn()
-DetFlags.ID_setOff()
+DetFlags.ID_setOn()
+#DetFlags.ID_setOff()
 # --- and switch off all the rest
 DetFlags.Calo_setOff()
 DetFlags.Muon_setOff()
@@ -195,7 +195,8 @@ if not jobConfig['hasSCT']:
   else:
     DetFlags.SCT_setOff()
     DetFlags.detdescr.SCT_setOn()
-#DetFlags.TRT_setOff()
+
+DetFlags.TRT_setOff()
 #DetFlags.detdescr.TRT_setOn()
 # --- printout
 if jobConfig['doPrintIndetConfig']:
@@ -247,6 +248,10 @@ InDetFlags.doRefit            = doRefitTracks
 InDetFlags.doLowBetaFinder    = False
 InDetFlags.doPrintConfigurables = jobConfig['doPrintIndetConfig']
 
+### Key flag  -- this will create the unconstrained beamspot collection on the fly from standard xAOD::TrackParticles
+InDetFlags.doVertexFindingForMonitoring = jobConfig['doPrimaryVertexing']
+
+
 # Standard monitoring
 InDetFlags.doMonitoringGlobal    = jobConfig['doMonitoringGlobal']
 
@@ -297,6 +302,16 @@ if jobConfig['doPrintIndetConfig']:
   InDetKeys.print_JobProperties()
 
 
+if jobConfig['doPrimaryVertexing'] : 
+  jobConfig['VertexContainer'] = InDetKeys.PrimaryVerticesWithoutBeamConstraint()
+  from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
+  RefittedVertexStream = MSMgr.NewPoolRootStream( "RefittedVertexStream", "RefittedVertex.pool.root" )
+  RefittedVertexStream.AddItem( 'xAOD::VertexContainer#'+InDetKeys.PrimaryVerticesWithoutBeamConstraint() )
+  RefittedVertexStream.AddItem( 'xAOD::VertexAuxContainer#'+InDetKeys.PrimaryVerticesWithoutBeamConstraint()+'Aux.-vxTrackAtVertex' )
+  RefittedVertexStream.AddItem( 'xAOD::EventInfo#EventInfo' )
+  RefittedVertexStream.AddItem( 'xAOD::EventAuxInfo#EventInfoAux.' )
+
+
 #--------------------------------------------------------------
 # enable statistics for reading ESD testing
 #--------------------------------------------------------------
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/share/VertexTemplate.py b/InnerDetector/InDetExample/InDetBeamSpotExample/share/VertexTemplate.py
index 4108122b1a9f4c6aa63660ff608755dd32795c3d..7de91c68759c5be0fa44bbea53181f5a45f47e0b 100644
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/share/VertexTemplate.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/share/VertexTemplate.py
@@ -1,11 +1,11 @@
-# $Id: VertexTemplate.py 714548 2015-12-14 16:30:23Z amorley $
+# $Id: VertexTemplate.py 780766 2016-10-27 14:03:02Z amorley $
 #
 # Top-level job options file to run the vertex-based beamspot algorithm
 # from AOD files using a JobRunner.
 #
 # Written by Juerg Beringer in July 2008.
 #
-print "InDetBeamSpotExample INFO Using $Id: VertexTemplate.py 714548 2015-12-14 16:30:23Z amorley $"
+print "InDetBeamSpotExample INFO Using $Id: VertexTemplate.py 780766 2016-10-27 14:03:02Z amorley $"
 
 # Default values (please put a default for EACH jobConfig parameter
 # so that the template can be used easily without JobRunner)
@@ -61,6 +61,8 @@ if not 'BeamSpotToolList' in jobConfig:              jobConfig['BeamSpotToolList
 #Fit Options for RooFit only
 if not 'RooFitMaxTransverseErr' in jobConfig:        jobConfig['RooFitMaxTransverseErr'] = 0.05
 
+if not 'FixWidth' in jobConfig:                      jobConfig['FixWidth'] =  False
+
 # General job setup
 include("InDetBeamSpotExample/AutoConfFragment.py")
 include("InDetBeamSpotExample/ReadInDetRecFragment.py")
@@ -89,17 +91,21 @@ ToolSvc += CfgMgr.InDet__InDetBeamSpotVertex(name            = 'InDetBeamSpotVer
                                              OutlierRhoFail  = 0.8,
                                              InitParK        = jobConfig['InitialKFactor'],
                                              FixParK         = jobConfig['ConstantKFactor'],
+                                             FixWidth        = jobConfig['FixWidth'],
                                              TruncatedRMS    = jobConfig['TruncatedRMS'],
                                              SetInitialRMS   = jobConfig['SetInitialRMS'],
                                              OutputLevel     = min(INFO,jobConfig['outputlevel']))
 
 
+print ToolSvc.InDetBeamSpotVertex
+
 ToolSvc += CfgMgr.InDet__InDetBeamSpotRooFit(name            = 'InDetBeamSpotRooFit',
                                              OutputLevel     = min(INFO,jobConfig['outputlevel']),
                                              InitialKFactor  = jobConfig['InitialKFactor'],
                                              ConstantKFactor = jobConfig['ConstantKFactor'],
                                              vtxResCut       = jobConfig['RooFitMaxTransverseErr'])
 
+print ToolSvc.InDetBeamSpotRooFit
 
 topSequence += CfgMgr.InDet__InDetBeamSpotFinder(name                = 'InDetBeamSpotFinder',
                                                  #job options
diff --git a/InnerDetector/InDetExample/InDetBeamSpotExample/www/beamspotnt.py b/InnerDetector/InDetExample/InDetBeamSpotExample/www/beamspotnt.py
index 52fdbebe6dcb5accd9e1993cc383715d0937fe9c..bca59a5fda0408ead6fb499609cff94f809b53e9 100755
--- a/InnerDetector/InDetExample/InDetBeamSpotExample/www/beamspotnt.py
+++ b/InnerDetector/InDetExample/InDetBeamSpotExample/www/beamspotnt.py
@@ -5,7 +5,7 @@
 beamspotnt is a command line utility for beam spot ntuples.
 """
 __author__  = 'Juerg Beringer'
-__version__ = '$Id: beamspotnt.py 759523 2016-07-04 12:49:24Z amorley $'
+__version__ = '$Id: beamspotnt.py 780766 2016-10-27 14:03:02Z amorley $'
 __usage__   = '''%prog [options] command [args ...]
 
 Commands are:
@@ -362,9 +362,13 @@ def fillInMissingLbs(allBSResultsInNt, lbSize):
           
         if(lastValidEntry >= 0):
           if allBSResultsInNt[nextValidEntry].lbStart !=  allBSResultsInNt[lastValidEntry].lbEnd + 1:
-            print "Missing Lumi block from {:>5d} to {:>5d}".format( allBSResultsInNt[lastValidEntry].lbEnd, allBSResultsInNt[nextValidEntry].lbStart + 1)
+            print "Missing Lumi block from {:>5d} to {:>5d}".format( allBSResultsInNt[lastValidEntry].lbEnd + 1 , allBSResultsInNt[nextValidEntry].lbStart)
+            
+            
             if allBSResultsInNt[nextValidEntry].lbStart -  allBSResultsInNt[lastValidEntry].lbEnd + 1 > lbSize:
               print "--Lumi block gap too large wont fill in the gap"           
+            elif (allBSResultsInNt[nextValidEntry].lbStart-1) -  (allBSResultsInNt[lastValidEntry].lbEnd+1) < 0 :
+              print "Missing Lumi block is invalid from {:>5d} to {:>5d}".format( allBSResultsInNt[lastValidEntry].lbEnd+1, allBSResultsInNt[nextValidEntry].lbStart -1)
             else:
               varList = ['posX','posY','posZ','sigmaX','sigmaY','sigmaZ','tiltX','tiltY','rhoXY','sigmaXY']
               calc = BeamSpotAverage(varList ,weightedAverage=True)
@@ -1190,6 +1194,7 @@ if cmd=='merge' and len(args)==2:
     allBSResultsInNt.sort()  
     if options.useAve:
         cleanUpLowStat( allBSResultsInNt, averagenVtx, lbSize * 10)
+        allBSResultsInNt.sort()
         fillInMissingLbs(allBSResultsInNt, lbSize * 10)
                    
     for b in allBSResultsInNt:
@@ -1370,8 +1375,6 @@ if cmd=='ave' and len(args)==1:
 
     cmdOk = True
 
-
-
 #
 # Different histograms of beam spot variables
 #