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:

r1740 - /java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalCalibrationsDriver.java

From:

[log in to unmask]

Reply-To:

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

Date:

Mon, 15 Dec 2014 23:58:35 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (95 lines)

Author: [log in to unmask]
Date: Mon Dec 15 15:58:30 2014
New Revision: 1740

Log:
Corrections and cleanup to calibrations Driver.

Modified:
    java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalCalibrationsDriver.java

Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalCalibrationsDriver.java
 =============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalCalibrationsDriver.java	(original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalCalibrationsDriver.java	Mon Dec 15 15:58:30 2014
@@ -20,6 +20,7 @@
 
 import org.hps.conditions.api.ConditionsObjectException;
 import org.hps.conditions.api.ConditionsRecord;
+import org.hps.conditions.api.FieldValueMap;
 import org.hps.conditions.database.DatabaseConditionsManager;
 import org.hps.conditions.database.TableConstants;
 import org.hps.conditions.database.TableMetaData;
@@ -57,6 +58,15 @@
     File outputFile = null;
     Set<Integer> runs = new HashSet<Integer>();
     static DecimalFormat decimalFormat = new DecimalFormat("#.####");
+    String inputHitsCollectionName = "EcalReadoutHits";
+    
+    /**
+     * Set the RawTrackerHit collection of hits to be used for the calibration.
+     * @param inputHitsCollectionName The name of the input hits collection.
+     */
+    public void setInputHitsCollectionName(String inputHitsCollectionName) {
+        this.inputHitsCollectionName = inputHitsCollectionName;
+    }
     
     /**
      * Set whether to automatically load the conditions into the database.
@@ -113,8 +123,10 @@
      * Check that the run numbers are valid.
      */
     public void startOfData() {
-        if (runEnd < runStart) {
-            throw new IllegalArgumentException("The runEnd must be >= runStart.");
+        if (runStart != null && runEnd != null) {
+            if (runEnd < runStart) {
+                throw new IllegalArgumentException("The runEnd must be >= runStart.");
+            }
         }
     }
         
@@ -138,8 +150,8 @@
     @Override
     public void process(EventHeader event) {
         runs.add(event.getRunNumber());
-        if (event.hasCollection(RawTrackerHit.class, "EcalReadoutHits")) {
-            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, "EcalReadoutHits");
+        if (event.hasCollection(RawTrackerHit.class, inputHitsCollectionName)) {
+            List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputHitsCollectionName);
             for (RawTrackerHit hit : hits) {
                 EcalChannel channel = ecalConditions.getChannelCollection().findGeometric(hit.getCellID());
                 if (channel != null) {
@@ -149,6 +161,9 @@
                     }
                 }
             }
+        } else {
+            // If the input collection does not exist in the event, this is considered a fatal error.
+            throw new RuntimeException("The collection " + this.inputHitsCollectionName + " does not exist in the event.");
         }
     }
     
@@ -240,9 +255,18 @@
     private void writeToFile(EcalCalibrationCollection calibrations, String fieldNames) {
         FileWriter writer = null;
         try {
-            writer = new FileWriter(outputFile);
-            writer.write(fieldNames);
-            writer.write(calibrations.toString());
+            writer = new FileWriter(outputFile); 
+            StringBuffer buff = new StringBuffer(fieldNames);
+            buff.append('\n');
+            for (EcalCalibration calibration : calibrations) {
+                FieldValueMap fieldValues = calibration.getFieldValues();
+                for (String field : fieldValues.keySet()) {
+                    buff.append(fieldValues.get(field) + " ");
+                }
+                buff.setLength(buff.length() - 1);
+                buff.append('\n');
+            }            
+            writer.write(buff.toString());
         } catch (IOException e) {
             throw new RuntimeException("There was a problem writing to the output file.", e);
         } finally {

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