fix bugs in MultiBuilder.cpp, some bugs in ClassDigitizer for DT5730

This commit is contained in:
Ryan Tang 2024-03-13 17:07:34 -04:00
parent 4276f7a149
commit 2199f4efd6
7 changed files with 100 additions and 24 deletions

View File

@ -29,7 +29,7 @@ int main(int argc, char **argv) {
if (argc < 6) {
printf("Incorrect number of arguments:\n");
printf("%s [timeWindow] [withTrace] [verbose] [batchSize] [inFile1] [inFile2] .... \n", argv[0]);
printf(" timeWindow : in ns \n");
printf(" timeWindow : in ns, -1 = no event building \n");
printf(" withTrace : 0 for no trace, 1 for trace \n");
printf(" verbose : > 0 for debug \n");
printf(" batchSize : the size of hit in a batch \n");

View File

@ -38,7 +38,7 @@ This defines the EventBuilder. The arguments are
```sh
./EventBuilder [timeWindow] [withTrace] [verbose] [batchSize] [inFile1] [inFile2] ....
timeWindow : in ns
timeWindow : in ns, -1 = no event building
withTrace : 0 for no trace, 1 for trace
verbose : > 0 for debug
batchSize : the size of hit in a batch
@ -49,9 +49,73 @@ as an example,
```sh
/EventBuilder 0 0 0 1000000 '\ls -1 test_001*.fsu'
```
setting the timeWindow to be -1, will split out a timesorted Hit.
## Important output message
Sometimes, you may encounter following output in red color
```sh
!!!!!!!!!!!!!!!!! ReadBatch | Need to increase the batch size.
```
That means the fsuReder need larger batchSize.
```sh
event 786 has size = 2350 > MAX_MULTI = 2000
```
This indicate the event 786 has event size 2350, which is larger than MAX_MULTI of 2000. depends on your experimental setup. If you think multiplicity more than 2000 makes sense, you can edit the MAX_MULTI in the EventBuilder.cpp.
## output
Evenbuilder output is standard information, an example structure is
```sh
******************************************************************************
*Tree :tree : test_001_379_-1.root *
*Entries : 2017231 : Total = 121385718 bytes File Size = 47528456 *
* : : Tree compression factor = 2.55 *
******************************************************************************
*Br 0 :evID : event_ID/l *
*Entries : 2017231 : Total Size= 16167926 bytes File Size = 4222686 *
*Baskets : 327 : Basket Size= 3835392 bytes Compression= 3.83 *
*............................................................................*
*Br 1 :multi : multi/i *
*Entries : 2017231 : Total Size= 8084409 bytes File Size = 56959 *
*Baskets : 165 : Basket Size= 1917952 bytes Compression= 141.87 *
*............................................................................*
*Br 2 :sn : sn[multi]/s *
*Entries : 2017231 : Total Size= 12143148 bytes File Size = 4648638 *
*Baskets : 406 : Basket Size= 25600000 bytes Compression= 2.61 *
*............................................................................*
*Br 3 :ch : ch[multi]/s *
*Entries : 2017231 : Total Size= 12143148 bytes File Size = 4719909 *
*Baskets : 406 : Basket Size= 25600000 bytes Compression= 2.57 *
*............................................................................*
*Br 4 :e : e[multi]/s *
*Entries : 2017231 : Total Size= 12142738 bytes File Size = 7040714 *
*Baskets : 406 : Basket Size= 25600000 bytes Compression= 1.72 *
*............................................................................*
*Br 5 :e2 : e2[multi]/s *
*Entries : 2017231 : Total Size= 12143148 bytes File Size = 4649857 *
*Baskets : 406 : Basket Size= 25600000 bytes Compression= 2.61 *
*............................................................................*
*Br 6 :e_t : e_timestamp[multi]/l *
*Entries : 2017231 : Total Size= 24270794 bytes File Size = 12883867 *
*Baskets : 649 : Basket Size= 25600000 bytes Compression= 1.88 *
*............................................................................*
*Br 7 :e_f : e_fineTime[multi]/s *
*Entries : 2017231 : Total Size= 12143579 bytes File Size = 4636856 *
*Baskets : 406 : Basket Size= 25600000 bytes Compression= 2.62 *
*............................................................................*
*Br 8 :traceLength : traceLength[multi]/s *
*Entries : 2017231 : Total Size= 12146944 bytes File Size = 4640404 *
*Baskets : 407 : Basket Size= 25600000 bytes Compression= 2.62 *
*............................................................................*
```
# SettingsExplorer.cpp
This defines the Setting explorer, the explorer takes the setting *bin file as argument.

View File

@ -308,7 +308,7 @@ int Digitizer::ProgramBoard_PHA(){
ret |= CAEN_DGTZ_SetIOLevel(handle, CAEN_DGTZ_IOLevel_NIM);
ret |= CAEN_DGTZ_SetExtTriggerInputMode(handle, CAEN_DGTZ_TRGMODE_ACQ_ONLY);
ret = CAEN_DGTZ_SetChannelEnableMask(handle, 0xFFFF);
ret = CAEN_DGTZ_SetChannelEnableMask(handle, ModelType == ModelTypeCode::VME ? 0xFFFF : 0x00FF);
//ret = CAEN_DGTZ_SetNumEventsPerAggregate(handle, 0);

View File

@ -93,24 +93,21 @@ void MultiBuilder::FindEarlistTimeAndCh(bool verbose){
earlistTime = -1;
earlistDigi = -1;
earlistCh = -1;
nExhaushedCh = 0;
for( int i = 0; i < nData; i++){
for( int j = 0; j < data[i]->GetNChannel(); j++ ){
chExhaused[i][j] = false;
}
for( int j = 0; j < data[i]->GetNChannel(); j++ ) chExhaused[i][j] = false;
for(unsigned int ch = 0; ch < MaxNChannels; ch ++){
if( ch >= data[i]->GetNChannel() ) {
for(unsigned int ch = 0; ch < data[i]->GetNChannel(); ch ++){
int index = data[i]->GetDataIndex(ch);
if( ch >= data[i]->GetNChannel() || index < 0 ) {
nExhaushedCh ++;
chExhaused[i][ch] = true;
continue;
}
if( data[i]->GetTimestamp(ch, data[i]->GetDataIndex(ch)) == 0 ||
data[i]->GetDataIndex(ch) == -1 ||
if( data[i]->GetTimestamp(ch, index) == 0 ||
loopIndex[i][ch] * dataSize[i] > data[i]->GetLoopIndex(ch) * dataSize[i] + data[i]->GetDataIndex(ch)) {
nExhaushedCh ++;
chExhaused[i][ch] = true;
@ -142,16 +139,13 @@ void MultiBuilder::FindLatestTimeAndCh(bool verbose){
for( int i = 0; i < nData; i++){
for( int j = 0; j < data[i]->GetNChannel(); j++ ){
chExhaused[i][j] = false;
}
for( int j = 0; j < data[i]->GetNChannel(); j++ ) chExhaused[i][j] = false;
for(unsigned int ch = 0; ch < MaxNChannels; ch ++){
// printf(" %d, %d | %d", i, ch, nextIndex[i][ch]);
if( nextIndex[i][ch] < 0 || ch >= data[i]->GetNChannel()) {
if( nextIndex[i][ch] < 0 || ch >= data[i]->GetNChannel() || data[i]->GetDataIndex(ch) < 0 ) {
nExhaushedCh ++;
chExhaused[i][ch] = true;
// printf(", exhanshed. %d \n", nExhaushedCh);
continue;
}
@ -194,8 +188,10 @@ void MultiBuilder::FindLatestTimeOfData(bool verbose){
latestCh = -1;
latestDigi = -1;
for( int i = 0; i < nData; i++){
// printf("%s | digi-%d-th | %d\n", __func__, i, data[i]->GetNChannel());
for( unsigned ch = 0; ch < data[i]->GetNChannel(); ch++ ){
int index = data[i]->GetDataIndex(ch);
// printf("ch-%2d | index : %d \n", ch, index);
if( index == -1 ) continue;
if( data[i]->GetTimestamp(ch, index) > latestTime ) {
latestTime = data[i]->GetTimestamp(ch, index);

View File

@ -25,6 +25,7 @@ Analyzer::Analyzer(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent )
snList.push_back(digi[k]->GetSerialNumber());
}
isBuildBackward = false;
mb = new MultiBuilder(dataList, typeList, snList);
buildTimerThread = new TimingThread(this);
@ -47,6 +48,18 @@ Analyzer::~Analyzer(){
delete [] dataList;
}
double Analyzer::RandomGauss(double mean, double sigma){
// Box-Muller transform to generate normally distributed random numbers
double u1 = QRandomGenerator::global()->generateDouble();
double u2 = QRandomGenerator::global()->generateDouble();
double z0 = sqrt(-2.0 * log(u1)) * cos(2 * M_PI * u2);
// Apply mean and standard deviation
return mean + z0 * sigma;
}
void Analyzer::RedefineEventBuilder(std::vector<int> idList){
delete mb;
delete [] dataList;
@ -78,7 +91,7 @@ void Analyzer::StopThread(){
void Analyzer::BuildEvents(bool verbose){
unsigned int nData = mb->GetNumOfDigitizer();
std::vector<int> idList = mb->GetDigiIDList();
for( unsigned int i = 0; i < nData; i++ ) digiMTX[idList[i]].lock();

View File

@ -48,6 +48,8 @@ public:
void RedefineEventBuilder(std::vector<int> idList);
void SetBackwardBuild(bool TF, int maxNumEvent = 100) { isBuildBackward = TF; maxNumEventBuilt = maxNumEvent;}
double RandomGauss(double mean, double sigma);
public slots:
void StartThread();
void StopThread();

View File

@ -21,7 +21,7 @@ public:
RedefineEventBuilder({0}); // only builder for the 0-th digitizer.
tick2ns = digi[0]->GetTick2ns();
//SetBackwardBuild(false, 100); // using normal building (acceding in time) or backward building, int the case of backward building, default events to be build is 100.
SetBackwardBuild(false, 100); // using normal building (acceding in time) or backward building, int the case of backward building, default events to be build is 100.
evtbder = GetEventBuilder();
evtbder->SetTimeWindow(500);
@ -58,7 +58,7 @@ inline void RAISOR::SetUpCanvas(){
setGeometry(0, 0, 500, 500);
//============ histograms
hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 5000, this);
hPID = new Histogram2D("RAISOR", "E", "dE", 100, 0, 5000, 100, 0, 20000, this);
layout->addWidget(hPID, 0, 0);
}
@ -67,7 +67,7 @@ inline void RAISOR::UpdateHistograms(){
if( this->isVisible() == false ) return;
BuildEvents(); // call the event builder to build events
BuildEvents(false); // call the event builder to build events
//============ Get events, and do analysis
long eventBuilt = evtbder->eventBuilt;
@ -97,7 +97,8 @@ inline void RAISOR::UpdateHistograms(){
}
hPID->Fill(E, dE); // x, y
// printf("(E, dE) = (%f, %f)\n", E, dE);
hPID->Fill(E + RandomGauss(0, 100), dE+ RandomGauss(0, 100)); // x, y
//check events inside any Graphical cut and extract the rate
for(int p = 0; p < cutList.count(); p++ ){