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  January 2015

HPS-SVN January 2015

Subject:

r1872 - in /java/trunk: conditions/src/main/java/org/hps/conditions/deprecated/EcalConditions.java monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalWindowPlots.java users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java

From:

[log in to unmask]

Reply-To:

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

Date:

Mon, 5 Jan 2015 23:20:22 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (324 lines)

Author: [log in to unmask]
Date: Mon Jan  5 15:20:14 2015
New Revision: 1872

Log:
Remove old EcalConditions class.

Removed:
    java/trunk/conditions/src/main/java/org/hps/conditions/deprecated/EcalConditions.java
Modified:
    java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalWindowPlots.java
    java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java

Modified: java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalWindowPlots.java
 =============================================================================
--- java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalWindowPlots.java	(original)
+++ java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalWindowPlots.java	Mon Jan  5 15:20:14 2015
@@ -11,7 +11,11 @@
 import javax.swing.JComboBox;
 import javax.swing.JLabel;
 
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.database.DatabaseConditionsManager;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.conditions.ecal.EcalConditionsUtil;
+import org.lcsim.detector.identifier.IIdentifierHelper;
 import org.lcsim.event.EventHeader;
 import org.lcsim.event.RawTrackerHit;
 import org.lcsim.geometry.Detector;
@@ -38,6 +42,9 @@
     private boolean testSlot = false;
     private boolean testChannel = false;
     private int plotCrate, plotSlot, plotChannel;
+    private EcalConditions conditions;
+    private EcalConditionsUtil util;
+    private IIdentifierHelper helper;
 
     public EcalWindowPlots() {
         int count = 0;
@@ -76,6 +83,11 @@
         if (inputCollection == null) {
             throw new RuntimeException("The inputCollection parameter was not set.");
         }
+        
+        DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance(); 
+        this.conditions = manager.getCachedConditions(EcalConditions.class, "ecal_conditions").getCachedData();
+        this.util = new EcalConditionsUtil(conditions);
+        this.helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
 
         setupPlots();
     }
