add numChannel for ClassData.h

This commit is contained in:
carina@hades 2023-10-06 17:57:43 -04:00
parent 1faaea4dcb
commit 434f15734c
5 changed files with 36 additions and 33 deletions

View File

@ -35,34 +35,34 @@ class Data{
unsigned int nByte; /// number of byte from read buffer unsigned int nByte; /// number of byte from read buffer
uint32_t AllocatedSize; uint32_t AllocatedSize;
double TriggerRate[MaxNChannels]; /// Hz float TriggerRate [MaxNChannels]; /// Hz
double NonPileUpRate[MaxNChannels]; /// Hz float NonPileUpRate [MaxNChannels]; /// Hz
unsigned long TotNumNonPileUpEvents[MaxNChannels]; unsigned long TotNumNonPileUpEvents[MaxNChannels]; /// also exclude overthrow
unsigned short NumEventsDecoded[MaxNChannels]; /// reset at every decode unsigned short NumEventsDecoded [MaxNChannels]; /// reset at every decode
unsigned short NumNonPileUpDecoded[MaxNChannels]; /// reset at every decode unsigned short NumNonPileUpDecoded [MaxNChannels]; /// reset at every decode
/// store data for event building and deduce the trigger rate. /// store data for event building and deduce the trigger rate.
//it is a circular memory //it is a circular memory
bool IsNotRollOverFakeAgg; bool IsNotRollOverFakeAgg;
int LoopIndex[MaxNChannels]; /// number of loop in the circular memory int LoopIndex[MaxNChannels]; /// number of loop in the circular memory
int DataIndex[MaxNChannels]; int DataIndex[MaxNChannels];
unsigned long long Timestamp[MaxNChannels][MaxNData]; /// 47 bit unsigned long long Timestamp[MaxNChannels][MaxNData]; /// 47 bit
unsigned short fineTime[MaxNChannels][MaxNData]; /// 10 bits, in unit of tick2ns / 1000 = ps unsigned short fineTime [MaxNChannels][MaxNData]; /// 10 bits, in unit of tick2ns / 1000 = ps
unsigned short Energy[MaxNChannels][MaxNData]; /// 15 bit unsigned short Energy [MaxNChannels][MaxNData]; /// 15 bit
unsigned short Energy2[MaxNChannels][MaxNData]; /// 15 bit, in PSD, Energy = Qshort, Energy2 = Qlong unsigned short Energy2 [MaxNChannels][MaxNData]; /// 15 bit, in PSD, Energy = Qshort, Energy2 = Qlong
bool PileUp[MaxNChannels][MaxNData]; /// pile up flag bool PileUp [MaxNChannels][MaxNData]; /// pile up flag
std::vector<short> Waveform1[MaxNChannels][MaxNData]; std::vector<short> Waveform1 [MaxNChannels][MaxNData]; // used at least 14 MB
std::vector<short> Waveform2[MaxNChannels][MaxNData]; std::vector<short> Waveform2 [MaxNChannels][MaxNData];
std::vector<bool> DigiWaveform1[MaxNChannels][MaxNData]; std::vector<bool> DigiWaveform1[MaxNChannels][MaxNData];
std::vector<bool> DigiWaveform2[MaxNChannels][MaxNData]; std::vector<bool> DigiWaveform2[MaxNChannels][MaxNData];
std::vector<bool> DigiWaveform3[MaxNChannels][MaxNData]; std::vector<bool> DigiWaveform3[MaxNChannels][MaxNData];
std::vector<bool> DigiWaveform4[MaxNChannels][MaxNData]; std::vector<bool> DigiWaveform4[MaxNChannels][MaxNData];
public: public:
Data(); Data(unsigned short numCh);
~Data(); ~Data();
void Allocate80MBMemory(); void Allocate80MBMemory();
@ -92,8 +92,8 @@ class Data{
protected: protected:
const unsigned short numChannel;
unsigned int nw; unsigned int nw;
//bool SaveWaveToMemory;
///for temperary ///for temperary
std::vector<short> tempWaveform1; std::vector<short> tempWaveform1;
@ -118,12 +118,11 @@ class Data{
int DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose); int DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose);
int DecodeQDCGroupedChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose); int DecodeQDCGroupedChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose);
}; };
//========================================== //==========================================
inline Data::Data(){ inline Data::Data(unsigned short numCh): numChannel(numCh){
tick2ns = 2.0; tick2ns = 2.0;
boardSN = 0; boardSN = 0;
DPPType = DPPType::DPP_PHA_CODE; DPPType = DPPType::DPP_PHA_CODE;
@ -298,7 +297,7 @@ inline void Data::PrintStat() const{
} }
printf("%2s | %6s | %9s | %9s | %6s | %6s(%4s)\n", "ch", "# Evt.", "Rate [Hz]", "Accept", "Tot. Evt.", "index", "loop"); printf("%2s | %6s | %9s | %9s | %6s | %6s(%4s)\n", "ch", "# Evt.", "Rate [Hz]", "Accept", "Tot. Evt.", "index", "loop");
printf("---+--------+-----------+-----------+----------\n"); printf("---+--------+-----------+-----------+----------\n");
for(int ch = 0; ch < MaxNChannels; ch++){ for(int ch = 0; ch < numChannel; ch++){
printf("%2d | %6d | %9.2f | %9.2f | %6lu | %6d(%2d)\n", ch, NumEventsDecoded[ch], TriggerRate[ch], NonPileUpRate[ch], TotNumNonPileUpEvents[ch], DataIndex[ch], LoopIndex[ch]); printf("%2d | %6d | %9.2f | %9.2f | %6lu | %6d(%2d)\n", ch, NumEventsDecoded[ch], TriggerRate[ch], NonPileUpRate[ch], TotNumNonPileUpEvents[ch], DataIndex[ch], LoopIndex[ch]);
} }
printf("---+--------+-----------+-----------+----------\n"); printf("---+--------+-----------+-----------+----------\n");
@ -312,7 +311,7 @@ inline void Data::PrintAllData(bool tableMode, unsigned int maxRowDisplay) const
int MaxEntry = 0; int MaxEntry = 0;
printf("%4s|", ""); printf("%4s|", "");
for( int ch = 0; ch < MaxNChannels; ch++){ for( int ch = 0; ch < numChannel; ch++){
if( LoopIndex[ch] > 0 ) { if( LoopIndex[ch] > 0 ) {
MaxEntry = MaxNData-1; MaxEntry = MaxNData-1;
}else{ }else{
@ -326,7 +325,7 @@ inline void Data::PrintAllData(bool tableMode, unsigned int maxRowDisplay) const
do{ do{
printf("%4d|", entry ); printf("%4d|", entry );
for( int ch = 0; ch < MaxNChannels; ch++){ for( int ch = 0; ch < numChannel; ch++){
if( DataIndex[ch] < 0 ) continue; if( DataIndex[ch] < 0 ) continue;
printf(" %5d,%12lld |", Energy[ch][entry], Timestamp[ch][entry]); printf(" %5d,%12lld |", Energy[ch][entry], Timestamp[ch][entry]);
} }
@ -337,7 +336,7 @@ inline void Data::PrintAllData(bool tableMode, unsigned int maxRowDisplay) const
}while(entry <= MaxEntry); }while(entry <= MaxEntry);
}else{ }else{
for( int ch = 0; ch < MaxNChannels ; ch++){ for( int ch = 0; ch < numChannel ; ch++){
if( DataIndex[ch] < 0 ) continue; if( DataIndex[ch] < 0 ) continue;
printf("------------ ch : %d, DataIndex : %d, loop : %d\n", ch, DataIndex[ch], LoopIndex[ch]); printf("------------ ch : %d, DataIndex : %d, loop : %d\n", ch, DataIndex[ch], LoopIndex[ch]);
for( int ev = 0; ev <= (LoopIndex[ch] > 0 ? MaxNData : DataIndex[ch]) ; ev++){ for( int ev = 0; ev <= (LoopIndex[ch] > 0 ? MaxNData : DataIndex[ch]) ; ev++){

View File

@ -16,7 +16,7 @@ Digitizer::~Digitizer(){
void Digitizer::Initalization(){ void Digitizer::Initalization(){
data = new Data(); data = nullptr;
portID = -1; portID = -1;
boardID = -1; boardID = -1;
@ -109,6 +109,8 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
case CAEN_DGTZ_V1740: tick2ns = 16.0; NCoupledCh = 8; break; ///ns -> 62.5 MSamples/s case CAEN_DGTZ_V1740: tick2ns = 16.0; NCoupledCh = 8; break; ///ns -> 62.5 MSamples/s
default : tick2ns = 4.0; break; default : tick2ns = 4.0; break;
} }
data = new Data(NChannel);
data->tick2ns = tick2ns; data->tick2ns = tick2ns;
data->boardSN = BoardInfo.SerialNumber; data->boardSN = BoardInfo.SerialNumber;
ADCbits = BoardInfo.ADC_NBits; ADCbits = BoardInfo.ADC_NBits;

View File

@ -6,9 +6,9 @@
int main(){ int main(){
Digitizer * digi = new Digitizer(); //Digitizer * digi = new Digitizer();
Data * data = digi->GetData(); Data * data = new Data(16);
std::random_device rd; std::random_device rd;
std::mt19937 gen(rd()); std::mt19937 gen(rd());
@ -56,6 +56,6 @@ int main(){
} }
delete digi; delete data;
} }

View File

@ -84,7 +84,8 @@ int main(int argc, char **argv){
for( int i = 0; i < nFile; i++){ for( int i = 0; i < nFile; i++){
inFile[i] = fopen(inFileName[i].Data(), "r"); inFile[i] = fopen(inFileName[i].Data(), "r");
if( inFile[i] ){ if( inFile[i] ){
data[i] = new Data(); 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);
data[i]->DPPType = type[i]; data[i]->DPPType = type[i];
data[i]->boardSN = ID[i]%1000; data[i]->boardSN = ID[i]%1000;
}else{ }else{

View File

@ -138,9 +138,10 @@ int main(int argc, char **argv) {
inFile[i] = fopen(fileList[i][0], "r"); inFile[i] = fopen(fileList[i][0], "r");
if( inFile[i] ){ if( inFile[i] ){
inFileIndex[i] = 0; inFileIndex[i] = 0;
data[i] = new Data(); if( typeList[i] == DPPType::DPP_PHA_CODE || typeList[i] == DPPType::DPP_PSD_CODE ) data[i] = new Data(16);
data[i]->DPPType = typeList[0]; if( typeList[i] == DPPType::DPP_QDC_CODE ) data[i] = new Data(64);
data[i]->boardSN = snList[0]; data[i]->DPPType = typeList[i];
data[i]->boardSN = snList[i];
}else{ }else{
inFileIndex[i] = -1; inFileIndex[i] = -1;
data[i] = nullptr; data[i] = nullptr;