Skip to content
Merged
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 @@ -87,7 +87,7 @@ public void build() {
//LOGGER.info("Construct uChannelL14Bottom");


UChannelL13 uChannelL14Bottom = new UChannelL14Bottom("support_bottom_L14", svtBox, alignmentCorrections,
UChannelL13 uChannelL14Bottom = new UChannelL14Bottom("support_bottom_L13", svtBox, alignmentCorrections,
supportRingKinL13Bottom);
surveyVolumes.add(uChannelL14Bottom);

Expand All @@ -109,7 +109,7 @@ public void build() {
//System.out.println("PF::Constructed supportRingKinL13Top: " + supportRingKinL13Top.toString());


UChannelL13 uChannelL14Top = new UChannelL14Top("support_top_L14", svtBox, alignmentCorrections,
UChannelL13 uChannelL14Top = new UChannelL14Top("support_top_L13", svtBox, alignmentCorrections,
supportRingKinL13Top);
surveyVolumes.add(uChannelL14Top);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public AlignmentStructuresBuilder(List<SiSensor> sensors) {
aliVolumeList.add(alignable_volumes.get("module_L7b_halfmodule_stereo_hole_sensor0_AV"));
aliVolumeList.add(alignable_volumes.get("module_L7b_halfmodule_stereo_slot_sensor0_AV"));
rot = (alignable_volumes.get("module_L7b_halfmodule_stereo_hole_sensor0_AV")).getL2G().getRotation();
AlignableVolume doublesensor_stereo_L7_Bot_AV = new AlignableVolume("doublesensor_stereo_L7_Bot_AV", aliVolumeList, rot, null,6);
AlignableVolume doublesensor_stereo_L7_Bot_AV = new AlignableVolume("doublesensor_stereo_L7_Bot_AV", aliVolumeList, rot, null,76);
alignable_volumes.put("doublesensor_stereo_L7_Bot_AV",doublesensor_stereo_L7_Bot_AV);
aliVolumeList.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public int getValue() {
}
};

private GblTrajectory _traj;
private GblTrajectory _traj = null;
private GblTrajectoryJna _traj_jna = null;
private double _chi2;
private double _lost;
private int _ndf;
Expand All @@ -90,6 +91,14 @@ public FittedGblTrajectory(GblTrajectory traj, double chi2, int ndf, double lost
_ndf = ndf;
_lost = lost;
}


public FittedGblTrajectory(GblTrajectoryJna traj_jna, double chi2, int ndf, double lost) {
_traj_jna = traj_jna;
_chi2 = chi2;
_ndf = ndf;
_lost = lost;
}

/**
* Find the index (or label) of the GBL point on the trajectory from the {@link GBLPOINT}.
Expand All @@ -101,8 +110,12 @@ public int getPointIndex(GBLPOINT point) {
int gblPointIndex;
if (point.compareTo(GBLPOINT.IP) == 0)
gblPointIndex = 1;
else if (point.compareTo(GBLPOINT.LAST) == 0)
gblPointIndex = _traj.getNumPoints();
else if (point.compareTo(GBLPOINT.LAST) == 0) {
if (_traj != null)
gblPointIndex = _traj.getNumPoints();
else
gblPointIndex = _traj_jna.getNumPoints();
}
else
throw new RuntimeException("This GBL point " + point.toString() + "( " + point.name() + ") is not valid");
return gblPointIndex;
Expand Down Expand Up @@ -135,7 +148,11 @@ public void getResults(GBLPOINT point, Vector locPar, SymMatrix locCov) {
public void getResults(int iLabel, Vector locPar, SymMatrix locCov) {

// Get the result from the trajectory
int ok = _traj.getResults(iLabel, locPar, locCov);
int ok = 0;
if (_traj != null)
ok = _traj.getResults(iLabel, locPar, locCov);
else
ok = _traj_jna.getResults(iLabel, locPar, locCov);

// check that the fit was ok
if (ok != 0)
Expand Down Expand Up @@ -183,6 +200,10 @@ public GblTrajectory get_traj() {
return _traj;
}

public GblTrajectoryJna get_traj_jna(){
return _traj_jna;
}

public double get_chi2() {
return _chi2;
}
Expand Down Expand Up @@ -326,27 +347,50 @@ public Pair<double[], SymmetricMatrix> getCorrectedPerigeeParameters(HelicalTrac
* @return kinks in a {@link GBLKinkData} object.
*/
public GBLKinkData getKinks() {
GblTrajectory traj = this._traj;
// get corrections from GBL fit
Vector locPar = new Vector(5);
SymMatrix locCov = new SymMatrix(5);
float[] lambdaKinks = new float[traj.getNumPoints() - 1];
double[] phiKinks = new double[traj.getNumPoints() - 1];

double oldPhi = 0, oldLambda = 0;
for (int i = 0; i < traj.getNumPoints(); i++) {
traj.getResults(i + 1, locPar, locCov); // vertex point
double newPhi = locPar.get(GBLPARIDX.XTPRIME.getValue());
double newLambda = locPar.get(GBLPARIDX.YTPRIME.getValue());
if (i > 0) {
lambdaKinks[i - 1] = (float) (newLambda - oldLambda);
phiKinks[i - 1] = newPhi - oldPhi;
// System.out.println("phikink: " + (newPhi - oldPhi));
float[] lambdaKinks ;
double[] phiKinks ;

if (_traj != null) {

lambdaKinks = new float[_traj.getNumPoints() - 1];
phiKinks = new double[_traj.getNumPoints() - 1];

double oldPhi = 0, oldLambda = 0;
for (int i = 0; i < _traj.getNumPoints(); i++) {
_traj.getResults(i + 1, locPar, locCov); // vertex point
double newPhi = locPar.get(GBLPARIDX.XTPRIME.getValue());
double newLambda = locPar.get(GBLPARIDX.YTPRIME.getValue());
if (i > 0) {
lambdaKinks[i - 1] = (float) (newLambda - oldLambda);
phiKinks[i - 1] = newPhi - oldPhi;
// System.out.println("phikink: " + (newPhi - oldPhi));
}
oldPhi = newPhi;
oldLambda = newLambda;
}
oldPhi = newPhi;
oldLambda = newLambda;
}

else {
lambdaKinks = new float[_traj_jna.getNumPoints() - 1];
phiKinks = new double[_traj_jna.getNumPoints() - 1];

double oldPhi = 0, oldLambda = 0;
for (int i = 0; i < _traj_jna.getNumPoints(); i++) {
_traj_jna.getResults(i + 1, locPar, locCov); // vertex point
double newPhi = locPar.get(GBLPARIDX.XTPRIME.getValue());
double newLambda = locPar.get(GBLPARIDX.YTPRIME.getValue());
if (i > 0) {
lambdaKinks[i - 1] = (float) (newLambda - oldLambda);
phiKinks[i - 1] = newPhi - oldPhi;
// System.out.println("phikink: " + (newPhi - oldPhi));
}
oldPhi = newPhi;
oldLambda = newLambda;
}
}

return new GBLKinkData(lambdaKinks, phiKinks);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class GBLOutputDriver extends Driver {
private String outputPlots = "GBLplots_ali.root";
private String trackCollectionName = "GBLTracks";
private String trackResidualsRelColName = "TrackResidualsGBLRelations";
private String dataRelationCollection = GBLKinkData.DATA_RELATION_COLLECTION;
private List<HpsSiSensor> sensors = new ArrayList<HpsSiSensor>();
private double bfield;
public boolean debug = false;
Expand All @@ -72,7 +73,29 @@ public class GBLOutputDriver extends Driver {

//Spacing between top and bottom in the 2D histos
private int mod = 5;

private double minMom = 1.;
private double maxMom = 6.;

private int nHits = 6;


public void setDataRelationCollection (String val) {
dataRelationCollection = val;
}

public void setNHits (int val ) {
nHits = val;
}

public void setMinMom (double val) {
minMom = val;
}

public void setMaxMom (double val) {
maxMom = val;
}

//Override the Z of the target.
public void setBsZ (double input) {
bsZ = input;
Expand Down Expand Up @@ -130,11 +153,10 @@ public void process(EventHeader event) {
List<Track> tracks = event.get(Track.class, trackCollectionName);

int TrackType = 0;
int nHits = 6;

if (trackCollectionName.contains("Kalman") || trackCollectionName.contains("KF")) {
TrackType = 1;
nHits = 12;
nHits = 2*nHits;
//System.out.println("PF:: DEBUG :: Found Kalman Tracks in the event");
}

Expand Down Expand Up @@ -173,16 +195,16 @@ public void process(EventHeader event) {

Hep3Vector momentum = new BasicHep3Vector(trk.getTrackStates().get(0).getMomentum());

if (momentum.magnitude() < 1.5)
if (momentum.magnitude() < minMom)
continue;

if (momentum.magnitude() > 6)
if (momentum.magnitude() > maxMom)
continue;

//System.out.println("Track passed momentum");

TrackState trackState = trk.getTrackStates().get(0);
if (Math.abs(trackState.getTanLambda()) < 0.025)
if (Math.abs(trackState.getTanLambda()) < 0.015)
continue;

//System.out.println("Track passed tanLambda");
Expand Down Expand Up @@ -254,6 +276,13 @@ public void process(EventHeader event) {
}

private void doGBLkinks(Track trk, GenericObject kink, Map<HpsSiSensor, Integer> sensorNums) {

if (kink == null) {
System.out.println("WARNING::Kink object is null");
return;
}


String vol = "_top";
int spacing = 0;
if (trk.getTrackStates().get(0).getTanLambda() < 0) {
Expand Down Expand Up @@ -335,8 +364,9 @@ private void doBasicGBLtrack(Track trk, Map<HpsSiSensor, TrackerHit> sensorHits)
isTop = "_top";
}

//There is a sign flip in the charge
String charge = "_pos";
if (trk.getCharge()<0)
if (trk.getCharge()>0)
charge = "_neg";


Expand Down Expand Up @@ -405,8 +435,8 @@ private void doBasicGBLtrack(Track trk, Map<HpsSiSensor, TrackerHit> sensorHits)
//Get the PathToPlane

BaseTrackState ts_bs = TrackUtils.getTrackExtrapAtVtxSurfRK(trackState,bFieldMap,0.,bsZ);


//Get the track parameters wrt the beamline using helix
double [] beamLine = new double [] {bsZ,0};
double [] helixParametersAtBS = TrackUtils.getParametersAtNewRefPoint(beamLine, trackState);
Expand All @@ -424,6 +454,9 @@ private void doBasicGBLtrack(Track trk, Map<HpsSiSensor, TrackerHit> sensorHits)
FillGBLTrackPlot(trkpFolder+"z0_vs_bs_rk",isTop,charge,ts_bs.getZ0());
FillGBLTrackPlot(trkpFolder+"z0_vs_bs_extrap",isTop,charge,helixParametersAtBS[BaseTrack.Z0]);


FillGBLTrackPlot(trkpFolder+"phi_vs_bs_extrap",isTop,charge,helixParametersAtBS[BaseTrack.PHI]);

//TH2D - Filling
FillGBLTrackPlot(trkpFolder+"d0_vs_phi",isTop,charge,trackState.getPhi(),trackState.getD0());
FillGBLTrackPlot(trkpFolder+"d0_vs_tanLambda",isTop,charge,trackState.getTanLambda(),trackState.getD0());
Expand Down Expand Up @@ -831,7 +864,7 @@ private void setupPlots() {
//TH1Ds
aidaGBL.histogram1D(trkpFolder+"d0"+vol+charge,nbins_t,-5.0,5.0);
aidaGBL.histogram1D(trkpFolder+"z0"+vol+charge,nbins_t,-1.3,1.3);
aidaGBL.histogram1D(trkpFolder+"phi"+vol+charge,nbins_t,-0.3,0.3);
aidaGBL.histogram1D(trkpFolder+"phi"+vol+charge,nbins_t,-0.06,0.06);
aidaGBL.histogram1D(trkpFolder+"tanLambda"+vol+charge,nbins_t,-0.2,0.2);
aidaGBL.histogram1D(trkpFolder+"p"+vol+charge,nbins_p,0.,pmax);
aidaGBL.histogram1D(trkpFolder+"p7h"+vol+charge,nbins_p,0.,pmax);
Expand All @@ -854,6 +887,7 @@ private void setupPlots() {
aidaGBL.histogram1D(trkpFolder+"z0_vs_bs_rk"+vol+charge, 2*nbins_t, -z0bsmax, z0bsmax);
aidaGBL.histogram1D(trkpFolder+"z0_vs_bs_extrap"+vol+charge, 2*nbins_t, -z0bsmax, z0bsmax);
aidaGBL.histogram1D(trkpFolder+"z0_vs_bs"+vol+charge, 2*nbins_t, -z0bsmax, z0bsmax);
aidaGBL.histogram1D(trkpFolder+"phi_vs_bs_extrap"+vol+charge,2*nbins_t, -0.06,0.06);


//TH2Ds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ Pointer GblTrajectoryCtorPtrComposed(Pointer [] points_1, int npoints_1, double
void GblTrajectory_fit(Pointer self, DoubleByReference Chi2, IntByReference Ndf, DoubleByReference lostWeight, char [] optionList, int aLabel);
void GblTrajectory_addPoint(Pointer self, Pointer point);
int GblTrajectory_isValid(Pointer self);
int GblTrajectory_getNumPoints(Pointer self);
void GblTrajectory_printTrajectory(Pointer self, int level);
void GblTrajectory_printData(Pointer self);
void GblTrajectory_printPoints(Pointer self, int level);
void GblTrajectory_getResults(Pointer self, int aSignedLabel, double[] localPar, int[] nLocalPar,
double[] localCov, int[] sizeLocalCov);
void GblTrajectory_milleOut(Pointer self, Pointer millebinary);
void GblTrajectory_getMeasResults(Pointer self, int aLabel, int[] numdata, double[] aResiduals, double[] aMeasErrors, double[] aResErrors, double[] aDownWeights);

}

Expand Down Expand Up @@ -116,13 +118,14 @@ public GblTrajectoryJna(List < Pair <List<GblPointJna>, Matrix> > PointsAndTrans
ppoints_2, npoints_2, trafo_2);
}

//to perform the full fit
public void fit(DoubleByReference Chi2, IntByReference Ndf, DoubleByReference lostWeight, String optionList) {

char[] c_optionList = optionList.toCharArray();
GblTrajectoryInterface.INSTANCE.GblTrajectory_fit(self, Chi2, Ndf, lostWeight, c_optionList,-999);
}


//To perform the fit removing a particular point
public void fit(DoubleByReference Chi2, IntByReference Ndf, DoubleByReference lostWeight, String optionList, int aLabel) {

char [] c_optionList = optionList.toCharArray();
Expand All @@ -138,6 +141,10 @@ public int isValid () {

}

public int getNumPoints() {
return GblTrajectoryInterface.INSTANCE.GblTrajectory_getNumPoints(self);
}

public void printTrajectory(int level) {
GblTrajectoryInterface.INSTANCE.GblTrajectory_printTrajectory(self,level);
}
Expand All @@ -150,8 +157,27 @@ public void printPoints(int level) {
GblTrajectoryInterface.INSTANCE.GblTrajectory_printPoints(self,level);
}


public void getMeasResults(int aLabel, int numData[], List<Double> aResiduals,List<Double> aMeasErrors, List<Double> aResErrors, List<Double> aDownWeights) {

double[] d_aResiduals = new double[2];
double[] d_aMeasErrors = new double[2];
double[] d_aResErrors = new double[2];
double[] d_aDownWeights = new double[2];

GblTrajectoryInterface.INSTANCE.GblTrajectory_getMeasResults(self, aLabel, numData, d_aResiduals, d_aMeasErrors, d_aResErrors, d_aDownWeights);

for (int i=0; i<2; i++) {
aResiduals.add(d_aResiduals[i]);
aMeasErrors.add(d_aMeasErrors[i]);
aResErrors.add(d_aResErrors[i]);
aDownWeights.add(d_aDownWeights[i]);
}

}

//!! Only 5-localPar and 5x5 local Cov for the moment
public void getResults(int aSignedLabel, Vector localPar, SymMatrix localCov) {
public int getResults(int aSignedLabel, Vector localPar, SymMatrix localCov) {

double[] d_localPar = new double[5];
double[] d_localCov = new double[25];
Expand All @@ -169,6 +195,8 @@ public void getResults(int aSignedLabel, Vector localPar, SymMatrix localCov) {
localCov.set(i,j,d_localCov[i+5*j]);
}
}

return 0;
}


Expand Down
Loading