Commit in hps-java/src/main/java/org/lcsim/hps/users/phansson on MAIN | |||
TriggerTurnOnAnalysis.java | +39 | -14 | 1.2 -> 1.3 |
TruthMomentumResolutionDriver.java | +140 | -52 | 1.1 -> 1.2 |
+179 | -66 |
Updated with new plots for analysis classes.
diff -u -r1.2 -r1.3 --- TriggerTurnOnAnalysis.java 2 Oct 2012 22:48:30 -0000 1.2 +++ TriggerTurnOnAnalysis.java 12 Oct 2012 05:55:55 -0000 1.3 @@ -29,7 +29,6 @@
private boolean _DEBUG = false; private String ecalClusterCollectionName = "EcalTriggerClusters"; private String triggerDataCollectionName = "TriggerStatus";
- private String outputPlotFileName = "trigturnonanalysis.aida";
private int totalEvents = 0;
@@ -54,6 +53,8 @@
private IHistogram2D hTrigThetayvsThetay; private IHistogram2D hele1vsele2;
+ private boolean _hideFrame = false; + private String _aidaFileName = "trigturnonanalysis.aida";
private AIDA aida = AIDA.defaultInstance(); private IAnalysisFactory af = aida.analysisFactory(); IHistogramFactory hf = aida.histogramFactory();
@@ -65,6 +66,15 @@
IPlotter plotter_count_11; IPlotter plotter_count_22;
+ + public void setHideFrame(boolean hide) { + this._hideFrame = hide; + } + + public void setAidaFileName(String filename) { + this._aidaFileName = filename; + } +
@Override public void detectorChanged(Detector detector) {
@@ -201,7 +211,7 @@
}
- if(totalEvents % 500 == 0) updatePlots();
+ if(totalEvents % 500 == 0 && !this._hideFrame) updatePlots(); //plots are updated at end of data anyway
totalEvents++; }
@@ -226,12 +236,23 @@
@Override public void endOfData() { updatePlots();
- if (!"".equals(outputPlotFileName))
+ if (!"".equals(this._aidaFileName))
try {
- aida.saveAs(outputPlotFileName);
+ aida.saveAs(this._aidaFileName);
} catch (IOException ex) {
- Logger.getLogger(TrigRateDriver.class.getName()).log(Level.SEVERE, "Couldn't save aida plots to file " + outputPlotFileName, ex);
+ Logger.getLogger(TrigRateDriver.class.getName()).log(Level.SEVERE, "Couldn't save aida plots to file " + this._aidaFileName, ex);
+ }
+
+ if(this._hideFrame) {
+ plotter_count.hide();
+ plotter_count_1.hide();
+ plotter_count_11.hide();
+ plotter_count_2.hide();
+ plotter_count_22.hide();
+ plotter_count_3.hide();
+ plotter_count_4.hide();
}
+
}
@@ -267,7 +288,6 @@
plotter_count.region(1).plot(hThetayvsEAll); plotter_count.region(2).plot(hThetay); plotter_count.region(3).plot(hThetayAll);
- plotter_count.show();
plotter_count_1 = af.createPlotterFactory().create(); plotter_count_1.createRegions(2,2);
@@ -276,7 +296,6 @@
plotter_count_1.region(1).plot(hThetaySmallestEcut); plotter_count_1.region(2).plot(hTrigThetaySmallestEcut); plotter_count_1.region(3).style().statisticsBoxStyle().setVisible(false);
- plotter_count_1.show();
plotter_count_11 = af.createPlotterFactory().create(); plotter_count_11.createRegions(2,2);
@@ -286,7 +305,6 @@
plotter_count_11.region(1).plot(hThetayLargestEcut); plotter_count_11.region(2).plot(hTrigThetayLargestEcut); plotter_count_11.region(3).style().statisticsBoxStyle().setVisible(false);
- plotter_count_11.show();
plotter_count_2 = af.createPlotterFactory().create(); plotter_count_2.createRegions(2,2);
@@ -297,7 +315,6 @@
plotter_count_2.region(0).plot(hThetaySmallestvsE); plotter_count_2.region(1).plot(hTrigThetaySmallestvsE); plotter_count_2.region(2).style().statisticsBoxStyle().setVisible(false);
- plotter_count_2.show();
plotter_count_22 = af.createPlotterFactory().create(); plotter_count_22.createRegions(2,2);
@@ -308,9 +325,8 @@
plotter_count_22.region(0).plot(hThetayLargestvsE); plotter_count_22.region(1).plot(hTrigThetayLargestvsE); plotter_count_22.region(2).style().statisticsBoxStyle().setVisible(false);
- plotter_count_22.show(); - - IPlotter plotter_count_3 = af.createPlotterFactory().create();
+ + plotter_count_3 = af.createPlotterFactory().create();
plotter_count_3.createRegions(1,2); plotter_count_3.setTitle("Trigger Count"); //plotter_count.style().statisticsBoxStyle().setVisible(true);
@@ -318,7 +334,6 @@
plotter_count_3.style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); plotter_count_3.region(0).plot(hThetayvsThetay); plotter_count_3.region(1).plot(hTrigThetayvsThetay);
- plotter_count_3.show();
plotter_count_4 = af.createPlotterFactory().create();
@@ -329,7 +344,17 @@
plotter_count_4.style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); plotter_count_4.region(0).style().statisticsBoxStyle().setVisible(false); plotter_count_4.region(0).plot(hele1vsele2);
- plotter_count_4.show();
+ + if(!this._hideFrame) { + plotter_count.show(); + plotter_count_1.show(); + plotter_count_11.show(); + plotter_count_2.show(); + plotter_count_22.show(); + plotter_count_3.show(); + plotter_count_4.show(); + } +
}
diff -u -r1.1 -r1.2 --- TruthMomentumResolutionDriver.java 21 Sep 2012 18:36:34 -0000 1.1 +++ TruthMomentumResolutionDriver.java 12 Oct 2012 05:55:55 -0000 1.2 @@ -32,16 +32,21 @@
IAnalysisFactory af = aida.analysisFactory(); IPlotter pPlotter; IPlotter pPlotter2;
+ IPlotter pPlotter22;
IPlotter pPlotter3;
- ICloud1D hElectronP; - ICloud1D hPositronP; - ICloud1D hTrackP; - ICloud1D hPosTrackP; - ICloud1D hTruthMatchedPosTrackP; - ICloud1D hTruthMatchedPosTrackPdiff; - ICloud1D hNegTrackP; - ICloud1D hTruthMatchedNegTrackP; - ICloud1D hTruthMatchedNegTrackPdiff;
+ IHistogram1D hElectronP; + IHistogram1D hPositronP; + IHistogram1D hTrackP; + IHistogram1D hPosTrackP; + IHistogram1D hTruthMatchedPosTrackP; + IHistogram1D hTruthMatchedPosTrackPdiff; + IHistogram1D[] hTruthMatchedPosTrackPdiffvsP = new IHistogram1D[5]; + IDataPointSet hTruthMatchedPosTrackPres; + IHistogram1D hNegTrackP; + IHistogram1D hTruthMatchedNegTrackP; + IHistogram1D hTruthMatchedNegTrackPdiff; + IHistogram1D[] hTruthMatchedNegTrackPdiffvsP = new IHistogram1D[5]; + IDataPointSet hTruthMatchedNegTrackPres;
ICloud1D hTruthMatchedPosTrackPdiffPrev[] = new ICloud1D[5]; ICloud1D hTruthMatchedNegTrackPdiffPrev[] = new ICloud1D[5]; ICloud1D hNTracks;
@@ -145,36 +150,34 @@
for (Track trk : tracklist) { double p = this.getMomentum(trk); this.hTrackP.fill(p);
- if(trk.getCharge()<0) { - this.hPosTrackP.fill(p); - if(positron!=null) { - if(positron.getCharge()<0) { - System.out.println("Error charge!!!"); - System.exit(1); - } - this.hTruthMatchedPosTrackP.fill(p); - this.hTruthMatchedPosTrackPdiff.fill(p - positron.getMomentum().magnitude()); - System.out.println("Filling pos for " + mc_pos_prev.size() + " prev "); - for(Map.Entry<Integer,MCParticle> prev : mc_pos_prev.entrySet()) { - System.out.println("prev " + prev.getKey()); - this.hTruthMatchedPosTrackPdiffPrev[prev.getKey()].fill(p - prev.getValue().getMomentum().magnitude()); - } - } - ++ntrks[1]; - } - else {
+ if(this.isElectronTrack(trk)) {
this.hNegTrackP.fill(p); if(electron!=null) { this.hTruthMatchedNegTrackP.fill(p); this.hTruthMatchedNegTrackPdiff.fill(p - electron.getMomentum().magnitude());
- System.out.println("Filling ele for " + mc_ele_prev.size() + " prev ");
+ hTruthMatchedNegTrackPdiffvsP[this.getMomentumBin(electron.getMomentum().magnitude())].fill(p - electron.getMomentum().magnitude()); + if(_debug) System.out.println("Filling ele for " + mc_ele_prev.size() + " prev ");
for(Map.Entry<Integer,MCParticle> prev : mc_ele_prev.entrySet()) {
- System.out.println("prev " + prev.getKey());
+ if(_debug) System.out.println("prev " + prev.getKey());
this.hTruthMatchedNegTrackPdiffPrev[prev.getKey()].fill(p - prev.getValue().getMomentum().magnitude()); } } ++ntrks[2]; }
+ else { + this.hPosTrackP.fill(p); + if(positron!=null) { + this.hTruthMatchedPosTrackP.fill(p); + this.hTruthMatchedPosTrackPdiff.fill(p - positron.getMomentum().magnitude()); + hTruthMatchedPosTrackPdiffvsP[this.getMomentumBin(positron.getMomentum().magnitude())].fill(p - positron.getMomentum().magnitude()); + if(_debug) System.out.println("Filling pos for " + mc_pos_prev.size() + " prev "); + for(Map.Entry<Integer,MCParticle> prev : mc_pos_prev.entrySet()) { + if(_debug) System.out.println("prev " + prev.getKey()); + this.hTruthMatchedPosTrackPdiffPrev[prev.getKey()].fill(p - prev.getValue().getMomentum().magnitude()); + } + } + ++ntrks[1]; + }
++totalTracks; ++ntrks[0];
@@ -201,13 +204,34 @@
mc_pos_prev.put(0, positron); }
+ if(totalTracks%50==0) this.updatePlots(); +
}
+ private int getMomentumBin(double p) { + int p_bin = -1; + for(int i=0;i<5;++i) { + double plow = i/2.0; + double phigh = (i)/2.0+0.5; + if(p>=plow && p<phigh) { + p_bin = i; + break; + } + } + if(p_bin==-1) p_bin = 4; + return p_bin; + } + + private boolean isElectronTrack(Track track) { + //fix confusing sign flip in magnetic field!! + return track.getCharge()>0 ? true : false; + } +
private HashMap<Integer,MCParticle> updatePrevMap(HashMap<Integer,MCParticle> map) { HashMap<Integer,MCParticle> newmap = new HashMap<Integer,MCParticle>(); for (Map.Entry<Integer, MCParticle> entry : map.entrySet()) { if(entry.getKey()<4) {
- System.out.println("Key e = " + entry.getKey() + ", Value = " + entry.getValue());
+ if(_debug) System.out.println("Key e = " + entry.getKey() + ", Value = " + entry.getValue());
newmap.put(entry.getKey()+1, entry.getValue()); } }
@@ -236,7 +260,7 @@
public void endOfData() {
-
+ this.updatePlots();
System.out.println("Total Number of Tracks Found = "+totalTracks); if (outputPlotFileName != "")
@@ -258,24 +282,34 @@
//style0.dataStyle().fillStyle().setColor("yellow"); //style0.dataStyle().errorBarStyle().setVisible(false); pPlotter.createRegions(2, 6);
- hTrackP = aida.cloud1D("Track p"); - hPosTrackP = aida.cloud1D("Track p q>0"); - hNegTrackP = aida.cloud1D("Track p q<0"); - hTruthMatchedPosTrackP = aida.cloud1D("Track p q>0 e+ match"); - hTruthMatchedNegTrackP = aida.cloud1D("Track p q<0 e- match"); - hTruthMatchedPosTrackPdiff = aida.cloud1D("Track p - p(e+) q>0 "); - hTruthMatchedNegTrackPdiff = aida.cloud1D("Track p - p(e-) q<0");
+ hTrackP = aida.histogram1D("Track p", 50, 0,4); + hPosTrackP = aida.histogram1D("Track p q>0", 50, 0,4); + hNegTrackP = aida.histogram1D("Track p q<0", 50, 0,4); + hTruthMatchedPosTrackP = aida.histogram1D("Track p q>0 e+ match", 50, 0,4); + hTruthMatchedNegTrackP = aida.histogram1D("Track p q<0 e- match", 50, 0,4); + hTruthMatchedPosTrackPdiff = aida.histogram1D("Track p - p(e+) q>0", 100, -0.2,0.2); + hTruthMatchedNegTrackPdiff = aida.histogram1D("Track p - p(e-) q<0", 100, -0.2,0.2); + for(int i=0;i<5;++i) { + double plow = i/2.0+0.5; + double phigh = (i+1)/2.0+0.5; + hTruthMatchedPosTrackPdiffvsP[i] = aida.histogram1D("Track p - p(e+) q>0 p["+plow+","+phigh+"]", 100, -0.2,0.2); + hTruthMatchedNegTrackPdiffvsP[i] = aida.histogram1D("Track p - p(e-) q<0 p["+plow+","+phigh+"]", 100, -0.2,0.2); + + } + IDataPointSetFactory dpsf = aida.analysisFactory().createDataPointSetFactory(aida.tree()); + hTruthMatchedPosTrackPres = dpsf.create("hTruthMatchedPosTrackPres", "RMS(Track p - p(e+)) q>0 vs P",2); + hTruthMatchedNegTrackPres = dpsf.create("hTruthMatchedNegTrackPres", "RMS(Track p - p(e-)) q<0 vs P",2);
hNTracks = aida.cloud1D("Ntrks"); trkCountVsEventPlot = aida.histogram1D("Number of Tracks vs Event Nr", 501, -0.5, 500.5); trkCountVsEventPlot.annotation().addItem("xAxisLabel", "Event Number"); hNPosTracks = aida.cloud1D("Ntrks q>0"); hNNegTracks = aida.cloud1D("Ntrks q<0");
- hElectronP = aida.cloud1D("Electron Momentum"); - hPositronP = aida.cloud1D("Positron Momentum"); - hNPositronsForTrack = aida.cloud1D("N positrons given track w/ q>0"); - hNElectronsForTrack = aida.cloud1D("N electrons given track w/ q<0"); - hNPositronsForTrackInv = aida.cloud1D("N positrons given track w/ q<0"); - hNElectronsForTrackInv = aida.cloud1D("N electrons given track w/ q>0");
+ hElectronP = aida.histogram1D("Electron Momentum", 50, 0,4); + hPositronP = aida.histogram1D("Positron Momentum", 50, 0,4); + hNPositronsForTrack = aida.cloud1D("N positrons given track with q>0"); + hNElectronsForTrack = aida.cloud1D("N electrons given track with q<0"); + hNPositronsForTrackInv = aida.cloud1D("N positrons given track with q<0"); + hNElectronsForTrackInv = aida.cloud1D("N electrons given track with q>0");
pPlotter.region(0).plot(hTrackP);
@@ -287,23 +321,40 @@
pPlotter.region(1).plot(hElectronP); pPlotter.region(7).plot(hPositronP); pPlotter.region(2).plot(this.hTruthMatchedPosTrackP);
+ pPlotter.region(3).plot(trkCountVsEventPlot);
pPlotter.region(8).plot(this.hTruthMatchedNegTrackP);
- pPlotter.region(3).plot(this.hTruthMatchedPosTrackPdiff); - pPlotter.region(9).plot(this.hTruthMatchedNegTrackPdiff);
pPlotter.region(4).plot(this.hNPositronsForTrack); pPlotter.region(10).plot(this.hNElectronsForTrack); pPlotter.region(5).plot(this.hNPositronsForTrackInv); pPlotter.region(11).plot(this.hNElectronsForTrackInv);
+
- pPlotter2 = af.createPlotterFactory().create("Truth p Plots"); - pPlotter2.setTitle("Truth p Plots");
+ pPlotter2 = af.createPlotterFactory().create("Resolution"); + pPlotter2.setTitle("Resolution");
pFrame.addPlotter(pPlotter2); style0 = pPlotter2.style(); //style0.dataStyle().fillStyle().setColor("yellow"); //style0.dataStyle().errorBarStyle().setVisible(false);
- pPlotter2.createRegions(1, 2); - pPlotter2.region(1).plot(trkCountVsEventPlot);
+ pPlotter2.createRegions(2, 2); + pPlotter2.region(0).plot(this.hTruthMatchedPosTrackPdiff); + pPlotter2.region(2).plot(this.hTruthMatchedNegTrackPdiff); + pPlotter2.region(1).plot(this.hTruthMatchedPosTrackPres); + pPlotter2.region(3).plot(this.hTruthMatchedNegTrackPres); + + + + pPlotter22 = af.createPlotterFactory().create("Resolutions"); + pPlotter22.setTitle("Resolutions"); + pFrame.addPlotter(pPlotter22); + style0 = pPlotter22.style(); + //style0.dataStyle().fillStyle().setColor("yellow"); + //style0.dataStyle().errorBarStyle().setVisible(false); + pPlotter22.createRegions(2, 5); + for(int i=0;i<5;++i) { + pPlotter22.region(i).plot(this.hTruthMatchedPosTrackPdiffvsP[i]); + pPlotter22.region(5+i).plot(this.hTruthMatchedNegTrackPdiffvsP[i]); + }
pPlotter3 = af.createPlotterFactory().create("Truth p Plots");
@@ -325,5 +376,42 @@
- -}
+ + + + void updatePlots() { + this.hTruthMatchedNegTrackPres.clear(); + this.hTruthMatchedPosTrackPres.clear(); + + for(int i=0;i<5;++i) { + + double plow = i/2.0+0.5; + double phigh = (i+1)/2.0+0.5; + double p = (phigh-plow)/2+plow; + double rms = hTruthMatchedPosTrackPdiffvsP[i].rms(); + double n = hTruthMatchedPosTrackPdiffvsP[i].entries(); + //aproximation + double rms_error = n==0? 0 : Math.sqrt(Math.pow(hTruthMatchedPosTrackPdiffvsP[i].rms(),2)/(2*hTruthMatchedPosTrackPdiffvsP[i].entries())); + + this.hTruthMatchedPosTrackPres.addPoint(); + this.hTruthMatchedPosTrackPres.point(i).coordinate(1).setValue(rms/p); + this.hTruthMatchedPosTrackPres.point(i).coordinate(1).setErrorPlus(rms_error); + this.hTruthMatchedPosTrackPres.point(i).coordinate(0).setValue(p); + this.hTruthMatchedPosTrackPres.point(i).coordinate(0).setErrorPlus((phigh-plow)/2); + + + rms = hTruthMatchedPosTrackPdiffvsP[i].rms(); + n = hTruthMatchedPosTrackPdiffvsP[i].entries(); + //aproximation + rms_error = n==0? 0 : Math.sqrt(Math.pow(hTruthMatchedPosTrackPdiffvsP[i].rms(),2)/(2*hTruthMatchedPosTrackPdiffvsP[i].entries())); + + this.hTruthMatchedNegTrackPres.addPoint(); + this.hTruthMatchedNegTrackPres.point(i).coordinate(1).setValue(rms/p); + this.hTruthMatchedNegTrackPres.point(i).coordinate(1).setErrorPlus(rms_error); + this.hTruthMatchedNegTrackPres.point(i).coordinate(0).setValue((phigh-plow)/2+plow); + this.hTruthMatchedNegTrackPres.point(i).coordinate(0).setErrorPlus((phigh-plow)/2); + + + } + } +}
\ No newline at end of file
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1