<%@ LANGUAGE="VBScript" %> <% start_time = Time %> Calibration Measurement <% ' ' Get the two ROWID's for the measurement, the outside routine will determine which ones ! ' Dim Rowid(1) Dim Wurst(1) Dim Channel(1536) Dim Slope(1536) Dim Logdate(1) Dim Description(1) Dim Comments(1) Dim Nchans(1) For i=0 To 1 Rowid(i)="-" Wurst(i)=-1 Logdate(i)=" " Description(i)=" " Comments(i)=" " Nchans(i)=" " Next nrows=0 If Request("REQ_ROWID_0")<>"" And Request("REQ_ROWID_0")<>"-" Then Rowid(nrows)=Request("REQ_ROWID_0") nrows=nrows+1 End If If Request("REQ_ROWID_1")<>"" And Request("REQ_ROWID_1")<>"-" Then Rowid(nrows)=Request("REQ_ROWID_1") nrows=nrows+1 End If ' gsfs added lines to read xmin, xmax, ymin, ymax 10/31/00 If Not IsEmpty(Request("xmin")) Then xmin = CDbl(Request("xmin")) End If If Not IsEmpty(Request("xmax")) Then xmax = CDbl(Request("xmax")) End If If Not IsEmpty(Request("ymin")) Then ymin = CDbl(Request("ymin")) End If If Not IsEmpty(Request("ymax")) Then ymax = CDbl(Request("ymax")) End If If Not IsEmpty(Request("xtic")) Then xtic = CDbl(Request("xtic")) End If If Not IsEmpty(Request("ytic")) Then ytic = CDbl(Request("ytic")) End If ' End of gsfs addition nrows=nrows-1 ' following lines added by gsfs 6/6/2000 If Not IsEmpty(Request("ymax")) Then ymax = CDbl(Request("ymax")) End If If Not IsEmpty(Request("ymin")) Then ymin = CDbl(Request("ymin")) End If ' End of insertion If nrows>-1 Then Set Connection = Server.CreateObject("ADODB.Connection") Connection.Mode = adModeRead Connection.Open phdb_rd ' ' Get number of channels in a string ' ' SQLStmtx = "select max(ahc.wurst_id) istring,max(chip_type) onechip,max(chip_type)*count(wurst_read_pos) nstring" SQLStmtx = SQLStmtx & " from assembly.asm_hybrid_chip ahc,assembly.asm_hybrid_id ahi,assembly.asm_hybrid_log ahl " SQLStmtx = SQLStmtx & " where ahl.ROWID = '" & CStr(Rowid(0)) & "'" SQLStmtx = SQLStmtx & " and ahl.HYBRID_ID=ahi.HYBRID_ID" SQLStmtx = SQLStmtx & " and ahc.hybrid_type=ahi.hybrid_type" SQLStmtx = SQLStmtx & " group by ahc.hybrid_type,ahc.wurst_id" Set RSx = Connection.Execute(SQLStmtx) kstring=0 Do While Not RSx.EOF nstring=Cint(RSx("nstring")) onechip=Cint(RSx("onechip")) kstring=kstring+1 RSx.MoveNext Loop SQLStmt0 = "select ahl.HYBRID_ID,to_char(LOGDATE,'MM/DD/YYYY HH24:MI:SS')LDATE,ahl.WURST_ID,CONFIG,ahl.COMMENTS,aha.DESCRIPTION from ASSEMBLY.ASM_HYBRID_LOG ahl,ASSEMBLY.ASM_HYBRID_ACTION aha " SQLStmt2 = "select ahl.WURST_ID,sm.MEASUREMENT_ID,sml.DESCRIPTION,sm.MEASUREMENT_VALUE value from ASSEMBLY.ASM_HYBRID_LOG ahl,ASSEMBLY.STRING_MEASUREMENT sm, ASSEMBLY.STRING_MEASUREMENT_LIST sml" ' ' Do SQL line fit preparation ' SQLStmt1 = "SELECT ahl.WURST_ID*" & CStr(nstring) & "+scm.CHANNELNUM ch,count(scm.MEASUREMENT_INP) nn,sum(scm.MEASUREMENT_INP) aa," SQLStmt1 = SQLStmt1 & "sum(scm.MEASUREMENT_INP*scm.MEASUREMENT_INP) bb,sum(scm.MEASUREMENT_OUT) cc," SQLStmt1 = SQLStmt1 & "sum(scm.MEASUREMENT_OUT*scm.MEASUREMENT_INP) dd" SQLStmt1 = SQLStmt1 & " from ASSEMBLY.STRING_CHANNEL_MEASUREMENT scm,ASSEMBLY.ASM_HYBRID_LOG ahl " If nrows=0 Then ' ' Just one string ' SQLStmt0 = SQLStmt0 & " where ahl.ROWID = '" & CStr(Rowid(0)) & "'" SQLStmt1 = SQLStmt1 & " where ahl.ROWID = '" & CStr(Rowid(0)) & "'" SQLStmt2 = SQLStmt2 & " where ahl.ROWID = '" & CStr(Rowid(0)) & "'" Else ' ' Two strings ' SQLStmt0 = SQLStmt0 & " where (ahl.ROWID = '" & CStr(Rowid(0)) & "' or ahl.ROWID = '" & CStr(Rowid(1)) & "') " SQLStmt1 = SQLStmt1 & " where (ahl.ROWID = '" & CStr(Rowid(0)) & "' or ahl.ROWID = '" & CStr(Rowid(1)) & "') " SQLStmt2 = SQLStmt2 & " where (ahl.ROWID = '" & CStr(Rowid(0)) & "' or ahl.ROWID = '" & CStr(Rowid(1)) & "') " End If SQLStmt0 = SQLStmt0 & " and ahl.ACTION=aha.ACTION order by ahl.WURST_ID" SQLStmt1 = SQLStmt1 & " and ahl.LOGDATE=scm.STARTDATE and scm.MEASUREMENT_ID = 'SIGCAL' and scm.MEASUREMENT_INP<1000.0 group by ahl.WURST_ID,scm.CHANNELNUM order by ahl.WURST_ID,scm.CHANNELNUM" SQLStmt2 = SQLStmt2 & " and ahl.LOGDATE=sm.STARTDATE and sm.MEASUREMENT_ID=sml.MEASUREMENT_ID order by sm.MEASUREMENT_ID,ahl.WURST_ID" Set RS0 = Connection.Execute(SQLStmt0) Set RS2 = Connection.Execute(SQLStmt2) %> <% If Not RS0.EoF Then %>

