add SetDataBase in Analysis, so all analyzsis class can use
This commit is contained in:
parent
ef8dca5430
commit
dbfb9f96bf
73
.vscode/settings.json
vendored
73
.vscode/settings.json
vendored
|
@ -84,6 +84,77 @@
|
|||
"files.associations": {
|
||||
"*.C": "cpp",
|
||||
"*.pro": "makefile",
|
||||
"regex": "cpp"
|
||||
"regex": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"bitset": "cpp",
|
||||
"charconv": "cpp",
|
||||
"chrono": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"string": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"source_location": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"format": "cpp",
|
||||
"fstream": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"ostream": "cpp",
|
||||
"semaphore": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"span": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"variant": "cpp"
|
||||
}
|
||||
}
|
|
@ -13,7 +13,9 @@ Analyzer::Analyzer(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent )
|
|||
setGeometry(0, 0, 1000, 800);
|
||||
|
||||
influx = nullptr;
|
||||
dataBaseIP = "";
|
||||
dataBaseName = "";
|
||||
dataBaseToken = "";
|
||||
|
||||
dataList = new Data*[nDigi];
|
||||
typeList.clear();
|
||||
|
@ -70,6 +72,61 @@ double Analyzer::RandomGauss(double mean, double sigma){
|
|||
|
||||
}
|
||||
|
||||
void Analyzer::SetDatabase(QString IP, QString Name, QString Token){
|
||||
dataBaseIP = IP;
|
||||
dataBaseName = Name;
|
||||
dataBaseToken = Token;
|
||||
|
||||
if( influx ) {
|
||||
delete influx;
|
||||
influx = nullptr;
|
||||
}
|
||||
|
||||
influx = new InfluxDB(dataBaseIP.toStdString());
|
||||
|
||||
if( influx->TestingConnection() ){
|
||||
printf("InfluxDB URL (%s) is Valid. Version : %s\n", dataBaseIP.toStdString().c_str(), influx->GetVersionString().c_str());
|
||||
|
||||
if( influx->GetVersionNo() > 1 && dataBaseToken.isEmpty() ) {
|
||||
printf("A Token is required for accessing the database.\n");
|
||||
delete influx;
|
||||
influx = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
influx->SetToken(dataBaseToken.toStdString());
|
||||
|
||||
//==== chck database exist
|
||||
influx->CheckDatabases();
|
||||
std::vector<std::string> databaseList = influx->GetDatabaseList();
|
||||
bool foundDatabase = false;
|
||||
for( int i = 0; i < (int) databaseList.size(); i++){
|
||||
if( databaseList[i] == dataBaseName.toStdString() ) foundDatabase = true;
|
||||
}
|
||||
if( foundDatabase ){
|
||||
influx->AddDataPoint("test value=1");
|
||||
influx->WriteData(dataBaseName.toStdString());
|
||||
influx->ClearDataPointsBuffer();
|
||||
if( influx->IsWriteOK() ){
|
||||
printf("test write database OK.\n");
|
||||
}else{
|
||||
printf("################# test write database FAIL.\n");
|
||||
delete influx;
|
||||
influx = nullptr;
|
||||
}
|
||||
}else{
|
||||
printf("Database name : %s NOT found.\n", dataBaseName.toStdString().c_str());
|
||||
delete influx;
|
||||
influx = nullptr;
|
||||
}
|
||||
}else{
|
||||
printf("InfluxDB URL (%s) is NOT Valid. \n", dataBaseIP.toStdString().c_str());
|
||||
delete influx;
|
||||
influx = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Analyzer::RedefineEventBuilder(std::vector<int> idList){
|
||||
delete mb;
|
||||
delete [] dataList;
|
||||
|
@ -98,8 +155,6 @@ void Analyzer::StopThread(){
|
|||
buildTimerThread->wait();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Analyzer::BuildEvents(bool verbose){
|
||||
|
||||
unsigned int nData = mb->GetNumOfDigitizer();
|
||||
|
@ -114,6 +169,58 @@ void Analyzer::BuildEvents(bool verbose){
|
|||
|
||||
}
|
||||
|
||||
void Analyzer::SetDatabaseButton(){
|
||||
|
||||
QDialog dialog;
|
||||
dialog.setWindowTitle("Influx Database");
|
||||
|
||||
QGridLayout layout(&dialog);
|
||||
|
||||
//------------------------------
|
||||
QLabel ipLabel("Database IP : ");
|
||||
layout.addWidget(&ipLabel, 0, 0);
|
||||
|
||||
QLineEdit ipLineEdit;
|
||||
ipLineEdit.setFixedSize(1000, 20);
|
||||
ipLineEdit.setText(dataBaseIP);
|
||||
layout.addWidget(&ipLineEdit, 0, 1);
|
||||
|
||||
//------------------------------
|
||||
QLabel nameLabel("Database Name : ");
|
||||
layout.addWidget(&nameLabel, 1, 0);
|
||||
|
||||
QLineEdit nameLineEdit;
|
||||
nameLineEdit.setFixedSize(1000, 20);
|
||||
nameLineEdit.setText(dataBaseName);
|
||||
layout.addWidget(&nameLineEdit, 1, 1);
|
||||
|
||||
//------------------------------
|
||||
QLabel tokenLabel("Database Token : ");
|
||||
layout.addWidget(&tokenLabel, 2, 0);
|
||||
|
||||
QLineEdit tokenLineEdit;
|
||||
tokenLineEdit.setFixedSize(1000, 20);
|
||||
tokenLineEdit.setText(dataBaseToken);
|
||||
layout.addWidget(&tokenLineEdit, 2, 1);
|
||||
|
||||
layout.addWidget(new QLabel("Only for version 2+, version 1+ can be skipped."), 3, 0, 1, 2);
|
||||
|
||||
// Buttons for OK and Cancel
|
||||
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
layout.addWidget(&buttonBox);
|
||||
|
||||
QObject::connect(&buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
||||
QObject::connect(&buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
||||
|
||||
dialog.resize(400, dialog.sizeHint().height()); // Set the width to 400 pixels
|
||||
|
||||
// Show the dialog and get the result
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
SetDatabase(ipLineEdit.text(), nameLineEdit.text(),tokenLineEdit.text());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//^####################################### below are open to customization
|
||||
|
||||
void Analyzer::SetUpCanvas(){
|
||||
|
|
|
@ -47,30 +47,33 @@ public:
|
|||
Analyzer(Digitizer ** digi, unsigned int nDigi, QMainWindow * parent = nullptr);
|
||||
virtual ~Analyzer();
|
||||
|
||||
virtual void SetUpCanvas();
|
||||
|
||||
MultiBuilder * GetEventBuilder() { return mb;}
|
||||
|
||||
void RedefineEventBuilder(std::vector<int> idList);
|
||||
void SetBackwardBuild(bool TF, int maxNumEvent = 100) { isBuildBackward = TF; maxNumEventBuilt = maxNumEvent;}
|
||||
void SetDatabase(QString IP, QString Name, QString Token);
|
||||
|
||||
double RandomGauss(double mean, double sigma);
|
||||
|
||||
public slots:
|
||||
void StartThread();
|
||||
void StopThread();
|
||||
void SetDatabaseButton();
|
||||
|
||||
virtual void SetUpCanvas();
|
||||
virtual void UpdateHistograms(); // where event-building, analysis, and ploting
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
protected:
|
||||
QGridLayout * layout;
|
||||
void BuildEvents(bool verbose = false);
|
||||
void SetUpdateTimeInSec(double sec = 1.0) {waitTimeinSec = sec; buildTimerThread->SetWaitTimeinSec(waitTimeinSec);}
|
||||
|
||||
InfluxDB * influx;
|
||||
std::string dataBaseName;
|
||||
QString dataBaseIP;
|
||||
QString dataBaseName;
|
||||
QString dataBaseToken;
|
||||
|
||||
private:
|
||||
Digitizer ** digi;
|
||||
|
|
|
@ -21,10 +21,6 @@ public:
|
|||
|
||||
evtbder = GetEventBuilder();
|
||||
evtbder->SetTimeWindow(500);
|
||||
|
||||
//========== use the influx from the Analyzer
|
||||
// influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/");
|
||||
dataBaseName = "testing";
|
||||
|
||||
allowSignalSlot = false;
|
||||
SetUpCanvas();
|
||||
|
@ -73,8 +69,8 @@ private:
|
|||
RComboBox * aCh;
|
||||
|
||||
QString rawDataPath;
|
||||
void SaveHistRange();
|
||||
void LoadHistRange();
|
||||
void SaveSettings();
|
||||
void LoadSettings();
|
||||
|
||||
};
|
||||
|
||||
|
@ -91,18 +87,20 @@ inline void CoincidentAnalyzer::SetUpCanvas(){
|
|||
boxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
||||
box->setLayout(boxLayout);
|
||||
|
||||
int rowID = 0;
|
||||
|
||||
{
|
||||
chkRunAnalyzer = new QCheckBox("Run Analyzer", this);
|
||||
boxLayout->addWidget(chkRunAnalyzer, 0, 0);
|
||||
boxLayout->addWidget(chkRunAnalyzer, rowID, 0);
|
||||
|
||||
QLabel * lbUpdateTime = new QLabel("Update Period [s]", this);
|
||||
lbUpdateTime->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbUpdateTime, 0, 1);
|
||||
boxLayout->addWidget(lbUpdateTime, rowID, 1);
|
||||
sbUpdateTime = new RSpinBox(this, 1);
|
||||
sbUpdateTime->setMinimum(0.1);
|
||||
sbUpdateTime->setMaximum(5);
|
||||
sbUpdateTime->setValue(1);
|
||||
boxLayout->addWidget(sbUpdateTime, 0, 2);
|
||||
boxLayout->addWidget(sbUpdateTime, rowID, 2);
|
||||
|
||||
connect(sbUpdateTime, &RSpinBox::valueChanged, this, [=](){ sbUpdateTime->setStyleSheet("color : blue"); });
|
||||
|
||||
|
@ -111,17 +109,36 @@ inline void CoincidentAnalyzer::SetUpCanvas(){
|
|||
SetUpdateTimeInSec(sbUpdateTime->value());
|
||||
});
|
||||
|
||||
QLabel * lbBuildWindow = new QLabel("Event Window [ns]", this);
|
||||
lbBuildWindow->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbBuildWindow, rowID, 3);
|
||||
sbBuildWindow = new RSpinBox(this, 0);
|
||||
sbBuildWindow->setMinimum(1);
|
||||
sbBuildWindow->setMaximum(9999999999);
|
||||
sbBuildWindow->setValue(1000);
|
||||
boxLayout->addWidget(sbBuildWindow, rowID, 4);
|
||||
|
||||
connect(sbBuildWindow, &RSpinBox::valueChanged, this, [=](){
|
||||
sbBuildWindow->setStyleSheet("color : blue;");
|
||||
});
|
||||
|
||||
connect(sbBuildWindow, &RSpinBox::returnPressed, this, [=](){
|
||||
sbBuildWindow->setStyleSheet("");
|
||||
evtbder->SetTimeWindow((int)sbBuildWindow->value());
|
||||
});
|
||||
|
||||
rowID ++;
|
||||
chkBackWardBuilding = new QCheckBox("Use Backward builder", this);
|
||||
boxLayout->addWidget(chkBackWardBuilding, 1, 0);
|
||||
boxLayout->addWidget(chkBackWardBuilding, rowID, 0);
|
||||
|
||||
QLabel * lbBKWindow = new QLabel("Max No. Backward Event", this);
|
||||
lbBKWindow->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbBKWindow, 1, 1);
|
||||
boxLayout->addWidget(lbBKWindow, rowID, 1);
|
||||
sbBackwardCount = new RSpinBox(this, 0);
|
||||
sbBackwardCount->setMinimum(1);
|
||||
sbBackwardCount->setMaximum(9999);
|
||||
sbBackwardCount->setValue(100);
|
||||
boxLayout->addWidget(sbBackwardCount, 1, 2);
|
||||
boxLayout->addWidget(sbBackwardCount, rowID, 2);
|
||||
|
||||
chkBackWardBuilding->setChecked(false);
|
||||
sbBackwardCount->setEnabled(false);
|
||||
|
@ -141,62 +158,48 @@ inline void CoincidentAnalyzer::SetUpCanvas(){
|
|||
SetBackwardBuild(true, sbBackwardCount->value());
|
||||
});
|
||||
|
||||
QLabel * lbBuildWindow = new QLabel("Event Window [ns]", this);
|
||||
lbBuildWindow->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbBuildWindow, 2, 1);
|
||||
sbBuildWindow = new RSpinBox(this, 0);
|
||||
sbBuildWindow->setMinimum(1);
|
||||
sbBuildWindow->setMaximum(9999999999);
|
||||
sbBuildWindow->setValue(1000);
|
||||
boxLayout->addWidget(sbBuildWindow, 2, 2);
|
||||
|
||||
connect(sbBuildWindow, &RSpinBox::valueChanged, this, [=](){
|
||||
sbBuildWindow->setStyleSheet("color : blue;");
|
||||
});
|
||||
|
||||
connect(sbBuildWindow, &RSpinBox::returnPressed, this, [=](){
|
||||
sbBuildWindow->setStyleSheet("");
|
||||
evtbder->SetTimeWindow((int)sbBuildWindow->value());
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
QFrame *separator = new QFrame(box);
|
||||
separator->setFrameShape(QFrame::HLine);
|
||||
separator->setFrameShadow(QFrame::Sunken);
|
||||
boxLayout->addWidget(separator, 3, 0, 1, 4);
|
||||
rowID ++;
|
||||
QFrame *separator0 = new QFrame(box);
|
||||
separator0->setFrameShape(QFrame::HLine);
|
||||
separator0->setFrameShadow(QFrame::Sunken);
|
||||
boxLayout->addWidget(separator0, rowID, 0, 1, 4);
|
||||
|
||||
rowID ++;
|
||||
QLabel * lbXDigi = new QLabel("X-Digi", this);
|
||||
lbXDigi->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbXDigi, 4, 0);
|
||||
boxLayout->addWidget(lbXDigi, rowID, 0);
|
||||
xDigi = new RComboBox(this);
|
||||
for(unsigned int i = 0; i < nDigi; i ++ ){
|
||||
xDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
|
||||
}
|
||||
boxLayout->addWidget(xDigi, 4, 1);
|
||||
boxLayout->addWidget(xDigi, rowID, 1);
|
||||
|
||||
QLabel * lbXCh = new QLabel("X-Ch", this);
|
||||
lbXCh->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbXCh, 4, 2);
|
||||
boxLayout->addWidget(lbXCh, rowID, 2);
|
||||
xCh = new RComboBox(this);
|
||||
for( int i = 0; i < digi[0]->GetNumInputCh(); i++) xCh->addItem("Ch-" + QString::number(i), i);
|
||||
boxLayout->addWidget(xCh, 4, 3);
|
||||
boxLayout->addWidget(xCh, rowID, 3);
|
||||
|
||||
rowID ++;
|
||||
QLabel * lbYDigi = new QLabel("Y-Digi", this);
|
||||
lbYDigi->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbYDigi, 5, 0);
|
||||
boxLayout->addWidget(lbYDigi, rowID, 0);
|
||||
yDigi = new RComboBox(this);
|
||||
for(unsigned int i = 0; i < nDigi; i ++ ){
|
||||
yDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
|
||||
}
|
||||
boxLayout->addWidget(yDigi, 5, 1);
|
||||
boxLayout->addWidget(yDigi, rowID, 1);
|
||||
|
||||
QLabel * lbYCh = new QLabel("Y-Ch", this);
|
||||
lbYCh->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbYCh, 5, 2);
|
||||
boxLayout->addWidget(lbYCh, rowID, 2);
|
||||
yCh = new RComboBox(this);
|
||||
for( int i = 0; i < digi[0]->GetNumInputCh(); i++) yCh->addItem("Ch-" + QString::number(i), i);
|
||||
boxLayout->addWidget(yCh, 5, 3);
|
||||
boxLayout->addWidget(yCh, rowID, 3);
|
||||
|
||||
connect(xDigi, &RComboBox::currentIndexChanged, this, [=](){
|
||||
allowSignalSlot = false;
|
||||
|
@ -243,26 +246,28 @@ inline void CoincidentAnalyzer::SetUpCanvas(){
|
|||
}
|
||||
|
||||
{
|
||||
rowID ++;
|
||||
QFrame *separator1 = new QFrame(box);
|
||||
separator1->setFrameShape(QFrame::HLine);
|
||||
separator1->setFrameShadow(QFrame::Sunken);
|
||||
boxLayout->addWidget(separator1, 6, 0, 1, 4);
|
||||
boxLayout->addWidget(separator1, rowID, 0, 1, 4);
|
||||
|
||||
rowID ++;
|
||||
QLabel * lbaDigi = new QLabel("ID-Digi", this);
|
||||
lbaDigi->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbaDigi, 7, 0);
|
||||
boxLayout->addWidget(lbaDigi, rowID, 0);
|
||||
aDigi = new RComboBox(this);
|
||||
for(unsigned int i = 0; i < nDigi; i ++ ){
|
||||
aDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
|
||||
}
|
||||
boxLayout->addWidget(aDigi, 7, 1);
|
||||
boxLayout->addWidget(aDigi, rowID, 1);
|
||||
|
||||
QLabel * lbaCh = new QLabel("1D-Ch", this);
|
||||
lbaCh->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbaCh, 7, 2);
|
||||
boxLayout->addWidget(lbaCh, rowID, 2);
|
||||
aCh = new RComboBox(this);
|
||||
for( int i = 0; i < digi[0]->GetNumInputCh(); i++) aCh->addItem("Ch-" + QString::number(i), i);
|
||||
boxLayout->addWidget(aCh, 7, 3);
|
||||
boxLayout->addWidget(aCh, rowID, 3);
|
||||
|
||||
connect(aDigi, &RComboBox::currentIndexChanged, this, [=](){
|
||||
allowSignalSlot = false;
|
||||
|
@ -292,13 +297,41 @@ inline void CoincidentAnalyzer::SetUpCanvas(){
|
|||
}
|
||||
|
||||
{
|
||||
QFrame *separator1 = new QFrame(box);
|
||||
separator1->setFrameShape(QFrame::HLine);
|
||||
separator1->setFrameShadow(QFrame::Sunken);
|
||||
boxLayout->addWidget(separator1, 8, 0, 1, 4);
|
||||
rowID ++;
|
||||
QFrame *separator2 = new QFrame(box);
|
||||
separator2->setFrameShape(QFrame::HLine);
|
||||
separator2->setFrameShadow(QFrame::Sunken);
|
||||
boxLayout->addWidget(separator2, rowID, 0, 1, 4);
|
||||
|
||||
rowID ++;
|
||||
QLabel * lbIP = new QLabel("Database IP :", box);
|
||||
lbIP->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbIP, rowID, 0);
|
||||
QLineEdit * leInfluxIP = new QLineEdit(box);
|
||||
leInfluxIP->setReadOnly(true);
|
||||
boxLayout->addWidget(leInfluxIP, rowID, 1, 1, 3);
|
||||
|
||||
QPushButton * bnInflux = new QPushButton("Set Influx", box);
|
||||
boxLayout->addWidget(bnInflux, rowID, 1, 1, 3);
|
||||
|
||||
rowID ++;
|
||||
QLabel * lbDBName = new QLabel("Database name :", box);
|
||||
lbDBName->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||
boxLayout->addWidget(lbDBName, rowID, 0);
|
||||
QLineEdit * leDBName= new QLineEdit(box);
|
||||
leDBName->setReadOnly(true);
|
||||
boxLayout->addWidget(leDBName, rowID, 1);
|
||||
|
||||
connect(bnInflux, &QPushButton::clicked, this, &Analyzer::SetDatabaseButton);
|
||||
|
||||
// rowID ++;
|
||||
// QFrame *separator3 = new QFrame(box);
|
||||
// separator3->setFrameShape(QFrame::HLine);
|
||||
// separator3->setFrameShadow(QFrame::Sunken);
|
||||
// boxLayout->addWidget(separator3, rowID, 0, 1, 4);
|
||||
|
||||
QPushButton * bnClearHist = new QPushButton("Clear All Hist.", this);
|
||||
boxLayout->addWidget(bnClearHist, 9, 1);
|
||||
boxLayout->addWidget(bnClearHist, rowID, 2);
|
||||
|
||||
connect(bnClearHist, &QPushButton::clicked, this, [=](){
|
||||
h2D->Clear();
|
||||
|
@ -308,14 +341,14 @@ inline void CoincidentAnalyzer::SetUpCanvas(){
|
|||
});
|
||||
|
||||
QPushButton * bnSaveSettings = new QPushButton("Save Settings", this);
|
||||
boxLayout->addWidget(bnSaveSettings, 9, 2);
|
||||
boxLayout->addWidget(bnSaveSettings, rowID, 3);
|
||||
|
||||
connect(bnSaveSettings, &QPushButton::clicked, this, &CoincidentAnalyzer::SaveHistRange);
|
||||
connect(bnSaveSettings, &QPushButton::clicked, this, &CoincidentAnalyzer::SaveSettings);
|
||||
|
||||
QPushButton * bnLoadSettings = new QPushButton("Load Settings", this);
|
||||
boxLayout->addWidget(bnLoadSettings, 9, 3);
|
||||
boxLayout->addWidget(bnLoadSettings, rowID, 4);
|
||||
|
||||
connect(bnLoadSettings, &QPushButton::clicked, this, &CoincidentAnalyzer::LoadHistRange);
|
||||
connect(bnLoadSettings, &QPushButton::clicked, this, &CoincidentAnalyzer::LoadSettings);
|
||||
|
||||
}
|
||||
|
||||
|
@ -445,22 +478,24 @@ inline void CoincidentAnalyzer::UpdateHistograms(){
|
|||
hMulti->UpdatePlot();
|
||||
h1g->UpdatePlot();
|
||||
|
||||
// QList<QString> cutNameList = h2D->GetCutNameList();
|
||||
// for( int p = 0; p < cutList.count(); p ++){
|
||||
// if( cutList[p].isEmpty() ) continue;
|
||||
// double dT = (tMax[p]-tMin[p]) * tick2ns / 1e9; // tick to sec
|
||||
// double rate = count[p]*1.0/(dT);
|
||||
//printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
//printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
// influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
// influx->WriteData(dataBaseName);
|
||||
// influx->ClearDataPointsBuffer();
|
||||
// }
|
||||
if( influx ){
|
||||
QList<QString> cutNameList = h2D->GetCutNameList();
|
||||
for( int p = 0; p < cutList.count(); p ++){
|
||||
if( cutList[p].isEmpty() ) continue;
|
||||
double dT = (tMax[p]-tMin[p]) / 1e9;
|
||||
double rate = count[p]*1.0/(dT);
|
||||
printf("%llu %llu, %f %d\n", tMin[p], tMax[p], dT, count[p]);
|
||||
printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
}
|
||||
|
||||
influx->WriteData(dataBaseName.toStdString());
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
inline void CoincidentAnalyzer::SaveHistRange(){
|
||||
inline void CoincidentAnalyzer::SaveSettings(){
|
||||
QString filePath = QFileDialog::getSaveFileName(this,
|
||||
"Save Settings to File",
|
||||
QDir::toNativeSeparators(rawDataPath + "/CoinAnaSettings.txt" ),
|
||||
|
@ -498,6 +533,10 @@ inline void CoincidentAnalyzer::SaveHistRange(){
|
|||
lines << QString::number(chkBackWardBuilding->isChecked());
|
||||
lines << QString::number(sbBackwardCount->value());
|
||||
|
||||
lines<< dataBaseIP;
|
||||
lines<< dataBaseName;
|
||||
lines<< dataBaseToken;
|
||||
|
||||
lines << "#===== End of File";
|
||||
|
||||
// Write each line to the file
|
||||
|
@ -512,7 +551,7 @@ inline void CoincidentAnalyzer::SaveHistRange(){
|
|||
|
||||
}
|
||||
}
|
||||
inline void CoincidentAnalyzer::LoadHistRange(){
|
||||
inline void CoincidentAnalyzer::LoadSettings(){
|
||||
|
||||
QString filePath = QFileDialog::getOpenFileName(this,
|
||||
"Load Settings to File",
|
||||
|
@ -563,13 +602,17 @@ inline void CoincidentAnalyzer::LoadHistRange(){
|
|||
if( count == 16 ) isBkEvtBuild = line.toInt();
|
||||
if( count == 17 ) bkCount = line.toInt();
|
||||
|
||||
if( count == 18 ) dataBaseIP = line;
|
||||
if( count == 19 ) dataBaseName = line;
|
||||
if( count == 20 ) dataBaseToken = line;
|
||||
|
||||
count ++;
|
||||
}
|
||||
|
||||
file.close();
|
||||
qDebug() << "File read successfully from" << filePath;
|
||||
|
||||
if( count >= 18 ){
|
||||
if( count >= 21 ){
|
||||
|
||||
sbUpdateTime->setValue(updateTime);
|
||||
chkBackWardBuilding->setChecked(isBkEvtBuild);
|
||||
|
@ -594,6 +637,8 @@ inline void CoincidentAnalyzer::LoadHistRange(){
|
|||
h1g->Rebin(a_bin, a_min, a_max);
|
||||
h2D->Rebin(x_bin, x_min, x_max, y_bin, y_min, y_max);
|
||||
|
||||
SetDatabase(dataBaseIP, dataBaseName, dataBaseToken);
|
||||
|
||||
}
|
||||
|
||||
}else {
|
||||
|
|
|
@ -124,7 +124,7 @@ inline void RAISOR::UpdateHistograms(){
|
|||
//printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
influx->WriteData(dataBaseName);
|
||||
influx->WriteData(dataBaseName.toStdString());
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -438,7 +438,7 @@ inline void SplitPole::UpdateHistograms(){
|
|||
//printf("%10s | %d | %f Hz \n", cutNameList[p].toStdString().c_str(), count[p], rate);
|
||||
|
||||
influx->AddDataPoint("Cut,name=" + cutNameList[p].toStdString()+ " value=" + std::to_string(rate));
|
||||
influx->WriteData(dataBaseName);
|
||||
influx->WriteData(dataBaseName.toStdString());
|
||||
influx->ClearDataPointsBuffer();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user