added location selector on the Cross panel

This commit is contained in:
Ryan Tang 2024-09-30 18:19:56 -04:00
parent 188d65897a
commit 0ee20bce0f
2 changed files with 62 additions and 19 deletions

View File

@ -276,6 +276,7 @@ public:
UpdatePlot();
}
void SetLineTitle(QString title, int lineID = 0) { graph(lineID)->setName(title); }
void SetXTitle(QString xTitle) { xAxis->setLabel(xTitle);}
void Rebin(int xbin, double xmin, double xmax){

View File

@ -58,11 +58,14 @@ private:
int tick2ns;
float ch1, ch4, ch7;
int chDE, chE;
float energyDE, energyE, ch7;
unsigned long long t1, t4, t7;
QPushButton * bnClearHist;
QLabel * lbInfluxIP;
RComboBox * cbLocation;
QCheckBox * chkDEFourTime;
};
@ -90,8 +93,41 @@ inline void Cross::SetUpCanvas(){
//layout->addWidget(hPID, 2, 0);
int row = 0;
cbLocation = new RComboBox(this);
cbLocation->addItem("Cross", 0);
cbLocation->addItem("Target", 1);
layout->addWidget(cbLocation, row, 0);
connect(cbLocation, &RComboBox::currentIndexChanged, this, [=](){
switch (cbLocation->currentData().toInt() ) {
case 0 : {
hdE->SetLineTitle("raw dE (ch = 0)");
hE->SetLineTitle("raw E (ch = 2)");
hdE->replot();
hE->replot();
chDE = 0;
chE = 2;
//Can also set histograms range
}
break;
case 1 : {
hdE->SetLineTitle("raw dE (ch = 1)");
hE->SetLineTitle("raw E (ch = 4)");
hdE->replot();
hE->replot();
chDE = 1;
chE = 4;
//Can also set histograms range
}
}
});
chkDEFourTime = new QCheckBox("dE channel / 4", this);
layout->addWidget(chkDEFourTime, row, 1);
bnClearHist = new QPushButton("Clear All Hist.", this);
layout->addWidget(bnClearHist, row, 0);
layout->addWidget(bnClearHist, row, 2);
connect( bnClearHist, &QPushButton::clicked, this, [=](){
hdE->Clear();
@ -105,6 +141,7 @@ inline void Cross::SetUpCanvas(){
hMulti->Clear();
});
QString haha;
if( influx ) {
haha = dataBaseIP + ", DB : " + dataBaseName;
@ -113,7 +150,7 @@ inline void Cross::SetUpCanvas(){
}
lbInfluxIP = new QLabel( haha , this);
if( influx == nullptr ) lbInfluxIP->setStyleSheet("color : red;");
layout->addWidget(lbInfluxIP, row, 1, 1, 3);
layout->addWidget(lbInfluxIP, row, 3, 1, 3);
row ++;
hdEE = new Histogram2D("dE vs E", "E[ch]", "dE[ch]", 500, -100, 5000, 500, -100, 5000, this);
@ -160,14 +197,13 @@ inline void Cross::UpdateHistograms(){
//============ Get the cut list, if any
QList<QPolygonF> cutList1 = hdEE->GetCutList();
const int nCut1 = cutList1.count();
printf(" >>>>>> num of cut = %d, event Size : %ld\n", nCut1, eventBuilt);
unsigned long long tMin1[nCut1], tMax1[nCut1];
unsigned int count1[nCut1];
QList<QPolygonF> cutList2 = hdEtotE->GetCutList();
const int nCut2 = cutList2.count();
unsigned long long tMin2[nCut2] = {0xFFFFFFFFFFFFFFFF}, tMax2[nCut2] = {0}; // not a proper way to initialized
unsigned int count2[nCut2]={0};
unsigned long long tMin2[nCut2], tMax2[nCut2];
unsigned int count2[nCut2];
//============ Processing data and fill histograms
long eventIndex = evtbder->eventIndex;
@ -179,6 +215,12 @@ inline void Cross::UpdateHistograms(){
tMax1[i] = 0;
count1[i] = 0;
}
for( int i = 0; i < nCut2; i++) {
tMin2[i] = -1;
tMax2[i] = 0;
count2[i] = 0;
}
for( long i = eventStart ; i <= eventIndex; i ++ ){
@ -189,14 +231,14 @@ inline void Cross::UpdateHistograms(){
hMulti->Fill(event.size());
ch1 = -100; t1 = 0;
ch4 = -100; t4 = 0;
energyDE = -100; t1 = 0;
energyE = -100; t4 = 0;
ch7 = -100; t7 = 0;
for( int k = 0; k < (int) event.size(); k++ ){
//event[k].Print();
if( event[k].ch == 0 ) {ch1 = event[k].energy; t1 = event[k].timestamp;} // Reads channel 0 of the digitizer corresponding to dE
if( event[k].ch == 2 ) {ch4 = event[k].energy; t4 = event[k].timestamp;} // Reads channel 2 of the digitizer corresponding to E
if( event[k].ch == chDE ) {energyDE = event[k].energy; t1 = event[k].timestamp;} // Reads channel 0 of the digitizer corresponding to dE
if( event[k].ch == chE ) {energyE = event[k].energy; t4 = event[k].timestamp;} // Reads channel 2 of the digitizer corresponding to E
if( event[k].ch == 7 ) {ch7 = event[k].energy; t7 = event[k].timestamp;} //RF Timing if setup
}
@ -204,27 +246,27 @@ inline void Cross::UpdateHistograms(){
// printf("(E, dE) = (%f, %f)\n", E, dE);
//hPID->Fill(ch4 , ch1); // x, y
//etotal = ch1*0.25*0.25 + ch4
if( ch1 > 0 ) hdE->Fill(ch1);
if( ch4 > 0 ) hE->Fill(ch4);
if( energyDE > 0 ) hdE->Fill(energyDE);
if( energyE > 0 ) hE->Fill(energyE);
if( ch7 > 0 ) hdT->Fill(ch7);
if( ch1 > 0 && ch4 > 0 ){
hTotE->Fill(0.25 * ch1 + ch4);
hdEE->Fill(ch4,ch1);
if( energyDE > 0 && energyE > 0 ){
hTotE->Fill(0.25 * energyDE + energyE);
hdEE->Fill(energyE,energyDE);
if( t4 > t1 ) {
hTWin->Fill((t4-t1));
}else{
hTWin->Fill((t1-t4));
}
hdEtotE->Fill(0.25 * ch1 + ch4,ch1);
hdEtotE->Fill( (chkDEFourTime->isChecked() ? 0.25 : 1) * energyDE + energyE,energyDE);
}
if( ch1 > 0 && ch7 > 0) hdEdT->Fill((t7-t1)*1e9,ch1);
if( energyDE > 0 && ch7 > 0) hdEdT->Fill((t7-t1)*1e9,energyDE);
//check events inside any Graphical cut and extract the rate
// if( ch1 == 0 && ch4 == 0 ) continue;
for(int p = 0; p < cutList1.count(); p++ ){
if( cutList1[p].isEmpty() ) continue;
if( cutList1[p].containsPoint(QPointF(ch4, ch1), Qt::OddEvenFill) ){
if( cutList1[p].containsPoint(QPointF(energyE, energyDE), Qt::OddEvenFill) ){
if( t1 < tMin1[p] ) tMin1[p] = t1;
if( t1 > tMax1[p] ) tMax1[p] = t1;
count1[p] ++;
@ -234,7 +276,7 @@ inline void Cross::UpdateHistograms(){
for(int p = 0; p < cutList2.count(); p++ ){
if( cutList2[p].isEmpty() ) continue;
if( cutList2[p].containsPoint(QPointF(ch1+ch4,ch1), Qt::OddEvenFill) ){
if( cutList2[p].containsPoint(QPointF(energyDE+energyE,energyDE), Qt::OddEvenFill) ){
if( t1 < tMin2[p] ) tMin2[p] = t1;
if( t1 > tMax2[p] ) tMax2[p] = t1;
count2[p] ++;