Gain Calibration HYBRID ID : <%= RS0("HYBRID_ID")%>

<% End If Do While Not RS0.EoF wurst_id=CInt(RS0("WURST_ID")) logdate(wurst_id)=RS0("LDATE") description(wurst_id)=RS0("DESCRIPTION") comments(wurst_id)=RS0("COMMENTS") nchans(wurst_id)=nstring RS0.MoveNext Loop %> <% ' ' Do heavy duty database extraction here ' Set RS1 = Connection.Execute(SQLStmt1) gain_average=0 npoints=0 Do While Not RS1.EoF ' ' Calculate calibration slope ' Channel(npoints)=CInt(RS1("CH")) ' nn=CDbl(RS1("NN")) aa=CDbl(RS1("AA")) bb=CDbl(RS1("BB")) cc=CDbl(RS1("CC")) dd=CDbl(RS1("DD")) ' If (aa*aa-nn*bb <>0) Then ' ' to get gain in mV/pF multiply by 21/2 ' Slope(npoints)=10.5*(nn*dd-aa*cc)/(nn*bb-aa*aa) gain_average=gain_average+Slope(npoints) Else Slope(npoints)=0. End If npoints=npoints+1 RS1.MoveNext Loop npoints=npoints-1 %> <% start_time = Time %> <% ' ' Prepare plot ' seed=-(second(now())+60*minute(now())+3600*hour(now())+3600*24*day(now())) filename="sigcal" & cstr(int(100000.*rnd(seed))) & ".jpg" filename_full=ph_image_directory & filename %> <% Dim Chart Dim Color(8) Color(0) = vbRed Color(1) = vbBlue Color(2) = vbYellow Color(3) = vbGreen Color(4)= vbMagenta Color(5)= vbCyan Color(6)= vbWhite Color(7)= vbBlack rem ********************************************************************** rem * Instantiate the Chart component rem ********************************************************************** Set Chart = Server.CreateObject ("ASPChart.Chart") rem ********************************************************************** rem * Create x Array rem ********************************************************************** Chart.AddSeries 5 Chart.SeriesTitle = "Channel Gain" Chart.LineWidth = 1 Chart.Stairs = True Chart.SeriesInLegend = true For ipoints=0 To npoints Chart.AddXY Channel(ipoints),Slope(ipoints),"",Color(1) Next rem ********************************************************************** rem * Add and format the title rem ********************************************************************** Chart.ChartTitleFont.Size = 16 Chart.ChartTitleFont.Name = "Arial" Chart.ChartTitleFont.Italic = true Chart.ChartTitleFont.Bold = true Chart.View3D = false Chart.LegendVisible = false Chart.LegendStyle = cSeries Chart.AxisGridLines = true Chart.Frame = false Chart.BottomAxisIncrement = onechip rem Chart.LeftAxisIncrement = 0.1 ' gsfs added xtic, ytic option If IsEmpty(xtic) Then Chart.BottomAxisIncrement = onechip Else Chart.BottomAxisIncrement = xtic End If If IsEmpty(ytic) Then Chart.LeftAxisIncrement = 10. Else Chart.LeftAxisIncrement = ytic End If rem ********************************************************************** rem * Remove the OuterBevel, add a gradient fill to chart panel rem ********************************************************************** Chart.BevelOuter = 0 rem Chart.GradientVisible = true rem Chart.GradientStartColor = vbWhite rem Chart.GradientEndColor = vbYellow Chart.PanelColor = Color(6) rem ********************************************************************** rem * Set the Width and Height of the image rem ********************************************************************** Chart.Height = 400 Chart.Width = 600 Chart.HorizAxisMax = kstring*nstring+1+8 Chart.HorizAxisMin = -8. ' Following lines changed gsfs 6/6/2000 If IsEmpty(ymax) Then Chart.VertAxisMax = 10.0 Else Chart.VertAxisMax = ymax End If If IsEmpty(ymin) Then Chart.VertAxisMin = 0. Else Chart.VertAxisMin = ymin End If Chart.LeftAxisIncrement = 0.2 If IsEmpty(xmin) Then Chart.HorizAxisMin = -8 Else Chart.HorizAxisMin = xmin End If If IsEmpty(xmax) Then Chart.HorizAxisMax = kstring*nstring+1+8 Else Chart.HorizAxisMax = xmax End If ' End of changes Chart.AddAxisLabel 1 , "Gain [mV/fC]" Chart.AddAxisLabel 2 , CStr(nstring) & "*String+Channel" rem ********************************************************************** rem * Set the filename, save the image and write the image tag rem ********************************************************************** Chart.FileName = filename_full Chart.SaveChart line="
<% old_test="XXXXXX" Do While Not RS2.Eof If old_test<>CStr(RS2("MEASUREMENT_ID")) Then If old_test<>"XXXXXX" Then 'finish previous row %> <% End If old_test=CStr(RS2("MEASUREMENT_ID")) %> <% If CInt(RS2("WURST_ID"))=0 Then %> <% Else %> <% End If Else If CInt(RS2("WURST_ID"))=1 Then %> <% Else %> <% End If End If %> <% RS2.MoveNext Loop %>
 

