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

Commit

Permalink
Merge pull request #105 from JeffersonLab/ebdev-neutvz
Browse files Browse the repository at this point in the history
eb: vz-correction for neutrals (and remove getopt dependency in build-coatjava.sh so it works on more systems)
  • Loading branch information
raffaelladevita authored Mar 30, 2018
2 parents c1e2023 + 703927f commit 0c642bb
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 85 deletions.
52 changes: 31 additions & 21 deletions build-coatjava.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
#!/bin/bash

OPTIONS=n
LONGOPTIONS=nospotbugs
PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name "$0" -- "$@")
eval set -- "$PARSED"

runSpotBugs="yes"

while true; do
case "$1" in
-n|--nospotbugs)
runSpotBugs="no"
shift
;;
--)
shift
break
;;
*)
echo "Programming error"
exit 3
;;
esac
for xx in $@
do
if [ "$xx" == "--nospotbugs" ]
then
runSpotBugs="no"
elif [ "$xx" == "-n" ]
then
runSpotBugs="no"
fi
done

# this doesn't work on some systems:
#OPTIONS=n
#LONGOPTIONS=nospotbugs
#PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name "$0" -- "$@")
#eval set -- "$PARSED"
#while true; do
# case "$1" in
# -n|--nospotbugs)
# runSpotBugs="no"
# shift
# ;;
# --)
# shift
# break
# ;;
# *)
# echo "Programming error"
# exit 3
# ;;
# esac
#done

rm -rf coatjava
mkdir -p coatjava
cp -r bin coatjava/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,50 +85,49 @@ public DetectorParticle(int charge, double px, double py, double pz,
detectorTrack = new DetectorTrack(charge,px,py,pz,vx,vy,vz);
}

