TV1720RawData.cxx
Go to the documentation of this file.00001 #include "TV1720RawData.h"
00002
00003 #include <iomanip>
00004 #include <iostream>
00005
00006 void TV1720RawData::HandlZLECompressedData(){
00007
00008
00009
00010 uint32_t chMask = GetData32()[1] & 0xFF;
00011 uint32_t iPtr=4;
00012 for(int iCh=0; iCh<8; iCh++){
00013 if (chMask & (1<<iCh)){
00014 uint32_t chSize = GetData32()[iPtr];
00015 uint32_t iChPtr = 1;
00016 uint32_t iBin=0;
00017 iPtr++;
00018
00019 TV1720RawChannel channel(iCh, IsZLECompressed());
00020
00021 while(iChPtr<chSize){
00022 uint32_t goodData = ((GetData32()[iPtr]>>31) & 0x1);
00023 uint32_t nWords = (GetData32()[iPtr] & 0xFFFFF);
00024 if(goodData){
00025 std::vector<uint32_t> samples;
00026 for(uint32_t iWord=0; iWord<nWords; iWord++){
00027 iPtr++;
00028 iChPtr++;
00029 samples.push_back((GetData32()[iPtr]&0xFFF));
00030 samples.push_back(((GetData32()[iPtr]>>16)&0xFFF));
00031 }
00032 channel.AddZlePulse(TV1720RawZlePulse(iBin, samples));
00033 }
00034
00035 iBin += (nWords*2);
00036 iChPtr++;
00037 iPtr++;
00038
00039 }
00040
00041 fMeasurements.push_back(channel);
00042 }
00043 }
00044
00045 }
00046
00047 void TV1720RawData::HandlUncompressedData(){
00048
00049
00050 uint32_t iPtr=4;
00051 uint32_t chMask = GetData32()[1] & 0xFF;
00052
00053 int nActiveChannels=0;
00054 for(int iCh=0; iCh<8; iCh++){
00055 if(chMask & (1<<iCh))
00056 nActiveChannels++;
00057 }
00058
00059
00060
00061 int N32samples = (GetEventSize() - 4)/ nActiveChannels;
00062
00063
00064 for(int iCh=0; iCh<8; iCh++){
00065
00066 if(!(chMask & (1<<iCh))){
00067
00068 TV1720RawChannel channel(iCh, IsZLECompressed());
00069 fMeasurements.push_back(channel);
00070 continue;
00071 }
00072
00073 TV1720RawChannel channel(iCh, IsZLECompressed());
00074
00075 for(int j = 0; j < N32samples; j++){
00076 uint32_t samp1 = (GetData32()[iPtr]&0xFFF);
00077 uint32_t samp2 = ((GetData32()[iPtr]>>16)&0xFFF);
00078
00079 channel.AddADCSample(samp1);
00080 channel.AddADCSample(samp2);
00081 iPtr++;
00082 }
00083
00084 fMeasurements.push_back(channel);
00085
00086 }
00087 }
00088
00089
00090 TV1720RawData::TV1720RawData(int bklen, int bktype, const char* name, void *pdata):
00091 TGenericData(bklen, bktype, name, pdata)
00092 {
00093
00094 fGlobalHeader0 = GetData32()[0];
00095 fGlobalHeader1 = GetData32()[1];
00096 fGlobalHeader2 = GetData32()[2];
00097 fGlobalHeader3 = GetData32()[3];
00098
00099
00100
00101 if(IsZLECompressed()){
00102 HandlZLECompressedData();
00103 }else{
00104 HandlUncompressedData();
00105 }
00106
00107 }
00108
00109 void TV1720RawData::Print(){
00110
00111 std::cout << "V1720 decoder for bank " << GetName().c_str() << std::endl;
00112 std::cout << "Bank size: " << GetEventSize() << std::endl;
00113
00114 if( IsZLECompressed())
00115 std::cout << "Data is ZLE compressed." << std::endl;
00116 else
00117 std::cout << "Data is not ZLE compressed." << std::endl;
00118
00119 std::cout << "Channel Mask : " << GetChannelMask() << std::endl;
00120
00121 std::cout << "Event counter : " << GetEventCounter() << std::endl;
00122 std::cout << "Trigger tag: " << GetTriggerTag() << std::endl;
00123
00124
00125 std::cout << "Number of channels with data: " << GetNChannels() << std::endl;
00126 for(int i = 0 ; i < GetNChannels(); i++){
00127
00128 TV1720RawChannel channelData = GetChannelData(i);
00129
00130 std::cout << "Channel: " << channelData.GetChannelNumber() << std::endl;
00131
00132 if(IsZLECompressed()){
00133 std::cout << "Number of ZLE pulses: " << channelData.GetNZlePulses() << std::endl;
00134 for(int j = 0; j < channelData.GetNZlePulses(); j++){
00135 std::cout << "Pulse: " << j << std::endl;
00136 TV1720RawZlePulse pulse = channelData.GetZlePulse(j);
00137 std::cout << "first sample bin: " << pulse.GetFirstBin() << std::endl;
00138 std::cout << "Samples ("<< pulse.GetNSamples()<< " total): " <<std::endl;
00139 for(int k = 0; k < pulse.GetNSamples(); k++){
00140 std::cout << pulse.GetSample(k) << ", ";
00141 if(k%12 == 11) std::cout << std::endl;
00142 }
00143 std::cout << std::endl;
00144
00145 }
00146 }
00147
00148 }
00149
00150 }