8 modified files
java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/TrackingReconstructionPlots.java 2014-08-26 02:23:26 UTC (rev 911)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/TrackingReconstructionPlots.java 2014-08-26 23:13:08 UTC (rev 912)
@@ -109,7 +109,6 @@
//topFrame.setTitle("Top Tracking Plots");
//bottomFrame = new AIDAFrame();
//bottomFrame.setTitle("Bottom Tracking Plots");
-
sensors = detector.getSubdetector(trackerName).getDetectorElement().findDescendants(SiSensor.class);
IAnalysisFactory fac = aida.analysisFactory();
@@ -130,12 +129,10 @@
plotter.region(1).plot(trkPy);
plotter.region(2).plot(trkPz);
plotter.region(3).plot(trkChi2);
-
+
plotter.show();
// ******************************************************************
-
-
top1 = fac.createPlotterFactory().create("Top Tracking Plots");
top1.setTitle("Top Momentum");
IPlotterStyle stop1 = top1.style();
@@ -153,10 +150,9 @@
top1.region(1).plot(toptrkPy);
top1.region(2).plot(toptrkPz);
top1.region(3).plot(toptrkChi2);
-
+
top1.show();
-
bot1 = fac.createPlotterFactory().create("Bottom Tracking Plots");
bot1.setTitle("Bottom Momentum");
IPlotterStyle sbot1 = bot1.style();
@@ -176,9 +172,8 @@
bot1.region(3).plot(bottrkChi2);
bot1.show();
-
-// ******************************************************************
+// ******************************************************************
IHistogram1D trkd0 = aida.histogram1D("d0 ", 25, -100.0, 100.0);
IHistogram1D trkphi = aida.histogram1D("sinphi ", 25, -0.2, 0.2);
IHistogram1D trkomega = aida.histogram1D("omega ", 25, -0.0025, 0.0025);
@@ -198,7 +193,6 @@
plotter22.region(3).plot(trklam);
plotter22.region(4).plot(trkz0);
-
plotter2 = fac.createPlotterFactory().create("HPS Tracking Plots");
plotter2.setTitle("Track extrapolation");
//plotterFrame.addPlotter(plotter2);
@@ -246,7 +240,6 @@
plotter222.region(2).plot(ampcl);
plotter222.region(5).plot(ampcl2);
-
plotter3 = fac.createPlotterFactory().create("HPS Residual Plots");
plotter3.setTitle("Residuals");
//plotterFrame.addPlotter(plotter3);
@@ -288,7 +281,6 @@
plotter3.region(7).plot(mod4ResY);
plotter3.region(9).plot(mod5ResY);
-
plotter3_1 = fac.createPlotterFactory().create("HPS Residual Plots (Single hit per layer)");
plotter3_1.setTitle("Residuals (Top)");
//plotterFrame.addPlotter(plotter3_1);
@@ -324,7 +316,6 @@
plotter3_1.region(7).plot(mod4ResY_Top);
plotter3_1.region(9).plot(mod5ResY_Top);
-
plotter3_2 = fac.createPlotterFactory().create("HPS Residual Plots (Single strip cluster per layer)");
plotter3_2.setTitle("Residuals (Bottom)");
//plotterFrame.addPlotter(plotter3_2);
@@ -360,9 +351,6 @@
plotter3_2.region(7).plot(mod4ResY_Bottom);
plotter3_2.region(9).plot(mod5ResY_Bottom);
-
-
-
plotter4 = fac.createPlotterFactory().create("HPS Track and ECal Plots");
plotter4.setTitle("Track and ECal Correlations");
//plotterFrame.addPlotter(plotter4);
@@ -381,7 +369,6 @@
// IHistogram1D distX2 = aida.histogram1D("deltaX (Pz>1)", 50, -400, 400);
// IHistogram1D distY2 = aida.histogram1D("deltaY (Pz>1)", 50, -40, 40);
-
IHistogram2D xEcalVsTrk = aida.histogram2D("X ECal Vs Track", 100, -400, 400, 100, -400, 400);
IHistogram2D yEcalVsTrk = aida.histogram2D("Y ECal Vs Track", 100, -100, 100, 100, -100, 100);
@@ -392,10 +379,7 @@
plotter4.region(2).plot(xEcalVsTrk);
plotter4.region(5).plot(yEcalVsTrk);
-
// ******************************************************************
-
-
top2 = fac.createPlotterFactory().create("Top ECal Plots");
top2.setTitle("Top ECal Correlations");
IPlotterStyle stop2 = top2.style();
@@ -411,12 +395,10 @@
IHistogram1D topdistX = aida.histogram1D("Top deltaX", 50, -400, 400);
IHistogram1D topdistY = aida.histogram1D("Top deltaY", 50, -40, 40);
-
IHistogram2D topxEcalVsTrk = aida.histogram2D("Top X ECal Vs Track", 100, -400, 400, 100, -400, 400);
IHistogram2D topyEcalVsTrk = aida.histogram2D("Top Y ECal Vs Track", 100, 0, 100, 100, 0, 100);
-
top2.region(0).plot(topeVsP);
top2.region(3).plot(topeOverP);
top2.region(1).plot(topdistX);
@@ -424,7 +406,6 @@
top2.region(2).plot(topxEcalVsTrk);
top2.region(5).plot(topyEcalVsTrk);
-
bot2 = fac.createPlotterFactory().create("Bottom ECal Plots");
bot2.setTitle("Bottom ECal Correlations");
IPlotterStyle sbot2 = bot2.style();
@@ -440,12 +421,10 @@
IHistogram1D BottomdistX = aida.histogram1D("Bottom deltaX", 50, -400, 400);
IHistogram1D BottomdistY = aida.histogram1D("Bottom deltaY", 50, -40, 40);
-
-
+
IHistogram2D BottomxEcalVsTrk = aida.histogram2D("Bottom X ECal Vs Track", 100, -400, 400, 100, -400, 400);
IHistogram2D BottomyEcalVsTrk = aida.histogram2D("Bottom Y ECal Vs Track", 100, -100, 0, 100, -100, 0);
-
bot2.region(0).plot(BottomeVsP);
bot2.region(3).plot(BottomeOverP);
bot2.region(1).plot(BottomdistX);
@@ -453,9 +432,7 @@
bot2.region(2).plot(BottomxEcalVsTrk);
bot2.region(5).plot(BottomyEcalVsTrk);
-
// ******************************************************************
-
top3 = fac.createPlotterFactory().create("Top ECal Plots");
top3.setTitle("Top ECal More Correlations");
IPlotterStyle stop3 = top3.style();
@@ -465,14 +442,13 @@
stop3.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
top3.createRegions(1, 2);
//topFrame.addPlotter(top3);
-
- IHistogram2D topdistXvsX = aida.histogram2D("Top deltaX vs X", 51,-400,400, 25, -400, 400);
- IHistogram2D topdistYvsY = aida.histogram2D("Top deltaY vs Y", 51,0,100, 25, -40, 40);
-
+
+ IHistogram2D topdistXvsX = aida.histogram2D("Top deltaX vs X", 51, -400, 400, 25, -400, 400);
+ IHistogram2D topdistYvsY = aida.histogram2D("Top deltaY vs Y", 51, 0, 100, 25, -40, 40);
+
top3.region(0).plot(topdistXvsX);
top3.region(1).plot(topdistYvsY);
-
-
+
bot3 = fac.createPlotterFactory().create("Bottom ECal Plots");
bot3.setTitle("Bottom ECal More Correlations");
IPlotterStyle sbot3 = bot3.style();
@@ -482,19 +458,14 @@
sbot3.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
bot3.createRegions(1, 2);
//bottomFrame.addPlotter(bot3);
-
-
- IHistogram2D botdistXvsX = aida.histogram2D("Bottom deltaX vs X", 51,-400,400, 25, -400, 400);
- IHistogram2D botdistYvsY = aida.histogram2D("Bottom deltaY vs Y", 51,-100,0, 25, -40, 40);
-
-
+
+ IHistogram2D botdistXvsX = aida.histogram2D("Bottom deltaX vs X", 51, -400, 400, 25, -400, 400);
+ IHistogram2D botdistYvsY = aida.histogram2D("Bottom deltaY vs Y", 51, -100, 0, 25, -40, 40);
+
bot3.region(0).plot(botdistXvsX);
bot3.region(1).plot(botdistYvsY);
-
-
-// ******************************************************************
-
+// ******************************************************************
plotter5 = fac.createPlotterFactory().create("HPS Hit Positions");
plotter5.setTitle("Hit Positions: Top");
//plotterFrame.addPlotter(plotter5);
@@ -540,11 +511,9 @@
IProfile avgLayersTopPlot = aida.profile1D("Number of Stereo Hits per layer in Top Half", 5, 1, 11);
IProfile avgLayersBottomPlot = aida.profile1D("Number of Stereo Hits per layer in Bottom Half", 5, 1, 11);
-
plotter55.region(0).plot(avgLayersTopPlot);
plotter55.region(1).plot(avgLayersBottomPlot);
-
plotter6 = fac.createPlotterFactory().create("HPS ECAL Hit Positions");
plotter6.setTitle("ECAL Positions");
//plotterFrame.addPlotter(plotter6);
@@ -555,7 +524,6 @@
style6.dataStyle().errorBarStyle().setVisible(false);
plotter6.createRegions(4, 2);
-
IHistogram2D topECal = aida.histogram2D("Top ECal Cluster Position", 50, -400, 400, 10, 0, 100);
IHistogram2D botECal = aida.histogram2D("Bottom ECal Cluster Position", 50, -400, 400, 10, -100, 0);
IHistogram2D topECal1 = aida.histogram2D("Top ECal Cluster Position (>0 tracks)", 50, -400, 400, 10, 0, 100);
@@ -565,7 +533,6 @@
IHistogram2D topECal3 = aida.histogram2D("Top ECal Cluster Position w_E (E>100,>0 tracks)", 50, -400, 400, 10, 0, 100);
IHistogram2D botECal3 = aida.histogram2D("Bottom ECal Cluster Position w_E (E>100,>0 tracks)", 50, -400, 400, 10, -100, 0);
-
plotter6.region(0).plot(topECal);
plotter6.region(1).plot(botECal);
plotter6.region(2).plot(topECal1);
@@ -577,13 +544,10 @@
//plotterFrame.pack();
//plotterFrame.setVisible(true);
-
//topFrame.pack();
//topFrame.setVisible(true);
-
//bottomFrame.pack();
//bottomFrame.setVisible(true);
-
plotter7 = fac.createPlotterFactory().create("HPS ECAL Hit Positions");
plotter7.setTitle("Basic Misc Stuff");
//plotterFrame.addPlotter(plotter7);
@@ -597,7 +561,6 @@
IHistogram2D quadrants = aida.histogram2D("Charge vs Slope", 2, -1, 1, 2, -1, 1);
plotter7.region(0).plot(quadrants);
-
}
public TrackingReconstructionPlots() {
@@ -685,24 +648,26 @@
return;
}
-
-
List<Track> tracks = event.get(Track.class, trackCollectionName);
nTracks.fill(tracks.size());
if (event.hasCollection(HPSEcalCluster.class, ecalCollectionName)) {
List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, ecalCollectionName);
for (HPSEcalCluster cluster : clusters) {
//System.out.println("cluser position = ("+cluster.getPosition()[0]+","+cluster.getPosition()[1]+") with energy = "+cluster.getEnergy());
- if (cluster.getPosition()[1] > 0)
+ if (cluster.getPosition()[1] > 0) {
aida.histogram2D("Top ECal Cluster Position").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
- if (cluster.getPosition()[1] < 0)
+ }
+ if (cluster.getPosition()[1] < 0) {
aida.histogram2D("Bottom ECal Cluster Position").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
+ }
if (tracks.size() > 0) {
- if (cluster.getPosition()[1] > 0)
+ if (cluster.getPosition()[1] > 0) {
aida.histogram2D("Top ECal Cluster Position (>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
- if (cluster.getPosition()[1] < 0)
+ }
+ if (cluster.getPosition()[1] < 0) {
aida.histogram2D("Bottom ECal Cluster Position (>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]);
+ }
if (cluster.getEnergy() > 100) {
if (cluster.getPosition()[1] > 0) {
@@ -716,12 +681,9 @@
}
}
-
-
}
}
-
List<SiTrackerHitStrip1D> stripHits = event.get(SiTrackerHitStrip1D.class, "StripClusterer_SiTrackerHitStrip1D");
int stripClustersPerLayerTop[] = getStripClustersPerLayer(stripHits, "up");
//int stripClustersPerLayerBottom[] = getStripClustersPerLayer(stripHits,"down");
@@ -752,13 +714,11 @@
aida.histogram1D("X (mm) @ Z=-150cm").fill(slt.getYZAtX(zAtColl)[0]);
aida.histogram1D("Y (mm) @ Z=-150cm").fill(slt.getYZAtX(zAtColl)[1]);
-
//Straight line after field-region???
//HelixConverter converterEcal = new HelixConverter(zAtDownStrPairSpec);
//StraightLineTrack sltEcal = converterEcal.Convert(ht);
// double sECAL = HelixUtils.PathToXPlane(ht, zEcal, 3000, 1).get(0);
// Hep3Vector posonhelix = HelixUtils.PointOnHelix(ht, sECAL);//position in tracker coordinates!
-
aida.histogram1D("X (mm) @ ECAL").fill(posAtEcal.x());
aida.histogram1D("Y (mm) @ ECAL").fill(posAtEcal.y());
if (trk.getPX() > 1.0) {
@@ -772,12 +732,13 @@
aida.histogram1D("z0 ").fill(trk.getTrackParameter(ParameterName.z0.ordinal()));
int isTop = -1;
- if (trk.getTrackerHits().get(0).getPosition()[2] > 0)
+ if (trk.getTrackerHits().get(0).getPosition()[2] > 0) {
isTop = 0;//make plot look pretty
+ }
int charge = trk.getCharge();
- if (charge > 0)
+ if (charge > 0) {
charge = 0;//make plot look pretty
-// System.out.println("Charge = " + charge + "; isTop = " + isTop);
+ }// System.out.println("Charge = " + charge + "; isTop = " + isTop);
aida.histogram2D("Charge vs Slope").fill(charge, isTop);
if (isTop == 0) {
aida.histogram1D("Top Track Momentum (Px)").fill(trk.getPY());
@@ -801,16 +762,21 @@
double zTr = posonhelix.z();
int layer = htc.Layer();
String modNum = "Module X ";
- if (layer == 1)
+ if (layer == 1) {
modNum = "Module 1 ";
- if (layer == 3)
+ }
+ if (layer == 3) {
modNum = "Module 2 ";
- if (layer == 5)
+ }
+ if (layer == 5) {
modNum = "Module 3 ";
- if (layer == 7)
+ }
+ if (layer == 7) {
modNum = "Module 4 ";
- if (layer == 9)
+ }
+ if (layer == 9) {
modNum = "Module 5 ";
+ }
SymmetricMatrix cov = htc.getCorrectedCovMatrix();
aida.histogram1D(modNum + "Residual X(mm)").fill(htcross.getCorrectedPosition().y() - yTr);//these hits should be rotated track hits already
@@ -836,8 +802,9 @@
// System.out.println("Hit X = " + x + "; Hit Y = " + y);
aida.histogram2D("Layer 1 HTH Position: Top").fill(x - sensorPos.x(), y - sensorPos.y());
}
- if (htc.Layer() == 7)
+ if (htc.Layer() == 7) {
aida.histogram2D("Layer 7 HTH Position: Top").fill(x - sensorPos.x(), y - sensorPos.y());
+ }
} else {
layersBot[htc.Layer() - 1]++;
Hep3Vector sensorPos = ((SiSensor) ((RawTrackerHit) htc.getRawHits().get(0)).getDetectorElement()).getGeometry().getPosition();
@@ -846,36 +813,40 @@
// System.out.println("Hit X = " + x + "; Hit Y = " + y);
aida.histogram2D("Layer 1 HTH Position: Bottom").fill(x - sensorPos.x(), y - sensorPos.y());
}
- if (htc.Layer() == 7)
+ if (htc.Layer() == 7) {
aida.histogram2D("Layer 7 HTH Position: Bottom").fill(x - sensorPos.x(), y - sensorPos.y());
+ }
}
-/*
- List<RawTrackerHit> rawHits = hit.getRawHits();
- for (RawTrackerHit rawHit : rawHits) {
- ChannelConstants constants = HPSSVTCalibrationConstants.getChannelConstants((SiSensor) rawHit.getDetectorElement(), rawHit.getIdentifierFieldValue("strip"));
- HPSShapeFitParameters fit = _shaper.fitShape(rawHit, constants);
- double amp = fit.getAmp();
+ /*
+ List<RawTrackerHit> rawHits = hit.getRawHits();
+ for (RawTrackerHit rawHit : rawHits) {
+ ChannelConstants constants = HPSSVTCalibrationConstants.getChannelConstants((SiSensor) rawHit.getDetectorElement(), rawHit.getIdentifierFieldValue("strip"));
+ HPSShapeFitParameters fit = _shaper.fitShape(rawHit, constants);
+ double amp = fit.getAmp();
- aida.histogram1D("Amp (HitOnTrack)").fill(amp);
- if (trk.getPX() > 1)
- aida.histogram1D("Amp Pz>1000 (HitOnTrack)").fill(amp);
- }
- */
+ aida.histogram1D("Amp (HitOnTrack)").fill(amp);
+ if (trk.getPX() > 1)
+ aida.histogram1D("Amp Pz>1000 (HitOnTrack)").fill(amp);
+ }
+ */
- for(HelicalTrackStrip hts:htcross.getStrips()){
- double clusterSum=0;
- for(RawTrackerHit rawHit: (List<RawTrackerHit>)hts.rawhits()){
- ChannelConstants constants = HPSSVTCalibrationConstants.getChannelConstants((SiSensor) rawHit.getDetectorElement(), rawHit.getIdentifierFieldValue("strip"));
- ShapeFitParameters fit = _shaper.fitShape(rawHit, constants);
- double amp = fit.getAmp();
- clusterSum+=amp;
- aida.histogram1D("Amp (HitOnTrack)").fill(amp);
- if (trk.getPX() > 1)
- aida.histogram1D("Amp Pz>1000 (HitOnTrack)").fill(amp);
- }
- aida.histogram1D("Amp (CluOnTrack)").fill(clusterSum);
- if (trk.getPX() > 1)
- aida.histogram1D("Amp Pz>1000 (CluOnTrack)").fill(clusterSum);
+ for (HelicalTrackStrip hts : htcross.getStrips()) {
+ double clusterSum = 0;
+ for (RawTrackerHit rawHit : (List<RawTrackerHit>) hts.rawhits()) {
+ ChannelConstants constants = HPSSVTCalibrationConstants.getChannelConstants((SiSensor) rawHit.getDetectorElement(), rawHit.getIdentifierFieldValue("strip"));
+ for (ShapeFitParameters fit : _shaper.fitShape(rawHit, constants)) {
+ double amp = fit.getAmp();
+ clusterSum += amp;
+ aida.histogram1D("Amp (HitOnTrack)").fill(amp);
+ if (trk.getPX() > 1) {
+ aida.histogram1D("Amp Pz>1000 (HitOnTrack)").fill(amp);
+ }
+ }
+ }
+ aida.histogram1D("Amp (CluOnTrack)").fill(clusterSum);
+ if (trk.getPX() > 1) {
+ aida.histogram1D("Amp Pz>1000 (CluOnTrack)").fill(clusterSum);
+ }
}
}
List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, ecalCollectionName);
@@ -883,9 +854,9 @@
// if (clust != null) {
if (clust != null) {
-
- posAtEcal = TrackUtils.extrapolateTrack(trk,clust.getPosition()[2]);//.positionAtEcal();
+ posAtEcal = TrackUtils.extrapolateTrack(trk, clust.getPosition()[2]);//.positionAtEcal();
+
aida.histogram2D("Energy Vs Momentum").fill(clust.getEnergy(), trk.getPX() * 1000.0);
aida.histogram1D("Energy Over Momentum").fill(clust.getEnergy() / (trk.getPX() * 1000.0));
aida.histogram1D("deltaX").fill(clust.getPosition()[0] - posAtEcal.x());
@@ -902,8 +873,8 @@
aida.histogram1D("Top Energy Over Momentum").fill(clust.getEnergy() / (trk.getPX() * 1000.0));
aida.histogram1D("Top deltaX").fill(clust.getPosition()[0] - posAtEcal.x());
aida.histogram1D("Top deltaY").fill(clust.getPosition()[1] - posAtEcal.y());
- aida.histogram2D("Top deltaX vs X").fill(clust.getPosition()[0],clust.getPosition()[0] - posAtEcal.x());
- aida.histogram2D("Top deltaY vs Y").fill(clust.getPosition()[1],clust.getPosition()[1] - posAtEcal.y());
+ aida.histogram2D("Top deltaX vs X").fill(clust.getPosition()[0], clust.getPosition()[0] - posAtEcal.x());
+ aida.histogram2D("Top deltaY vs Y").fill(clust.getPosition()[1], clust.getPosition()[1] - posAtEcal.y());
aida.histogram2D("Top X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x());
aida.histogram2D("Top Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y());
} else {
@@ -911,8 +882,8 @@
aida.histogram1D("Bottom Energy Over Momentum").fill(clust.getEnergy() / (trk.getPX() * 1000.0));
aida.histogram1D("Bottom deltaX").fill(clust.getPosition()[0] - posAtEcal.x());
aida.histogram1D("Bottom deltaY").fill(clust.getPosition()[1] - posAtEcal.y());
- aida.histogram2D("Bottom deltaX vs X").fill(clust.getPosition()[0],clust.getPosition()[0] - posAtEcal.x());
- aida.histogram2D("Bottom deltaY vs Y").fill(clust.getPosition()[1],clust.getPosition()[1] - posAtEcal.y());
+ aida.histogram2D("Bottom deltaX vs X").fill(clust.getPosition()[0], clust.getPosition()[0] - posAtEcal.x());
+ aida.histogram2D("Bottom deltaY vs Y").fill(clust.getPosition()[1], clust.getPosition()[1] - posAtEcal.y());
aida.histogram2D("Bottom X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x());
aida.histogram2D("Bottom Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y());
}
@@ -977,15 +948,16 @@
System.out.println("Processing stripCluster " + stripCluster.toString());
}
-
if (!"".equals(side)) {
String s;
- if (stripCluster.getPosition()[1] >= 0.0)
+ if (stripCluster.getPosition()[1] >= 0.0) {
s = "up";
- else
+ } else {
s = "down";
- if (!s.equals(side))
+ }
+ if (!s.equals(side)) {
continue;
+ }
}
name = stripCluster.getSensor().getName();
@@ -1020,12 +992,13 @@
@Override
public void endOfData() {
- if (outputPlots != null)
+ if (outputPlots != null) {
try {
aida.saveAs(outputPlots);
} catch (IOException ex) {
Logger.getLogger(TrackingReconstructionPlots.class.getName()).log(Level.SEVERE, null, ex);
}
+ }
//plotterFrame.dispose();
//topFrame.dispose();
//bottomFrame.dispose();
java/trunk/tracking/src/main/java/org/hps/recon/tracking
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/DumbShaperFit.java 2014-08-26 02:23:26 UTC (rev 911)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/DumbShaperFit.java 2014-08-26 23:13:08 UTC (rev 912)
@@ -1,5 +1,7 @@
package org.hps.recon.tracking;
+import java.util.ArrayList;
+import java.util.Collection;
import org.hps.conditions.deprecated.HPSSVTCalibrationConstants.ChannelConstants;
import org.lcsim.event.RawTrackerHit;
@@ -16,12 +18,12 @@
}
@Override
- public ShapeFitParameters fitShape(RawTrackerHit rth, ChannelConstants constants) {
+ public Collection<ShapeFitParameters> fitShape(RawTrackerHit rth, ChannelConstants constants) {
short[] adcVals = rth.getADCValues();
return this.fitShape(adcVals, constants);
}
- public ShapeFitParameters fitShape(short[] adcVals, ChannelConstants constants) {
+ public Collection<ShapeFitParameters> fitShape(short[] adcVals, ChannelConstants constants) {
ShapeFitParameters fitresults = new ShapeFitParameters();
double[] pedSub = { -99.0, -99.0, -99.0, -99.0, -99.0, -99.0 };
double maxADC = -99999;
@@ -60,6 +62,8 @@
fitresults.setAmp(maxADC);
fitresults.setT0(t0);
- return fitresults;
+ ArrayList<ShapeFitParameters> fits = new ArrayList<ShapeFitParameters>();
+ fits.add(fitresults);
+ return fits;
}
}
java/trunk/tracking/src/main/java/org/hps/recon/tracking
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/RawTrackerHitFitterDriver.java 2014-08-26 02:23:26 UTC (rev 911)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/RawTrackerHitFitterDriver.java 2014-08-26 23:13:08 UTC (rev 912)
@@ -105,37 +105,38 @@
for (RawTrackerHit hit : rawHits) {
int strip = hit.getIdentifierFieldValue("strip");
ChannelConstants constants = HPSSVTCalibrationConstants.getChannelConstants((SiSensor) hit.getDetectorElement(), strip);
- ShapeFitParameters fit = _shaper.fitShape(hit, constants);
- if (correctT0Shift) {
- fit.setT0(fit.getT0() - constants.getT0Shift());
- }
- if (subtractTOF) {
- double tof = hit.getDetectorElement().getGeometry().getPosition().magnitude() / (Const.SPEED_OF_LIGHT * Const.nanosecond);
- fit.setT0(fit.getT0() - tof);
- }
- if (useTimestamps) {
- double t0Svt = ReadoutTimestamp.getTimestamp(ReadoutTimestamp.SYSTEM_TRACKER, event);
- double t0Trig = ReadoutTimestamp.getTimestamp(ReadoutTimestamp.SYSTEM_TRIGGERBITS, event);
- double corMod = (t0Svt - t0Trig) + 200.0;
- fit.setT0(fit.getT0() + corMod);
- }
- if (useTruthTime) {
- double t0Svt = ReadoutTimestamp.getTimestamp(ReadoutTimestamp.SYSTEM_TRACKER, event);
- double absoluteHitTime = fit.getT0() + t0Svt;
- double relativeHitTime = ((absoluteHitTime + 250.0) % 500.0) - 250.0;
+ for (ShapeFitParameters fit : _shaper.fitShape(hit, constants)) {
+ if (correctT0Shift) {
+ fit.setT0(fit.getT0() - constants.getT0Shift());
+ }
+ if (subtractTOF) {
+ double tof = hit.getDetectorElement().getGeometry().getPosition().magnitude() / (Const.SPEED_OF_LIGHT * Const.nanosecond);
+ fit.setT0(fit.getT0() - tof);
+ }
+ if (useTimestamps) {
+ double t0Svt = ReadoutTimestamp.getTimestamp(ReadoutTimestamp.SYSTEM_TRACKER, event);
+ double t0Trig = ReadoutTimestamp.getTimestamp(ReadoutTimestamp.SYSTEM_TRIGGERBITS, event);
+ double corMod = (t0Svt - t0Trig) + 200.0;
+ fit.setT0(fit.getT0() + corMod);
+ }
+ if (useTruthTime) {
+ double t0Svt = ReadoutTimestamp.getTimestamp(ReadoutTimestamp.SYSTEM_TRACKER, event);
+ double absoluteHitTime = fit.getT0() + t0Svt;
+ double relativeHitTime = ((absoluteHitTime + 250.0) % 500.0) - 250.0;
- fit.setT0(relativeHitTime);
+ fit.setT0(relativeHitTime);
+ }
+ if (debug) {
+ System.out.println(fit);
+ }
+ fits.add(fit);
+ FittedRawTrackerHit hth = new FittedRawTrackerHit(hit, fit);
+ hits.add(hth);
+ if (strip == HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR) { // drop unbonded channel
+ continue;
+ }
+ hit.getDetectorElement().getReadout().addHit(hth);
}
- if (debug) {
- System.out.println(fit);
- }
- fits.add(fit);
- FittedRawTrackerHit hth = new FittedRawTrackerHit(hit, fit);
- hits.add(hth);
- if (strip == HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR) { // drop unbonded channel
- continue;
- }
- hit.getDetectorElement().getReadout().addHit(hth);
}
event.put(fitCollectionName, fits, ShapeFitParameters.class, genericObjectFlags);
event.put(fittedHitCollectionName, hits, FittedRawTrackerHit.class, relationFlags);
java/trunk/tracking/src/main/java/org/hps/recon/tracking
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/ShaperAnalyticFitAlgorithm.java 2014-08-26 02:23:26 UTC (rev 911)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/ShaperAnalyticFitAlgorithm.java 2014-08-26 23:13:08 UTC (rev 912)
@@ -1,5 +1,7 @@
package org.hps.recon.tracking;
+import java.util.ArrayList;
+import java.util.Collection;
import org.hps.conditions.deprecated.HPSSVTCalibrationConstants.ChannelConstants;
import org.hps.conditions.deprecated.HPSSVTConstants;
import org.lcsim.event.RawTrackerHit;
@@ -14,12 +16,12 @@
public class ShaperAnalyticFitAlgorithm implements ShaperFitAlgorithm {
@Override
- public ShapeFitParameters fitShape(RawTrackerHit rth, ChannelConstants constants) {
+ public Collection<ShapeFitParameters> fitShape(RawTrackerHit rth, ChannelConstants constants) {
short[] samples = rth.getADCValues();
return this.fitShape(samples, constants);
}
- public ShapeFitParameters fitShape(short[] samples, ChannelConstants constants) {
+ public Collection<ShapeFitParameters> fitShape(short[] samples, ChannelConstants constants) {
double minChisq = Double.POSITIVE_INFINITY;
int bestStart = 0;
ShapeFitParameters fit = new ShapeFitParameters();
@@ -37,7 +39,9 @@
// constants.getPedestal(), samples[4] - constants.getPedestal(), samples[5] -
// constants.getPedestal());
// System.out.println("start = " + bestStart + ", " + fit);
- return fit;
+ ArrayList<ShapeFitParameters> fits = new ArrayList<ShapeFitParameters>();
+ fits.add(fit);
+ return fits;
}
private double fitSection(short[] samples, ChannelConstants constants, ShapeFitParameters fit, int start) {
java/trunk/tracking/src/main/java/org/hps/recon/tracking
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/ShaperFitAlgorithm.java 2014-08-26 02:23:26 UTC (rev 911)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/ShaperFitAlgorithm.java 2014-08-26 23:13:08 UTC (rev 912)
@@ -1,5 +1,6 @@
package org.hps.recon.tracking;
+import java.util.Collection;
import org.hps.conditions.deprecated.HPSSVTCalibrationConstants.ChannelConstants;
import org.lcsim.event.RawTrackerHit;
@@ -10,6 +11,6 @@
// TODO: Add class documentation.
public interface ShaperFitAlgorithm {
- public ShapeFitParameters fitShape(RawTrackerHit rth, ChannelConstants constants);
+ public Collection<ShapeFitParameters> fitShape(RawTrackerHit rth, ChannelConstants constants);
}
java/trunk/tracking/src/main/java/org/hps/recon/tracking
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/ShaperLinearFitAlgorithm.java 2014-08-26 02:23:26 UTC (rev 911)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/ShaperLinearFitAlgorithm.java 2014-08-26 23:13:08 UTC (rev 912)
@@ -1,5 +1,7 @@
package org.hps.recon.tracking;
+import java.util.ArrayList;
+import java.util.Collection;
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.linear.ArrayRealVector;
import org.apache.commons.math3.linear.CholeskyDecomposition;
@@ -7,10 +9,9 @@
import org.apache.commons.math3.linear.RealVector;
import org.freehep.math.minuit.FCNBase;
import org.freehep.math.minuit.FunctionMinimum;
-import org.freehep.math.minuit.MnHesse;
+import org.freehep.math.minuit.MinosError;
+import org.freehep.math.minuit.MnMinos;
import org.freehep.math.minuit.MnSimplex;
-import org.freehep.math.minuit.MnStrategy;
-import org.freehep.math.minuit.MnUserParameterState;
import org.freehep.math.minuit.MnUserParameters;
import org.hps.conditions.deprecated.HPSSVTCalibrationConstants.ChannelConstants;
import org.hps.conditions.deprecated.HPSSVTConstants;
@@ -28,6 +29,7 @@
final int nPeaks;
final double[] times;
final double[] amplitudes;
+ final double[] amplitudeErrors;
private ChannelConstants channelConstants;
private double[] y;
private double[] sigma;
@@ -37,21 +39,23 @@
nPeaks = 1;
times = new double[nPeaks];
amplitudes = new double[nPeaks];
+ amplitudeErrors = new double[nPeaks];
}
public ShaperLinearFitAlgorithm(int nPeaks) {
this.nPeaks = nPeaks;
times = new double[nPeaks];
amplitudes = new double[nPeaks];
+ amplitudeErrors = new double[nPeaks];
}
@Override
- public ShapeFitParameters fitShape(RawTrackerHit rth, ChannelConstants constants) {
+ public Collection<ShapeFitParameters> fitShape(RawTrackerHit rth, ChannelConstants constants) {
short[] samples = rth.getADCValues();
return this.fitShape(samples, constants);
}
- public ShapeFitParameters fitShape(short[] samples, ChannelConstants constants) {
+ public Collection<ShapeFitParameters> fitShape(short[] samples, ChannelConstants constants) {
channelConstants = constants;
y = new double[samples.length];
sigma = new double[samples.length];
@@ -62,8 +66,6 @@
usedSamples[i] = i;
}
- MnStrategy myStrategy = new MnStrategy(2);
-
MnUserParameters myParams = new MnUserParameters();
myParams.add("time", 0.0, HPSSVTConstants.SAMPLING_INTERVAL, -500.0, (samples.length - 1) * HPSSVTConstants.SAMPLING_INTERVAL);
@@ -71,15 +73,16 @@
MnSimplex simplex = new MnSimplex(this, myParams, 2);
FunctionMinimum min = simplex.minimize();
- MnHesse hesse = new MnHesse(2);
- MnUserParameterState myState = hesse.calculate(this, myParams);
+ MnMinos minos = new MnMinos(this, min);
+ MinosError t0err = minos.minos(0);
ShapeFitParameters fit = new ShapeFitParameters();
fit.setAmp(amplitudes[0]);
+ fit.setAmpErr(amplitudes[0]);
fit.setChiSq(min.fval());
fit.setT0(times[0]);
- fit.setT0Err(myState.error(0));
+ fit.setT0Err((t0err.lower() + t0err.upper()) / 2);
fit.setTp(constants.getTp());
// System.out.format("%f\t%f\t%f\t%f\t%f\t%f\n", samples[0] - constants.getPedestal(),
@@ -87,25 +90,31 @@
// constants.getPedestal(), samples[4] - constants.getPedestal(), samples[5] -
// constants.getPedestal());
// System.out.println("start = " + bestStart + ", " + fit);
- return fit;
+ ArrayList<ShapeFitParameters> fits = new ArrayList<ShapeFitParameters>();
+ fits.add(fit);
+ return fits;
}
private double doLinFit(double[] times) {
RealMatrix sc_mat = new Array2DRowRealMatrix(nPeaks, usedSamples.length);
RealVector y_vec = new ArrayRealVector(usedSamples.length);
+ RealVector var_vec = new ArrayRealVector(usedSamples.length);
for (int j = 0; j < usedSamples.length; j++) {
for (int i = 0; i < times.length; i++) {
sc_mat.setEntry(i, usedSamples[j], getAmplitude(HPSSVTConstants.SAMPLING_INTERVAL * usedSamples[j] - times[i], channelConstants) / sigma[usedSamples[j]]);
}
y_vec.setEntry(usedSamples[j], y[usedSamples[j]] / sigma[usedSamples[j]]);
+ var_vec.setEntry(usedSamples[j], sigma[usedSamples[j]] * sigma[usedSamples[j]]);
}
RealVector a_vec = sc_mat.operate(y_vec);
RealMatrix coeff_mat = sc_mat.multiply(sc_mat.transpose());
CholeskyDecomposition a_qr = new CholeskyDecomposition(coeff_mat);
RealVector solved_amplitudes = a_qr.getSolver().solve(a_vec);
+ RealVector amplitude_err = a_qr.getSolver().solve(var_vec);
for (int i = 0; i < times.length; i++) {
amplitudes[i] = solved_amplitudes.getEntry(i);
+ amplitudeErrors[i] = Math.sqrt(amplitude_err.getEntry(i));
}
return y_vec.subtract(sc_mat.operate(solved_amplitudes)).getNorm();
}
java/trunk/users/src/main/java/org/hps/users/omoreno
--- java/trunk/users/src/main/java/org/hps/users/omoreno/SvtPerformance.java 2014-08-26 02:23:26 UTC (rev 911)
+++ java/trunk/users/src/main/java/org/hps/users/omoreno/SvtPerformance.java 2014-08-26 23:13:08 UTC (rev 912)
@@ -1,6 +1,5 @@
package org.hps.users.omoreno;
-
import hep.aida.IHistogram1D;
import hep.aida.IPlotter;
import hep.physics.vec.BasicHep3Vector;
@@ -29,7 +28,7 @@
/**
* Driver that looks at the performance of the SVT.
- *
+ *
* @author Omar Moreno <[log in to unmask]>
* @version $Id:$
*/
@@ -38,19 +37,19 @@
private AIDA aida;
private List<IPlotter> plotters = new ArrayList<IPlotter>();
ShaperAnalyticFitAlgorithm shaperFitter = new ShaperAnalyticFitAlgorithm();
-
+
File performanceOutputFile;
BufferedWriter performanceWriter;
- File samplesOutputFile;
- BufferedWriter samplesWriter;
+ File samplesOutputFile;
+ BufferedWriter samplesWriter;
String performanceOutputFileName = "svt_performance.dat";
String samplesOutputFileName = "samples.dat";
int plotterIndex = 0;
- int eventNumber = 0;
- int runNumber = 0;
+ int eventNumber = 0;
+ int runNumber = 0;
double totalTracks = 0;
double totalTwoTrackEvents = 0;
@@ -65,98 +64,97 @@
// Plot Flags
boolean plotClustersPerLayer = false;
boolean plotMIP = false;
- boolean plotSamples = false;
- boolean batchMode = true;
-
- public SvtPerformance(){
+ boolean plotSamples = false;
+ boolean batchMode = true;
+
+ public SvtPerformance() {
}
// --- Setters ---//
// ---------------//
-
/**
* Enable/disble debug mode
- *
+ *
* @param true or false
- *
+ *
*/
- public void setDebug(boolean debug){
+ public void setDebug(boolean debug) {
this.debug = debug;
}
/**
* Enable/disable plotting the number of clusters per layer. Only clusters
* from stereo hits associated with a track are used.
- *
+ *
* @param true or false
- *
+ *
*/
- public void setPlotClustersPerLayer(boolean plotClustersPerLayer){
+ public void setPlotClustersPerLayer(boolean plotClustersPerLayer) {
this.plotClustersPerLayer = plotClustersPerLayer;
}
/**
* Enable/disable plotting the cluster charge. Only clusters from stereo
* hits associated with a track are used.
- *
+ *
* @param true or false
- *
+ *
*/
- public void setPlotClusterCharge(boolean plotMIP){
+ public void setPlotClusterCharge(boolean plotMIP) {
this.plotMIP = plotMIP;
}
/**
- * Enable/disable plotting of raw hit samples. Only raw hits from clusters
+ * Enable/disable plotting of raw hit samples. Only raw hits from clusters
* associated with a track are used.
- *
+ *
* @param true or false
- *
+ *
*/
- public void setPlotSamples(boolean plotSamples){
- this.plotSamples = plotSamples;
+ public void setPlotSamples(boolean plotSamples) {
+ this.plotSamples = plotSamples;
}
-
+
/**
- * Enable/disable batch mode. If set to true, plots are not shown.
+ * Enable/disable batch mode. If set to true, plots are not shown.
*
* @param true or false
- *
+ *
*/
- public void setBatchMode(boolean batchMode){
- this.batchMode = batchMode;
+ public void setBatchMode(boolean batchMode) {
+ this.batchMode = batchMode;
}
-
+
/**
* Set the name of the file to which performance data will be written.
- *
+ *
* @param peformanceOutputFileName: Name of the output file
- *
+ *
*/
- public void setPerformanceOutputFileName(String performanceOutputFileName){
+ public void setPerformanceOutputFileName(String performanceOutputFileName) {
this.performanceOutputFileName = performanceOutputFileName;
}
/**
* Set the name of the file to which raw sample data will be written.
- *
+ *
* @param samplesOutputFileName : Name of the output file
- *
+ *
*/
- public void setSamplesOutputFileName(String samplesOutputFileName){
+ public void setSamplesOutputFileName(String samplesOutputFileName) {
this.samplesOutputFileName = samplesOutputFileName;
}
-
+
/**
* Set the run number
- *
- * @param runNumber
- *
+ *
+ * @param runNumber
+ *
*/
- public void setRunNumber(int runNumber){
- this.runNumber = runNumber;
+ public void setRunNumber(int runNumber) {
+ this.runNumber = runNumber;
}
-
+
protected void detectorChanged(Detector detector) {
this.printDebug("Setting up plots");
@@ -164,7 +162,7 @@
// setup AIDA
aida = AIDA.defaultInstance();
aida.tree().cd("/");
-
+
// Get the list of sensors from the detector
List<HpsSiSensor> sensors = detector.getDetectorElement().findDescendants(HpsSiSensor.class);
@@ -174,10 +172,9 @@
// --- Clusters Per Layer ---//
// --------------------------//
+ if (plotClustersPerLayer) {
- if(plotClustersPerLayer){
-
- if(!batchMode){
+ if (!batchMode) {
plotters.add(PlotUtils.setupPlotter("# Clusters Per Layer", 1, 2));
for (HpsSiSensor sensor : sensors) {
if (sensor.isTopLayer()) {
@@ -197,21 +194,23 @@
// --- MIP Plots ---//
// -----------------//
- if(plotMIP){
+ if (plotMIP) {
try {
-
+
performanceOutputFile = new File(performanceOutputFileName);
- if (!performanceOutputFile.exists()) performanceOutputFile.createNewFile();
-
+ if (!performanceOutputFile.exists()) {
+ performanceOutputFile.createNewFile();
+ }
+
performanceWriter = new BufferedWriter(new FileWriter(performanceOutputFile.getAbsoluteFile()));
-
+
} catch (IOException exception) {
exception.printStackTrace();
}
-
- try{
+ try {
+
performanceWriter.write("! run I\n");
performanceWriter.write("! event I\n");
performanceWriter.write("! volume I\n");
@@ -226,13 +225,12 @@
performanceWriter.write("! hit_y D\n");
performanceWriter.write("! trk_chi_squared D\n");
performanceWriter.write("! hit_time D\n");
-
-
- } catch(IOException exception){
+
+ } catch (IOException exception) {
exception.printStackTrace();
}
-
- if(!batchMode){
+
+ if (!batchMode) {
plotters.add(PlotUtils.setupPlotter("Cluster Charge", 5, 4));
for (HpsSiSensor sensor : sensors) {
if (sensor.isTopLayer()) {
@@ -247,24 +245,25 @@
plotterIndex++;
}
}
-
+
//--- Sample Plots ---//
//--------------------//
- if(plotSamples){
+ if (plotSamples) {
try {
-
+
samplesOutputFile = new File(samplesOutputFileName);
- if (!samplesOutputFile.exists()) samplesOutputFile.createNewFile();
-
+ if (!samplesOutputFile.exists()) {
+ samplesOutputFile.createNewFile();
+ }
+
samplesWriter = new BufferedWriter(new FileWriter(samplesOutputFile.getAbsoluteFile()));
-
+
} catch (IOException exception) {
exception.printStackTrace();
}
-
-
- try{
+
+ try {
samplesWriter.write("! run I\n");
samplesWriter.write("! event I\n");
samplesWriter.write("! volume I\n");
@@ -277,70 +276,77 @@
samplesWriter.write("! sample5 I\n");
samplesWriter.write("! sample6 I\n");
samplesWriter.write("! pedestal D\n");
-
-
- } catch(IOException exception){
-
+
+ } catch (IOException exception) {
+
}
-
+
}
-
- if(batchMode) return;
-
+
+ if (batchMode) {
+ return;
+ }
+
// Show the plotters
- for (IPlotter plotter : plotters) plotter.show();
+ for (IPlotter plotter : plotters) {
+ plotter.show();
+ }
}
public void process(EventHeader event) {
- eventNumber++;
-
- if (!event.hasCollection(Track.class, trackCollectionName))
+ eventNumber++;
+
+ if (!event.hasCollection(Track.class, trackCollectionName)) {
return;
+ }
List<Track> tracks = event.get(Track.class, trackCollectionName);
HpsSiSensor sensor = null;
String plotTitle = null;
int channel, bad_channel;
- int maxClusterChannel = 0;
- int hitsPerCluster = 0;
+ int maxClusterChannel = 0;
+ int hitsPerCluster = 0;
ChannelConstants constants = null;
- ShapeFitParameters fit = null;
double clusterAmplitude, maxClusterAmplitude;
double noise = 0;
double chiSquared = -1;
double trkChiSquared = 0;
- double hitTime = 0;
- double hitX, hitY, pedestal;
- short[] samples;
+ double hitTime = 0;
+ double hitX, hitY, pedestal;
+ short[] samples;
// Loop over all tracks in an event
for (Track track : tracks) {
- trkChiSquared = 0;
- trkChiSquared = track.getChi2();
-
- if((new BasicHep3Vector(track.getTrackStates().get(0).getMomentum())).magnitude() <= .500) continue;
-
- double[] topClusters = new double[10];
+ trkChiSquared = 0;
+ trkChiSquared = track.getChi2();
+
+ if ((new BasicHep3Vector(track.getTrackStates().get(0).getMomentum())).magnitude() <= .500) {
+ continue;
+ }
+
+ double[] topClusters = new double[10];
double[] bottomClusters = new double[10];
// Loop over all stereo hits associated with a track
- hitX = 0; hitY = 0;
+ hitX = 0;
+ hitY = 0;
for (TrackerHit trackerHit : track.getTrackerHits()) {
-
- hitX = trackerHit.getPosition()[1];
- hitY = trackerHit.getPosition()[2];
-
+
+ hitX = trackerHit.getPosition()[1];
+ hitY = trackerHit.getPosition()[2];
+
// Loop over the strip hits used to crate the stereo hit
- hitTime = 0;
+ hitTime = 0;
for (HelicalTrackStrip stripHit : ((HelicalTrackCross) trackerHit).getStrips()) {
-
- hitTime = stripHit.time();
-
+
+ hitTime = stripHit.time();
+
sensor = (HpsSiSensor) ((RawTrackerHit) stripHit.rawhits().get(0)).getDetectorElement();
- if (sensor.isTopLayer())
+ if (sensor.isTopLayer()) {
topClusters[sensor.getLayerNumber() - 1] += 1;
- else
+ } else {
bottomClusters[sensor.getLayerNumber() - 1] += 1;
+ }
maxClusterAmplitude = 0;
clusterAmplitude = 0;
@@ -353,43 +359,44 @@
RawTrackerHit rawHit = (RawTrackerHit) rh;
channel = rawHit.getIdentifierFieldValue("strip");
// Check if the channel neighbors a channel that has been tagged as bad
- if(HPSSVTCalibrationConstants.isBadChannel(sensor, channel+1)
- || HPSSVTCalibrationConstants.isBadChannel(sensor, channel-1)){
- bad_channel = 1;
+ if (HPSSVTCalibrationConstants.isBadChannel(sensor, channel + 1)
+ || HPSSVTCalibrationConstants.isBadChannel(sensor, channel - 1)) {
+ bad_channel = 1;
}
-
- if(plotSamples){
+
+ if (plotSamples) {
samples = rawHit.getADCValues();
pedestal = sensor.getPedestal(channel);
-
+
try {
- if(sensor.isTopLayer()){
+ if (sensor.isTopLayer()) {
samplesWriter.write(runNumber + " " + eventNumber + " 0 " + sensor.getLayerNumber() + " ");
} else {
samplesWriter.write(runNumber + " " + eventNumber + " 1 " + sensor.getLayerNumber() + " ");
}
samplesWriter.write(channel + " " + samples[0] + " " + samples[1] + " " + samples[2] + " "
- + samples[3] + " " + samples[4] + " " + samples[5] + " " + pedestal + "\n");
+ + samples[3] + " " + samples[4] + " " + samples[5] + " " + pedestal + "\n");
} catch (IOException exception) {
exception.printStackTrace();
}
}
-
+
constants = HPSSVTCalibrationConstants.getChannelConstants(sensor, channel);
- fit = shaperFitter.fitShape(rawHit, constants);
- if (fit.getAmp() > maxClusterAmplitude) {
- maxClusterChannel = channel;
- maxClusterAmplitude = fit.getAmp();
+ for (ShapeFitParameters fit : shaperFitter.fitShape(rawHit, constants)) {
+ if (fit.getAmp() > maxClusterAmplitude) {
+ maxClusterChannel = channel;
+ maxClusterAmplitude = fit.getAmp();
+ }
+ if (stripHit.rawhits().size() == 1) {
+ chiSquared = fit.getChiSq();
+ }
+ noise += Math.pow(sensor.getNoise(channel), 2);
+ clusterAmplitude += fit.getAmp();
}
- if(stripHit.rawhits().size() == 1){
- chiSquared = fit.getChiSq();
- }
- noise += Math.pow(sensor.getNoise(channel), 2);
- clusterAmplitude += fit.getAmp();
}
noise = Math.sqrt(noise);
-
+
if (plotMIP) {
try {
if (sensor.isTopLayer()) {
@@ -399,13 +406,13 @@
plotTitle = "Bottom - Layer " + sensor.getLayerNumber() + " - Cluster Charge";
performanceWriter.write(runNumber + " " + eventNumber + " 1 " + sensor.getLayerNumber() + " ");
}
- performanceWriter.write(maxClusterChannel + " " + clusterAmplitude + " " + noise + " " + hitsPerCluster + " "
- + bad_channel + " " + chiSquared + " " + hitX + " " + hitY + " " + trkChiSquared + " "
- + hitTime + "\n");
+ performanceWriter.write(maxClusterChannel + " " + clusterAmplitude + " " + noise + " " + hitsPerCluster + " "
+ + bad_channel + " " + chiSquared + " " + hitX + " " + hitY + " " + trkChiSquared + " "
+ + hitTime + "\n");
} catch (IOException exception) {
- exception.printStackTrace();
+ exception.printStackTrace();
}
- if(!batchMode){
+ if (!batchMode) {
aida.histogram1D(plotTitle).fill(clusterAmplitude);
}
}
@@ -432,8 +439,9 @@
* print debug statements
*/
public void printDebug(String debugStatement) {
- if (!debug)
+ if (!debug) {
return;
+ }
System.out.println(this.getClass().getSimpleName() + ": " + debugStatement);
}
@@ -442,7 +450,7 @@
try {
performanceWriter.close();
- samplesWriter.close();
+ samplesWriter.close();
} catch (IOException exception) {
exception.printStackTrace();
}
java/trunk/users/src/main/java/org/hps/users/omoreno
--- java/trunk/users/src/main/java/org/hps/users/omoreno/SvtQA.java 2014-08-26 02:23:26 UTC (rev 911)
+++ java/trunk/users/src/main/java/org/hps/users/omoreno/SvtQA.java 2014-08-26 23:13:08 UTC (rev 912)
@@ -42,7 +42,7 @@
/**
* SVT Quality Assurance Driver
- *
+ *
* @author Omar Moreno <[log in to unmask]>
* @version $Id: SvtQA.java,v 1.7 2013/10/25 19:45:01 jeremy Exp $
*/
@@ -52,7 +52,7 @@
private ShaperAnalyticFitAlgorithm shaperFitter = new ShaperAnalyticFitAlgorithm();
private List<IHistogram1D> histos1D = new ArrayList<IHistogram1D>();
private List<IHistogram2D> histos2D = new ArrayList<IHistogram2D>();
- private List<IPlotter> plotters = new ArrayList<IPlotter>();
+ private List<IPlotter> plotters = new ArrayList<IPlotter>();
private Map<String, double[]> sensorToOccupancy = new HashMap<String, double[]>();
private Map<String, double[]> sensorToStereoOccupancy = new HashMap<String, double[]>();
BufferedWriter output = null;
@@ -62,7 +62,7 @@
int channelNumber = 0;
int plotterIndex = 0;
- int apvNumber = 0;
+ int apvNumber = 0;
double totalNumberEvents = 0;
double totalNumberOfRawHitEvents = 0;
double[] totalTopSamples = new double[6];
@@ -70,7 +70,7 @@
double[] topSamples = new double[6];
double[] bottomSamples = new double[6];
double totalNumberOfHits = 0;
-
+
double maxOccupancy = 1.0;
double maxOccupancyVariation = 1000; // %
@@ -79,10 +79,10 @@
// Plot flags
boolean enableADCvsChannel = false;
- boolean enableOccupancy = false;
+ boolean enableOccupancy = false;
boolean enableStereoHitOccupancy = false;
boolean enableChannelPlots = false;
- boolean enableAPVPlots = false;
+ boolean enableAPVPlots = false;
boolean enableChiSquaredvsChannel = false;
boolean enableSamples = false;
boolean enableT0Plots = false;
@@ -97,7 +97,7 @@
/**
* Default Ctor
*/
- public SvtQA(){
+ public SvtQA() {
}
//--- Setters ---//
@@ -105,132 +105,134 @@
/**
* Enable/disable occupancy plots
*/
- public void setEnableOccupancyPlots(boolean enableOccupancy){
+ public void setEnableOccupancyPlots(boolean enableOccupancy) {
this.enableOccupancy = enableOccupancy;
}
/**
* Enable/disable stereo hit occupancy plots
*/
- public void setEnableStereoHitOccupancyPlots(boolean enableStereoHitOccupancy){
+ public void setEnableStereoHitOccupancyPlots(boolean enableStereoHitOccupancy) {
this.enableStereoHitOccupancy = enableStereoHitOccupancy;
}
/**
- * Enable/disable ADC counts vs Channel plots
+ * Enable/disable ADC counts vs Channel plots
*/
- public void setEnableADCvsChannelPlots(boolean enableADCvsChannel){
+ public void setEnableADCvsChannelPlots(boolean enableADCvsChannel) {
this.enableADCvsChannel = enableADCvsChannel;
}
/**
* Enable/disable Channel Plots
*/
- public void setEnableChannelPlots(boolean enableChannelPlots){
+ public void setEnableChannelPlots(boolean enableChannelPlots) {
this.enableChannelPlots = enableChannelPlots;
}
/**
- * Enable/disable plots associated with individual APVs
+ * Enable/disable plots associated with individual APVs
*/
- public void setEnableAPVPlots(boolean enableAPVPlots){
+ public void setEnableAPVPlots(boolean enableAPVPlots) {
this.enableAPVPlots = enableAPVPlots;
}
/**
- * Enable/disable Chi Squared of fit to samples vs Channel plots
+ * Enable/disable Chi Squared of fit to samples vs Channel plots
*/
- public void setEnableChiSquaredvsChannelPlots(boolean enableChiSquaredvsChannel){
+ public void setEnableChiSquaredvsChannelPlots(boolean enableChiSquaredvsChannel) {
this.enableChiSquaredvsChannel = enableChiSquaredvsChannel;
}
/**
* Enable/disable plots of the APV samples
*/
- public void setEnableSamplesPlots(boolean enableSamples){
+ public void setEnableSamplesPlots(boolean enableSamples) {
this.enableSamples = enableSamples;
}
/**
- * Enable/disable t0 plots
+ * Enable/disable t0 plots
*/
- public void setEnableT0Plots(boolean enableT0Plots){
+ public void setEnableT0Plots(boolean enableT0Plots) {
this.enableT0Plots = enableT0Plots;
}
/**
- * Set the channel number of interest
+ * Set the channel number of interest
*/
- public void setChannelNumber(int channelNumber){
+ public void setChannelNumber(int channelNumber) {
this.channelNumber = channelNumber;
}
/**
- * Set the sensor of interest
+ * Set the sensor of interest
*/
- public void setSensorName(String sensorName){
+ public void setSensorName(String sensorName) {
this.sensorName = sensorName;
}
/**
* Set the APV number of interest
*/
- public void setApvNumber(int apvNumber){
+ public void setApvNumber(int apvNumber) {
this.apvNumber = apvNumber;
}
/**
- * Set the maximum occupancy a channel may have
+ * Set the maximum occupancy a channel may have
*/
- public void setMaxOccupancy(double maxOccupancy){
+ public void setMaxOccupancy(double maxOccupancy) {
this.maxOccupancy = maxOccupancy;
}
/**
* Set the maximum channel to channel occupancy variation
*/
- public void setMaxOccupancyVariation(double maxOccupancyVariation){
+ public void setMaxOccupancyVariation(double maxOccupancyVariation) {
this.maxOccupancyVariation = maxOccupancyVariation;
}
/**
- *
+ *
*/
- public void setOutputFileName(String outputFile){
+ public void setOutputFileName(String outputFile) {
this.outputFile = outputFile;
}
/**
*
*/
- public void setVerbose(boolean verbose){
+ public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
/**
*
*/
- public void setSimulation(boolean simulation){
+ public void setSimulation(boolean simulation) {
this.simulation = simulation;
}
-
+
/**
- *
+ *
*/
- public void setEnableTotalNumberOfHitsPlots(boolean enableTotalNumberOfHitsPlots){
- this.enableTotalNumberOfHitsPlots = enableTotalNumberOfHitsPlots;
+ public void setEnableTotalNumberOfHitsPlots(boolean enableTotalNumberOfHitsPlots) {
+ this.enableTotalNumberOfHitsPlots = enableTotalNumberOfHitsPlots;
}
/**
- *
+ *
*/
- private int getAPVNumber(int physicalChannel){
- int apv = (int) Math.floor((physicalChannel - TOTAL_STRIPS_PER_SENSOR)/-128);
- if(apv > 4 || apv < 0) throw new RuntimeException("Invalid APV Number: " + apv );
+ private int getAPVNumber(int physicalChannel) {
+ int apv = (int) Math.floor((physicalChannel - TOTAL_STRIPS_PER_SENSOR) / -128);
+ if (apv > 4 || apv < 0) {
+ throw new RuntimeException("Invalid APV Number: " + apv);
+ }
return apv;
- }
+ }
- protected void detectorChanged(Detector detector){
+ protected void detectorChanged(Detector detector) {
super.detectorChanged(detector);
// setup AIDA
@@ -246,9 +248,9 @@
//--- Occupancy ---//
//-----------------//
- if(enableOccupancy){
+ if (enableOccupancy) {
plotters.add(PlotUtils.setupPlotter("Occupancy", 5, 4));
- for(SiSensor sensor : sensors){
+ for (SiSensor sensor : sensors) {
sensorToOccupancy.put(SvtUtils.getInstance().getDescription(sensor), new double[640]);
title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
histo1D = aida.histogram1D(title, 640, 0, 639);
@@ -260,9 +262,9 @@
//--- Stereo Hit Occupancy ---//
//----------------------------//
- if(enableStereoHitOccupancy){
+ if (enableStereoHitOccupancy) {
plotters.add(PlotUtils.setupPlotter("Stereo Hit Occupancy", 5, 4));
- for(SiSensor sensor : sensors){
+ for (SiSensor sensor : sensors) {
sensorToStereoOccupancy.put(SvtUtils.getInstance().getDescription(sensor), new double[640]);
title = SvtUtils.getInstance().getDescription(sensor) + " - Stereo Hit Occupancy";
histo1D = aida.histogram1D(title, 640, 0, 639);
@@ -274,17 +276,17 @@
//--- ADC Counts vs Channel ---//
//-----------------------------//
- if(enableADCvsChannel){
- if(sensorName.equals("all")){
+ if (enableADCvsChannel) {
+ if (sensorName.equals("all")) {
plotters.add(PlotUtils.setupPlotter("ADC Counts vs Channel #", 5, 4));
- for(SiSensor sensor : sensors){
+ for (SiSensor sensor : sensors) {
title = SvtUtils.getInstance().getDescription(sensor) + " - ADC Counts vs Channel #";
histo2D = aida.histogram2D(title, 640, 0, 639, 300, 0, 10000);
histos2D.add(histo2D);
PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, PlotUtils.getPlotterRegion(sensor), "Channel #", "ADC Counts", histo2D);
}
plotterIndex++;
- } else if(sensorName != null){
+ } else if (sensorName != null) {
title = sensorName + " - ADC Counts vs Channel #";
plotters.add(PlotUtils.setupPlotter(title, 0, 0));
histo2D = aida.histogram2D(title, 640, 0, 639, 300, 0, 10000);
@@ -298,7 +300,7 @@
//--- Chi Squared vs Channel ---//
//------------------------------//
- if(enableChiSquaredvsChannel){
+ if (enableChiSquaredvsChannel) {
title = sensorName + " - Chi Squared vs Channel #";
plotters.add(PlotUtils.setupPlotter(title, 0, 0));
histo2D = aida.histogram2D(title, 640, 0, 639, 300, 0, 100);
@@ -307,17 +309,18 @@
plotterIndex++;
}
-
//--- Single Channel Plots ---//
//----------------------------//
- if(enableChannelPlots){
- if(sensorName == null) throw new RuntimeException("Sensor of interest is not set!");
+ if (enableChannelPlots) {
+ if (sensorName == null) {
+ throw new RuntimeException("Sensor of interest is not set!");
+ }
title = sensorName + " - Channel: " + channelNumber;
plotters.add(PlotUtils.setupPlotter(title, 2, 2));
title = "ADC Counts";
histo1D = aida.histogram1D(title, 300, 4000, 7000);
histos1D.add(histo1D);
- PlotUtils.setup1DRegion(plotters.get(plotterIndex),title , 0, "ADC Counts", histo1D);
+ PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 0, "ADC Counts", histo1D);
title = "Shaper Signal Amplitude";
histo1D = aida.histogram1D(title, 300, 0, 3000);
histos1D.add(histo1D);
@@ -331,14 +334,16 @@
//--- APV Plots ---//
//-----------------//
- if(enableAPVPlots){
- if(sensorName == null) throw new RuntimeException("Sensor of interest is not set!");
+ if (enableAPVPlots) {
+ if (sensorName == null) {
+ throw new RuntimeException("Sensor of interest is not set!");
+ }
title = sensorName + " - APV " + apvNumber;
plotters.add(PlotUtils.setupPlotter(title, 2, 2));
title = "APV " + apvNumber + " - ADC Counts";
histo1D = aida.histogram1D(title, 400, 0, 10000);
histos1D.add(histo1D);
- PlotUtils.setup1DRegion(plotters.get(plotterIndex),title , 0, "ADC Counts", histo1D);
+ PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 0, "ADC Counts", histo1D);
title = "APV " + apvNumber + " - Shaper Signal Amplitude";
histo1D = aida.histogram1D(title, 300, 0, 6000);
histos1D.add(histo1D);
@@ -351,12 +356,12 @@
histo2D = aida.histogram2D(title, 300, 0, 6000, 100, -100, 100);
histos2D.add(histo2D);
PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, 3, "Amplitude [ADC Counts]", "t0 [ns]", histo2D);
- plotterIndex++;
+ plotterIndex++;
}
//--- Samples Amplitude vs Sample Number ---//
//------------------------------------------//
- if(enableSamples){
+ if (enableSamples) {
title = "APV Sample Number vs Sample Amplitude";
plotters.add(PlotUtils.setupPlotter(title, 1, 2));
plotters.get(plotterIndex).style().zAxisStyle().setParameter("scale", "log");
@@ -373,19 +378,18 @@
//--- t0 Plots ---//
//----------------//
- if(enableT0Plots){
- if(sensorName.equals("all")){
+ if (enableT0Plots) {
+ if (sensorName.equals("all")) {
plotters.add(PlotUtils.setupPlotter("t0 Resolution vs Channel #", 5, 4));
plotters.get(plotterIndex).style().zAxisStyle().setParameter("scale", "log");
- for(SiSensor sensor : sensors){
+ for (SiSensor sensor : sensors) {
title = SvtUtils.getInstance().getDescription(sensor) + " - t0 Resolution vs Channel #";
histo2D = aida.histogram2D(title, 640, 0, 639, 40, -20, 20);
histos2D.add(histo2D);
PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, PlotUtils.getPlotterRegion(sensor), "Channel #", "t0 Resolution [ns]", histo2D);
}
plotterIndex++;
- }
- else if(sensorName != null){
+ } else if (sensorName != null) {
title = sensorName + " - Hit Time Resolution";
plotters.add(PlotUtils.setupPlotter(title, 0, 0));
plotters.get(plotterIndex).style().statisticsBoxStyle().setVisible(true);
@@ -393,33 +397,36 @@
histos1D.add(histo1D);
PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 0, "<Hit Time> - Hit Time [ns]", histo1D);
plotterIndex++;
+ } else {
+ throw new RuntimeException("Sensor of interest not set!");
}
- else throw new RuntimeException("Sensor of interest not set!");
}
-
- if(enableTotalNumberOfHitsPlots){
- title = "Total Number of RawTrackerHits";
- plotters.add(PlotUtils.setupPlotter(title, 0, 0));
- plotters.get(plotterIndex).style().statisticsBoxStyle().setVisible(true);
- histo1D = aida.histogram1D(title, 100, 0, 75);
- histos1D.add(histo1D);
- PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 0, "Number of RawTrackerHits", histo1D);
- plotterIndex++;
+
+ if (enableTotalNumberOfHitsPlots) {
+ title = "Total Number of RawTrackerHits";
+ plotters.add(PlotUtils.setupPlotter(title, 0, 0));
+ plotters.get(plotterIndex).style().statisticsBoxStyle().setVisible(true);
+ histo1D = aida.histogram1D(title, 100, 0, 75);
+ histos1D.add(histo1D);
+ PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 0, "Number of RawTrackerHits", histo1D);
+ plotterIndex++;
}
- for(IPlotter plotter : plotters) plotter.show();
-
+ for (IPlotter plotter : plotters) {
+ plotter.show();
+ }
+
}
/**
- *
+ *
*/
- public int findPeakSamples(short[] samples){
+ public int findPeakSamples(short[] samples) {
int maxSample = 0;
int maxSampleIndex = 0;
- for(int index = 0; index < samples.length; index++){
- if(maxSample < samples[index]){
+ for (int index = 0; index < samples.length; index++) {
+ if (maxSample < samples[index]) {
maxSample = samples[index];
maxSampleIndex = index;
}
@@ -427,31 +434,30 @@
return maxSampleIndex;
}
+ public void process(EventHeader event) {
-
- public void process(EventHeader event){
-
totalNumberEvents++;
String title;
// If the event doesn't contain RawTrackerHits then skip it
- if(!event.hasCollection(RawTrackerHit.class, rawHitCollectionName )){
- if(verbose) System.out.println("Event doesn't contain RawTrackerHits! Skipping event ...");
+ if (!event.hasCollection(RawTrackerHit.class, rawHitCollectionName)) {
+ if (verbose) {
+ System.out.println("Event doesn't contain RawTrackerHits! Skipping event ...");
+ }
return;
}
// Get the RawTrackerHits from the event
List<RawTrackerHit> rawHits = event.get(RawTrackerHit.class, rawHitCollectionName);
-
+
// Get the total number of RawTrackerHits in the event
- if(enableTotalNumberOfHitsPlots && rawHits.size() != 0){
+ if (enableTotalNumberOfHitsPlots && rawHits.size() != 0) {
aida.histogram1D("Total Number of RawTrackerHits").fill(rawHits.size());
}
SiSensor sensor = null;
ChannelConstants constants = null;
- ShapeFitParameters fit = null;
- for(RawTrackerHit rawHit : rawHits){
+ for (RawTrackerHit rawHit : rawHits) {
// Get the sensor on which this hit occurred
sensor = (SiSensor) rawHit.getDetectorElement();
@@ -469,81 +475,81 @@
constants = HPSSVTCalibrationConstants.getChannelConstants(sensor, channel);
// Fit the samples associated with the RawTrackerHit
- fit = shaperFitter.fitShape(rawHit, constants);
+ for (ShapeFitParameters fit : shaperFitter.fitShape(rawHit, constants)) {
- // Fill the occupancy plots
- if(enableOccupancy){
- title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
- aida.histogram1D(title).fill(channel, 1);
- }
+ // Fill the occupancy plots
+ if (enableOccupancy) {
+ title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
+ aida.histogram1D(title).fill(channel, 1);
+ }
- // Fill ADC vs Channel # plots
- if(enableADCvsChannel && sensorName.equals("all")){
- title = SvtUtils.getInstance().getDescription(sensor) + " - ADC Counts vs Channel #";
- for(short sample : samples){
- aida.histogram2D(title).fill(channel, sample);
+ // Fill ADC vs Channel # plots
+ if (enableADCvsChannel && sensorName.equals("all")) {
+ title = SvtUtils.getInstance().getDescription(sensor) + " - ADC Counts vs Channel #";
+ for (short sample : samples) {
+ aida.histogram2D(title).fill(channel, sample);
+ }
+ } else if (enableADCvsChannel && SvtUtils.getInstance().getDescription(sensor).equals(sensorName)) {
+ title = sensorName + " - ADC Counts vs Channel #";
+ for (short sample : samples) {
+ aida.histogram2D(title).fill(channel, sample);
+ }
}
- } else if(enableADCvsChannel && SvtUtils.getInstance().getDescription(sensor).equals(sensorName)){
- title = sensorName + " - ADC Counts vs Channel #";
- for(short sample : samples){
- aida.histogram2D(title).fill(channel, sample);
- }
- }
- //
- if(enableChannelPlots && SvtUtils.getInstance().getDescription(sensor).equals(sensorName) && channel == channelNumber){
- title = "ADC Counts";
- for(short sample : samples){
- aida.histogram1D(title).fill(sample);
+ //
+ if (enableChannelPlots && SvtUtils.getInstance().getDescription(sensor).equals(sensorName) && channel == channelNumber) {
+ title = "ADC Counts";
+ for (short sample : samples) {
+ aida.histogram1D(title).fill(sample);
+ }
+ title = "Shaper Signal Amplitude";
+ aida.histogram1D(title).fill(fit.getAmp());
+ System.out.println("Amplitude: " + fit.getAmp());
+ title = "t0";
+ aida.histogram1D(title).fill(fit.getT0());
+ System.out.println("t0 " + fit.getT0());
}
- title = "Shaper Signal Amplitude";
- aida.histogram1D(title).fill(fit.getAmp());
- System.out.println("Amplitude: " + fit.getAmp());
- title="t0";
- aida.histogram1D(title).fill(fit.getT0());
- System.out.println("t0 " + fit.getT0());
- }
- if(enableAPVPlots && SvtUtils.getInstance().getDescription(sensor).equals(sensorName) && apv == apvNumber ){
- title = "APV " + apvNumber + " - ADC Counts";
- for(short sample : samples){
- aida.histogram1D(title).fill(sample);
+ if (enableAPVPlots && SvtUtils.getInstance().getDescription(sensor).equals(sensorName) && apv == apvNumber) {
+ title = "APV " + apvNumber + " - ADC Counts";
+ for (short sample : samples) {
+ aida.histogram1D(title).fill(sample);
+ }
+ title = "APV " + apvNumber + " - Shaper Signal Amplitude";
+ aida.histogram1D(title).fill(fit.getAmp());
+ title = "APV " + apvNumber + " - t0";
+ aida.histogram1D(title).fill(fit.getT0());
+ title = "APV " + apvNumber + " - Amplitude vs t0";
+ aida.histogram2D(title).fill(fit.getAmp(), fit.getT0());
}
- title = "APV " + apvNumber + " - Shaper Signal Amplitude";
- aida.histogram1D(title).fill(fit.getAmp());
- title = "APV " + apvNumber + " - t0";
- aida.histogram1D(title).fill(fit.getT0());
- title = "APV " + apvNumber + " - Amplitude vs t0";
- aida.histogram2D(title).fill(fit.getAmp(), fit.getT0());
}
}
/*
- if(enableOccupancy){
- for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
- title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
- aida.histogram1D(title).reset();
- int nEvents = simulation ? SvtReadout.getNumberOfTriggers() : totalNumberEvents;
- for(int index = 0; index < 640; index++){
- aida.histogram1D(title).fill(index, sensorToOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[index]/nEvents);
- }
+ if(enableOccupancy){
+ for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
+ title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
+ aida.histogram1D(title).reset();
+ int nEvents = simulation ? SvtReadout.getNumberOfTriggers() : totalNumberEvents;
+ for(int index = 0; index < 640; index++){
+ aida.histogram1D(title).fill(index, sensorToOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[index]/nEvents);
+ }
+ }
+ }*/
+ // If the event doesn't contain FittedRawTrackerHits then skip it
+ if (!event.hasCollection(FittedRawTrackerHit.class, fittedHitCollectionName)) {
+ if (verbose) {
+ System.out.println("Event doesn't contain FittedRawTrackerHits! Skipping event ...");
}
- }*/
-
- // If the event doesn't contain FittedRawTrackerHits then skip it
- if(!event.hasCollection(FittedRawTrackerHit.class, fittedHitCollectionName)){
- if(verbose) System.out.println("Event doesn't contain FittedRawTrackerHits! Skipping event ...");
return;
}
// Get the RawTrackerHits from the event
List<FittedRawTrackerHit> fittedHits = event.get(FittedRawTrackerHit.class, fittedHitCollectionName);
-
+
//System.out.println(this.getClass().getSimpleName() + ": Number of FittedRawTrackerHits " + fittedHits.size());
+ for (FittedRawTrackerHit fittedHit : fittedHits) {
- for(FittedRawTrackerHit fittedHit : fittedHits){
-
-
// Get the channel number
int channel = fittedHit.getRawTrackerHit().getIdentifierFieldValue("strip");
@@ -551,26 +557,28 @@
sensor = (SiSensor) fittedHit.getRawTrackerHit().getDetectorElement();
// Fill Chi Squared vs Channel # plots
- if(enableChiSquaredvsChannel && SvtUtils.getInstance().getDescription(sensor).equals(sensorName)){
+ if (enableChiSquaredvsChannel && SvtUtils.getInstance().getDescription(sensor).equals(sensorName)) {
title = sensorName + " - Chi Squared vs Channel #";
aida.histogram2D(title).fill(channel, fittedHit.getShapeFitParameters().getChiSq());
}
}
// If the event does not contain stereo hits, skip the event
- if(!event.hasCollection(HelicalTrackHit.class, stereoHitCollectionName)){
- if(verbose) System.out.println("Event doesn't contain HelicalTrackHits! Skipping event ...");
+ if (!event.hasCollection(HelicalTrackHit.class, stereoHitCollectionName)) {
+ if (verbose) {
+ System.out.println("Event doesn't contain HelicalTrackHits! Skipping event ...");
+ }
return;
}
// Get the list of HelicalTrackHits
- List<HelicalTrackHit> stereoHits =event.get(HelicalTrackHit.class, stereoHitCollectionName);
+ List<HelicalTrackHit> stereoHits = event.get(HelicalTrackHit.class, stereoHitCollectionName);
- for(HelicalTrackHit stereoHit : stereoHits){
+ for (HelicalTrackHit stereoHit : stereoHits) {
double totalT0 = 0;
- for(Object hit : stereoHit.getRawHits()){
+ for (Object hit : stereoHit.getRawHits()) {
RawTrackerHit rawHit = (RawTrackerHit) hit;
@@ -583,31 +591,33 @@
constants = HPSSVTCalibrationConstants.getChannelConstants(sensor, channel);
// Fit the samples associated with the RawTrackerHit
- fit = shaperFitter.fitShape(rawHit, constants);
+ for (ShapeFitParameters fit : shaperFitter.fitShape(rawHit, constants)) {
- // Get the shaper signal samples
- short[] samples = rawHit.getADCValues();
+ // Get the shaper signal samples
+ short[] samples = rawHit.getADCValues();
- if(enableStereoHitOccupancy){
- title = SvtUtils.getInstance().getDescription(sensor) + " - Stereo Hit Occupancy";
- sensorToStereoOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[channel] += 1;
- }
+ if (enableStereoHitOccupancy) {
+ title = SvtUtils.getInstance().getDescription(sensor) + " - Stereo Hit Occupancy";
+ sensorToStereoOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[channel] += 1;
+ }
- // Fill Sample Plots
- if(enableSamples){
- if(fit.getAmp() > 2000 && fit.getAmp() < 6000){
- for(int sampleN = 1; sampleN <= samples.length; sampleN++){
- if((sampleN == 1 && totalNumberEvents%5 != 0) || (sampleN == 2 && totalNumberEvents%5 != 0)/* || (sampleN == 3 && totalNumberEvents%3 != 0) */) continue;
- if(SvtUtils.getInstance().isTopLayer(sensor)){
- aida.histogram2D("APV Sample Number vs Sample Amplitude - Top").fill(sampleN, samples[sampleN-1] - constants.getPedestal());
- totalTopSamples[sampleN-1]++;
- topSamples[sampleN-1] += samples[sampleN-1] - constants.getPedestal();
+ // Fill Sample Plots
+ if (enableSamples) {
+ if (fit.getAmp() > 2000 && fit.getAmp() < 6000) {
+ for (int sampleN = 1; sampleN <= samples.length; sampleN++) {
+ if ((sampleN == 1 && totalNumberEvents % 5 != 0) || (sampleN == 2 && totalNumberEvents % 5 != 0)/* || (sampleN == 3 && totalNumberEvents%3 != 0) */) {
+ continue;
+ }
+ if (SvtUtils.getInstance().isTopLayer(sensor)) {
+ aida.histogram2D("APV Sample Number vs Sample Amplitude - Top").fill(sampleN, samples[sampleN - 1] - constants.getPedestal());
+ totalTopSamples[sampleN - 1]++;
+ topSamples[sampleN - 1] += samples[sampleN - 1] - constants.getPedestal();
+ } else {
+ aida.histogram2D("APV Sample Number vs Sample Amplitude - Bottom").fill(sampleN, samples[sampleN - 1] - constants.getPedestal());
+ totalBottomSamples[sampleN - 1]++;
+ bottomSamples[sampleN - 1] += samples[sampleN - 1] - constants.getPedestal();
+ }
}
- else{
- aida.histogram2D("APV Sample Number vs Sample Amplitude - Bottom").fill(sampleN, samples[sampleN-1] - constants.getPedestal());
- totalBottomSamples[sampleN-1]++;
- bottomSamples[sampleN-1] += samples[sampleN - 1] - constants.getPedestal();
- }
}
}
}
@@ -615,66 +625,67 @@
}
/*
- if(enableStereoHitOccupancy){
- for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
- title = SvtUtils.getInstance().getDescription(sensor) + " - Stereo Hit Occupancy";
- aida.histogram1D(title).reset();
- for(int index = 0; index < 640; index++){
- aida.histogram1D(title).fill(index, sensorToStereoOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[index]/event.getEventNumber());
- }
- }
- }*/
- if(!event.hasCollection(Track.class, trackCollectionName)) return;
-
+ if(enableStereoHitOccupancy){
+ for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
+ title = SvtUtils.getInstance().getDescription(sensor) + " - Stereo Hit Occupancy";
+ aida.histogram1D(title).reset();
+ for(int index = 0; index < 640; index++){
+ aida.histogram1D(title).fill(index, sensorToStereoOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[index]/event.getEventNumber());
+ }
+ }
+ }*/
+ if (!event.hasCollection(Track.class, trackCollectionName)) {
+ return;
+ }
+
// Get the list of tracks in the event
List<SeedTrack> tracks = event.get(SeedTrack.class, trackCollectionName);
- if(enableT0Plots){
+ if (enableT0Plots) {
// Loop over all tracks in the event
- for(Track track : tracks){
+ for (Track track : tracks) {
-
double totalT0 = 0;
double totalHits = 0;
// Loop over all stereo hits comprising a track
- for(TrackerHit crossHit : track.getTrackerHits()){
+ for (TrackerHit crossHit : track.getTrackerHits()) {
HelicalTrackCross htc = (HelicalTrackCross) crossHit;
- for(HelicalTrackStrip hts : htc.getStrips()){
+ for (HelicalTrackStrip hts : htc.getStrips()) {
totalT0 += hts.time();
totalHits++;
}
}
- double meanT0 = totalT0/totalHits;
+ double meanT0 = totalT0 / totalHits;
- for(TrackerHit crossHit : track.getTrackerHits()){
+ for (TrackerHit crossHit : track.getTrackerHits()) {
HelicalTrackCross htc = (HelicalTrackCross) crossHit;
- for(HelicalTrackStrip hts : htc.getStrips()){
+ for (HelicalTrackStrip hts : htc.getStrips()) {
//SiSensor sensor = null;
- if(TrackUtils.getZ0(track) > 0){
+ if (TrackUtils.getZ0(track) > 0) {
sensor = SvtUtils.getInstance().getSensor(0, hts.layer() - 1);
- } else if(TrackUtils.getZ0(track) < 0){
+ } else if (TrackUtils.getZ0(track) < 0) {
sensor = SvtUtils.getInstance().getSensor(1, hts.layer() - 1);
}
int channel = ((RawTrackerHit) hts.rawhits().get(0)).getIdentifierFieldValue("strip");
-
- if(sensorName.equals("all")){
- aida.histogram2D(SvtUtils.getInstance().getDescription(sensor) + " - t0 Resolution vs Channel #").fill(channel, meanT0 - hts.time());
+
+ if (sensorName.equals("all")) {
+ aida.histogram2D(SvtUtils.getInstance().getDescription(sensor) + " - t0 Resolution vs Channel #").fill(channel, meanT0 - hts.time());
} else {
- if(SvtUtils.getInstance().getDescription(sensor).equals(sensorName)){
- aida.histogram1D(sensorName + " - Hit Time Resolution").fill(meanT0 - hts.time());
+ if (SvtUtils.getInstance().getDescription(sensor).equals(sensorName)) {
+ aida.histogram1D(sensorName + " - Hit Time Resolution").fill(meanT0 - hts.time());
+ }
+
}
-
- }
}
}
}
@@ -683,165 +694,175 @@
}
@Override
- public void endOfData(){
- String title;
-
+ public void endOfData() {
+ String title;
-
- String plotName;
- if(enableOccupancy){
- for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
- title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
- // Scale the hits per channel by the number of events
- aida.histogram1D(title).scale(1/totalNumberEvents);
-
- // Write the occupancies to a file
- if(SvtUtils.getInstance().isTopLayer(sensor)){
- plotName = outputFile + "_top_";
- } else {
- plotName = outputFile + "_bottom_";
- }
-
- if(SvtUtils.getInstance().getLayerNumber(sensor) < 10){
- plotName += "0" + SvtUtils.getInstance().getLayerNumber(sensor) + ".dat";
- } else {
- plotName += SvtUtils.getInstance().getLayerNumber(sensor) + ".dat";
- }
-
- // Open the output files stream
- if(plotName != null){
- try{
- output = new BufferedWriter(new FileWriter(plotName));
- for(int channel = 0; channel < 640; channel++){
- output.write(channel + " " + aida.histogram1D(title).binHeight(channel) + "\n");
- }
- output.close();
- } catch(Exception e) {
- System.out.println(this.getClass().getSimpleName() + " :Error! " + e.getMessage());
- }
- }
- }
- }
-
- if(enableT0Plots){
- int bins = aida.histogram1D(sensorName + " - Hit Time Resolution").axis().bins();
- for(int bin = 0; bin < bins; bin++){
- System.out.println(bin + " " + aida.histogram1D(sensorName + " - Hit Time Resolution").binHeight(bin));
- }
- }
-
- System.out.println("Total Bad Channels: " + HPSSVTCalibrationConstants.getTotalBadChannels() + "\n");
-
- /*
- for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
- if(outputFile != null && sensorName.equals(SvtUtils.getInstance().getDescription(sensor))){
- try{
- for(int channel = 0; channel < 639; channel++){
- output.write(channel + " " + this.getOccupancy(sensor, channel) + "\n");
- }
- output.close();
- } catch(IOException e){
- System.out.println(this.getClass().getSimpleName() + ": Error! " + e.getMessage());
- }
- }
-
- System.out.println("%===================================================================%");
- System.out.println(SvtUtils.getInstance().getDescription(sensor) + " Bad Channels");
- System.out.println("%===================================================================%");
- for(int index = 0; index < 640; index++){
+ String plotName;
+ if (enableOccupancy) {
+ for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
+ title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy";
+ // Scale the hits per channel by the number of events
+ aida.histogram1D(title).scale(1 / totalNumberEvents);
- // Check is the channel can be considered bad
- this.checkChannel(sensor, index);
- }
+ // Write the occupancies to a file
+ if (SvtUtils.getInstance().isTopLayer(sensor)) {
+ plotName = outputFile + "_top_";
+ } else {
+ plotName = outputFile + "_bottom_";
}
- System.out.println("%===================================================================% \n");
- }*/
- if(enableStereoHitOccupancy){
- for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
- System.out.println("%===================================================================% \n");
- System.out.println(SvtUtils.getInstance().getDescription(sensor) + " Bad Channels");
- System.out.println("%===================================================================% \n");
- for(int index = 0; index < 640; index++){
- // Check is the channel can be considered bad
- this.checkChannel(sensor, index);
+ if (SvtUtils.getInstance().getLayerNumber(sensor) < 10) {
+ plotName += "0" + SvtUtils.getInstance().getLayerNumber(sensor) + ".dat";
+ } else {
+ plotName += SvtUtils.getInstance().getLayerNumber(sensor) + ".dat";
+ }
+
+ // Open the output files stream
+ if (plotName != null) {
+ try {
+ output = new BufferedWriter(new FileWriter(plotName));
+ for (int channel = 0; channel < 640; channel++) {
+ output.write(channel + " " + aida.histogram1D(title).binHeight(channel) + "\n");
+ }
+ output.close();
+ } catch (Exception e) {
+ System.out.println(this.getClass().getSimpleName() + " :Error! " + e.getMessage());
}
- System.out.println("%===================================================================% \n");
}
}
+ }
- if(outputFile != null){
- try{
- aida.saveAs(outputFile);
- } catch(IOException exeption){
- System.out.println("File " + outputFile + " was not found!");
- }
+ if (enableT0Plots) {
+ int bins = aida.histogram1D(sensorName + " - Hit Time Resolution").axis().bins();
+ for (int bin = 0; bin < bins; bin++) {
+ System.out.println(bin + " " + aida.histogram1D(sensorName + " - Hit Time Resolution").binHeight(bin));
}
-
- if(enableSamples){
- double sigma = 0;
- double[] topMean = new double[6];
- double[] bottomMean = new double[6];
-
+ }
+
+ System.out.println("Total Bad Channels: " + HPSSVTCalibrationConstants.getTotalBadChannels() + "\n");
+
+ /*
+ for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
+ if(outputFile != null && sensorName.equals(SvtUtils.getInstance().getDescription(sensor))){
+ try{
+ for(int channel = 0; channel < 639; channel++){
+ output.write(channel + " " + this.getOccupancy(sensor, channel) + "\n");
+ }
+ output.close();
+ } catch(IOException e){
+ System.out.println(this.getClass().getSimpleName() + ": Error! " + e.getMessage());
+ }
+ }
+
+ System.out.println("%===================================================================%");
+ System.out.println(SvtUtils.getInstance().getDescription(sensor) + " Bad Channels");
+ System.out.println("%===================================================================%");
+ for(int index = 0; index < 640; index++){
+
+ // Check is the channel can be considered bad
+ this.checkChannel(sensor, index);
+ }
+ }
+ System.out.println("%===================================================================% \n");
+ }*/
+ if (enableStereoHitOccupancy) {
+ for (SiSensor sensor : SvtUtils.getInstance().getSensors()) {
System.out.println("%===================================================================% \n");
- for(int index = 0; index < topSamples.length; index++){
- topMean[index] = topSamples[index]/totalTopSamples[index];
- System.out.println("Top sample " + index + " mean: " + topMean[index]);
- }
-
- System.out.println("\n%===================================================================% \n");
- for(int index = 0; index < bottomSamples.length; index++){
- bottomMean[index] = bottomSamples[index]/totalBottomSamples[index];
- System.out.println("Bottom sample " + index + " mean: " + bottomMean[index]);
- }
- System.out.println("\n%===================================================================% \n");
+ System.out.println(SvtUtils.getInstance().getDescription(sensor) + " Bad Channels");
+ System.out.println("%===================================================================% \n");
+ for (int index = 0; index < 640; index++) {
+ // Check is the channel can be considered bad
+ this.checkChannel(sensor, index);
+ }
+ System.out.println("%===================================================================% \n");
}
}
- public double getOccupancy(SiSensor sensor, int channel){
- if(!enableOccupancy) throw new RuntimeException("Occupancy calculation was not enabled!");
- double nEvents = simulation ? SvtReadout.getNumberOfTriggers() : totalNumberEvents;
- return sensorToOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[channel]/nEvents;
+ if (outputFile != null) {
+ try {
+ aida.saveAs(outputFile);
+ } catch (IOException exeption) {
+ System.out.println("File " + outputFile + " was not found!");
+ }
+ }
+
+ if (enableSamples) {
+ double sigma = 0;
+ double[] topMean = new double[6];
+ double[] bottomMean = new double[6];
+
+ System.out.println("%===================================================================% \n");
+ for (int index = 0; index < topSamples.length; index++) {
+ topMean[index] = topSamples[index] / totalTopSamples[index];
+ System.out.println("Top sample " + index + " mean: " + topMean[index]);
+ }
+
+ System.out.println("\n%===================================================================% \n");
+ for (int index = 0; index < bottomSamples.length; index++) {
+ bottomMean[index] = bottomSamples[index] / totalBottomSamples[index];
+ System.out.println("Bottom sample " + index + " mean: " + bottomMean[index]);
[truncated at 1000 lines; 89 more skipped]
SVNspam 0.1