2023-06-14 15:20:15 -04:00
|
|
|
#ifndef MuLTI_BUILDER_H
|
|
|
|
#define MuLTI_BUILDER_H
|
|
|
|
|
|
|
|
#include "ClassData.h"
|
2024-01-12 19:12:37 -05:00
|
|
|
#include "Hit.h"
|
2023-06-14 15:20:15 -04:00
|
|
|
|
2023-09-06 09:59:06 -04:00
|
|
|
#define MaxNEvent 100000 // circular, this number should be at least nDigi * MaxNChannel * MaxNData
|
2023-06-14 15:20:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
class MultiBuilder {
|
|
|
|
|
|
|
|
public:
|
2023-06-19 12:48:17 -04:00
|
|
|
MultiBuilder(Data ** multiData, std::vector<int> type, std::vector<int> sn);
|
2023-10-05 13:13:15 -04:00
|
|
|
MultiBuilder(Data * singleData, int type, int sn);
|
2023-06-14 15:20:15 -04:00
|
|
|
~MultiBuilder();
|
|
|
|
|
2023-12-12 15:35:47 -05:00
|
|
|
void SetTimeWindow(unsigned short ticks) {timeWindow = ticks; leftOverTime = ticks;}
|
2023-12-11 18:55:12 -05:00
|
|
|
unsigned short GetTimeWindow() const{return timeWindow;}
|
|
|
|
|
2024-01-11 17:32:58 -05:00
|
|
|
void SetTimeJump(unsigned long long TimeJumpInNanoSec) {timeJump = TimeJumpInNanoSec;}
|
|
|
|
unsigned long long GetTimeJump() const {return timeJump;}
|
|
|
|
|
2023-12-11 18:55:12 -05:00
|
|
|
void SetLeftOverTime(unsigned long long ticks) {leftOverTime = ticks;}
|
|
|
|
unsigned long long GetLeftOverTime() const{return leftOverTime;}
|
|
|
|
|
|
|
|
void SetBreakTime(unsigned long long ticks) {breakTime = ticks;}
|
|
|
|
unsigned long long GetBreakTime() const{return breakTime;}
|
2023-06-14 15:20:15 -04:00
|
|
|
|
2023-06-15 11:48:18 -04:00
|
|
|
unsigned int GetNumOfDigitizer() const {return nData;}
|
|
|
|
std::vector<int> GetDigiIDList() const {return idList;}
|
|
|
|
|
2023-06-14 15:20:15 -04:00
|
|
|
void BuildEvents(bool isFinal = false, bool skipTrace = false, bool verbose = false);
|
2023-06-20 11:57:39 -04:00
|
|
|
void BuildEventsBackWard(int maxNumEvent = 100, bool verbose = false); // always skip trace, for faster online building
|
2023-06-14 15:20:15 -04:00
|
|
|
|
|
|
|
void ClearEvents();
|
2023-06-19 12:48:17 -04:00
|
|
|
void PrintStat();
|
2023-11-21 18:03:10 -05:00
|
|
|
void PrintAllEvent();
|
2023-06-14 15:20:15 -04:00
|
|
|
|
|
|
|
long eventIndex;
|
|
|
|
long eventBuilt; // reset once call BuildEvents()
|
|
|
|
long totalEventBuilt;
|
2023-06-23 13:50:21 -04:00
|
|
|
std::vector<Hit> events[MaxNEvent];
|
2023-06-14 15:20:15 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<int> typeList;
|
2023-06-15 11:48:18 -04:00
|
|
|
std::vector<int> snList;
|
|
|
|
std::vector<int> idList;
|
2024-01-11 11:52:40 -05:00
|
|
|
std::vector<int> tick2ns;
|
2023-06-14 15:20:15 -04:00
|
|
|
const unsigned short nData;
|
|
|
|
Data ** data; // assume all data has MaxNChannel (16)
|
|
|
|
|
2024-01-18 23:09:50 -05:00
|
|
|
std::vector<uShort> dataSize;
|
|
|
|
|
2023-06-14 15:20:15 -04:00
|
|
|
unsigned short timeWindow;
|
2023-12-11 18:55:12 -05:00
|
|
|
unsigned long long leftOverTime;
|
|
|
|
unsigned long long breakTime; // timestamp for breaking the event builder
|
2024-01-11 17:32:58 -05:00
|
|
|
|
|
|
|
unsigned long long timeJump; //time diff for a time jump, default is 1e8 ns
|
|
|
|
unsigned long long lastEventTime; // timestamp for detect time jump
|
|
|
|
|
2023-11-21 17:17:31 -05:00
|
|
|
int loopIndex[MaxNDigitizer][MaxNChannels];
|
|
|
|
int nextIndex[MaxNDigitizer][MaxNChannels];
|
2023-06-14 15:20:15 -04:00
|
|
|
|
|
|
|
int nExhaushedCh;
|
2023-11-21 17:17:31 -05:00
|
|
|
bool chExhaused[MaxNDigitizer][MaxNChannels];
|
2023-06-15 11:48:18 -04:00
|
|
|
|
2023-12-12 15:35:47 -05:00
|
|
|
void FindEarlistTimeAndCh(bool verbose = false); // search through the nextIndex
|
2023-06-14 15:20:15 -04:00
|
|
|
unsigned long long earlistTime;
|
|
|
|
int earlistDigi;
|
|
|
|
int earlistCh;
|
2023-12-12 15:35:47 -05:00
|
|
|
void FindLatestTimeAndCh(bool verbose = false); // search through the nextIndex
|
2023-06-15 11:48:18 -04:00
|
|
|
unsigned long long latestTime;
|
|
|
|
int latestDigi;
|
|
|
|
int latestCh;
|
|
|
|
|
2023-12-12 15:35:47 -05:00
|
|
|
void FindEarlistTimeAmongLastData(bool verbose = false);
|
2023-06-15 11:48:18 -04:00
|
|
|
void FindLatestTimeOfData(bool verbose = false);
|
|
|
|
|
2023-11-21 17:17:31 -05:00
|
|
|
int lastBackWardIndex[MaxNDigitizer][MaxNChannels];
|
2023-06-14 15:20:15 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|