00001 #include "TMesytecData.hxx" 00002 00003 // Must be either 11, 12 or 13 bit; default is 11 bit 00004 int gBitResolution = 0x7ff; 00005 00006 00007 uint32_t ADCMeasMesy::GetMeasurement() const {return (adc_measurement_word & gBitResolution);} 00008 00009 00010 00011 TMesytecData::TMesytecData(int bklen, int bktype, const char* name, void *pdata): 00012 TGenericData(bklen, bktype, name, pdata) 00013 { 00014 00015 /// Save the current header. 00016 fGlobalHeader =0; 00017 00018 for(int i = 0; i < GetSize(); i++){ 00019 uint32_t word = GetData32()[i]; 00020 00021 if( (word & 0xc0000000) == 0x40000000){ // header word 00022 fGlobalHeader = word; 00023 // Figure out which bit resolution we are using 00024 int bitresolution = ((fGlobalHeader & 0x7000) >> 12); 00025 if(bitresolution == 1) 00026 gBitResolution = 0x7ff; 00027 else if(bitresolution == 2) 00028 gBitResolution = 0xfff; 00029 else if(bitresolution == 4) 00030 gBitResolution = 0x1fff; 00031 00032 } 00033 00034 if( (word & 0xc0000000) == 0x00000000 && 00035 (word & 0x3fe00000) == 0x04000000 ){ // Data word 00036 fMeasurements.push_back(ADCMeasMesy(fGlobalHeader,word)); 00037 } 00038 00039 if( (word & 0xc0000000) == 0x00000000 && 00040 (word & 0x3fe00000) == 0x04000000 ){ // Data extended timestamp 00041 // Not currently supported!!! 00042 } 00043 00044 if((word & 0xc0000000) == 0xc0000000){ // trailer word 00045 fGlobalTrailer = word; 00046 } 00047 00048 } 00049 00050 } 00051 00052 00053 void TMesytecData::Print(){ 00054 00055 std::cout << "Data for Mesytec module in bank " << GetName() << std::endl; 00056 std::cout << "Module ID = " << GetModuleID() << std::endl; 00057 std::cout << "Bit resolution : 0x" << std::hex 00058 << gBitResolution << std::dec << std::endl; 00059 00060 std::cout << "Timestamp = " << GetTimeStamp() << std::endl; 00061 00062 std::vector<ADCMeasMesy> measurements = GetMeasurements(); 00063 std::cout << "Number of measurements: " << measurements.size() << std::endl; 00064 00065 for(unsigned int i = 0; i < measurements.size(); i++){ 00066 ADCMeasMesy adcmeas = measurements[i]; 00067 std::cout << "meas: " << adcmeas.GetMeasurement() 00068 << " [chan="<< adcmeas.GetChannel() 00069 <<",OOR=" << adcmeas.IsOutOfRange() << "] "; 00070 if(i%2==1) std::cout << std::endl; 00071 } 00072 std::cout << std::endl; 00073 00074 00075 }