Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
fixed issue with the EB detector banks not beeing written out
Browse files Browse the repository at this point in the history
  • Loading branch information
raffaelladevita committed Aug 7, 2017
1 parent 08c6a1e commit c45be19
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public CalorimeterResponse(int sector, int layer, int component){


public static List<DetectorResponse> readHipoEvent(DataEvent event,
String bankName, DetectorType type){
String bankName, DetectorType type){
List<DetectorResponse> responseList = new ArrayList<DetectorResponse>();
if(event.hasBank(bankName)==true){
DataBank bank = event.getBank(bankName);
Expand All @@ -38,6 +38,7 @@ public static List<DetectorResponse> readHipoEvent(DataEvent event,
int sector = bank.getByte("sector", row);
int layer = bank.getByte("layer", row);
DetectorResponse response = new DetectorResponse(sector,layer,0);
response.setHitIndex(row);
response.getDescriptor().setType(type);
float x = bank.getFloat("x", row);
float y = bank.getFloat("y", row);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ public static DataBank getDetectorParticleBank(List<DetectorParticle> particles,
* @param bank_name
* @return
*/
public static DataBank getCalorimeterResponseBank(List<CalorimeterResponse> responses, DataEvent event, String bank_name){
public static DataBank getCalorimeterResponseBank(List<DetectorResponse> responses, DataEvent event, String bank_name){
DataBank bank = event.createBank(bank_name, responses.size());
for(int row = 0; row < responses.size(); row++){
CalorimeterResponse r = responses.get(row);
DetectorResponse r = responses.get(row);

bank.setShort("index", row, (short) r.getHitIndex());
bank.setShort("pindex", row, (short) r.getAssociation());
Expand Down Expand Up @@ -229,10 +229,10 @@ public static DataBank getCalorimeterResponseBank(List<CalorimeterResponse> resp
return bank;
}

public static DataBank getScintillatorResponseBank(List<ScintillatorResponse> responses, DataEvent event, String bank_name){
public static DataBank getScintillatorResponseBank(List<DetectorResponse> responses, DataEvent event, String bank_name){
DataBank bank = event.createBank(bank_name, responses.size());
for(int row = 0; row < responses.size(); row++){
ScintillatorResponse r = responses.get(row);
DetectorResponse r = responses.get(row);
bank.setShort("index",row,(short) r.getHitIndex());
bank.setShort("pindex", row, (short) r.getAssociation());
bank.setByte("detector", row, (byte) r.getDescriptor().getType().getDetectorId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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 Down Expand Up @@ -114,22 +115,24 @@ public List<CherenkovResponse> getCherenkovResponseList(){
return responses;
}

public List<CalorimeterResponse> getCalorimeterResponseList(){
public List<DetectorResponse> getCalorimeterResponseList(){
this.setAssociation();
List<CalorimeterResponse> responses = new ArrayList<CalorimeterResponse>();
List<DetectorResponse> responses = new ArrayList<DetectorResponse>();
for(DetectorParticle p : this.particleList){
for(CalorimeterResponse r : p.getCalorimeterResponses()){
for(DetectorResponse r : p.getDetectorResponses()){
if(r.getDescriptor().getType()==DetectorType.EC)
responses.add(r);
}
}
return responses;
}

public List<ScintillatorResponse> getScintillatorResponseList(){
public List<DetectorResponse> getScintillatorResponseList(){
this.setAssociation();
List<ScintillatorResponse> responses = new ArrayList<ScintillatorResponse>();
List<DetectorResponse> responses = new ArrayList<DetectorResponse>();
for(DetectorParticle p : this.particleList){
for(ScintillatorResponse r : p.getScintillatorResponses()){
for(DetectorResponse r : p.getDetectorResponses()){
if(r.getDescriptor().getType()==DetectorType.FTOF)
responses.add(r);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public class DetectorParticle implements Comparable {
private List<DetectorResponse> responseStore = new ArrayList<DetectorResponse>();
private List<CherenkovResponse> cherenkovStore = new ArrayList<CherenkovResponse>();

private List<ScintillatorResponse> scintillatorStore = new ArrayList<ScintillatorResponse>();
private List<CalorimeterResponse> calorimeterStore = new ArrayList<CalorimeterResponse>();
// private List<ScintillatorResponse> scintillatorStore = new ArrayList<ScintillatorResponse>();
// private List<CalorimeterResponse> calorimeterStore = new ArrayList<CalorimeterResponse>();

private TreeMap<DetectorType,Vector3> projectedHit =
new TreeMap<DetectorType,Vector3>();

Expand Down Expand Up @@ -137,7 +137,8 @@ public static DetectorParticle createNeutral(CalorimeterResponse resp){
track.setTrackEnd(resp.getPosition().x(),
resp.getPosition().y(),resp.getPosition().z());
DetectorParticle particle = new DetectorParticle(track);
particle.addCalorimeterResponse(resp);
// particle.addCalorimeterResponse(resp);
particle.addResponse(resp);
return particle;
}

Expand All @@ -149,21 +150,21 @@ public List<CherenkovResponse> getCherenkovResponse(){
return this.cherenkovStore;
}

public List<CalorimeterResponse> getCalorimeterResponse(){
return this.calorimeterStore;
}
// public List<CalorimeterResponse> getCalorimeterResponse(){
// return this.calorimeterStore;
// }

public List<ScintillatorResponse> getScintillatorResponse(){
return this.scintillatorStore;
}
// public List<ScintillatorResponse> getScintillatorResponse(){
// return this.scintillatorStore;
// }

public void addCherenkovResponse(CherenkovResponse res){
this.cherenkovStore.add(res);
}

public void addCalorimeterResponse(CalorimeterResponse res){
this.calorimeterStore.add(res);
}
// public void addCalorimeterResponse(CalorimeterResponse res){
// this.calorimeterStore.add(res);
// }

public void addResponse(DetectorResponse res, boolean match){
this.responseStore.add(res);
Expand All @@ -183,42 +184,42 @@ public void addResponse(DetectorResponse res, boolean match){
}
}

public void addResponse(CalorimeterResponse res, boolean match){
this.calorimeterStore.add(res);
if(match==true){
Line3D distance = this.getDistance(res);

res.getMatchedPosition().setXYZ(
distance.midpoint().x(),
distance.midpoint().y(),distance.midpoint().z());

/*Vector3D vec = new Vector3D(
this.particleCrossPosition.x(),
particleCrossPosition.y(),
particleCrossPosition.z());
*/
res.setPath(this.getPathLength(res.getPosition()));
}
}


public void addResponse(ScintillatorResponse res, boolean match){
this.scintillatorStore.add(res);
if(match==true){
Line3D distance = this.getDistance(res);

res.getMatchedPosition().setXYZ(
distance.midpoint().x(),
distance.midpoint().y(),distance.midpoint().z());

/*Vector3D vec = new Vector3D(
this.particleCrossPosition.x(),
particleCrossPosition.y(),
particleCrossPosition.z());
*/
res.setPath(this.getPathLength(res.getPosition()));
}
}
// public void addResponse(CalorimeterResponse res, boolean match){
// this.calorimeterStore.add(res);
// if(match==true){
// Line3D distance = this.getDistance(res);
//
// res.getMatchedPosition().setXYZ(
// distance.midpoint().x(),
// distance.midpoint().y(),distance.midpoint().z());
//
// /*Vector3D vec = new Vector3D(
// this.particleCrossPosition.x(),
// particleCrossPosition.y(),
// particleCrossPosition.z());
// */
// res.setPath(this.getPathLength(res.getPosition()));
// }
// }
//
//
// public void addResponse(ScintillatorResponse res, boolean match){
// this.scintillatorStore.add(res);
// if(match==true){
// Line3D distance = this.getDistance(res);
//
// res.getMatchedPosition().setXYZ(
// distance.midpoint().x(),
// distance.midpoint().y(),distance.midpoint().z());
//
// /*Vector3D vec = new Vector3D(
// this.particleCrossPosition.x(),
// particleCrossPosition.y(),
// particleCrossPosition.z());
// */
// res.setPath(this.getPathLength(res.getPosition()));
// }
// }

public Particle getPhysicsParticle(int pid){
Particle particle = new Particle(pid,
Expand Down Expand Up @@ -331,13 +332,13 @@ public List<CherenkovResponse> getCherenkovResponses(){
return this.cherenkovStore;
}

public List<CalorimeterResponse> getCalorimeterResponses(){
return this.calorimeterStore;
}

public List<ScintillatorResponse> getScintillatorResponses(){
return this.scintillatorStore;
}
// public List<CalorimeterResponse> getCalorimeterResponses(){
// return this.calorimeterStore;
// }
//
// public List<ScintillatorResponse> getScintillatorResponses(){
// return this.scintillatorStore;
// }

public DetectorResponse getHit(DetectorType type){
for(DetectorResponse res : this.responseStore){
Expand Down Expand Up @@ -560,10 +561,6 @@ public int getDetectorHit(List<DetectorResponse> hitList, DetectorType type,
return bestIndex;
}





/**
* returns DetectorResponse that matches closely with the trajectory
* @param responses
Expand Down Expand Up @@ -656,14 +653,14 @@ public String toString(){
str.append(String.format("[particle] id = %5d, c = %2d, p = %6.2f , sf = %6.3f, htcc = %5d, beta = %6.3f, mass2 = %8.3f\n",
this.getPid(), this.getCharge(),this.vector().mag(),this.getEnergyFraction(DetectorType.EC),
this.getNphe(DetectorType.HTCC),this.getBeta(),this.getMass()));
for(ScintillatorResponse res : this.scintillatorStore){
str.append(res.toString());
str.append("\n");
}
for(CalorimeterResponse res : this.calorimeterStore){
str.append(res.toString());
str.append("\n");
}
// for(ScintillatorResponse res : this.scintillatorStore){
// str.append(res.toString());
// str.append("\n");
// }
// for(CalorimeterResponse res : this.calorimeterStore){
// str.append(res.toString());
// str.append("\n");
// }
for(DetectorResponse res : this.responseStore){
str.append(res.toString());
str.append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class DetectorResponse {
private Double particlePath = 0.0;
private int association = -1;
private int hitIndex = -1;

public DetectorResponse(){
super();
}
Expand Down Expand Up @@ -67,7 +67,8 @@ public double getMatchedDistance(){

public DetectorDescriptor getDescriptor(){ return this.descriptor;}
public int getHitIndex(){return hitIndex;}

public void setHitIndex(int hitIndex) {this.hitIndex = hitIndex;}

public int getAssociation(){ return this.association;}
public void setAssociation(int asc){ this.association = asc;}

Expand Down Expand Up @@ -105,7 +106,7 @@ public int getParticleMatch(DetectorEvent event){
* @return
*/
public static List<DetectorResponse> readHipoEvent(DataEvent event,
String bankName, DetectorType type){
String bankName, DetectorType type){
List<DetectorResponse> responseList = new ArrayList<DetectorResponse>();
if(event.hasBank(bankName)==true){
DataBank bank = event.getBank(bankName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ public static List<DetectorResponse> readHipoEvent(DataEvent event,
int nrows = bank.rows();
for(int row = 0; row < nrows; row++){
int sector = bank.getByte("sector", row);
int layer = bank.getByte("layer", row);
DetectorResponse response = new DetectorResponse(sector,layer,0);
int layer = bank.getByte("layer", row);
int paddle = bank.getShort("component", row);
DetectorResponse response = new DetectorResponse(sector,layer,paddle);
response.setHitIndex(row);
response.getDescriptor().setType(type);
float x = bank.getFloat("x", row);
float y = bank.getFloat("y", row);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ public boolean processDataEvent(DataEvent de) {
de.appendBanks(bankP);
DataBank bankEve = DetectorData.getEventBank(eb.getEvent(), de, eventBank);
de.appendBanks(bankEve);
List<CalorimeterResponse> calorimeters = eb.getEvent().getCalorimeterResponseList();
List<DetectorResponse> calorimeters = eb.getEvent().getCalorimeterResponseList();
if(calorimeterBank!=null && calorimeters.size()>0) {
DataBank bankCal = DetectorData.getCalorimeterResponseBank(calorimeters, de, calorimeterBank);
de.appendBanks(bankCal);
}
List<ScintillatorResponse> scintillators = eb.getEvent().getScintillatorResponseList();
List<DetectorResponse> scintillators = eb.getEvent().getScintillatorResponseList();
if(scintillatorBank!=null && scintillators.size()>0) {
DataBank bankSci = DetectorData.getScintillatorResponseBank(scintillators, de, scintillatorBank);
de.appendBanks(bankSci);
Expand Down

0 comments on commit c45be19

Please sign in to comment.