MiniballSort
Loading...
Searching...
No Matches
Settings.cc
Go to the documentation of this file.
1#include "Settings.hh"
2
11
12MiniballSettings::MiniballSettings( std::string filename ) {
13
14 SetFile( filename );
17
18}
19
21
22 // Loop over all channels and see what we find
23 for( unsigned int i = 0; i < n_febex_sfp; ++i ){
24
25 for( unsigned int j = 0; j < n_febex_board; ++j ){
26
27 for( unsigned int k = 0; k < n_febex_ch; ++k ){
28
29 std::vector<std::string> active_chs;
30 std::string detname;
31
32 // Is it a Miniball?
33 if( IsMiniball(i,j,k) ){
34
35 detname = "Miniball_";
36 detname += std::to_string( GetMiniballCluster(i,j,k) ) + "_";
37 detname += std::to_string( GetMiniballCrystal(i,j,k) ) + "_";
38 detname += std::to_string( GetMiniballSegment(i,j,k) ) + "\n";
39 active_chs.push_back( detname );
40
41 }
42
43 // Is it a CD?
44 if( IsCD(i,j,k) ){
45
46 detname = "CD_";
47 detname += std::to_string( GetCDDetector(i,j,k) ) + "_";
48 detname += std::to_string( GetCDSector(i,j,k) ) + "_";
49 detname += std::to_string( GetCDStrip(i,j,k) ) + ".";
50 detname += std::to_string( GetCDSide(i,j,k) ) + "\n";
51 active_chs.push_back( detname );
52
53 }
54
55 // Is it a Pad?
56 if( IsPad(i,j,k) ){
57
58 detname = "Pad_";
59 detname += std::to_string( GetPadDetector(i,j,k) ) + "_";
60 detname += std::to_string( GetPadSector(i,j,k) ) + "\n";
61 active_chs.push_back( detname );
62
63 }
64
65 // Is it a Spede?
66 if( IsSpede(i,j,k) ){
67
68 detname = "Spede_";
69 detname += std::to_string( GetSpedeSegment(i,j,k) ) + "\n";
70 active_chs.push_back( detname );
71
72 }
73
74 // Is it a beam dump?
75 if( IsBeamDump(i,j,k) ){
76
77 detname = "BeamDump_";
78 detname += std::to_string( GetBeamDumpDetector(i,j,k) ) + "\n";
79 active_chs.push_back( detname );
80
81 }
82
83 // Is it an IonChamber?
84 if( IsIonChamber(i,j,k) ){
85
86 detname = "IonChamber_";
87 detname += std::to_string( GetIonChamberLayer(i,j,k) ) + "\n";
88 active_chs.push_back( detname );
89
90 }
91
92 // Is it a pulser?
93 if( IsPulser(i,j,k) ){
94
95 detname = "Pulser_";
96 detname += std::to_string( GetPulser(i,j,k) ) + "\n";
97 active_chs.push_back( detname );
98
99 }
100
101 // Is it EBIS?
102 if( GetEBISSfp() == i && GetEBISBoard() == j && GetEBISChannel() == k )
103 active_chs.push_back( "EBIS\n" );
104
105 // Is it T1?
106 if( GetT1Sfp() == i && GetT1Board() == j && GetT1Channel() == k )
107 active_chs.push_back( "T1\n" );
108
109 // Is it SC?
110 if( GetSCSfp() == i && GetSCBoard() == j && GetSCChannel() == k )
111 active_chs.push_back( "SC\n" );
112
113 // Is it RILIS?
114 if( GetRILISSfp() == i && GetRILISBoard() == j && GetRILISChannel() == k )
115 active_chs.push_back( "RILIS\n" );
116
117
118 // Check now if we have multiple detectors in this channel
119 if( active_chs.size() > 1 ) {
120
121 std::cout << "Too many detectors in SFP " << i;
122 std::cout << ", board " << j << ", channel " << k << ":\n";
123 for( unsigned int q = 0; q < active_chs.size(); ++q )
124 std::cout << active_chs.at(q);
125
126 } // more than one detector
127
128 } // k = ch
129
130 } // j = board
131
132 } // i = sfp
133
134}
135
137
138 TEnv *config = new TEnv( fInputFile.data() );
139
140 // FEBEX initialisation
141 n_febex_sfp = config->GetValue( "NumberOfFebexSfps", 2 );
142 n_febex_board = config->GetValue( "NumberOfFebexBoards", 16 );
143 n_febex_ch = config->GetValue( "NumberOfFebexChannels", 16 );
144
145 // DGF initialisation
146 n_dgf_mod = config->GetValue( "NumberOfDgfModules", 0 );
147 n_dgf_ts_mod = config->GetValue( "NumberOfDgfTimestampModules", 5 );
148 n_dgf_ch = config->GetValue( "NumberOfDgfChannels", 4 );
149 dgf_mod_offset = config->GetValue( "DgfModuleOffset", 1 );
150 dgf_ts_mod_offset = config->GetValue( "DgfTimestampModuleOffset", 49 );
151 dgf_ts_delay = config->GetValue( "DgfTimestampDelay", 65527 );
152 dgf_ts_units = config->GetValue( "DgfTimestampUnits", 25. );
153
154 // CAEN ADC initialisation
155 n_caen_mod = config->GetValue( "NumberOfCaenAdcModules", 0 );
156 n_caen_ch = config->GetValue( "NumberOfCaenAdcChannels", 32 );
157 caen_mod_offset = config->GetValue( "CaenAdcModuleOffset", 60 );
158 caen_ts_units = config->GetValue( "CaenAdcTimestampUnits", 25. );
159
160 // Mesytec ADC initialisation
161 n_madc_mod = config->GetValue( "NumberOfMesytecAdcModules", 0 );
162 n_madc_ch = config->GetValue( "NumberOfMesytecAdcChannels", 32 );
163 madc_mod_offset = config->GetValue( "MesytecAdcModuleOffset", 55 );
164 madc_ts_units = config->GetValue( "MesytecAdcTimestampUnits", 25. );
165
166 // Scaler unit initialisation
167 n_scaler_unit = config->GetValue( "NumberOfScalerUnits", 1 );
168 scaler_unit_offset = config->GetValue( "ScalerUnitOffset", 0 );
169
170 // Pattern unit initialisation
171 n_pattern_unit = config->GetValue( "NumberOfPatternUnits", 1 );
172 pattern_unit_offset = config->GetValue( "PatternUnitOffset", 67 );
173
174 // VME ID initialisation
175 dgf_vme_first = config->GetValue( "Dgf.VME.First", 1 );
176 dgf_vme_last = config->GetValue( "Dgf.VME.Last", 10 );
177 adc_vme_first = config->GetValue( "Adc.VME.First", 11 );
178 adc_vme_last = config->GetValue( "Adc.VME.Last", 19 );
179 scaler_vme_first = config->GetValue( "Scaler.VME.First", 20 );
180 scaler_vme_last = config->GetValue( "Scaler.VME.Last", 20 );
181 pattern_vme_first = config->GetValue( "Pattern.VME.First", 21 );
182 pattern_vme_last = config->GetValue( "Pattern.VME.Last", 21 );
183 dgfscaler_vme_first = config->GetValue( "DgfScaler.VME.First", 22 );
184 dgfscaler_vme_last = config->GetValue( "DgfScaler.VME.Last", 24 );
185
186 // Miniball array initialisation
187 n_mb_cluster = config->GetValue( "NumberOfMiniballClusters", 8 );
188 n_mb_crystal = config->GetValue( "NumberOfMiniballCrystals", 3 );
189 n_mb_segment = config->GetValue( "NumberOfMiniballSegments", 7 );
190
191 // CD detector initialisation
192 n_cd_det = config->GetValue( "NumberOfCDDetectors", 1 );
193 n_cd_sector = config->GetValue( "NumberOfCDSectors", 4 );
194 n_cd_side = 2; // always 2, you cannot change this!
195 n_cd_pstrip = config->GetValue( "NumberOfCDStrips.P", 16 );
196 n_cd_nstrip = config->GetValue( "NumberOfCDStrips.N", 12 );
197
198 // Beam dump initialisation
199 n_bd_det = config->GetValue( "NumberOfBeamDumpDetectors", 1 );
200
201 // SPEDE initialisation
202 //n_spede_seg = config->GetValue( "NumberOfSpedeSegments", 24 );
203 n_spede_seg = config->GetValue( "NumberOfSpedeSegments", 0 );
204
205 // IonChamber initialisation
206 n_ic_layer = config->GetValue( "NumberOfIonChamberLayers", 2 );
207
208 // Pulser events
209 n_pulsers = config->GetValue( "NumberOfPulsers", 2 );
210 if( n_pulsers > 10 ) {
211
212 std::cout << "Number of pulsers limited to 10" << std::endl;
213 n_pulsers = 10;
214
215 }
216
217 // Info code initialisation
218 pause_code = 2;
219 resume_code = 3;
220 sync_msb_code = 14;
221 sync_hsb_code = 15;
222 tm_msb_code = 7;
223 tm_hsb_code = 8;
224 pulser_code = 30; // code for first channel, others are pulser_code+id
225 ebis_sfp = config->GetValue( "EBIS.Sfp", 1 );
226 ebis_board = config->GetValue( "EBIS.Board", 10 );
227 ebis_ch = config->GetValue( "EBIS.Channel", 0 ); // ch 0 if in DGF too!
228 ebis_dgf = config->GetValue( "EBIS.Dgf", 52 );
229 ebis_code = 21;
230 t1_sfp = config->GetValue( "T1.Sfp", 1 );
231 t1_board = config->GetValue( "T1.Board", 10 );
232 t1_ch = config->GetValue( "T1.Channel", 2 );
233 t1_dgf = config->GetValue( "T1.Dgf", 52 );
234 t1_code = 22;
235 sc_sfp = config->GetValue( "SC.Sfp", 1 );
236 sc_board = config->GetValue( "SC.Board", 10 );
237 sc_ch = config->GetValue( "SC.Channel", 4 );
238 sc_dgf = config->GetValue( "SC.Dgf", 52 );
239 sc_code = 23;
240 laser_sfp = config->GetValue( "RILIS.Sfp", 1 );
241 laser_board = config->GetValue( "RILIS.Board", 10 );
242 laser_ch = config->GetValue( "RILIS.Channel", 6 );
243 laser_pattern = config->GetValue( "RILIS.Pattern", 8 ); // channel for laser status
244 laser_code = 24;
245
246
247 // Event builder
248 event_window = config->GetValue( "EventWindow", 3e3 );
249 mbs_event_sort = config->GetValue( "MbsEventSort", true );
250
251 // Hit windows for complex events
252 mb_hit_window = config->GetValue( "MiniballCrystalHitWindow", 400. );
253 ab_hit_window = config->GetValue( "MiniballAddbackHitWindow", 400. );
254 cd_hit_window = config->GetValue( "CDHitWindow", 150. );
255 pad_hit_window = config->GetValue( "PadHitWindow", 150. );
256 ic_hit_window = config->GetValue( "IonChamberHitWindow", 500. );
257
258
259 // Data things
260 block_size = config->GetValue( "DataBlockSize", 0x10000 );
261 flag_febex_only = config->GetValue( "FebexOnlyData", true );
262
263
264 // Pileup and clipped rejection
265 pileup_reject = config->GetValue( "PileupRejection",
266 config->GetValue( "PileUpRejection", false ) );
267 clipped_reject = config->GetValue( "ClippedRejection", true );
268
269
270 // Buffer full rejection
271 bufferfull_reject = config->GetValue( "BufferFullRejection", false );
272 bufferpart_reject = config->GetValue( "BufferPartRejection", false );
273
274
275 // Electronics mapping
276 // Will depend on whether we have FEBEX or DGF/ADC combo
277 unsigned int i_size = n_febex_sfp;
278 unsigned int j_size_dgf = n_febex_board;
279 unsigned int j_size_adc = n_febex_board;
280 unsigned int k_size_dgf = n_febex_ch;
281 unsigned int k_size_adc = n_febex_ch;
282
283 // We don't have FEBEX if any of the SFP/board/ch is = 0
284 // but for confidence, check that we have some ADCs or DGFs
285 if( ( !n_febex_sfp || !n_febex_board || !n_febex_ch ) &&
286 ( n_madc_mod || n_caen_mod || n_dgf_mod ) ) {
287
288 i_size = 1;
289 j_size_dgf = GetNumberOfDgfModules();
290 j_size_adc = GetNumberOfAdcModules();
291 k_size_dgf = GetNumberOfDgfChannels();
292 k_size_adc = GetMaximumNumberOfAdcChannels();
293
294 }
295
296 // Resize it all
297 mb_cluster.resize( i_size );
298 mb_crystal.resize( i_size );
299 mb_segment.resize( i_size );
300 cd_det.resize( i_size );
301 cd_sector.resize( i_size );
302 cd_side.resize( i_size );
303 cd_strip.resize( i_size );
304 pad_det.resize( i_size );
305 pad_sector.resize( i_size );
306 bd_det.resize( i_size );
307 spede_seg.resize( i_size );
308 ic_layer.resize( i_size );
309 pulser.resize( i_size );
310
311 for( unsigned int i = 0; i < i_size; ++i ){
312
313 mb_cluster[i].resize( j_size_dgf );
314 mb_crystal[i].resize( j_size_dgf );
315 mb_segment[i].resize( j_size_dgf );
316 bd_det[i].resize( j_size_dgf );
317 spede_seg[i].resize( j_size_dgf );
318 pulser[i].resize( j_size_dgf );
319
320 // DGFs or FEBEX
321 for( unsigned int j = 0; j < j_size_dgf; ++j ){
322
323 mb_cluster[i][j].resize( k_size_dgf );
324 mb_crystal[i][j].resize( k_size_dgf );
325 mb_segment[i][j].resize( k_size_dgf );
326 bd_det[i][j].resize( k_size_dgf );
327 spede_seg[i][j].resize( k_size_dgf );
328 pulser[i][j].resize( k_size_dgf );
329
330 for( unsigned int k = 0; k < k_size_dgf; ++k ){
331
332 mb_cluster[i][j][k] = -1;
333 mb_crystal[i][j][k] = -1;
334 mb_segment[i][j][k] = -1;
335 bd_det[i][j][k] = -1;
336 spede_seg[i][j][k] = -1;
337 pulser[i][j][k] = -1;
338
339 } // k: febex/dgf ch
340
341 } // j: febex/dgf board
342
343 cd_det[i].resize( j_size_adc );
344 cd_sector[i].resize( j_size_adc );
345 cd_side[i].resize( j_size_adc );
346 cd_strip[i].resize( j_size_adc );
347 pad_det[i].resize( j_size_adc );
348 pad_sector[i].resize( j_size_adc );
349 ic_layer[i].resize( j_size_adc );
350
351 // ADCs or FEBEX
352 for( unsigned int j = 0; j < j_size_adc; ++j ){
353
354 cd_det[i][j].resize( k_size_adc );
355 cd_sector[i][j].resize( k_size_adc );
356 cd_side[i][j].resize( k_size_adc );
357 cd_strip[i][j].resize( k_size_adc );
358 pad_det[i][j].resize( k_size_adc );
359 pad_sector[i][j].resize( k_size_adc );
360 ic_layer[i][j].resize( k_size_adc );
361
362 for( unsigned int k = 0; k < k_size_adc; ++k ){
363
364 cd_det[i][j][k] = -1;
365 cd_sector[i][j][k] = -1;
366 cd_side[i][j][k] = -1;
367 cd_strip[i][j][k] = -1;
368 pad_det[i][j][k] = -1;
369 pad_sector[i][j][k] = -1;
370 ic_layer[i][j][k] = -1;
371
372 } // k: febex/adc ch
373
374 } // j: febex/adc board
375
376 } // i: febex sfp
377
378
379 // Miniball array electronics mapping
380 int d, s, b, c, g;
381 mb_sfp.resize( n_mb_cluster );
382 mb_board.resize( n_mb_cluster );
383 mb_dgf.resize( n_mb_cluster );
384 mb_ch.resize( n_mb_cluster );
385 mb_veto.resize( n_mb_cluster );
386
387 for( unsigned int i = 0; i < n_mb_cluster; ++i ){
388
389 mb_sfp[i].resize( n_mb_crystal );
390 mb_board[i].resize( n_mb_crystal );
391 mb_dgf[i].resize( n_mb_crystal );
392 mb_ch[i].resize( n_mb_crystal );
393 mb_veto[i].resize( n_mb_crystal );
394
395 for( unsigned int j = 0; j < n_mb_crystal; ++j ){
396
397 mb_sfp[i][j].resize( n_mb_segment );
398 mb_board[i][j].resize( n_mb_segment );
399 mb_dgf[i][j].resize( n_mb_segment );
400 mb_ch[i][j].resize( n_mb_segment );
401 mb_veto[i][j].resize( n_mb_segment );
402
403 for( unsigned int k = 0; k < n_mb_segment; ++k ){
404
405 d = i*3 + j; // Crystal ordering: 0-23
406 s = 0; // spread 24 crystals over 1 SFPs
407 b = d/2; // 2 crystals per board
408 c = k + 9*(d&0x1); // odd crystals starts at ch9
409 g = d*2; // dgf number is 2 * detector number
410 if( k > 2 ) g++; // but add one for segments 3-6
411 mb_sfp[i][j][k] = config->GetValue( Form( "Miniball_%d_%d_%d.Sfp", i, j, k ), s );
412 mb_board[i][j][k] = config->GetValue( Form( "Miniball_%d_%d_%d.Board", i, j, k ), b );
413 mb_dgf[i][j][k] = config->GetValue( Form( "Miniball_%d_%d_%d.Dgf", i, j, k ), g );
414 mb_ch[i][j][k] = config->GetValue( Form( "Miniball_%d_%d_%d.Channel", i, j, k ), c );
415 mb_veto[i][j][k] = config->GetValue( Form( "Miniball_%d_%d_%d.Veto", i, j, k ), false );
416
417 // Check FEBEX inputs aren't overlapped
418 if( mb_sfp[i][j][k] < n_febex_sfp && n_febex_sfp > 0 &&
419 mb_board[i][j][k] < n_febex_board && n_febex_board > 0 &&
420 mb_ch[i][j][k] < n_febex_ch && n_febex_ch > 0 ){
421
422 if( mb_cluster[mb_sfp[i][j][k]][mb_board[i][j][k]][mb_ch[i][j][k]] >= 0 ||
423 mb_crystal[mb_sfp[i][j][k]][mb_board[i][j][k]][mb_ch[i][j][k]] >= 0 ||
424 mb_segment[mb_sfp[i][j][k]][mb_board[i][j][k]][mb_ch[i][j][k]] >= 0 ) {
425
426 std::cout << "You have defined two Miniball detectors in the same channel:" << std::endl;
427 std::cout << "\tMiniball_" << mb_cluster[mb_sfp[i][j][k]][mb_board[i][j][k]][mb_ch[i][j][k]] << "_";
428 std::cout << mb_crystal[mb_sfp[i][j][k]][mb_board[i][j][k]][mb_ch[i][j][k]] << "_";
429 std::cout << mb_segment[mb_sfp[i][j][k]][mb_board[i][j][k]][mb_ch[i][j][k]] << " and ";
430 std::cout << "Miniball_" << i << "_" << j << "_" << k << std::endl;
431
432 }
433
434 else {
435
436 mb_cluster[mb_sfp[i][j][k]][mb_board[i][j][k]][mb_ch[i][j][k]] = i;
437 mb_crystal[mb_sfp[i][j][k]][mb_board[i][j][k]][mb_ch[i][j][k]] = j;
438 mb_segment[mb_sfp[i][j][k]][mb_board[i][j][k]][mb_ch[i][j][k]] = k;
439
440 }
441
442 }
443
444 // Check DGF inputs aren't overlapped
445 else if( mb_dgf[i][j][k] < n_dgf_mod && n_dgf_mod > 0 &&
446 mb_ch[i][j][k] < n_dgf_ch && n_dgf_ch > 0 ){
447
448 if( mb_cluster[0][mb_dgf[i][j][k]][mb_ch[i][j][k]] >= 0 ||
449 mb_crystal[0][mb_dgf[i][j][k]][mb_ch[i][j][k]] >= 0 ||
450 mb_segment[0][mb_dgf[i][j][k]][mb_ch[i][j][k]] >= 0 ) {
451
452 std::cout << "You have defined two Miniball detectors in the same channel:" << std::endl;
453 std::cout << "\tMiniball_" << mb_cluster[0][mb_dgf[i][j][k]][mb_ch[i][j][k]] << "_";
454 std::cout << mb_crystal[0][mb_dgf[i][j][k]][mb_ch[i][j][k]] << "_";
455 std::cout << mb_segment[0][mb_dgf[i][j][k]][mb_ch[i][j][k]] << " and ";
456 std::cout << "Miniball_" << i << "_" << j << "_" << k << std::endl;
457
458 }
459
460 else {
461
462 mb_cluster[0][mb_dgf[i][j][k]][mb_ch[i][j][k]] = i;
463 mb_crystal[0][mb_dgf[i][j][k]][mb_ch[i][j][k]] = j;
464 mb_segment[0][mb_dgf[i][j][k]][mb_ch[i][j][k]] = k;
465
466 }
467
468
469 }
470
471 else {
472
473 std::cerr << "Dodgy Miniball settings: sfp = " << mb_sfp[i][j][k];
474 if( n_febex_board ) std::cerr << ", board = " << mb_board[i][j][k];
475 if( n_dgf_mod ) std::cerr << ", dgf = " << mb_dgf[i][j][k];
476 std::cerr << ", channel = " << mb_ch[i][j][k] << std::endl;
477
478 }
479
480 } // k: mb segment
481
482 } // j: mb crystal
483
484 } // i: mb cluster
485
486
487 // CD detector electronics mapping
488 unsigned int side_size;
489 std::string side_str;
490 cd_sfp.resize( n_cd_det );
491 cd_board.resize( n_cd_det );
492 cd_adc.resize( n_cd_det );
493 cd_ch.resize( n_cd_det );
494
495 for( unsigned int i = 0; i < n_cd_det; ++i ){
496
497 cd_sfp[i].resize( n_cd_sector );
498 cd_board[i].resize( n_cd_sector );
499 cd_adc[i].resize( n_cd_sector );
500 cd_ch[i].resize( n_cd_sector );
501
502 for( unsigned int j = 0; j < n_cd_sector; ++j ){
503
504 cd_sfp[i][j].resize( n_cd_side );
505 cd_board[i][j].resize( n_cd_side );
506 cd_adc[i][j].resize( n_cd_side );
507 cd_ch[i][j].resize( n_cd_side );
508
509 for( unsigned int k = 0; k < n_cd_side; ++k ){
510
511 // p or n side?
512 if( k == 0 ) side_str = "P";
513 else side_str = "N";
514
515 // p or n side?
516 if( k == 0 ) side_size = n_cd_pstrip;
517 else side_size = n_cd_nstrip;
518
519 cd_sfp[i][j][k].resize( side_size );
520 cd_board[i][j][k].resize( side_size );
521 cd_adc[i][j][k].resize( side_size );
522 cd_ch[i][j][k].resize( side_size );
523
524 for( unsigned int l = 0; l < side_size; ++l ){
525
526 s = 1; // sfp number - all in SFP 1
527 b = j*2 + k; // boards go 0-7
528 c = l;
529 g = j; // adc number is same as segment by default
530 cd_sfp[i][j][k][l] = config->GetValue( Form( "CD_%d_%d_%d.%s.Sfp", i, j, l, side_str.data() ), s );
531 cd_board[i][j][k][l] = config->GetValue( Form( "CD_%d_%d_%d.%s.Board", i, j, l, side_str.data() ), b );
532 cd_adc[i][j][k][l] = config->GetValue( Form( "CD_%d_%d_%d.%s.Adc", i, j, l, side_str.data() ), g );
533 cd_ch[i][j][k][l] = config->GetValue( Form( "CD_%d_%d_%d.%s.Channel", i, j, l, side_str.data() ), c );
534
535 if( cd_sfp[i][j][k][l] < n_febex_sfp && n_febex_sfp > 0 &&
536 cd_board[i][j][k][l] < n_febex_board && n_febex_board > 0 &&
537 cd_ch[i][j][k][l] < n_febex_ch && n_febex_ch > 0 ){
538
539 if( cd_det[cd_sfp[i][j][k][l]][cd_board[i][j][k][l]][cd_ch[i][j][k][l]] >= 0 ||
540 cd_sector[cd_sfp[i][j][k][l]][cd_board[i][j][k][l]][cd_ch[i][j][k][l]] >= 0 ||
541 cd_side[cd_sfp[i][j][k][l]][cd_board[i][j][k][l]][cd_ch[i][j][k][l]] >= 0 ||
542 cd_strip[cd_sfp[i][j][k][l]][cd_board[i][j][k][l]][cd_ch[i][j][k][l]] >= 0 ) {
543
544 std::cout << "You have defined two CD detector strips in the same channel:" << std::endl;
545 std::cout << "\tCD_" << cd_det[cd_sfp[i][j][k][l]][cd_board[i][j][k][l]][cd_ch[i][j][k][l]] << "_";
546 std::cout << cd_sector[cd_sfp[i][j][k][l]][cd_board[i][j][k][l]][cd_ch[i][j][k][l]] << "_";
547 std::cout << cd_strip[cd_sfp[i][j][k][l]][cd_board[i][j][k][l]][cd_ch[i][j][k][l]];
548 if( k == 0 ) std::cout << ".P and" << std::endl;
549 else std::cout << ".N and CD_" << std::endl;
550 std::cout << i << "_" << j << "_" << l;
551 if( k == 0 ) std::cout << ".P" << std::endl;
552 else std::cout << ".N" << std::endl;
553
554 }
555
556 else {
557
558 cd_det[cd_sfp[i][j][k][l]][cd_board[i][j][k][l]][cd_ch[i][j][k][l]] = i;
559 cd_sector[cd_sfp[i][j][k][l]][cd_board[i][j][k][l]][cd_ch[i][j][k][l]] = j;
560 cd_side[cd_sfp[i][j][k][l]][cd_board[i][j][k][l]][cd_ch[i][j][k][l]] = k;
561 cd_strip[cd_sfp[i][j][k][l]][cd_board[i][j][k][l]][cd_ch[i][j][k][l]] = l;
562
563 }
564
565 }
566
567 else if( cd_adc[i][j][k][l] < GetNumberOfAdcModules() && GetNumberOfAdcModules() > 0 &&
569
570
571 if( cd_det[0][cd_adc[i][j][k][l]][cd_ch[i][j][k][l]] >= 0 ||
572 cd_sector[0][cd_adc[i][j][k][l]][cd_ch[i][j][k][l]] >= 0 ||
573 cd_side[0][cd_adc[i][j][k][l]][cd_ch[i][j][k][l]] >= 0 ||
574 cd_strip[0][cd_adc[i][j][k][l]][cd_ch[i][j][k][l]] >= 0 ) {
575
576 std::cout << "You have defined two CD detector strips in the same channel:" << std::endl;
577 std::cout << "\tCD_" << cd_det[0][cd_adc[i][j][k][l]][cd_ch[i][j][k][l]] << "_";
578 std::cout << cd_sector[0][cd_adc[i][j][k][l]][cd_ch[i][j][k][l]] << "_";
579 std::cout << cd_strip[0][cd_adc[i][j][k][l]][cd_ch[i][j][k][l]];
580 if( k == 0 ) std::cout << ".P and" << std::endl;
581 else std::cout << ".N and CD_" << std::endl;
582 std::cout << i << "_" << j << "_" << l;
583 if( k == 0 ) std::cout << ".P" << std::endl;
584 else std::cout << ".N" << std::endl;
585
586 }
587
588 else {
589
590 cd_det[0][cd_adc[i][j][k][l]][cd_ch[i][j][k][l]] = i;
591 cd_sector[0][cd_adc[i][j][k][l]][cd_ch[i][j][k][l]] = j;
592 cd_side[0][cd_adc[i][j][k][l]][cd_ch[i][j][k][l]] = k;
593 cd_strip[0][cd_adc[i][j][k][l]][cd_ch[i][j][k][l]] = l;
594
595 }
596
597 }
598
599 else {
600
601 std::cerr << "Dodgy CD settings: sfp = " << cd_sfp[i][j][k][l];
602 if( n_febex_board > 0 ) std::cerr << ", board = " << cd_board[i][j][k][l];
603 if( GetNumberOfAdcModules() > 0 ) std::cerr << ", adc = " << cd_adc[i][j][k][l];
604 std::cerr << ", channel = " << cd_ch[i][j][k][l] << std::endl;
605
606 }
607
608 } // l: cd strips
609
610 } // k: cd side
611
612 } // j: cd sector
613
614 } // i: cd detector
615
616
617 // PAD detector electronics mapping
618 pad_sfp.resize( n_cd_det );
619 pad_board.resize( n_cd_det );
620 pad_adc.resize( n_cd_det );
621 pad_ch.resize( n_cd_det );
622
623 for( unsigned int i = 0; i < n_cd_det; ++i ){
624
625 pad_sfp[i].resize( n_cd_sector );
626 pad_board[i].resize( n_cd_sector );
627 pad_adc[i].resize( n_cd_sector );
628 pad_ch[i].resize( n_cd_sector );
629
630 for( unsigned int j = 0; j < n_cd_sector; ++j ){
631
632 s = 1;
633 b = 8;
634 c = i*n_cd_sector+j;
635 g = i;
636 pad_sfp[i][j] = config->GetValue( Form( "Pad_%d_%d.Sfp", i, j ), s );
637 pad_board[i][j] = config->GetValue( Form( "Pad_%d_%d.Board", i, j ), b );
638 pad_adc[i][j] = config->GetValue( Form( "Pad_%d_%d.Adc", i, j ), g );
639 pad_ch[i][j] = config->GetValue( Form( "Pad_%d_%d.Channel", i, j ), c );
640
641 if( pad_sfp[i][j] < n_febex_sfp && n_febex_sfp > 0 &&
642 pad_board[i][j] < n_febex_board && n_febex_board > 0 &&
643 pad_ch[i][j] < n_febex_ch && n_febex_ch > 0 ){
644
645 if( pad_det[pad_sfp[i][j]][pad_board[i][j]][pad_ch[i][j]] >= 0 ||
646 pad_sector[pad_sfp[i][j]][pad_board[i][j]][pad_ch[i][j]] >= 0 ) {
647
648 std::cout << "You have defined two Pad detectors in the same channel:" << std::endl;
649 std::cout << "\tPad_" << pad_det[pad_sfp[i][j]][pad_board[i][j]][pad_ch[i][j]] << "_";
650 std::cout << pad_sector[pad_sfp[i][j]][pad_board[i][j]][pad_ch[i][j]] << "and";
651 std::cout << "Pad_" << i << "_" << j << std::endl;
652
653 }
654
655 else {
656
657 pad_det[pad_sfp[i][j]][pad_board[i][j]][pad_ch[i][j]] = i;
658 pad_sector[pad_sfp[i][j]][pad_board[i][j]][pad_ch[i][j]] = j;
659
660 }
661
662 }
663
664 else if( pad_adc[i][j] < GetNumberOfAdcModules() && GetNumberOfAdcModules() > 0 &&
666
667 if( pad_det[0][pad_adc[i][j]][pad_ch[i][j]] >= 0 ||
668 pad_sector[0][pad_adc[i][j]][pad_ch[i][j]] >= 0 ) {
669
670 std::cout << "You have defined two Pad detectors in the same channel:" << std::endl;
671 std::cout << "\tPad_" << pad_det[0][pad_adc[i][j]][pad_ch[i][j]] << "_";
672 std::cout << pad_sector[0][pad_adc[i][j]][pad_ch[i][j]] << "and";
673 std::cout << "Pad_" << i << "_" << j << std::endl;
674
675 }
676
677 else {
678
679 pad_det[0][pad_adc[i][j]][pad_ch[i][j]] = i;
680 pad_sector[0][pad_adc[i][j]][pad_ch[i][j]] = j;
681
682 }
683
684 }
685
686 else {
687
688 std::cerr << "Dodgy PAD settings: sfp = " << pad_sfp[i][j];
689 if( n_febex_board > 0 ) std::cerr << ", board = " << pad_board[i][j];
690 if( GetNumberOfAdcModules() > 0 ) std::cerr << ", adc = " << pad_adc[i][j];
691 std::cerr << ", channel = " << pad_ch[i][j] << std::endl;
692
693 }
694
695 } // j: cd sector
696
697 } // i: cd detector
698
699
700 // Beam dump detector mapping
701 bd_sfp.resize( n_bd_det );
702 bd_board.resize( n_bd_det );
703 bd_dgf.resize( n_bd_det );
704 bd_ch.resize( n_bd_det );
705
706 for( unsigned int i = 0; i < n_bd_det; ++i ){
707
708 bd_sfp[i] = config->GetValue( Form( "BeamDump_%d.Sfp", i ), 1 );
709 bd_board[i] = config->GetValue( Form( "BeamDump_%d.Board", i ), 10 );
710 bd_dgf[i] = config->GetValue( Form( "BeamDump_%d.Dgf", i ), 54 );
711 bd_ch[i] = config->GetValue( Form( "BeamDump_%d.Channel", i ), (int)(i*2+1) );
712
713 if( bd_sfp[i] < n_febex_sfp && n_febex_sfp > 0 &&
715 bd_ch[i] < n_febex_ch && n_febex_ch > 0 ){
716
717 if( bd_det[bd_sfp[i]][bd_board[i]][bd_ch[i]] >= 0 ){
718
719 std::cout << "You have defined two beam-dump detectors in the same channel:" << std::endl;
720 std::cout << "\tBeamDump_" << bd_det[bd_sfp[i]][bd_board[i]][bd_ch[i]] << " and ";
721 std::cout << "BeamDump_" << i << std::endl;
722
723 }
724
725 else {
726
727 bd_det[bd_sfp[i]][bd_board[i]][bd_ch[i]] = i;
728
729 }
730
731 }
732
733 else if( bd_dgf[i] < n_dgf_mod && n_dgf_mod > 0 &&
734 bd_ch[i] < n_dgf_ch && n_dgf_ch > 0 ){
735
736 if( bd_det[0][bd_dgf[i]][bd_ch[i]] >= 0 ){
737
738 std::cout << "You have defined two beam-dump detectors in the same channel:" << std::endl;
739 std::cout << "\tBeamDump_" << bd_det[0][bd_dgf[i]][bd_ch[i]] << " and ";
740 std::cout << "BeamDump_" << i << std::endl;
741
742 }
743
744 else {
745
746 bd_det[0][bd_dgf[i]][bd_ch[i]] = i;
747
748 }
749
750 }
751
752 else {
753
754 std::cerr << "Dodgy beam-dump settings: sfp = " << bd_sfp[i];
755 if( n_febex_board > 0 ) std::cerr << ", board = " << bd_board[i];
756 if( n_dgf_mod > 0 )std::cerr << ", dgf = " << bd_dgf[i];
757 std::cerr << ", channel = " << bd_ch[i] << std::endl;
758
759 }
760
761 } // i: beam dump detector
762
763
764 // SPEDE detector mapping
765 spede_sfp.resize( n_spede_seg );
766 spede_board.resize( n_spede_seg );
767 spede_ch.resize( n_spede_seg );
768
769 for( unsigned int i = 0; i < n_spede_seg; ++i ){
770
771 s = 1;
772 if( i < 16 ){
773 b = 8;
774 c = i;
775 }
776 else {
777 b = 9;
778 c = i-16;
779 }
780
781 spede_sfp[i] = config->GetValue( Form( "Spede_%d.Sfp", i ), s );
782 spede_board[i] = config->GetValue( Form( "Spede_%d.Board", i ), b );
783 spede_ch[i] = config->GetValue( Form( "Spede_%d.Channel", i ), c );
784
785 if( spede_sfp[i] < n_febex_sfp &&
787 spede_ch[i] < n_febex_ch ){
788
789 if( spede_seg[spede_sfp[i]][spede_board[i]][spede_ch[i]] >= 0 ){
790
791 std::cout << "You have defined two SPEDE segments in the same channel:" << std::endl;
792 std::cout << "\tSpede_" << spede_seg[spede_sfp[i]][spede_board[i]][spede_ch[i]] << " and ";
793 std::cout << "Spede_" << i << std::endl;
794
795 }
796
797 else {
798
799 spede_seg[spede_sfp[i]][spede_board[i]][spede_ch[i]] = i;
800
801 }
802
803 }
804
805 else {
806
807 std::cerr << "Dodgy SPEDE settings: sfp = " << spede_sfp[i];
808 std::cerr << ", board = " << spede_board[i];
809 std::cerr << ", channel = " << spede_ch[i] << std::endl;
810
811 }
812
813
814 } // i: SPEDE detector
815
816 // IonChamber detector mapping
817 ic_sfp.resize( n_ic_layer );
818 ic_board.resize( n_ic_layer );
819 ic_adc.resize( n_ic_layer );
820 ic_ch.resize( n_ic_layer );
821
822 for( unsigned int i = 0; i < n_ic_layer; ++i ){
823
824 ic_sfp[i] = config->GetValue( Form( "IonChamber_%d.Sfp", i ), 1 );
825 ic_board[i] = config->GetValue( Form( "IonChamber_%d.Board", i ), 10 );
826 ic_adc[i] = config->GetValue( Form( "IonChamber_%d.Adc", i ), 4 );
827 ic_ch[i] = config->GetValue( Form( "IonChamber_%d.Channel", i ), (int)((i+n_bd_det)*2+1) );
828
829 if( ic_sfp[i] < n_febex_sfp && n_febex_sfp > 0 &&
831 ic_ch[i] < n_febex_ch && n_febex_ch > 0 ){
832
833 if( ic_layer[ic_sfp[i]][ic_board[i]][ic_ch[i]] >= 0 ){
834
835 std::cout << "You have defined two IonChamber elements in the same channel:" << std::endl;
836 std::cout << "\tIonChamber_" << ic_layer[ic_sfp[i]][ic_board[i]][ic_ch[i]] << " and ";
837 std::cout << "IonChamber_" << i << std::endl;
838
839 }
840
841 else {
842
843 ic_layer[ic_sfp[i]][ic_board[i]][ic_ch[i]] = i;
844
845 }
846
847 }
848
849 else if( ic_adc[i] < GetNumberOfAdcModules() && GetNumberOfAdcModules() > 0 &&
851
852 if( ic_layer[0][ic_adc[i]][ic_ch[i]] >= 0 ){
853
854 std::cout << "You have defined two IonChamber elements in the same channel:" << std::endl;
855 std::cout << "\tIonChamber_" << ic_layer[0][ic_adc[i]][ic_ch[i]] << " and ";
856 std::cout << "IonChamber_" << i << std::endl;
857
858 }
859
860 else {
861
862 ic_layer[0][ic_adc[i]][ic_ch[i]] = i;
863
864 }
865
866 }
867
868 else {
869
870 std::cerr << "Dodgy IonChamber settings: sfp = " << ic_sfp[i];
871 if( n_febex_board > 0 ) std::cerr << ", board = " << ic_board[i];
872 if( GetNumberOfAdcModules() > 0 ) std::cerr << ", adc = " << ic_adc[i];
873 std::cerr << ", channel = " << ic_ch[i] << std::endl;
874
875 }
876
877
878 } // i: IonChamber detector
879
880
881 // Pulser input mapping
882 pulser_sfp.resize( n_pulsers );
883 pulser_board.resize( n_pulsers );
884 pulser_ch.resize( n_pulsers );
885
886 for( unsigned int i = 0; i < n_pulsers; ++i ){
887
888 pulser_sfp[i] = config->GetValue( Form( "Pulser_%d.Sfp", i ), (int)i );
889 pulser_board[i] = config->GetValue( Form( "Pulser_%d.Board", i ), 15 );
890 pulser_ch[i] = config->GetValue( Form( "Pulser_%d.Channel", i ), 15 );
891
892 if( pulser_sfp[i] < n_febex_sfp &&
894 pulser_ch[i] < n_febex_ch ){
895
896 if( pulser[pulser_sfp[i]][pulser_board[i]][pulser_ch[i]] >= 0 ){
897
898 std::cout << "You have defined two Sync Pulsers in the same channel:" << std::endl;
899 std::cout << "\tPulser_" << pulser[pulser_sfp[i]][pulser_board[i]][pulser_ch[i]] << " and ";
900 std::cout << "Pulser_" << i << std::endl;
901
902 }
903
904 else {
905
906 pulser[pulser_sfp[i]][pulser_board[i]][pulser_ch[i]] = i;
907
908 }
909
910 }
911
912 else {
913
914 std::cerr << "Dodgy pulser settings: sfp = " << pulser_sfp[i];
915 std::cerr << ", board = " << pulser_board[i];
916 std::cerr << ", channel = " << pulser_ch[i] << std::endl;
917
918 }
919
920 } // i: pulser inputs
921
922 // Finished
923 delete config;
924
925}
926
927
928bool MiniballSettings::IsMiniball( unsigned int dgf, unsigned int ch ) {
929
931 if( dgf < n_dgf_mod && ch < n_dgf_ch ) {
932
933 if( mb_cluster[0][dgf][ch] >= 0 ) return true;
934 else return false;
935 }
936
937 else {
938
939 std::cerr << "Bad Miniball event: dgf = " << dgf;
940 std::cerr << ", channel = " << ch << std::endl;
941 return false;
942
943 }
944
945}
946
947bool MiniballSettings::IsMiniball( unsigned int sfp, unsigned int board, unsigned int ch ) {
948
950 if( sfp < n_febex_sfp && board < n_febex_board && ch < n_febex_ch ) {
951
952 if( mb_cluster[sfp][board][ch] >= 0 ) return true;
953 else return false;
954
955 }
956
957 else {
958
959 std::cerr << "Bad Miniball event: sfp = " << sfp;
960 std::cerr << ", board = " << board;
961 std::cerr << ", channel = " << ch << std::endl;
962 return false;
963
964 }
965
966}
967
968bool MiniballSettings::IsMiniballSegmentVetoed( unsigned int clu, unsigned int cry, unsigned int seg ) {
969
971 if( clu < n_mb_cluster && cry < n_mb_crystal && seg < n_mb_segment )
972 return mb_veto[clu][cry][seg];
973
974 else {
975
976 std::cerr << "Bad Miniball detector: Cluster = " << clu;
977 std::cerr << ", Crystal = " << cry;
978 std::cerr << ", Segment = " << seg << std::endl;
979 return false;
980
981 }
982
983}
984
985int MiniballSettings::GetMiniballID( unsigned int dgf, unsigned int ch,
986 const std::vector<std::vector<std::vector<int>>> &vector ) {
987
989 if( dgf < n_dgf_mod && ch < n_dgf_ch )
990 return vector[0][dgf][ch];
991
992 else {
993
994 std::cerr << "Bad Miniball event: dgf = " << dgf;
995 std::cerr << ", channel = " << ch << std::endl;
996 return 0;
997
998 }
999
1000}
1001
1002int MiniballSettings::GetMiniballID( unsigned int sfp, unsigned int board, unsigned int ch,
1003 const std::vector<std::vector<std::vector<int>>> &vector ) {
1004
1006 if( sfp < n_febex_sfp && board < n_febex_board && ch < n_febex_ch )
1007 return vector[sfp][board][ch];
1008
1009 else {
1010
1011 std::cerr << "Bad Miniball event: sfp = " << sfp;
1012 std::cerr << ", board = " << board;
1013 std::cerr << ", channel = " << ch << std::endl;
1014 return 0;
1015
1016 }
1017
1018}
1019
1020
1021bool MiniballSettings::IsCD( unsigned int adc, unsigned int ch ) {
1022
1025
1026 if( cd_det[0][adc][ch] >= 0 ) return true;
1027 else return false;
1028
1029 }
1030
1031 else {
1032
1033 std::cerr << "Bad CD event: adc = " << adc;
1034 std::cerr << ", channel = " << ch << std::endl;
1035 return false;
1036
1037 }
1038
1039}
1040
1041bool MiniballSettings::IsCD( unsigned int sfp, unsigned int board, unsigned int ch ) {
1042
1044 if( sfp < n_febex_sfp && board < n_febex_board && ch < n_febex_ch ) {
1045
1046 if( cd_det[sfp][board][ch] >= 0 ) return true;
1047 else return false;
1048
1049 }
1050
1051 else {
1052
1053 std::cerr << "Bad CD event: sfp = " << sfp;
1054 std::cerr << ", board = " << board;
1055 std::cerr << ", channel = " << ch << std::endl;
1056 return false;
1057
1058 }
1059
1060}
1061
1062int MiniballSettings::GetCDID( unsigned int adc, unsigned int ch,
1063 const std::vector<std::vector<std::vector<int>>> &vector ) {
1064
1067 return vector[0][adc][ch];
1068
1069 else {
1070
1071 std::cerr << "Bad CD event: adc = " << adc;
1072 std::cerr << ", channel = " << ch << std::endl;
1073 return 0;
1074
1075 }
1076
1077}
1078
1079int MiniballSettings::GetCDID( unsigned int sfp, unsigned int board, unsigned int ch,
1080 const std::vector<std::vector<std::vector<int>>> &vector ) {
1081
1083 if( sfp < n_febex_sfp && board < n_febex_board && ch < n_febex_ch )
1084 return vector[sfp][board][ch];
1085
1086 else {
1087
1088 std::cerr << "Bad CD event: sfp = " << sfp;
1089 std::cerr << ", board = " << board;
1090 std::cerr << ", channel = " << ch << std::endl;
1091 return 0;
1092
1093 }
1094
1095}
1096
1097bool MiniballSettings::IsPad( unsigned int adc, unsigned int ch ) {
1098
1101
1102 if( pad_det[0][adc][ch] >= 0 ) return true;
1103 else return false;
1104
1105 }
1106
1107 else {
1108
1109 std::cerr << "Bad Pad event: adc = " << adc;
1110 std::cerr << ", channel = " << ch << std::endl;
1111 return false;
1112
1113 }
1114
1115}
1116
1117bool MiniballSettings::IsPad( unsigned int sfp, unsigned int board, unsigned int ch ) {
1118
1120 if( sfp < n_febex_sfp && board < n_febex_board && ch < n_febex_ch ) {
1121
1122 if( pad_det[sfp][board][ch] >= 0 ) return true;
1123 else return false;
1124
1125 }
1126
1127 else {
1128
1129 std::cerr << "Bad Pad event: sfp = " << sfp;
1130 std::cerr << ", board = " << board;
1131 std::cerr << ", channel = " << ch << std::endl;
1132 return false;
1133
1134 }
1135
1136}
1137
1138int MiniballSettings::GetPadDetector( unsigned int adc, unsigned int ch ) {
1139
1142 return pad_det[0][adc][ch];
1143
1144 else {
1145
1146 std::cerr << "Bad Pad event: adc = " << adc;
1147 std::cerr << ", channel = " << ch << std::endl;
1148 return false;
1149
1150 }
1151
1152}
1153
1154int MiniballSettings::GetPadDetector( unsigned int sfp, unsigned int board, unsigned int ch ) {
1155
1157 if( sfp < n_febex_sfp && board < n_febex_board && ch < n_febex_ch )
1158 return pad_det[sfp][board][ch];
1159
1160 else {
1161
1162 std::cerr << "Bad Pad event: sfp = " << sfp;
1163 std::cerr << ", board = " << board;
1164 std::cerr << ", channel = " << ch << std::endl;
1165 return false;
1166
1167 }
1168
1169}
1170
1171int MiniballSettings::GetPadSector( unsigned int adc, unsigned int ch ) {
1172
1175 return pad_sector[0][adc][ch];
1176
1177 else {
1178
1179 std::cerr << "Bad Pad event: adc = " << adc;
1180 std::cerr << ", channel = " << ch << std::endl;
1181 return 0;
1182
1183 }
1184
1185}
1186
1187int MiniballSettings::GetPadSector( unsigned int sfp, unsigned int board, unsigned int ch ) {
1188
1190 if( sfp < n_febex_sfp && board < n_febex_board && ch < n_febex_ch )
1191 return pad_sector[sfp][board][ch];
1192
1193 else {
1194
1195 std::cerr << "Bad Pad event: sfp = " << sfp;
1196 std::cerr << ", board = " << board;
1197 std::cerr << ", channel = " << ch << std::endl;
1198 return 0;
1199
1200 }
1201
1202}
1203
1204bool MiniballSettings::IsBeamDump( unsigned int dgf, unsigned int ch ) {
1205
1207 if( GetBeamDumpDetector(dgf,ch) >= 0 ) return true;
1208 else return false;
1209
1210}
1211
1212bool MiniballSettings::IsBeamDump( unsigned int sfp, unsigned int board, unsigned int ch ) {
1213
1215 if( GetBeamDumpDetector(sfp,board,ch) >= 0 ) return true;
1216 else return false;
1217
1218}
1219
1220int MiniballSettings::GetBeamDumpDetector( unsigned int dgf, unsigned int ch ) {
1221
1223 if( dgf < n_dgf_mod && ch < n_dgf_ch )
1224 return bd_det[0][dgf][ch];
1225
1226 else {
1227
1228 std::cerr << "Bad beam dump event: dgf = " << dgf;
1229 std::cerr << ", channel = " << ch << std::endl;
1230 return 0;
1231
1232 }
1233
1234}
1235
1236int MiniballSettings::GetBeamDumpDetector( unsigned int sfp, unsigned int board, unsigned int ch ) {
1237
1239 if( sfp < n_febex_sfp && board < n_febex_board && ch < n_febex_ch )
1240 return bd_det[sfp][board][ch];
1241
1242 else {
1243
1244 std::cerr << "Bad beam dump event: sfp = " << sfp;
1245 std::cerr << ", board = " << board;
1246 std::cerr << ", channel = " << ch << std::endl;
1247 return 0;
1248
1249 }
1250
1251}
1252
1253bool MiniballSettings::IsSpede( unsigned int sfp, unsigned int board, unsigned int ch ) {
1254
1256 if( GetSpedeSegment(sfp,board,ch) >= 0 ) return true;
1257 else return false;
1258
1259}
1260
1261int MiniballSettings::GetSpedeSegment( unsigned int sfp, unsigned int board, unsigned int ch ) {
1262
1264 if( sfp < n_febex_sfp && board < n_febex_board && ch < n_febex_ch )
1265 return spede_seg[sfp][board][ch];
1266
1267 else {
1268
1269 std::cerr << "Bad SPEDE event: sfp = " << sfp;
1270 std::cerr << ", board = " << board;
1271 std::cerr << ", channel = " << ch << std::endl;
1272 return 0;
1273
1274 }
1275
1276}
1277
1278bool MiniballSettings::IsIonChamber( unsigned int adc, unsigned int ch ) {
1279
1281 if( GetIonChamberLayer(adc,ch) >= 0 ) return true;
1282 else return false;
1283
1284}
1285
1286bool MiniballSettings::IsIonChamber( unsigned int sfp, unsigned int board, unsigned int ch ) {
1287
1289 if( GetIonChamberLayer(sfp,board,ch) >= 0 ) return true;
1290 else return false;
1291
1292}
1293
1294int MiniballSettings::GetIonChamberLayer( unsigned int adc, unsigned int ch ) {
1295
1298 return ic_layer[0][adc][ch];
1299
1300 else {
1301
1302 std::cerr << "Bad IonChamber event: adc = " << adc;
1303 std::cerr << ", channel = " << ch << std::endl;
1304 return 0;
1305
1306 }
1307
1308}
1309
1310int MiniballSettings::GetIonChamberLayer( unsigned int sfp, unsigned int board, unsigned int ch ) {
1311
1313 if( sfp < n_febex_sfp && board < n_febex_board && ch < n_febex_ch )
1314 return ic_layer[sfp][board][ch];
1315
1316 else {
1317
1318 std::cerr << "Bad IonChamber event: sfp = " << sfp;
1319 std::cerr << ", board = " << board;
1320 std::cerr << ", channel = " << ch << std::endl;
1321 return 0;
1322
1323 }
1324
1325}
1326
1327bool MiniballSettings::IsPulser( unsigned int sfp, unsigned int board, unsigned int ch ) {
1328
1330 if( GetPulser(sfp,board,ch) >= 0 ) return true;
1331 else return false;
1332
1333}
1334
1335int MiniballSettings::GetPulser( unsigned int sfp, unsigned int board, unsigned int ch ) {
1336
1338 if( sfp < n_febex_sfp && board < n_febex_board && ch < n_febex_ch )
1339 return pulser[sfp][board][ch];
1340
1341 else {
1342
1343 std::cerr << "Bad pulser event: sfp = " << sfp;
1344 std::cerr << ", board = " << board;
1345 std::cerr << ", channel = " << ch << std::endl;
1346 return 0;
1347
1348 }
1349
1350}
ClassImp(MiniballSettings) MiniballSettings
Definition Settings.cc:3
unsigned int n_pattern_unit
Number of pattern unit modules.
Definition Settings.hh:328
unsigned int dgf_mod_offset
module number offset for the DGFs
Definition Settings.hh:320
unsigned int n_caen_mod
Number of CAEN ADC modules.
Definition Settings.hh:322
unsigned int pulser_code
Info code when we have a pulser event in InfoData packets.
Definition Settings.hh:427
unsigned int ebis_sfp
Location of the EBIS signal in the FEBEX system (sfp)
Definition Settings.hh:428
unsigned int caen_mod_offset
module number offset for the CAEN ADCs
Definition Settings.hh:324
double mb_hit_window
Prompt time for correlated Miniball events in crystal, i.e. segmen-core events.
Definition Settings.hh:454
unsigned int n_madc_mod
Number of Mesytec ADC modules.
Definition Settings.hh:325
std::vector< std::vector< std::vector< int > > > cd_det
A channel map for the CD detectors (-1 if not a CD, 0 forward CD, 1 backward CD)
Definition Settings.hh:367
unsigned int ebis_dgf
Location of the EBIS signal in the DGF system (module)
Definition Settings.hh:429
unsigned int n_scaler_unit
Number of scaler unit modules.
Definition Settings.hh:330
bool IsCD(unsigned int adc, unsigned int ch)
Definition Settings.cc:1021
std::vector< unsigned int > bd_dgf
A list of DGF module numbers for each beam dump detector.
Definition Settings.hh:387
unsigned int laser_board
Location of the RILIS laser signal in the FEBEX system (board)
Definition Settings.hh:444
unsigned int block_size
not yet implemented, needs C++ style reading of data files
Definition Settings.hh:461
unsigned int ebis_ch
Location of the EBIS signal in the FEBEX system (channel)
Definition Settings.hh:431
unsigned int GetRILISChannel()
Definition Settings.hh:167
unsigned int adc_vme_first
Definition Settings.hh:335
unsigned int laser_sfp
Location of the RILIS laser signal in the FEBEX system (sfp)
Definition Settings.hh:443
unsigned int dgf_vme_last
Marabou IDs for DGFs.
Definition Settings.hh:334
std::vector< std::vector< std::vector< bool > > > mb_veto
A boolean to check if we need to veto any segments.
Definition Settings.hh:350
int GetIonChamberLayer(unsigned int adc, unsigned int ch)
Definition Settings.cc:1294
std::vector< unsigned int > pulser_sfp
A list of SFP numbers for each pulser.
Definition Settings.hh:414
std::vector< std::vector< unsigned int > > pad_ch
A list of channel numbers for each PAD detector.
Definition Settings.hh:376
void TestSettings()
Definition Settings.cc:20
unsigned int dgf_ts_mod_offset
module number offset for the timestamper DGFs
Definition Settings.hh:321
std::vector< std::vector< std::vector< std::vector< unsigned int > > > > cd_adc
A list of ADC module numbers for each CD detector, sector, side and strip.
Definition Settings.hh:365
unsigned int n_cd_nstrip
number of n-side strips
Definition Settings.hh:360
std::vector< unsigned int > ic_board
A list of board numbers for each IonChamber segment.
Definition Settings.hh:406
unsigned int tm_msb_code
Medium significant bits of the timestamp are here.
Definition Settings.hh:423
unsigned int n_cd_sector
number of sectors in the CD (or quadrants, it's 4)
Definition Settings.hh:357
unsigned int pattern_unit_offset
module number offset for the pattern units
Definition Settings.hh:329
std::vector< std::vector< std::vector< std::vector< unsigned int > > > > cd_ch
A list of channel numbers for each CD detector, sector, side and strip.
Definition Settings.hh:366
bool clipped_reject
reject events that are clipped by the ADC range
Definition Settings.hh:466
unsigned int ebis_code
Info code when we have an EBIS event in InfoData packets.
Definition Settings.hh:432
double ab_hit_window
Prompt time for correlated Miniball events in cluster, i.e. addback events.
Definition Settings.hh:455
int GetSpedeSegment(unsigned int sfp, unsigned int board, unsigned int ch)
Definition Settings.cc:1261
unsigned int pattern_vme_last
Marabou IDs for pattern unit modules.
Definition Settings.hh:337
unsigned int GetEBISChannel()
Definition Settings.hh:150
int GetMiniballSegment(unsigned int dgf, unsigned int ch)
Definition Settings.hh:216
int GetPadDetector(unsigned int adc, unsigned int ch)
Definition Settings.cc:1138
bool IsIonChamber(unsigned int adc, unsigned int ch)
Definition Settings.cc:1278
int GetPadSector(unsigned int adc, unsigned int ch)
Definition Settings.cc:1171
double dgf_ts_units
Definition Settings.hh:476
unsigned int n_cd_pstrip
number of p-side strips
Definition Settings.hh:359
bool IsPulser(unsigned int sfp, unsigned int board, unsigned int ch)
Definition Settings.cc:1327
void ReadSettings()
Definition Settings.cc:136
std::vector< unsigned int > ic_ch
A list of channel numbers for each IonChamber segment.
Definition Settings.hh:408
unsigned int n_madc_ch
Number of Mesytec ADC channels.
Definition Settings.hh:326
unsigned int laser_ch
Location of the RILIS laser signal in the FEBEX system (channel)
Definition Settings.hh:445
std::vector< std::vector< unsigned int > > pad_board
A list of board numbers for each PAD detector.
Definition Settings.hh:374
unsigned int GetT1Channel()
Definition Settings.hh:156
std::vector< std::vector< std::vector< int > > > pad_det
A channel map for the PAD detectors (-1 if not a PAD, 0 forward CD-PAD, 1 backward CD-PAD)
Definition Settings.hh:377
int GetMiniballCrystal(unsigned int dgf, unsigned int ch)
Definition Settings.hh:210
unsigned int GetSCChannel()
Definition Settings.hh:162
int GetMiniballID(unsigned int dgf, unsigned int ch, const std::vector< std::vector< std::vector< int > > > &vector)
Definition Settings.cc:985
ClassDef(MiniballSettings, 3) private unsigned int n_febex_sfp
Number of SFPs in acquisition.
Definition Settings.hh:305
std::vector< unsigned int > bd_ch
A list of channel numbers for each beam dump detector.
Definition Settings.hh:388
std::vector< std::vector< std::vector< unsigned int > > > mb_sfp
A list of SFP numbers for each MB cluster, crystal and segment.
Definition Settings.hh:346
unsigned int sync_msb_code
Sync pulse code from Exploder (msb)
Definition Settings.hh:421
unsigned int GetNumberOfDgfChannels()
Definition Settings.hh:43
std::vector< unsigned int > spede_ch
A list of channel numbers for each SPEDE segment.
Definition Settings.hh:398
int GetMiniballCluster(unsigned int dgf, unsigned int ch)
Definition Settings.hh:204
void SetFile(std::string filename)
Definition Settings.hh:28
unsigned int n_caen_ch
Number of CAENADC channels.
Definition Settings.hh:323
bool mbs_event_sort
Flag to define if we sort MBS data by readout event (true), or by global time (false)
Definition Settings.hh:451
unsigned int scaler_unit_offset
module number offset for the scaler units
Definition Settings.hh:331
std::vector< unsigned int > bd_board
A list of board numbers for each beam dump detector.
Definition Settings.hh:386
unsigned int n_mb_cluster
Miniball usuall has 8 triple cluster detectors.
Definition Settings.hh:341
int GetCDStrip(unsigned int adc, unsigned int ch)
Definition Settings.hh:257
unsigned int GetRILISBoard()
Definition Settings.hh:166
bool IsPad(unsigned int adc, unsigned int ch)
Definition Settings.cc:1097
unsigned int t1_sfp
Location of the T1 signal in the FEBEX system (sfp)
Definition Settings.hh:433
double cd_hit_window
Prompt time for correlated CD events.
Definition Settings.hh:456
std::vector< unsigned int > spede_board
A list of board numbers for each SPEDE segment.
Definition Settings.hh:396
int GetCDSector(unsigned int adc, unsigned int ch)
Definition Settings.hh:245
bool pileup_reject
reject events where the pileup flag is set by the MWD firmware
Definition Settings.hh:465
int GetCDDetector(unsigned int adc, unsigned int ch)
Definition Settings.hh:239
std::vector< unsigned int > spede_sfp
A list of SFP numbers for each SPEDE segment.
Definition Settings.hh:395
unsigned int n_spede_seg
Number of SPEDE segments, usually 24.
Definition Settings.hh:392
double caen_ts_units
Definition Settings.hh:477
unsigned int GetSCSfp()
Definition Settings.hh:159
std::vector< std::vector< std::vector< std::vector< unsigned int > > > > cd_board
A list of board numbers for each CD detector, sector, side and strip.
Definition Settings.hh:364
std::vector< std::vector< std::vector< int > > > pad_sector
Definition Settings.hh:378
std::vector< std::vector< std::vector< unsigned int > > > mb_dgf
A list of DGF module numbers for each MB cluster, crystal and segment.
Definition Settings.hh:348
unsigned int n_bd_det
Number of beam dump detectors.
Definition Settings.hh:382
bool flag_febex_only
when there is only FEBEX data in the file
Definition Settings.hh:462
unsigned int t1_dgf
Location of the T1 signal in the DGF system (module)
Definition Settings.hh:434
unsigned int scaler_vme_last
Marabou IDs for scaler modules.
Definition Settings.hh:336
std::vector< std::vector< std::vector< unsigned int > > > mb_board
A list of board numbers for each MB cluster, crystal and segment.
Definition Settings.hh:347
unsigned int n_dgf_ch
Number of DGF channels.
Definition Settings.hh:319
unsigned int t1_code
Info code when we have a T1 event in InfoData packets.
Definition Settings.hh:437
unsigned int GetT1Board()
Definition Settings.hh:154
std::vector< unsigned int > ic_adc
A list of ADC module numbers for each IonChamber segment.
Definition Settings.hh:407
unsigned int ebis_board
Location of the EBIS signal in the FEBEX system (board)
Definition Settings.hh:430
double pad_hit_window
Prompt time for correlated CD-Pad events.
Definition Settings.hh:457
std::vector< std::vector< std::vector< int > > > cd_strip
A channel map for the CD strips IDs (-1 if not a CD, strip ID otherwise)
Definition Settings.hh:370
unsigned int n_cd_side
number of sides, it's always 2, i.e. p-side and n-side
Definition Settings.hh:358
unsigned int laser_pattern
Location of the RILIS laser signal in the pattern unit (channel)
Definition Settings.hh:446
unsigned int GetNumberOfAdcModules()
Definition Settings.hh:61
bool IsMiniballSegmentVetoed(unsigned int clu, unsigned int cry, unsigned int seg)
Definition Settings.cc:968
std::vector< std::vector< std::vector< std::vector< unsigned int > > > > cd_sfp
A list of SFP numbers for each CD detector, sector, side and strip.
Definition Settings.hh:363
unsigned int GetEBISSfp()
Definition Settings.hh:147
std::vector< std::vector< std::vector< int > > > bd_det
A channel map for the beam dump detectors (-1 if not a beam dump, otherwise detector number)
Definition Settings.hh:389
std::vector< std::vector< std::vector< int > > > mb_cluster
A channel map for the Miniball cluster IDs (-1 if not Miniball)
Definition Settings.hh:351
unsigned int madc_mod_offset
module number offset for the MADCs
Definition Settings.hh:327
unsigned int n_dgf_ts_mod
Number of DGF timestamp modules (subset of n_dgf_mod)
Definition Settings.hh:318
std::vector< std::vector< std::vector< int > > > cd_sector
A channel map for the CD sectors (-1 if not a CD, 0-3 for quadrants)
Definition Settings.hh:368
std::vector< std::vector< std::vector< int > > > ic_layer
A channel map for the IonChamber segments (-1 if not a IonChamber, otherwise layer number,...
Definition Settings.hh:409
std::vector< std::vector< std::vector< unsigned int > > > mb_ch
A list of channel numbers for each MB cluster, crystal and segment.
Definition Settings.hh:349
unsigned int laser_code
Info code when we have a RILIS Laser ON coincidence with EBIS in InfoData packets.
Definition Settings.hh:447
unsigned int n_ic_layer
Number of IonChamber layers, usually 2, dE (gas) and E (Si)
Definition Settings.hh:402
unsigned int sc_sfp
Location of the SuperCycle signal in the FEBEX system (sfp)
Definition Settings.hh:438
bool IsSpede(unsigned int sfp, unsigned int board, unsigned int ch)
Definition Settings.cc:1253
std::vector< std::vector< std::vector< int > > > cd_side
A channel map for the CD sides (-1 if not a CD, 0 for p-side, 1 for n-side)
Definition Settings.hh:369
double ic_hit_window
Prompt time for correlated ionchamber events.
Definition Settings.hh:458
bool IsMiniball(unsigned int dgf, unsigned int ch)
Definition Settings.cc:928
std::vector< unsigned int > ic_sfp
A list of SFP numbers for each IonChamber segment.
Definition Settings.hh:405
bool IsBeamDump(unsigned int dgf, unsigned int ch)
Definition Settings.cc:1204
unsigned int n_mb_segment
Number of sgements in a crystal is 7, including core = 0.
Definition Settings.hh:343
int GetBeamDumpDetector(unsigned int dgf, unsigned int ch)
Definition Settings.cc:1220
int GetCDID(unsigned int adc, unsigned int ch, const std::vector< std::vector< std::vector< int > > > &vector)
Definition Settings.cc:1062
int GetCDSide(unsigned int adc, unsigned int ch)
Definition Settings.hh:251
std::vector< std::vector< std::vector< int > > > pulser
A channel map for the pulser inputs.
Definition Settings.hh:417
std::vector< std::vector< std::vector< int > > > mb_crystal
A channel map for the Miniball crystal IDs (-1 if not Miniball)
Definition Settings.hh:352
unsigned int sc_dgf
Location of the SuperCycle signal in the DGF system (module)
Definition Settings.hh:439
unsigned int GetMaximumNumberOfAdcChannels()
Definition Settings.hh:62
int GetPulser(unsigned int sfp, unsigned int board, unsigned int ch)
Definition Settings.cc:1335
unsigned int dgfscaler_vme_last
Marabou IDs for DGF scalers.
Definition Settings.hh:338
unsigned int n_febex_ch
Number of channels per board (16 for FEBEX4)
Definition Settings.hh:314
double event_window
Event builder time window in ns.
Definition Settings.hh:450
std::vector< std::vector< unsigned int > > pad_sfp
A list of SFP numbers for each PAD detector.
Definition Settings.hh:373
unsigned int pause_code
Info code when acquisition has paused due to a full buffer.
Definition Settings.hh:425
unsigned int GetSCBoard()
Definition Settings.hh:160
unsigned int t1_board
Location of the T1 signal in the FEBEX system (board)
Definition Settings.hh:435
std::vector< std::vector< unsigned int > > pad_adc
A list of ADC module numbers for each PAD detector.
Definition Settings.hh:375
unsigned int GetNumberOfDgfModules()
Definition Settings.hh:41
unsigned int pattern_vme_first
Definition Settings.hh:337
unsigned int sc_ch
Location of the SuperCycle signal in the FEBEX system (channel)
Definition Settings.hh:441
unsigned int scaler_vme_first
Definition Settings.hh:336
unsigned int adc_vme_last
Marabou IDs for ADCs.
Definition Settings.hh:335
unsigned int tm_hsb_code
Highest significant bits of the timestamp are here.
Definition Settings.hh:424
unsigned int n_dgf_mod
Number of DGF modules.
Definition Settings.hh:317
std::vector< std::vector< std::vector< int > > > mb_segment
A channel map for the Miniball segment IDs (-1 if not Miniball)
Definition Settings.hh:353
unsigned int dgfscaler_vme_first
Definition Settings.hh:338
unsigned int n_febex_board
Maximum number of boards per SFP.
Definition Settings.hh:313
unsigned int n_pulsers
Number of pulser inputs for synchronisation tests.
Definition Settings.hh:413
std::vector< unsigned int > pulser_board
A list of board numbers for each pulser.
Definition Settings.hh:415
unsigned int n_cd_det
Number of CD detectors (just 1 for Coulex)
Definition Settings.hh:356
unsigned int t1_ch
Location of the T1 signal in the FEBEX system (channel)
Definition Settings.hh:436
unsigned int GetT1Sfp()
Definition Settings.hh:153
unsigned int n_mb_crystal
Number of crystals in a triple cluster is 3.
Definition Settings.hh:342
unsigned int GetRILISSfp()
Definition Settings.hh:165
unsigned int dgf_vme_first
Definition Settings.hh:334
unsigned int sync_hsb_code
Sync pulse code from Exploder (hsb)
Definition Settings.hh:422
unsigned int GetEBISBoard()
Definition Settings.hh:148
std::vector< unsigned int > bd_sfp
A list of SFP numbers for each beam dump detector.
Definition Settings.hh:385
unsigned int sc_board
Location of the SuperCycle signal in the FEBEX system (board)
Definition Settings.hh:440
unsigned int sc_code
Info code when we have a SuperCycle event in InfoData packets.
Definition Settings.hh:442
unsigned int resume_code
Info code when acquisition has resumed after a pause.
Definition Settings.hh:426
std::vector< unsigned int > pulser_ch
A list of channel numbers for each pulser.
Definition Settings.hh:416
double madc_ts_units
Definition Settings.hh:478
std::vector< std::vector< std::vector< int > > > spede_seg
A channel map for the SPEDE segments (-1 if not a SPEDE, otherwise segment number)
Definition Settings.hh:399