Print

Print


Commit in java/trunk/users/src/main/java/org/lcsim/hps/users/celentan on MAIN
EcalHitPlots.java+60-35284 -> 285
EcalMonitoringPlots.java+136added 285
+196-35
1 added + 1 modified, total 2 files


java/trunk/users/src/main/java/org/lcsim/hps/users/celentan
EcalHitPlots.java 284 -> 285
--- java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalHitPlots.java	2014-03-06 04:28:27 UTC (rev 284)
+++ java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalHitPlots.java	2014-03-07 00:16:27 UTC (rev 285)
@@ -8,20 +8,21 @@
 
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Arrays;
 
-
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.GenericObject;
 import org.lcsim.geometry.Detector;
 import org.lcsim.hps.evio.TriggerData;
 import org.lcsim.hps.monitoring.deprecated.Resettable;
+import org.lcsim.hps.monitoring.deprecated.Redrawable;
 import org.lcsim.hps.recon.ecal.ECalUtils;
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
-
 import org.freehep.swing.popup.GlobalMouseListener;
 import org.freehep.swing.popup.GlobalPopupListener;
+
 import java.awt.event.MouseListener;
 import java.awt.event.MouseEvent;
 import java.awt.event.InputEvent; 
@@ -29,7 +30,7 @@
 import javax.swing.JPanel;
 //import org.jfree.chart.ChartPanel;
 
-public class EcalHitPlots extends Driver implements Resettable,MouseListener{
+public class EcalHitPlots extends Driver implements Resettable, MouseListener, Redrawable{
 
     //AIDAFrame plotterFrame;
     String inputCollection = "EcalCalHits";
@@ -51,10 +52,12 @@
     //Plotter5
     IPlotter plotter5;
     ArrayList<IHistogram1D> channelEnergyPlot;
+    IHistogram2D channelMeanEnergy; 
     GlobalMouseListener plotter5listener;
     boolean isPlotter5zoomed=false;
     
     int eventn = 0;
+    int eventRefreshRate = 1;
     int dummy = 0;
     double maxE = 5000 * ECalUtils.MeV;
     double maxEch = 2500 * ECalUtils.MeV;
@@ -82,7 +85,7 @@
     	
       //  plotterFrame = new AIDAFrame();
        // plotterFrame.setTitle("HPS ECal Hit Plots");
-    	System.out.println("qui: "+ detector.getClass().getName());
+    	System.out.println("Detector changed called: "+ detector.getClass().getName());
     	aida.tree().cd("/");
         IPlotterFactory plotterFactory = aida.analysisFactory().createPlotterFactory("Ecal Hit Plots");
 
@@ -127,33 +130,26 @@
         plotter5 = plotterFactory.create("Hit Energies - per channel");
         plotter5.setTitle("Hit Energies - per channel");
         plotter5.style().dataStyle().errorBarStyle().setVisible(false);
-        plotter5.createRegions(47,11); //1 more, to have raw 0 and column 0 empty.
-      
+        plotter5.createRegions(1, 2);
+  
+        
         plotter5listener=new GlobalMouseListener(thePlotterUtilities.componentForPlotter(plotter5));
         plotter5listener.addMouseListener(this);
         
-        
+        channelMeanEnergy = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Hit Count", 47, -23.5, 23.5, 11, -5.5, 5.5);
         channelEnergyPlot=new ArrayList<IHistogram1D>();
-      
-        
-        
-    
-       // plotter5Listener.addMouseListener(this);
-        
+         
         for(int id = 0; id < (47*11); id = id +1){
         	  
         	  int row=this.getRowFromHistoID(id);
         	  int column=this.getColumnFromHistoID(id);      
-        	  
-        	  //create the histogram, the global listener, and the specific listener.
-        	  channelEnergyPlot.add(aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Energy : " + (row) + " "+ (column)+ ": "+id, 1000, -0.1, maxEch));
+        	  //create the histograms
+        	  channelEnergyPlot.add(aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Hit Energy : " + (row) + " "+ (column)+ ": "+id, 1000, -0.1, maxEch));     
+        	 }
+         
+        plotter5.region(0).plot(channelMeanEnergy);
         
-        	  
-        	  if ((row!=0)&&(column!=0)&&(!isInHole(row,column))){
-        		  plotter5.region(id).plot(channelEnergyPlot.get(id));       	
-        	  }
-        	 }
-               
+        
         plotter3 = plotterFactory.create("Hit Times");
         plotter3.setTitle("Hit Times");
       //  plotterFrame.addPlotter(plotter3);
@@ -338,6 +334,11 @@
         } else {
             hitCountPlot.fill(0);
         }
+        
+        if (eventRefreshRate > 0 && ++eventn % eventRefreshRate == 0) {
+            redraw();
+        }
+        
     }
 
     @Override
@@ -408,36 +409,41 @@
             		  	 int id=getHistoIDFromRowColumn(row, column);
             			 System.out.println("ZOOM IN histo "+id);
             		  	 System.out.println(row+" "+column+" "+id+" ");   
+            	      	 plotter5.destroyRegions();
             		  	 plotter5.clearRegions();
-        				 plotter5.destroyRegions();
-        				 System.out.println(plotter5.numberOfRegions());
-        				 plotter5.createRegion();
+        				
+            		  	 //	plotter5.destroyRegions();
+        				/*
+            		  	 System.out.println(plotter5.numberOfRegions());
+        				 */
+            		  	 plotter5.createRegion();
         				 plotter5.region(0).plot(channelEnergyPlot.get(id));
-        				 System.out.println(plotter5.numberOfRegions());
-        				 plotter5.refresh();
+        				 System.out.println(plotter5.numberOfRegions());      				
         				 plotter5.show();
-        				 father.repaint();
+        				  
         			 }
         			 else {
         				 this.isPlotter5zoomed=false;
         				 System.out.println("ZOOM out");
         				 System.out.println(plotter5.numberOfRegions());
         				 plotter5.clearRegions();
-        				 plotter5.destroyRegions();
+        				 /*plotter5.destroyRegions();
         				 System.out.println(plotter5.numberOfRegions());
+        				 
         				 plotter5.createRegions(47,11); //1 more, to have raw 0 and column 0 empty.
-        				 System.out.println(plotter5.numberOfRegions());
+        				
+        			
+        				 System.out.println(Arrays.toString(plotter5.availableParameters()));
         			     for(int id = 0; id < (47*11); id = id +1){			        	  
         			       int row=getRowFromHistoID(id);
         			       int column=getColumnFromHistoID(id);       			        	  
         			        	  if ((row!=0)&&(column!=0)&&(!isInHole(row,column))){
         			        		  plotter5.region(id).plot(channelEnergyPlot.get(id));       	
         			        	  }
-        			     }
-        			     plotter.region(0).plot(hitCountPlot);
-        				 plotter5.refresh();
-        				 plotter5.show();   //a
-        				 father.repaint();
+        			     }*/
+        			     plotter5.region(0).plot(hitCountPlot);
+        				
+        				 plotter5.show();          				
         			}
         	  }
             break;
