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

HPS-SVN November 2015

Subject:

r3974 - /java/trunk/users/src/main/java/org/hps/users/baltzell/RfFitterDriver.java

From:

[log in to unmask]

Reply-To:

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

Date:

Mon, 23 Nov 2015 15:16:31 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (133 lines)

Author: [log in to unmask]
Date: Mon Nov 23 07:16:28 2015
New Revision: 3974

Log:
resolution matching c code

Modified:
    java/trunk/users/src/main/java/org/hps/users/baltzell/RfFitterDriver.java

Modified: java/trunk/users/src/main/java/org/hps/users/baltzell/RfFitterDriver.java
 =============================================================================
--- java/trunk/users/src/main/java/org/hps/users/baltzell/RfFitterDriver.java	(original)
+++ java/trunk/users/src/main/java/org/hps/users/baltzell/RfFitterDriver.java	Mon Nov 23 07:16:28 2015
@@ -64,9 +64,10 @@
 					foundRf=true;
 					times[ii] = fitPulse(hit);
 					if (ii==1){
+						
 						System.out.println(times[1]-times[0]);
 					}
-  				    
+					  				    
 					break;
 				}
 			}
@@ -93,40 +94,37 @@
 		double fitThresh[]={-999,-999};
 		double pedVal[]={-999,-999};
 		
-		//use this loop to look for bins containing the peaks (2-3 peaks)
-		for (int ii=4; ii<adcSamples.length-4; ii++) {
-			//after 2 peaks, stop looking for more
+		// Look for bins containing the peaks (2-3 peaks)
+		for (int ii=4; ii<adcSamples.length; ii++) {
+			// After 2 peaks, stop looking for more
 			if (iz==2){break;}
-			//System.out.println("nsamp:\t"+ii+"\t"+adcSamples[ii]+"\tplus 1:\t"+adcSamples[ii+1]+"\tminus 1:\t"+adcSamples[ii-1]);
-			if ((adcSamples[ii+1]>0) && (adcSamples[ii-1]>0) && (adcSamples[ii]>threshold) && ii>12){
-				//System.out.println("Passed 1st condition!\t"+iz);
-				if ((adcSamples[ii]>adcSamples[ii+1]) && (adcSamples[ii]>adcSamples[ii-1]) ){
-					//System.out.println("iz:\t"+iz);
-//						||((adcSamples[ii]==adcSamples[ii+1] && adcSamples[ii]>adcSamples[ii-1]))){//not in c code
+			if ((adcSamples[ii+1]>0) && (adcSamples[ii-1]>0) && (adcSamples[ii]>threshold) && ii>8){
+				if ((adcSamples[ii]>adcSamples[ii+1]) && (adcSamples[ii]>=adcSamples[ii-1]) ){
+					
 					peakBin[iz]=ii;
 					iz++;
 				}
 			}
 		}
 		
+		
 		int jj=0;
-		//choose peak closest to center of window (second peak, ik=1)
+		// Choose peak closest to center of window (second peak, ik=1)
 		final int ik=1;
 		pedVal[ik] = (adcSamples[peakBin[ik]-6]+adcSamples[peakBin[ik]-7]+adcSamples[peakBin[ik]-8]+adcSamples[peakBin[ik]-9])/4.0;
 		fitThresh[ik]= (adcSamples[peakBin[ik]]+pedVal[ik])/3.0;
-		
-		//calc initial values along the way, we find/fit 3 points:
+	
+		// Initial values: we find/fit 3 points:
 		double itime[] = {-999,-999,-999};
 		double ifadc[] = {-999,-999,-999};
-			
-		//find the points of the peak bin to peak bin-5 (look backwards to forwards)
+		
+		// Find the points of the peak bin to peak bin-5 
 		for (int ll=0; ll<5; ll++){	
 			if ((adcSamples[peakBin[ik]-5+ll]) > fitThresh[ik]){
-				//get one below fit threshold and two points above	
+				// One point is below fit threshold and two points are above	
 				if(jj==0 && (adcSamples[peakBin[ik]-6+ll] > pedVal[ik])){
 					final int zz=fitData.size();	
 					fitData.addPoint();
-					//System.out.println("fit points:\t"+zz+"\t"+(peakBin[ik]-6+ll)+"\t"+adcSamples[peakBin[ik]-6+ll]);
 					itime[zz] = peakBin[ik]-6+ll;
 					ifadc[zz] = adcSamples[peakBin[ik]-6+ll];
 					fitData.point(zz).coordinate(0).setValue(peakBin[ik]-6+ll);
@@ -137,42 +135,34 @@
 				}
 				final int zz=fitData.size();	
 				fitData.addPoint();
-				//System.out.println("fit points:\t"+zz+"\t"+(peakBin[ik]-5+ll)+"\t"+adcSamples[peakBin[ik]-5+ll]);
 				itime[zz] = peakBin[ik]-5+ll;
 				ifadc[zz] = adcSamples[peakBin[ik]-5+ll];
 				fitData.point(zz).coordinate(0).setValue(peakBin[ik]-5+ll);
 				fitData.point(zz).coordinate(1).setValue(adcSamples[peakBin[ik]-5+ll]);
 				fitData.point(zz).coordinate(1).setErrorMinus(NOISE);
 				fitData.point(zz).coordinate(1).setErrorPlus(NOISE);
-						
+					
 				jj++;
 				if (jj==3) {break;}					
 			}
 		}
-			
+		
 		double islope = ((double)(ifadc[2]-ifadc[0]))/(itime[2]-itime[0]);
 		double icept = ifadc[1] - islope*itime[1];
-		//System.out.println("initial parameters, icept:\t"+icept+"\t islope:\t"+islope+"\t itime:\t"+itime[1]);
-		// properly initialize fit parameters:
-		//fitFunction.setParameter("time",0.0);//itime[1]);
+		// Initialize fit parameters:
 		fitFunction.setParameter("intercept",icept);
 		fitFunction.setParameter("slope",islope);
-	
+
 		// this used to be turned on somewhere else on every event, dunno if it still is:
 		//Logger.getLogger("org.freehep.math.minuit").setLevel(Level.OFF);
-		
+	
 		IFitResult fitResults = fitter.fit(fitData,fitFunction);
 		
-		//choose to get the time value at this location on the fit:
+		// Read the time value at this location on the fit:
 		double halfVal = (adcSamples[peakBin[1]]+pedVal[1])/2.0;	
-		//System.out.println("Fit results:\t"+fitResults.fittedParameter("intercept")+"\t"+fitResults.fittedParameter("slope"));
-		//System.out.println("Half height:\t"+halfVal);
+	
 		return NSPERSAMPLE*(halfVal-fitResults.fittedParameter("intercept"))/fitResults.fittedParameter("slope");
+			
+	}
 		
-		
-	}
-	
-	
-	
-	
 }

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