Chnage enum DPPType -> DPPTypeCode; reduce the fsu.ts size; remove Hit::bd

This commit is contained in:
Ryan Tang 2024-03-02 00:33:08 -05:00
parent b3ab5da207
commit cc79c7ea3c
17 changed files with 185 additions and 123 deletions

View File

@ -16,7 +16,6 @@
#define NumCoupledChannel 8 // the max numnber of Coupled/RegChannel is 8 for PHA, PSD, QDC
std::vector<std::string> AggSeperator(std::string inFileName, std::string saveFolder = "./", short verbose = false){
printf("================ AggSeperator \n");
@ -53,7 +52,7 @@ std::vector<std::string> AggSeperator(std::string inFileName, std::string saveFo
for( int i = 0; i < NumCoupledChannel; i++){
newFileFlag[i] = true;
outputFileList.push_back( saveFolder + fileName + "." + std::to_string(i));
outputFileList.push_back( saveFolder + fileName + "." + std::to_string(i) + ".agg");
}
do{

View File

@ -93,9 +93,9 @@ int main(int argc, char **argv){
if (argc <= 1) {
printf("Incorrect number of arguments:\n");
printf("%s [inFile] [DPPType] \n", argv[0]);
printf(" +-- PHA = %d\n", DPPType::DPP_PHA_CODE);
printf(" +-- PSD = %d\n", DPPType::DPP_PSD_CODE);
printf(" +-- QDC = %d\n", DPPType::DPP_QDC_CODE);
printf(" +-- PHA = %d\n", DPPTypeCode::DPP_PHA_CODE);
printf(" +-- PSD = %d\n", DPPTypeCode::DPP_PSD_CODE);
printf(" +-- QDC = %d\n", DPPTypeCode::DPP_QDC_CODE);
return 1;
}

View File

@ -57,9 +57,9 @@ int main(int argc, char **argv){
TString typeStr = &inFileName[i][snPos+9];
typeStr.Resize(3);
if( typeStr == "PHA" ) type[i] = DPPType::DPP_PHA_CODE;
if( typeStr == "PSD" ) type[i] = DPPType::DPP_PSD_CODE;
if( typeStr == "QDC" ) type[i] = DPPType::DPP_QDC_CODE;
if( typeStr == "PHA" ) type[i] = DPPTypeCode::DPP_PHA_CODE;
if( typeStr == "PSD" ) type[i] = DPPTypeCode::DPP_PSD_CODE;
if( typeStr == "QDC" ) type[i] = DPPTypeCode::DPP_QDC_CODE;
int order = atoi(&inFileName[i][snPos+13]);
ID[i] = sn[i] + order * 1000;
@ -84,8 +84,8 @@ int main(int argc, char **argv){
for( int i = 0; i < nFile; i++){
inFile[i] = fopen(inFileName[i].Data(), "r");
if( inFile[i] ){
if( type[i] == DPPType::DPP_PHA_CODE || type[i] == DPPType::DPP_PSD_CODE ) data[i] = new Data(16);
if( type[i] == DPPType::DPP_QDC_CODE ) data[i] = new Data(64);
if( type[i] == DPPTypeCode::DPP_PHA_CODE || type[i] == DPPTypeCode::DPP_PSD_CODE ) data[i] = new Data(16);
if( type[i] == DPPTypeCode::DPP_QDC_CODE ) data[i] = new Data(64);
data[i]->DPPType = type[i];
data[i]->boardSN = ID[i]%1000;
}else{

View File

@ -149,8 +149,8 @@ int main(int argc, char **argv) {
inFile[i] = fopen(fileList[i][0], "r");
if( inFile[i] ){
inFileIndex[i] = 0;
if( typeList[i] == DPPType::DPP_PHA_CODE || typeList[i] == DPPType::DPP_PSD_CODE ) data[i] = new Data(16);
if( typeList[i] == DPPType::DPP_QDC_CODE ) data[i] = new Data(64);
if( typeList[i] == DPPTypeCode::DPP_PHA_CODE || typeList[i] == DPPTypeCode::DPP_PSD_CODE ) data[i] = new Data(16);
if( typeList[i] == DPPTypeCode::DPP_QDC_CODE ) data[i] = new Data(64);
data[i]->DPPType = typeList[i];
data[i]->boardSN = snList[i];
data[i]->tick2ns = t2nsList[i];

View File

@ -52,9 +52,9 @@ void keyPressCommand(){
}
if (c == 'b') { //==========
if( digi->GetDPPType() == DPPType::DPP_PHA_CODE || digi->GetDPPType() == DPPType::DPP_PSD_CODE ){
if( digi->GetDPPType() == DPPTypeCode::DPP_PHA_CODE || digi->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ){
RegList = RegisterBoardList_PHAPSD;
}else if(digi->GetDPPType() == DPPType::DPP_QDC_CODE) {
}else if(digi->GetDPPType() == DPPTypeCode::DPP_QDC_CODE) {
RegList = RegisterBoardList_QDC;
}
@ -131,9 +131,9 @@ void keyPressCommand(){
return;
}
if( digi->GetDPPType() == DPPType::DPP_PHA_CODE ) RegList = RegisterChannelList_PHA;
if( digi->GetDPPType() == DPPType::DPP_PSD_CODE ) RegList = RegisterChannelList_PSD;
if( digi->GetDPPType() == DPPType::DPP_QDC_CODE ) RegList = RegisterChannelList_QDC;
if( digi->GetDPPType() == DPPTypeCode::DPP_PHA_CODE ) RegList = RegisterChannelList_PHA;
if( digi->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ) RegList = RegisterChannelList_PSD;
if( digi->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) RegList = RegisterChannelList_QDC;
for( int i = 0; i < (int) RegList.size(); i++){
std::string typeStr ;
@ -245,9 +245,9 @@ int main(int argc, char **argv) {
digi = new Digitizer();
digi->LoadSettingBinaryToMemory(argv[1]);
if( !(digi->GetDPPType() == DPPType::DPP_PHA_CODE ||
digi->GetDPPType() == DPPType::DPP_PSD_CODE ||
digi->GetDPPType() == DPPType::DPP_QDC_CODE )){
if( !(digi->GetDPPType() == DPPTypeCode::DPP_PHA_CODE ||
digi->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ||
digi->GetDPPType() == DPPTypeCode::DPP_QDC_CODE )){
printf("DPP-type not supported. Or Binary file is not supported.\n");
delete digi;
return -1;

View File

@ -3,6 +3,8 @@
#include <algorithm>
#include <filesystem>
#include "AggSeparator.h"
class FSUReader{
public:
@ -173,11 +175,11 @@ inline void FSUReader::OpenFile(std::string fileName, uInt dataSize, int verbose
order = atoi(tokens[5].c_str());
DPPType = -1;
if( fileName.find("PHA") != std::string::npos ) DPPType = DPPType::DPP_PHA_CODE;
if( fileName.find("PSD") != std::string::npos ) DPPType = DPPType::DPP_PSD_CODE;
if( fileName.find("QDC") != std::string::npos ) DPPType = DPPType::DPP_QDC_CODE;
if( fileName.find("PHA") != std::string::npos ) DPPType = DPPTypeCode::DPP_PHA_CODE;
if( fileName.find("PSD") != std::string::npos ) DPPType = DPPTypeCode::DPP_PSD_CODE;
if( fileName.find("QDC") != std::string::npos ) DPPType = DPPTypeCode::DPP_QDC_CODE;
numCh = (DPPType == DPPType::DPP_QDC_CODE ? 64 : 16);
numCh = (DPPType == DPPTypeCode::DPP_QDC_CODE ? 64 : 16);
data = new Data(numCh, dataSize);
data->tick2ns = tick2ns;
@ -388,14 +390,21 @@ inline std::string FSUReader::SaveHit2NewFile(std::string saveFolder){
if( i% 10000 == 0 ) printf("Saving %lu/%lu Hit (%.2f%%)\n\033[A\r", i, hitCount, i*100./hitCount);
fwrite( &(hit[i].sn), 2, 1, outFile);
fwrite( &(hit[i].ch), 1, 1, outFile);
//fwrite( &(hit[i].sn), 2, 1, outFile);
uint16_t flag = hit[i].ch + (hit[i].pileUp << 8) ;
if( DPPType == DPPTypeCode::DPP_PSD_CODE ) flag += ( 1 << 15);
if( hit[i].traceLength > 0 ) flag += (1 << 14);
// fwrite( &(hit[i].ch), 1, 1, outFile);
fwrite( &flag, 2, 1, outFile);
fwrite( &(hit[i].energy), 2, 1, outFile);
fwrite( &(hit[i].energy2), 2, 1, outFile);
fwrite( &(hit[i].timestamp), 8, 1, outFile);
if( DPPType == DPPTypeCode::DPP_PSD_CODE ) fwrite( &(hit[i].energy2), 2, 1, outFile);
fwrite( &(hit[i].timestamp), 6, 1, outFile);
fwrite( &(hit[i].fineTime), 2, 1, outFile);
fwrite( &(hit[i].pileUp), 1, 1, outFile);
fwrite( &(hit[i].traceLength), 2, 1, outFile);
// fwrite( &(hit[i].pileUp), 1, 1, outFile);
if( hit[i].traceLength > 0 ) fwrite( &(hit[i].traceLength), 2, 1, outFile);
for( uShort j = 0; j < hit[i].traceLength; j++){
fwrite( &(hit[i].trace[j]), 2, 1, outFile);

View File

@ -147,16 +147,24 @@ inline int FSUTSReader::ReadNextHit(bool withTrace, int verbose){
hitIndex ++;
dummy = fread(&(hit->sn), 2, 1, inFile);
dummy = fread(&(hit->ch), 1, 1, inFile);
dummy = fread(&(hit->energy), 2, 1, inFile);
dummy = fread(&(hit->energy2), 2, 1, inFile);
dummy = fread(&(hit->timestamp), 8, 1, inFile);
dummy = fread(&(hit->fineTime), 2, 1, inFile);
dummy = fread(&(hit->traceLength), 2, 1, inFile);
dummy = fread(&(hit->pileUp), 1, 1, inFile);
hit->sn = sn;
uint16_t temp = 0;
dummy = fread(&temp, 2, 1, inFile); // [0:7] ch [8] pileUp [14] hasTrace [15] hasEnergy2
hit->ch = (temp & 0xFF);
hit->pileUp = ((temp>>8) & 0x1);
bool hasEnergy2 = ((temp>>15) & 0x1);
bool hasTrace = ((temp>>14) & 0x1);
dummy = fread(&(hit->energy), 2, 1, inFile);
if( hasEnergy2 ) dummy = fread(&(hit->energy2), 2, 1, inFile);
dummy = fread(&(hit->timestamp), 6, 1, inFile);
dummy = fread(&(hit->fineTime), 2, 1, inFile);
if( hasTrace ) {
dummy = fread(&(hit->traceLength), 2, 1, inFile);
if( hit->trace.size() > 0 ) hit->trace.clear();
}
if( withTrace && hit->traceLength > 0 ){
for(uShort j = 0; j < hit->traceLength; j++){

View File

@ -3,7 +3,7 @@
void script(){
FSUReader * reader = new FSUReader("/data1/20230816_Encore/data_raw/temp_006_334_PHA_000.fsu", 16);
FSUReader * reader = new FSUReader("~/ExpData/testing/.fsu", 16);
Data * data = reader->GetData();
data->tick2ns = 4;

View File

@ -19,12 +19,17 @@
//#define MaxNData 10000 /// store 10k events per channels
#define DefaultDataSize 10000
enum DPPType{
enum DPPTypeCode{
DPP_PHA_CODE = 0x8B,
DPP_PSD_CODE = 0x88,
DPP_QDC_CODE = 0x87
};
enum ModelTypeCode{
VME = 0,
DT = 1
};
class Data{
public:
@ -58,6 +63,8 @@ class Data{
uShort GetEnergy2(unsigned short ch, unsigned int index) const {return Energy2[ch][index];}
bool GetPileUp(unsigned short ch, unsigned int index) const {return PileUp[ch][index];}
uInt GetWordIndex() const {return nw;}
std::vector<short> ** Waveform1 ; // used at least 14 MB
std::vector<short> ** Waveform2 ;
std::vector<bool> ** DigiWaveform1;
@ -151,7 +158,7 @@ class Data{
inline Data::Data(unsigned short numCh, uInt dataSize): numInputCh(numCh){
tick2ns = 2.0;
boardSN = 0;
DPPType = DPPType::DPP_PHA_CODE;
DPPType = DPPTypeCode::DPP_PHA_CODE;
DPPTypeStr = "";
buffer = NULL;
@ -518,8 +525,8 @@ inline void Data::PrintAllData(bool tableMode, unsigned int maxRowDisplay) const
if( DataIndex[ch] < 0 ) continue;
printf("------------ ch : %d, DataIndex : %d, loop : %d\n", ch, DataIndex[ch], LoopIndex[ch]);
for( int ev = 0; ev <= (LoopIndex[ch] > 0 ? dataSize : DataIndex[ch]) ; ev++){
if( DPPType == DPPType::DPP_PHA_CODE || DPPType == DPPType::DPP_QDC_CODE ) printf("%4d, %5u, %18llu, %5u \n", ev, Energy[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
if( DPPType == DPPType::DPP_PSD_CODE ) printf("%4d, %5u, %5u, %18llu, %5u \n", ev, Energy[ch][ev], Energy2[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
if( DPPType == DPPTypeCode::DPP_PHA_CODE || DPPType == DPPTypeCode::DPP_QDC_CODE ) printf("%4d, %5u, %18llu, %5u \n", ev, Energy[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
if( DPPType == DPPTypeCode::DPP_PSD_CODE ) printf("%4d, %5u, %5u, %18llu, %5u \n", ev, Energy[ch][ev], Energy2[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
if( maxRowDisplay > 0 && (unsigned int) ev > maxRowDisplay ) break;
}
}
@ -531,8 +538,8 @@ inline void Data::PrintChData(unsigned short ch, unsigned int maxRowDisplay) con
if( DataIndex[ch] < 0 ) printf("no data in ch-%d\n", ch);
printf("------------ ch : %d, DataIndex : %d, loop : %d\n", ch, DataIndex[ch], LoopIndex[ch]);
for( int ev = 0; ev < (LoopIndex[ch] > 0 ? dataSize : DataIndex[ch]) ; ev++){
if( DPPType == DPPType::DPP_PHA_CODE || DPPType == DPPType::DPP_QDC_CODE ) printf("%4d, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
if( DPPType == DPPType::DPP_PSD_CODE ) printf("%4d, %5u, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Energy2[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
if( DPPType == DPPTypeCode::DPP_PHA_CODE || DPPType == DPPTypeCode::DPP_QDC_CODE ) printf("%4d, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
if( DPPType == DPPTypeCode::DPP_PSD_CODE ) printf("%4d, %5u, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Energy2[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]);
if( maxRowDisplay > 0 && (unsigned int) ev > maxRowDisplay ) break;
}
@ -594,9 +601,9 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){
if( BoardID > 0 ) {
switch(BoardID){
case 0x8 : DPPType = DPPType::DPP_PSD_CODE; break;
case 0xB : DPPType = DPPType::DPP_PHA_CODE; break;
case 0x7 : DPPType = DPPType::DPP_QDC_CODE; break;
case 0x8 : DPPType = DPPTypeCode::DPP_PSD_CODE; break;
case 0xB : DPPType = DPPTypeCode::DPP_PHA_CODE; break;
case 0x7 : DPPType = DPPTypeCode::DPP_QDC_CODE; break;
}
}
@ -614,13 +621,13 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){
nw = nw + 1;
if( DPPType == DPPType::DPP_PHA_CODE ) {
if( DPPType == DPPTypeCode::DPP_PHA_CODE ) {
if ( DecodePHADualChannelBlock(chMask, fastDecode, verbose) < 0 ) break;
}
if( DPPType == DPPType::DPP_PSD_CODE ) {
if( DPPType == DPPTypeCode::DPP_PSD_CODE ) {
if ( DecodePSDDualChannelBlock(chMask, fastDecode, verbose) < 0 ) break;
}
if( DPPType == DPPType::DPP_QDC_CODE ) {
if( DPPType == DPPTypeCode::DPP_QDC_CODE ) {
if ( DecodeQDCGroupedChannelBlock(chMask, fastDecode, verbose) < 0 ) break;
}
}
@ -646,13 +653,13 @@ inline void Data::DecodeDualBlock(char * &buffer, unsigned int size, int DPPType
nw = 0;
if( DPPType == DPPType::DPP_PHA_CODE ) {
if( DPPType == DPPTypeCode::DPP_PHA_CODE ) {
DecodePHADualChannelBlock(chMask, fastDecode, verbose) ;
}
if( DPPType == DPPType::DPP_PSD_CODE ) {
if( DPPType == DPPTypeCode::DPP_PSD_CODE ) {
DecodePSDDualChannelBlock(chMask, fastDecode, verbose) ;
}
if( DPPType == DPPType::DPP_QDC_CODE ) {
if( DPPType == DPPTypeCode::DPP_QDC_CODE ) {
DecodeQDCGroupedChannelBlock(chMask, fastDecode, verbose) ;
}

View File

@ -26,7 +26,8 @@ void Digitizer::Initalization(){
isInputChEqRegCh = true;
NCoupledCh = 8;
ADCbits = 1;
DPPType = 0;
DPPType = DPPTypeCode::DPP_PHA_CODE;
ModelType = ModelTypeCode::VME;
ADCFullSize = 0;
tick2ns = 0;
BoardInfo = {};
@ -122,13 +123,15 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
isInputChEqRegCh = true;
regChannelMask = pow(2, NumInputCh)-1;
switch(BoardInfo.Model){
case CAEN_DGTZ_V1730: tick2ns = 2.0; NCoupledCh = NumInputCh/2; break; ///ns -> 500 MSamples/s
case CAEN_DGTZ_DT5730: tick2ns = 2.0; NCoupledCh = NumInputCh/2; break; ///ns -> 500 MSamples/s
case CAEN_DGTZ_V1725: tick2ns = 4.0; NCoupledCh = NumInputCh/2; break; ///ns -> 250 MSamples/s
case CAEN_DGTZ_DT5730: tick2ns = 2.0; NCoupledCh = NumInputCh/2; ModelType = ModelTypeCode::DT; break; ///ns -> 500 MSamples/s
case CAEN_DGTZ_DT5720: tick2ns = 4.0; NCoupledCh = NumInputCh/2; ModelType = ModelTypeCode::DT; break; ///ns -> 250 MSamples/s
case CAEN_DGTZ_V1730: tick2ns = 2.0; NCoupledCh = NumInputCh/2; ModelType = ModelTypeCode::VME; break; ///ns -> 500 MSamples/s
case CAEN_DGTZ_V1725: tick2ns = 4.0; NCoupledCh = NumInputCh/2; ModelType = ModelTypeCode::VME; break; ///ns -> 250 MSamples/s
case CAEN_DGTZ_V1740: {
NumInputCh = 64;
NCoupledCh = NumRegChannel;
isInputChEqRegCh = false;
ModelType = ModelTypeCode::VME;
tick2ns = 16.0; break; ///ns -> 62.5 MSamples/s
}
default : tick2ns = 4.0; break;
@ -175,7 +178,7 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
ErrorMsg("========== Set BoardID");
///======================= Check virtual probe
if( DPPType != DPPType::DPP_QDC_CODE ){
if( DPPType != DPPTypeCode::DPP_QDC_CODE ){
int probes[MAX_SUPPORTED_PROBES];
int numProbes;
ret = CAEN_DGTZ_GetDPP_SupportedVirtualProbes(handle, 1, probes, &numProbes);
@ -229,9 +232,9 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
if( isConnected ) isDummy = false;
if( isConnected && program) {
if( DPPType == DPPType::DPP_PHA_CODE ) ProgramBoard_PHA();
if( DPPType == DPPType::DPP_PSD_CODE ) ProgramBoard_PSD();
if( DPPType == DPPType::DPP_QDC_CODE ) ProgramBoard_QDC();
if( DPPType == DPPTypeCode::DPP_PHA_CODE ) ProgramBoard_PHA();
if( DPPType == DPPTypeCode::DPP_PSD_CODE ) ProgramBoard_PSD();
if( DPPType == DPPTypeCode::DPP_QDC_CODE ) ProgramBoard_QDC();
}
//if( isConnected ) ReadAllSettingsFromBoard();
@ -281,9 +284,9 @@ void Digitizer::SetRegChannelOnOff(unsigned short ch, bool onOff){
}
void Digitizer::ProgramBoard(){
if( DPPType == DPPType::DPP_PHA_CODE ) ProgramBoard_PHA();
if( DPPType == DPPType::DPP_PSD_CODE ) ProgramBoard_PSD();
if( DPPType == DPPType::DPP_QDC_CODE ) ProgramBoard_QDC();
if( DPPType == DPPTypeCode::DPP_PHA_CODE ) ProgramBoard_PHA();
if( DPPType == DPPTypeCode::DPP_PSD_CODE ) ProgramBoard_PSD();
if( DPPType == DPPTypeCode::DPP_QDC_CODE ) ProgramBoard_QDC();
}
int Digitizer::ProgramBoard_PHA(){
@ -333,7 +336,7 @@ int Digitizer::ProgramBoard_PHA(){
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0x5, 0xAAAA);
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0x6, 0xAAAA);
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0x7, 0xAAAA);
if( NumRegChannel > 8 ){
if( ModelType == ModelTypeCode::VME ){
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0x8, 0xAAAA);
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0x9, 0xAAAA);
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0xA, 0xAAAA);
@ -390,6 +393,7 @@ int Digitizer::ProgramBoard_PSD(){
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0x5, 0xAAAA);
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0x6, 0xAAAA);
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0x7, 0xAAAA);
if( ModelType == ModelTypeCode::VME ){
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0x8, 0xAAAA);
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0x9, 0xAAAA);
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0xA, 0xAAAA);
@ -398,6 +402,7 @@ int Digitizer::ProgramBoard_PSD(){
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0xD, 0xAAAA);
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0xE, 0xAAAA);
ret |= CAEN_DGTZ_SetChannelDCOffset(handle, 0xF, 0xAAAA);
}
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PreTrigger) + 0x7000 , 20 );
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::RecordLength_G) + 0x7000 , 80 );
@ -522,7 +527,7 @@ void Digitizer::StartACQ(){
}
}
if( DPPType == DPPType::DPP_PHA_CODE ) {
if( DPPType == DPPTypeCode::DPP_PHA_CODE ) {
printf(" Setting Trapzoid Scaling Factor and Fine Gain \n");
for( int ch = 0; ch < NumRegChannel; ch++){
@ -753,7 +758,7 @@ Reg Digitizer::FindRegister(uint32_t address){
Reg tempReg;
///========= Find Match Register
if( DPPType == DPPType::DPP_PHA_CODE || DPPType == DPPType::DPP_PSD_CODE ){
if( DPPType == DPPTypeCode::DPP_PHA_CODE || DPPType == DPPTypeCode::DPP_PSD_CODE ){
for( int p = 0; p < (int) RegisterBoardList_PHAPSD[p]; p++){
if( address == RegisterBoardList_PHAPSD[p].GetAddress() ) {
tempReg = RegisterBoardList_PHAPSD[p];
@ -805,11 +810,11 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){
printf("===== Digitizer(%d)::%s \n", GetSerialNumber(), __func__);
/// board setting
if( DPPType == DPPType::DPP_PHA_CODE || DPPType == DPPType::DPP_PSD_CODE ){
if( DPPType == DPPTypeCode::DPP_PHA_CODE || DPPType == DPPTypeCode::DPP_PSD_CODE ){
for( int p = 0; p < (int) RegisterBoardList_PHAPSD.size(); p++){
if( RegisterBoardList_PHAPSD[p].GetRWType() == RW::WriteONLY) continue;
if( BoardInfo.Model == CAEN_DGTZ_DT5730 && RegisterBoardList_PHAPSD[p].GetAddress() == 0x81C4 ) continue;
if( ModelType == ModelTypeCode::DT && RegisterBoardList_PHAPSD[p].GetAddress() == 0x81C4 ) continue;
ReadRegister(RegisterBoardList_PHAPSD[p]);
}
regChannelMask = GetSettingFromMemory(DPP::RegChannelEnableMask);
@ -862,7 +867,7 @@ void Digitizer::ProgramSettingsToBoard(){
Reg haha;
if( DPPType == DPPType::DPP_PHA_CODE || DPPType == DPPType::DPP_PSD_CODE ){
if( DPPType == DPPTypeCode::DPP_PHA_CODE || DPPType == DPPTypeCode::DPP_PSD_CODE ){
/// board setting
//for( int p = 0; p < (int) RegisterBoardList_PHAPSD.size(); p++){
@ -885,7 +890,6 @@ void Digitizer::ProgramSettingsToBoard(){
if( DPPType == V1730_DPP_PHA_CODE ){
for( int p = 0; p < (int) RegisterChannelList_PHA.size(); p++){
if( RegisterChannelList_PHA[p].GetRWType() == RW::ReadWrite ){
if( BoardInfo.Model == CAEN_DGTZ_DT5730 && RegisterBoardList_PHAPSD[p].GetAddress() == 0x81C4 ) continue;
haha = RegisterChannelList_PHA[p];
WriteRegister(haha, GetSettingFromMemory(haha, ch), ch, false);
usleep(pauseMilliSec * 1000);
@ -895,7 +899,6 @@ void Digitizer::ProgramSettingsToBoard(){
if( DPPType == V1730_DPP_PSD_CODE ){
for( int p = 0; p < (int) RegisterChannelList_PSD.size(); p++){
if( RegisterChannelList_PSD[p].GetRWType() == RW::ReadWrite){
if( BoardInfo.Model == CAEN_DGTZ_DT5730 && RegisterBoardList_PHAPSD[p].GetAddress() == 0x81C4 ) continue;
haha = RegisterChannelList_PSD[p];
WriteRegister(haha, GetSettingFromMemory(haha, ch), ch, false);
usleep(pauseMilliSec * 1000);
@ -1104,37 +1107,51 @@ void Digitizer::SaveAllSettingsAsText(std::string fileName){
haha.SetName("");
uint32_t actualAddress = haha.CalAddress(i);
if( ModelType == ModelTypeCode::DT && actualAddress == 0x81C4 ) continue;
if ( DPPType == V1730_DPP_PHA_CODE || DPPType == V1730_DPP_PSD_CODE ){
///printf("%7d--- 0x%04X, 0x%04X\n", i, haha->GetAddress(), haha->ActualAddress());
for( int p = 0; p < (int) RegisterBoardList_PHAPSD.size(); p++){
if( haha.GetAddress() == (uint32_t) RegisterBoardList_PHAPSD[p] ) haha = RegisterBoardList_PHAPSD[p];
if( haha.GetAddress() == (uint32_t) RegisterBoardList_PHAPSD[p] ) {
haha = RegisterBoardList_PHAPSD[p];
break;
}
}
if( DPPType == V1730_DPP_PHA_CODE) {
for( int p = 0; p < (int) RegisterChannelList_PHA.size(); p++){
if( haha.GetAddress() == (uint32_t) RegisterChannelList_PHA[p] ) haha = RegisterChannelList_PHA[p];
if( haha.GetAddress() == (uint32_t) RegisterChannelList_PHA[p] ) {
haha = RegisterChannelList_PHA[p];
break;
}
}
}
if( DPPType == V1730_DPP_PSD_CODE) {
for( int p = 0; p < (int) RegisterChannelList_PSD.size(); p++){
if( haha.GetAddress() == (uint32_t) RegisterChannelList_PSD[p] ) haha = RegisterChannelList_PSD[p];
if( haha.GetAddress() == (uint32_t) RegisterChannelList_PSD[p] ) {
haha = RegisterChannelList_PSD[p];
break;
}
}
}
}else{
for( int p = 0; p < (int) RegisterBoardList_QDC.size(); p++){
if( haha.GetAddress() == (uint32_t) RegisterBoardList_QDC[p] ) haha = RegisterBoardList_QDC[p];
if( haha.GetAddress() == (uint32_t) RegisterBoardList_QDC[p] ) {
haha = RegisterBoardList_QDC[p];
break;
}
}
for( int p = 0; p < (int) RegisterChannelList_QDC.size(); p++){
if( haha.GetAddress() == (uint32_t) RegisterChannelList_QDC[p] ) haha = RegisterChannelList_QDC[p];
if( haha.GetAddress() == (uint32_t) RegisterChannelList_QDC[p] ) {
haha = RegisterChannelList_QDC[p];
break;
}
}
}
if( BoardInfo.Model == CAEN_DGTZ_DT5730 && haha.GetAddress() == 0x81C4 ) continue;
if( haha.GetName() != "" ) {
std::string typeStr ;
if( haha.GetRWType() == RW::ReadWrite ) typeStr = "R/W";

View File

@ -33,6 +33,7 @@ class Digitizer{
int NCoupledCh; /// number of Coupled channel
int ADCbits; /// ADC bit
int DPPType; /// DPP verion
int ModelType; /// VME or DT
unsigned int ADCFullSize; /// pow(2, ADCbits) - 1
float tick2ns; /// channel to ns
CAEN_DGTZ_BoardInfo_t BoardInfo;
@ -132,6 +133,7 @@ class Digitizer{
int GetCoupledChannels() const {return NCoupledCh;}
int GetHandle() const {return handle;}
int GetDPPType() const {return DPPType;}
int GetModelType() const {return ModelType;}
std::string GetDPPString(int DPPType = 0); /// if no input, use digitizer DPPType
int GetADCBits() const {return BoardInfo.ADC_NBits;}
std::string GetROCVersion() const {return BoardInfo.ROC_FirmwareRel;}

View File

@ -622,7 +622,7 @@ void DigiSettingsPanel::SetUpGlobalTriggerMaskAndFrontPanelMask(QGridLayout * &
maskLayout->setSpacing(2);
int coupledNum = 2;
if( digi[ID]->GetDPPType() == DPPType::DPP_QDC_CODE ) coupledNum = 8;
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) coupledNum = 8;
for( int i = 0; i < digi[ID]->GetCoupledChannels(); i++){
@ -648,7 +648,7 @@ void DigiSettingsPanel::SetUpGlobalTriggerMaskAndFrontPanelMask(QGridLayout * &
}
});
if( digi[ID]->GetDPPType() == DPPType::DPP_QDC_CODE ) bnGlobalTriggerMask[ID][i]->setEnabled(false);
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) bnGlobalTriggerMask[ID][i]->setEnabled(false);
bnTRGOUTMask[ID][i] = new QPushButton(this);
bnTRGOUTMask[ID][i]->setFixedSize(QSize(20,20));
@ -725,7 +725,7 @@ void DigiSettingsPanel::SetUpGlobalTriggerMaskAndFrontPanelMask(QGridLayout * &
});
if( digi[ID]->GetDPPType() == DPPType::DPP_QDC_CODE ) sbGlbMajLvl[ID]->setEnabled(false);
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) sbGlbMajLvl[ID]->setEnabled(false);
//*============================================
@ -800,7 +800,7 @@ void DigiSettingsPanel::SetUpGlobalTriggerMaskAndFrontPanelMask(QGridLayout * &
});
//^============================================ Trigger Validation Mask
if( digi[ID]->GetDPPType() == DPPType::DPP_QDC_CODE ) {
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) {
QLabel * info = new QLabel ("No Trigger Mask for DPP-QDC firmware", this);
bdTriggerLayout[ID]->addWidget(info, 0, 0, 1, 13 );
return;
@ -1277,7 +1277,7 @@ void DigiSettingsPanel::SetUpInquiryCopyTab(){
void DigiSettingsPanel::SetUpChannelMask(unsigned int digiID){
QString lbStr = "Channel Mask :";
if( digi[digiID]->GetDPPType() == DPPType::DPP_QDC_CODE ) lbStr = "Group Mask :";
if( digi[digiID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) lbStr = "Group Mask :";
QLabel * chMaskLabel = new QLabel(lbStr, this);
chMaskLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter);
@ -1291,12 +1291,12 @@ void DigiSettingsPanel::SetUpChannelMask(unsigned int digiID){
chLayout->setSpacing(0);
int nChGrp = digi[digiID]->GetNumRegChannels();
if( digi[digiID]->GetDPPType() == DPPType::DPP_QDC_CODE ) nChGrp = digi[digiID]->GetNumRegChannels();
if( digi[digiID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) nChGrp = digi[digiID]->GetNumRegChannels();
for( int i = 0; i < nChGrp; i++){
bnChEnableMask[digiID][i] = new QPushButton(this);
bnChEnableMask[digiID][i]->setFixedSize(QSize(20,20));
if( digi[digiID]->GetDPPType() == DPPType::DPP_QDC_CODE ){
if( digi[digiID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
bnChEnableMask[digiID][i]->setToolTip("Ch:" + QString::number(8*i) + "-" + QString::number(8*(i+1)-1));
}else{
bnChEnableMask[digiID][i]->setToolTip("Ch:" + QString::number(i));
@ -1313,14 +1313,14 @@ void DigiSettingsPanel::SetUpChannelMask(unsigned int digiID){
if( bnChEnableMask[digiID][i]->styleSheet() == "" ){
bnChEnableMask[digiID][i]->setStyleSheet("background-color : green;");
if( digi[digiID]->GetDPPType() == DPPType::DPP_QDC_CODE ){
if( digi[digiID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
digi[digiID]->SetBits(DPP::QDC::GroupEnableMask, {1, i}, 1, i);
}else{
digi[digiID]->SetBits(DPP::RegChannelEnableMask, {1, i}, 1, i);
}
}else{
bnChEnableMask[digiID][i]->setStyleSheet("");
if( digi[digiID]->GetDPPType() == DPPType::DPP_QDC_CODE ){
if( digi[digiID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
digi[digiID]->SetBits(DPP::QDC::GroupEnableMask, {1, i}, 0, i);
}else{
digi[digiID]->SetBits(DPP::RegChannelEnableMask, {1, i}, 0, i);
@ -3143,14 +3143,14 @@ void DigiSettingsPanel::UpdateBoardAndChannelsStatus(){
for( int i = 0; i < digi[ID]->GetNumRegChannels(); i++){
uint32_t chStatus = digi[ID]->ReadRegister(DPP::ChannelStatus_R, i);
if( digi[ID]->GetDPPType() == DPPType::DPP_PHA_CODE || digi[ID]->GetDPPType() == DPPType::DPP_PSD_CODE ){
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PHA_CODE || digi[ID]->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ){
bnChStatus[ID][i][0]->setStyleSheet( ( (chStatus >> 2 ) & 0x1 ) ? "background-color: red;" : "");
bnChStatus[ID][i][1]->setStyleSheet( ( (chStatus >> 3 ) & 0x1 ) ? "background-color: green;" : "");
bnChStatus[ID][i][2]->setStyleSheet( ( (chStatus >> 8 ) & 0x1 ) ? "background-color: red;" : "");
leADCTemp[ID][i]->setText( QString::number( digi[ID]->GetSettingFromMemory(DPP::ChannelADCTemperature_R, i) ) );
}
if( digi[ID]->GetDPPType() == DPPType::DPP_QDC_CODE ){
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
bnChStatus[ID][i][0]->setStyleSheet( ( (chStatus >> 2 ) & 0x1 ) ? "background-color: red;" : "");
}

2
Hit.h
View File

@ -6,7 +6,6 @@
class Hit{
public:
unsigned short sn;
uint8_t bd;
uint8_t ch;
unsigned short energy;
unsigned short energy2;
@ -23,7 +22,6 @@ public:
void Clear(){
sn = 0;
bd = 0;
ch = 0;
energy = 0;
energy2 = 0;

View File

@ -253,14 +253,13 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
if( time >= earlistTime && (time - earlistTime <= timeWindow) ){
em.sn = snList[bd];
em.bd = bd;
em.ch = ch;
em.energy = data[bd]->GetEnergy(ch, nextIndex[bd][ch]);
em.timestamp = time;
em.fineTime = data[bd]->GetFineTime(ch, nextIndex[bd][ch]);
if( !skipTrace ) em.trace = data[bd]->Waveform1[ch][nextIndex[bd][ch]];
if( typeList[bd] == DPPType::DPP_PSD_CODE ) em.energy2 = data[bd]->GetEnergy2(ch, nextIndex[bd][ch]);
if( typeList[bd] == DPPTypeCode::DPP_PSD_CODE ) em.energy2 = data[bd]->GetEnergy2(ch, nextIndex[bd][ch]);
events[eventIndex].push_back(em);
nextIndex[bd][ch]++;
@ -304,8 +303,15 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
printf(">>>>>>>>>>>>>>>>> Event ID : %ld, total built: %ld, multiplicity : %ld\n", eventIndex, totalEventBuilt, events[eventIndex].size());
for( int i = 0; i <(int) events[eventIndex].size(); i++){
int chxxx = events[eventIndex][i].ch;
int bd = events[eventIndex][i].bd;
printf("%02d, %02d | %5d | %5d %llu \n", bd, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
int sn = events[eventIndex][i].sn;
int bd = 0;
for( int pp = 0; pp < nData; pp++){
if( sn == data[pp]->boardSN ) {
bd = pp;
break;
}
}
printf("%05d, %02d | %5d | %5d %llu \n", sn, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
}
if( nExhaushedCh == nData * MaxNChannels ) {
@ -377,11 +383,10 @@ void MultiBuilder::BuildEventsBackWard(int maxNumEvent, bool verbose){
unsigned long long time = data[bd]->GetTimestamp(ch, nextIndex[bd][ch]);
if( time <= latestTime && (latestTime - time <= timeWindow)){
em.sn = snList[bd];
em.bd = bd;
em.ch = ch;
em.energy = data[bd]->GetEnergy(ch, nextIndex[bd][ch]);
em.timestamp = time;
if( typeList[bd] == DPPType::DPP_PSD_CODE ) em.energy2 = data[bd]->GetEnergy2(ch, nextIndex[bd][ch]);
if( typeList[bd] == DPPTypeCode::DPP_PSD_CODE ) em.energy2 = data[bd]->GetEnergy2(ch, nextIndex[bd][ch]);
events[eventIndex].push_back(em);
nextIndex[bd][ch]--;
@ -407,8 +412,15 @@ void MultiBuilder::BuildEventsBackWard(int maxNumEvent, bool verbose){
printf(">>>>>>>>>>>>>>>>> Event ID : %ld, total built: %ld, multiplicity : %ld\n", eventIndex, totalEventBuilt, events[eventIndex].size());
for( int i = 0; i <(int) events[eventIndex].size(); i++){
int chxxx = events[eventIndex][i].ch;
int bd = events[eventIndex][i].bd;
printf("%02d, %02d | %d | %5d %llu \n", bd, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
int sn = events[eventIndex][i].sn;
int bd = 0;
for( int pp = 0; pp < nData; pp++){
if( sn == data[pp]->boardSN ) {
bd = pp;
break;
}
}
printf("%05d, %02d | %5d | %5d %llu \n", sn, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
}
if( nExhaushedCh == nData * MaxNChannels ) {

View File

@ -579,7 +579,7 @@ void Scope::SetUpComboBox(RComboBox * &cb, QString str, int row, int col, const
int ch = cbScopeCh->currentIndex();
int value = cb->currentData().toInt();
if( digi[ID]->GetDPPType() == DPPType::DPP_QDC_CODE ) {
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) {
int grp = ch/8; // convert ch to grp
digiMTX[ID].lock();
@ -664,7 +664,7 @@ void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Re
msg += " | 0x" + QString::number(value, 16);
if( digi[ID]->GetDPPType() == DPPType::DPP_QDC_CODE ){
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
int grp = ch/8; // convert ch to grp
digiMTX[ID].lock();
digi[ID]->WriteRegister(para, value, grp);
@ -1023,7 +1023,7 @@ void Scope::UpdateComobox(RComboBox * &cb, const Reg para){
enableSignalSlot = false;
int haha = -99;
if( digi[ID]->GetDPPType() == DPPType::DPP_QDC_CODE ){
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
haha = digi[ID]->GetSettingFromMemory(para, ch/8);
}else{
haha = digi[ID]->GetSettingFromMemory(para, ch);
@ -1043,7 +1043,7 @@ void Scope::UpdateComobox(RComboBox * &cb, const Reg para){
void Scope::UpdateSpinBox(RSpinBox * &sb, const Reg para){
int ch = cbScopeCh->currentIndex();
if( digi[ID]->GetDPPType() == DPPType::DPP_QDC_CODE ) ch = ch /8;
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) ch = ch /8;
enableSignalSlot = false;
unsigned int haha = digi[ID]->GetSettingFromMemory(para, ch);

View File

@ -251,7 +251,7 @@ inline void CoincidentAnalyzer::SetUpCanvas(){
boxLayout->addWidget(lbaDigi, 7, 0);
aDigi = new RComboBox(this);
for(unsigned int i = 0; i < nDigi; i ++ ){
aDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
aDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), digi[i]->GetSerialNumber());
}
boxLayout->addWidget(aDigi, 7, 1);
@ -390,16 +390,16 @@ inline void CoincidentAnalyzer::UpdateHistograms(){
unsigned long long xT = 0;
for( int k = 0; k < (int) event.size(); k++ ){
//event[k].Print();
if( event[k].bd == a_bd && event[k].ch == a_ch) {
if( event[k].sn == a_bd && event[k].ch == a_ch) {
h1->Fill(event[k].energy);
aE = event[k].energy;
}
if( event[k].bd == x_bd && event[k].ch == x_ch) {
if( event[k].sn == x_bd && event[k].ch == x_ch) {
xE = event[k].energy;
xT = event[k].timestamp;
}
if( event[k].bd == y_bd && event[k].ch == y_ch) yE = event[k].energy;
if( event[k].sn == y_bd && event[k].ch == y_ch) yE = event[k].energy;
}
if( xE >= 0 && yE >= 0 ) h2D->Fill(xE, yE);

View File

@ -4,6 +4,15 @@
#include "Analyser.h"
#include "Isotope.h"
int SN2Bd(int sn){
switch (sn) {
case 278 : return 0; break;
case 45 : return 1; break;
case 370 : return 2; break;
};
return 0;
};
namespace ChMap{
const int mapping[3][16] = {
@ -117,7 +126,8 @@ inline void Encore::UpdateHistograms(){
double sum[17] = {0};
for( int k = 0; k < (int) event.size(); k++ ){
int bd = event[k].bd;
int bd = SN2Bd(event[k].sn);
int ch = event[k].ch;
int ID = ChMap::mapping[bd][ch];