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 2016

HPS-SVN February 2016

Subject:

r4223 - /java/trunk/users/src/main/java/org/hps/users/celentan/LedOnlineOfflineComparisonDriver.java

From:

[log in to unmask]

Reply-To:

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

Date:

Mon, 15 Feb 2016 13:23:50 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (222 lines)

Author: [log in to unmask]
Date: Mon Feb 15 05:23:48 2016
New Revision: 4223

Log:
added driver to compare between what is on db and data from a txt file. This is a driver to exploit the already-implemented conditions system

Added:
    java/trunk/users/src/main/java/org/hps/users/celentan/LedOnlineOfflineComparisonDriver.java

Added: java/trunk/users/src/main/java/org/hps/users/celentan/LedOnlineOfflineComparisonDriver.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/celentan/LedOnlineOfflineComparisonDriver.java	(added)
+++ java/trunk/users/src/main/java/org/hps/users/celentan/LedOnlineOfflineComparisonDriver.java	Mon Feb 15 05:23:48 2016
@@ -0,0 +1,206 @@
+package org.hps.users.celentan;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.Detector;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+import hep.aida.IPlotter;
+import hep.aida.IPlotterFactory;
+import hep.aida.IPlotterStyle;
+import hep.aida.IProfile1D;
+
+
+
+
+
+
+
+import org.hps.conditions.api.ConditionsObjectException;
+import org.hps.conditions.api.ConditionsRecord;
+import org.hps.conditions.api.DatabaseObjectException;
+import org.hps.conditions.api.TableMetaData;
+import org.hps.conditions.database.DatabaseConditionsManager;
+import org.hps.conditions.ecal.EcalChannel;
+import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection;
+import org.hps.conditions.ecal.EcalChannelConstants;
+import org.hps.conditions.ecal.EcalConditions;
+import org.hps.conditions.ecal.EcalLed;
+import org.hps.conditions.ecal.EcalLed.EcalLedCollection;
+import org.hps.conditions.ecal.EcalLedCalibration;
+import org.hps.conditions.ecal.EcalLedCalibration.EcalLedCalibrationCollection;
+import org.hps.conditions.ecal.EcalLedCalibration.LedColor;
+
+import java.io.*;
+import java.util.Scanner;
+
+/**
+ * This is a skeleton that can be used to create a user analysis Driver in LCSim.
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class LedOnlineOfflineComparisonDriver extends Driver {    
+
+
+	int runNumber;
+
+	AIDA aida;
+
+	DatabaseConditionsManager conditionsManager;
+
+	private EcalChannelCollection ChannelCollection;	
+	private EcalLedCollection LEDCollection;
+	private EcalConditions ecalConditions;
+	private EcalLedCalibrationCollection LEDCalibrations;
+
+
+	IHistogram1D hChargeChannelsOnline;
+	IHistogram1D hChargeChannelsOffline;
+	IHistogram1D hChargeChannelsRatio;
+	IHistogram1D hChargeChannelsRatioAll;
+	
+	IHistogram2D hChargeChannelsRatio2D;
+	
+	Map < Integer,Double > onlineResponse;
+	Map < Integer,Double > offlineResponse;
+	Map < Integer,Double > onlineRMS;
+	Map < Integer,Double > offlineRMS;
+
+
+	private static final int NUM_CHANNELS = 442;
+	/**
+	 * Your Driver should have a public constructor.
+	 */
+	public  LedOnlineOfflineComparisonDriver() {
+		getLogger().info("Hello  LedOnlineOfflineComparisonDriver!");
+	}
+
+
+	/**
+	 * Process a single event.  
+	 * Your analysis code should go in here.
+	 * @param event The LCSim event to process.
+	 */
+	public void process(EventHeader event) {
+
+	}
+
+	/**
+	 * Initialization code should go here that doesn't need the conditions system or Detector.
+	 */
+	public void startOfData() {
+		getLogger().info("start of data");
+	}
+
+	/**
+	 * Driver setup should go here that needs information from the conditions system or Detector.
+	 * @param detector The LCSim Detector object.
+	 */
+	public void detectorChanged(Detector detector) {
+		getLogger().info("detector changed");
+
+		onlineResponse = new HashMap< Integer , Double >();
+		offlineResponse= new HashMap< Integer , Double >();
+		onlineRMS= new HashMap< Integer , Double >();
+		offlineRMS= new HashMap< Integer , Double >();
+
+		conditionsManager = DatabaseConditionsManager.getInstance();
+		ChannelCollection = conditionsManager.getCachedConditions(EcalChannelCollection.class, "ecal_channels").getCachedData();	
+		ecalConditions = conditionsManager.getEcalConditions();		
+		LEDCollection = conditionsManager.getCachedConditions(EcalLedCollection.class, "ecal_leds").getCachedData();
+		LEDCalibrations =  conditionsManager.getCachedConditions(EcalLedCalibrationCollection.class,"ecal_led_calibrations").getCachedData();
+
+
+		// Setup plots
+		aida = AIDA.defaultInstance();
+		aida.tree().cd("/");
+		hChargeChannelsOnline =  aida.histogram1D("LEDonline",NUM_CHANNELS,-0.5,NUM_CHANNELS-0.5);
+		hChargeChannelsOffline = aida.histogram1D("LEDoffline",NUM_CHANNELS,-0.5,NUM_CHANNELS-0.5);
+		hChargeChannelsRatio = aida.histogram1D("ratio",NUM_CHANNELS,-0.5,NUM_CHANNELS-0.5);
+		hChargeChannelsRatioAll = aida.histogram1D("ratioAll",100,-0.03,0.03);
+		
+		hChargeChannelsRatio2D  = aida.histogram2D("ratio2D",47, -23.5, 23.5, 11, -5.5, 5.5);
+	}
+
+
+	public void endOfData(){
+
+		int channel_id;
+		int row,column;
+		double led_response_online,led_rms_online;
+		double led_response_offline,led_rms_offline;
+		double diff,ratio;
+
+
+		getLogger().info("end of data");
+		runNumber= conditionsManager.getRun();
+		System.out.println("runNumber is:"+runNumber);
+		for (EcalLedCalibration LEDcalibration : LEDCalibrations){
+
+			channel_id=LEDcalibration.getFieldValue("ecal_channel_id");
+			led_response_online=LEDcalibration.getFieldValue("led_response");
+			led_rms_online=LEDcalibration.getFieldValue("rms");
+
+
+			onlineResponse.put(channel_id,led_response_online);
+			onlineRMS.put(channel_id, led_rms_online);
+		}
+		String fileName = runNumber+".raw.txt";
+		try {
+			//Create object of FileReader
+			FileReader inputFile = new FileReader(fileName);
+
+			//Instantiate the BufferedReader Class
+			BufferedReader bufferReader = new BufferedReader(inputFile);
+
+			//Variable to hold the one line data
+			String line;
+
+			while ((line = bufferReader.readLine()) != null)   {
+				Scanner s=new Scanner(line);
+				channel_id=s.nextInt();
+				column=s.nextInt();
+				row=s.nextInt();
+				led_response_offline=s.nextDouble();
+				led_rms_offline=s.nextDouble();
+				s.close();
+				offlineResponse.put(channel_id,led_response_offline);
+				offlineRMS.put(channel_id, led_rms_offline);
+
+
+			}
+			//Close the buffer reader
+			bufferReader.close();
+		} catch (IOException e) {
+			System.err.println(e);
+		}
+		/*now some comparisons*/
+		for (EcalLedCalibration LEDcalibration : LEDCalibrations){
+			channel_id=LEDcalibration.getFieldValue("ecal_channel_id");
+
+			EcalChannel channel = ChannelCollection.findChannel(channel_id);
+			row=channel.getY();
+			column=channel.getX();
+			
+			System.out.println(channel_id+" "+column+" "+row);
+			led_response_online=onlineResponse.get(channel_id);
+			led_response_offline=offlineResponse.get(channel_id);
+
+			diff=led_response_online-led_response_offline;
+			ratio=2*diff/(led_response_online+led_response_offline);
+			
+			ratio =  led_response_online/led_response_offline;
+			
+			hChargeChannelsOnline.fill(channel_id,led_response_online);
+			hChargeChannelsOffline.fill(channel_id,led_response_offline);
+			hChargeChannelsRatio.fill(channel_id,ratio);
+			hChargeChannelsRatioAll.fill(ratio);
+			if ((column==-14)&&(row==-2)) continue;
+			hChargeChannelsRatio2D.fill(column,row,ratio);
+		}
+	}
+}

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