Print

Print


Author: [log in to unmask]
Date: Sun Jun 21 11:26:28 2015
New Revision: 3174

Log:
allowing reading of ecal gains from file

Added:
    java/branches/HPSJAVA-ECALGAINCALIB/steering-files/src/main/resources/org/hps/steering/users/baltzell/EngRun2015EcalOnly_GainFile.lcsim
Modified:
    java/branches/HPSJAVA-ECALGAINCALIB/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java
    java/branches/HPSJAVA-ECALGAINCALIB/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java

Modified: java/branches/HPSJAVA-ECALGAINCALIB/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java
 =============================================================================
--- java/branches/HPSJAVA-ECALGAINCALIB/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java	(original)
+++ java/branches/HPSJAVA-ECALGAINCALIB/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java	Sun Jun 21 11:26:28 2015
@@ -4,7 +4,11 @@
 
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.hps.conditions.database.DatabaseConditionsManager;
@@ -51,6 +55,42 @@
  */
 public class EcalRawConverter {
 
+    private Map<Integer,Double> gainFileGains = new HashMap<Integer,Double>();
+    public String gainFileName = null;
+    
+    private void readGainFile() {
+        System.out.println("Reading ECal Gains from:  "+gainFileName);
+        File file = new File(gainFileName);
+        String content=null;
+        try {
+            FileReader reader = new FileReader(file);
+            char[] chars = new char[(int) file.length()];
+            reader.read(chars);
+            content = new String(chars);
+            reader.close();
+            String lines[]=content.split("\n");
+            int nlines = 0;
+            for (String line : lines) {
+                String columns[] = line.split(" ");
+                if (nlines++ > 0) {
+                    final int channelid = Integer.valueOf(columns[0]);
+                    final double gain = Double.valueOf(columns[1]);
+                    if (gainFileGains.containsKey(channelid)) {
+                        System.err.println("Duplicate Entries in ECal Gain File.");
+                        System.exit(2);
+                    }
+                    gainFileGains.put(channelid,gain);
+                }
+            }
+            if (nlines != 442+1) {
+                System.err.println("Invalid Gain File.");
+                System.exit(3);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+    
     private boolean useTimeWalkCorrection = false;
     private boolean useRunningPedestal = false;
     private boolean constantGain = false;
@@ -111,6 +151,7 @@
     private EcalConditions ecalConditions = null;
 
     public EcalRawConverter() {
+        
     	// Track changes in the DAQ configuration.
     	ConfigurationManager.addActionListener(new ActionListener() {
 			@Override
@@ -565,7 +606,11 @@
         if(useDAQConfig) {
         	//float gain = ConfigurationManager.getInstance().getFADCConfig().getGain(ecalConditions.getChannelCollection().findGeometric(cellID));
         	return config.getGain(cellID) * adcSum * EcalUtils.MeV;
-        }  else if(use2014Gain) {
+        } else if (gainFileName!=null) {
+            System.err.println(findChannelId(cellID)+" "+gainFileGains.get(findChannelId(cellID))); 
+            return gainFileGains.get(findChannelId(cellID)) * adcSum * EcalUtils.MeV; //gain is defined as MeV/integrated ADC
+        }
+        else if(use2014Gain) {
             if (constantGain) {
                 return adcSum * EcalUtils.gainFactor * EcalUtils.ecalReadoutPeriod;
             } else {
@@ -589,6 +634,7 @@
         // ECAL combined conditions object.
         ecalConditions = DatabaseConditionsManager.getInstance().getEcalConditions();
         pulseFitter.setDetector(detector);
+        if (gainFileName != null) readGainFile();
     }
 
     /**
@@ -600,5 +646,8 @@
     public EcalChannelConstants findChannel(long cellID) {
         return ecalConditions.getChannelConstants(ecalConditions.getChannelCollection().findGeometric(cellID));
     }
+    public Integer findChannelId(long cellID) {
+        return ecalConditions.getChannelCollection().findGeometric(cellID).getChannelId();
+    }
     
 }

Modified: java/branches/HPSJAVA-ECALGAINCALIB/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java
 =============================================================================
--- java/branches/HPSJAVA-ECALGAINCALIB/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java	(original)
+++ java/branches/HPSJAVA-ECALGAINCALIB/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java	Sun Jun 21 11:26:28 2015
@@ -47,6 +47,8 @@
         converter = new EcalRawConverter();
     }
 
+    public void setGainFile(String filename) { converter.gainFileName=filename; }
+    
     /*
      * Set to <code>true</code> to use pulse fitting instead of arithmetic integration:<br/>
      */

Added: java/branches/HPSJAVA-ECALGAINCALIB/steering-files/src/main/resources/org/hps/steering/users/baltzell/EngRun2015EcalOnly_GainFile.lcsim
 =============================================================================
--- java/branches/HPSJAVA-ECALGAINCALIB/steering-files/src/main/resources/org/hps/steering/users/baltzell/EngRun2015EcalOnly_GainFile.lcsim	(added)
+++ java/branches/HPSJAVA-ECALGAINCALIB/steering-files/src/main/resources/org/hps/steering/users/baltzell/EngRun2015EcalOnly_GainFile.lcsim	Sun Jun 21 11:26:28 2015
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
+<!-- 
+  Offline reconstruction for 2015 (engineering run with SVT+ECal) data.
+  @author Sho Uemura <[log in to unmask]>
+-->
+    <execute>
+        <driver name="EventMarkerDriver"/>
+        <!--<driver name="RawTrackerHitSensorSetup"/>-->
+        <!--<driver name="RawTrackerHitFitterDriver" />-->
+        <!--<driver name="TrackerHitDriver"/>-->
+        <!--<driver name="HelicalTrackHitDriver"/>-->
+        <!--<driver name="TrackerReconDriver"/>-->
+        <driver name="EcalRunningPedestal"/>
+        <driver name="EcalRawConverter" />
+        <driver name="ReconClusterer" />
+        <driver name="GTPOnlineClusterer" />
+        <!--<driver name="CopyCluster" />-->
+        <!--<driver name="ReconParticle" />--> 
+        <!--<driver name="TrackDataDriver" />-->             
+        <!--<driver name="GBLDriver"/>-->
+        <driver name="LCIOWriter"/>
+        <driver name="CleanupDriver"/>
+    </execute>    
+    <drivers>    
+        <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver">
+            <eventInterval>1000</eventInterval>
+        </driver>        
+        <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup">
+            <readoutCollections>SVTRawTrackerHits</readoutCollections>
+        </driver>
+        <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver">
+            <fitAlgorithm>Pileup</fitAlgorithm>
+            <useTimestamps>false</useTimestamps>
+            <correctTimeOffset>true</correctTimeOffset>
+            <correctT0Shift>true</correctT0Shift>
+            <useTruthTime>false</useTruthTime>
+            <subtractTOF>true</subtractTOF>
+            <subtractTriggerTime>true</subtractTriggerTime>
+            <correctChanT0>true</correctChanT0>
+            <debug>false</debug>
+        </driver>
+        <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver">
+            <neighborDeltaT>8.0</neighborDeltaT>
+        </driver>
+        <driver name="HelicalTrackHitDriver" type="org.hps.recon.tracking.HelicalTrackHitDriver">
+            <debug>false</debug>
+            <clusterTimeCut>12.0</clusterTimeCut>
+            <maxDt>16.0</maxDt>
+            <clusterAmplitudeCut>400.0</clusterAmplitudeCut>
+        </driver>
+        <driver name="TrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver">
+            <strategyResource>HPS-Full.xml</strategyResource>
+            <debug>false</debug>
+            <rmsTimeCut>8.0</rmsTimeCut>
+        </driver>        
+        <driver name="GBLDriver" type="org.hps.recon.tracking.gbl.GBLOutputDriver">
+            <debug>0</debug>
+            <isMC>false</isMC>
+            <gblFileName></gblFileName>
+        </driver>
+        <driver name="EcalRunningPedestal" type="org.hps.recon.ecal.EcalRunningPedestalDriver">
+            <logLevel>CONFIG</logLevel>
+            <minLookbackEvents>5</minLookbackEvents>
+            <maxLookbackEvents>40</maxLookbackEvents>
+        </driver>
+        <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver">
+            <ecalCollectionName>EcalCalHits</ecalCollectionName>
+            <use2014Gain>false</use2014Gain>
+            <useTimestamps>false</useTimestamps>
+            <useTruthTime>false</useTruthTime>
+            <useRunningPedestal>true</useRunningPedestal>
+            <useTimeWalkCorrection>false</useTimeWalkCorrection>
+            <emulateFirmware>true</emulateFirmware>
+            <emulateMode7>true</emulateMode7>
+            <leadingEdgeThreshold>12</leadingEdgeThreshold>
+            <nsa>100</nsa>
+            <nsb>20</nsb>
+            <nPeak>3</nPeak>
+            <useFit>true</useFit>
+            <fixShapeParameter>true</fixShapeParameter>
+            <gainFile>ecalGains.txt</gainFile>
+        </driver>       
+        <driver name="ReconClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver">
+            <logLevel>WARNING</logLevel>
+            <outputClusterCollectionName>EcalClusters</outputClusterCollectionName>
+            <hitEnergyThreshold>0.0075</hitEnergyThreshold>
+            <seedEnergyThreshold>0.050</seedEnergyThreshold> 
+            <clusterEnergyThreshold>0.100</clusterEnergyThreshold>
+            <minTime>0.0</minTime>
+            <timeWindow>25.0</timeWindow>
+            <useTimeCut>true</useTimeCut>
+            <writeRejectedHitCollection>false</writeRejectedHitCollection>
+        </driver>
+        <driver name="GTPOnlineClusterer" type="org.hps.recon.ecal.cluster.ClusterDriver">
+            <logLevel>WARNING</logLevel>
+            <clustererName>GTPOnlineClusterer</clustererName>
+            <outputClusterCollectionName>EcalClustersGTP</outputClusterCollectionName>
+            <!-- seedMinEnergy -->
+            <cuts>0.100</cuts>
+        </driver> 
+        <driver name="CopyCluster" type="org.hps.recon.ecal.cluster.CopyClusterCollectionDriver">
+            <inputCollectionName>EcalClusters</inputCollectionName>
+            <outputCollectionName>EcalClustersCorr</outputCollectionName>
+    		<storeHits>true</storeHits>
+        </driver>
+        <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver">  
+            <ecalClusterCollectionName>EcalClustersCorr</ecalClusterCollectionName>        
+        </driver>
+        <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver" />
+        <driver name="LCIOWriter" type="org.lcsim.util.loop.LCIODriver">
+            <outputFilePath>${outputFile}.slcio</outputFilePath>
+        </driver>
+        <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"/>
+        <driver name="AidaSaveDriver" type="org.lcsim.job.AidaSaveDriver">
+            <outputFileName>${outputFile}.root</outputFileName>
+        </driver>
+    </drivers>
+</lcsim>