Skip to content
Open
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 @@ -118,7 +118,7 @@ protected void process(EventHeader event) {
MCParticle mcp = ttm.getMCParticle();

if (mcp != null) {
trackToMCParticleRelations.add(new BaseLCRelation(track,mcp));
trackToMCParticleRelations.add(new BaseLCRelation(track,mcp,ttm.getPurity()));

//Hep3Vector origin = new BasicHep3Vector(0.,0.,0.);
HelicalTrackFit mcp_htf = TrackUtils.getHTF(mcp,bfield);
Expand Down Expand Up @@ -178,8 +178,9 @@ protected void process(EventHeader event) {
}

int flag = 1 << LCIOConstants.TRBIT_HITS;
int relFlag = 1 << LCIOConstants.LCREL_WEIGHTED;
event.put(trackCollectionName+"Truth", truthTrackCollection, Track.class, flag);
event.put(trackCollectionName+"ToTruthTrackRelations", trackToTruthTrackRelations, LCRelation.class, 0);
event.put(trackCollectionName+"ToMCParticleRelations", trackToMCParticleRelations, LCRelation.class, 0);
event.put(trackCollectionName+"ToMCParticleRelations", trackToMCParticleRelations, LCRelation.class, relFlag);
}//closes process
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package org.hps.recon.filtering;

import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.lcsim.event.EventHeader;
import org.lcsim.event.LCRelation;
import org.lcsim.event.MCParticle;
import org.lcsim.lcio.LCIOWriter;
import org.lcsim.util.Driver;

/**
* Writes a separate, small skim LCIO file containing only events where all three signal
* electrons -- the e-/e+ daughters of an A' (MCParticle PDGID 622 with two daughters) and a
* separate recoil e- (the PDGID-11 daughter of a top-level PDGID-623 "reaction" particle) --
* are each matched to a reconstructed Track, using the same MC-truth conventions as
* CascadeVertexTupleDriver. Unlike filtering on CascadeVertexCandidates,
* this only requires that tracking found all three tracks; it doesn't require that any
* V0/vertex candidate was successfully built from them, so the skim stays valid regardless of
* changes to the downstream vertex-fitting code.
*
* This driver does not skip events: every event flows through the rest of the driver chain
* unaffected, and passing events are additionally written to {@link #outputFilePath} here.
*/
public class ThreeElectronTrackingFilter extends Driver {

private String mcParticlesColName = "MCParticle";
private String trackToMCParticleRelationsColName = "KalmanFullTracksToMCParticleRelations";
private String outputFilePath;
private LCIOWriter writer;
private int nprocessed = 0;
private int npassed = 0;

public void setMcParticlesColName(String mcParticlesColName) {
this.mcParticlesColName = mcParticlesColName;
}

public void setTrackToMCParticleRelationsColName(String trackToMCParticleRelationsColName) {
this.trackToMCParticleRelationsColName = trackToMCParticleRelationsColName;
}

public void setOutputFilePath(String outputFilePath) {
this.outputFilePath = outputFilePath;
}

@Override
protected void startOfData() {
if (outputFilePath == null) {
throw new RuntimeException("outputFilePath must be set");
}
try {
writer = new LCIOWriter(outputFilePath);
writer.reOpen();
} catch (IOException x) {
throw new RuntimeException("Error creating skim LCIO writer", x);
}
}

@Override
protected void endOfData() {
try {
writer.close();
} catch (IOException x) {
throw new RuntimeException("Error closing skim LCIO writer", x);
}
System.out.println(this.getClass().getSimpleName() + ": processed " + nprocessed + ", passed " + npassed);
}

@Override
protected void process(EventHeader event) {
nprocessed++;

if (passesThreeElectronTrackingCut(event)) {
npassed++;
try {
writer.write(event);
} catch (IOException x) {
throw new RuntimeException("Error writing skim LCIO file", x);
}
}
}

private boolean passesThreeElectronTrackingCut(EventHeader event) {
if (!event.hasCollection(MCParticle.class, mcParticlesColName)
|| !event.hasCollection(LCRelation.class, trackToMCParticleRelationsColName)) {
return false;
}

List<MCParticle> mcParticles = event.get(MCParticle.class, mcParticlesColName);

MCParticle eleMC = null;
MCParticle posMC = null;
MCParticle recoilMC = null;
for (MCParticle mcp : mcParticles) {
if (mcp.getPDGID() == 622 && mcp.getDaughters().size() == 2) {
for (MCParticle daughter : mcp.getDaughters()) {
if (daughter.getPDGID() == 11) {
eleMC = daughter;
} else if (daughter.getPDGID() == -11) {
posMC = daughter;
}
}
break;
}
}
if (eleMC != null || posMC != null) {
for (MCParticle mcp : mcParticles) {
if (mcp.getPDGID() == 623) {
for (MCParticle daughter : mcp.getDaughters()) {
if (daughter.getPDGID() == 11) {
recoilMC = daughter;
break;
}
}
break;
}
}
}

if (eleMC == null || posMC == null || recoilMC == null) {
return false;
}

Set<MCParticle> trackedMC = new HashSet<MCParticle>();
for (LCRelation rel : event.get(LCRelation.class, trackToMCParticleRelationsColName)) {
trackedMC.add((MCParticle) rel.getTo());
}

return trackedMC.contains(eleMC) && trackedMC.contains(posMC) && trackedMC.contains(recoilMC);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ protected void detectorChanged(Detector detector) {
}
LOGGER.config("Using beam position [ Z, X, Y ]: " + String.format("[ %f, %f, %f ]",
beamPositionToUse[0], beamPositionToUse[1], beamPositionToUse[2]));

// Keep the base class's beamPosition field (read directly by the cascade/N-track
// beamspot-position-constraint toggles in ReconParticleDriver.findCascadeVertices)
// in sync with the conditions-resolved value used by the existing V0 constraint above.
this.beamPosition = beamPositionToUse;
}

public void setMaxMollerP(double input) {
Expand Down Expand Up @@ -256,6 +261,13 @@ public void setMinVertexChisqProb(double input) {
cuts.setMinVertexChisqProb(input);
}

public void setMaxVertexChisq(double input) {
if (cuts == null) {
cuts = new StandardCuts(beamEnergy);
}
cuts.setMaxVertexChisq(input);
}

public void setIncludeUnmatchedTracksInFSP(boolean setUMTrks) {
includeUnmatchedTracksInFSP = setUMTrks;
}
Expand Down Expand Up @@ -694,6 +706,10 @@ private void makeV0Candidates(ReconstructedParticle electron, ReconstructedParti
return;
}

if (vtxFit.getChi2() > cuts.getMaxVertexChisq()) {
return;
}

// patch the track parameters at the found vertex
if (_patchVertexTrackParameters) {
patchVertex(vtxFit);
Expand Down
Loading
Loading