Skip to content

Commit

Permalink
Update tracking for new genfit
Browse files Browse the repository at this point in the history
  • Loading branch information
fairlyons authored and olantwin committed Oct 30, 2024
1 parent 6cf1bd3 commit b21b9e7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ it in future.

* shipStrawTracking: Move to argparse
* CMake: Use external genfit2
* shipStrawTracking, shipDigiReco, shipVertex: Make compatible with current genfit

### Removed

Expand Down
35 changes: 23 additions & 12 deletions python/shipDigiReco.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,34 +931,45 @@ def findTracks(self):
#check
atrack = entry[1]
theTrack = entry[0]
if not theTrack.checkConsistency():
print('Problem with track before fit, not consistent',atrack,theTrack)
continue
try:
theTrack.checkConsistency()
except ROOT.genfit.Exception as e:
print('Problem with track before fit, not consistent',atrack,theTrack)
print(e.what())
ut.reportError(e)
# do the fit
try: self.fitter.processTrack(theTrack) # processTrackWithRep(theTrack,rep,True)
try:
self.fitter.processTrack(theTrack) # processTrackWithRep(theTrack,rep,True)
except:
if global_variables.debug:
print("genfit failed to fit track")
error = "genfit failed to fit track"
ut.reportError(error)
continue
#check
if not theTrack.checkConsistency():
if global_variables.debug:
print('Problem with track after fit, not consistent', atrack, theTrack)
error = "Problem with track after fit, not consistent"
ut.reportError(error)
continue
try:
theTrack.checkConsistency()
except ROOT.genfit.Exception as e:
if global_variables.debug:
print('Problem with track after fit, not consistent', atrack, theTrack)
print(e.what())
error = "Problem with track after fit, not consistent"
ut.reportError(error)
try:
fittedState = theTrack.getFittedState()
fittedMom = fittedState.getMomMag()
except:
error = "Problem with fittedstate"
ut.reportError(error)
continue
fitStatus = theTrack.getFitStatus()
fitStatus = theTrack.getFitStatus()
try:
fitStatus.isFitConverged()
except ROOT.genfit.Exception as e:
error = "Fit not converged"
ut.reportError(error)
nmeas = fitStatus.getNdf()
chi2 = fitStatus.getChi2()/nmeas
chi2 = fitStatus.getChi2() / nmeas
global_variables.h['chi2'].Fill(chi2)
# make track persistent
nTrack = self.fGenFitArray.GetEntries()
Expand Down
4 changes: 3 additions & 1 deletion python/shipStrawTracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,10 @@ def extrapolateToPlane(fT,z):
state = ROOT.genfit.StateOnPlane(rep)
pos,mom = fstate.getPos(),fstate.getMom()
rep.setPosMom(state,pos,mom)
detPlane = ROOT.genfit.DetPlane(NewPosition, parallelToZ)
detPlanePtr = ROOT.genfit.SharedPlanePtr(detPlane)
try:
rep.extrapolateToPlane(state, NewPosition, parallelToZ )
rep.extrapolateToPlane(state, detPlanePtr)
pos,mom = state.getPos(),state.getMom()
rc = True
except:
Expand Down
6 changes: 3 additions & 3 deletions python/shipVertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,16 @@ def TwoTrackVertex(self):
#print "*********************************** vertex fit precise ******************************************** "

detPlane = ROOT.genfit.DetPlane(ROOT.TVector3(0,0,HNLPos[2]),ROOT.TVector3(1,0,0),ROOT.TVector3(0,1,0))
plane = ROOT.genfit.RKTrackRep().makePlane(ROOT.TVector3(0,0,HNLPos[2]),ROOT.TVector3(1,0,0),ROOT.TVector3(0,1,0))
detPlanePtr = ROOT.genfit.SharedPlanePtr(detPlane)
st1 = fittedTracks[t1].getFittedState()
st2 = fittedTracks[t2].getFittedState()
try:
st1.extrapolateToPlane(plane)
st1.extrapolateToPlane(detPlanePtr)
except:
ut.reportError("shipVertex.TwoTrackVertex: extrapolation did not work")
continue
try:
st2.extrapolateToPlane(plane)
st2.extrapolateToPlane(detPlanePtr)
except:
ut.reportError("shipVertex.TwoTrackVertex: extrapolation did not work")
continue
Expand Down

0 comments on commit b21b9e7

Please sign in to comment.