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 @@ -5,7 +5,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jlab.clas.physics.Particle;
import org.jlab.detector.base.DetectorType;
import org.jlab.geom.prim.Vector3D;
import org.jlab.io.base.DataBank;
Expand Down Expand Up @@ -90,80 +89,6 @@ public static List<DetectorParticle> readDetectorParticles(DataEvent event, Stri
return particles;
}

/**
* reads Detector Event, detector particles and detector responses and then
* adds all associated responses to each particle.
*
* @param event
* @return
*/
public static DetectorEvent readDetectorEvent(DataEvent event) {
return DetectorData.readDetectorEvent(event, "REC::Particle", "REC::Detector");
}

public static DetectorEvent readDetectorEvent(DataEvent event, String particle_bank, String response_bank) {

List<DetectorParticle> particles = DetectorData.readDetectorParticles(event, particle_bank);
DetectorEvent detectorEvent = new DetectorEvent();
for (DetectorParticle p : particles) {
detectorEvent.addParticle(p);
}

List<DetectorResponse> responses = DetectorData.readDetectorResponses(event, response_bank);
for (DetectorResponse r : responses) {
int association = r.getAssociation();
if (association >= 0 && association < detectorEvent.getParticles().size()) {
detectorEvent.getParticles().get(association).addResponse(r);
}
}

detectorEvent.getPhysicsEvent().clear();

for (DetectorParticle p : particles) {
if (p.getPid() == 0) {
Particle part = Particle.createWithMassCharge(
p.getMass(), p.getCharge(),
p.vector().x(), p.vector().y(), p.vector().z(),
p.vertex().x(), p.vertex().y(), p.vertex().z()
);
detectorEvent.getPhysicsEvent().addParticle(part);
} else {
Particle part = Particle.createWithPid(p.getPid(),
p.vector().x(), p.vector().y(), p.vector().z(),
p.vertex().x(), p.vertex().y(), p.vertex().z()
);
detectorEvent.getPhysicsEvent().addParticle(part);
}
}

if (event.hasBank("MC::Particle") == true) {
DataBank bank = event.getBank("MC::Particle");
detectorEvent.getGeneratedEvent().clear();
int nrows = bank.rows();
for (int row = 0; row < nrows; row++) {
detectorEvent.getGeneratedEvent().addGeneratedParticle(
bank.getInt("pid", row),
bank.getFloat("px", row),
bank.getFloat("py", row),
bank.getFloat("pz", row),
bank.getFloat("vx", row),
bank.getFloat("vy", row),
bank.getFloat("vz", row)
);
detectorEvent.getPhysicsEvent().addGeneratedParticle(
bank.getInt("pid", row),
bank.getFloat("px", row),
bank.getFloat("py", row),
bank.getFloat("pz", row),
bank.getFloat("vx", row),
bank.getFloat("vy", row),
bank.getFloat("vz", row)
);
}
}
return detectorEvent;
}

