Main INDEX
Monthly INDEX
PREV
NEXT
User name Moffit
Log entry time 04:14:13 on June29,2004
Entry number 127320
keyword=Restarted CODA after 2521. Changed crl.
Restarted CODA after run 2521. Did this because I've changed part of
the CODA Readout List (crl) in hopes of diagnosing a possible problem
with the vxWorks random number generator (rand()).
I've noticed, looking at runs since run 2000, that there are periods
in which dacnoise does not change. This has happened to at least 40
runs... and the periods that it is off varies from 5k events... to
100k events. It doesn't seem to correspond to any specific types of
runs (parityscan, production, optics, cosmics, other).
Random Number Generation for Dacnoise:
o Since a floating point operation cannot be done during an ISR, an
array of random numbers is generated at the beginning of each run
(during the "prestart" sequence). This array is a set of 2M unsigned
shorts (4 MBytes, I think).
algorithm:
for (j=0;j<2000000;j++) {
/* Generate random integers from 2048 to 63488 */
ranny[j] = 2048 + (unsigned short) (61440.0*rand()/(32768+1.0));
}
o During each event, one of these array values are fed into each
ADC DACnoise register (this register is write only... so we readout
the array value into the datastream. We haven't seen any problem
with regard to this).
The trouble we're observing, is that 2047 or 2048 is repeatedly
written to the ADCs for several thousands of events. This seems to
suggest a problem with the number returned by rand().
The new algorithm (which may increase the amount of time spent in
"prestart"):
for (j=0;j<2000000;j++) {
/* Generate random integers from 2048 to 63488 */
tmp_rand = (unsigned short) (61440.0*rand()/(32768+1.0));
while(tmp_rand==0 || tmp_rand==-1) {
tmp_rand = (unsigned short) (61440.0*rand()/(32768+1.0));
}
ranny[j] = 2048 + tmp_rand;
}
With this change... we'll no longer see any dacnoise values of 2048.
I hope this hack will get around this rand() problem for now.