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

View File

@ -62,13 +62,13 @@ private:
Digitizer2Gen ** digi; Digitizer2Gen ** digi;
unsigned short nDigi; unsigned short nDigi;
std::vector<std::vector<int>> mapping; std::vector<std::vector<int>> mapping;
QStringList detType; QStringList detTypeNameList;
std::vector<int> nDetinType; std::vector<int> nDetinType;
std::vector<int> detMaxID; std::vector<int> detMaxID;
QStringList detGroupName; QStringList detGroupNameList;
std::vector<int> detGroupID; std::vector<int> detGroupID;
std::vector<int> nDetinGroup; 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; QString digiSettingPath;