@@ -127,13 +139,15 @@
 
     @Override
     public void process(EventHeader event) {
-        if (event.hasCollection(RawTrackerHit.class, inputCollection)) {
+        if (event.hasCollection(RawTrackerHit.class, inputCollection)) {            
             List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection);
             for (RawTrackerHit hit : hits) {
-                Long daqId = EcalConditions.physicalToDaqID(hit.getCellID());
-                int crate = EcalConditions.getCrate(daqId);
-                int slot = EcalConditions.getSlot(daqId);
-                int channel = EcalConditions.getChannel(daqId);
+                
+                EcalChannel ecalChannel = util.findChannel(helper, hit.getCellID());
+                int crate = ecalChannel.getCrate();
+                int slot = ecalChannel.getSlot();
+                int channelNumber = ecalChannel.getChannel();
+                                
 //System.out.println("got hit: crate " + crate + ", slot " + slot + ", channel " + channel);
                 if (hit.getADCValues().length != window) {
                     throw new RuntimeException("Hit has unexpected window length " + hit.getADCValues().length + ", not " + window);
@@ -144,7 +158,7 @@
                 if (testSlot && slot != plotSlot) {
                     continue;
                 }
-                if (testChannel && channel != plotChannel) {
+                if (testChannel && channelNumber != plotChannel) {
                     continue;
                 }
                 windowPlot.reset();

Modified: java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/celentan/RawPedestalComputator.java	Mon Jan  5 15:20:14 2015
@@ -1,131 +1,125 @@
 package org.hps.users.celentan;
 
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
 import java.util.List;
 
-import org.hps.conditions.deprecated.EcalConditions;
+import org.hps.conditions.database.DatabaseConditionsManager;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalChannel.GeometryId;
+import org.hps.conditions.ecal.EcalConditions;
 import org.hps.recon.ecal.ECalUtils;
-import org.lcsim.event.CalorimeterHit;
+import org.lcsim.detector.identifier.IIdentifierHelper;
 import org.lcsim.event.EventHeader;
-import org.lcsim.event.GenericObject;
-import org.lcsim.event.RawCalorimeterHit;
 import org.lcsim.event.RawTrackerHit;
 import org.lcsim.geometry.Detector;
-import org.lcsim.lcio.LCIOConstants;
 import org.lcsim.util.Driver;
-import java.io.PrintWriter;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 
+public class RawPedestalComputator extends Driver {
 
-public class RawPedestalComputator extends Driver{
-	
-	   String inputCollectionRaw = "EcalReadoutHits";
-	   int row,column;
-	   
-	   int[] windowRaw=new int[47*11];//in case we have the raw waveform, this is the window lenght (in samples)
-	   boolean[] isFirstRaw=new boolean[47*11];  
-	   
-	   double[] pedestal=new double[47*11];
-	   double[] noise=new double[47*11];
-	   double[] result;
-	   
-	   int pedSamples=50;
-	   int nEvents=0;
-	   @Override
-	    public void detectorChanged(Detector detector) {
-	    	System.out.println("Pedestal computator: detector changed");
-	    	for (int ii=0;ii<11*47;ii++){
-	    		isFirstRaw[ii]=true;
-	    		pedestal[ii]=0;
-	    		noise[ii]=0;
-	    	}
-	   }
-	   
+    String inputCollectionRaw = "EcalReadoutHits";
+    int row, column;
 
-	    @Override
-	    public void process(EventHeader event) {
-	    	int ii=0;
-	    	if (event.hasCollection(RawTrackerHit.class, inputCollectionRaw)){       	
-	    		List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollectionRaw);
-	          	for (RawTrackerHit hit : hits) {
-	          		row=hit.getIdentifierFieldValue("iy");
-	                column=hit.getIdentifierFieldValue("ix");	
-	                ii = ECalUtils.getHistoIDFromRowColumn(row,column);
-	                if ((row!=0)&&(column!=0)){
-	                	if (!ECalUtils.isInHole(row,column)){
-	                		if (isFirstRaw[ii]){ //at the very first hit we read for this channel, we need to read the window length and save it
-	                			isFirstRaw[ii]=false;
-	                			windowRaw[ii]=hit.getADCValues().length;  
-	                		 }
-	                  		result=ECalUtils.computeAmplitude(hit.getADCValues(),windowRaw[ii],pedSamples);
-	                  		pedestal[ii]+=result[1];
-	                  		noise[ii]+=result[2];	                  		
-	                	}
-	                }	
-	          	}		
-	    	  }	
-	    	nEvents++;
-	    }
-	    
-	    @Override
-	    public void endOfData() {
-	    	try{
-	    	PrintWriter writerTop = new PrintWriter("default01.ped","UTF-8");
-    		PrintWriter writerBottom = new PrintWriter("default02.ped","UTF-8");	
-	    	
-	    	for (int ii=0;ii<11*47;ii++){	    	
-	    		int row,column;	
-	    		row=ECalUtils.getRowFromHistoID(ii);
-	    		column=ECalUtils.getColumnFromHistoID(ii);
-	    		if (ECalUtils.isInHole(row,column)) continue;
-   				if ((row==0)||(column==0)) continue;
-	    		pedestal[ii]/=nEvents;
-	    		noise[ii]/=nEvents;
+    int[] windowRaw = new int[47 * 11];// in case we have the raw waveform, this is the window lenght (in samples)
+    boolean[] isFirstRaw = new boolean[47 * 11];
 
-	    		long daqID=EcalConditions.physicalToDaqID(EcalConditions.makePhysicalID(column,row));
-	    		
-	    		int crate=EcalConditions.getCrate(daqID);
-	    		int slot=EcalConditions.getSlot(daqID);
-	    		int channel=EcalConditions.getChannel(daqID);
+    double[] pedestal = new double[47 * 11];
+    double[] noise = new double[47 * 11];
+    double[] result;
 
-	    		System.out.println(column+" "+row+" "+crate+" "+slot+" "+channel+" "+pedestal[ii]+" "+noise[ii]);
-	    		
-	    		
-	    		
-	    		if (crate==37){
-	    			writerTop.print(slot+" "+channel+" "+(int)(Math.round(pedestal[ii]))+" "+(int)(Math.round(noise[ii]))+"\r\n");
-	    		}
-	    		else if (crate==39){
-	    			writerBottom.print(slot+" "+channel+" "+(int)(Math.round(pedestal[ii]))+" "+(int)(Math.round(noise[ii]))+"\r\n");
-	    		}
-	    		
-	    	}
+    int pedSamples = 50;
+    int nEvents = 0;
 
-    		writerTop.close();
-    		writerBottom.close();
-	    	}
-	    	 catch(FileNotFoundException fnfe)
-	        {
+    private EcalConditions conditions;
+    private IIdentifierHelper helper;
+    private int systemId;
 
-	            System.out.println(fnfe.getMessage());
+    @Override
+    public void detectorChanged(Detector detector) {
 
-	        }
+        DatabaseConditionsManager manager = DatabaseConditionsManager.getInstance();
+        this.conditions = manager.getCachedConditions(EcalConditions.class, "ecal_conditions").getCachedData();
+        this.helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
+        this.systemId = detector.getSubdetector("Ecal").getSystemID();
 
-	        catch(IOException ioe)
-	        {
+        System.out.println("Pedestal computator: detector changed");
+        for (int ii = 0; ii < 11 * 47; ii++) {
+            isFirstRaw[ii] = true;
+            pedestal[ii] = 0;
+            noise[ii] = 0;
+        }
+    }
 
-	            System.out.println(ioe.getMessage());
+    @Override
+    public void process(EventHeader event) {
+        int ii = 0;
+        if (event.hasCollection(RawTrackerHit.class, inputCollectionRaw)) {
+            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollectionRaw);
+            for (RawTrackerHit hit : hits) {
+                row = hit.getIdentifierFieldValue("iy");
+                column = hit.getIdentifierFieldValue("ix");
+                ii = ECalUtils.getHistoIDFromRowColumn(row, column);
+                if ((row != 0) && (column != 0)) {
+                    if (!ECalUtils.isInHole(row, column)) {
+                        if (isFirstRaw[ii]) { // at the very first hit we read for this channel, we need to read the window length and save it
+                            isFirstRaw[ii] = false;
+                            windowRaw[ii] = hit.getADCValues().length;
+                        }
+                        result = ECalUtils.computeAmplitude(hit.getADCValues(), windowRaw[ii], pedSamples);
+                        pedestal[ii] += result[1];
+                        noise[ii] += result[2];
+                    }
+                }
+            }
+        }
+        nEvents++;
+    }
 
-	        }
-	    }
+    @Override
+    public void endOfData() {
+        try {
+            PrintWriter writerTop = new PrintWriter("default01.ped", "UTF-8");
+            PrintWriter writerBottom = new PrintWriter("default02.ped", "UTF-8");
+
+            for (int ii = 0; ii < 11 * 47; ii++) {
+                int row, column;
+                row = ECalUtils.getRowFromHistoID(ii);
+                column = ECalUtils.getColumnFromHistoID(ii);
+                if (ECalUtils.isInHole(row, column))
+                    continue;
+                if ((row == 0) || (column == 0))
+                    continue;
+                pedestal[ii] /= nEvents;
+                noise[ii] /= nEvents;
+
+                EcalChannel ecalChannel = conditions.getChannelCollection().findChannel(new GeometryId(helper, new int[] {systemId, column, row}));
+                int crate = ecalChannel.getCrate();
+                int slot = ecalChannel.getSlot();
+                int channel = ecalChannel.getChannel();
+
+                System.out.println(column + " " + row + " " + crate + " " + slot + " " + channel + " " + pedestal[ii] + " " + noise[ii]);
+
+                if (crate == 37) {
+                    writerTop.print(slot + " " + channel + " " + (int) (Math.round(pedestal[ii])) + " " + (int) (Math.round(noise[ii])) + "\r\n");
+                } else if (crate == 39) {
+                    writerBottom.print(slot + " " + channel + " " + (int) (Math.round(pedestal[ii])) + " " + (int) (Math.round(noise[ii])) + "\r\n");
+                }
+
+            }
+
+            writerTop.close();
+            writerBottom.close();
+        } catch (FileNotFoundException fnfe) {
+
+            System.out.println(fnfe.getMessage());
+
+        }
+
+        catch (IOException ioe) {
+
+            System.out.println(ioe.getMessage());
+
+        }
+    }
 }
-
-
-
-
-
-
-
-
-
-

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