|
1 | 1 | package org.hps.recon.skims; |
2 | 2 |
|
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; |
4 | 8 |
|
5 | | -import org.lcsim.event.EventHeader; |
| 9 | +import org.hps.record.triggerbank.AbstractIntData; |
| 10 | +import org.hps.record.triggerbank.TSData2019; |
6 | 11 |
|
| 12 | +import org.lcsim.event.EventHeader; |
| 13 | +import org.lcsim.event.GenericObject; |
7 | 14 |
|
| 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 | + */ |
8 | 23 | 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 | + |
18 | 33 | @Override |
19 | 34 | 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); |
25 | 84 | } |
| 85 | + public FEESkimmer(String file, Set<String> ignore) { |
| 86 | + super(file, ignore); |
| 87 | + } |
| 88 | + |
26 | 89 | @Override |
27 | 90 | 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 | + } |
28 | 110 | return; |
29 | 111 | } |
30 | 112 |
|
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+"!"); |
35 | 124 | } |
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; |
38 | 145 | } |
39 | 146 | } |
0 commit comments