Skip to content
Draft
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 @@ -164,6 +164,55 @@ public static DetectorEvent readDetectorEvent(DataEvent event, String particle_b
return detectorEvent;
}

public static final int[] HYPOTHESES = {11,211,321,2212};

/**
* @param particles
* @param event
* @param bank_name a RICH::Particle bank
*/
public static void richifyParticles(List<DetectorParticle> particles, DataEvent event, String bank_name) {
if (event.hasBank(bank_name)) {
DataBank rich = event.getBank(bank_name);
int nrows = rich.rows();
for (int row = 0; row<nrows; row++) {
DetectorParticle p = particles.get(rich.getByte("pindex", row));
p.setPid(rich.getShort("best_PID", row));
p.setChi2(rich.getShort("best_c2", row));
p.particleScores[0] = rich.getFloat("el_logl", row);
p.particleScores[1] = rich.getFloat("pi_logl", row);
p.particleScores[2] = rich.getFloat("k_logl", row);
p.particleScores[3] = rich.getFloat("pr_logl", row);
}
}
}

/**
* @param particles
* @param event
* @param bank_name
* @return a REC::Hypothesis bank
*/
public static DataBank getHypothesesBank(List<DetectorParticle> particles, DataEvent event, String bank_name) {
int nrows = 0;
final int np = particles.size();
for (int i=0; i<np; i++)
for (int j=0; j<HYPOTHESES.length; j++)
if (particles.get(i).particleScores[j] > 0) nrows += 1;
DataBank bank = event.createBank(bank_name, nrows);
for (int i=0; i<np; i++) {
for (int j=0; j<HYPOTHESES.length; j++) {
if (particles.get(i).particleScores[j] > 0) {
int row = j + i*HYPOTHESES.length;
bank.setByte("pindex", row, (byte)i);
bank.setInt("pid", row, HYPOTHESES[j]*particles.get(i).getCharge());
bank.setFloat("logl", row, (float)particles.get(i).particleScores[j]);
}
}
}
return bank;
}