/**
* creates a bank with particles information.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.jlab.clas.physics.Particle;
import org.jlab.clas.physics.PhysicsEvent;
import org.jlab.detector.base.DetectorType;
import org.jlab.io.base.DataEvent;


/**
*
Expand All @@ -16,56 +12,19 @@
public class DetectorEvent {

private final List<DetectorParticle> particleList = new ArrayList<>();
private final PhysicsEvent generatedEvent = new PhysicsEvent();
private final PhysicsEvent reconstructedEvent = new PhysicsEvent();
private DetectorHeader eventHeader = new DetectorHeader();

public DetectorEvent(){

}
public DetectorEvent(){}

public void sort() {
Collections.sort(particleList);
setAssociation();
}

public static DetectorEvent readDetectorEvent(DataEvent event){
return DetectorData.readDetectorEvent(event);
}

public DetectorHeader getEventHeader() {
return eventHeader;
}

public PhysicsEvent getGeneratedEvent(){
return this.generatedEvent;
}

public PhysicsEvent getPhysicsEvent(){
return this.reconstructedEvent;
}

public DetectorParticle matchedParticle(int pid, int skip){
Particle particle = generatedEvent.getParticleByPid(pid, skip);
if(particle.p()<0.0000001) return new DetectorParticle();
return matchedParticle(particle);
}

public DetectorParticle matchedParticle(Particle p){
double compare = 100.0;
int index = -1;
for(int i = 0; i < particleList.size();i++){
if(p.charge()==particleList.get(i).getCharge()){
if(particleList.get(i).compare(p.vector().vect())<compare){
compare = particleList.get(i).compare(p.vector().vect());
index = i;
}
}
}
if(index<0&&compare>0.2) return new DetectorParticle();
return this.particleList.get(index);
}

public void clear(){
this.particleList.clear();
}
Expand Down Expand Up @@ -180,14 +139,6 @@ public void setAssociation(){
}
}

public void addParticle(double px, double py, double pz,
double vx, double vy, double vz){
DetectorParticle particle = new DetectorParticle();
particle.vector().setXYZ(px, py, pz);
particle.vertex().setXYZ(vx, vy, vz);
this.addParticle(particle);
}

public DetectorParticle getTriggerParticle() {
for (int ii=0; ii<particleList.size(); ii++) {
if (particleList.get(ii).isTriggerParticle()) {
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.Comparator;
import java.util.List;
import org.jlab.detector.base.DetectorDescriptor;
import org.jlab.detector.base.DetectorType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataEvent;


/**
*
* @author baltzell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ public void assignParticleStartTimes(DetectorEvent event,DetectorType type,int l
ebrf.getStartTime(trig, type, layer,
event.getParticles().get(ii).vertex().z()));
}

}

}

public void assignNeutralMomenta(DetectorEvent de) {
Expand Down Expand Up @@ -325,9 +323,8 @@ public void assignBetas(DetectorEvent event,final boolean useStartTimeFromFT){
event.getEventHeader().getStartTime();

for (DetectorParticle p : event.getParticles()) {
double beta = -99;
final double thisStartTime = p.getCharge()==0 ? startTime : p.getStartTime();

double beta = -99;
if (p.isTriggerParticle()) {
final double mass = PDGDatabase.getParticleById(p.getPid()).mass();
final double mom = p.vector().mag();
Expand Down Expand Up @@ -359,6 +356,7 @@ public void assignBetas(DetectorEvent event,final boolean useStartTimeFromFT){
p.setBeta(beta);
}
}

public void assignPids(DetectorEvent event,final boolean useStartTimeFromFT) {

PIDHypothesis pidHyp = new PIDHypothesis(event.getEventHeader().getTorus());
Expand Down Expand Up @@ -389,12 +387,9 @@ else if (p.getCharge()<0) {
}
}



public class PIDHypothesis {

private float torus = 0;
private int theoryPID = -1;
private double PIDquality = 0.0;
private DetectorEvent event;
private boolean useStartTimeFromFT = false;
Expand Down Expand Up @@ -426,7 +421,6 @@ public void PIDMatch(DetectorParticle p, int pid) {

final boolean htccPionThreshold = p.vector().mag()>EBConstants.HTCC_PION_THRESHOLD;
final boolean ltccPionThreshold = p.vector().mag()>EBConstants.LTCC_PION_THRESHOLD;
final boolean ltccKaonThreshold = p.vector().mag()>EBConstants.LTCC_KAON_THRESHOLD;

switch(abs(pid)) {
case 11:
Expand Down Expand Up @@ -594,12 +588,10 @@ else if (p.getCharge()!=0) {
*/
public void finalizePID(DetectorParticle p, int pid) {
p.setPid(pid);
theoryPID = pid;
PIDquality = this.PIDQuality(p, pid);
p.setPidQuality(PIDquality);

}

}
}

Expand Down
Loading
Loading