Skip to content
Merged
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
113 changes: 58 additions & 55 deletions recon/src/main/java/org/hps/recon/particle/HpsReconParticleDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* candidates and does vertex fits.
*/
public class HpsReconParticleDriver extends ReconParticleDriver {

private Logger LOGGER = Logger.getLogger(HpsReconParticleDriver.class.getPackage().getName());

/**
Expand All @@ -55,7 +55,7 @@ public class HpsReconParticleDriver extends ReconParticleDriver {
* spot constraints.
*/
protected String beamConMollerCandidatesColName = "BeamspotConstrainedMollerCandidates";

/**
* LCIO collection name for Moller candidate particles generated with target
* constraints.
Expand Down Expand Up @@ -118,31 +118,31 @@ public class HpsReconParticleDriver extends ReconParticleDriver {
protected List<Vertex> unconstrainedVcVertices;

private boolean makeConversionCols = true;

private boolean makeMollerCols = true;

private boolean includeUnmatchedTracksInFSP = true;

/**
* Whether to read beam positions from the conditions database.
* By default this is turned off.
* Whether to read beam positions from the conditions database. By default
* this is turned off.
*/
private boolean useBeamPositionConditions = false;

/**
* Whether to use a fixed Z position for the 2016 run.
* By default this is turned on.
* Whether to use a fixed Z position for the 2016 run. By default this is
* turned on.
*/
private boolean useFixedVertexZPosition = true;

/**
* The actual beam position passed to the vertex fitter.
*
* This can come from the parent class's default or steering settings,
* or the conditions database, depending on flag settings.
*
* This can come from the parent class's default or steering settings, or
* the conditions database, depending on flag settings.
*/
private double[] beamPositionToUse = new double[3];
private boolean requireClustersForV0=true;
private boolean requireClustersForV0 = true;

/**
* Represents a type of constraint for vertex fitting.
Expand Down Expand Up @@ -172,23 +172,23 @@ private enum Constraint {
public HpsReconParticleDriver() {
super();
}

protected void detectorChanged(Detector detector) {

// Make sure super-class setup is activated.
super.detectorChanged(detector);

// Setup optional usage of beam positions from database.
final DatabaseConditionsManager mgr = DatabaseConditionsManager.getInstance();
if (this.useBeamPositionConditions && mgr.hasConditionsRecord("beam_positions")) {
LOGGER.config("Using beam position from conditions database");
BeamPositionCollection beamPositions =
mgr.getCachedConditions(BeamPositionCollection.class, "beam_positions").getCachedData();
BeamPosition beamPositionCond = beamPositions.get(0);
BeamPositionCollection beamPositions
= mgr.getCachedConditions(BeamPositionCollection.class, "beam_positions").getCachedData();
BeamPosition beamPositionCond = beamPositions.get(0);
beamPositionToUse = new double[]{
beamPositionCond.getPositionZ(),
beamPositionCond.getPositionX(),
beamPositionCond.getPositionY()
beamPositionCond.getPositionZ(),
beamPositionCond.getPositionX(),
beamPositionCond.getPositionY()
};
if (this.useFixedVertexZPosition) {
LOGGER.config("Using fixed Z position: " + this.beamPosition[0]);
Expand Down Expand Up @@ -249,34 +249,38 @@ public void setIncludeUnmatchedTracksInFSP(boolean setUMTrks) {
}

/**
* This method used to activate usage of the internal map of run numbers to beam positions.
*
* Now, it activates usage of the beam positions from the conditions database instead.
* This should result in the same behavior as before, and steering files should not need
* to be updated (though eventually they should be).
*
* This method used to activate usage of the internal map of run numbers to
* beam positions.
*
* Now, it activates usage of the beam positions from the conditions
* database instead. This should result in the same behavior as before, and
* steering files should not need to be updated (though eventually they
* should be).
*
* @deprecated Use {@link #setUseBeamPositionConditions(boolean)} instead.
*/
@Deprecated
@Deprecated
public void setUseInternalVertexXYPositions(boolean b) {
// Changed this method to activate reading of conditions from the database. --JM
this.useBeamPositionConditions = b;
LOGGER.warning("The method HpsReconParticleDriver.setUseInternalVertexXYPositions() is deprecated. Use setUseBeamPositionConditions() instead.");
}

/**
* Set whether to use beam positions from the database.
*
* @param b True to use beam positions from the database
*/
public void setUseBeamPositionConditions(boolean b) {
this.useBeamPositionConditions = b;
}
public void setStoreCovTrkMomList(boolean b){
_storeCovTrkMomList=b;

public void setStoreCovTrkMomList(boolean b) {
_storeCovTrkMomList = b;
}
public void setRequireClustersForV0(boolean b){
this.requireClustersForV0=b;

public void setRequireClustersForV0(boolean b) {
this.requireClustersForV0 = b;
}

/**
Expand All @@ -296,7 +300,7 @@ protected void process(EventHeader event) {
// only use one target z position
beamPositionToUse[0] = beamPosition[0];
}
*/
*/
if (makeMollerCols) {
unconstrainedMollerCandidates = new ArrayList<ReconstructedParticle>();
beamConMollerCandidates = new ArrayList<ReconstructedParticle>();
Expand All @@ -314,17 +318,17 @@ protected void process(EventHeader event) {
super.process(event);

if (makeMollerCols) {
event.put(unconstrainedMollerCandidatesColName, unconstrainedMollerCandidates, ReconstructedParticle.class,0);
event.put(beamConMollerCandidatesColName, beamConMollerCandidates, ReconstructedParticle.class,0);
event.put(targetConMollerCandidatesColName, targetConMollerCandidates, ReconstructedParticle.class,0);
event.put(unconstrainedMollerVerticesColName, unconstrainedMollerVertices, Vertex.class,0);
event.put(beamConMollerVerticesColName, beamConMollerVertices, Vertex.class,0);
event.put(targetConMollerVerticesColName, targetConMollerVertices, Vertex.class,0);
event.put(unconstrainedMollerCandidatesColName, unconstrainedMollerCandidates, ReconstructedParticle.class, 0);
event.put(beamConMollerCandidatesColName, beamConMollerCandidates, ReconstructedParticle.class, 0);
event.put(targetConMollerCandidatesColName, targetConMollerCandidates, ReconstructedParticle.class, 0);
event.put(unconstrainedMollerVerticesColName, unconstrainedMollerVertices, Vertex.class, 0);
event.put(beamConMollerVerticesColName, beamConMollerVertices, Vertex.class, 0);
event.put(targetConMollerVerticesColName, targetConMollerVertices, Vertex.class, 0);

}
if (makeConversionCols) {
event.put(unconstrainedVcCandidatesColName, unconstrainedVcCandidates, ReconstructedParticle.class,0);
event.put(unconstrainedVcVerticesColName, unconstrainedVcVertices, Vertex.class,0);
event.put(unconstrainedVcCandidatesColName, unconstrainedVcCandidates, ReconstructedParticle.class, 0);
event.put(unconstrainedVcVerticesColName, unconstrainedVcVertices, Vertex.class, 0);
}
}

Expand Down Expand Up @@ -373,12 +377,11 @@ public void findV0s(List<ReconstructedParticle> electrons, List<ReconstructedPar
if (TrackType.isGBL(positron.getType()) != TrackType.isGBL(electron.getType())) {
continue;
}

// Make V0 candidates
try {
this.makeV0Candidates(electron, positron);
}
catch (RuntimeException e) {
} catch (RuntimeException e) {
e.printStackTrace();
System.out.println("HpsReconParticleDriver::makeV0Candidates fails:: skipping ele/pos pair.");
continue;
Expand Down Expand Up @@ -571,25 +574,24 @@ private BilliorVertex fitVertex(Constraint constraint, ReconstructedParticle ele
*
*/
private void makeV0Candidates(ReconstructedParticle electron, ReconstructedParticle positron) {

//boolean eleIsTop = (electron.getTracks().get(0).getTrackerHits().get(0).getPosition()[2] > 0);
//boolean posIsTop = (positron.getTracks().get(0).getTrackerHits().get(0).getPosition()[2] > 0);

//This eleIsTop/posIsTop logic is valid for all track types [both Helix+GBL and Kalman]
boolean eleIsTop = (electron.getTracks().get(0).getTrackStates().get(0).getTanLambda() > 0);
boolean posIsTop = (positron.getTracks().get(0).getTrackStates().get(0).getTanLambda() > 0);

if ((eleIsTop == posIsTop) && (!makeConversionCols)) {
return;
}

if (electron.getClusters() == null || positron.getClusters() == null) {
return;
}
if (requireClustersForV0&&(electron.getClusters().isEmpty() || positron.getClusters().isEmpty())) {
if (requireClustersForV0 && (electron.getClusters().isEmpty() || positron.getClusters().isEmpty())) {
return;
}
if(requireClustersForV0){
if (requireClustersForV0) {
double eleClusTime = ClusterUtilities.getSeedHitTime(electron.getClusters().get(0));
double posClusTime = ClusterUtilities.getSeedHitTime(positron.getClusters().get(0));

Expand All @@ -610,7 +612,7 @@ private void makeV0Candidates(ReconstructedParticle electron, ReconstructedParti
if (candidate.getStartVertex().getProbability() < cuts.getMinVertexChisqProb()) {
return;
}

// patch the track parameters at the found vertex
if (_patchVertexTrackParameters) {
patchVertex(vtxFit);
Expand All @@ -625,8 +627,9 @@ private void makeV0Candidates(ReconstructedParticle electron, ReconstructedParti

// Create candidate particles for the other two constraints.
for (Constraint constraint : Constraint.values()) {
if(constraint == Constraint.UNCONSTRAINED) continue; // Skip the UNCONSTRAINED case, done already

if (constraint == Constraint.UNCONSTRAINED) {
continue; // Skip the UNCONSTRAINED case, done already
}
// Generate a candidate vertex and particle.
vtxFit = fitVertex(constraint, electron, positron);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import org.hps.conditions.beam.BeamEnergy.BeamEnergyCollection;
import org.hps.recon.tracking.CoordinateTransformations;
import org.hps.recon.tracking.TrackUtils;
import org.hps.record.StandardCuts;

import org.hps.recon.utils.TrackClusterMatcher;
Expand All @@ -23,7 +22,6 @@
import org.lcsim.event.Cluster;
import org.lcsim.event.EventHeader;
import org.lcsim.event.ReconstructedParticle;
import org.lcsim.event.RelationalTable;
import org.lcsim.event.Track;
import org.lcsim.event.Vertex;
import org.lcsim.event.base.BaseCluster;
Expand Down Expand Up @@ -57,8 +55,8 @@ public abstract class ReconParticleDriver extends Driver {
protected boolean isMC = false;
private boolean disablePID = false;
protected StandardCuts cuts = new StandardCuts();
RelationalTable hitToRotated = null;
RelationalTable hitToStrips = null;
// RelationalTable hitToRotated = null;
// RelationalTable hitToStrips = null;
//Track to Cluster matching algorithms interfaced from
//TrackClusteMatcherInter and the specific algorithm is chosen by name using
//TrackClusterMatcherFactory
Expand Down Expand Up @@ -714,8 +712,8 @@ protected void process(EventHeader event) {
}
}

hitToRotated = TrackUtils.getHitToRotatedTable(event);
hitToStrips = TrackUtils.getHitToStripsTable(event);
// hitToRotated = TrackUtils.getHitToRotatedTable(event);
// hitToStrips = TrackUtils.getHitToStripsTable(event);

// Instantiate new lists to store reconstructed particles and
// V0 candidate particles and vertices.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
<driver name="RawTrackerHitFitterDriver" />
<driver name="TrackerHitDriver"/>

<!--
<driver name="HelicalTrackHitDriver"/>

-->

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

Expand Down Expand Up @@ -87,7 +89,7 @@

<driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver">
<neighborDeltaT>8.0</neighborDeltaT>
<saveMonsterEvents>false</saveMonsterEvents>
<saveMonsterEvents>true</saveMonsterEvents>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this changed from false to true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe the current way of handling these events is correct, and simply skipping these events may be giving us a false impression of how well we're doing. I'd like to see what effect this has in combination with enabling the event flag filter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The event flag filter is not currently activated in this steering file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is your intention, please add it to this steering file and I will approve this PR.

<thresholdMonsterEvents>200</thresholdMonsterEvents>
<debug>false</debug>
</driver>
Expand All @@ -109,7 +111,9 @@

<driver name="ReconParticleDriver_Kalman" type="org.hps.recon.particle.HpsReconParticleDriver" >
<ecalClusterCollectionName>EcalClustersCorr</ecalClusterCollectionName>
<trackCollectionNames>KalmanFullTracks</trackCollectionNames>
<trackCollectionNames>KalmanFullTracks</trackCollectionNames>
<matcherTrackCollectionName>KalmanFullTracks</matcherTrackCollectionName>
<trackClusterMatcherAlgo>TrackClusterMatcherMinDistance</trackClusterMatcherAlgo>
<unconstrainedV0CandidatesColName>UnconstrainedV0Candidates_KF</unconstrainedV0CandidatesColName>
<unconstrainedV0VerticesColName>UnconstrainedV0Vertices_KF</unconstrainedV0VerticesColName>
<beamConV0CandidatesColName>BeamspotConstrainedV0Candidates_KF</beamConV0CandidatesColName>
Expand All @@ -125,15 +129,15 @@
<beamPositionY>0.04</beamPositionY>
<beamSigmaY>0.020</beamSigmaY>
<beamPositionZ>-7.5</beamPositionZ>
<maxElectronP>7.0</maxElectronP>
<maxElectronP>10.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>false</useTrackPositionForClusterCorrection>
<useTrackPositionForClusterCorrection>true</useTrackPositionForClusterCorrection>
<debug>false</debug>
<makeMollerCols>false</makeMollerCols>
</driver>
Expand Down