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 @@ -205,65 +205,24 @@ private int getJitter(int sector, int layer, int wire, int order) {
}
return jitter;
}

public void fetch_DCHits(DataEvent event, Clas12NoiseAnalysis noiseAnalysis,
NoiseReductionParameters parameters,
Clas12NoiseResult results) {
this.initialize(event);
this.fetch_DCHits(noiseAnalysis, parameters, results);
}


/**
* reads the hits using clas-io methods to get the EvioBank for the DC and
* fill the values to instantiate the DChit and MChit classes.This methods
* fills the DChit list of hits.
*
* @param noiseAnalysis
* @param parameters
* @param results
*/
private void fetch_DCHits(Clas12NoiseAnalysis noiseAnalysis,
NoiseReductionParameters parameters,
Clas12NoiseResult results) {

_DCHits = new ArrayList<>();

IndexedList<Boolean> noise = new IndexedList<>(4);
public void fetch_DCHits(DataEvent event) {
this.initialize(event);

RawDataBank bankDGTZ = new RawDataBank(bankNames.getTdcBank(), OrderGroups.NODENOISE);
bankDGTZ.read(event);

// event selection, including cut on max number of hits
if( run <= 0 ||
tiTimeStamp < 0 ||
bankDGTZ.rows()==0 || bankDGTZ.rows()>Constants.MAXHITS ) {
return;
}
else {
int rows = bankDGTZ.rows();
int[] sector = new int[rows];
int[] layer = new int[rows];
int[] superlayer = new int[rows];
int[] wire = new int[rows];
for (int i = 0; i < rows; i++) {
sector[i] = bankDGTZ.getByte("sector", i);
layer[i] = (bankDGTZ.getByte("layer", i)-1)%6 + 1;
superlayer[i] = (bankDGTZ.getByte("layer", i)-1)/6 + 1;
wire[i] = bankDGTZ.getShort("component", i);
}
results.clear();
noiseAnalysis.clear();
noiseAnalysis.findNoise(sector, superlayer, layer, wire, results);
for(int i=0; i<rows; i++)
noise.add(results.noise[i], sector[i], superlayer[i], layer[i], wire[i]);
}

// DataBank bankDGTZ = event.getBank(bankNames.getTdcBank());
_DCHits = new ArrayList<>();

this.getDCRBJitters(Constants.getInstance().isSWAPDCRBBITS());

RawDataBank bankFiltered = new RawDataBank(bankNames.getTdcBank(), rawBankOrders);
bankFiltered.read(event);

if(run <= 0 || tiTimeStamp < 0 || bankFiltered.rows() > Constants.MAXHITS) return;

this.set_NumTDCBankRows(bankFiltered.rows());
for (int i = 0; i < bankFiltered.rows(); i++) {
int sector = bankFiltered.getByte("sector", i);
Expand All @@ -279,12 +238,7 @@ private void fetch_DCHits(Clas12NoiseAnalysis noiseAnalysis,
if (wirestat != null) {
if (wirestat.getIntValue("status", sector, layer+(superlayer-1)*6, wire) != 0)
passHit = false;
}

if(noise.hasItem(sector, superlayer, layer, wire)) {
if(noise.getItem(sector, superlayer, layer, wire))
passHit = false;
}
}

if (passHit && wire != -1 && !(superlayer == 0)) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,34 +188,20 @@ public List<FittedCluster> ClusterSplitter(FittedCluster clus, int nextClsStartI
}
}
}
//no gaps
List<Hit> contigArrayOfHits = new ArrayList<>(); //contiguous cluster

boolean passCluster = true;
for (int l = 1; l <= Constants.NLAYR; l++) {
for (int i = 0; i < newClus.size(); i++) {
if (newClus.get(i).get_Layer() == l) {
contigArrayOfHits.add(newClus.get(i));
}
}
}
for (int i = 0; i < contigArrayOfHits.size() - 1; i++) { //if there is a gap do not include in list
if (contigArrayOfHits.get(i + 1).get_Layer() - contigArrayOfHits.get(i).get_Layer() > 1) {
passCluster = false;

//Limits for cluster candiates
boolean passCluster = false;
int nLayers = count_nlayers_in_cluster(newClus);
if((!isExceptionalCluster(newClus) && nLayers >= Constants.DC_MIN_NLAYERS)
|| (isExceptionalCluster(newClus) && nLayers >= Constants.DC_MIN_NLAYERS - 1)) {
//require consistency with line
cf.SetFitArray(newClus, "LC");
cf.Fit(newClus, true);
if ((nLayers == 6 && newClus.get_fitProb() > 0.9) || (nLayers == 5 && newClus.get_fitProb() > 0.85)
|| (nLayers == 4 && newClus.get_fitProb() > 0.75) || (nLayers == 3 && newClus.get_fitProb() > 0.65)) {
passCluster = true;
}
}
//require 4 layers to make a cluster
if ((!isExceptionalCluster(contigArrayOfHits) && count_nlayers_in_cluster(contigArrayOfHits) < Constants.DC_MIN_NLAYERS)
|| (isExceptionalCluster(contigArrayOfHits) && count_nlayers_in_cluster(contigArrayOfHits) < Constants.DC_MIN_NLAYERS - 1)) {
passCluster = false;
}

//require consistency with line
cf.SetFitArray(newClus, "LC");
cf.Fit(newClus, true);
if (newClus.get_fitProb() < 0.9) {
passCluster = false;
}

if (!(splitclusters.contains(newClus)) && passCluster) {
splitclusters.add(newClus);
Expand Down Expand Up @@ -314,7 +300,7 @@ public int count_nlayers_hit(Hit[] hits_inlayer) {
* @param hitsInClus the hits in a cluster
* @return the number of layers in a cluster
*/
int count_nlayers_in_cluster(List<Hit> hitsInClus) {
int count_nlayers_in_cluster(List<? extends Hit> hitsInClus) {
// count hits in each layer
int nlayr = 6;
int[] nlayers = new int[nlayr];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ public List<FittedCluster> FindHitBasedClusters(List<Hit> allhits, ClusterCleane
int idSharedHits = numTDCBankRows + 10000;
for (FittedCluster clus : fittedClusList) {
if (clus != null && ((!ct.isExceptionalFittedCluster(clus) && clus.size() >= Constants.DC_MIN_NLAYERS) ||
(ct.isExceptionalFittedCluster(clus) && clus.size() >= Constants.DC_MIN_NLAYERS-1)) && clus.get_fitProb()>Constants.HITBASEDTRKGMINFITHI2PROB) {
(ct.isExceptionalFittedCluster(clus) && clus.size() >= Constants.DC_MIN_NLAYERS-1))
&& ((ct.count_nlayers_in_cluster(clus) < Constants.DC_MIN_NLAYERS && clus.get_fitProb() > 0.4) || (ct.count_nlayers_in_cluster(clus) >= Constants.DC_MIN_NLAYERS && clus.get_fitProb()>Constants.HITBASEDTRKGMINFITHI2PROB))) {

// update the hits
for (FittedHit fhit : clus) {
Expand Down
13 changes: 13 additions & 0 deletions reconstruction/dc/src/main/java/org/jlab/rec/dc/track/Track.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public void setFinalStateVec(StateVec finalStateVec) {
private Segment _singleSuperlayer ;
private int _fitConvergenceStatus;
private StateVec finalStateVec ;

private boolean isAITrack = false;

public Track() {
}
Expand Down Expand Up @@ -98,6 +100,14 @@ public Segment getSingleSuperlayer() {
public void setSingleSuperlayer(Segment _singleSuperlayer) {
this._singleSuperlayer = _singleSuperlayer;
}

public void setIsAITrack(boolean isAITrack){
this.isAITrack = isAITrack;
}

public boolean getIsAITrack(){
return isAITrack;
}

public int getBitStatus() {
int status = 0;
Expand All @@ -119,6 +129,9 @@ public int getBitStatus() {
for(int isl = 0; isl <6; isl++) {
status |= segmentStatus[isl] << isl*2;
}

status |= (this.isAITrack ? 1 : 0) << 12; // The 13th bit tells if track is from AI-assisted trcking; 1: yes; 0: no

return status;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.jlab.service.dc;

import cnuphys.snr.NoiseReductionParameters;
import cnuphys.snr.clas12.Clas12NoiseAnalysis;
import cnuphys.snr.clas12.Clas12NoiseResult;

import java.util.List;
import org.jlab.clas.swimtools.Swim;
import org.jlab.io.base.DataEvent;
Expand Down Expand Up @@ -45,35 +41,24 @@ public boolean processDataEvent(DataEvent event) {
// get Field
Swim dcSwim = new Swim();
/* 2 */
// init SNR
Clas12NoiseResult results = new Clas12NoiseResult();
ClusterFitter cf = new ClusterFitter();
/* 3 */
Clas12NoiseAnalysis noiseAnalysis = new Clas12NoiseAnalysis();
ClusterCleanerUtilities ct = new ClusterCleanerUtilities();
/* 4 */
NoiseReductionParameters parameters =
new NoiseReductionParameters(
2,
Constants.SNR_LEFTSHIFTS,
Constants.SNR_RIGHTSHIFTS);
RecoBankWriter rbc = new RecoBankWriter(this.getBanks());
/* 5 */
ClusterFitter cf = new ClusterFitter();
HitReader hitRead = new HitReader(this.getBanks(), this.getRawBankOrders(), super.getConstantsManager(), Constants.getInstance().dcDetector);
/* 6 */
ClusterCleanerUtilities ct = new ClusterCleanerUtilities();
hitRead.fetch_DCHits(event);
/* 7 */
RecoBankWriter rbc = new RecoBankWriter(this.getBanks());
/* 8 */
HitReader hitRead = new HitReader(this.getBanks(), this.getRawBankOrders(), super.getConstantsManager(), Constants.getInstance().dcDetector);
/* 9 */
hitRead.fetch_DCHits(event, noiseAnalysis, parameters, results);
/* 10 */
//I) get the hits
List<Hit> hits = hitRead.get_DCHits(Constants.getInstance().SECTORSELECT);
//II) process the hits
//1) exit if hit list is empty
if (hits.isEmpty()) {
return true;
}
/* 11 */
/* 8 */
//2) find the clusters from these hits
ClusterFinder clusFinder = new ClusterFinder();
List<FittedCluster> clusters = clusFinder.FindHitBasedClusters(hits,
Expand All @@ -84,7 +69,7 @@ public boolean processDataEvent(DataEvent event) {
return true;
} else {
List<FittedHit> fhits = rbc.createRawHitList(hits);
/* 13 */
/* 9 */
rbc.updateListsWithClusterInfo(fhits, clusters);
event.appendBanks(rbc.fillHitsBank(event, fhits),
rbc.fillHBClustersBank(event, clusters)
Expand Down
45 changes: 15 additions & 30 deletions reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.jlab.service.dc;

import cnuphys.snr.NoiseReductionParameters;
import cnuphys.snr.clas12.Clas12NoiseAnalysis;
import cnuphys.snr.clas12.Clas12NoiseResult;

import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -69,36 +65,25 @@ public boolean processDataEvent(DataEvent event) {
// get Field
Swim dcSwim = new Swim();
/* 2 */
// init SNR
Clas12NoiseResult results = new Clas12NoiseResult();
/* 3 */
Clas12NoiseAnalysis noiseAnalysis = new Clas12NoiseAnalysis();
/* 4 */
NoiseReductionParameters parameters =
new NoiseReductionParameters(
2,
Constants.SNR_LEFTSHIFTS,
Constants.SNR_RIGHTSHIFTS);
/* 5 */
ClusterFitter cf = new ClusterFitter();
/* 6 */
/* 3 */
ClusterCleanerUtilities ct = new ClusterCleanerUtilities();
/* 7 */
/* 4 */
RecoBankWriter rbc = new RecoBankWriter(this.getBanks());
/* 8 */
/* 5 */
HitReader hitRead = new HitReader(this.getBanks(), this.getRawBankOrders(), super.getConstantsManager(), Constants.getInstance().dcDetector);
/* 9 */
hitRead.fetch_DCHits(event, noiseAnalysis, parameters, results);
/* 6 */
hitRead.fetch_DCHits(event);

/* 10 */
/* 7 */
//I) get the hits
List<Hit> hits = hitRead.get_DCHits();
//II) process the hits
//1) exit if hit list is empty
if (hits.isEmpty()) {
return true;
}
/* 11 */
/* 8 */
//2) find the clusters from these hits
ClusterFinder clusFinder = new ClusterFinder();
List<FittedCluster> clusters = clusFinder.FindHitBasedClusters(hits,
Expand All @@ -108,17 +93,17 @@ public boolean processDataEvent(DataEvent event) {
if (clusters.isEmpty()) {
return true;
}
/* 12 */
/* 9 */
List<FittedHit> fhits = rbc.createRawHitList(hits);
/* 13 : assign cluster IDs to hits: if hit is associated to two clusters, the second survives*/
/* 10 : assign cluster IDs to hits: if hit is associated to two clusters, the second survives*/
rbc.updateListsWithClusterInfo(fhits, clusters);
/* 14 */
/* 11 */
//3) find the segments from the fitted clusters
SegmentFinder segFinder = new SegmentFinder();
List<Segment> segments = segFinder.get_Segments(clusters,
event,
Constants.getInstance().dcDetector, false);
/* 15 */
/* 12 */
// need 6 segments to make a trajectory
if (segments.isEmpty()) {
rbc.fillAllHBBanks(event,
Expand All @@ -142,7 +127,7 @@ public boolean processDataEvent(DataEvent event) {
}
}
segments.removeAll(rmSegs);
/* 16 */
/* 13 */
CrossMaker crossMake = new CrossMaker();
List<Cross> crosses = crossMake.find_Crosses(segments, Constants.getInstance().dcDetector);
if (crosses.isEmpty()) {
Expand All @@ -154,7 +139,7 @@ public boolean processDataEvent(DataEvent event) {
null);
return true;
}
/* 17 */
/* 14 */
CrossListFinder crossLister = new CrossListFinder();

CrossList crosslist = crossLister.candCrossLists(event, crosses,
Expand All @@ -163,14 +148,14 @@ public boolean processDataEvent(DataEvent event) {
Constants.getInstance().dcDetector,
null,
dcSwim, false);
/* 18 */
/* 15 */
//6) find the list of track candidates
TrackCandListFinder trkcandFinder = new TrackCandListFinder(Constants.HITBASE);
List<Track> trkcands = trkcandFinder.getTrackCands(crosslist,
Constants.getInstance().dcDetector,
Swimmer.getTorScale(),
dcSwim, false);
/* 19 */
/* 16 */

// track found
int trkId = 1;
Expand Down
Loading