public static DetectorParticle createNeutral(double x, double y, double z){
Vector3D dir = new Vector3D(x,y,z);
public static DetectorParticle createNeutral(
double x, double y, double z,
double vx, double vy, double vz){

Vector3D dir = new Vector3D(x-vx,y-vy,z-vz);
dir.unit();

DetectorTrack track = new DetectorTrack(0,1.0);

track.addCross(x, y, z, dir.x(),dir.y(),dir.z());

track.setVector(dir.x(), dir.y(), dir.z());
track.setPath(Math.sqrt(x*x+y*y+z*z));

track.setVertex(vx,vy,vz);

track.setPath(Math.sqrt(Math.pow(x-vx,2)+Math.pow(y-vy,2)+Math.pow(z-vz,2)));

track.setTrackEnd(x, y, z);

return new DetectorParticle(track);
}

public static DetectorParticle createNeutral(double x, double y, double z){
return createNeutral(x,y,z,0,0,0);
}

public static DetectorParticle createNeutral(DetectorResponse resp){
Vector3D dir = new Vector3D(resp.getPosition().x(),
resp.getPosition().y(),resp.getPosition().z());
dir.unit();
DetectorTrack track = new DetectorTrack(0,1.0);
track.addCross(resp.getPosition().x(),
resp.getPosition().y(),resp.getPosition().z(),
dir.x(),dir.y(),dir.z());
track.setVector(dir.x(), dir.y(), dir.z());
track.setVertex(0.0, 0.0, 0.0);
track.setPath(resp.getPosition().mag());
track.setTrackEnd(resp.getPosition().x(),
resp.getPosition().y(),resp.getPosition().z());
DetectorParticle particle = new DetectorParticle(track);
DetectorParticle particle = createNeutral(
resp.getPosition().x(),
resp.getPosition().y(),
resp.getPosition().z());
particle.addResponse(resp);
return particle;
}

public static DetectorParticle createNeutral(CalorimeterResponse resp){
Vector3D dir = new Vector3D(resp.getPosition().x(),
resp.getPosition().y(),resp.getPosition().z());
dir.unit();
DetectorTrack track = new DetectorTrack(0,1.0);
track.addCross(resp.getPosition().x(),
resp.getPosition().y(),resp.getPosition().z(),
dir.x(),dir.y(),dir.z());
track.setVector(dir.x(), dir.y(), dir.z());
track.setVertex(0.0, 0.0, 0.0);
track.setPath(resp.getPosition().mag());
track.setTrackEnd(resp.getPosition().x(),
resp.getPosition().y(),resp.getPosition().z());
DetectorParticle particle = new DetectorParticle(track);
// particle.addCalorimeterResponse(resp);

public static DetectorParticle createNeutral(DetectorResponse resp,Vector3 vertex){
DetectorParticle particle = createNeutral(
resp.getPosition().x(),
resp.getPosition().y(),
resp.getPosition().z(),
vertex.x(),
vertex.y(),
vertex.z());
particle.addResponse(resp);
return particle;
}
Expand Down Expand Up @@ -175,16 +174,6 @@ public List<CherenkovResponse> getCherenkovResponse(){
return this.cherenkovStore;
}



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

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

public void addCherenkovResponse(CherenkovResponse res){
this.cherenkovStore.add(res);
}
Expand All @@ -193,10 +182,6 @@ public void addTaggerResponse(TaggerResponse res) {
this.taggerStore.add(res);
}

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

public void addResponse(DetectorResponse res, boolean match){
this.responseStore.add(res);
if(match==true){
Expand Down
22 changes: 13 additions & 9 deletions reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public boolean processDataEvent(DataEvent de) {
EventBuilder eb = new EventBuilder();
eb.initEvent(head); // clear particles

EBMatching ebm = new EBMatching(eb);

// Process RF:
EBRadioFrequency rf = new EBRadioFrequency();
eb.getEvent().getEventHeader().setRfTime(rf.getTime(de)+EBCCDBConstants.getDouble(EBCCDBEnum.RF_OFFSET));

List<DetectorResponse> responseECAL = CalorimeterResponse.readHipoEvent(de, "ECAL::clusters", DetectorType.ECAL,"ECAL::moments");
List<DetectorResponse> responseFTOF = ScintillatorResponse.readHipoEvent(de, "FTOF::hits", DetectorType.FTOF);
List<DetectorResponse> responseCTOF = ScintillatorResponse.readHipoEvent(de, "CTOF::hits", DetectorType.CTOF);
Expand All @@ -74,23 +80,21 @@ public boolean processDataEvent(DataEvent de) {
eb.getPindexMap().put(0, tracks.size());
eb.getPindexMap().put(1, ctracks.size());

// Process tracks:
// Process tracks-hit matching:
eb.processHitMatching();

// Assign trigger/startTime particle:
eb.assignTrigger();

// Create neutrals:
// (after assigning trigger particle, to get vertex/momentum right):
eb.processNeutralTracks();

List<DetectorParticle> centralParticles = eb.getEvent().getCentralParticles();

EBMatching ebm = new EBMatching(eb);

ebm.processCentralParticles(de,"CVTRec::Tracks","CTOF::hits","CND::hits",
centralParticles, responseCTOF, responseCND);

eb.assignTrigger();

// Process RF:
EBRadioFrequency rf = new EBRadioFrequency();
eb.getEvent().getEventHeader().setRfTime(rf.getTime(de)+EBCCDBConstants.getDouble(EBCCDBEnum.RF_OFFSET));

// Do PID etc:
EBAnalyzer analyzer = new EBAnalyzer();
analyzer.processEvent(eb.getEvent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jlab.clas.physics.Vector3;
import org.jlab.clas.detector.DetectorParticle;
import org.jlab.clas.detector.DetectorResponse;
import org.jlab.clas.detector.DetectorTrack;
Expand Down Expand Up @@ -145,8 +146,13 @@ public List<DetectorParticle> findNeutrals(int ecalLayer) {
List<DetectorResponse> responsesECAL =
eventBuilder.getUnmatchedResponses(null, DetectorType.ECAL, ecalLayer);

Vector3 vertex = new Vector3(0,0,0);
if (eventBuilder.getEvent().getParticles().size()>0) {
vertex.copy(eventBuilder.getEvent().getParticle(0).vertex());
}

for (DetectorResponse r : responsesECAL)
parts.add(DetectorParticle.createNeutral(r));
parts.add(DetectorParticle.createNeutral(r,vertex));

// add other responses:
this.addResponsesECAL(parts,otherEcalLayers);
Expand All @@ -170,6 +176,11 @@ public void processCentralParticles(DataEvent de,
List<DetectorResponse> ctofHits,
List<DetectorResponse> cndHits) {

Vector3 vertex = new Vector3(0,0,0);
if (eventBuilder.getEvent().getParticles().size()>0) {
vertex.copy(eventBuilder.getEvent().getParticle(0).vertex());
}

// Make a neutral particle for each CND hit without an
// associated track.
if (de.hasBank(cndBankName)==true) {
Expand All @@ -180,7 +191,7 @@ public void processCentralParticles(DataEvent de,
final int trkid=cndBank.getInt("trkID",icnd);
if (trkid==-1) {
// make neutral particle
DetectorParticle p = DetectorParticle.createNeutral(cndHits.get(icnd));
DetectorParticle p = DetectorParticle.createNeutral(cndHits.get(icnd),vertex);
this.eventBuilder.getEvent().addParticle(p);
cnd_count = cnd_count + 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,18 @@ public void processNeutralTracks() {
// set particle kinematics:
for(DetectorParticle p : particles) {

final double energy = p.getEnergy(DetectorType.ECAL);
final double px = p.vector().x();
final double py = p.vector().y();
final double pz = p.vector().z();
final double sf = EBUtil.getExpectedSamplingFraction(energy);
final double visEnergy = p.getEnergy(DetectorType.ECAL);
final double sampFract = EBUtil.getExpectedSamplingFraction(visEnergy);
final double corEnergy = visEnergy / sampFract;

// direction cosines:
final double cx = p.vector().x();
final double cy = p.vector().y();
final double cz = p.vector().z();

p.setCharge(0);
p.vector().setXYZ(px*energy/sf,py*energy/sf,pz*energy/sf);

p.vector().setXYZ(cx*corEnergy,cy*corEnergy,cz*corEnergy);
final int pcalCount = p.countResponses(DetectorType.ECAL,1);
final int caloCount = pcalCount +
p.countResponses(DetectorType.ECAL,4) +
Expand Down

0 comments on commit 0c642bb

Please sign in to comment.