Repository navigation
Expand file tree
/
Copy pathchanges.patch
More file actions
637 lines (584 loc) · 31.3 KB
/
Copy pathchanges.patch
File metadata and controls
637 lines (584 loc) · 31.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
diff --git a/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC2StreamNUandSNXMIT.hh b/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC2StreamNUandSNXMIT.hh
index 1d10ed91..27ae3194 100644
--- a/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC2StreamNUandSNXMIT.hh
+++ b/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC2StreamNUandSNXMIT.hh
@@ -84,19 +84,11 @@ namespace sbndaq {
std::ofstream binFileNU; // temp
std::ofstream binFileSN; // temp
char binFileNameNU[80]; // Name of binary dump file for NU stream
- char binFileNameSN[200]; // Name of binary dump file for SN stream
-
- size_t total_words_inserted = 0;
- size_t total_words_written = 0;
+ char binFileNameSN[80]; // Name of binary dump file for SN stream
int N_SNDMAs;
int N_SNWrites;
- time_t t;
- struct tm ltm;
- int SNBinSubFileNum_;
- int SNDMATransferCnt_;
-
};
} // namespace sbndaq
diff --git a/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC2StreamNUandSNXMIT_generator.cc b/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC2StreamNUandSNXMIT_generator.cc
index db98f537..d6fa7ca4 100644
--- a/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC2StreamNUandSNXMIT_generator.cc
+++ b/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC2StreamNUandSNXMIT_generator.cc
@@ -33,9 +33,6 @@ void sbndaq::NevisTPC2StreamNUandSNXMIT::ConfigureStart() {
N_SNWrites = 0;
//std::string connectionString = "tcp://10.226.36.6:" + std::to_string(fGPSZMQPortNTB);
- SNBinSubFileNum_ = -1;
- SNDMATransferCnt_ = 0;
-
if(fUseZMQ){
_zmqGPSPublisher.bind(fGPSZMQPortNTB);} // This port can be configured in fcl file and need to change the localhost to -daq subnet to find daq subnet, ifconfig and choose ino2 10.226.36.6
// Any port > 10000 can be used by artdaq (netstat -lpnu4 --> this will tell you the used ports)
@@ -43,17 +40,15 @@ void sbndaq::NevisTPC2StreamNUandSNXMIT::ConfigureStart() {
if( fDumpBinary ){
// Get timestamp for binary file name
- //time_t t = time(0);
- //struct tm ltm = *localtime( &t );
- t = time(0);
- ltm = *localtime( &t );
+ time_t t = time(0);
+ struct tm ltm = *localtime( &t );
sprintf(binFileNameNU, "%s/sbndrawbin_run%06i_%4i.%02i.%02i-%02i.%02i.%02i_TPC_NU.dat",
fDumpBinaryDir.c_str(), sbndaq::NevisTPC_generatorBase::run_number(),
ltm.tm_year + 1900, ltm.tm_mon + 1, ltm.tm_mday, ltm.tm_hour, ltm.tm_min, ltm.tm_sec);
TLOG(TLVL_INFO)<< "Opening raw binary file " << binFileNameNU;
binFileNU.open( binFileNameNU, std::ofstream::out | std::ofstream::binary ); // temp
-/*
+
if( fSNReadout ){
sprintf(binFileNameSN, "%s/sbndrawbin_run%06i_%4i.%02i.%02i-%02i.%02i.%02i_TPC_SN.dat",
fDumpBinaryDir.c_str(), sbndaq::NevisTPC_generatorBase::run_number(),
@@ -64,7 +59,6 @@ void sbndaq::NevisTPC2StreamNUandSNXMIT::ConfigureStart() {
// to do: Send SN data to a dedicated Event Builder? Does it require its own BoardReader?
// Otherwise use MicroBooNE example to make several files with the binary dump instead of a giant file
}
-*/
}
// Create Crate object
@@ -179,7 +173,7 @@ void sbndaq::NevisTPC2StreamNUandSNXMIT::startFireCalibTrig() {
void sbndaq::NevisTPC2StreamNUandSNXMIT::ConfigureStop() {
if( fSNReadout ){
GetSNData_thread_->stop();
- WriteSNData_thread_->stop();
+ WriteSNData_thread_->stop();
}
// FireCALIB_thread_->stop();
if( fControllerTriggerFreq > 0 ){//only stop thread if it met conditions to get started
@@ -307,10 +301,19 @@ size_t sbndaq::NevisTPC2StreamNUandSNXMIT::GetFEMCrateData() {
TLOG(TGETDATA)<< "GetFEMCrateData";
+ // Just for tests
+ // Taken from NevisTPCFile_generator and adapted to use an XMITReader
+ // To be reviewed
+ // uint16_t* buffer = new uint16_t[fChunkSize];
+ TLOG(TGETDATA) << "Going to call Readsome function";
+ //std::streamsize bytesRead = fNUXMITReader->readsome(reinterpret_cast<char*>(buffer), fChunkSize);
std::streamsize bytesRead = fNUXMITReader->readsome(reinterpret_cast<char*>(&DMABuffer_[0]), fChunkSize);
//unsigned wordsRead = bytesRead * sizeof(char) / sizeof(uint16_t);
TLOG(TGETDATA) << "Number of bytes read:" << int(bytesRead) ;
+ //std::copy(buffer, buffer + wordsRead, &DMABuffer_[0]);
+
+ //if( fDumpBinary ) binFileNU.write( (char*)buffer, fChunkSize );
if( fDumpBinary ) binFileNU.write( (char*)(&DMABuffer_[0]), fChunkSize );
binFileNU.flush();
@@ -323,8 +326,12 @@ bool sbndaq::NevisTPC2StreamNUandSNXMIT::GetSNData() {
TLOG(TGETDATA)<< "GetSNData";
+ // Just for tests
+ // Taken from NevisTPCFile_generator and adapted to use an XMITReader
+ // To be reviewed
+ // uint16_t* SNBuffer_ = new uint16_t[fSNChunkSize];
+
std::streamsize bytesRead = fSNXMITReader->readsome(reinterpret_cast<char*>(&SNDMABuffer_[0]), fSNChunkSize);
- if (bytesRead <=0) return false;
if (bytesRead == fSNChunkSize){
++N_SNDMAs;
@@ -333,12 +340,11 @@ bool sbndaq::NevisTPC2StreamNUandSNXMIT::GetSNData() {
size_t n_words = bytesRead/sizeof(uint16_t);
size_t new_buffer_size = SNCircularBuffer_.Insert(n_words, SNDMABuffer_);
- TLOG(TGETDATA)<< "Successfully inserted " << n_words << " . SN Buffer occupancy now " << new_buffer_size;
-
- total_words_inserted += n_words;
- TLOG(TGETDATA) << "Inserted " << n_words << " words. Total inserted: " << total_words_inserted;
+ TLOG(TGETDATA)<< "Successfully inserted " << n_words << " . SN Buffer occupancy now " << new_buffer_size;
- TLOG(TGETDATA) << "SNCircularBuffer_.buffer.size() " << SNCircularBuffer_.buffer.size() ;
+ // if( fDumpBinary ) binFileSN.write( (char*)(&SNDMABuffer_[0]), fSNChunkSize );
+ //delete[] SNBuffer_;
+ //memset(SNBuffer_, 0, fSNChunkSize*sizeof(uint16_t)); // avoid clearing?
if(metricMan != nullptr) {
//send SN metrics
@@ -353,52 +359,19 @@ bool sbndaq::NevisTPC2StreamNUandSNXMIT::GetSNData() {
bool sbndaq::NevisTPC2StreamNUandSNXMIT::WriteSNData() {
- //Writing and erasing number of words to and from circular buffer --> to fix missing frames issue
- if (SNCircularBuffer_.buffer.size() >= fSNChunkSize / sizeof(uint16_t)) {
-
- //Make binary subfiles
- if (SNDMATransferCnt_ == 1000) SNDMATransferCnt_ = 0;
- if (SNDMATransferCnt_ == 0) {
- if (fDumpBinary && fSNReadout) {
- if (binFileSN.is_open()) {
- TLOG(TLVL_INFO)<< "Closing raw binary file " << binFileNameSN;
- binFileSN.close();
- }
-
- ++SNBinSubFileNum_;
-
- sprintf(binFileNameSN, "%s/sbndrawbin_run%06i_%4i.%02i.%02i-%02i.%02i.%02i_subfile%i_TPC_SN.dat",
- fDumpBinaryDir.c_str(), sbndaq::NevisTPC_generatorBase::run_number(),
- ltm.tm_year + 1900, ltm.tm_mon + 1, ltm.tm_mday, ltm.tm_hour, ltm.tm_min, ltm.tm_sec, SNBinSubFileNum_);
-
- TLOG(TLVL_INFO)<< "Opening raw binary file " << binFileNameSN;
- binFileSN.open(binFileNameSN, std::ofstream::out | std::ofstream::binary);
- }
- }
+ if( SNCircularBuffer_.buffer.size() < fSNChunkSize ) return false;
+
+ std::copy(SNCircularBuffer_.buffer.begin(), SNCircularBuffer_.buffer.begin() + fSNChunkSize, SNBuffer_);
+
+ binFileSN.write((char*)SNBuffer_, fSNChunkSize );
- std::copy(SNCircularBuffer_.buffer.begin(),
- SNCircularBuffer_.buffer.begin() + (fSNChunkSize / sizeof(uint16_t)),
- SNBuffer_);
-
- binFileSN.write(reinterpret_cast<char*>(SNBuffer_), fSNChunkSize);
- ++N_SNWrites;
-
- ++SNDMATransferCnt_;
-
- binFileSN.flush();
-
- size_t n_words_written = fSNChunkSize / sizeof(uint16_t);
- total_words_written += n_words_written;
-
- TLOG(TFILLFRAG) << "Wrote " << n_words_written << " words (" << fSNChunkSize << " bytes) to binary file. "
- << "Total written: " << total_words_written;
-
-
-size_t new_buffer_size = SNCircularBuffer_.Erase(fSNChunkSize/sizeof(uint16_t));
-
- TLOG(TFILLFRAG)<< "Successfully erased " << fSNChunkSize/sizeof(uint16_t) << " . SN Buffer occupancy now " << new_buffer_size;
- }
+ ++N_SNWrites;
+ binFileSN.flush();
+
+ size_t new_buffer_size = SNCircularBuffer_.Erase(fSNChunkSize);
+ TLOG(TFILLFRAG)<< "Successfully erased " << fSNChunkSize << " . SN Buffer occupancy now " << new_buffer_size;
+
if(metricMan != nullptr) {
//send SN metrics
metricMan->sendMetric(
diff --git a/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC_generatorBase.cc b/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC_generatorBase.cc
index bd9214f2..12170b71 100644
--- a/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC_generatorBase.cc
+++ b/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC_generatorBase.cc
@@ -150,11 +150,6 @@ size_t sbndaq::NevisTPC_generatorBase::CircularBuffer::Insert(size_t n_words, st
n_words,buffer.size(),buffer.capacity());
return buffer.size();
}
-size_t sbndaq::NevisTPC_generatorBase::CircularBuffer::InsertSafe( size_t n_words, const uint16_t* data) {
- buffer.insert(buffer.end(), data, data + n_words);
- return buffer.size();
-}
-
size_t sbndaq::NevisTPC_generatorBase::CircularBuffer::Erase(size_t n_words){
@@ -177,32 +172,13 @@ bool sbndaq::NevisTPC_generatorBase::GetData(){
auto start_time = std::chrono::steady_clock::now();
- size_t n_words = GetFEMCrateData()/sizeof(uint16_t);
-
- // size_t n_words;
-
+ size_t n_words = GetFEMCrateData()/sizeof(uint16_t);
TRACE(TGETDATA,"GetFEMCrateData() return %lu words",n_words);
// if(n_words==0)
// return false;
while (n_words == 0) {
n_words = GetFEMCrateData()/sizeof(uint16_t);
- /*
- if (n_words > 0) {
- ++dma_counter_;
-
- TLOG(TLVL_INFO) << "Received." << dma_counter_ << " DMAs";
- // TRACE(TGETDATA, "Received 1 DMA. Stopping GetData thread.");
-
- if (dma_counter_ >= 1) {
- TLOG(TLVL_INFO) << "Stopping get data thread after " << dma_counter_ << " ..... DMAs";
- stop();
- return false; // This tells the thread to stop
- }
- return true;
- }
-
- */
auto current_time = std::chrono::steady_clock::now();
auto elapsed_time = std::chrono::duration_cast<std::chrono::seconds>(current_time - start_time).count();
if (elapsed_time > fTimeoutSec){ //fcl configurable timeout (in seconds) for more ability to do low rate nonstandard trigger configurations
diff --git a/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC_generatorBase.hh b/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC_generatorBase.hh
index 9b17c00d..5f77d6c3 100644
--- a/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC_generatorBase.hh
+++ b/sbndaq-artdaq/Generators/SBND/NevisTPC/NevisTPC_generatorBase.hh
@@ -27,11 +27,6 @@ public:
explicit NevisTPC_generatorBase(fhicl::ParameterSet const &ps);
virtual ~NevisTPC_generatorBase();
-
-private:
- size_t dma_counter_ = 0;
-
-
protected:
bool getNext_(artdaq::FragmentPtrs &output) override;
void start() override;
@@ -108,7 +103,6 @@ protected:
}
size_t Insert(size_t, std::unique_ptr<uint16_t[]> const &);
- size_t InsertSafe(size_t n_words, const uint16_t* data);
size_t Erase(size_t);
} CircularBuffer_t;
diff --git a/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/Crate.cpp b/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/Crate.cpp
index b07500fa..28fb73a3 100644
--- a/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/Crate.cpp
+++ b/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/Crate.cpp
@@ -254,8 +254,7 @@ This function is added to debug FEMs is software but hasnot tested yet
// To do: This function needs to be updated/overloaded to configure the zero suppression
getTPCFEM(tpc_it)->fem_setup(crateconfig);
TLOG(TLVL_INFO) << "Crate: FEM in slot " << getTPCFEM(tpc_it)->module_number() << " all set.";
- getTPCFEM(tpc_it)->readStatus();
- }
+ }
}
// Setup tx mode registers (this is done twice for some reason...)
diff --git a/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/NevisTPCFEM.cpp b/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/NevisTPCFEM.cpp
index d91f29e7..c1c07634 100644
--- a/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/NevisTPCFEM.cpp
+++ b/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/NevisTPCFEM.cpp
@@ -1,58 +1,7 @@
#include "NevisTPCFEM.h"
#include "FPGAFirmwareReader.h"
-#include "tracemf.h"
-#include <cmath>
-#include <stdlib.h>
-#include <random>
-
+#include "trace.h"
#define TRACE_NAME "NevisTPCFEM"
-#define PI 3.14159265
-
-#include <fstream>
-#include <sstream>
-#include <unordered_map>
-#include <string>
-#include <vector>
-#include <iostream>
-
-using ZSMap = std::unordered_map<std::string, std::unordered_map<std::string, unsigned int>>;
-
-/*
-ZSMap parseZSFile(const std::string& filename) {
- std::ifstream infile(filename);
- ZSMap zs_data;
- std::string slot, key;
- unsigned int value;
-
- while (infile >> slot >> key >> value) {
- zs_data[slot][key] = value;
- }
-
- return zs_data;
-}
-
-*/
-
-
-ZSMap parseZSFile(const std::string& filename) {
- ZSMap zs_data;
- std::ifstream infile(filename);
- std::string full_key;
- unsigned int value;
-
- while (infile >> full_key >> value) {
- // full_key should look like "slot3.ch0"
- size_t dot_pos = full_key.find('.');
- if (dot_pos != std::string::npos) {
- std::string slot_key = full_key.substr(0, dot_pos); // "slot3"
- std::string chan_key = full_key.substr(dot_pos + 1); // "ch0" or "ped0"
- zs_data[slot_key][chan_key] = value;
- }
- }
-
- return zs_data;
-}
-
namespace nevistpc {
@@ -539,7 +488,7 @@ namespace nevistpc {
void NevisTPCFEM::setLoadThreshold(data_payload_t const &chan, data_payload_t const &size){
controller()->send(ControlDataPacket(_slot_number, device::STRATIX_FPGA, stratix_fpga::LOAD_THRESHOLD + chan, size));
usleep(10);
- TLOG(TLVL_INFO) << "NevisTPCFEM: called " << __func__ << " with " << chan << ", " << size;
+ TLOG(TLVL_INFO) << "NevisTPCFEM: called " << __func__ << " with " << chan << ", " << size;
}
void NevisTPCFEM::setLoadThresholdMean(data_payload_t const &size){
@@ -581,7 +530,7 @@ namespace nevistpc {
usleep(1);
controller()->send(ControlDataPacket(_slot_number, device::STRATIX_FPGA, stratix_fpga::WRITE_BASELINE, size));
usleep(1);
- TLOG(TLVL_INFO) << "NevisTPCFEM: called " << __func__ << " for ch " << chan << " with " << size;
+ TLOG(TLVL_INFO) << "NevisTPCFEM: called " << __func__ << " for ch " << chan << " with " << size;
}
void NevisTPCFEM::enableFEMFakeData(bool const &flag){
@@ -591,78 +540,18 @@ namespace nevistpc {
TLOG(TLVL_INFO) << "NevisTPCFEM: called " << __func__ << " with " << flag;
}
-
- unsigned int fakewaveform_shaperfunction (std::string shape, unsigned int smpl, unsigned int chnl, int noise,const std::vector<unsigned int>& threshold,const std::vector<unsigned int>& baseline){
-
- // unsigned int baseline = 750; //(chnl%2 == 0)? 15 : 45; //2058 : 458;// 15 : 45; // 15 ADC for even channels, 45 ADC for odd channels
- //unsigned int threshold = 100; //(chnl%2 == 0)? 2049 : 450; // 2049 ADC for even channels, 450 ADC for odd channels
- unsigned int signall = 0;
- unsigned int bkgg = 20;
- // bkgg = baseline + noise;
- // bkgg = ped_val + noise;
-
-
- if (shape == "uB") {//signals movtivated by physics of uB
- // if(chnl<4){
- unsigned int ped_val = (chnl < baseline.size()) ? baseline[chnl] : 750;
- unsigned int ch_val = (chnl < threshold.size()) ? threshold[chnl] : 100;
- if (smpl>=2 && smpl<10){
- int signal = std::round(600*std::sin(PI/48*(smpl-1)));
- signall = ped_val + signal + noise;
- TLOG(TLVL_INFO) << "Check pedestal for channel:: " << chnl << " is: " << ped_val;
- TLOG(TLVL_INFO) << "Check threshold for channel:: " << chnl << " is: " << ch_val;
-
- return (signall & 0xfff);
- }
- else{
- bkgg = ped_val + noise;
- TLOG(TLVL_INFO) << "Check pedestal for channel:: " << chnl << " is: " << ped_val;
- TLOG(TLVL_INFO) << "Check threshold for channel:: " << chnl << " is: " << ch_val;
- return (bkgg & 0xfff); //baseline + noise ;
-
- }
- }
- return (bkgg & 0xfff);
-
- }
- /*
-
- if (shape == "square") {//490-512 square waves, channel dependent amplitudes
-
- unsigned int ped_val = (chnl < baseline.size()) ? baseline[chnl] : 750;
- unsigned int ch_val = (chnl < threshold.size()) ? threshold[chnl] : 100;
- if (smpl>490 and smpl<512) return ch_val+(chnl*5+ped_val);
- else {
-return ch_val - (chnl*5 + ped_val);
- }
- return (bkgg & 0xfff); // Or use a fixed fallback value
- }
- }
- */
-
-
-
- void NevisTPCFEM::loadFEMFakeData(std::string const &pattern, const std::vector<unsigned int>& threshold, const std::vector<unsigned int>& baseline){
- unsigned int fake_data_array[73216];
- std::default_random_engine generator;//construct random number generator and gaussian for random noise
- std::normal_distribution<double> distribution(0.0,2.5);//noise centered at 0, std dev of 2.5
+ void NevisTPCFEM::loadFEMFakeData(std::string const &pattern){
+ unsigned int fake_data_array[65536];
// Create fake data pattern
for( unsigned int channel = 0; channel < 64; channel++ ){
- for(unsigned int sample = 0; sample < 1144; sample++ ){
+ for(unsigned int sample = 0; sample < 1024; sample++ ){
// Fake data is the sum of channel number and sample index
if( pattern == "channel+sample" ) fake_data_array[channel + sample*64]= (channel + sample) & 0xfff;
// Fake data is the channel number
else if( pattern == "channel" ) fake_data_array[channel + sample*64]= channel & 0xfff;
// Fake data is the sample index number
else if( pattern == "sample" ) fake_data_array[channel + sample*64]= sample & 0xfff;
- else if ( pattern == "signalLike" ) {
- int noise = std::round(distribution(generator));
- fake_data_array[channel + sample*64]= fakewaveform_shaperfunction("uB", sample & 0xfff, channel & 0xfff, noise & 0xfff,threshold, baseline);
- // mf::LogInfo("NevisTPCFEMs") << "SignalLike Fake data for channel : " << channel << "and sample : " << sample << "is : " << std::hex << (fake_data_array[channel + sample*64]);
- TLOG(TLVL_INFO) << "SignalLike Fake data for channel : " << channel << "and sample : " << sample << "is : " << std::dec << (fake_data_array[channel + sample*64]);
-
-}
else{
TLOG(TLVL_ERROR) << "FEM fake data pattern" << pattern << " not recognized. Filling with zeroes.";
fake_data_array[channel+sample*64]= 0 & 0xfff;
@@ -676,7 +565,7 @@ return ch_val - (chnl*5 + ped_val);
// Store 4 12-bit ADC samples as 3 16-bit words
// 64 channels * 1024 samples/channel * 12 bit/sample * 1 word/16 bit = 49152 words into FEM memory
unsigned int address = 0;
- for( unsigned int sample = 0; sample < 1144; sample ++ ){
+ for( unsigned int sample = 0; sample < 1024; sample ++ ){
for( unsigned int channel=0; channel < 64; channel++ ){
unsigned int packing_index = channel%4;
unsigned int packed_word;
@@ -698,9 +587,6 @@ return ch_val - (chnl*5 + ped_val);
void NevisTPCFEM::fem_setup(fhicl::ParameterSet const& crateConfig){
- std::vector<unsigned int> threshold;
- std::vector<unsigned int> baseline;
-
TLOG(TLVL_INFO) << "FEM setup for slot " << (int)_slot_number;
// Power On arria power supply
powerOnArriaFPGA();
@@ -753,8 +639,6 @@ return ch_val - (chnl*5 + ped_val);
TLOG(TLVL_INFO) << "NevisTPCFEM: Configuring static-baseline zero suppression for SN stream...";
}
-
- /*
// To do: set the threshold (and baseline values) in the fcl file (current values correspond to the WIB fake data pattern)
for (unsigned int chan_it = 0; chan_it < 64; ++chan_it) {
if( !static_baseline ){ // Dynamic baseline thresholds
@@ -763,58 +647,14 @@ return ch_val - (chnl*5 + ped_val);
//unsigned int i = (3 << 12) + 475; // 1: Bipolar (+) 475 ADC threshold // overflows memory
setLoadThreshold( chan_it, i );
} else { // Static baseline values and thresholds
- unsigned int threshold = 100; //(chan_it%2 == 0)? 500 : 2039; // 500 ADC for even channels, 2039 ADC for odd channels
-
- unsigned int baseline = 750; //(chan_it%2 == 0)? 767 : 2040; // 767 ADC for even channels, 2040 ADC for odd channels
-
+ unsigned int threshold = (chan_it%2 == 0)? 500 : 2039; // 500 ADC for even channels, 2039 ADC for odd channels
+ unsigned int baseline = (chan_it%2 == 0)? 767 : 2040; // 767 ADC for even channels, 2040 ADC for odd channels
//unsigned int threshold = 2046; // Aggressive threshold for all channels
//unsigned int baseline = 2047; // Aggressive threshold for all channels
setLoadThreshold( chan_it, threshold );
setLoadBaseline( chan_it, baseline );
}
- }
-
- */
-
- //reading zsparameters from text file:
- fhicl::ParameterSet zsParams = crateConfig.get<fhicl::ParameterSet>("zero_suppression_params");
- std::string zs_filename = zsParams.get<std::string>("config_file");
- ZSMap zs_data = parseZSFile(zs_filename);
- std::string slot_key = "slot" + std::to_string((int)_slot_number);
- if (zs_data.find(slot_key) == zs_data.end()) {
- TLOG(TLVL_INFO) << "Zero suppression configuration not found for " << slot_key;
- }
-
- // std::vector<unsigned int> threshold;
- // std::vector<unsigned int> baseline;
- unsigned int n_channels = 64;
- for (size_t chan_it = 0; chan_it < n_channels; chan_it++) {
-
-
- std::string ch_key = "ch" + std::to_string(chan_it);
- std::string ped_key = "ped" + std::to_string(chan_it);
- // default values if not provided in file
-
- unsigned int ch_val= 100;
- unsigned int ped_val = 650;
- if (zs_data[slot_key].find(ch_key) != zs_data[slot_key].end())
- {
- ch_val = zs_data[slot_key][ch_key];
- }
- if (zs_data[slot_key].find(ped_key) != zs_data[slot_key].end())
- {
- ped_val = zs_data[slot_key][ped_key];
- }
- // TLOG(TLVL_INFO) << "Threshold for channel " << chan_it << " is : " << ch_val << " and baseline is: " << ped_val ;
- threshold.push_back(ch_val);
- baseline.push_back(ped_val);
- //TLOG(TLVL_INFO) << " Threshold size " << threshold.size() ;
- setLoadThreshold( chan_it, ch_val );
- setLoadBaseline( chan_it, ped_val );
- }
-
-
-
+ }
// To do: write the values on the fcl file
if( !static_baseline ){ // Dynamic baseline estimation tolerances
setLoadThresholdMean( crateConfig.get<int>( "load_threshold_mean", 0x1024 )); // large value since since the fake WIB data has no quiet region
@@ -829,11 +669,7 @@ return ch_val - (chnl*5 + ped_val);
bool use_fake_data = crateConfig.get<bool>("fem_fake_data", false);
enableFEMFakeData( use_fake_data );
if( use_fake_data ){
- std::string pattern = crateConfig.get<std::string>("fem_fake_data_pattern", "signalLike");
- // std::string pattern = crateConfig.get<std::string>("fem_fake_data_pattern"); //, "channel");
- //loadFEMFakeData( crateConfig.get<std::string>( "fem_fake_data_pattern", "channel",threshold,baseline ) );
- // loadFEMFakeData( crateConfig.get<std::string>( pattern,threshold,baseline));
- loadFEMFakeData(pattern, threshold, baseline);
- }
+ loadFEMFakeData( crateConfig.get<std::string>( "fem_fake_data_pattern", "channel" ) );
+ }
}
}
diff --git a/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/NevisTPCFEM.h b/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/NevisTPCFEM.h
index 4bc634a2..6249bebc 100644
--- a/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/NevisTPCFEM.h
+++ b/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/NevisTPCFEM.h
@@ -76,10 +76,7 @@ namespace nevistpc {
private:
bool badstat;
- std::vector<unsigned int> threshold;
- std::vector<unsigned int> baseline;
-
- };
+ };
class NevisTPCFEM: public UsesControllerModule {
@@ -262,8 +259,8 @@ namespace nevistpc {
void setFEMBipolar(data_payload_t const &size);
void setLoadBaseline(data_payload_t const &chan, data_payload_t const &size);
void enableFEMFakeData(bool const &flag);
- // void loadFEMFakeData(std::string const &pattern);
- void loadFEMFakeData(std::string const &pattern, const std::vector<unsigned int>& threshold, const std::vector<unsigned int>& baseline);
+ void loadFEMFakeData(std::string const &pattern);
+
void runDefaultNUConfig(data_payload_t const&febChanID);
void fem_setup(fhicl::ParameterSet const& configParams);
diff --git a/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/XMITReader.cpp b/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/XMITReader.cpp
index 77acc1c3..c8d49dce 100644
--- a/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/XMITReader.cpp
+++ b/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/XMITReader.cpp
@@ -237,20 +237,9 @@ namespace nevistpc {
_dma1.readSize = ( size_t ) size;
_dma2.readSize = ( size_t ) size;
-
- // TLOG(TLVL_INFO) << "loopnumber : " << _loopNumber;
dma_buffer& dma = ( ( _loopNumber % 2 ) == 0 ) ? _dma1 : _dma2;
-
- // Print which buffer is being used and its size
- /* if (( _loopNumber % 2 ) == 0) {
- TLOG(TLVL_INFO) << "Using _dma1, size = " << _dma1.bufferSize ;
- } else {
- TLOG(TLVL_INFO) << "Using _dma2, size = " << _dma2.bufferSize ;
- }*/
-
-
if ( _isFirstEverDMA ) {
dmaInitializeOnFirstLoop();
@@ -324,10 +313,6 @@ namespace nevistpc {
_loopNumber++;
// exit(0);
-
- lastUsedBuffer_ = &dma;
- dma.in_use = true;
-
return readSize;
}
diff --git a/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/XMITReader.h b/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/XMITReader.h
index 363d15df..c4e5dc85 100644
--- a/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/XMITReader.h
+++ b/sbndaq-artdaq/Generators/SBND/NevisTPC/nevishwutils/XMITReader.h
@@ -27,21 +27,15 @@ namespace nevistpc{
DWORD r_cs_reg;
size_t bufferSize;
size_t readSize;
- bool in_use = false;
};
class XMITReader{
- private:
- dma_buffer* lastUsedBuffer_ = nullptr;
-
public:
enum class dma_completion_status: uint8_t {
timeout = 0,
complete
};
- dma_buffer* lastUsedBuffer() const { return lastUsedBuffer_; }
-
explicit XMITReader ( std::string const& streamName, fhicl::ParameterSet const & ps );