LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  February 2015

HPS-SVN February 2015

Subject:

r2210 - /java/trunk/monitoring-util/src/main/java/org/hps/monitoring/subsys/ecal/EcalPedestalMonitor.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Thu, 26 Feb 2015 00:46:36 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (154 lines)

Author: [log in to unmask]
Date: Wed Feb 25 16:46:31 2015
New Revision: 2210

Log:
implement refresh rate gets up to 20KHz

Modified:
    java/trunk/monitoring-util/src/main/java/org/hps/monitoring/subsys/ecal/EcalPedestalMonitor.java

Modified: java/trunk/monitoring-util/src/main/java/org/hps/monitoring/subsys/ecal/EcalPedestalMonitor.java
 =============================================================================
--- java/trunk/monitoring-util/src/main/java/org/hps/monitoring/subsys/ecal/EcalPedestalMonitor.java	(original)
+++ java/trunk/monitoring-util/src/main/java/org/hps/monitoring/subsys/ecal/EcalPedestalMonitor.java	Wed Feb 25 16:46:31 2015
@@ -18,22 +18,34 @@
 import org.lcsim.util.aida.AIDA;
 /*
  * Reads output of org.hps.recon.ecal.RunningPedestalDriver and makes strip charts.
+ * 
+ * Are we going to lose/reinitialize these plots when run ends?
+ * Or can we keep on going off ET-ring across runs?
+ * 
  * Baltzell
  */
 public class EcalPedestalMonitor extends Driver {
 
+    long previousTime;
+    long currentTime;
+    int refreshRate=1000; // units = ms
+   
+    int nDetectorChanges=0;
+   
     int maxAge = 999999999;
     int maxCount = 100000;
     int rangeSize = 100000;
+   
+    // None of this "works":
+    //int maxAge = 86400000; // 1 day (units ms)
+    //int maxCount = 999999999;//(int)maxAge/refreshRate;
+    //int rangeSize = 999999999;//maxAge; // what is this?
    
     final int crates[]={1,2};
     final int slots[]={3,4,5,6,7,8,9,14,15,16,17,18,19,20};
     
     String collectionName = "EcalRunningPedestals";
     
-//    static {
-//        org.hps.monitoring.plotting.MonitoringAnalysisFactory.register();
-//    }
     MonitoringPlotFactory plotFactory = (MonitoringPlotFactory) AIDA.defaultInstance()
             .analysisFactory().createPlotterFactory("ECal Pedestal Monitoring");
 
@@ -45,38 +57,36 @@
     public void startOfData() {
         //plotFactory.createStripChart("X","Y",maxAge,maxCount,rangeSize);
         plotFactory.create().show();
+        
+        //System.out.println("----------------------------    "+maxCount);
     }
 
     @Override
     public void detectorChanged(Detector detector) {
+        
+        // this would defeat the purpose.
+        if (nDetectorChanges++ > 0) return;
+        
+        currentTime=0;
+        previousTime=0;
+        
         ecalConditions = DatabaseConditionsManager.getInstance().getEcalConditions();
-        /*
-        for (EcalChannel cc : ecalConditions.getChannelCollection()) {
-            final int crate = cc.getCrate();
-            final int slot = cc.getSlot();
-            if (!stripCharts.containsKey(crate)) {
-                stripCharts.put(crate,new HashMap<Integer, JFreeChart>());
-            }
-            if (!stripCharts2.containsKey(crate)) {
-                stripCharts2.put(crate,new HashMap<Integer, TimeSeries>());
-            }
-            if (!stripCharts.get(crate).containsKey(slot)) {
-                String name = String.format("C%dS%02d",crate,slot);
-                JFreeChart stripChart = plotFactory.createStripChart(name,"asdf",
-                        maxAge,maxCount,rangeSize);
-                stripCharts.get(crate).put(slot,stripChart);
-                stripCharts2.get(crate).put(slot,StripChartUtil.getTimeSeries(stripChart));
-            }
-        }
-        */
+        
         // put them in order:
         for (int crate : crates) {
             stripCharts.put(crate,new HashMap<Integer, JFreeChart>());
             stripCharts2.put(crate,new HashMap<Integer, TimeSeries>());
             for (int slot : slots) {
+                
+                final double ped=getAveragePedestal(crate,slot);
+                
                 String name = String.format("C%dS%02d",crate,slot);
                 JFreeChart stripChart = plotFactory.createStripChart(name,"asdf",
                         maxAge,maxCount,rangeSize);
+//                stripChart.getXYPlot().getRangeAxis().setRange(70,140);
+//                stripChart.getXYPlot().getRangeAxis().setFixedAutoRange(10);
+//                stripChart.getXYPlot().getRangeAxis().setAutoRange(true);
+                stripChart.getXYPlot().getRangeAxis().setRangeAboutValue(ped,10);
                 stripCharts.get(crate).put(slot,stripChart);
                 stripCharts2.get(crate).put(slot,StripChartUtil.getTimeSeries(stripChart));
             }
@@ -89,6 +99,10 @@
         if (!event.hasItem(collectionName)) {
             return;
         }
+
+        currentTime=System.currentTimeMillis();
+        if (currentTime - previousTime < refreshRate) return;
+        previousTime=currentTime;
 
         // get the running pedestals:
         Map<EcalChannel, Double> peds = (Map<EcalChannel, Double>) event.get(collectionName);
@@ -126,4 +140,33 @@
         }
 
     }
+    
+    
+    public EcalChannel findChannel(int crate, int slot, int chan) {
+        for (EcalChannel cc : ecalConditions.getChannelCollection()) {
+            if (crate == cc.getCrate() && slot == cc.getSlot() && chan == cc.getChannel()) {
+                return cc;
+            }
+        }
+        throw new RuntimeException(String.format(
+                "Could not find channel:  (crate,slot,channel)=(%d,%d,%d)",crate,slot,chan));
+    }
+
+    public double getAveragePedestal(int crate,int slot)
+    {
+        int nsum=0;
+        double sum=0;
+        for (int chan=0; chan<16; chan++) {
+            for (EcalChannel cc : ecalConditions.getChannelCollection()) {
+                if (cc.getCrate()!=crate || cc.getSlot()!=slot || cc.getChannel()!=chan) continue;
+                sum += getStaticPedestal(crate,slot,chan);
+                nsum ++;
+            }
+        }
+        return (nsum>0 ? sum/nsum : sum);
+    }
+
+    public double getStaticPedestal(int crate, int slot, int chan) {
+        return ecalConditions.getChannelConstants(findChannel(crate,slot,chan)).getCalibration().getPedestal();
+    }
 }

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use