Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,24 @@ public class HpsReconParticleDriver extends ReconParticleDriver {
private double[] beamPositionToUse = new double[3];
private boolean requireClustersForV0 = true;

/**
* Whether to refit TARGET_CONSTRAINED vertices after shifting the tracks
* to the first-pass vertex, as is done for UNCONSTRAINED and
* BS_CONSTRAINED. Off by default (original behaviour).
*/
private boolean refitTargetConstrained = false;

/**
* Whether the first-pass vertex fit uses the reference point of the
* input track states. Kalman perigee states are defined about the beam
* spot (e.g. z = -1.1 mm), not the origin; without this the fitter
* assumes the origin, which biases target-constrained fits (the vertex
* is pulled to twice the target z and the opening angle closes by ~2%).
* On by default; set false to reproduce the original (pass5 and earlier)
* behaviour.
*/
private boolean useTrackReferencePoint = true;

/**
* Represents a type of constraint for vertex fitting.
*
Expand Down Expand Up @@ -283,6 +301,27 @@ public void setStoreCovTrkMomList(boolean b) {
public void setRequireClustersForV0(boolean b) {
this.requireClustersForV0 = b;
}

/**
* Set whether TARGET_CONSTRAINED vertices are refit with the tracks
* shifted to the first-pass vertex.
*
* @param b True to refit target-constrained vertices
*/
public void setRefitTargetConstrained(boolean b) {
this.refitTargetConstrained = b;
}

/**
* Set whether the first-pass vertex fit is done about the reference
* point of the input track states instead of the origin (default true).
* Set false only to reproduce the original behaviour.
*
* @param b True to use the track state reference point
*/
public void setUseTrackReferencePoint(boolean b) {
this.useTrackReferencePoint = b;
}

public void setUnconstrainedMollerCandidatesColName(String s)
{
Expand Down Expand Up @@ -545,6 +584,22 @@ private BilliorVertex fitVertex(Constraint constraint, ReconstructedParticle ele
break;
}

// The Billior tracks carry the parameters of the first track state,
// which are defined about that state's reference point (tracking
// frame). Fit about the same point so that the vertex position and
// the beam/target constraints are computed in absolute coordinates.
if (useTrackReferencePoint) {
double[] eleRef = electron.getTracks().get(0).getTrackStates().get(0).getReferencePoint();
double[] posRef = positron.getTracks().get(0).getTrackStates().get(0).getReferencePoint();
if (Math.abs(eleRef[0] - posRef[0]) > 1e-6 || Math.abs(eleRef[1] - posRef[1]) > 1e-6
|| Math.abs(eleRef[2] - posRef[2]) > 1e-6) {
LOGGER.warning(String.format("Electron and positron track reference points differ: "
+ "(%f, %f, %f) vs (%f, %f, %f); using the electron's.",
eleRef[0], eleRef[1], eleRef[2], posRef[0], posRef[1], posRef[2]));
}
vtxFitter.setReferencePosition(eleRef);
}

// Add the electron and positron tracks to a track list for
// the vertex fitter.
List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>();
Expand Down Expand Up @@ -589,7 +644,10 @@ private BilliorVertex fitVertex(Constraint constraint, ReconstructedParticle ele
// ... this is required because the vertex fit assumes trajectories
// change linearly about the reference point (which we initially guess to be
// (0,0,0) while for long-lived decays there is significant curvature
if (constraint == Constraint.BS_CONSTRAINED || constraint == Constraint.UNCONSTRAINED) {
// Optionally do the same for TARGET_CONSTRAINED: the first pass is
// linearized about (0,0,0), the refit about the target point itself.
if (constraint == Constraint.BS_CONSTRAINED || constraint == Constraint.UNCONSTRAINED
|| (constraint == Constraint.TARGET_CONSTRAINED && refitTargetConstrained)) {
List<ReconstructedParticle> recoList = new ArrayList<ReconstructedParticle>();
recoList.add(electron);
recoList.add(positron);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@ public void setBeamSigmaY(double sigmaY) {
beamSize[2] = sigmaY; // The beamsize array is in the tracking frame HPS Y => TRACK Z
}

/**
* Sets the beam size sigma in the z-direction.
*
* @param sigmaZ - The standard deviation of the beam width in the
* z-direction (beam/target longitudinal spread).
*/
public void setBeamSigmaZ(double sigmaZ) {
beamSize[0] = sigmaZ; // The beamsize array is in the tracking frame HPS Z => TRACK X
}

/**
* Sets the beam position in the z-direction in mm.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,12 @@ private BasicMatrix makeRk(double Vx, double Vy, double Vz, double pxtot, double
rk.setElement(1, 0, _beamPosition[1] - ((Vy + _referencePosition[1]) - pytot / pxtot * (Vx - _beamPosition[0] + _referencePosition[0])));
rk.setElement(2, 0, _beamPosition[2] - ((Vz + _referencePosition[2]) - pztot / pxtot * (Vx - _beamPosition[0] + _referencePosition[0])));
} else {
rk.setElement(0, 0, _beamPosition[0] - Vx);
rk.setElement(1, 0, _beamPosition[1] - Vy);
rk.setElement(2, 0, _beamPosition[2] - Vz);
// The vertex position is relative to the reference position, so add it back

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is the whole fix? Maybe the referencePosition isn't (0,0,0), which is presumed in the previous?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did try without the refit and only this change, but the bias was still there. Without the refit it wasnt to pull it to ~0.5mm ... between target generation point and (0,0,0)

// before comparing with the (absolute) target position. The reference is the
// origin unless the tracks were shifted for a refit (see HpsReconParticleDriver).
rk.setElement(0, 0, _beamPosition[0] - (Vx + _referencePosition[0]));
rk.setElement(1, 0, _beamPosition[1] - (Vy + _referencePosition[1]));
rk.setElement(2, 0, _beamPosition[2] - (Vz + _referencePosition[2]));
}
if (_debug)
System.out.println("makeRk::rk = (" + rk.e(0, 0) + ", " + rk.e(1, 0) + ", " + rk.e(2, 0) + ")");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
<?xml version="1.0" encoding="UTF-8"?>
<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
<!--
Steering file for pass-5 2021 reconstruction on MC readout data
created: 12/18/2025
@author Matthew Gignac <mgignac@slac.stanford.edu>, Sarah Gaiser <sgaiser@slac.stanford.edu>

Fixed-beam-position variant of
PhysicsRun2021MCRecon_KF_WithSpacing_pass5_physics_HitSmear_HitKill_14272.lcsim.
The beam position is NOT read from the conditions database (which puts the
target-constrained vertex at x = +0.091, y = -0.021 mm while the MC beam is
at x = y = 0); it is fixed from this file instead:
[ Z, X, Y ] = [ -1.1, 0.0, 0.0 ] mm (HPS frame), sigmas unchanged
(x 0.055, y 0.045, z = code default 0.001 mm).
Only these drivers differ from the original:
KalmanPatRecDriver: useBeamPositionConditions false, beamPositionX/Y 0.0
ReconParticleDriver_Kalman: useBeamPositionConditions false, beamPositionX/Y 0.0,
deprecated useInternalVertexXYPositions removed
(it is an alias that also sets useBeamPositionConditions)
refitTargetConstrained true: target-constrained vertices are
refit with the tracks shifted to the first-pass vertex, as for
the unconstrained/beamspot fits. Removes the ~2% closing of the
top/bottom opening angle (and ~-2.4 MeV mass bias at 180 MeV).
Requires an hps-java build that has this option.
-->
<execute>

<driver name="EventMarkerDriver"/>

<!-- Ecal reconstruction drivers -->
<driver name="EcalRawConverter" />
<driver name="EcalTimeCorrection"/>
<driver name="ReconClusterer" />
<driver name="CopyCluster" />

<!-- Hodoscope drivers -->
<driver name="HodoRunningPedestal"/>
<driver name="HodoRawConverter"/>

<!-- SVT reconstruction drivers -->
<driver name="RawTrackerHitSensorSetup"/>
<driver name="RawTrackerHitFitterDriver" />
<driver name="RawHitTimeSmearer"/>
<driver name="TrackerHitDriver"/>
<driver name="StripHitKiller"/>


<driver name="StripHitNHitsSmearer"/>


<driver name="KalmanPatRecDriver"/>
<driver name="TrackTimeSmearer"/>
<driver name="TrackTruthMatching_KF"/>
<driver name="ReconParticleDriver_Kalman" />



<!-- Event filtering -->
<driver name="LCIOWriter"/>
<driver name="AidaSaveDriver"/>
<driver name="CleanupDriver"/>

</execute>
<drivers>
<driver name="SVTHitEfficiency" type="org.hps.recon.tracking.kalman.SvtHitEfficiencyKalman">
<maxLayer>14</maxLayer>
<useTrkTimeCut>false</useTrkTimeCut>
<!--<trkTimeCut>10.0</trkTimeCut> -->
<!-- <trkTimeMean>15.0</trkTimeMean> -->
<debug>false</debug>
</driver>
<driver name="StripHitKiller" type="org.hps.recon.tracking.StripHitKiller">
<ratioFiles>pass5v9run14272_L1b_axial_hole.txt pass5v9run14272_L1b_stereo_hole.txt pass5v9run14272_L1t_axial_hole.txt pass5v9run14272_L1t_stereo_hole.txt pass5v9run14272_L2b_axial_hole.txt pass5v9run14272_L2b_stereo_hole.txt pass5v9run14272_L2t_axial_hole.txt pass5v9run14272_L2t_stereo_hole.txt</ratioFiles>
<debug>false</debug>
</driver>
<driver name="RawHitTimeSmearer" type="org.hps.recon.tracking.RawHitTimeSmearer">
<smearTimeFile>timeSmearing-2nsL4L7-4nsL1L3.txt</smearTimeFile>
<debug>false</debug>
</driver>
<driver name="TrackTimeSmearer" type="org.hps.recon.tracking.TrackTimeSmearer">
<debug>false</debug>
<smearBottom>0.8</smearBottom>
<smearTop>0.8</smearTop>
</driver>
<driver name="StripHitNHitsSmearer" type="org.hps.recon.tracking.StripHitNHitsSmearer">
<smearPositionFile>posSmearing_pass5_v9.txt</smearPositionFile>
<debug>false</debug>
</driver>
<driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver">
<eventInterval>1000</eventInterval>
</driver>
<driver name="HodoRunningPedestal" type="org.hps.recon.ecal.HodoRunningPedestalDriver">
<inputCollectionName>HodoscopeReadoutHits</inputCollectionName>
<logLevel>CONFIG</logLevel>
<isMC>true</isMC>
</driver>
<driver name="HodoRawConverter" type="org.hps.recon.ecal.HodoRawConverterDriver">
<inputCollectionName>HodoscopeReadoutHits</inputCollectionName>
<tETAllChannels>8</tETAllChannels>
<logLevel>CONFIG</logLevel>
<isMC>true</isMC>
</driver>

<!-- Ecal reconstruction drivers -->
<driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverter2Driver">
</driver>
<driver name="EcalTimeCorrection" type="org.hps.recon.ecal.EcalTimeCorrectionDriver">
<additionalShift>13.3</additionalShift>
</driver>
<driver name="ReconClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver">
<logLevel>WARNING</logLevel>
<outputClusterCollectionName>EcalClusters</outputClusterCollectionName>
</driver>
<driver name="CopyCluster" type="org.hps.recon.ecal.cluster.CopyClusterCollectionDriver">
<inputCollectionName>EcalClusters</inputCollectionName>
<outputCollectionName>EcalClustersCorr</outputCollectionName>
</driver>
<!-- SVT reconstruction drivers -->
<driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup">
<readoutCollections>SVTRawTrackerHits</readoutCollections>
</driver>
<driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver">
<chiSqrThresh>.5</chiSqrThresh>
<doOldDT>1</doOldDT>
<fitAlgorithm>Pileup</fitAlgorithm>
<fitTimeMinimizer>Migrad</fitTimeMinimizer>
<useTimestamps>true</useTimestamps>
<tsCorrectionScale>165</tsCorrectionScale>
<correctTimeOffset>true</correctTimeOffset>
<correctT0Shift>true</correctT0Shift>
<useTruthTime>false</useTruthTime>
<subtractTOF>true</subtractTOF>
<subtractTriggerTime>false</subtractTriggerTime>
<correctChanT0>false</correctChanT0>
<isMC>true</isMC>
<debug>false</debug>
</driver>
<driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver">
<neighborDeltaT>24.0</neighborDeltaT>
<neighborDeltaTSigma>3.0</neighborDeltaTSigma>
<saveMonsterEvents>false</saveMonsterEvents>
<thresholdMonsterEvents>400</thresholdMonsterEvents>
<clusterSeedThreshold>4.0</clusterSeedThreshold>
<doTimeError>1.0</doTimeError>
<clusterNeighborThreshold>3.0</clusterNeighborThreshold>
<clusterThreshold>3.0</clusterThreshold>
<doDeadFix>true</doDeadFix>
<doVSplit>true</doVSplit>
<debug>false</debug>
</driver>
<driver name="KalmanPatRecDriver" type="org.hps.recon.tracking.kalman.KalmanPatRecDriver">
<addResiduals>true</addResiduals>
<addKinks>true</addKinks>
<numPatRecIteration> 2 </numPatRecIteration>
<numKalmanIteration> 1 </numKalmanIteration>
<maxPtInverse> 8.881915381218574 </maxPtInverse>
<maxD0> 39.249197341740356 </maxD0>
<maxZ0> 8.37847994612359 </maxZ0>
<maxChi2> 11.546843987796496 </maxChi2>
<minHitsTopIter1> 9 </minHitsTopIter1>
<minHitsBotIter1> 9 </minHitsBotIter1>
<minHitsTopIter2> 8 </minHitsTopIter2>
<minHitsBotIter2> 8 </minHitsBotIter2>
<minStereo> 3 </minStereo>
<maxSharedHits> 2 </maxSharedHits>
<maxTimeRange> 40.0 </maxTimeRange>
<maxTanLambda> 5.0 </maxTanLambda>
<maxChi2Inc> 12.320066328390354 </maxChi2Inc>
<minChi2IncBad> 9.206482863412027 </minChi2IncBad>
<maxChi2IncShare> 5.862027198856136 </maxChi2IncShare>
<mxChi2Vtx> 5.508828061070076 </mxChi2Vtx>
<numEvtPlots> 5 </numEvtPlots>
<doDebugPlots> false </doDebugPlots>
<siHitsLimit> 400 </siHitsLimit>
<seedCompThr> 0.3473319986601534 </seedCompThr>
<useBeamPositionConditions>false</useBeamPositionConditions>
<beamPositionX>0.0</beamPositionX>
<beamPositionY>0.0</beamPositionY>
<beamSigmaX>0.055</beamSigmaX>
<beamSigmaY>0.045</beamSigmaY>
<useFixedVertexZPosition>true</useFixedVertexZPosition>
<beamPositionZ>-1.1</beamPositionZ>
<lowPhThresh> 7.197594353612735 </lowPhThresh>
<verbose> false </verbose>
</driver>
<driver name="TrackTruthMatching_KF" type="org.hps.analysis.MC.TrackToMCParticleRelationsDriver">
<trackCollectionName>KalmanFullTracks</trackCollectionName>
<kalmanTracks>true</kalmanTracks>
<debug>false</debug>
</driver>
<driver name="ReconParticleDriver_Kalman" type="org.hps.recon.particle.HpsReconParticleDriver" >
<ecalClusterCollectionName>EcalClustersCorr</ecalClusterCollectionName>
<trackCollectionNames>KalmanFullTracks</trackCollectionNames>
<matcherTrackCollectionName>KalmanFullTracks</matcherTrackCollectionName>
<trackClusterMatcherAlgo>TrackClusterMatcherMinDistance</trackClusterMatcherAlgo>
<unconstrainedV0CandidatesColName>UnconstrainedV0Candidates_KF</unconstrainedV0CandidatesColName>
<unconstrainedV0VerticesColName>UnconstrainedV0Vertices_KF</unconstrainedV0VerticesColName>
<beamConV0CandidatesColName>BeamspotConstrainedV0Candidates_KF</beamConV0CandidatesColName>
<beamConV0VerticesColName>BeamspotConstrainedV0Vertices_KF</beamConV0VerticesColName>
<targetConV0CandidatesColName>TargetConstrainedV0Candidates_KF</targetConV0CandidatesColName>
<targetConV0VerticesColName>TargetConstrainedV0Vertices_KF</targetConV0VerticesColName>
<finalStateParticlesColName>FinalStateParticles_KF</finalStateParticlesColName>
<otherElectronsColName>OtherElectrons_KF</otherElectronsColName>
<includeUnmatchedTracksInFSP>true</includeUnmatchedTracksInFSP>
<useBeamPositionConditions>false</useBeamPositionConditions>
<requireClustersForV0>false</requireClustersForV0>
<!-- refit TC vertices about the target point (needs hps-java with setRefitTargetConstrained) -->
<refitTargetConstrained>true</refitTargetConstrained>
<beamPositionX>0.0</beamPositionX>
<beamPositionY>0.0</beamPositionY>
<beamSigmaX>0.055</beamSigmaX>
<beamSigmaY>0.045</beamSigmaY>
<beamPositionZ>-1.1</beamPositionZ>
<maxElectronP>7.0</maxElectronP>
<maxVertexP>7.0</maxVertexP>
<minVertexChisqProb>0.0</minVertexChisqProb>
<maxVertexClusterDt>40.0</maxVertexClusterDt>
<maxMatchDt>40</maxMatchDt>
<trackClusterTimeOffset>40</trackClusterTimeOffset>
<useCorrectedClusterPositionsForMatching>false</useCorrectedClusterPositionsForMatching>
<applyClusterCorrections>true</applyClusterCorrections>
<useTrackPositionForClusterCorrection>true</useTrackPositionForClusterCorrection>
<debug>false</debug>
<isMC>true</isMC>
<makeMollerCols>true</makeMollerCols>
<unconstrainedMollerCandidatesColName>UnconstrainedMollerCandidates_KF</unconstrainedMollerCandidatesColName>
<unconstrainedMollerVerticesColName>UnconstrainedMollerVertices_KF</unconstrainedMollerVerticesColName>
<beamConMollerCandidatesColName>BeamspotConstrainedMollerCandidates_KF</beamConMollerCandidatesColName>
<beamConMollerVerticesColName>BeamspotConstrainedMollerVertices_KF</beamConMollerVerticesColName>
<targetConMollerCandidatesColName>TargetConstrainedMollerCandidates_KF</targetConMollerCandidatesColName>
<targetConMollerVerticesColName>TargetConstrainedMollerVertices_KF</targetConMollerVerticesColName>
</driver>
<driver name="AidaSaveDriver" type="org.lcsim.job.AidaSaveDriver">
<outputFileName>${outputFile}_hit_eff.root</outputFileName>
</driver>
<driver name="LCIOWriter" type="org.lcsim.util.loop.LCIODriver">
<outputFilePath>${outputFile}.slcio</outputFilePath>
</driver>
<driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"/>

</drivers>
</lcsim>

Loading