Public Member Functions | Public Attributes | Private Attributes | List of all members
TestDigit Class Reference

#include <TestDigit.h>

Public Member Functions

 TestDigit (int i=0)
 

Public Attributes

std::string line = "-----------------------------"
 
AdcCount lowbits = 63
 
AdcCount highbits = 4095 - 63
 
AdcIndex channel = -1
 
AdcSignal pedestal = 0.0
 
const raw::RawDigitpdig = nullptr
 
AdcIndex nsig = 0
 
AdcSignalVector sigsin
 
AdcFlagVector expflags
 

Private Attributes

std::unique_ptr< raw::RawDigitdigitPtr
 

Detailed Description

Definition at line 11 of file TestDigit.h.

Constructor & Destructor Documentation

TestDigit::TestDigit ( int  i = 0)

Definition at line 36 of file TestDigit.h.

36  {
37  const string myname = "TestDigit::ctor: ";
38  cout << myname << line << endl;
39  cout << myname << "Creating raw digit " << idig << endl;
40  float fac = 250.0;
41  pedestal = 2000.2;
42  for ( int i=0; i<10; ++i ) sigsin.push_back(fac*i);
43  for ( int i=10; i>=0; --i ) sigsin.push_back(fac*i);
44  for ( int i=19; i>=0; --i ) sigsin.push_back(-sigsin[i]);
45  if ( idig == 2 ) { // Add a gap and then repeat the waveform.
46  for ( unsigned int ksig = 0; ksig<30; ++ksig ) {
47  sigsin.push_back(pedestal);
48  }
49  for ( unsigned int isig=0; isig<nsig; ++isig) {
50  sigsin.push_back(sigsin[isig]);
51  }
52  }
53  nsig = sigsin.size();
54  assert(sigsin.size() == nsig);
55  AdcCountVector adcsin;
56  unsigned int isig_stucklo = 5;
57  unsigned int isig_stuckhi = 15;
58  for ( unsigned int isig=0; isig<nsig; ++isig) {
59  AdcSignal sig = sigsin[isig] + pedestal;
60  AdcCount adc = 0.0;
61  if ( sig > 0.0 ) adc = int(sig+0.5);
62  if ( adc > 4095 ) adc = 4095;
63  AdcCount adchigh = adc & highbits;
64  if ( isig == isig_stucklo ) adc = adchigh; // Stuck low bits to zero.
65  if ( isig == isig_stuckhi ) adc = adchigh + lowbits; // Stuck low bits to one.
66  adcsin.push_back(adc);
67  }
68  assert(adcsin.size() == nsig);
69  channel = 123;
70  digitPtr.reset(new raw::RawDigit(channel, nsig, adcsin, raw::kNone));
71  raw::RawDigit& dig = *digitPtr;
72  dig.SetPedestal(pedestal);
73  cout << myname << " Compressed size: " << dig.NADC() << endl;
74  cout << myname << " Uncompressed size: " << dig.Samples() << endl;
75  cout << myname << " Pedestal: " << dig.GetPedestal() << endl;
76  cout << myname << " Channel: " << dig.Channel() << endl;
77  assert(dig.Samples() == nsig);
78  assert(dig.Channel() == channel);
79  assert(dig.GetPedestal() == pedestal);
80 
81  cout << myname << line << endl;
82  cout << myname << "Create the expected flag vector." << endl;
83  expflags.resize(nsig, AdcGood);
84  for ( unsigned int isig=0; isig<nsig; ++isig) {
85  AdcCount adc = adcsin[isig];
86  AdcCount adclow = adc & lowbits;
87  if ( adc <= 0 ) expflags[isig] = AdcUnderflow;
88  else if ( adc >= 4095 ) expflags[isig] = AdcOverflow;
89  else if ( adclow == 0 ) expflags[isig] = AdcStuckOff;
90  else if ( adclow == lowbits ) expflags[isig] = AdcStuckOn;
91  }
92  pdig = digitPtr.get();
93 }
float GetPedestal() const
Definition: RawDigit.h:214
std::vector< AdcCount > AdcCountVector
Definition: AdcTypes.h:19
AdcSignalVector sigsin
Definition: TestDigit.h:25
AdcCount highbits
Definition: TestDigit.h:20
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
Definition: RawDigit.h:213
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
float AdcSignal
Definition: AdcTypes.h:21
ChannelID_t Channel() const
DAQ channel this raw data was read from.
Definition: RawDigit.h:212
int16_t adc
Definition: CRTFragment.hh:202
const AdcFlag AdcUnderflow
Definition: AdcTypes.h:33
AdcFlagVector expflags
Definition: TestDigit.h:26
AdcIndex channel
Definition: TestDigit.h:21
const raw::RawDigit * pdig
Definition: TestDigit.h:23
no compression
Definition: RawTypes.h:9
std::unique_ptr< raw::RawDigit > digitPtr
Definition: TestDigit.h:30
const AdcFlag AdcGood
Definition: AdcTypes.h:32
AdcIndex nsig
Definition: TestDigit.h:24
const AdcFlag AdcOverflow
Definition: AdcTypes.h:34
size_t NADC() const
Number of elements in the compressed ADC sample vector.
Definition: RawDigit.h:207
const AdcFlag AdcStuckOn
Definition: AdcTypes.h:37
AdcSignal pedestal
Definition: TestDigit.h:22
std::string line
Definition: TestDigit.h:18
const AdcFlag AdcStuckOff
Definition: AdcTypes.h:36
void SetPedestal(float ped, float sigma=1.)
Set pedestal and its RMS (the latter is 0 by default)
Definition: RawDigit.cxx:68
AdcCount lowbits
Definition: TestDigit.h:19
short AdcCount
Definition: AdcTypes.h:18
QTextStream & endl(QTextStream &s)

Member Data Documentation

AdcIndex TestDigit::channel = -1

Definition at line 21 of file TestDigit.h.

std::unique_ptr<raw::RawDigit> TestDigit::digitPtr
private

Definition at line 30 of file TestDigit.h.

AdcFlagVector TestDigit::expflags

Definition at line 26 of file TestDigit.h.

AdcCount TestDigit::highbits = 4095 - 63

Definition at line 20 of file TestDigit.h.

std::string TestDigit::line = "-----------------------------"

Definition at line 18 of file TestDigit.h.

AdcCount TestDigit::lowbits = 63

Definition at line 19 of file TestDigit.h.

AdcIndex TestDigit::nsig = 0

Definition at line 24 of file TestDigit.h.

const raw::RawDigit* TestDigit::pdig = nullptr

Definition at line 23 of file TestDigit.h.

AdcSignal TestDigit::pedestal = 0.0

Definition at line 22 of file TestDigit.h.

AdcSignalVector TestDigit::sigsin

Definition at line 25 of file TestDigit.h.


The documentation for this class was generated from the following file: