fix MultiBuilder use MaxRegChannel, which should not
This commit is contained in:
parent
ab54bbbc09
commit
926517df91
|
@ -72,7 +72,9 @@ class Data{
|
||||||
void ClearData();
|
void ClearData();
|
||||||
void ClearTriggerRate();
|
void ClearTriggerRate();
|
||||||
void ClearBuffer();
|
void ClearBuffer();
|
||||||
|
|
||||||
|
unsigned short GetNChannel() const {return numInputCh;}
|
||||||
|
|
||||||
void CopyBuffer( const char * buffer, const unsigned int size);
|
void CopyBuffer( const char * buffer, const unsigned int size);
|
||||||
|
|
||||||
void DecodeBuffer(bool fastDecode, int verbose = 0); /// fastDecode will not save waveform
|
void DecodeBuffer(bool fastDecode, int verbose = 0); /// fastDecode will not save waveform
|
||||||
|
|
|
@ -31,7 +31,7 @@ void MultiBuilder::ClearEvents(){
|
||||||
for( int i = 0; i < MaxNEvent; i++) events[i].clear();
|
for( int i = 0; i < MaxNEvent; i++) events[i].clear();
|
||||||
|
|
||||||
for( int i = 0; i < MaxNDigitizer; i++){
|
for( int i = 0; i < MaxNDigitizer; i++){
|
||||||
for( int j = 0; j < MaxRegChannel; j++){
|
for( int j = 0; j < MaxNChannels; j++){
|
||||||
loopIndex[i][j] = 0;
|
loopIndex[i][j] = 0;
|
||||||
nextIndex[i][j] = -1;
|
nextIndex[i][j] = -1;
|
||||||
chExhaused[i][j] = false;
|
chExhaused[i][j] = false;
|
||||||
|
@ -51,7 +51,7 @@ void MultiBuilder::PrintStat(){
|
||||||
|
|
||||||
printf("Total number of evet built : %ld\n", totalEventBuilt);
|
printf("Total number of evet built : %ld\n", totalEventBuilt);
|
||||||
for( int i = 0; i < nData ; i++){
|
for( int i = 0; i < nData ; i++){
|
||||||
for( int ch = 0; ch < MaxRegChannel ; ch++){
|
for( int ch = 0; ch < data[i]->GetNChannel() ; ch++){
|
||||||
printf("%d %3d %2d | %7d (%d)\n", i, snList[i], ch, nextIndex[i][ch], loopIndex[i][ch]);
|
printf("%d %3d %2d | %7d (%d)\n", i, snList[i], ch, nextIndex[i][ch], loopIndex[i][ch]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,12 +68,20 @@ void MultiBuilder::FindEarlistTimeAndCh(bool verbose){
|
||||||
|
|
||||||
for( int i = 0; i < nData; i++){
|
for( int i = 0; i < nData; i++){
|
||||||
|
|
||||||
for( int j = 0; j < MaxRegChannel; j++ ){
|
for( int j = 0; j < data[i]->GetNChannel(); j++ ){
|
||||||
chExhaused[i][j] = false;
|
chExhaused[i][j] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(unsigned int ch = 0; ch < MaxRegChannel; ch ++){
|
for(unsigned int ch = 0; ch < MaxNChannels; ch ++){
|
||||||
if( data[i]->Timestamp[ch][data[i]->DataIndex[ch]] == 0 || data[i]->DataIndex[ch] == -1 || loopIndex[i][ch] * MaxNData + nextIndex[i][ch] > data[i]->LoopIndex[ch] * MaxNData + data[i]->DataIndex[ch]) {
|
if( ch >= data[i]->GetNChannel() ) {
|
||||||
|
nExhaushedCh ++;
|
||||||
|
chExhaused[i][ch] = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( data[i]->Timestamp[ch][data[i]->DataIndex[ch]] == 0 ||
|
||||||
|
data[i]->DataIndex[ch] == -1 ||
|
||||||
|
loopIndex[i][ch] * MaxNData + nextIndex[i][ch] > data[i]->LoopIndex[ch] * MaxNData + data[i]->DataIndex[ch]) {
|
||||||
nExhaushedCh ++;
|
nExhaushedCh ++;
|
||||||
chExhaused[i][ch] = true;
|
chExhaused[i][ch] = true;
|
||||||
continue;
|
continue;
|
||||||
|
@ -104,13 +112,13 @@ void MultiBuilder::FindLatestTimeAndCh(bool verbose){
|
||||||
|
|
||||||
for( int i = 0; i < nData; i++){
|
for( int i = 0; i < nData; i++){
|
||||||
|
|
||||||
for( int j = 0; j < MaxRegChannel; j++ ){
|
for( int j = 0; j < data[i]->GetNChannel(); j++ ){
|
||||||
chExhaused[i][j] = false;
|
chExhaused[i][j] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(unsigned int ch = 0; ch < MaxRegChannel; ch ++){
|
for(unsigned int ch = 0; ch < MaxNChannels; ch ++){
|
||||||
// printf(" %d, %d | %d", i, ch, nextIndex[i][ch]);
|
// printf(" %d, %d | %d", i, ch, nextIndex[i][ch]);
|
||||||
if( nextIndex[i][ch] < 0 ) {
|
if( nextIndex[i][ch] < 0 || ch >= data[i]->GetNChannel()) {
|
||||||
nExhaushedCh ++;
|
nExhaushedCh ++;
|
||||||
chExhaused[i][ch] = true;
|
chExhaused[i][ch] = true;
|
||||||
|
|
||||||
|
@ -137,7 +145,7 @@ void MultiBuilder::FindLatestTimeOfData(bool verbose){
|
||||||
latestCh = -1;
|
latestCh = -1;
|
||||||
latestDigi = -1;
|
latestDigi = -1;
|
||||||
for( int i = 0; i < nData; i++){
|
for( int i = 0; i < nData; i++){
|
||||||
for( unsigned ch = 0; ch < MaxRegChannel; ch++ ){
|
for( unsigned ch = 0; ch < data[i]->GetNChannel(); ch++ ){
|
||||||
int index = data[i]->DataIndex[ch];
|
int index = data[i]->DataIndex[ch];
|
||||||
if( index == -1 ) continue;
|
if( index == -1 ) continue;
|
||||||
if( data[i]->Timestamp[ch][index] > latestTime ) {
|
if( data[i]->Timestamp[ch][index] > latestTime ) {
|
||||||
|
@ -155,7 +163,7 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||||
FindLatestTimeOfData(verbose);
|
FindLatestTimeOfData(verbose);
|
||||||
|
|
||||||
FindEarlistTimeAndCh(verbose);
|
FindEarlistTimeAndCh(verbose);
|
||||||
if( earlistCh == -1 || nExhaushedCh == nData * MaxRegChannel) return; /// no data
|
if( earlistCh == -1 || nExhaushedCh == nData * MaxNChannels) return; /// no data
|
||||||
|
|
||||||
eventBuilt = 0;
|
eventBuilt = 0;
|
||||||
//======= Start building event
|
//======= Start building event
|
||||||
|
@ -177,8 +185,10 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||||
// printf("##### %d/%d | ", k, nData);
|
// printf("##### %d/%d | ", k, nData);
|
||||||
// data[k]->PrintAllData(true, 10);
|
// data[k]->PrintAllData(true, 10);
|
||||||
|
|
||||||
for( unsigned int i = 0; i < MaxRegChannel; i++){
|
const int numCh = data[k]->GetNChannel();
|
||||||
int ch = (i + earlistCh ) % MaxRegChannel;
|
|
||||||
|
for( int i = 0; i < numCh; i++){
|
||||||
|
int ch = (i + earlistCh ) % numCh;
|
||||||
if( chExhaused[bd][ch] ) continue;
|
if( chExhaused[bd][ch] ) continue;
|
||||||
if( loopIndex[bd][ch] * MaxNData + nextIndex[bd][ch] > data[bd]->LoopIndex[ch] * MaxNData + data[bd]->DataIndex[ch]) {
|
if( loopIndex[bd][ch] * MaxNData + nextIndex[bd][ch] > data[bd]->LoopIndex[ch] * MaxNData + data[bd]->DataIndex[ch]) {
|
||||||
nExhaushedCh ++;
|
nExhaushedCh ++;
|
||||||
|
@ -234,7 +244,7 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||||
printf("%02d, %02d | %d | %5d %llu \n", bd, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
|
printf("%02d, %02d | %d | %5d %llu \n", bd, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nExhaushedCh == nData * MaxRegChannel ) {
|
if( nExhaushedCh == nData * MaxNChannels ) {
|
||||||
printf("######################### no more event to be built\n");
|
printf("######################### no more event to be built\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +259,7 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}while(nExhaushedCh < nData * MaxRegChannel);
|
}while(nExhaushedCh < nData * MaxNChannels);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,8 +269,9 @@ void MultiBuilder::BuildEventsBackWard(int maxNumEvent, bool verbose){
|
||||||
|
|
||||||
// remember the end of DataIndex, prevent over build
|
// remember the end of DataIndex, prevent over build
|
||||||
for( int k = 0; k < nData; k++){
|
for( int k = 0; k < nData; k++){
|
||||||
for( int i = 0; i < MaxRegChannel; i++){
|
for( int i = 0; i < data[i]->GetNChannel(); i++){
|
||||||
nextIndex[k][i] = data[k]->DataIndex[i];
|
nextIndex[k][i] = data[k]->DataIndex[i];
|
||||||
|
loopIndex[k][i] = data[k]->LoopIndex[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,8 +292,10 @@ void MultiBuilder::BuildEventsBackWard(int maxNumEvent, bool verbose){
|
||||||
for( int k = 0; k < nData; k++){
|
for( int k = 0; k < nData; k++){
|
||||||
int bd = (k + latestDigi) % nData;
|
int bd = (k + latestDigi) % nData;
|
||||||
|
|
||||||
for( unsigned int i = 0; i < MaxRegChannel; i++){
|
const int numCh = data[k]->GetNChannel();
|
||||||
int ch = (i + latestCh) % MaxRegChannel;
|
|
||||||
|
for( int i = 0; i < numCh; i++){
|
||||||
|
int ch = (i + latestCh) % numCh;
|
||||||
if( chExhaused[bd][ch] ) continue;
|
if( chExhaused[bd][ch] ) continue;
|
||||||
//if( nextIndex[bd][ch] <= lastBackWardIndex[bd][ch] || nextIndex[bd][ch] < 0){
|
//if( nextIndex[bd][ch] <= lastBackWardIndex[bd][ch] || nextIndex[bd][ch] < 0){
|
||||||
if( nextIndex[bd][ch] < 0){
|
if( nextIndex[bd][ch] < 0){
|
||||||
|
@ -330,7 +343,7 @@ void MultiBuilder::BuildEventsBackWard(int maxNumEvent, bool verbose){
|
||||||
printf("%02d, %02d | %d | %5d %llu \n", bd, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
|
printf("%02d, %02d | %d | %5d %llu \n", bd, chxxx, nextIndex[bd][chxxx], events[eventIndex][i].energy, events[eventIndex][i].timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nExhaushedCh == nData * MaxRegChannel ) {
|
if( nExhaushedCh == nData * MaxNChannels ) {
|
||||||
printf("######################### no more event to be built\n");
|
printf("######################### no more event to be built\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -338,7 +351,7 @@ void MultiBuilder::BuildEventsBackWard(int maxNumEvent, bool verbose){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}while(nExhaushedCh < nData * MaxRegChannel && eventBuilt <= maxNumEvent);
|
}while(nExhaushedCh < nData * MaxNChannels && eventBuilt <= maxNumEvent);
|
||||||
|
|
||||||
// // remember the end of DataIndex, prevent over build
|
// // remember the end of DataIndex, prevent over build
|
||||||
// for( int k = 0; k < nData; k++){
|
// for( int k = 0; k < nData; k++){
|
||||||
|
|
|
@ -70,11 +70,11 @@ private:
|
||||||
Data ** data; // assume all data has MaxNChannel (16)
|
Data ** data; // assume all data has MaxNChannel (16)
|
||||||
|
|
||||||
unsigned short timeWindow;
|
unsigned short timeWindow;
|
||||||
int loopIndex[MaxNDigitizer][MaxRegChannel];
|
int loopIndex[MaxNDigitizer][MaxNChannels];
|
||||||
int nextIndex[MaxNDigitizer][MaxRegChannel];
|
int nextIndex[MaxNDigitizer][MaxNChannels];
|
||||||
|
|
||||||
int nExhaushedCh;
|
int nExhaushedCh;
|
||||||
bool chExhaused[MaxNDigitizer][MaxRegChannel];
|
bool chExhaused[MaxNDigitizer][MaxNChannels];
|
||||||
|
|
||||||
void FindEarlistTimeAndCh(bool verbose = false); // search thtough the nextIndex
|
void FindEarlistTimeAndCh(bool verbose = false); // search thtough the nextIndex
|
||||||
unsigned long long earlistTime;
|
unsigned long long earlistTime;
|
||||||
|
@ -87,7 +87,7 @@ private:
|
||||||
|
|
||||||
void FindLatestTimeOfData(bool verbose = false);
|
void FindLatestTimeOfData(bool verbose = false);
|
||||||
|
|
||||||
int lastBackWardIndex[MaxNDigitizer][MaxRegChannel];
|
int lastBackWardIndex[MaxNDigitizer][MaxNChannels];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user