ROOTANA
TCamacADCData.cxx
Go to the documentation of this file.
1 #include "TCamacADCData.hxx"
2 
3 #include <iostream>
4 
5 
6 // Set the ADC value for this channel.
7 void CamacADCEvent::SetADC(int ch, int adc){
8  if(ch >= 0 && ch < NADC)
9  ADCValues[ch] = adc;
10 }
11 
12 
13 TCamacData::TCamacData(int bklen, int bktype, const char* name, void *pdata):
14  TGenericData(bklen, bktype, name, pdata)
15 {
16 
17  int ntriggers = GetData16()[0] & 0xfff;
18 
19  int pointer = 1;
20 
21  static int checkword = 0xfeed;
22 
23 
24  bool fail = false;
25  while(GetData16()[pointer] != 0xffff){
26 
27  CamacADCEvent event;
28 
29  // Find the next checkword. Should be 14 words along.
30  if(GetData16()[pointer+13] != checkword){
31  // check if the checkword is one word back.
32  if(GetData16()[pointer+12] == checkword){
33  std::cout << "This event had only 11 samples; not 12. Setting all values to -1." << std::endl;
34  fMeasurements.push_back(event);
35  pointer += 13;
36  continue;
37  }else{
38  std::cout << "This event seems mangled; whole set of events probably mangled." << std::endl;
39  }
40  }
41 
42 
43  pointer++; // not sure what this word is... possibly the number of subsequent words in event.
44 
45  // fill ADC values;
46  for(int i = 0; i < NADC; i++){
47  event.SetADC(i,GetData16()[pointer++]);
48  }
49  if(GetData16()[pointer++] != checkword){
50  std::cout << "Data (@" << pointer << ") " << GetData16()[pointer] << " doesn't match checkword "
51  << checkword << std::endl;
52  fail = true;
53  }
54 
55  fMeasurements.push_back(event);
56 
57  }
58 
59  if((int)fMeasurements.size() != ntriggers){
60  std::cout << "TCamacData::CamacData: Triggers don't match!! " << ntriggers << " " << fMeasurements.size() << std::endl;
61  }
62 
63  if(fail){
64  std::cout << "bklen: " << bklen << std::endl;
65  for(int i = 0; i < bklen; i++){
66  if(i%16 == 0){ std::cout << i << std::endl;}
67  std::cout << std::hex << GetData16()[i] << " " << std::dec;
68  if(i%16 == 15) std::cout << std::endl;
69 
70  }
71  std::cout << std::endl;
72  }
73 
74 
75 }
#define NADC
This class is meant to store a single trigger (LAM) of CAMAC ADC data.
void SetADC(int ch, int adc)
int ADCValues[NADC]
std::vector< CamacADCEvent > fMeasurements
Vector of CAMAC ADC measurements.
TCamacData(int bklen, int bktype, const char *name, void *pdata)
Constructor.
const uint16_t * GetData16() const