Typedefs | Functions
test_ProtoduneChannelHelper.cxx File Reference
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include "duneprototypes/Protodune/singlephase/Utility/ProtoduneChannelHelper.h"
#include "TH1F.h"
#include <cassert>

Go to the source code of this file.

Typedefs

using Index = ProtoduneChannelHelper::Index
 
using IndexVector = std::vector< Index >
 

Functions

int test_ProtoduneChannelHelper (Index nshow=64)
 
int main (int argc, char *argv[])
 

Typedef Documentation

Definition at line 25 of file test_ProtoduneChannelHelper.cxx.

Definition at line 26 of file test_ProtoduneChannelHelper.cxx.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 105 of file test_ProtoduneChannelHelper.cxx.

105  {
106  Index nshow = 64;
107  if ( argc > 1 ) {
108  string sarg(argv[1]);
109  if ( sarg == "-h" ) {
110  cout << "Usage: " << argv[0] << "[NSHOW]" << endl;
111  cout << " NSHOW [64]: Every nshow'th channels will be displayed in log." << endl;
112  return 0;
113  }
114  nshow = std::stoi(sarg);
115  }
116  return test_ProtoduneChannelHelper(nshow);
117 }
int test_ProtoduneChannelHelper(Index nshow=64)
unsigned int Index
QTextStream & endl(QTextStream &s)
int test_ProtoduneChannelHelper ( Index  nshow = 64)

Definition at line 30 of file test_ProtoduneChannelHelper.cxx.

30  {
31  const string myname = "test_ProtoduneChannelHelper: ";
32 #ifdef NDEBUG
33  cout << myname << "NDEBUG must be off." << endl;
34  abort();
35 #endif
36  string line = "-----------------------------";
37 
38  cout << myname << line << endl;
39 
40  ProtoduneChannelHelper chh(false);
41  Index badIndex = chh.badIndex();
42 
43  cout << myname << "Check some good values." << endl;
44  for ( Index ichaOff : { 0, 102, 1234, 1407, 3967, 15359 } ) {
45  Index ichaOn = chh.onlineChannel(ichaOff);
46  cout << myname << ichaOff << " --> " << ichaOn << endl;
47  assert( ichaOff != badIndex );
48  }
49 
50  cout << myname << line << endl;
51  cout << myname << "Check some bad values." << endl;
52  for ( Index ichaOff : { -1, 15360, 20000 } ) {
53  Index ichaOn = chh.onlineChannel(ichaOff);
54  cout << myname << ichaOff << " --> " << ichaOn << endl;
55  assert( ichaOn == badIndex );
56  }
57 
58  cout << myname << line << endl;
59  cout << myname << "Check each online index appears exactly once." << endl;
60  const Index ncha = 15360;
61  IndexVector onlineCounts(ncha);
62  IndexVector offlineChannel(ncha, badIndex);
63  for ( Index ichaOff=0; ichaOff<ncha; ++ichaOff ) {
64  Index ichaOn = chh.onlineChannel(ichaOff);
65  Index irem = ichaOn;
66  Index itps = irem/2560;
67  irem = irem%2560;
68  Index ifmb = irem/128 + 1;
69  irem = irem%128;
70  Index iasc = irem/16 + 1;
71  Index iach = irem%16;
72  if ( nshow*(ichaOff/nshow) == ichaOff || ichaOn >= ncha ) {
73  cout << myname << " " << setw(4) << ichaOff << " --> " << setw(4) << ichaOn
74  << " (" << itps << ", " << setw(2) << ifmb << ", "
75  << iasc << ", " << setw(2) << iach << ")" << endl;
76  }
77  assert( itps == chh.tpcSet(ichaOn) );
78  assert( ifmb == chh.femb(ichaOn) );
79  assert( iasc == chh.asic(ichaOn) );
80  assert( iach == chh.asicChannel(ichaOn) );
81  assert( ichaOn < ncha );
82  if ( offlineChannel[ichaOn] != badIndex ) {
83  cout << myname << "ERROR: Online channel " << ichaOn
84  << " is mapped to two offline channels:" << endl;
85  cout << " " << offlineChannel[ichaOn] << endl;
86  cout << " " << ichaOff << endl;
87  assert( false );
88  }
89  assert( onlineCounts[ichaOn] == 0 );
90  onlineCounts[ichaOn] += 1;
91  offlineChannel[ichaOn] = ichaOff;
92  }
93  for ( Index ichaOn=0; ichaOn<ncha; ++ichaOn ) {
94  assert( onlineCounts[ichaOn] == 1 );
95  assert( offlineChannel[ichaOn] != badIndex );
96  }
97 
98  cout << myname << line << endl;
99  cout << myname << "Done." << endl;
100  return 0;
101 }
std::vector< Index > IndexVector
Index badIndex
unsigned int Index
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)