void OfflineLocalisationDialog::MakeLayout() { this->setWindowTitle("Offline Localisation"); QVBoxLayout *buttonsLayout = new QVBoxLayout(); QPushButton *openFileButton = new QPushButton("&Open Log..."); connect(openFileButton,SIGNAL(clicked()), this, SLOT(OpenLogFiles())); buttonsLayout->addWidget(openFileButton); QPushButton *runSimulationButton = new QPushButton("&Run simulation"); connect(runSimulationButton,SIGNAL(clicked()), this, SLOT(BeginSimulation())); buttonsLayout->addWidget(runSimulationButton); QPushButton *saveLogButton = new QPushButton("Save &Log..."); saveLogButton->setEnabled(false); connect(m_offline_loc,SIGNAL(SimDataChanged(bool)), saveLogButton, SLOT(setEnabled(bool))); connect(saveLogButton,SIGNAL(clicked()), this, SLOT(SaveAsLocalisationLog())); buttonsLayout->addWidget(saveLogButton); QPushButton *saveReportButton = new QPushButton("Save Report..."); saveReportButton->setEnabled(false); connect(m_offline_loc,SIGNAL(SimDataChanged(bool)), saveReportButton, SLOT(setEnabled(bool))); //connect(runSimulationButton,SIGNAL(pressed()), this, SLOT(BeginSimulation())); buttonsLayout->addWidget(saveReportButton); QVBoxLayout *displayLayout = new QVBoxLayout(); QLabel *fileLabel = new QLabel("Log files"); displayLayout->addWidget(fileLabel); m_fileListDisplay = new QTextBrowser(this); m_fileListDisplay->setWordWrapMode(QTextOption::NoWrap); displayLayout->addWidget(m_fileListDisplay); QHBoxLayout *overallLayout = new QHBoxLayout(); overallLayout->addLayout(buttonsLayout); overallLayout->addLayout(displayLayout,1); m_progressBar = new QProgressDialog("Runing localisation...","Cancel",0, m_offline_loc->NumberOfLogFrames(),this); m_progressBar->setWindowModality(Qt::WindowModal); m_progressBar->setValue(0); m_progressBar->setMinimumDuration(100); connect(m_offline_loc, SIGNAL(updateProgress(int,int)), this, SLOT(DiplayProgress(int,int))); connect(m_offline_loc, SIGNAL(finished()), this, SLOT(CompleteSimulation())); connect(m_progressBar, SIGNAL(canceled()), this, SLOT(CancelProgress())); connect(m_reader, SIGNAL(OpenLogFilesChanged(std::vector<QFileInfo>)), this, SLOT(SetOpenFileList(std::vector<QFileInfo>))); setLayout(overallLayout); }
void CsICalib::Bisection(Int_t A, Double_t chan) //UShort_t chan { IGNORE_UNUSED(chan); Int_t middle, it = 0; good_bisection = kTRUE; if ((A - 5) > 0) { left = A - 5; } else { left = 1; } right = A + 10; Int_t factor = 1; Double_t difference = 0.; Double_t diffright = 0.; SetFragmentA(left); CompleteSimulation(); difference = eEnergySi - sEnergySi; if (difference > 0) { factor = -1; } difference *= factor; SetFragmentA(right); CompleteSimulation(); difference = eEnergySi - sEnergySi; if (difference > 0) good_bisection = kFALSE; difference *= factor; diffright = difference; if (difference < 0) { while (diffright < 0) { if ((left - 1) > 0) left = left - 1; else left = 1; SetFragmentA(left); CompleteSimulation(); difference = eEnergySi - sEnergySi; if (difference > 0) { factor = -1; } diffright *= factor; if (left == 1) { cout << "Bisection error : Lower value of A not found" << endl; good_bisection = kFALSE; break; } } } //loop: bisection while ((right - left) > 1) { middle = (left + right + 1) / 2; SetFragmentA(middle); CompleteSimulation(); esi2 = sEnergySi; ecsi2 = sEnergyCsI; difference = factor * (eEnergySi - sEnergySi); if (difference < 0) { left = middle; } else right = middle; it++; } //simulated energies for two values of A closest to the point of zero //difference between the simulated energy for Si and the one from calibration SetFragmentA(left); CompleteSimulation(); esi1 = sEnergySi; ecsi1 = sEnergyCsI; SetFragmentA(right); CompleteSimulation(); esi2 = sEnergySi; ecsi2 = sEnergyCsI; }
void CsICalib::Bisection(Int_t A, Double_t chan){ //UShort_t chan Int_t middle, it=0; //L->Log<<"------------"<<endl; //L->Log<<"Valeur de A : "<<A<<endl; //L->Log<<"Energy Si Reference : "<<eEnergySi<<endl; if(A-5>0) left=A-5.; //left and right are integer!! A is a double else left=1; right=A+10; //L->Log<<"-----------------------------------BISECTION-------------------"<<endl;//paola //new bisection method //=== Test SetFragmentA(left); CompleteSimulation(chan); Int_t factor = 1; Double_t difference = 0.; difference = eEnergySi - sEnergySi; if(difference>0){ factor = -1; } difference *= factor; //L->Log<<"A left : "<<left<<" ESi measured : "<<eEnergySi<<" ESi calculated : "<<sEnergySi<<" difference : "<<difference<<" factor : "<<factor<<endl; SetFragmentA(right); CompleteSimulation(chan); difference = eEnergySi - sEnergySi; difference *= factor; //L->Log<<"A right : "<<right<<" ESi measured : "<<eEnergySi<<" ESi calculated : "<<sEnergySi<<" difference : "<<difference<<" factor : "<<factor<<endl; if(difference<0){ //L->Log<<"Bisection error"<<endl; } // === End test //loop: bisection while(right-left>1){ //L->Log<<"-------------------loop bisection------------"<<endl; //L->Log<<"LightCsI : "<<LightCsI<<endl; //cout<<"LightCsI : "<<LightCsI<<endl; middle=(left+right+1)/2; //simulated energies stored for middle A SetFragmentA(middle); CompleteSimulation(chan); esi2=sEnergySi; ecsi2=sEnergyCsI; //new bisection method //=== Test difference = factor*(eEnergySi - sEnergySi); //L->Log<<"difference : "<<difference<<endl; if(difference<0){ left = middle; } else right = middle; // === End test /*if(esi2>eEnergySi){ right=middle; } else left=middle;*/ //L->Log<<"A2 (middle) : "<<middle<<" ESi2= "<<sEnergySi<<" ECsI2= "<<sEnergyCsI<<endl; //paola it++; //L->Log<<"----------------iteration= "<<it<<endl; } //end of bisection loop //simulated energies for two values of A closest to the point of zero //difference between the simulated energy for Si and the one from calibration SetFragmentA(left); CompleteSimulation(chan); esi1=sEnergySi; ecsi1=sEnergyCsI; //L->Log<<"esi1 : "<<esi1<<" ecsi1 : "<<ecsi1<<endl; SetFragmentA(right); CompleteSimulation(chan); esi2=sEnergySi; ecsi2=sEnergyCsI; //L->Log<<"esi2 : "<<esi2<<" ecsi2 : "<<ecsi2<<endl; }