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  December 2014

HPS-SVN December 2014

Subject:

r1678 - /java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/util/DatabaseCheck.java

From:

[log in to unmask]

Reply-To:

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

Date:

Wed, 10 Dec 2014 22:38:31 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (139 lines)

Author: mccaky
Date: Wed Dec 10 14:38:26 2014
New Revision: 1678

Log:
Added a database check utility.

Added:
    java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/util/DatabaseCheck.java

Added: java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/util/DatabaseCheck.java
 =============================================================================
--- java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/util/DatabaseCheck.java	(added)
+++ java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/util/DatabaseCheck.java	Wed Dec 10 14:38:26 2014
@@ -0,0 +1,123 @@
+package org.hps.monitoring.ecal.eventdisplay.util;
+
+import java.awt.Point;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.hps.conditions.database.DatabaseConditionsManager;
+import org.hps.conditions.database.TableConstants;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalLed;
+import org.hps.conditions.ecal.EcalLed.EcalLedCollection;
+import org.hps.conditions.ecal.EcalConditions;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
+
+public class DatabaseCheck {
+	private static final Set<Integer> idFailSet = new HashSet<Integer>();
+	private static final Set<Point> pointFailSet = new HashSet<Point>();
+	
+	public static void main(String[] args) throws ConditionsNotFoundException, IOException {
+		// Check that an appropriate file has been given.
+		String filepath = null;
+		if(args.length == 1) {
+			filepath = args[0];
+		}
+		
+		// If no file path was defined, throw an error.
+		if(filepath == null) {
+			throw new FileNotFoundException("No CSV mapping file defined.");
+		}
+		
+		// Initialize the local database.
+		EcalWiringManager manager = new EcalWiringManager(filepath);
+		
+		// Initialize the database.
+		DatabaseConditionsManager conditionsManager = DatabaseConditionsManager.getInstance();
+		conditionsManager.setDetector("HPS-Proposal2014-v7-2pt2", 2000);
+		
+		// Get ECAL conditions.
+		EcalConditions ecalConditions = ConditionsManager.defaultInstance().getCachedConditions(EcalConditions.class, TableConstants.ECAL_CONDITIONS).getCachedData();
+		 
+		// Get the list of EcalChannel objects.
+		EcalChannelCollection channels = ecalConditions.getChannelCollection();
+		EcalLedCollection leds = conditionsManager.getConditionsData(EcalLedCollection.class, TableConstants.ECAL_LEDS);
+		
+		// Map the LED objects to their channels.
+		Map<Integer, EcalLed> ledMap = new HashMap<Integer, EcalLed>();
+        for (EcalLed led : leds) {
+        	ledMap.put(led.getEcalChannelId(), led);
+        }
+		
+		// Perform the comparison test.
+		for(EcalChannel channel : channels) {
+			// Get the crystal point information.
+			Point crystal = new Point(channel.getX(), channel.getY());
+			
+			// Get the data from manager.
+			CrystalDataSet data = manager.getCrystalData(crystal);
+			
+			// Get the appropriate LED collection.
+			EcalLed led = ledMap.get(channel.getChannelId());
+			
+			// Perform the comparison.
+			System.out.printf("Checking Mappings for Crystal (%3d, %3d):%n", crystal.x, crystal.y);
+			System.out.printf("\tChannel ID      :: %d%n", channel.getChannelId());
+			
+			System.out.printf("\tChannel     [ %3d ] vs [ %3d ] ... ", channel.getChannel(), data.getFADCChannel());
+			if(channel.getChannel() == data.getFADCChannel()) {
+				System.out.printf("[ Success ]%n");
+			} else {
+				System.out.printf("[ Failure ]%n");
+				idFailSet.add(channel.getChannelId());
+				pointFailSet.add(crystal);
+			}
+			
+			int crate = data.getMotherboard().isTop() ? 1 : 2;
+			System.out.printf("\tCrate       [ %3d ] vs [ %3d ] ... ", channel.getCrate(), crate);
+			if(channel.getCrate() == crate) {
+				System.out.printf("[ Success ]%n");
+			} else {
+				System.out.printf("[ Failure ]%n");
+				idFailSet.add(channel.getChannelId());
+				pointFailSet.add(crystal);
+			}
+			
+			System.out.printf("\tSlot        [ %3d ] vs [ %3d ] ... ", channel.getSlot(), data.getFADCSlot());
+			if(channel.getSlot() == data.getFADCSlot()) {
+				System.out.printf("[ Success ]%n");
+			} else {
+				System.out.printf("[ Failure ]%n");
+				idFailSet.add(channel.getChannelId());
+				pointFailSet.add(crystal);
+			}
+			
+			System.out.printf("\tLED Channel [ %3d ] vs [ %3d ] ... ", led.getLedNumber(), data.getLEDChannel());
+			if(led.getLedNumber() == data.getLEDChannel()) {
+				System.out.printf("[ Success ]%n");
+			} else {
+				System.out.printf("[ Failure ]%n");
+				idFailSet.add(channel.getChannelId());
+				pointFailSet.add(crystal);
+			}
+			
+			System.out.println();
+			System.out.println();
+		}
+		
+		// Print out the failing crystals.
+		System.out.println("Crystals that Failed:");
+		for(Point fail : pointFailSet) {
+			System.out.printf("\tCrystal (%3d, %3d)%n", fail.x, fail.y);
+		}
+		if(pointFailSet.isEmpty()) {
+			System.out.println("\tNone!");
+		}
+	}
+	
+}

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