Run IIb Find_DAC Notes ---------------------- 22-Dec-2005 Find_DAC is the algorithm which is used to seek a pedestal DAC control value to produce a desired target ADC zero energy response. In practice, the Run IIb L1CAL will use 50 counts of Zero Energy Response for the Raw ADC energy values (not to be confused with the Output Et Zero Energy Response which is set to 8 counts). Some of the ADF channel tests inject a sine wave into the ADF card, for which Find_DAC is used to seek a Zero Energy Response close to mid-scale, and a value of 490 ADC counts have been used to commission the cards. Find_DAC can be run while the BLS cables are connected to the ADF inputs, and must thus accomodate the typical trigger tower noise. Review of Find_DAC Steps: ------------------------ 1) Set the DAC Control value to zero -> push ADC zeresp up to max (still mid scale) KiDacMinValue 0 // should produce a Half-range Zeresp of ~ 505 KiZerespMaxOkLow 490 // lowest value acceptable for Max Zeresp ~ 3% off of 505 KiZerespMaxOkHigh 520 // highest value acceptable for Max Zeresp ~ 3% off of 505 if ( ( fAverage < (double) KiZerespMaxOkLow ) || ( fAverage > (double) KiZerespMaxOkHigh ) ) Message: " Warning: Failed Forcing Zeresp to highest: DAC = ..." 2) Set the DAC Control value to full scale -> push ADC zeresp down to zero KiDacMaxValue 4095 // should produce a Null Zeresp of 0 KfZerespMinOk 0.1 // highest value acceptable for a Low Zeresp = must be able to set to zero (but noise?) if ( fAverage > KfZerespMinOk ) Message: " Warning: Failed Forcing Zeresp to 0x0000 : DAC = ..." 3) Set the DAC Control value to low value -> set ADC zeresp to low value KiDacLowAdcValue 3500 // should produce a Low Zeresp around 25 Steps (1) and (2) were using the smaller sample size (100 entries) Steps (3) and above use the larger sample size (1,000 entries) as the results are used in computations. KiZerespLowOkLow 5 // lowest value acceptable for low-scale Zeresp ~ 3% of range off of 20 KiZerespLowOkHigh 35 // highest value acceptable for low-scale Zeresp ~ 3% of range off of 20 if ( ( fZerespLowAvr < (double) KiZerespLowOkLow ) || ( fZerespLowAvr > (double) KiZerespLowOkHigh ) ) Message: " Warning: Failed Forcing Zeresp to ~small : DAC ..." The problem here is that the DAC-to-ADC function is not linear in this range. If the KiDacLowAdcValue value fails to produce a >> 0 DAC value, the slope calculation will be flawed. 4) Set the DAC Control value to low value -> set ADC zeresp to mid range KiDacMidAdcValue 50 // should produce a High Zeresp around 500 KiZerespMidOkLow 485 // lowest value acceptable for mid-scale Zeresp ~ 3 % off of 500 KiZerespMidOkHigh 515 // highest value acceptable for mid-scale Zeresp ~ 3 % off of 500 if ( ( fZerespMidAvr < (double) KiZerespMidOkLow ) || ( fZerespMidAvr > (double) KiZerespMidOkHigh ) ) Message: " Warning: Failed Forcing Zeresp to ~middle: DAC = " 5) Compute DAC to ADC ratio Compute a measurement of the DAC to ADC ratio fDacToAdcRatioMeas = ( KiDacLowAdcValue - KiDacMidAdcValue ) / ( fZerespMidAvr - fZerespLowAvr ) ; KfDacToAdcRatioTyp 7.15 // Increasing the DAC by +7 increases the Zeresp by +1 KfDacToAdcRatioOkDiff 0.5 // Accepted Difference between Calculated and Typical DAC to ADC ratio if ( fabs ( fDacToAdcRatioMeas - KfDacToAdcRatioTyp ) > KfDacToAdcRatioOkDiff ) Message: " Warning: DAC to ADC Ratio Problem, " There is also a minimum hardcoded sanity check before allowing Find_DAC to proceed to verify that the Histogram Averages that were used to compute the slope had actually moved by a non-trivial amount. This was meant to catch crude problems where the DAC and ADCs are not really correlated. This could be replaced by a more serious and selective test. if ( fabs ( fZerespMidAvr - fZerespLowAvr ) <= 1.0 ) // disaster protection Message: " Aborting: Couldn't Compute DAC to ADC Ratio" 6) Scan a range of consecutive DAC Control value and pick best histogram 6.a) Scan range The Low ADC measurement plus the measured slope are enough to compute an initial guess close to the desired DAC control value. The test will then scan a number of consecutive DAC control values around this initial guess. Find_DAC currently scans 14 consecutive DAC Values, corresponding to about +/- 1 ADC counts (if the initial guess was on target) around the desired DAC zero energy response. KiTotHistoScanned 14 // How many histograms will be built around the target zeresp //Verify we computed a valid control value if ( ( uwScanDacValueStart >= KiDacMaxValue ) || ( uwScanDacValueStart <= KiDacMinValue ) ) Message: " Aborting: Illegal Computed DAC Value =... for Start of Scan" 6.b) Scan For each Histogram built, Find_DAC verifies that the Histogram average is within reason (i.e. no error programming the DAC) KfZerespCloseOk 2.0 // How close to the target zeresp ANY histogram has to be if ( ( fabs( fScanAverage[uwHistoNum] - (double) uwZerespGoal) > KfZerespCloseOk ) ) Message: " Average out of tolerance DAC= ..." There will also be an error_tag in the result file so that the operator will have to review this tower, accept or correct the value, and remove the message. 6.c) Pick "best" value While scanning, Find_DAC keeps track of the "best" histogram. Find_DAC has code to support two options - pick the histogram with the highest population in the target bin, - pick the population with average closest to the target value. 6.d) Success We say we succeeded if we selected an histogram other than the first or last one and we also make sure we got close enough to the target Zeresp KfZerespDiffOk 0.15 // How close to the target zeresp the BEST histogram needs to be if ( ( uwHistoChosen != 0 ) && ( uwHistoChosen != KiTotHistoScanned-1 ) && ( fabs( fScanAverage[uwHistoChosen] - (double) uwZerespGoal) < KfZerespDiffOk ) ) Message: " Picked Histo# ... DAC=... Avr=...Dev=...DevAvr= " The Trigger Tower is explicitely programmed with the DAC Control value just found 6.e) Failure If the verification in 6.d failed, Message: " Failed: No Satisfactory DAC Control Value" The Trigger Tower is explicitely programmed with the DAC Control value set for lowest zeresp -> will stand out in TT_ADC trigmon There will also be an error_tag in the result file so that the operator will have to review this tower, accept or correct the value, and remove the message. First System Wide Find_DAC Run of 16-Dec-2005 afternoon ------------------------------------------------------- It takes about 4+4 minutes to scan all 1280 EM+HD towers. Find_DAC encountered 3 problems. All 3 were caused by missing the lowish ADC value in step #3 and thus miscalculating the slope and DAC search window and starting the search from too low in ADC counts i.e. starting from too high in DAC value EM_TT(+ 6,13) ------------- Crate 0 Slot 21 eta +5:+8 phi 13:16 Card SN#B4 Card Commissioning Test on Thu-31-Mar-2005 already showed this problem for relative channel TT_EM(1,0) but it didn't prevent Find_DAC from finding a value for DAC=490 Now Processing EM_TT(+ 6,13) DAC= 0 -> Avr=497.08 Dev= 0.27 ( 92@497 8@498 ) DAC= 4095 -> Avr= 0.00 Dev= 0.00 ( 100@0 ) DAC= 3500 -> Avr= 0.00 Dev= 0.00 ( 1000@0 ) EM_TT(+ 6,13) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 0.00 DAC= 50 -> Avr=491.38 Dev= 0.49 ( 619@491 381@492 ) Computed DAC to ADC ratio = 7.02 DAC= 3452 -> Avr= 4.98 Dev= 0.13 ( 17@4 982@5 1@6 ) EM_TT(+ 6,13) Average out of tolerance DAC= 3452 Avr= 4.98 Dev= 0.13 DAC= 3451 -> Avr= 5.01 Dev= 0.11 ( 988@5 12@6 ) EM_TT(+ 6,13) Average out of tolerance DAC= 3451 Avr= 5.01 Dev= 0.11 DAC= 3450 -> Avr= 5.13 Dev= 0.34 ( 871@5 129@6 ) EM_TT(+ 6,13) Average out of tolerance DAC= 3450 Avr= 5.13 Dev= 0.34 DAC= 3449 -> Avr= 5.34 Dev= 0.47 ( 661@5 339@6 ) EM_TT(+ 6,13) Average out of tolerance DAC= 3449 Avr= 5.34 Dev= 0.47 DAC= 3448 -> Avr= 5.62 Dev= 0.48 ( 375@5 625@6 ) EM_TT(+ 6,13) Average out of tolerance DAC= 3448 Avr= 5.62 Dev= 0.48 DAC= 3447 -> Avr= 5.87 Dev= 0.34 ( 133@5 866@6 1@7 ) EM_TT(+ 6,13) Average out of tolerance DAC= 3447 Avr= 5.87 Dev= 0.34 DAC= 3446 -> Avr= 5.97 Dev= 0.17 ( 29@5 970@6 1@7 ) EM_TT(+ 6,13) Average out of tolerance DAC= 3446 Avr= 5.97 Dev= 0.17 DAC= 3445 -> Avr= 6.02 Dev= 0.17 ( 3@5 972@6 25@7 ) DAC= 3444 -> Avr= 6.10 Dev= 0.30 ( 899@6 101@7 ) DAC= 3443 -> Avr= 6.29 Dev= 0.45 ( 715@6 285@7 ) DAC= 3442 -> Avr= 6.53 Dev= 0.50 ( 468@6 532@7 ) DAC= 3441 -> Avr= 6.76 Dev= 0.42 ( 236@6 764@7 ) DAC= 3440 -> Avr= 6.92 Dev= 0.28 ( 85@6 914@7 1@8 ) DAC= 3439 -> Avr= 6.98 Dev= 0.16 ( 21@6 975@7 4@8 ) EM_TT(+ 6,13) Failed: No Satisfactory DAC Control Value EM_TT(+14,21) ------------- Crate 2 Slot 15 eta +13:+16 phi 21:24 Card SN#D6 Card Commissioning Test on Wed-06-Apr-2005 already showed this problem for relative channel TT_EM(1,0) but it didn't prevent Find_DAC from finding a value for DAC=490 Now Processing EM_TT(+14,21) DAC= 0 -> Avr=501.22 Dev= 0.41 ( 78@501 22@502 ) DAC= 4095 -> Avr= 0.00 Dev= 0.00 ( 100@0 ) DAC= 3500 -> Avr= 0.00 Dev= 0.00 ( 1000@0 ) EM_TT(+14,21) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 0.00 DAC= 50 -> Avr=495.83 Dev= 0.37 ( 168@495 832@496 ) Computed DAC to ADC ratio = 6.96 DAC= 3452 -> Avr= 5.84 Dev= 0.38 ( 165@5 832@6 3@7 ) EM_TT(+14,21) Average out of tolerance DAC= 3452 Avr= 5.84 Dev= 0.38 DAC= 3451 -> Avr= 5.99 Dev= 0.27 ( 39@5 928@6 33@7 ) EM_TT(+14,21) Average out of tolerance DAC= 3451 Avr= 5.99 Dev= 0.27 DAC= 3450 -> Avr= 6.11 Dev= 0.32 ( 5@5 884@6 111@7 ) DAC= 3449 -> Avr= 6.26 Dev= 0.44 ( 741@6 259@7 ) DAC= 3448 -> Avr= 6.43 Dev= 0.49 ( 571@6 429@7 ) DAC= 3447 -> Avr= 6.64 Dev= 0.48 ( 358@6 639@7 3@8 ) DAC= 3446 -> Avr= 6.81 Dev= 0.41 ( 195@6 799@7 6@8 ) DAC= 3445 -> Avr= 6.96 Dev= 0.33 ( 73@6 892@7 35@8 ) DAC= 3444 -> Avr= 7.08 Dev= 0.31 ( 11@6 896@7 93@8 ) DAC= 3443 -> Avr= 7.20 Dev= 0.40 ( 1@6 795@7 204@8 ) DAC= 3442 -> Avr= 7.36 Dev= 0.48 ( 640@7 360@8 ) DAC= 3441 -> Avr= 7.56 Dev= 0.50 ( 443@7 557@8 ) DAC= 3440 -> Avr= 7.76 Dev= 0.43 ( 239@7 761@8 ) DAC= 3439 -> Avr= 7.92 Dev= 0.28 ( 86@7 913@8 1@9 ) EM_TT(+14,21) Failed: No Satisfactory DAC Control Value EM_TT(- 4,22) ------------- Crate 0 Slot 15 eta -1:-4 phi 21:24 Card SN#A14 Card Commissioning Test on Thu-24-Mar-2005 already showed this problem for relative channel TT_EM(3,1) but it didn't prevent Find_DAC from finding a value for DAC=490 Now Processing EM_TT(- 4,22) DAC= 0 -> Avr=498.05 Dev= 0.22 ( 95@498 5@499 ) DAC= 4095 -> Avr= 0.00 Dev= 0.00 ( 100@0 ) DAC= 3500 -> Avr= 0.00 Dev= 0.00 ( 1000@0 ) EM_TT(- 4,22) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 0.00 DAC= 50 -> Avr=492.22 Dev= 0.42 ( 776@492 224@493 ) Computed DAC to ADC ratio = 7.01 DAC= 3452 -> Avr= 5.63 Dev= 0.48 ( 373@5 627@6 ) EM_TT(- 4,22) Average out of tolerance DAC= 3452 Avr= 5.63 Dev= 0.48 DAC= 3451 -> Avr= 5.89 Dev= 0.32 ( 112@5 888@6 ) EM_TT(- 4,22) Average out of tolerance DAC= 3451 Avr= 5.89 Dev= 0.32 DAC= 3450 -> Avr= 5.97 Dev= 0.16 ( 26@5 973@6 1@7 ) EM_TT(- 4,22) Average out of tolerance DAC= 3450 Avr= 5.97 Dev= 0.16 DAC= 3449 -> Avr= 6.00 Dev= 0.09 ( 4@5 992@6 4@7 ) DAC= 3448 -> Avr= 6.05 Dev= 0.21 ( 953@6 47@7 ) DAC= 3447 -> Avr= 6.17 Dev= 0.38 ( 825@6 175@7 ) DAC= 3446 -> Avr= 6.46 Dev= 0.50 ( 544@6 456@7 ) DAC= 3445 -> Avr= 6.74 Dev= 0.44 ( 261@6 739@7 ) DAC= 3444 -> Avr= 6.90 Dev= 0.30 ( 97@6 903@7 ) DAC= 3443 -> Avr= 6.98 Dev= 0.14 ( 19@6 979@7 2@8 ) DAC= 3442 -> Avr= 7.03 Dev= 0.19 ( 4@6 963@7 33@8 ) DAC= 3441 -> Avr= 7.13 Dev= 0.33 ( 872@7 128@8 ) DAC= 3440 -> Avr= 7.35 Dev= 0.48 ( 647@7 353@8 ) DAC= 3439 -> Avr= 7.62 Dev= 0.49 ( 385@7 615@8 ) EM_TT(- 4,22) Failed: No Satisfactory DAC Control Value List of all the warnings which occured in this run of Find_DAC: --------------------------------------------------------------- HD_TT(+ 3,21) Warning: Failed Forcing Zeresp to highest: DAC = 0 Avr = 523.79 HD_TT(+19,23) Warning: Failed Forcing Zeresp to highest: DAC = 0 Avr = 522.24 HD_TT(+ 3,21) Warning: Failed Forcing Zeresp to ~middle: DAC = 50 Avr = 517.70 HD_TT(+19,23) Warning: Failed Forcing Zeresp to ~middle: DAC = 50 Avr = 516.99 EM_TT(+ 2,22) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 2.98 EM_TT(+ 3, 7) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.33 EM_TT(+ 4, 2) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.91 EM_TT(+ 6, 3) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 2.58 EM_TT(+ 6,13) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 0.00 EM_TT(+ 6,28) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.12 EM_TT(+ 8,28) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 2.98 EM_TT(+10,29) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.52 EM_TT(+10,32) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.37 EM_TT(+13,14) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.27 EM_TT(+13,19) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 1.07 EM_TT(+13,31) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.96 EM_TT(+14,13) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 1.90 EM_TT(+14,21) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 0.00 EM_TT(+16, 5) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 2.08 EM_TT(+17, 7) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.59 EM_TT(+17,31) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 1.85 EM_TT(+18,12) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.94 EM_TT(+20,17) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.88 EM_TT(- 1, 2) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.00 EM_TT(- 4,22) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 0.00 EM_TT(- 6,12) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.51 EM_TT(- 6,27) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 1.63 EM_TT(- 7, 2) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.89 EM_TT(- 7,17) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 1.01 EM_TT(- 7,22) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.71 EM_TT(- 9,13) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.35 EM_TT(- 9,22) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.31 EM_TT(-11,12) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.99 EM_TT(-11,22) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 2.94 EM_TT(-11,24) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 5.00 EM_TT(-12,15) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.00 EM_TT(-13,10) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.02 EM_TT(-13,23) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.76 EM_TT(-14, 3) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.03 EM_TT(-14,12) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.61 EM_TT(-14,21) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.46 EM_TT(-15,22) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.98 EM_TT(-16,14) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 2.00 EM_TT(-16,22) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.71 EM_TT(-17,16) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 1.93 EM_TT(-18, 8) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.03 EM_TT(-19,13) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.17 EM_TT(-20, 6) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.17 EM_TT(-20,11) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.02 EM_TT(-20,14) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.45 HD_TT(+ 9,31) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.87 HD_TT(+14, 2) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 0.07 HD_TT(+14, 3) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 0.96 HD_TT(+14, 6) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.51 HD_TT(+14,19) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.99 HD_TT(+14,21) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 3.05 HD_TT(+18,17) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 0.22 HD_TT(+19,23) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 36.89 HD_TT(- 9,13) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 1.68 HD_TT(-13,31) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.86 HD_TT(-14, 9) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 4.16 HD_TT(-14,30) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 2.77 HD_TT(-20,26) Warning: Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 2.95 Additionally, all the towers suffering from "Failed Forcing Zeresp to ~small : DAC = 3500 Avr = 0.00" also received a number of messages "Average out of tolerance" while scanning successive DAC values. Possible Changes/Actions: ------------------------ A.1) Try to see if HD_TT(+ 3,21) and HD_TT(+19,23) can be brought back in the flock as they seem to produce consistently higher ADC values. A.2) Do nothing and put up with the warnings, since Find_DAC is still successful. A.3) Suppress the warnings by accepting these extremes Raise KiZerespMaxOkHigh from 520 to 525 Raise KiZerespMidOkHigh from 515 to 520 B.1) Try to see if EM_TT(+ 6,13) EM_TT(+14,21) and EM_TT(- 4,22) can be brought back in the flock as they seem to produce consistently lower ADC values. B.2) Changing the DAC value used to get a "low" ADC reading. The worst case seems to start the scanning range with a DAC of ~5 instead of ~7, so we could lower KiDacLowAdcValue by some 3*7=21 counts The allowable range should also be updated C.1) Suppress most of the "Failed Forcing Zeresp to ~small" warnings by widening the allowable low ADC value Lower KiZerespLowOkLow from 5 to ? C.2) Suppress most of the "Failed Forcing Zeresp to ~small" warnings by changing the DAC value used to get a "low" ADC reading, as in B.2.