Skip to content

Commit e540b1a

Browse files
committed
Merge remote-tracking branch 'origin/master' into displaced3prongvertex
2 parents 4efa781 + 4d47d03 commit e540b1a

13 files changed

Lines changed: 2030 additions & 550 deletions

File tree

‎recon/src/main/java/org/hps/recon/particle/HpsReconParticleDriver.java‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ public class HpsReconParticleDriver extends ReconParticleDriver {
145145
private double[] beamPositionToUse = new double[3];
146146
private boolean requireClustersForV0 = true;
147147

148+
/**
149+
* Whether the first-pass vertex fit uses the reference point of the
150+
* input track states. Kalman perigee states are defined about the beam
151+
* spot (e.g. z = -1.1 mm), not the origin; without this the fitter
152+
* assumes the origin, which biases target-constrained fits (the vertex
153+
* is pulled to twice the target z and the opening angle closes by ~2%).
154+
* On by default; set false to reproduce the original (pass5 and earlier)
155+
* behaviour.
156+
*/
157+
private boolean useTrackReferencePoint = true;
158+
148159
/**
149160
* Represents a type of constraint for vertex fitting.
150161
*
@@ -295,6 +306,17 @@ public void setStoreCovTrkMomList(boolean b) {
295306
public void setRequireClustersForV0(boolean b) {
296307
this.requireClustersForV0 = b;
297308
}
309+
310+
/**
311+
* Set whether the first-pass vertex fit is done about the reference
312+
* point of the input track states instead of the origin (default true).
313+
* Set false only to reproduce the original behaviour.
314+
*
315+
* @param b True to use the track state reference point
316+
*/
317+
public void setUseTrackReferencePoint(boolean b) {
318+
this.useTrackReferencePoint = b;
319+
}
298320

299321
public void setUnconstrainedMollerCandidatesColName(String s)
300322
{
@@ -557,6 +579,22 @@ private BilliorVertex fitVertex(Constraint constraint, ReconstructedParticle ele
557579
break;
558580
}
559581

582+
// The Billior tracks carry the parameters of the first track state,
583+
// which are defined about that state's reference point (tracking
584+
// frame). Fit about the same point so that the vertex position and
585+
// the beam/target constraints are computed in absolute coordinates.
586+
if (useTrackReferencePoint) {
587+
double[] eleRef = electron.getTracks().get(0).getTrackStates().get(0).getReferencePoint();
588+
double[] posRef = positron.getTracks().get(0).getTrackStates().get(0).getReferencePoint();
589+
if (Math.abs(eleRef[0] - posRef[0]) > 1e-6 || Math.abs(eleRef[1] - posRef[1]) > 1e-6
590+
|| Math.abs(eleRef[2] - posRef[2]) > 1e-6) {
591+
LOGGER.warning(String.format("Electron and positron track reference points differ: "
592+
+ "(%f, %f, %f) vs (%f, %f, %f); using the electron's.",
593+
eleRef[0], eleRef[1], eleRef[2], posRef[0], posRef[1], posRef[2]));
594+
}
595+
vtxFitter.setReferencePosition(eleRef);
596+
}
597+
560598
// Add the electron and positron tracks to a track list for
561599
// the vertex fitter.
562600
List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>();
Lines changed: 129 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,146 @@
11
package org.hps.recon.skims;
22

3-
import java.util.Set;
3+
import java.util.Set;
4+
import java.io.BufferedReader;
5+
import java.io.IOException;
6+
import java.io.InputStream;
7+
import java.io.InputStreamReader;
48

5-
import org.lcsim.event.EventHeader;
9+
import org.hps.record.triggerbank.AbstractIntData;
10+
import org.hps.record.triggerbank.TSData2019;
611

12+
import org.lcsim.event.EventHeader;
13+
import org.lcsim.event.GenericObject;
714

15+
/**
16+
* Skimmer for full-energy-electron (FEE) events.
17+
*
18+
* The selection is applied in steps; the first (and, for now, only) step is the
19+
* trigger skim, which requires that the event was taken with an FEE trigger.
20+
* The trigger bits are read from the 2019+ TS bank, so this is applicable to the
21+
* 2019 and 2021 running periods.
22+
*/
823
public class FEESkimmer extends Skimmer {
9-
private String _FEECandidateCollectionName = "UnconstrainedFEECandidates";
10-
private double _clusterTimingCut = 20.0; // only used if _tight is true
11-
private double _v0Chi2Cut = 100.0;
12-
private double _trackChi2Cut = 80.0;
13-
private double _trackDtCut = 20.0;
14-
private double _trackPMax = 0.9;
15-
private double _v0PMax = 1.4;
16-
private int _nHitsMin=10;
17-
24+
//default parameters...ok for 2021 run
25+
private String _tsBankCollectionName = "TSBank";
26+
private boolean _requireFEETrigger = true;
27+
private boolean _useFEETopTrigger = true;
28+
private boolean _useFEEBotTrigger = true;
29+
private boolean _debug = false;
30+
private int totalFEETopTriggers = 0;
31+
private int totalFEEBotTriggers = 0;
32+
1833
@Override
1934
public boolean passSelection(EventHeader event){
20-
// System.out.println(this.getClass().getName()+":: in pass selection");
21-
boolean pass=true;
22-
23-
24-
return pass;
35+
if(_debug)
36+
System.out.println(this.getClass().getName()+":: in pass selection");
37+
incrementEventProcessed();
38+
39+
//step 1: trigger skim
40+
if(!passTriggerSelection(event))
41+
return false;
42+
43+
incrementEventPassed();
44+
return true;
45+
}
46+
47+
/**
48+
* Require an FEE trigger bit in the TS bank. If neither the top nor the
49+
* bottom FEE trigger is requested, or if the trigger requirement is turned
50+
* off altogether, every event passes this step.
51+
*/
52+
private boolean passTriggerSelection(EventHeader event){
53+
if(!_requireFEETrigger)
54+
return true;
55+
56+
if (!event.hasCollection(GenericObject.class, _tsBankCollectionName)) {
57+
if(_debug)System.out.println(this.getClass().getName()+":: no "+_tsBankCollectionName+" collection in event");
58+
return false;
59+
}
60+
61+
boolean pass=false;
62+
for (GenericObject tsBank : event.get(GenericObject.class, _tsBankCollectionName)) {
63+
if (AbstractIntData.getTag(tsBank) != TSData2019.BANK_TAG)
64+
continue;
65+
TSData2019 triggerData = new TSData2019(tsBank);
66+
if (_useFEETopTrigger && triggerData.isFEETopTrigger()) {
67+
totalFEETopTriggers++;
68+
pass=true;
69+
}
70+
if (_useFEEBotTrigger && triggerData.isFEEBotTrigger()) {
71+
totalFEEBotTriggers++;
72+
pass=true;
73+
}
74+
}
75+
76+
if(_debug && !pass)
77+
System.out.println(this.getClass().getName()+":: failed FEE trigger");
78+
79+
return pass;
80+
}
81+
82+
public FEESkimmer(String file) {
83+
super(file, null);
2584
}
85+
public FEESkimmer(String file, Set<String> ignore) {
86+
super(file, ignore);
87+
}
88+
2689
@Override
2790
public void setParameters(String parsFileName){
91+
String infilePreResDir = "/org/hps/recon/skims/";
92+
String infile=infilePreResDir+parsFileName;
93+
InputStream inParamStream = this.getClass().getResourceAsStream(infile);
94+
System.out.println(this.getClass().getName()+":: reading in FEE skimming cuts from "+infile);
95+
BufferedReader reader = new BufferedReader(new InputStreamReader(inParamStream));
96+
String line;
97+
String delims = "[ ]+";// this will split strings between one or more spaces
98+
try {
99+
while ((line = reader.readLine()) != null) {
100+
String[] tokens = line.split(delims);
101+
String parName=tokens[0].replaceAll("\\s+","");
102+
System.out.println(this.getClass().getName()+":: parameter name = " + parName + "; value = " + tokens[1]);
103+
putParam(parName,tokens[1]);
104+
105+
}
106+
} catch (IOException ex) {
107+
System.out.println(this.getClass().getName()+":: died while reading parameters");
108+
return;
109+
}
28110
return;
29111
}
30112

31-
32-
public FEESkimmer(String file) {
33-
super(file, null);
34-
// this(super.addFileExtension(file), null);
113+
private void putParam(String parName, String var){
114+
if(parName.equals("tsBankCollectionName"))
115+
_tsBankCollectionName=var;
116+
else if(parName.equals("requireFEETrigger"))
117+
_requireFEETrigger=Boolean.parseBoolean(var);
118+
else if(parName.equals("useFEETopTrigger"))
119+
_useFEETopTrigger=Boolean.parseBoolean(var);
120+
else if(parName.equals("useFEEBotTrigger"))
121+
_useFEEBotTrigger=Boolean.parseBoolean(var);
122+
else
123+
System.out.println(this.getClass().getName()+":: couldn't find "+parName+"!");
35124
}
36-
public FEESkimmer(String file, Set<String> ignore) {
37-
super(file, ignore);
125+
126+
public int getTotalFEETopTriggers(){
127+
return totalFEETopTriggers;
128+
}
129+
130+
public int getTotalFEEBotTriggers(){
131+
return totalFEEBotTriggers;
132+
}
133+
134+
public void setRequireFEETrigger(boolean require){
135+
this._requireFEETrigger=require;
136+
}
137+
public void setUseFEETopTrigger(boolean use){
138+
this._useFEETopTrigger=use;
139+
}
140+
public void setUseFEEBotTrigger(boolean use){
141+
this._useFEEBotTrigger=use;
142+
}
143+
public void setTsBankCollectionName(String name){
144+
this._tsBankCollectionName=name;
38145
}
39146
}

‎recon/src/main/java/org/hps/recon/skims/MultiSkimDriver.java‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ public class MultiSkimDriver extends Driver {
3131

3232
private String v0OutputFile="v0Skim";
3333
private String threeBodyOutputFile="threeBodySkim";
34-
private String FEEOutputFile="FEESkim";
34+
private String feeOutputFile="FEESkim";
3535
private String mollerOutputFile="mollerSkim";
3636

3737
private String v0ParamFile="default";
3838
private String threeBodyParamFile="default";
39-
private String FEEParamFile="default";
39+
private String feeParamFile="default";
4040
private String mollerParamFile="default";
4141

4242
private Skimmer v0Skimmer;
4343
private Skimmer threeBodySkimmer;
44-
private Skimmer FEESkimmer;
44+
private Skimmer feeSkimmer;
4545
private Skimmer mollerSkimmer;
4646

4747
protected Double beamEnergy;
@@ -62,6 +62,14 @@ public void endOfData() {
6262
System.out.println("Total number of V0s passing skim = "+((V0Skimmer)v0Skimmer).getTotalV0sPassing());
6363
}
6464

65+
if(skimFEE){
66+
System.out.println("FEE skim events processed = " + feeSkimmer.getNProcessed());
67+
System.out.println("Events passed = " + feeSkimmer.getNPassed());
68+
System.out.println(" Pass efficiency = " + feeSkimmer.getPassFraction());
69+
System.out.println("Total number of FEE top triggers = "+((FEESkimmer)feeSkimmer).getTotalFEETopTriggers());
70+
System.out.println("Total number of FEE bottom triggers = "+((FEESkimmer)feeSkimmer).getTotalFEEBotTriggers());
71+
}
72+
6573
if(skimMoller){
6674
System.out.println("Moller skim events processed = " + mollerSkimmer.getNProcessed());
6775
System.out.println("Events passed = " + mollerSkimmer.getNPassed());
@@ -85,8 +93,8 @@ protected void process(EventHeader event) {
8593
writeSkimList.add(threeBodySkimmer);
8694

8795
if(skimFEE &&
88-
FEESkimmer.passSelection(event))
89-
writeSkimList.add(FEESkimmer);
96+
feeSkimmer.passSelection(event))
97+
writeSkimList.add(feeSkimmer);
9098
if(skimMoller &&
9199
mollerSkimmer.passSelection(event))
92100
writeSkimList.add(mollerSkimmer);
@@ -130,8 +138,8 @@ public void setThreeBodyOutputFile(String outputFile){
130138
this.threeBodyOutputFile=outputFile;
131139
}
132140

133-
public void setFEEOutputFile(String outputFile){
134-
this.FEEOutputFile=outputFile;
141+
public void setFeeOutputFile(String outputFile){
142+
this.feeOutputFile=outputFile;
135143
}
136144
public void setMollerOutputFile(String outputFile){
137145
this.mollerOutputFile=outputFile;
@@ -154,7 +162,7 @@ protected void detectorChanged(Detector detector) {
154162
if(skimThreeBody)
155163
threeBodySkimmer=setupSkimmer("ThreeBody",threeBodyOutputFile, threeBodyParamFile);
156164
if(skimFEE)
157-
FEESkimmer=setupSkimmer("FEE",FEEOutputFile, FEEParamFile);
165+
feeSkimmer=setupSkimmer("FEE",feeOutputFile, feeParamFile);
158166
if(skimMoller)
159167
mollerSkimmer=setupSkimmer("Moller",mollerOutputFile, mollerParamFile);
160168
}
@@ -188,8 +196,8 @@ public void setThreeBodyParamFile(String pFile){
188196
this.threeBodyParamFile=pFile;
189197
}
190198

191-
public void setFEEParamFile(String pFile){
192-
this.FEEParamFile=pFile;
199+
public void setFeeParamFile(String pFile){
200+
this.feeParamFile=pFile;
193201
}
194202

195203
public void setMollerParamFile(String pFile){

‎recon/src/main/java/org/hps/recon/vertexing/BilliorVertexer.java‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,12 @@ private BasicMatrix makeRk(double Vx, double Vy, double Vz, double pxtot, double
457457
rk.setElement(1, 0, _beamPosition[1] - ((Vy + _referencePosition[1]) - pytot / pxtot * (Vx - _beamPosition[0] + _referencePosition[0])));
458458
rk.setElement(2, 0, _beamPosition[2] - ((Vz + _referencePosition[2]) - pztot / pxtot * (Vx - _beamPosition[0] + _referencePosition[0])));
459459
} else {
460-
rk.setElement(0, 0, _beamPosition[0] - Vx);
461-
rk.setElement(1, 0, _beamPosition[1] - Vy);
462-
rk.setElement(2, 0, _beamPosition[2] - Vz);
460+
// The vertex position is relative to the reference position (the reference
461+
// point of the input track states, or the previous vertex for a refit), so add
462+
// it back before comparing with the (absolute) target position.
463+
rk.setElement(0, 0, _beamPosition[0] - (Vx + _referencePosition[0]));
464+
rk.setElement(1, 0, _beamPosition[1] - (Vy + _referencePosition[1]));
465+
rk.setElement(2, 0, _beamPosition[2] - (Vz + _referencePosition[2]));
463466
}
464467
if (_debug)
465468
System.out.println("makeRk::rk = (" + rk.e(0, 0) + ", " + rk.e(1, 0) + ", " + rk.e(2, 0) + ")");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
requireFEETrigger true
2+
useFEETopTrigger true
3+
useFEEBotTrigger true

0 commit comments

Comments
 (0)