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,9 +35,9 @@ class Data{
unsigned int nByte; /// number of byte from read buffer
uint32_t AllocatedSize;
double TriggerRate[MaxNChannels]; /// Hz
double NonPileUpRate[MaxNChannels]; /// Hz
unsigned long TotNumNonPileUpEvents[MaxNChannels];
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
@ -54,7 +54,7 @@ class Data{
unsigned short Energy2 [MaxNChannels][MaxNData]; /// 15 bit, in PSD, Energy = Qshort, Energy2 = Qlong
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<bool> DigiWaveform1[MaxNChannels][MaxNData];
std::vector<bool> DigiWaveform2[MaxNChannels][MaxNData];
@ -62,7 +62,7 @@ class Data{
std::vector<bool> DigiWaveform4[MaxNChannels][MaxNData];
public:
Data();
Data(unsigned short numCh);
~Data();
void Allocate80MBMemory();
@ -92,8 +92,8 @@ class Data{
protected:
const unsigned short numChannel;
unsigned int nw;
//bool SaveWaveToMemory;
///for temperary
std::vector<short> 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++){

View File

@ -16,7 +16,7 @@ Digitizer::~Digitizer(){
void Digitizer::Initalization(){
data = new Data();
data = nullptr;
portID = -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
default : tick2ns = 4.0; break;
}
data = new Data(NChannel);
data->tick2ns = tick2ns;
data->boardSN = BoardInfo.SerialNumber;
ADCbits = BoardInfo.ADC_NBits;

View File

@ -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;
}

View File

@ -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{

View File

@ -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;