/**
* creates a bank with particles information.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public class DetectorParticle implements Comparable {
private int particleScore = 0; // scores are assigned detector hits
private double particleScoreChi2 = 0.0; // chi2 for particle score
private double startTime = -1.0; // per-particle start-time

public double[] particleScores = new double[4];

public double getStartTime() { return this.startTime; }
public void setStartTime(double time) {this.startTime=time; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jlab.clas.detector;

import java.util.ArrayList;
import java.util.List;
import org.jlab.detector.base.DetectorType;
import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataEvent;
Expand All @@ -16,10 +15,6 @@ public class RingCherenkovResponse extends DetectorResponse {
private int cluster = 0;
private int xtalk = 0;

//public RingCherenkovResponse(){
// super();
//}

public RingCherenkovResponse(int sector, int layer, int component){
this.getDescriptor().setSectorLayerComponent(sector, layer, component);
}
Expand All @@ -34,13 +29,11 @@ public RingCherenkovResponse(RingCherenkovResponse r){
public void set_cluster(int cluster){ this.cluster = cluster;}
public void set_xtalk(int xtalk){ this.xtalk = xtalk;}

// ----------------
public static ArrayList<DetectorResponse> readHipoEvent(DataEvent event,
String bankName, DetectorType type, int signal_type){
// ----------------

int debugMode = 0;
ArrayList<DetectorResponse> responseList = new ArrayList<DetectorResponse>();
ArrayList<DetectorResponse> responseList = new ArrayList<>();

if(debugMode==1){
if(signal_type==0)System.out.format(" reading bank %s for single hits \n", bankName);
Expand Down Expand Up @@ -72,8 +65,7 @@ public static ArrayList<DetectorResponse> readHipoEvent(DataEvent event,
z = bank.getFloat("z", row);
if(debugMode>=1)System.out.format(" ---> read cluster %4d %4d %8.2f %8.2f ",row,id,energy,time);
}

if(bankName.equals("RICH::Hit")){
else if(bankName.equals("RICH::Hit")){
id = bank.getShort("id", row);
int cluster = bank.getShort("cluster", row);
int xtalk = bank.getShort("xtalk", row);
Expand All @@ -88,7 +80,7 @@ public static ArrayList<DetectorResponse> readHipoEvent(DataEvent event,
if(debugMode>=1)System.out.format(" ---> read hit %4d %4d (%3d %3d %5d --> %3d) %8.2f %8.2f ",
row,id,status,cluster,xtalk,good,energy,time);
}
if(bankName.equals("RICH::Signal")){
else if(bankName.equals("RICH::Signal")){
id = bank.getShort("id", row);
int hindex = bank.getShort("hindex", row);
int size = bank.getShort("size", row);
Expand Down
11 changes: 11 additions & 0 deletions etc/bankdefs/hipo4/event.json
Original file line number Diff line number Diff line change
Expand Up @@ -644,5 +644,16 @@
{"name":"py", "type":"F", "info":"y component of the momentum (GeV)"},
{"name":"pz", "type":"F", "info":"z component of the momentum (GeV)"}
]
},
{
"name": "REC::Hypothesis",
"group": 300,
"item": 50,
"info": "Particle identification bank",
"entries": [
{"name":"pindex","type":"S", "info":"row index in REC::Particle"},
{"name":"pid", "type":"I", "info":"particle id hypothesis in LUND conventions"},
{"name":"logl", "type":"F", "info":"log(Likelihood) for this hypothesis"}
]
}
]
5 changes: 5 additions & 0 deletions reconstruction/eb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
<artifactId>clas12detector-ltcc</artifactId>
<version>14.1.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jlab.clas12.detector</groupId>
<artifactId>clas12detector-rich</artifactId>
<version>14.1.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
95 changes: 58 additions & 37 deletions reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jlab.rec.eb.EBCCDBEnum;
import org.jlab.rec.eb.EBScalers;
import org.jlab.rec.eb.EBRadioFrequency;
import org.jlab.rec.rich.RICHEBEngine;

/**
*
Expand All @@ -26,6 +27,8 @@ public class EBEngine extends ReconstructionEngine {

boolean usePOCA = false;

RICHEBEngine rich;

// output banks:
String eventBank = null;
String eventBankFT = null;
Expand All @@ -43,6 +46,7 @@ public class EBEngine extends ReconstructionEngine {
String ftBank = null;
String trajectoryBank = null;
String covMatrixBank = null;
public String hypothesisBank = null;

// inputs banks:
String trackType = null;
Expand All @@ -52,16 +56,54 @@ public class EBEngine extends ReconstructionEngine {
String covMatrixType = null;
String cvtTrackType = null;
String cvtTrajType = null;
public String richParticleType = null;

public EBEngine(String name){
super(name,"gavalian","1.0");
initBankNames();
}

public void initBankNames() {
//Initialize bank names
@Override
public boolean init() {

this.registerOutputBank(eventBank);
this.registerOutputBank(particleBank);
this.registerOutputBank(eventBankFT);
this.registerOutputBank(particleBankFT);
this.registerOutputBank(calorimeterBank);
this.registerOutputBank(caloextrasBank);
this.registerOutputBank(scintillatorBank);
this.registerOutputBank(scintextrasBank);
this.registerOutputBank(cherenkovBank);
this.registerOutputBank(trackBank);
this.registerOutputBank(utrackBank);
this.registerOutputBank(ftrackBank);
this.registerOutputBank(crossBank);
this.registerOutputBank(ftBank);
this.registerOutputBank(trajectoryBank);
this.registerOutputBank(covMatrixBank);
this.registerOutputBank(hypothesisBank);

if (this.getEngineConfigString("outputBankPrefix")!=null) {
this.setOutputBankPrefix(this.getEngineConfigString("outputBankPrefix"));
}

requireConstants(EBCCDBConstants.getAllTableNames());

this.getConstantsManager().setVariation("default");

if (this.getEngineConfigString("eb-rich") != null) {
rich = new RICHEBEngine();
rich.init();
}
return true;
}

@Override
public void detectorChanged(int run) {}

public void initBankNames() {}

public void setUsePOCA(boolean val) {
this.usePOCA=val;
}
Expand Down Expand Up @@ -91,6 +133,7 @@ public void setOutputBankPrefix(String prefix) {
this.setParticleBankFT(prefix+"FT::Particle");
this.setCovMatrixBank(prefix+"::CovMat");
}
hypothesisBank = prefix+"::Hypothesis";
}

public boolean processDataEventUser(DataEvent de,EBScalers ebs) {
Expand Down Expand Up @@ -236,6 +279,14 @@ public boolean processDataEventUser(DataEvent de,EBScalers ebs) {
}
}

if (rich != null) {
rich.processDataEvent(de);
de.removeBank("REC::Particle");
DetectorData.richifyParticles(eb.getEvent().getParticles(), de, richParticleType);
de.appendBank(DetectorData.getHypothesesBank(eb.getEvent().getParticles(), de, "REC::Hypotheses"));
de.appendBanks(DetectorData.getDetectorParticleBank(eb.getEvent().getParticles(), de, particleBank));
}

// update PID for FT-based start time:
// WARNING: this modified particles
analyzer.processEventFT(eb.getEvent());
Expand All @@ -245,11 +296,15 @@ public boolean processDataEventUser(DataEvent de,EBScalers ebs) {
if (particleBankFT!=null) {
DataBank bankPFT = DetectorData.getDetectorParticleShadowBank(eb.getEvent().getParticles(), de, particleBankFT);
de.appendBanks(bankPFT);
if (rich != null) {
DetectorData.richifyParticles(eb.getEvent().getParticles(), de, particleBank);
de.appendBank(DetectorData.getHypothesesBank(eb.getEvent().getParticles(), de, hypothesisBank));
}
}
}

}

return true;
}

Expand Down Expand Up @@ -345,38 +400,4 @@ public void setCvtTrajType(String name) {
this.cvtTrajType = name;
}

@Override
public boolean init() {

this.registerOutputBank(eventBank);
this.registerOutputBank(particleBank);
this.registerOutputBank(eventBankFT);
this.registerOutputBank(particleBankFT);
this.registerOutputBank(calorimeterBank);
this.registerOutputBank(caloextrasBank);
this.registerOutputBank(scintillatorBank);
this.registerOutputBank(scintextrasBank);
this.registerOutputBank(cherenkovBank);
this.registerOutputBank(trackBank);
this.registerOutputBank(utrackBank);
this.registerOutputBank(ftrackBank);
this.registerOutputBank(crossBank);
this.registerOutputBank(ftBank);
this.registerOutputBank(trajectoryBank);
this.registerOutputBank(covMatrixBank);

if (this.getEngineConfigString("outputBankPrefix")!=null) {
this.setOutputBankPrefix(this.getEngineConfigString("outputBankPrefix"));
}

requireConstants(EBCCDBConstants.getAllTableNames());

this.getConstantsManager().setVariation("default");

return true;
}

@Override
public void detectorChanged(int runNumber) {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public void initBankNames() {
this.setCovMatrixType("TimeBasedTrkg::TBCovMat");
this.setCvtTrackType("CVTRec::Tracks");
this.setCvtTrajType("CVTRec::Trajectory");
this.richParticleType = "RICH::Particle";
}

}
Loading
Loading