finished debug of Solaris panel after Mapping.h format changed

This commit is contained in:
Ryan Tang 2023-04-03 12:25:23 -04:00
parent 69955a863d
commit 7ba39bcc5a
2 changed files with 66 additions and 62 deletions

View File

@ -32,14 +32,14 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
qDebug() << "Please increase the MaxNumberOfChannel";
}
this->mapping = mapping;
this->detType = detType;
this->detTypeNameList = detType;
this->detMaxID = detMaxID;
this->detGroupID = detGroupID;
this->detGroupName = detGroupName;
this->detGroupNameList = detGroupName;
this->digiSettingPath = analysisPath + "/working/Settings/";
//Check number of detector type; Array 0-199, Recoil 200-299, other 300-
int nDetType = detType.size();
int nDetType = detTypeNameList.size();
for( int k = 0 ; k < nDetType; k++) nDetinType.push_back(0);
std::vector<int> condenGroupID = detGroupID;
@ -72,40 +72,40 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
//consolidate detIDListTemp --> 2D array of (detID, (Digi << 8) + ch, +.... )
//for example, {2, 0, 0}, {2, 100, 1}, {2, 200, 2}--> {2, 0, 0, 1, 2};
//for example, {2, 1, 3}, {2, 101, 4}, {2, 201, 5}--> {2, 0, 3, 4, 5};
detIDList.clear();
detIDArrayList.clear();
bool repeated = false;
for( int i = 0; i < detIDListTemp.size(); i++ ){
repeated = false;
if( detIDList.size() == 0 ){
detIDList << detIDListTemp[i];
if( detIDArrayList.size() == 0 ){
detIDArrayList << detIDListTemp[i];
continue;
}
for( int j = 0; j < detIDList.size() ; j++){
if( detIDList[j][0] == detIDListTemp[i][0] ) { // same group
for( int j = 0; j < detIDArrayList.size() ; j++){
if( detIDArrayList[j][0] == detIDListTemp[i][0] ) { // same group
int type1 = FindDetTypeID(detIDList[j][1]);
int type1 = FindDetTypeID(detIDArrayList[j][1]);
int type2 = FindDetTypeID(detIDListTemp[i][1]);
int low1 = (type1 == 0 ? 0 : detMaxID[type1-1]);
int low2 = (type2 == 0 ? 0 : detMaxID[type2-1]);
int detID1 = detIDList[j][1] - low1;
int detID1 = detIDArrayList[j][1] - low1;
int detID2 = detIDListTemp[i][1] - low2;
if( detID1 == detID2) {
repeated = true;
detIDList[j] << detIDListTemp[i][2];
detIDArrayList[j] << detIDListTemp[i][2];
break;
}
}
}
if( !repeated ) {
detIDList << detIDListTemp[i];
detIDArrayList << detIDListTemp[i];
}
}
//---- sort detIDList;
std::sort(detIDList.begin(), detIDList.end(), [](const QList<int>& a, const QList<int>& b) {
std::sort(detIDArrayList.begin(), detIDArrayList.end(), [](const QList<int>& a, const QList<int>& b) {
return a.at(1) < b.at(1);
});
@ -213,13 +213,13 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
connect(chkAll[detGroup][SettingID], &QCheckBox::stateChanged, this, [=](bool state){
bool found = false;
for(int i = 0; i < detIDList.size(); i++){
if( detIDList[i][0] != detGroup ) continue;
for(int i = 0; i < detIDArrayList.size(); i++){
if( detIDArrayList[i][0] != detGroup ) continue;
if( found == false ){
found = true;
continue;
}else{
groupBox[detGroup][SettingID][detIDList[i][1]]->setEnabled(!state);
groupBox[detGroup][SettingID][detIDArrayList[i][1]]->setEnabled(!state);
}
}
});
@ -230,9 +230,9 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
line->setFixedHeight(10);
layout->addWidget(line, 1, 0, 1, NCOL);
for(int i = 0; i < detIDList.size(); i++){
if( detIDList[i][0] != detGroup ) continue;
CreateDetGroup(SettingID, detIDList[i], layout, i/NCOL + 2, i%NCOL);
for(int i = 0; i < detIDArrayList.size(); i++){
if( detIDArrayList[i][0] != detGroup ) continue;
CreateDetGroup(SettingID, detIDArrayList[i], layout, i/NCOL + 2, i%NCOL);
}
}
@ -248,7 +248,7 @@ SOLARISpanel::~SOLARISpanel(){
//^######################################################################
int SOLARISpanel::FindDetTypeID(int detID){
for( int i = 0; i < (int) detType.size(); i++){
for( int i = 0; i < (int) detTypeNameList.size(); i++){
int lowID = (i == 0) ? 0 : detMaxID[i-1];
if( lowID <= detID && detID < detMaxID[i]) {
return i;
@ -290,7 +290,7 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detIDArray, QGridLay
int typeID = FindDetTypeID(mapping[digiID][chID]);
QLabel * lb = new QLabel(detType[typeID].remove(' '), this);
QLabel * lb = new QLabel(detTypeNameList[typeID].remove(' '), this);
layout0->addWidget(lb, 2*chIndex, 0, 2, 1);
chkOnOff[SettingID][digiID][chID] = new QCheckBox(this);
@ -337,17 +337,17 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detIDArray, QGridLay
}
if( chkAll[detGroup][SettingID]->isChecked() ){
for(int k = 0; k < detIDList.size() ; k++){
if( detGroup == detIDList[k][0] ){
for( int h = ChStartIndex; h < detIDList[k].size() ; h++){
for(int k = 0; k < detIDArrayList.size() ; k++){
if( detGroup == detIDArrayList[k][0] ){
for( int h = ChStartIndex; h < detIDArrayList[k].size() ; h++){
if( h != chIndex + ChStartIndex) continue;
int digiK = (detIDList[k][h] >> 8);
int digiK = (detIDArrayList[k][h] >> 8);
if( digiK >= nDigi ) continue;
int index = (detIDList[k][h] & 0xFF);
int index = (detIDArrayList[k][h] & 0xFF);
QString msg;
msg = QString::fromStdString(para.GetPara()) + "|DIG:"+ QString::number(digi[digiK]->GetSerialNumber());
msg += ",CH:" + QString::number(index) + "(" + detType[typeID] + ")";
msg += ",CH:" + QString::number(index) + "(" + detTypeNameList[typeID] + ")";
msg += " = " + QString::number(spb->value());
if( digi[digiK]->WriteValue(para, std::to_string(spb->value()), index)){
@ -363,7 +363,7 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detIDArray, QGridLay
}else{
QString msg;
msg = QString::fromStdString(para.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber());
msg += ",CH:" + QString::number(chID) + "(" + detType[typeID] + ")";
msg += ",CH:" + QString::number(chID) + "(" + detTypeNameList[typeID] + ")";
msg += " = " + QString::number(spb->value());
if( digi[digiID]->WriteValue(para, std::to_string(spb->value()), chID)){
SendLogMsg(msg + "|OK.");
@ -383,17 +383,17 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detIDArray, QGridLay
if( chkAll[detGroup][SettingID]->isChecked() ){
for(int k = 0; k < detIDList.size() ; k++){
if( detGroup == detIDList[k][0] ){
for(int k = 0; k < detIDArrayList.size() ; k++){
if( detGroup == detIDArrayList[k][0] ){
for( int h = ChStartIndex; h < detIDList[k].size() ; h++){
for( int h = ChStartIndex; h < detIDArrayList[k].size() ; h++){
if( h != chIndex + ChStartIndex) continue;
int digiK = (detIDList[k][h] >> 8);
int digiK = (detIDArrayList[k][h] >> 8);
if( digiK >= nDigi ) continue;
int index = (detIDList[k][h] & 0xFF);
int index = (detIDArrayList[k][h] & 0xFF);
QString msg;
msg = QString::fromStdString(PHA::CH::ChannelEnable.GetPara()) + "|DIG:"+ QString::number(digi[digiK]->GetSerialNumber());
msg += ",CH:" + QString::number(index) + "(" + detType[typeID] + ")";
msg += ",CH:" + QString::number(index) + "(" + detTypeNameList[typeID] + ")";
msg += ( state ? " = True" : " = False");
if( digi[digiK]->WriteValue(PHA::CH::ChannelEnable, state ? "True" : "False", index)){
@ -415,7 +415,7 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detIDArray, QGridLay
QString msg;
msg = QString::fromStdString(PHA::CH::ChannelEnable.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber());
msg += ",CH:" + QString::number(chID) + "(" + detType[typeID] + ")";
msg += ",CH:" + QString::number(chID) + "(" + detTypeNameList[typeID] + ")";
msg += ( state ? " = True" : " = False");
qDebug() << msg;
@ -470,14 +470,13 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detIDArray, QGridLay
if( chkAll[detGroup][SettingID]->isChecked() ){
//TODO if( detIDList[k][1] >= detMaxID[0] || 0 > detIDList[k][1]) continue; //! only for array
for( int gg = 0; gg < nDetinGroup[detGroup]; gg++){
//TODO -==== if( gg >= )
if( gg == detID ) continue;
cbTrigger[detGroup][gg]->setCurrentIndex(index);
for( int k = 0; k < detIDArrayList.size(); k++){
if( detIDArrayList[k][0] != detGroup ) continue;
int haha = detIDArrayList[k][1];
if( haha == detID )continue;
cbTrigger[detGroup][haha]->setCurrentIndex(index);
}
}
///----------- single
@ -586,24 +585,27 @@ void SOLARISpanel::UpdatePanelFromMemory(){
}
//@===================== Trigger
for( int k = 0; k < detIDList.size() ; k++){
if( detIDList[k][1] >= detMaxID[0] || 0 > detIDList[k][1]) continue; //! only for array
for( int k = 0; k < detIDArrayList.size() ; k++){
if( detIDArrayList[k][1] >= detMaxID[0] || 0 > detIDArrayList[k][1]) continue; //! only for array
if( detIDList[k][0] != 0 ) continue;
if( detIDArrayList[k][0] != 0 ) continue;
//if( detIDList[k].size() <= 2) continue;
bool skipFlag = false;
std::vector<unsigned long> triggerMap;
std::vector<std::string> coincidentMask;
std::vector<std::string> antiCoincidentMask;
std::vector<std::string> eventTriggerSource;
std::vector<std::string> waveTriggerSource;
for( int h = ChStartIndex; h < detIDList[k].size(); h++){
int chIndex = h - ChStartIndex;
int digiID = detIDList[k][chIndex] >> 8;
if( digiID >= nDigi) continue;
for( int h = ChStartIndex; h < detIDArrayList[k].size(); h++){
int digiID = detIDArrayList[k][h] >> 8;
if( digiID >= nDigi) {
skipFlag = true;
continue;
}
int chID = (detIDList[k][h] & 0xFF);
int chID = (detIDArrayList[k][h] & 0xFF);
triggerMap.push_back(Utility::TenBase(digi[digiID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, chID)));
coincidentMask.push_back(digi[digiID]->GetSettingValue(PHA::CH::CoincidenceMask, chID));
antiCoincidentMask.push_back(digi[digiID]->GetSettingValue(PHA::CH::AntiCoincidenceMask, chID));
@ -611,13 +613,12 @@ void SOLARISpanel::UpdatePanelFromMemory(){
waveTriggerSource.push_back(digi[digiID]->GetSettingValue(PHA::CH::WaveTriggerSource, chID));
}
if(skipFlag) continue;
//====== only acceptable condition is eventTriggerSource are all ChSelfTrigger
// and coincidentMask for e, xf, xn, are at least one for Ch64Trigger
// and waveTriggerSource are all ChSelfTrigger
int detTypeID = FindDetTypeID(detIDList[k][1]);
//====== a stupid way
// triggerSource : Other = 0x0, Disabled = 0x1, ChSelfTrigger = 0x2, TRGIN = 0x3
// CoinMask : Other = 0x0, Disbaled = 0x1, Ch64Trigger = 0x2, TRGIN = 0x3
@ -656,6 +657,8 @@ void SOLARISpanel::UpdatePanelFromMemory(){
stupidIndex.push_back(index);
}
//printf("===================== detIDList : %d %d \n", detIDList[k][0], detIDList[k][1]);
int jaja[5] = {0}; // this store the count for each comboxIndex;
for( int i = 0; i < (int) stupidIndex.size(); i++){
//printf(" %d | 0x%s \n", i, QString::number(stupidIndex[i], 16).toUpper().toStdString().c_str());
@ -677,24 +680,25 @@ void SOLARISpanel::UpdatePanelFromMemory(){
// if Trigger e, need to check the trigger mask;
if( comboxIndex == 3){
unsigned long ShouldBeMask = 1ULL << (detIDList[k][ChStartIndex] & 0xFF);
unsigned long ShouldBeMask = 1ULL << (detIDArrayList[k][ChStartIndex] & 0xFF);
for( int i = 1; i < (int) triggerMap.size(); i ++){
//printf(" %d | %lu =? %lu \n", i, triggerMap[i], ShouldBeMask);
if( triggerMap[i] != ShouldBeMask) comboxIndex = 4;
}
}
cbTrigger[detTypeID][detIDList[k][1]]->setCurrentIndex(comboxIndex);
int detGroup = FindDetGroup(detIDArrayList[k][1]);
cbTrigger[detGroup][detIDArrayList[k][1]]->setCurrentIndex(comboxIndex);
}
//@===================== Coin. time
std::vector<int> coinTime;
for( int i = 0; i < detIDList.size(); i++){
for( int j = ChStartIndex; j < detIDList[i].size(); j++){
int digiID = detIDList[i][j] >> 8;
int chID = (detIDList[i][j] & 0xFF);
for( int i = 0; i < detIDArrayList.size(); i++){
for( int j = ChStartIndex; j < detIDArrayList[i].size(); j++){
int digiID = detIDArrayList[i][j] >> 8;
int chID = (detIDArrayList[i][j] & 0xFF);
if( digiID >= nDigi ) continue;
if( digi[digiID]->IsDummy() || !digi[digiID]->IsConnected() ) continue;
coinTime.push_back( atoi(digi[digiID]->GetSettingValue(PHA::CH::CoincidenceLength, chID).c_str()));

View File

@ -62,13 +62,13 @@ private:
Digitizer2Gen ** digi;
unsigned short nDigi;
std::vector<std::vector<int>> mapping;
QStringList detType;
QStringList detTypeNameList;
std::vector<int> nDetinType;
std::vector<int> detMaxID;
QStringList detGroupName;
QStringList detGroupNameList;
std::vector<int> detGroupID;
std::vector<int> nDetinGroup;
QList<QList<int>> detIDList; // 1-D array of { detID, (Digi << 8 ) + ch}
QList<QList<int>> detIDArrayList; // 1-D array of { detID, (Digi << 8 ) + ch}
QString digiSettingPath;