Bug Summary

File:libraries/DAQ/Df250EmulatorAlgorithm_v3.cc
Location:line 336, column 10
Description:Division by zero

Annotated Source Code

1#include <DAQ/Df250EmulatorAlgorithm_v3.h>
2
3// corresponds to version 0x0C12 of the fADC250 firmware
4
5Df250EmulatorAlgorithm_v3::Df250EmulatorAlgorithm_v3(JEventLoop *loop){
6 // Enables forced use of default values
7 FORCE_DEFAULT = 0;
8
9 USE_CRATE_DEFAULTS = 1;
10
11 // Default values for the essential parameters
12 NSA_DEF = 20;
13 NSB_DEF = 5;
14 THR_DEF = 120;
15 NPED_DEF = 4;
16 MAXPED_DEF = 512;
17 NSAT_DEF = 2;
18
19 // DEBUG
20 NSA_DEF = 15;
21 NSB_DEF = 1;
22 THR_DEF = 108;
23 NPED_DEF = 4;
24 MAXPED_DEF = 512;
25 NSAT_DEF = 2;
26
27
28 // Set verbosity
29 VERBOSE = 0;
30
31 if(gPARMS){
32 gPARMS->SetDefaultParameter("EMULATION250:USE_CRATE_DEFAULTS", USE_CRATE_DEFAULTS,"Set to >0 to force use of crate-dependent default values");
33 gPARMS->SetDefaultParameter("EMULATION250:FORCE_DEFAULT", FORCE_DEFAULT,"Set to >0 to force use of default values");
34 gPARMS->SetDefaultParameter("EMULATION250:NSA", NSA_DEF,"Set NSA for firmware emulation, will be overwritten by BORConfig if present");
35 gPARMS->SetDefaultParameter("EMULATION250:NSB", NSB_DEF,"Set NSB for firmware emulation, will be overwritten by BORConfig if present");
36 gPARMS->SetDefaultParameter("EMULATION250:THR", THR_DEF,"Set threshold for firmware emulation, will be overwritten by BORConfig if present");
37 gPARMS->SetDefaultParameter("EMULATION250:NPED", NPED_DEF,"Set NPED for firmware emulation, will be overwritten by BORConfig if present");
38 gPARMS->SetDefaultParameter("EMULATION250:MAXPED", MAXPED_DEF,"Set MAXPED for firmware emulation, will be overwritten by BORConfig if present");
39 gPARMS->SetDefaultParameter("EMULATION250:NSAT", NSAT_DEF,"Set NSAT for firmware emulation, will be overwritten by BORConfig if present");
40 gPARMS->SetDefaultParameter("EMULATION250:VERBOSE", VERBOSE,"Set verbosity for f250 emulation");
41 }
42}
43
44void Df250EmulatorAlgorithm_v3::EmulateFirmware(const Df250WindowRawData* rawData,
45 std::vector<Df250PulseData*> &pdat_objs)
46{
47 // This is the main routine called by JEventSource_EVIO::GetObjects() and serves as the entry point for the code.
48 if (VERBOSE > 0) {
1
Taking false branch
49 jout << " Df250EmulatorAlgorithm_v3::EmulateFirmware ==> Starting emulation <==" << endl;
50 jout << "rocid : " << rawData->rocid << " slot: " << rawData->slot << " channel: " << rawData->channel << endl;
51 }
52
53 // First check that we have window raw data available
54 if (rawData == NULL__null) {
2
Taking false branch
55 jerr << " ERROR: Df250EmulatorAlgorithm_v3::EmulateFirmware - raw sample data is missing" << endl;
56 jerr << " Contact mstaib@jlab.org" << endl;
57 return;
58 }
59 if (rawData->samples.size() == 0) {
3
Taking false branch
60 jerr << " ERROR: Df250EmulatorAlgorithm_v3::EmulateFirmware - raw sample data has zero size" << endl;
61 jerr << "rocid : " << rawData->rocid << " slot: " << rawData->slot << " channel: " << rawData->channel << endl;
62 //jerr << " Contact mstaib@jlab.org" << endl;
63 return;
64 }
65
66 // We need the channel number to get the threshold
67 uint32_t channel = rawData->channel;
68
69 // First grab the config objects from the raw data and get the quantities we need from them
70 // The only things we need for this version of the f250 firmware are NSB, NSA, and the threshold.
71 // These are all stored in the BOR config. We can grab this from the raw data since that was already associated in JEventSource_EVIO::GetObjects.
72 const Df250BORConfig *f250BORConfig = NULL__null;
73 rawData->GetSingle(f250BORConfig);
74
75 uint32_t NSA;
76 int32_t NSB;
77 uint32_t NPED, MAXPED;
78 uint16_t THR;
79 uint16_t NSAT;
80 //If this does not exist, or we force it, use the default values
81 if (f250BORConfig == NULL__null || FORCE_DEFAULT){
82 static int counter = 0;
83 NSA = NSA_DEF;
84 NSB = NSB_DEF;
85 THR = THR_DEF;
86 NPED = NPED_DEF;
4
Value assigned to 'NPED'
87 MAXPED = MAXPED_DEF;
88 NSAT = NSAT_DEF;
89 if (counter < 10){
5
Taking true branch
90 counter++;
91 if (counter == 10) jout << " WARNING Df250EmulatorAlgorithm_v3::EmulateFirmware No Df250BORConfig == Using default values == LAST WARNING" << endl;
6
Taking false branch
92 else jout << " WARNING Df250EmulatorAlgorithm_v3::EmulateFirmware No Df250BORConfig == Using default values " << endl;
93 //<< rawData->rocid << "/" << rawData->slot << "/" << rawData->channel << endl;
94 }
95
96
97 if(USE_CRATE_DEFAULTS) {
7
Taking false branch
98 // BASED on run 71137
99 // FCAL, crates = 11-22
100 if( (rawData->rocid >= 11) && (rawData->rocid <= 22) ) {
101 NSA = 15;
102 NSB = 1;
103 THR = 108;
104 //NPED = NPED_DEF;
105 //MAXPED = MAXPED_DEF;
106 NSAT = 2;
107 }
108 // BCAL, crates = 31-46
109 else if( (rawData->rocid >= 31) && (rawData->rocid <= 46) ) {
110 NSA = 26;
111 NSB = 1;
112 THR = 105;
113 //NPED = NPED_DEF;
114 //MAXPED = MAXPED_DEF;
115 NSAT = 2;
116 }
117 // TAGH, crates 73-74, 75[slot 7-16]
118 else if( (rawData->rocid == 73) || (rawData->rocid == 74) || ( (rawData->rocid == 75) && (rawData->slot >= 7) && (rawData->slot <= 16)) ) {
119 NSA = 6;
120 NSB = 3;
121 THR = 300;
122 //NPED = NPED_DEF;
123 //MAXPED = MAXPED_DEF;
124 NSAT = 2;
125 }
126 // TAGM, crates 71-72, 75[slot 3-6]
127 else if( (rawData->rocid == 71) || (rawData->rocid == 72) || ( (rawData->rocid == 75) && (rawData->slot >= 3) && (rawData->slot <= 6)) ) {
128 NSA = 6;
129 NSB = 3;
130 THR = 150;
131 //NPED = NPED_DEF;
132 //MAXPED = MAXPED_DEF;
133 NSAT = 2;
134 }
135 // TOF, crates = 77
136 else if( rawData->rocid == 77 ) {
137 NSA = 10;
138 NSB = 1;
139 THR = 160;
140 //NPED = NPED_DEF;
141 //MAXPED = MAXPED_DEF;
142 NSAT = 2;
143 }
144 // PS, crates = 83-84
145 else if( (rawData->rocid >= 83) && (rawData->rocid <= 84) ) {
146 NSA = 10;
147 NSB = 3;
148 THR = 130;
149 //NPED = NPED_DEF;
150 //MAXPED = MAXPED_DEF;
151 NSAT = 2;
152 }
153 // ST, crates = 94
154 else if( rawData->rocid == 94 ) {
155 NSA = 20;
156 NSB = 5;
157 THR = 120;
158 //NPED = NPED_DEF;
159 //MAXPED = MAXPED_DEF;
160 NSAT = 2;
161 }
162 }
163 }
164 else{
165 NSA = f250BORConfig->NSA;
166 NSB = f250BORConfig->NSB;
167 THR = f250BORConfig->adc_thres[channel];
168 NPED = f250BORConfig->NPED;
169 MAXPED = f250BORConfig->MaxPed;
170 NSAT = f250BORConfig->NSAT;
171 //if (VERBOSE > 0) jout << "Df250EmulatorAlgorithm_v3::EmulateFirmware NSA: " << NSA << " NSB: " << NSB << " THR: " << THR << endl;
172 }
173
174 if (VERBOSE > 0) jout << "Df250EmulatorAlgorithm_v3::EmulateFirmware NSA: " << NSA << " NSB: " << NSB << " THR: " << THR << endl;
8
Taking false branch
175
176 // Note that in principle we could get this information from the Df250Config objects as well, but generally only NPED and the value of NSA+NSB are saved
177 // not the individual NSA and NSB values
178
179 /*
180 // TEST
181 if( (rawData->rocid >= 31) || (rawData->rocid <= 46) ) {
182 NSA = NSA_DEF;
183 NSB = NSB_DEF;
184 }
185 */
186
187 // quality bits
188 bool bad_pedestal = false;
189 bool bad_timing_pedestal = false;
190 bool no_timing_calculation = false;
191
192 // Now we can start to loop over the raw data
193 // This requires a few passes due to some features in the way the quantities are calculated...
194 // The first step is to scan the samples for TC (threshold crossing sample) and compute the
195 // integrals of all pulses found.
196
197 vector<uint16_t> samples = rawData->samples;
198 uint16_t NW = samples.size();
199 uint32_t npulses = 0;
200 const int max_pulses = 3;
201 uint32_t TC[max_pulses] = {};
202 uint32_t TMIN[max_pulses] = {3};
203 //uint32_t TNSAT[max_pulses] = {};
204 uint32_t pulse_integral[max_pulses] = {};
205 bool has_overflow_samples[max_pulses] = {false};
206 bool has_underflow_samples[max_pulses] = {false};
207 uint32_t number_samples_above_threshold[max_pulses] = {0};
208 bool NSA_beyond_PTW[max_pulses] = {false};
209 bool vpeak_beyond_NSA[max_pulses] = {false};
210 bool vpeak_not_found[max_pulses] = {false};
211
212 // some verbose debugging output
213 if(VERBOSE > 0) {
9
Taking false branch
214 for (unsigned int i=0; i < NW; i++) {
215 if(VERBOSE > 2) {
216 if(samples[i] == 0x1fff)
217 jout << "Overflow at sample " << i << endl;
218 if(samples[i] == 0x1000)
219 jout << "Underflow at sample " << i << endl;
220 }
221 if (VERBOSE > 5) jout << "Df250EmulatorAlgorithm_v3::EmulateFirmware samples[" << i << "]: " << samples[i] << endl;
222 }
223 }
224
225
226 // look for the threhold crossings and compute the integrals
227 //unsigned int MAX_SAMPLE = (NSB>0) ? (NW-NSAT) : (NW-NSAT+NSB-1)); // check this
228 unsigned int MAX_SAMPLE = NW-NSAT;
229 //cerr << " MAX_SAMPLE = " << MAX_SAMPLE << " NW = " << NW << " NSAT = " << NSAT << endl;
230 //for (unsigned int i=0; i < MAX_SAMPLE; i++) {
231 for (unsigned int i=0; i < MAX_SAMPLE; i++) {
10
Assuming 'i' is >= 'MAX_SAMPLE'
11
Loop condition is false. Execution continues on line 312
232 if ((samples[i] & 0xfff) > THR) {
233 if (VERBOSE > 1) {
234 jout << "threshold crossing at " << i << endl;
235 }
236
237 // save threshold crossing - could be overwritten
238 TC[npulses] = i+1;
239
240 // check that we have more than NSAT samples over threshold
241 if( NSAT>1 ){
242 int samples_over_threshold = 1;
243
244 if(i==0) {
245 // the algorithm only terminates if we dip below threshold...
246 //for(unsigned int j=i+1; ((samples[j]&0xfff)>=THR) && (j<MAX_SAMPLE+1); j++) {
247 for(unsigned int j=i+1; ((samples[j]&0xfff)>THR) && (j<MAX_SAMPLE+1); j++) {
248 // only count samples actually above threshold
249 if ((samples[j] & 0xfff) > THR)
250 samples_over_threshold++;
251
252 if( samples_over_threshold == NSAT ) {
253 //TC[npulses] = j+1;
254 //i=j;
255 break;
256 }
257
258 }
259 } else {
260 for(unsigned int j=i+1; ((samples[j]&0xfff)>THR) && (j<MAX_SAMPLE+1); j++) {
261 samples_over_threshold++;
262
263 if( samples_over_threshold == NSAT )
264 break;
265 }
266 }
267
268 // if we couldn't find NSAT samples above threshold, move on...
269 if( samples_over_threshold != NSAT )
270 continue;
271 }
272 //else {
273 //TNSAT[npulses] = TC[npulses];
274 //}
275
276
277 // calculate integral
278 unsigned int ibegin;
279 if(NSB > 0)
280 ibegin = i > uint32_t(NSB) ? (i - NSB) : 0; // Set to beginning of window if too early
281 else {
282 ibegin = i - NSB;
283 if(ibegin > uint32_t(NW)) // make sure we don't start looking outside the window
284 break;
285 }
286 unsigned int iend = (i + NSA) < uint32_t(NW) ? (i + NSA) : NW; // Set to last sample if too late
287 // check to see if NSA extends beyond the end of the window
288 NSA_beyond_PTW[npulses] = (i + NSA - 1) >= uint32_t(NW);
289 for (i = ibegin; i < iend; ++i) {
290 pulse_integral[npulses] += (samples[i] & 0xfff);
291 // quality monitoring
292 if(samples[i] == 0x1fff) {
293 has_overflow_samples[npulses] = true;
294 }
295 if(samples[i] == 0x1000) {
296 has_underflow_samples[npulses] = true;
297 }
298 // count number of samples within NSA that are above thresholds
299 if( (i+1>=TC[npulses]) && ((samples[i] & 0xfff) > THR) )
300 number_samples_above_threshold[npulses]++;
301 }
302 for (; i < NW && (samples[i] & 0xfff) >= THR; ++i) {}
303 if (++npulses == max_pulses)
304 break;
305 TMIN[npulses] = i;
306 }
307 }
308
309 // That concludes the first pass over the data.
310 // Now we can head into the fine timing pass over the data.
311
312 uint32_t VPEAK[max_pulses] = {};
313 uint32_t TPEAK[max_pulses] = {};
314 uint16_t TMID[max_pulses] = {};
315 uint16_t VMID[max_pulses] = {};
316 uint16_t TFINE[max_pulses] = {};
317 uint32_t pulse_time[max_pulses] = {};
318
319 // The pulse pedestal is the sum of NPED (4-15) samples at the beginning of the window
320 uint32_t pedestal = 0;
321 uint32_t VMIN = 0; // VMIN is just the average of the first 4 samples, needed for timing algorithm
322 for (unsigned int i=0; i < NPED; i++) {
12
Assuming 'i' is >= 'NPED'
13
Loop condition is false. Execution continues on line 336
323 pedestal += (samples[i] & 0xfff);
324 if(i<4)
325 VMIN += (samples[i] & 0xfff);
326 // error conditions
327 // sample larger than MaxPed
328 if ((samples[i] & 0xfff) > MAXPED) {
329 bad_pedestal = true;
330 }
331 // samples with underflow/overflow
332 if( (samples[i] == 0x1fff) || (samples[i] == 0x1000) ) {
333 bad_pedestal = true;
334 }
335 }
336 VMIN /= NPED; // compute average
14
Division by zero
337
338 // error conditions for timing algorithm
339 //bool pedestal_underflow = false;
340 for (unsigned int i=0; i < 4; i++) {
341 // We set the "Time Quality bit 0" to 1 if any of the first 4 samples is greated than MaxPed or TET...
342 if ( ((samples[i] & 0xfff) > MAXPED) || ((samples[i] & 0xfff) > THR) ) {
343 bad_timing_pedestal = true;
344 }
345 // ... or is overflow or underflow
346 if ( (samples[i] == 0x1000) || (samples[i] == 0x1fff) ) {
347 bad_timing_pedestal = true;
348 }
349 //}
350
351 // "If any of the first 4 samples is greater than TET the TDC will NOT proceed..."
352 // Waiit for iiit...
353 if( (samples[i] & 0xfff) > THR ) {
354 no_timing_calculation = true;
355 }
356 }
357
358
359 for (unsigned int p=0; p < npulses; ++p) {
360
361 // "If any of the first 4 samples is greater than TET or underflow the TDC will NOT proceed
362 // 1. pulse time is set to TC
363 // 2. pulse peak is set to zero - not anymore!
364 // 3. Time quality bits 0 and 1 are set to 1"
365 if(no_timing_calculation) {
366 TMID[p] = TC[p];
367 TFINE[p] = 0;
368 VPEAK[p] = 0;
369 //vpeak_not_found[p] = true; // this is "time quality bit 1"
370 // "Time Quality bit 0" should already be set
371 } // should just put an else here...
372
373 // we set up a loop so that we can break out of it at appropriate times...
374 // note that currently the timing algorithm is run when the pedestal has underflow samples,
375 // but according to the documentation, it shouldn't...
376 // NOTE that we should always run the calculation since we always need to search for the
377 // peak position, just in some edge cases we don't need to run the timing algorithm
378
379 //while ( (!no_timing_calculation || pedestal_underflow) && true) {
380 while (true) {
381 //if (VMIN == 99999) {
382 // VPEAK[p] = 0;
383 // reportTC[p] = true;
384 // pulse_time[p] = (TC[p] << 6);
385 // break;
386 // }
387
388 // search for the peak of the pulse
389 // has to be after the threshold crossing (NO?)
390 // has to be before the last sample
391 unsigned int ipeak;
392 for (ipeak = TC[p]; (int)ipeak < NW-1; ++ipeak) {
393 //for (ipeak = TC[p]+1; ipeak < NW-1; ++ipeak) {
394 if ((samples[ipeak] & 0xfff) < (samples[ipeak-1] & 0xfff)) {
395 VPEAK[p] = (samples[ipeak-1] & 0xfff);
396 TPEAK[p] = ipeak-1;
397 break;
398 }
399 }
400
401 // check to see if the peak is beyond the NSA
402 if(ipeak > TC[p]+NSA)
403 vpeak_beyond_NSA[p] = true;
404
405 if (VERBOSE > 1) {
406 jout << " pulse " << p << ": VMIN: " << VMIN
407 << " TC: " << TC[p] << " VPEAK: " << VPEAK[p] << endl;
408 }
409
410 // set error conditions in case we didn't find the peak
411 if (VPEAK[p] == 0) {
412 TMID[p] = TC[p];
413 TFINE[p] = 0;
414 VPEAK[p] = 0;
415 vpeak_beyond_NSA[p] = true;
416 vpeak_not_found[p] = true;
417 break;
418 }
419
420 // we have found the peak position, now ignore the timing calculation if need be...
421 if(no_timing_calculation)
422 break;
423
424 // VMID is the half amplitude
425 VMID[p] = (VMIN + VPEAK[p]) >> 1;
426
427
428 // look down the leading edge for the sample that satisfies V(N1) <= VMID < V(N+1)
429 // N1 is then the coarse time
430 // note that when analyzing pulses after the first, we could end up with a time for the
431 // second pulse that is before the first one! this is a little crazy, but is how
432 // the algorithm is currently implemented
433 for (unsigned int i = TPEAK[p]; i >= 1; --i) {
434 if ( ((samples[i-1] & 0xfff) <= VMID[p]) && ((samples[i] & 0xfff) > VMID[p]) ) { // V(N1) <= VMID < V(N+1)
435 // if ( ((samples[i-1] & 0xfff) <= VMID[p]) // V(N1) <= VMID < V(N+1)
436 // || ( (samples[i-1] & 0xfff) > (samples[i] & 0xfff) ) ) { // we aren't on the leading edge anymore
437 TMID[p] = i;
438 break;
439 }
440 }
441
442 if (TMID[p] == 0) { // handle the case where we couldn't find a coarse time - redundant?
443 TFINE[p] = 0;
444 }
445 else {
446 // fine timing algorithm (see documentation)
447 int Vnext = (samples[TMID[p]] & 0xfff);
448 int Vlast = (samples[TMID[p]-1] & 0xfff);
449 if (VERBOSE > 2) {
450 jout << " TMIN = " << TMIN[p] << " TMID = " << TMID[p] << " TPEAK = " << TPEAK[p] << endl
451 << " VMID = " << VMID[p] << " Vnext = " << Vnext << " Vlast = " << Vlast << endl;
452 }
453 if (Vnext > Vlast && VMID[p] >= Vlast)
454 TFINE[p] = 64 * (VMID[p] - Vlast) / (Vnext - Vlast);
455 else
456 TFINE[p] = 62;
457 if(TFINE[p] == 64)
458 TFINE[p] = 0;
459 }
460 pulse_time[p] = ((TMID[p]-1) << 6) + TFINE[p];
461 break;
462 }
463 VMIN = (VMIN < 99999)? VMIN : 0; // deprecated?
464
465 if (VERBOSE > 1) {
466 jout << " pulse " << p << ": VMID: " << VMID[p] << " TMID: " << TMID[p]
467 << " TFINE: " << TFINE[p] << " time: " << pulse_time[p]
468 << " integral: " << pulse_integral[p] << endl;
469 if (VERBOSE > 2) {
470 jout << " TMIN = " << TMIN[p] << " TMID = " << TMID[p] << " TPEAK = " << TPEAK[p] << endl;
471 //<< " VMID = " << VMID[p] << " Vnext = " << Vnext << " Vlast = " << Vlast << endl;
472 }
473 }
474
475 // algorithm is finished, fill the information
476 Df250PulseData* f250PulseData;
477 if( p < pdat_objs.size() ) {
478 f250PulseData = pdat_objs[p];
479
480 if(f250PulseData == NULL__null) {
481 jerr << " NULL f250PulseData object!" << endl;
482 continue;
483 }
484 } else {
485 // make a fresh object if one does not exist
486 f250PulseData = new Df250PulseData;
487
488 f250PulseData->rocid = rawData->rocid;
489 f250PulseData->slot = rawData->slot;
490 f250PulseData->channel = rawData->channel;
491 f250PulseData->itrigger = rawData->itrigger;
492 // word 1
493 f250PulseData->event_within_block = 1;
494 f250PulseData->QF_pedestal = bad_pedestal;
495 f250PulseData->pedestal = pedestal;
496 // word 2
497 f250PulseData->integral = pulse_integral[p];
498 f250PulseData->QF_NSA_beyond_PTW = NSA_beyond_PTW[p];
499 f250PulseData->QF_overflow = has_overflow_samples[p];
500 f250PulseData->QF_underflow = has_underflow_samples[p];
501 f250PulseData->nsamples_over_threshold = number_samples_above_threshold[p];
502 // word 3
503 f250PulseData->course_time = TMID[p];
504 f250PulseData->fine_time = TFINE[p];
505 f250PulseData->QF_vpeak_beyond_NSA = vpeak_beyond_NSA[p];
506 f250PulseData->QF_vpeak_not_found = vpeak_not_found[p];
507 f250PulseData->QF_bad_pedestal = bad_timing_pedestal;
508 // other information
509 f250PulseData->pulse_number = p;
510 f250PulseData->nsamples_integral = NSA + NSB;
511 f250PulseData->nsamples_pedestal = NPED;
512 f250PulseData->emulated = true;
513
514 f250PulseData->AddAssociatedObject(rawData);
515 const_cast<Df250WindowRawData*>(rawData)->AddAssociatedObject(f250PulseData);
516 pdat_objs.push_back(f250PulseData);
517 }
518
519 // copy over emulated values
520 f250PulseData->integral_emulated = pulse_integral[p];
521 f250PulseData->pedestal_emulated = pedestal;
522 f250PulseData->pulse_peak_emulated = VPEAK[p];
523 f250PulseData->course_time_emulated = TMID[p];
524 f250PulseData->fine_time_emulated = TFINE[p];
525
526 // check the emulated quality factors as well
527 uint32_t QF = 0; // make single quality factor number for compactness
528 if( bad_pedestal ) QF |= (1<<0);
529 if( NSA_beyond_PTW[p] ) QF |= (1<<1);
530 if( has_overflow_samples[p] ) QF |= (1<<2);
531 if( has_underflow_samples[p] ) QF |= (1<<3);
532 if( vpeak_beyond_NSA[p] ) QF |= (1<<4);
533 if( vpeak_not_found[p] ) QF |= (1<<5);
534 if( bad_timing_pedestal ) QF |= (1<<6);
535 f250PulseData->QF_emulated = QF;
536
537 if(VERBOSE > 3) {
538 cout << boolalpha;
539 cout << "bad_pedestal = " << bad_pedestal << endl;
540 cout << "NSA_beyond_PTW = " << NSA_beyond_PTW[p] << endl;
541 cout << "has_overflow_samples = " << has_overflow_samples[p] << endl;
542 cout << "has_underflow_samples = " << has_underflow_samples[p] << endl;
543 cout << "vpeak_beyond_NSA = " << vpeak_beyond_NSA[p] << endl;
544 cout << "vpeak_not_found = " << vpeak_not_found[p] << endl;
545 cout << "bad_timing_pedestal = " << bad_timing_pedestal << endl;
546 cout << "total QF = " << QF << endl;
547 }
548
549 // if we are using the emulated values, copy them
550 if( f250PulseData->emulated ) {
551 f250PulseData->integral = f250PulseData->integral_emulated;
552 f250PulseData->pedestal = f250PulseData->pedestal_emulated;
553 f250PulseData->pulse_peak = f250PulseData->pulse_peak_emulated;
554 f250PulseData->course_time = f250PulseData->course_time_emulated;
555 f250PulseData->fine_time = f250PulseData->fine_time_emulated;
556
557 /*
558 if( (rawData->rocid >= 31) || (rawData->rocid <= 46) ) {
559 f250PulseData->nsamples_integral = NSA + NSB;
560 }
561 */
562
563 }
564
565 }
566
567 if (VERBOSE > 0) jout << " Df250EmulatorAlgorithm_v3::EmulateFirmware ==> Emulation complete <==" << endl;
568 return;
569}