7 modified files
java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DQMDatabaseManager.java 2014-05-15 15:45:40 UTC (rev 584)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DQMDatabaseManager.java 2014-05-15 15:51:59 UTC (rev 585)
@@ -45,6 +45,7 @@
* Class constructor, which is only package accessible.
*/
DQMDatabaseManager() {
+ System.out.println("Making the instance of DQMDatabaseManager");
}
java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java 2014-05-15 15:45:40 UTC (rev 584)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java 2014-05-15 15:51:59 UTC (rev 585)
@@ -8,9 +8,11 @@
import org.lcsim.util.aida.AIDA;
/**
- * sort of an interface for DQM analysis drivers
- * creates the DQM database manager, checks whether row exists in db etc
+ * sort of an interface for DQM analysis drivers creates the DQM database
+ * manager, checks whether row exists in db etc
+ *
* @author mgraham on Apr 15, 2014
+ * update mgraham on May 15, 2014 to include calculateEndOfRunQuantities & printDQMData i.e. useful methods
*/
public class DataQualityMonitor extends Driver {
@@ -19,6 +21,7 @@
public String recoVersion = "v0.0";
public static int runNumber = 1350;
public boolean overwriteDB = false;
+ public boolean connectToDB = false;
public void setRecoVersion(String recoVersion) {
this.recoVersion = recoVersion;
@@ -28,31 +31,39 @@
this.overwriteDB = overwrite;
}
+ public void setConnectToDB(boolean connect) {
+ this.overwriteDB = connect;
+ }
+
public void DataQualityMonitor() {
}
public void endOfData() {
- manager = DQMDatabaseManager.getInstance();
+ if (connectToDB) {
+ manager = DQMDatabaseManager.getInstance();
//fill any plots that only get filled at end of data...e.g. SVT occupancy plots
- fillEndOfRunPlots();
- //check to see if I need to make a new db entry
- boolean entryExists = false;
- try {
- entryExists = checkRowExists();
- if(entryExists)System.out.println("Found an existing run/reco entry in the dqm database");
- } catch (SQLException ex) {
- Logger.getLogger(DataQualityMonitor.class.getName()).log(Level.SEVERE, null, ex);
+ //check to see if I need to make a new db entry
+ boolean entryExists = false;
+ try {
+ entryExists = checkRowExists();
+ if (entryExists)
+ System.out.println("Found an existing run/reco entry in the dqm database");
+ } catch (SQLException ex) {
+ Logger.getLogger(DataQualityMonitor.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ if (!entryExists)
+ makeNewRow();
+ else if (!overwriteDB)
+ return; //entry exists and I don't want to overwrite
+ dumpDQMData();
}
- if (!entryExists)
- makeNewRow();
- else
- if (!overwriteDB)
- return; //entry exists and I don't want to overwrite
-
- dumpDQMData();
+ calculateEndOfRunQuantities();
+ fillEndOfRunPlots();
+ printDQMData();
}
private void makeNewRow() {
@@ -76,14 +87,27 @@
}
public String getRunRecoString() {
- return "run=" + runNumber + " and recoversion='"+recoVersion+"'";
+ return "run=" + runNumber + " and recoversion='" + recoVersion + "'";
}
//override this method to do something interesting
+ //like fill some plots that you only want to fill at end of data (e.g. for occupancies)
public void fillEndOfRunPlots() {
}
+
//override this method to do something interesting
+ //like calculate averages etc. that can then be put in the db
+ public void calculateEndOfRunQuantities() {
+ }
+
+
+//override this method to do something interesting
+ //like write the DQM data to the database
public void dumpDQMData() {
}
+ //override this method to do something interesting
+ //like print the DQM data log file
+ public void printDQMData() {
+ }
}
java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/EcalMonitoring.java 2014-05-15 15:45:40 UTC (rev 584)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/EcalMonitoring.java 2014-05-15 15:51:59 UTC (rev 585)
@@ -1,11 +1,63 @@
package org.hps.analysis.dataquality;
+import hep.aida.IHistogram1D;
+import java.util.HashMap;
+import java.util.Map;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawCalorimeterHit;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.geometry.Detector;
+
/**
*
- * @author mgraham on Mar 28, 2014
+ * @author mgraham on Mar 28, 2014...just added empty (almost) file into svn
+ * May 14, 2014 put some DQM template stuff in...ECal-ers should really fill in the guts
*/
-public class EcalMonitoring {
+public class EcalMonitoring extends DataQualityMonitor {
+ String readoutHitCollectionName="EcalReadoutHits";//these are in ADC counts
+ String calibratedHitCollectionName="EcalCalHits";//these are in energy
+ String clusterCollectionName = "EcalClusters";
+ private Map<String, Double> monitoredQuantityMap = new HashMap<>();
+ String[] ecalQuantNames = {"Good","Stuff","For","ECAL"};
+
+ protected void detectorChanged(Detector detector) {
+ System.out.println("EcalMonitoring::detectorChanged Setting up the plotter");
+ aida.tree().cd("/");
+
+ //make some cool plots that will get saved in root format...2D is good too!
+ IHistogram1D energy = aida.histogram1D("Cluster Energy", 25, 0, 2.5);
+
+ }
+ @Override
+ public void process(EventHeader event) {
+ /* make sure everything is there */
+ if (!event.hasCollection(RawCalorimeterHit.class, readoutHitCollectionName))
+ return;
+
+
+ }
+
+
+ @Override
+ public void dumpDQMData() {
+ System.out.println("EcalMonitoring::endOfData filling DQM database");
+ }
+
+ @Override
+ public void printDQMData() {
+ System.out.println("EcalMonitoring::printDQMData");
+
+ System.out.println("*******************************");
+ }
+
+ /**
+ * Calculate the averages here and fill the map
+ */
+ @Override
+ public void calculateEndOfRunQuantities() {
+ }
+
}
java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/HitMCEfficiency.java 2014-05-15 15:45:40 UTC (rev 584)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/HitMCEfficiency.java 2014-05-15 15:51:59 UTC (rev 585)
@@ -21,7 +21,7 @@
* April 29 -- first pass, makes the SimTrackerHits-->SiClusters efficiency vs position (with a settable t0 cut)
* @author mgraham on April 29, 2014
*/
-// TODO: Add HelicalTrackHit efficiency...this should include the fitted track hit cuts (t0 & chi^2) automatically since that where the cut is applied
+// TODO: Add HelicalTrackHit efficiency...this should include the fitted hit cuts (t0 & chi^2) automatically since that where the cut is applied
// TODO: Add some quantities for DQM monitoring: e.g. <efficiency>, probably within first 1 cm or so.
public class HitMCEfficiency extends DataQualityMonitor {
java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/ReconMonitoring.java 2014-05-15 15:45:40 UTC (rev 584)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/ReconMonitoring.java 2014-05-15 15:51:59 UTC (rev 585)
@@ -1,11 +1,195 @@
package org.hps.analysis.dataquality;
+import hep.aida.IHistogram1D;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.hps.recon.tracking.TrackUtils;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.Track;
+import org.lcsim.geometry.Detector;
/**
- *
+ * DQM driver reconstructed particles (i.e. electrons, positrons, photons)
+ * plots things like number of electrons (or positrons)/event, photons/event, e+/e- momentum,
+ * and track-cluster matching stuff
* @author mgraham on Mar 28, 2014
+ * big update on May 14, 2014...right now the output is crap;
+ * no charge<0 tracks & the track momentum isn't filled;
+ * likely a problem with ReconParticle
+ * TODO: may want to break out the V0 DQM (not written) into it's own class
*/
+public class ReconMonitoring extends DataQualityMonitor {
-public class ReconMonitoring {
+ String finalStateParticlesColName = "FinalStateParticles";
+ String unconstrainedV0CandidatesColName = "UnconstrainedV0Candidates";
+ String beamConV0CandidatesColName = "BeamspotConstrainedV0Candidates";
+ String targetV0ConCandidatesColName = "TargetConstrainedV0Candidates";
+ private Map<String, Double> monitoredQuantityMap = new HashMap<>();
+ String[] fpQuantNames = {"nEle_per_Event", "nPos_per_Event", "nPhoton_per_Event", "nUnAssociatedTracks_per_Event", "avg_delX_at_ECal", "avg_delY_at_ECal", "avg_E_Over_P"};
+ //some counters
+ int nRecoEvents = 0;
+ int nTotEle = 0;
+ int nTotPos = 0;
+ int nTotPhotons = 0;
+ int nTotUnAss = 0;
+ int nTotAss = 0;
+ //some summers
+ double sumdelX = 0.0;
+ double sumdelY = 0.0;
+ double sumEoverP = 0.0;
+ protected void detectorChanged(Detector detector) {
+ System.out.println("ReconMonitoring::detectorChanged Setting up the plotter");
+ aida.tree().cd("/");
+
+ /* Final State Particle Quantities */
+ /* plot electron & positron momentum separately */
+ IHistogram1D elePx = aida.histogram1D("Electron Px (GeV)", 25, -0.1, 0.200);
+ IHistogram1D elePy = aida.histogram1D("Electron Py (GeV)", 25, -0.1, 0.1);
+ IHistogram1D elePz = aida.histogram1D("Electron Pz (GeV)", 25, 0, 2.4);
+
+ IHistogram1D posPx = aida.histogram1D("Positron Px (GeV)", 25, -0.1, 0.200);
+ IHistogram1D posPy = aida.histogram1D("Positron Py (GeV)", 25, -0.1, 0.1);
+ IHistogram1D posPz = aida.histogram1D("Positron Pz (GeV)", 25, 0, 2.4);
+ /* photon quanties (...right now, just unassociated clusters) */
+ IHistogram1D nPhotonsHisto = aida.histogram1D("Number of photons per event", 10, 0, 10);
+ IHistogram1D enePhoton = aida.histogram1D("Photon Energy (GeV)", 25, 0, 2.4);
+ IHistogram1D xPhoton = aida.histogram1D("Photon X position (mm)", 25, -100, 100);
+ IHistogram1D yPhoton = aida.histogram1D("Photon Y position (mm)", 25, -100, 100);
+
+ /* tracks with associated clusters */
+ IHistogram1D eneOverp = aida.histogram1D("Cluster Energy Over TrackMomentum", 25, 0, 2.0);
+ IHistogram1D deltaXAtCal = aida.histogram1D("delta X @ ECal (mm)", 25, -10, 10.0);
+ IHistogram1D deltaYAtCal = aida.histogram1D("delta Y @ ECal (mm)", 25, -10, 10.0);
+ /* number of unassocaited tracks */
+ IHistogram1D nUnAssTracksHisto = aida.histogram1D("Number of unassociated tracks per event", 10, 0, 10);
+ }
+
+ @Override
+ public void process(EventHeader event) {
+ /* make sure everything is there */
+ if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName))
+ return;
+// if (!event.hasCollection(ReconstructedParticle.class, unconstrainedV0CandidatesColName))
+// return;
+// if (!event.hasCollection(ReconstructedParticle.class, beamConV0CandidatesColName))
+// return;
+// if (!event.hasCollection(ReconstructedParticle.class, targetV0ConCandidatesColName))
+// return;
+ nRecoEvents++;
+ int nPhotons = 0; //number of photons
+ int nUnAssTracks = 0; //number of tracks w/o clusters
+ List<ReconstructedParticle> finalStateParticles = event.get(ReconstructedParticle.class, finalStateParticlesColName);
+// System.out.println("This events has " + finalStateParticles.size() + " final state particles");
+ for (ReconstructedParticle fsPart : finalStateParticles) {
+ // Extrapolate the track to the Ecal cluster position
+ boolean isPhoton = false;
+ boolean hasCluster = true;
+ Track fsTrack = null;
+ Cluster fsCluster = null;
+ //TODO: mg-May 14, 2014 use PID to do this instead...not sure if that's implemented yet
+ if (fsPart.getTracks().size() == 1)//should always be 1 or zero for final state particles
+ fsTrack = fsPart.getTracks().get(0);
+ else
+ isPhoton = true;
+ //get the cluster
+ if (fsPart.getClusters().size() == 1)
+ fsCluster = fsPart.getClusters().get(0);
+ else
+ hasCluster = false;
+
+ //deal with electrons & positrons first
+ if (!isPhoton) {
+ double charge = fsPart.getCharge();
+ Hep3Vector mom = fsPart.getMomentum();
+ if (charge < 0) {
+ nTotEle++;
+ aida.histogram1D("Electron Px (GeV)").fill(mom.x());
+ aida.histogram1D("Electron Py (GeV)").fill(mom.y());
+ aida.histogram1D("Electron Pz (GeV)").fill(mom.z());
+ } else {
+ nTotPos++;
+ aida.histogram1D("Positron Px (GeV)").fill(mom.x());
+ aida.histogram1D("Positron Py (GeV)").fill(mom.y());
+ aida.histogram1D("Positron Pz (GeV)").fill(mom.z());
+ }
+
+ }
+ //now, the photons
+ if (isPhoton) {
+ double ene = fsPart.getEnergy();
+ //TODO: mg-May 14, 2014....I would like to do this!!!!
+ //double xpos = fsCluster.getPositionAtShowerMax(false)[0];// false-->assume a photon instead of electron from calculating shower depth
+ //double ypos = fsCluster.getPositionAtShowerMax(false)[1];
+ //but I can't because ReconParticles don't know about HPSEcalClusters, and casting it as one doesn't seem to work
+ Hep3Vector clusterPosition = new BasicHep3Vector(fsCluster.getPosition());
+ double xpos = clusterPosition.x();
+ double ypos = clusterPosition.y();
+ nPhotons++;
+ nTotPhotons++;
+ aida.histogram1D("Photon Energy (GeV)").fill(ene);
+ aida.histogram1D("Photon X position (mm)").fill(xpos);
+ aida.histogram1D("Photon Y position (mm)").fill(ypos);
+ }
+
+ if (hasCluster && !isPhoton) {
+ nTotAss++;
+ Hep3Vector mom = fsPart.getMomentum();
+ double ene = fsPart.getEnergy();
+ double eOverP = ene / mom.magnitude();
+ Hep3Vector clusterPosition = new BasicHep3Vector(fsCluster.getPosition());//this gets position at shower max assuming it's an electron/positron
+ Hep3Vector trackPosAtEcal = TrackUtils.extrapolateTrack(fsTrack, clusterPosition.z());
+ double dx = trackPosAtEcal.y() - clusterPosition.x();//remember track vs detector coords
+ double dy = trackPosAtEcal.z() - clusterPosition.y();//remember track vs detector coords
+ sumdelX += dx;
+ sumdelY += dy;
+ sumEoverP += eOverP;
+
+ aida.histogram1D("Cluster Energy Over TrackMomentum").fill(eOverP);
+ aida.histogram1D("delta X @ ECal (mm)").fill(dx);
+ aida.histogram1D("delta Y @ ECal (mm)").fill(dy);
+ }
+ if (!hasCluster) {//if there is no cluster, can't be a track or else it wouldn't be in list
+ nUnAssTracks++; //count per event
+ nTotUnAss++; //and keep a running total for averaging
+ }
+ }
+ aida.histogram1D("Number of unassociated tracks per event").fill(nUnAssTracks);
+ aida.histogram1D("Number of photons per event").fill(nPhotons);
+ //Ok...done with the final state tracks! Now, do the A' candidates. Soon.
+
+ }
+
+ @Override
+ public void dumpDQMData() {
+ System.out.println("ReconMonitoring::endOfData filling DQM database");
+ }
+
+ @Override
+ public void printDQMData() {
+ System.out.println("ReconMonitoring::printDQMData");
+ for(int i =0;i<7;i++){//TODO: do this in a smarter way...loop over the map
+ System.out.println(fpQuantNames[i]+" = "+monitoredQuantityMap.get(fpQuantNames[i]));
+ }
+ System.out.println("*******************************");
+ }
+
+ /**
+ * Calculate the averages here and fill the map
+ */
+ @Override
+ public void calculateEndOfRunQuantities() {
+ monitoredQuantityMap.put(fpQuantNames[0], (double) nTotEle / nRecoEvents);
+ monitoredQuantityMap.put(fpQuantNames[1], (double) nTotPos / nRecoEvents);
+ monitoredQuantityMap.put(fpQuantNames[2], (double) nTotPhotons / nRecoEvents);
+ monitoredQuantityMap.put(fpQuantNames[3], (double) nTotUnAss / nRecoEvents);
+ monitoredQuantityMap.put(fpQuantNames[4], (double) sumdelX / nTotAss);
+ monitoredQuantityMap.put(fpQuantNames[5], (double) sumdelY / nTotAss);
+ monitoredQuantityMap.put(fpQuantNames[6], (double) sumEoverP / nTotAss);
+ }
}
java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/SvtMonitoring.java 2014-05-15 15:45:40 UTC (rev 584)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/SvtMonitoring.java 2014-05-15 15:51:59 UTC (rev 585)
@@ -1,10 +1,7 @@
package org.hps.analysis.dataquality;
-import hep.aida.IAnalysisFactory;
-import hep.aida.IFitFactory;
import hep.aida.IHistogram1D;
import hep.aida.IPlotter;
-import hep.aida.IPlotterStyle;
import org.lcsim.geometry.Detector;
import java.util.HashMap;
import java.util.List;
@@ -15,7 +12,7 @@
import org.lcsim.event.RawTrackerHit;
/**
- * DQM driver for the monte carlo for reconstructed track quantities
+ * DQM driver for the monte carlo for reconstructed track quantities
* plots things like occupancy, t0, amplitude, chi^2 (from APV25 sampling fit); each on a per/sensor basis
* saves to DQM database: <occupancy>
* @author mgraham on Mar 28, 2014
@@ -165,6 +162,7 @@
sensorHist.fill(i, stripOccupancy);
avg += stripOccupancy;
}
+ //do the end-of-run quantities here too since we've already done the loop.
avg /= strips.length;
avgOccupancyMap.put(sensor.getName(), avg);
}
@@ -175,13 +173,14 @@
System.out.println("SvtMonitoring::endOfData filling DQM database");
double s1occ = 0.99;
String put = "update dqm SET avgOcc_T1=" + s1occ + " WHERE " + getRunRecoString();
-// manager.updateQuery(put);
- printDQMData();
+// manager.updateQuery(put);
}
+ @Override
public void printDQMData() {
for (SiSensor sensor : sensors) {
System.out.println(avgOccupancyNames.get(sensor.getName()) + ": " + avgOccupancyMap.get(sensor.getName()));
}
}
+
}
java/trunk/analysis/src/main/java/org/hps/analysis/dataquality
--- java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java 2014-05-15 15:45:40 UTC (rev 584)
+++ java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java 2014-05-15 15:51:59 UTC (rev 585)
@@ -15,7 +15,7 @@
import org.lcsim.geometry.IDDecoder;
/**
- * DQM driver for the monte carlo for reconstructed track quantities
+ * DQM driver for reconstructed track quantities
* plots things like number of tracks/event, momentum, chi^2, track parameters (d0/z0/theta/phi/curvature)
* @author mgraham on Mar 28, 2014
*/
@@ -96,14 +96,14 @@
List<Track> tracks = event.get(Track.class, trackCollectionName);
aida.histogram1D("Tracks per Event").fill(tracks.size());
for (Track trk : tracks) {
-
+ // fill momentum in ReconMonitoring instead...
aida.histogram1D("Track Momentum (Px)").fill(trk.getPY());
aida.histogram1D("Track Momentum (Py)").fill(trk.getPZ());
aida.histogram1D("Track Momentum (Pz)").fill(trk.getPX());
aida.histogram1D("Track Chi2").fill(trk.getChi2());
aida.histogram1D("Hits per Track").fill(trk.getTrackerHits().size());
-
+ //why is getTrackParameter depricated? How am I supposed to get this?
aida.histogram1D("d0 ").fill(trk.getTrackParameter(LCIOParameters.ParameterName.d0.ordinal()));
aida.histogram1D("sinphi ").fill(Math.sin(trk.getTrackParameter(LCIOParameters.ParameterName.phi0.ordinal())));
aida.histogram1D("omega ").fill(trk.getTrackParameter(LCIOParameters.ParameterName.omega.ordinal()));
SVNspam 0.1