String_0

String_1

Test Date <%=logdate(0)%> <%=logdate(1)%>
Test Type <%=Description(0)%> <%=Description(1)%>
Channels <%=Nchans(0)%> <%=Nchans(1)%>
Comments <%=comments(0)%> <%=comments(1)%>
<%=RS2("DESCRIPTION")%> <%=RS2("VALUE")%>   <%=RS2("VALUE")%> <%=RS2("VALUE")%> Error: Table logic messed up
" Response.Write (line) rem ********************************************************************** rem * Destroy the object rem ********************************************************************** Set Chart = nothing ' Database is not needed anymore ! Connection.Close %> <% Else %> Both ROWID's are empty ! <%End If%>
<% If npoints>0 Then gain_average=gain_average/npoints Else gain_average=0 End If %>

Average Gain is <%=Round(gain_average,2)%> [mV/fC]

Channels with gain less than 70% of Average Gain:

<% ' ' list broken channels ' nbroken=0 For ipoints=0 To npoints If Slope(ipoints)<0.7*Gain_Average Then nbroken=nbroken+1 %> <% End If Next %>
String Channel Plot coordinate Slope
<%=(ipoints\nstring)%> <%=(ipoints Mod nstring)%> <%=ipoints%> <%=Round(Slope(ipoints),1)%>

There are total of <%=nbroken%> broken channels