ROOTANA
TV1720RawData.cxx
Go to the documentation of this file.
1 #include "TV1720RawData.h"
2 
3 #include <iomanip>
4 #include <iostream>
5 
7 
8  // >>> Loop over ZLE data and fill up
9 
10  uint32_t chMask = GetData32()[1] & 0xFF;
11  uint32_t iPtr=4;
12  for(int iCh=0; iCh<8; iCh++){
13  if (chMask & (1<<iCh)){
14  uint32_t chSize = GetData32()[iPtr];
15  uint32_t iChPtr = 1;// The chSize space is included in chSize
16  uint32_t iBin=0;
17  iPtr++;
18 
19  TV1720RawChannel channel(iCh, IsZLECompressed());
20 
21  while(iChPtr<chSize){
22  uint32_t goodData = ((GetData32()[iPtr]>>31) & 0x1);
23  uint32_t nWords = (GetData32()[iPtr] & 0xFFFFF);
24  if(goodData){
25  std::vector<uint32_t> samples;
26  for(uint32_t iWord=0; iWord<nWords; iWord++){
27  iPtr++;
28  iChPtr++;
29  samples.push_back((GetData32()[iPtr]&0xFFF));
30  samples.push_back(((GetData32()[iPtr]>>16)&0xFFF));
31  }
32  channel.AddZlePulse(TV1720RawZlePulse(iBin, samples));
33  }
34 
35  iBin += (nWords*2);
36  iChPtr++;
37  iPtr++;
38 
39  }
40 
41  fMeasurements.push_back(channel);
42  }
43  }
44 
45 }
46 
48 
49  // Skip the header.
50  uint32_t iPtr=4;
51  uint32_t chMask = GetData32()[1] & 0xFF;
52 
53  int nActiveChannels=0;
54  for(int iCh=0; iCh<8; iCh++){
55  if(chMask & (1<<iCh))
56  nActiveChannels++;
57  }
58  // Assume that we have readout the same number of samples for each channel.
59  // The number of 32 bit double-samples per channel is then
60  // N32samples = (bank size - 4)/ nActiveChannels
61  int N32samples = (GetEventSize() - 4)/ nActiveChannels;
62 
63  // Loop over channels
64  for(int iCh=0; iCh<8; iCh++){
65 
66  if(!(chMask & (1<<iCh))){
67  // Add empty channel data objects, to keep vector simple.
68  TV1720RawChannel channel(iCh, IsZLECompressed());
69  fMeasurements.push_back(channel);
70  continue;
71  }
72 
73  TV1720RawChannel channel(iCh, IsZLECompressed());
74 
75  for(int j = 0; j < N32samples; j++){
76  uint32_t samp1 = (GetData32()[iPtr]&0xFFF);
77  uint32_t samp2 = ((GetData32()[iPtr]>>16)&0xFFF);
78 
79  channel.AddADCSample(samp1);
80  channel.AddADCSample(samp2);
81  iPtr++;
82  }
83 
84  fMeasurements.push_back(channel);
85 
86  }
87 }
88 
89 
90 TV1720RawData::TV1720RawData(int bklen, int bktype, const char* name, void *pdata):
91  TGenericData(bklen, bktype, name, pdata)
92 {
93 
98 
99 
100 
101  if(IsZLECompressed()){
103  }else{
105  }
106 
107 }
108 
110 
111  std::cout << "V1720 decoder for bank " << GetName().c_str() << std::endl;
112  std::cout << "Bank size: " << GetEventSize() << std::endl;
113 
114  if( IsZLECompressed())
115  std::cout << "Data is ZLE compressed." << std::endl;
116  else
117  std::cout << "Data is not ZLE compressed." << std::endl;
118 
119  std::cout << "Channel Mask : " << GetChannelMask() << std::endl;
120 
121  std::cout << "Event counter : " << GetEventCounter() << std::endl;
122  std::cout << "Trigger tag: " << GetTriggerTag() << std::endl;
123 
124 
125  std::cout << "Number of channels with data: " << GetNChannels() << std::endl;
126  for(int i = 0 ; i < GetNChannels(); i++){
127 
128  TV1720RawChannel channelData = GetChannelData(i);
129 
130  std::cout << "Channel: " << channelData.GetChannelNumber() << std::endl;
131 
132  if(IsZLECompressed()){
133  std::cout << "Number of ZLE pulses: " << channelData.GetNZlePulses() << std::endl;
134  for(int j = 0; j < channelData.GetNZlePulses(); j++){
135  std::cout << "Pulse: " << j << std::endl;
136  TV1720RawZlePulse pulse = channelData.GetZlePulse(j);
137  std::cout << "first sample bin: " << pulse.GetFirstBin() << std::endl;
138  std::cout << "Samples ("<< pulse.GetNSamples()<< " total): " <<std::endl;
139  for(int k = 0; k < pulse.GetNSamples(); k++){
140  std::cout << pulse.GetSample(k) << ", ";
141  if(k%12 == 11) std::cout << std::endl;
142  }
143  std::cout << std::endl;
144 
145  }
146  }
147 
148  }
149 
150 }
const uint32_t * GetData32() const
std::string GetName() const
int GetNZlePulses() const
Get the number of ZLE pulses (for compressed data)
Definition: TV1720RawData.h:83
void AddADCSample(uint32_t sample)
TV1720RawZlePulse GetZlePulse(int i) const
Get the ZLE pulse (for compressed data.
Definition: TV1720RawData.h:87
int GetChannelNumber() const
Definition: TV1720RawData.h:64
void AddZlePulse(TV1720RawZlePulse pulse)
void Print()
Print the bank contents in a structured way.
void HandlUncompressedData()
Helper method to handle uncompressed data.
uint32_t GetEventSize() const
Get the number of 32-bit words in bank.
void HandlZLECompressedData()
Helper method to handle ZLE compressed data.
uint32_t fGlobalHeader3
std::vector< TV1720RawChannel > fMeasurements
Vector of V1720 measurements.
TV1720RawChannel GetChannelData(int i)
Get Channel Data.
TV1720RawData(int bklen, int bktype, const char *name, void *pdata)
Constructor.
int GetNChannels() const
Get Number of channels in this bank.
uint32_t fGlobalHeader2
uint32_t fGlobalHeader0
The overall global headers.
uint32_t GetChannelMask() const
uint32_t GetEventCounter() const
Get event counter.
uint32_t GetTriggerTag() const
Get trigger tag.
bool IsZLECompressed() const
Is the V1720 data ZLE compressed?
uint32_t fGlobalHeader1
Class to store information from a single V1720 ZLE pulse.
Definition: TV1720RawData.h:10
int GetSample(int i) const
Get the first bin for this pulse.
Definition: TV1720RawData.h:32
int GetNSamples() const
Get the number of samples.
Definition: TV1720RawData.h:27
int GetFirstBin() const
Get the first bin for this pulse.
Definition: TV1720RawData.h:22