@@ -448,6 +454,25 @@
             }
           }
         }   
+
+
+    @Override
+    public void redraw() {
+         channelMeanEnergy.reset();
+         for(int id = 0; id < (47*11); id = id +1){			        	  
+		       int row=getRowFromHistoID(id);
+		       int column=getColumnFromHistoID(id);       			        	  
+		        	  if ((row!=0)&&(column!=0)&&(!isInHole(row,column))){
+		        		 if (channelEnergyPlot.get(id).mean()>0) channelMeanEnergy.fill(row,column,channelEnergyPlot.get(id).mean());	
+		        	  }
+		     }
+    
+    }
+    @Override
+    public void setEventRefreshRate(int eventRefreshRate) {
+        this.eventRefreshRate = eventRefreshRate;
+    }
+
 }
 
    
\ No newline at end of file

java/trunk/users/src/main/java/org/lcsim/hps/users/celentan
EcalMonitoringPlots.java added at 285
--- java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalMonitoringPlots.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/lcsim/hps/users/celentan/EcalMonitoringPlots.java	2014-03-07 00:16:27 UTC (rev 285)
@@ -0,0 +1,136 @@
+package org.lcsim.hps.users.celentan;
+
+import hep.aida.IHistogram2D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterStyle;
+
+import java.util.List;
+import org.lcsim.event.CalorimeterHit;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.RawTrackerHit;
+import org.lcsim.event.base.BaseRawCalorimeterHit;
+import org.lcsim.geometry.Detector;
+import org.lcsim.hps.monitoring.deprecated.Redrawable;
+import org.lcsim.hps.monitoring.deprecated.Resettable;
+import org.lcsim.hps.recon.ecal.HPSEcalCluster;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class EcalMonitoringPlots extends Driver implements Resettable, Redrawable {
+
+    String inputCollection = "EcalReadoutHits";
+    String clusterCollection = "EcalClusters";
+    AIDA aida = AIDA.defaultInstance();
+    IPlotter plotter;
+    IHistogram2D hitCountFillPlot;
+    IHistogram2D hitCountDrawPlot;
+    IHistogram2D clusterCountFillPlot;
+    IHistogram2D clusterCountDrawPlot;
+    int eventRefreshRate = 1;
+    int eventn = 0;
+    boolean hide = false;
+
+    public EcalMonitoringPlots() {
+    }
+
+    public void setInputCollection(String inputCollection) {
+        this.inputCollection = inputCollection;
+    }
+
+    public void setClusterCollection(String clusterCollection) {
+        this.clusterCollection = clusterCollection;
+    }
+
+    public void setHide(boolean hide) {
+        this.hide = hide;
+    }
+
+    protected void detectorChanged(Detector detector) {
+        // Setup the plotter.
+        plotter = aida.analysisFactory().createPlotterFactory("Ecal Monitoring Plots").create("HPS ECal Monitoring Plots");
+        // Setup plots.
+        aida.tree().cd("/");
+        hitCountDrawPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Hit Count", 47, -23.5, 23.5, 11, -5.5, 5.5);
+        hitCountFillPlot = makeCopy(hitCountDrawPlot);
+        clusterCountDrawPlot = aida.histogram2D(detector.getDetectorName() + " : " + clusterCollection + " : Cluster Center Count", 47, -23.5, 23.5, 11, -5.5, 5.5);
+        clusterCountFillPlot = makeCopy(clusterCountDrawPlot);
+
+        // Create the plotter regions.
+        plotter.createRegions(1, 2);
+        plotter.style().statisticsBoxStyle().setVisible(false);
+        IPlotterStyle style = plotter.region(0).style();
+        style.setParameter("hist2DStyle", "colorMap");
+        style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        plotter.region(0).plot(hitCountDrawPlot);
+        style = plotter.region(1).style();
+        style.setParameter("hist2DStyle", "colorMap");
+        style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        plotter.region(1).plot(clusterCountDrawPlot);
+        if (!hide) {
+            plotter.show();
+        }
+    }
+
+    public void process(EventHeader event) {
+        if (event.hasCollection(BaseRawCalorimeterHit.class, inputCollection)) {
+            List<BaseRawCalorimeterHit> hits = event.get(BaseRawCalorimeterHit.class, inputCollection);
+            for (BaseRawCalorimeterHit hit : hits) {
+                hitCountFillPlot.fill(hit.getIdentifierFieldValue("ix"), hit.getIdentifierFieldValue("iy"));
+            }
+        }
+        if (event.hasCollection(RawTrackerHit.class, inputCollection)) {
+            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection);
+            for (RawTrackerHit hit : hits) {
+                hitCountFillPlot.fill(hit.getIdentifierFieldValue("ix"), hit.getIdentifierFieldValue("iy"));
+            }
+        }
+        if (event.hasCollection(CalorimeterHit.class, inputCollection)) {
+            List<CalorimeterHit> hits = event.get(CalorimeterHit.class, inputCollection);
+            for (CalorimeterHit hit : hits) {
+                hitCountFillPlot.fill(hit.getIdentifierFieldValue("ix"), hit.getIdentifierFieldValue("iy"));
+            }
+        }
+        if (event.hasCollection(HPSEcalCluster.class, clusterCollection)) {
+            List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, clusterCollection);
+//if (clusters.size()>1)            
+            for (HPSEcalCluster cluster : clusters) {
+                clusterCountFillPlot.fill(cluster.getSeedHit().getIdentifierFieldValue("ix"), cluster.getSeedHit().getIdentifierFieldValue("iy"));
+            }
+        }
+        if (eventRefreshRate > 0 && ++eventn % eventRefreshRate == 0) {
+            redraw();
+        }
+    }
+
+    public void endOfData() {
+        plotter.hide();
+        plotter.destroyRegions();
+    }
+
+    @Override
+    public void reset() {
+        hitCountFillPlot.reset();
+        hitCountDrawPlot.reset();
+        clusterCountFillPlot.reset();
+        clusterCountDrawPlot.reset();
+    }
+
+    @Override
+    public void redraw() {
+        hitCountDrawPlot.reset();
+        hitCountDrawPlot.add(hitCountFillPlot);
+        clusterCountDrawPlot.reset();
+        clusterCountDrawPlot.add(clusterCountFillPlot);
+    }
+
+    @Override
+    public void setEventRefreshRate(int eventRefreshRate) {
+        this.eventRefreshRate = eventRefreshRate;
+    }
+
+    private IHistogram2D makeCopy(IHistogram2D hist) {
+        return aida.histogram2D(hist.title() + "_copy", hist.xAxis().bins(), hist.xAxis().lowerEdge(), hist.xAxis().upperEdge(), hist.yAxis().bins(), hist.yAxis().lowerEdge(), hist.yAxis().upperEdge());
+    }
+}
+
SVNspam 0.1