From 434f15734c24f00b0ddd167d3cb1385de66200b0 Mon Sep 17 00:00:00 2001 From: "carina@hades" Date: Fri, 6 Oct 2023 17:57:43 -0400 Subject: [PATCH] add numChannel for ClassData.h --- ClassData.h | 47 +++++++++++++++++++++++----------------------- ClassDigitizer.cpp | 6 ++++-- DataGenerator.cpp | 6 +++--- DumpFSU2ROOT.cpp | 3 ++- EventBuilder.cpp | 7 ++++--- 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/ClassData.h b/ClassData.h index 582517f..9f14c12 100644 --- a/ClassData.h +++ b/ClassData.h @@ -33,36 +33,36 @@ class Data{ float tick2ns; /// only use in TriggerRate calculation unsigned int nByte; /// number of byte from read buffer - uint32_t AllocatedSize; - - double TriggerRate[MaxNChannels]; /// Hz - double NonPileUpRate[MaxNChannels]; /// Hz - unsigned long TotNumNonPileUpEvents[MaxNChannels]; - unsigned short NumEventsDecoded[MaxNChannels]; /// reset at every decode - unsigned short NumNonPileUpDecoded[MaxNChannels]; /// reset at every decode + uint32_t AllocatedSize; + + float TriggerRate [MaxNChannels]; /// Hz + float NonPileUpRate [MaxNChannels]; /// Hz + unsigned long TotNumNonPileUpEvents[MaxNChannels]; /// also exclude overthrow + unsigned short NumEventsDecoded [MaxNChannels]; /// reset at every decode + unsigned short NumNonPileUpDecoded [MaxNChannels]; /// reset at every decode /// store data for event building and deduce the trigger rate. //it is a circular memory bool IsNotRollOverFakeAgg; - int LoopIndex[MaxNChannels]; /// number of loop in the circular memory - int DataIndex[MaxNChannels]; + int LoopIndex[MaxNChannels]; /// number of loop in the circular memory + int DataIndex[MaxNChannels]; unsigned long long Timestamp[MaxNChannels][MaxNData]; /// 47 bit - unsigned short fineTime[MaxNChannels][MaxNData]; /// 10 bits, in unit of tick2ns / 1000 = ps - unsigned short Energy[MaxNChannels][MaxNData]; /// 15 bit - unsigned short Energy2[MaxNChannels][MaxNData]; /// 15 bit, in PSD, Energy = Qshort, Energy2 = Qlong - bool PileUp[MaxNChannels][MaxNData]; /// pile up flag + unsigned short fineTime [MaxNChannels][MaxNData]; /// 10 bits, in unit of tick2ns / 1000 = ps + unsigned short Energy [MaxNChannels][MaxNData]; /// 15 bit + unsigned short Energy2 [MaxNChannels][MaxNData]; /// 15 bit, in PSD, Energy = Qshort, Energy2 = Qlong + bool PileUp [MaxNChannels][MaxNData]; /// pile up flag - std::vector Waveform1[MaxNChannels][MaxNData]; - std::vector Waveform2[MaxNChannels][MaxNData]; + std::vector Waveform1 [MaxNChannels][MaxNData]; // used at least 14 MB + std::vector Waveform2 [MaxNChannels][MaxNData]; std::vector DigiWaveform1[MaxNChannels][MaxNData]; std::vector DigiWaveform2[MaxNChannels][MaxNData]; std::vector DigiWaveform3[MaxNChannels][MaxNData]; std::vector DigiWaveform4[MaxNChannels][MaxNData]; public: - Data(); + Data(unsigned short numCh); ~Data(); void Allocate80MBMemory(); @@ -91,9 +91,9 @@ class Data{ void ZeroTotalFileSize() { FinishedOutFilesSize = 0; } protected: - + + const unsigned short numChannel; unsigned int nw; - //bool SaveWaveToMemory; ///for temperary std::vector tempWaveform1; @@ -118,12 +118,11 @@ class Data{ int DecodePSDDualChannelBlock(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; boardSN = 0; 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("---+--------+-----------+-----------+----------\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("---+--------+-----------+-----------+----------\n"); @@ -312,7 +311,7 @@ inline void Data::PrintAllData(bool tableMode, unsigned int maxRowDisplay) const int MaxEntry = 0; printf("%4s|", ""); - for( int ch = 0; ch < MaxNChannels; ch++){ + for( int ch = 0; ch < numChannel; ch++){ if( LoopIndex[ch] > 0 ) { MaxEntry = MaxNData-1; }else{ @@ -326,7 +325,7 @@ inline void Data::PrintAllData(bool tableMode, unsigned int maxRowDisplay) const do{ printf("%4d|", entry ); - for( int ch = 0; ch < MaxNChannels; ch++){ + for( int ch = 0; ch < numChannel; ch++){ if( DataIndex[ch] < 0 ) continue; 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); }else{ - for( int ch = 0; ch < MaxNChannels ; ch++){ + for( int ch = 0; ch < numChannel ; ch++){ 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 ? MaxNData : DataIndex[ch]) ; ev++){ diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 8e87f04..bdf7eb6 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -16,8 +16,8 @@ Digitizer::~Digitizer(){ void Digitizer::Initalization(){ - data = new Data(); - + data = nullptr; + portID = -1; boardID = -1; handle = -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 default : tick2ns = 4.0; break; } + + data = new Data(NChannel); data->tick2ns = tick2ns; data->boardSN = BoardInfo.SerialNumber; ADCbits = BoardInfo.ADC_NBits; diff --git a/DataGenerator.cpp b/DataGenerator.cpp index 428f05f..28f9e18 100644 --- a/DataGenerator.cpp +++ b/DataGenerator.cpp @@ -6,9 +6,9 @@ int main(){ - Digitizer * digi = new Digitizer(); + //Digitizer * digi = new Digitizer(); - Data * data = digi->GetData(); + Data * data = new Data(16); std::random_device rd; std::mt19937 gen(rd()); @@ -56,6 +56,6 @@ int main(){ } - delete digi; + delete data; } \ No newline at end of file diff --git a/DumpFSU2ROOT.cpp b/DumpFSU2ROOT.cpp index ac04288..da6eb85 100644 --- a/DumpFSU2ROOT.cpp +++ b/DumpFSU2ROOT.cpp @@ -84,7 +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] ){ - 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]->boardSN = ID[i]%1000; }else{ diff --git a/EventBuilder.cpp b/EventBuilder.cpp index 6adbc0b..8b501cc 100644 --- a/EventBuilder.cpp +++ b/EventBuilder.cpp @@ -138,9 +138,10 @@ int main(int argc, char **argv) { inFile[i] = fopen(fileList[i][0], "r"); if( inFile[i] ){ inFileIndex[i] = 0; - data[i] = new Data(); - data[i]->DPPType = typeList[0]; - data[i]->boardSN = snList[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); + data[i]->DPPType = typeList[i]; + data[i]->boardSN = snList[i]; }else{ inFileIndex[i] = -1; data[i] = nullptr;