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

HPS-SVN May 2015

Subject:

r3005 - /java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java

From:

[log in to unmask]

Reply-To:

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

Date:

Wed, 20 May 2015 19:20:25 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (124 lines)

Author: [log in to unmask]
Date: Wed May 20 12:20:14 2015
New Revision: 3005

Log:
mode 7 timing resolution corrected

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

Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java
 =============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java	(original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java	Wed May 20 12:20:14 2015
@@ -27,6 +27,7 @@
  * @author Sho Uemura <[log in to unmask]>
  * @author Andrea Celentano <[log in to unmask]>
  * @author Nathan Baltzell <[log in to unmask]>
+ * @author Holly Szumila <[log in to unmask]>
  *
  * baltzell:  New in 2015:  (default behavior is still unchanged)
  *
@@ -287,7 +288,7 @@
      */
     public double[] convertWaveformToPulse(RawTrackerHit hit,int thresholdCrossing,boolean mode7) {
         short samples[] = hit.getADCValues();
-        
+        //System.out.println("NewEvent");
         // choose integration range:
         int firstSample,lastSample;
         if ((NSA+NSB)/nsPerSample >= samples.length) {
@@ -303,7 +304,10 @@
         double minADC=0;
         for (int jj=0; jj<4; jj++) minADC += samples[jj];
         // does the firmware's conversion of min to int occur before or after time calculation?  undocumented.
-        minADC=(int)(minADC/4); 
+        //minADC=(int)(minADC/4); 
+        minADC = (minADC/4);
+        
+        //System.out.println("Avg pedestal:\t"+minADC);
         
         // mode-7's max pulse height:
         double maxADC=0;
@@ -319,43 +323,56 @@
             
             // integrate pulse:
             sumADC += samples[jj];
-           
+        	}
+        
             // find pulse maximum:
-            if (jj>firstSample && jj<samples.length-5) { // The "5" here is a firmware constant.
-                if (samples[jj+1]<samples[jj]) {
+            //if (jj>firstSample && jj<samples.length-5) { // The "5" here is a firmware constant.
+            for (int jj=thresholdCrossing; jj<samples.length-5; jj++) { // The "5" here is a firmware constant.
+            	if (samples[jj+1]<samples[jj]){ 
                     sampleMaxADC=jj;
                     maxADC=samples[jj];
+                    break;                
                 }
             }
-        }
-       
+        
+
         // pulse time with 4ns resolution:
         double pulseTime=thresholdCrossing*nsPerSample;
         
         // calculate Mode-7 high-resolution time:
         if (mode7) {
-            if (thresholdCrossing < 4) {
+        	if (thresholdCrossing < 4) {
                 // special case where firmware sets max to zero and time to 4ns time.
                 maxADC=0;
             }
             else if (maxADC>0) {
-                // linear interpolation between threshold crossing and
-                // pulse maximum to find time at pulse half-height:
-                double t0 = thresholdCrossing*nsPerSample;
-                double a0 = samples[thresholdCrossing];
-                double t1 = sampleMaxADC*nsPerSample;
-                double a1 = maxADC;
-                double slope = (a1-a0)/(t1-t0);
-                double halfMax = (maxADC+minADC)/2;
-                // this is not rigorously firmware-correct, need to find halfMax-crossing.
-                double tmpTime = t1 - (a1 - halfMax) / slope;
-                if (slope>0 && tmpTime>0) {
-                    pulseTime = tmpTime;
-                }
-                // else another special firmware case
-            }
-        }
-        
+            // linear interpolation between threshold crossing and
+            // pulse maximum to find time at pulse half-height:
+          
+            final double halfMax = (maxADC+minADC)/2;
+            int t0 = -1;
+            for (int ii=thresholdCrossing-1; ii<lastSample; ii++)
+            {
+              if (ii>=samples.length-1) break;
+              if (samples[ii]<=halfMax && samples[ii+1]>halfMax)
+              {
+                t0 = ii;
+                break;
+              }
+            }
+            if (t0 > 0)
+            {
+            	final int t1 = t0 + 1;
+              final int a0 = samples[t0];
+              final int a1 = samples[t1];
+              final double slope = (a1 - a0); // units = ADC/sample
+              final double yint = a1 - slope * t1;  // units = ADC 
+              pulseTime = ((halfMax - a0)/(a1-a0) + t0)* nsPerSample;
+              
+            }
+
+           }
+        }
         return new double []{pulseTime,sumADC,minADC,maxADC};
     }
    

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