60#include <QApplication>
61#include <QProgressBar>
62#include <QDesktopWidget>
70#include <QCommandLineParser>
72#include <Inventor/C/errors/debugerror.h>
73#include <Inventor/Qt/SoQt.h>
88 std::vector<std::string>
vec;
89 for (
const QString&
str : list) {
90 vec.push_back(
str.toStdString());
185 if (event->type()==QEvent::MouseButtonPress
186 ||event->type()==QEvent::MouseButtonDblClick
187 ||event->type()==QEvent::Wheel) {
188 QTime t = QTime::currentTime();
191 if (timediff>timecut) {
194 QMouseEvent*mouseEvent =
dynamic_cast<QMouseEvent*
>(event);
196 txt =
event->type()==QEvent::MouseButtonDblClick?
"Dbl-click"
197 :(mouseEvent->button()&Qt::LeftButton?
"Left-click"
198 :(mouseEvent->button()&Qt::RightButton?
"Right-click":
"Middle-click"));
200 QWheelEvent * wheelEvent =
dynamic_cast<QWheelEvent*
>(event);
204 txt =
"Unknown event";
210 QLabel *
label =
new QLabel(txt,0,Qt::Tool|Qt::FramelessWindowHint
211 |Qt::X11BypassWindowManagerHint|Qt::WindowStaysOnTopHint);
212 label->setStyleSheet(
"background-color: yellow;color: black;"
213 "font: bold 140%;border: 2px solid black");
215 label->setFrameStyle(QFrame::StyledPanel);
216 label->setAttribute(Qt::WA_ShowWithoutActivating);
217 label->setFocusPolicy(Qt::NoFocus);
218 QPoint p(QCursor::pos().
x()-
label->sizeHint().width()/2,QCursor::pos().y()-
label->sizeHint().height());
220 QTimer::singleShot(0,
label,SLOT(show()));
221 QTimer::singleShot(500,
label, SLOT(deleteLater()));
236 ISvcLocator* svcLocator,
239: QObject(parent),
m_d(new
Imp)
241 m_d->availEvents = availEvents;
243 m_d->eventsProcessed = 0;
245 m_d->scheduler =
this;
249 m_d->batchMode =
false;
250 m_d->batchUtilities =
nullptr;
251 m_d->batchModeAllEvents =
false;
252 m_d->batchModeNEvents = 0;
253 m_d->batchModeRandomConfig =
false;
255 m_d->allSystemsRefreshed =
false;
256 m_d->goingtonextevent=
true;
257 m_d->currentsystemrefreshing=0;
258 m_d->eraseJustAfterRefresh=
false;
259 m_d->postponedUncreateAndDeleteCW=0;
260 m_d->refreshtimer =
new QTimer(
this);
269 connect(
m_d->mainwindow->tabManager(),SIGNAL(visibleChannelsChanged(
const QSet<IVP1ChannelWidget*>&,
const QSet<IVP1ChannelWidget*>&,
const double&)),
270 m_d->prioritiser,SLOT(visibleChannelsChanged(
const QSet<IVP1ChannelWidget*>&,
const QSet<IVP1ChannelWidget*>&,
const double&)));
274 SoQt::init(
m_d->mainwindow );
279 qDebug() <<
"VP1ExecutionScheduler:: Do we run in 'batch' mode?" << batchMode;
283 m_d->batchMode =
true;
292 m_d->mainwindow->show();
296 m_d->pb =
m_d->mainwindow->progressbar;
297 m_d->pbtimer =
new QTimer(
this);
299 m_d->calctimethisevent=0;
300 m_d->currentrefreshsystemestimate=0;
303 m_d->cruisetimer =
new QTimer(
this);
305 m_d->cruisetab_waitingtoproceed=
false;
307 #if defined BUILDVP1LIGHT
313 if (checkDisplayMouseClicks) {
315 qApp->installEventFilter(
m_d->globalEventFilter);
317 m_d->globalEventFilter = 0;
322 m_d->skipEvent =
true;
325 connect(auth,SIGNAL(authenticationSuccessful(QNetworkAccessManager*)),
326 availEvtsHttps,SLOT(start(QNetworkAccessManager*)));
327 connect(availEvtsHttps,SIGNAL(freshEventsChanged()),
328 auth,SLOT(accept()));
335 m_d->skipEvent =
false;
341 m_d->refreshtimer->stop();
342 delete m_d->batchUtilities;
343 delete m_d->mainwindow;
344 delete m_d->prioritiser;
345 delete m_d->globalEventFilter;
352 ISvcLocator* svcLocator,
354 const QStringList& joboptions,
355 QString initialCruiseMode,
356 unsigned initialCruiseSeconds,
357 const QString& singleEventSource,
358 const QString& singleEventLocalTmpDir,
359 unsigned localFileCacheLimit,
360 const QStringList& availableLocalInputDirectories )
369 if (alternative.isEmpty()) {
370 VP1Msg::message(
"ERROR: The DISPLAY environment variable is "+QString(unset?
"not set":
"empty")+
".");
371 VP1Msg::message(
"This might be because something else in Athena has disabled it.");
373 "the DISPLAY_ORIG environment variable to the contents of DISPLAY before launching your job.");
377 VP1Msg::message(
"For the current job, I will try with DISPLAY=\":0.0\", which is the correct value when running locally.");
380 VP1Msg::message(
"WARNING: The DISPLAY environment variable is "+QString(unset?
"not set":
"empty")+
". Setting to value found in DISPLAY_ORIG");
382 VP1Msg::message(
"WARNING: Setting DISPLAY variable to '"+alternative+
"'");
388 QCoreApplication::setOrganizationName(
"ATLAS");
389 #if defined BUILDVP1LIGHT
390 QCoreApplication::setApplicationName(
"VP1Light");
392 QCoreApplication::setApplicationName(
"VP1");
394 QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
400 VP1Msg::message(
"VP1ExecutionScheduler::init ERROR: QApplication already initialized. Expect problems!!!");
404 static char execpath[] =
"/some/fake/executable/vp1";
405 static char *argv[2];
419 if (!singleEventSource.isEmpty()&&!singleEventLocalTmpDir.isEmpty()) {
420 const bool httpmode = singleEventSource.startsWith(
"http://");
421 const bool httpsmode = singleEventSource.startsWith(
"https://");
424 availEvents =
new VP1AvailEvtsHttp(singleEventSource, 60, 30*60, singleEventLocalTmpDir,localFileCacheLimit);
425 }
else if(httpsmode) {
426 availEvents =
new VP1AvailEvtsHttps(singleEventSource, 1000, 30*60, singleEventLocalTmpDir,localFileCacheLimit);
429 singleEventLocalTmpDir,localFileCacheLimit);
430 static_cast<VP1AvailEvtsLocalDir*
>(availEvents)->setAvailableSourceDirectories(availableLocalInputDirectories);
439 if (joboptions.empty()) {
442 qDebug() <<
"config files: " << joboptions;
443 for (
const QString& opt : joboptions)
448 if (joboptions.size() != 0 ) {
453 if (batchNevents > 0 ) {
460 if (scheduler->
m_d->
mainwindow->tabWidget_central->count()<=1) {
461 if (initialCruiseMode==
"TAB") {
462 VP1Msg::message(
"ERROR: Can not start in cruisemode TAB unless there are at least 2 tabs loaded from initial .vp1 files. Reverting to cruise mode NONE.");
463 initialCruiseMode=
"NONE";
464 }
else if (initialCruiseMode==
"BOTH") {
465 VP1Msg::message(
"ERROR: Can not start in cruisemode BOTH unless there are at least 2 tabs loaded from initial .vp1 files. Reverting to cruise mode EVENT.");
466 initialCruiseMode=
"EVENT";
471 if (initialCruiseMode==
"EVENT") {
473 scheduler->
m_d->
mainwindow->radioButton_cruise_event->setChecked(
true);
474 scheduler->
m_d->
mainwindow->pushButton_cruise->setChecked(
true);
476 }
else if (initialCruiseMode==
"TAB") {
478 scheduler->
m_d->
mainwindow->radioButton_cruise_tab->setChecked(
true);
479 scheduler->
m_d->
mainwindow->pushButton_cruise->setChecked(
true);
480 }
else if (initialCruiseMode==
"BOTH") {
482 scheduler->
m_d->
mainwindow->radioButton_cruise_both->setChecked(
true);
483 scheduler->
m_d->
mainwindow->pushButton_cruise->setChecked(
true);
485 if (initialCruiseMode!=
"NONE")
486 VP1Msg::message(
"ERROR: unknown initial cruise mode "+initialCruiseMode+
" (valid are NONE/EVENT/TAB/BOTH). Assuming NONE.");
488 scheduler->
m_d->
mainwindow->radioButton_cruise_event->setChecked(
true);
489 scheduler->
m_d->
mainwindow->pushButton_cruise->setChecked(
false);
494 int cruisesecs = ( initialCruiseSeconds == 0 ? 0 :
495 std::max(scheduler->
m_d->
mainwindow->spinBox_cruise->minimum(),
496 std::min(scheduler->
m_d->
mainwindow->spinBox_cruise->maximum(),
497 static_cast<int>(initialCruiseSeconds))));
499 scheduler->
m_d->
mainwindow->spinBox_cruise->setValue(cruisesecs);
508 #if defined BUILDVP1LIGHT
515 QMessageBox::information(0,
"End of job reached",Qt::convertFromPlainText(
"Job about to end.\n\nThis is most"
516 " likely since there are no more available events to process."),QMessageBox::Ok,QMessageBox::Ok);
521 qApp->processEvents();
533 const QString quickExitEnv(
"VP1_HARD_EXIT_AT_END");
535 #if defined BUILDVP1LIGHT
541 if (checkHardExitAtEnd) {
542 VP1Msg::message(
"Hard job exit (unset "+quickExitEnv+
" to disable this behaviour).");
551 double remaining =
prioritiser->estimateRemainingCalcTime();
568 if (
m_d->currentrefreshsystemestimate<1.0)
570 double timing=(
m_d->prioritiser->elapsedTiming_Refresh())*0.95;
571 if (timing>
m_d->currentrefreshsystemestimate)
573 m_d->pb->setValue(
static_cast<int>((
m_d->calctimethisevent+timing)*10.0));
580 return m_d->nextRequestedEvent;
586 m_d->nextRequestedEvent = f;
594 m_d->nextRequestedEvent=
"";
596#if defined BUILDVP1LIGHT
598 if ( !firstlaunch ) {
599 if ( (getEvtNr() >= 0) && (getEvtNr() < m_totEvtNr) ) {
602 std::set<IVP1System *>::iterator itsys, itsysE =
m_d->mainwindow->tabManager()->selectedChannelWidget()->systems().end();
603 for (itsys =
m_d->mainwindow->tabManager()->selectedChannelWidget()->systems().begin();itsys!=itsysE;++itsys) {
604 if((*itsys)->name()==
"Analysis"){
609 else if ( (getEvtNr() < 0) && (getEvtNr() >= m_totEvtNr) ) {
611 msgBox.setWindowTitle(
"No more events");
612 msgBox.setText(
"There are no more events in this file. Returning to previous event.");
613 msgBox.setIcon(QMessageBox::Icon::Information);
621 m_d->mainwindow->setRunEvtNumber(
runnumber, eventnumber, triggerType, time, !
m_d->skipEvent);
624 m_d->goingtonextevent =
false;
625 m_d->calctimethisevent=0;
626 m_d->currentrefreshsystemestimate=0;
627 m_d->updateProgressBar();
629 assert(!
m_d->refreshtimer->isActive());
633 m_d->refreshtimer->start();
640 qApp->processEvents();
644 m_d->mainwindow->groupBox_channelcontrols->setEnabled(
true);
645 m_d->mainwindow->groupBox_cruise->setEnabled(
true);
646 m_d->mainwindow->groupBox_event->setEnabled(
true);
651 if (
m_d->batchModeRandomConfig) {
652 VP1Msg::messageDebug(
"User chose 'batch' and 'batch-random-config'. So we now replace the configuration with a random one from the input set...");
653 QString randomConfigFile = QString::fromStdString(
m_d->batchUtilities->getRandomConfigFile() );
654 m_d->mainwindow->replaceConfigurationFile(randomConfigFile);
657 if (
m_d->batchMode &&
m_d->allVisibleRefreshed() ) {
663 m_d->skipEvent=
false;
664 m_d->mainwindow->nextEvent();
674 m_d->mainwindow->groupBox_channelcontrols->setEnabled(
false);
675 m_d->mainwindow->groupBox_cruise->setEnabled(
false);
676 m_d->mainwindow->groupBox_event->setEnabled(
false);
678 m_d->goingtonextevent =
true;
680 if (
m_d->refreshtimer->isActive()) {
681 m_d->refreshtimer->stop();
685 m_d->pbtimer->stop();
691 assert(!
m_d->currentsystemrefreshing);
692 for (
IVP1System*s :
m_d->prioritiser->getSystemsToEraseByPriority()) {
693 qApp->processEvents(QEventLoop::ExcludeUserInputEvents|QEventLoop::ExcludeSocketNotifiers);
697 ++
m_d->eventsProcessed;
698 VP1Msg::messageDebug(
"event processed. " + QString::number(
m_d->eventsProcessed) +
" events processed so far.");
702 cw->goingToNextEvent();
705 qApp->processEvents(QEventLoop::ExcludeUserInputEvents|QEventLoop::ExcludeSocketNotifiers);
709 return !
m_d->mainwindow->mustQuit();
719 assert(!s->isRefreshing());
721 QString
base = QString(s->name())+
" from channel "+s->channel()->unique_name();
722 m_d->mainwindow->statusBar()->showMessage(
"Erasing system ["+
base+
"]" );
725 s->disallowUpdateGUI();
728 m_d->mainwindow->statusBar()->showMessage(
"Post-erase update to channel ["+
base+
"]" );
729 s->channel()->systemErased(s);
730 m_d->mainwindow->statusBar()->clearMessage();
737 if (
m_d->currentsystemrefreshing!=s) {
741 assert(s->isRefreshing());
742 m_d->eraseJustAfterRefresh=
true;
749 assert(!
m_d->goingtonextevent);
750 if (
m_d->currentsystemrefreshing)
753 IVP1System * s =
m_d->prioritiser->nextErasedActiveSystemByPriority();
757 assert(
m_d->refreshtimer->isActive());
759 m_d->refreshtimer->stop();
762 m_d->pbtimer->stop();
769 std::set<IVP1System*>::const_iterator it, itE = cw->
systems().end();
770 for (it=cw->
systems().begin();it!=itE;++it) {
771 qInfo() <<
"System name:" << (*it)->name();
785 std::set<IVP1System*>::const_iterator it, itE = cw->
systems().end();
786 for (it=cw->
systems().begin();it!=itE;++it)
793 if (!
m_d->goingtonextevent&&!
m_d->refreshtimer->isActive())
794 m_d->refreshtimer->start();
800 return m_d->currentsystemrefreshing;
806 QString sysname = s->name();
809 m_d->updateProgressBar();
813 assert(!
m_d->currentsystemrefreshing);
815 m_d->currentrefreshsystemestimate =
m_d->prioritiser->beginTiming_Refresh(s);
816 m_d->currentsystemrefreshing = s;
818 QString
base = QString(s->name())+
" from channel "+s->channel()->unique_name();
819 m_d->mainwindow->statusBar()->showMessage(
"Refreshing system ["+
base+
"]" );
822 s->setRefreshing(
true);
824 s->channel()->emitRefreshInfoChanged();
827 s->setRefreshing(
false);
828 s->disallowUpdateGUI();
830 m_d->mainwindow->statusBar()->showMessage(
"Post-refresh update to channel ["+
base+
"]" );
831 s->channel()->systemRefreshed(s);
833 m_d->mainwindow->statusBar()->clearMessage();
834 m_d->currentsystemrefreshing = 0;
835 m_d->calctimethisevent +=
m_d->prioritiser->endTiming_Refresh();
836 m_d->currentrefreshsystemestimate=0;
837 m_d->updateProgressBar();
840 s->channel()->emitRefreshInfoChanged();
846 s->channel()->lastOfActiveSystemsRefreshed();
848 m_d->allSystemsRefreshed =
true;
852 m_d->performPostRefreshCruiseActions(s->channel());
854 if (
m_d->eraseJustAfterRefresh) {
856 m_d->eraseJustAfterRefresh=
false;
861 if (
m_d->postponedUncreateAndDeleteCW) {
863 m_d->postponedUncreateAndDeleteCW=0;
896 if (
m_d->batchMode) {
899 VP1Msg::messageDebug(
"batchModeNEvents: " + QString::number(
m_d->batchModeNEvents) +
" - m_d->eventsProcessed: " + QString::number(
m_d->eventsProcessed) );
910 if (
m_d->batchModeAllEvents) {
915 QApplication::quit();
917 }
else if (
m_d->batchModeNEvents > 0 ) {
918 if (
m_d->batchModeNEvents ==
m_d->eventsProcessed+1) {
920 VP1Msg::messageWarningAllRed(
"'batch mode' with 'batch-n-events' option. Processed the " + QString::number(
m_d->eventsProcessed+1) +
" events set by the user. Now exiting VP1");
922 m_d->mainwindow->close();
926 QApplication::quit();
935 m_d->mainwindow->close();
946 QString chnlname = s->name().toLower();
947 VP1Msg::messageDebug(
"VP1ExecutionScheduler::saveSnaphsotToFile() - taking the snapshot of the channel " + chnlname );
958 QString folderName =
"";
962 if ( ! (batchOutFolder ==
"") ) {
964 folderName = batchOutFolder;
967 folderName =
"atlas_vp1_batch_images";
970 QDir dir(folderName);
976 if (folderName.startsWith(
"/"))
977 folder = folderName + QDir::separator();
979 folder = currentsaveimagepath + folderName + QDir::separator();
986 QString runnumb = QString::number(
m_d->mainwindow->getRunNumber());
987 QString evnumb = QString::number(
m_d->mainwindow->getEventNumber());
988 QString evtimestamp = QString::number(
m_d->mainwindow->getEventTimestamp());
990 time_t t_evttimestamp =
m_d->mainwindow->getEventTimestamp();
991 struct tm human_evtimestamp;
992 localtime_r(&t_evttimestamp, &human_evtimestamp);
994 std::ostringstream h_evtimestamp_ostri;
995 h_evtimestamp_ostri << 1900 + human_evtimestamp.tm_year
996 <<
"-" << 1 + human_evtimestamp.tm_mon
997 <<
"-" << human_evtimestamp.tm_mday
998 <<
"T" << human_evtimestamp.tm_hour <<
"-" << human_evtimestamp.tm_min <<
"-" << human_evtimestamp.tm_sec <<
"CEST";
1000 std::string h_evtimestamp_str = h_evtimestamp_ostri.str();
1001 QString h_evtimestamp = QString::fromStdString(h_evtimestamp_str);
1005 time_t t_timestamp = time(0);
1007 localtime_r(&t_timestamp, <m);
1011 +
" - " +
"Month: " + QString::number(1 + ltm.tm_mon) +
" - "
1012 +
"Day: " + QString::number(ltm.tm_mday)
1013 +
" - " "Time: " + QString::number(ltm.tm_hour) +
":" + QString::number(ltm.tm_min) +
":" + QString::number(ltm.tm_sec) +
"CEST");
1015 std::ostringstream ostri_unix;
1016 ostri_unix << t_timestamp;
1018 std::ostringstream ostri;
1019 ostri << 1900 + ltm.tm_year
1020 <<
"-" << 1 + ltm.tm_mon
1021 <<
"-" << ltm.tm_mday
1022 <<
"T" << ltm.tm_hour <<
"-" << ltm.tm_min <<
"-" << ltm.tm_sec <<
"CEST";
1024 std::string unixTimestamp = ostri_unix.str();
1025 std::string humanTimestamp = ostri.str();
1026 QString q_unixTimestamp = QString::fromStdString(unixTimestamp);
1027 QString q_humanTimestamp = QString::fromStdString(humanTimestamp);
1037 QString filename = folder +
"vp1_batch_snapshot_r" + runnumb +
"_ev" + evnumb +
"_evtime_H" + h_evtimestamp +
"_U" + evtimestamp +
"___imgtime_H" + q_humanTimestamp +
"_U" + q_unixTimestamp +
".png";
1040 QPixmap pm = s->channel()->getSnapshot();
1050 QString latestImageFileName = currentsaveimagepath + QString(
"latest_vp1image");
1051 QFile latestImage(latestImageFileName);
1052 if(latestImage.exists() && !latestImage.remove())
1053 throw std::runtime_error(
"Unable to overwrite the existing latest image file");
1054 if(!latestImage.open(QIODevice::WriteOnly | QIODevice::Text))
1055 throw std::runtime_error(
"Unable to create new latest image file");
1056 latestImage.write(filename.toStdString().c_str());
1057 latestImage.close();
1075 connect(cw,SIGNAL(message(
const QString&)),
m_d->mainwindow,SLOT(channelAddToMessageBox(
const QString&)));
1077 std::set<IVP1System *>::iterator itsys, itsysE = cw->
systems().end();
1078 for (itsys = cw->
systems().begin();itsys!=itsysE;++itsys) {
1080 connect((*itsys),SIGNAL(sysmessage(
const QString&)),
m_d->mainwindow,SLOT(systemAddToMessageBox(
const QString&)));
1083 for (itsys = cw->
systems().begin();itsys!=itsysE;++itsys) {
1084 (*itsys)->setCanRegisterController(
true);
1086 (*itsys)->setCanRegisterController(
false);
1103 if (
m_d->currentsystemrefreshing&&cw->
systems().find(
m_d->currentsystemrefreshing)!=cw->
systems().end()) {
1104 assert(!
m_d->postponedUncreateAndDeleteCW);
1105 m_d->postponedUncreateAndDeleteCW=cw;
1115 cw->setUpdatesEnabled(
false);
1118 std::set<IVP1System *>::iterator itsys, itsysE = cw->
systems().end();
1119 for (itsys = cw->
systems().begin();itsys!=itsysE;++itsys) {
1120 (*itsys)->blockSignals(
true);
1121 disconnect(*itsys,0,0,0);
1123 cw->blockSignals(
true);
1124 disconnect(cw,0,0,0);
1127 for (itsys = cw->
systems().begin();itsys!=itsysE;++itsys) {
1128 assert(
m_d->currentsystemrefreshing!=(*itsys));
1134 for (itsys = cw->
systems().begin();itsys!=itsysE;++itsys) {
1136 (*itsys)->uncreate();
1157 QSet<QWidget*> w_ignore;
1158#if QTCORE_VERSION >= 0x050E00
1159 QList<QWidget*> widgets = QApplication::allWidgets();
1160 QSet<QWidget*> wl (widgets.begin(), widgets.end());
1162 QSet<QWidget*> wl = QApplication::allWidgets().toSet();
1164 w_ignore<<qApp->desktop();
1165 for (QObject*o : qApp->children()) {
1166 if (o->isWidgetType())
1167 w_ignore << static_cast<QWidget*>(o);
1169 for (QWidget * w : wl) {
1170 if (w->objectName().startsWith(
"internal clipboard"))
1172 if (w->objectName()==
"empty_widget")
1175 wl.subtract(w_ignore);
1177 std::cout<<std::endl;
1178 std::cout<<
"VP1 WARNING: "<<wl.count()<<
" widget"<<(wl.count()>1?
"s":
"")<<
" left at end of job:"<<std::endl;
1180 for (QWidget*w : wl) {
1181 std::cout<<++i<<
") Address="<<w<<
", ObjectName="<<w->objectName().toStdString()<<
", ClassName="<<w->metaObject()->className()<<std::endl;
1183 std::cout<<std::endl;
1192 std::set<IVP1System*>::const_iterator it, itE = cw->
systems().end();
1194 for (it=cw->
systems().begin();it!=itE;++it) {
1201 QString name = QString((*it)->name());
1202 QString active = QString::number((*it)->activeState());
1203 QString state = QString::number((*it)->state());
1204 std::cout << i <<
" - name: " << name.toStdString() <<
" - active: " << active.toStdString() <<
" - refreshed: " << state.toStdString() << std::endl;
1219 if (!
scheduler->hasAllActiveSystemsRefreshed(cw))
1228 if (!
scheduler->hasAllActiveSystemsRefreshed(cw))
1275 assert(0&&
"not implemented");
1308 assert(0&&
"UNKNOWN CRUISE MODE");
1316 if (
m_d->cruisemode == m)
1318 m_d->cruisemode = m;
1320 m_d->mainwindow->tabManager()->setTabCruiseMode(m==
TAB||m==
BOTH);
1332 m_d->cruisetimer->stop();
1334 if (!
m_d->mainwindow->okToProceedToNextEvent()) {
1336 m_d->cruisetimer->start( (
m_d->mainwindow->spinBox_cruise->value() > 5 ? 3000 : 1000) );
1340 assert(!
m_d->goingtonextevent);
1342 switch (
m_d->cruisemode) {
1344 assert(0&&
"should never happen");
1347 assert(
m_d->cruisetab_waitingtoproceed==
false);
1348 if (
m_d->allSoonVisibleRefreshed()) {
1349 m_d->mainwindow->tabManager()->showNextTab();
1351 if (
m_d->allVisibleRefreshed())
1352 m_d->cruisetimer->start(
m_d->mainwindow->spinBox_cruise->value()*1000);
1354 m_d->cruisetab_waitingtoproceed=
true;
1358 m_d->mainwindow->goToNextEvent();
1362 assert(0&&
"Not implemented");
1366 assert(0&&
"UNKNOWN CRUISE MODE");
1375 return m_d->mainwindow->userRequestedFiles();
1390void VP1ExecutionScheduler::loadEvent(){
1392 const char* appName =
"VP1Light";
1396 ::Error( appName,
XAOD_MESSAGE(
"Failed to execute xAOD::Init" ) );
1403 QSettings settings(
"ATLAS",
"VP1Light");
1404 std::string
path = settings.value(
"aod/path").toString().toStdString();
1407 m_ifile = ::TFile::Open(
path.c_str(),
"READ" );
1409 ::Error( appName,
XAOD_MESSAGE(
"File %s couldn't be opened..." ),
1413 if( !m_event->readFrom( m_ifile ).isSuccess() ) {
1414 ::Error( appName,
XAOD_MESSAGE(
"Failed to read from xAOD file %s" ),
1420 if( m_event->getEntry( 0 ) < 0 ) {
1421 ::Error( appName,
XAOD_MESSAGE(
"Couldn't load entry 0 from file %s" ),
1427 m_event->getEntry( m_evtNr );
1430 QStringList jetList;
1431 QStringList vertexList;
1432 QStringList otherList;
1433 QStringList caloClusterList;
1434 QStringList trackParticleList;
1435 QStringList muonList;
1436 QStringList electronList;
1440 TTree*
ct = (TTree*)m_ifile->Get(
"CollectionTree");
1441 m_totEvtNr =
ct->GetEntriesFast();
1443 std::string className =
ct->GetBranch(
ct->GetListOfBranches()->At(i)->GetName())->GetClassName();
1446 if(
split(className,
"_v[1-9]")==
"DataVector<xAOD::Vertex>"){
1447 vertexList <<
ct->GetListOfBranches()->At(i)->GetName();
1449 if(
split(className,
"_v[1-9]")==
"xAOD::MissingETContainer"){
1450 otherList <<
ct->GetListOfBranches()->At(i)->GetName();
1452 if(
split(className,
"_v[1-9]")==
"DataVector<xAOD::Jet>"){
1453 jetList <<
ct->GetListOfBranches()->At(i)->GetName();
1455 if(
split(className,
"_v[1-9]")==
"DataVector<xAOD::CaloCluster>"){
1456 caloClusterList <<
ct->GetListOfBranches()->At(i)->GetName();
1458 if(
split(className,
"_v[1-9]")==
"DataVector<xAOD::TrackParticle>"){
1459 trackParticleList <<
ct->GetListOfBranches()->At(i)->GetName();
1461 if(
split(className,
"_v[1-9]")==
"DataVector<xAOD::Muon>"){
1462 muonList <<
ct->GetListOfBranches()->At(i)->GetName();
1464 if(
split(className,
"_v[1-9]")==
"DataVector<xAOD::Electron>"){
1465 electronList <<
ct->GetListOfBranches()->At(i)->GetName();
1470 m_list.append(vertexList);
1471 m_list.append(otherList);
1472 m_list.append(jetList);
1473 m_list.append(caloClusterList);
1474 m_list.append(trackParticleList);
1475 m_list.append(muonList);
1476 m_list.append(electronList);
1480 if( !m_event->retrieve (eventInfo,
"EventInfo").isSuccess() ) {
1488 QString currentEvt =
"Event: " + QString::number(getEvtNr()+1) +
"/" + QString::number(getTotEvtNr());
1489 m_d->mainwindow->pushButton_eventselect->setText(currentEvt);
1493void VP1ExecutionScheduler::passEvent(IVP1System* sys){
1494 sys->setEvent(m_event);
1495 sys->setObjectList(m_list);
1499QString VP1ExecutionScheduler::split(
const std::string& input,
const std::string& regex) {
1500 std::regex
re(regex);
1502 std::vector<std::string>
vec = {
first, last};
1504 for (
unsigned int i=0;
i<
vec.size();
i++){
1505 list << QString::fromStdString(
vec[i]);
1507 return list.join(
"");
const boost::regex re(r_e)
std::vector< size_t > vec
TGraphErrors * GetEntries(TH2F *histo)
std::vector< std::string > qstringlistToVecString(const QStringList &list)
The Athena Transient Store API.
static StoreGateSvc * eventStore()
static void setPointers(StoreGateSvc *eventStore, StoreGateSvc *detectorStore, ISvcLocator *, IToolSvc *)
static StoreGateSvc * detectorStore()
const QString & fileinfoLocation()
bool eventFilter(QObject *watched, QEvent *event)
IVP1ChannelWidget * postponedUncreateAndDeleteCW
double currentrefreshsystemestimate
VP1AvailEvents * availEvents
bool cruisetab_waitingtoproceed
VP1MainWindow * mainwindow
void performPostRefreshCruiseActions(IVP1ChannelWidget *cw)
GlobalEventFilter * globalEventFilter
bool batchModeRandomConfig
bool eraseJustAfterRefresh
VP1ExecutionScheduler * scheduler
bool allSoonVisibleRefreshed() const
VP1BatchUtilities * batchUtilities
bool allVisibleRefreshed() const
static void warnIfWidgetsAlive()
IVP1System * currentsystemrefreshing
VP1Prioritiser * prioritiser
QString nextRequestedEvent
const QString & nextRequestedEventFile() const
static VP1ExecutionScheduler * init(StoreGateSvc *eventStore, StoreGateSvc *detStore, ISvcLocator *svcLocator, IToolSvc *toolSvc, const QStringList &joboptions, QString initialCruiseMode="NONE", unsigned initialCruiseSeconds=10, const QString &singleEventSource="", const QString &singleEventLocalTmpDir="", unsigned localFileCacheLimit=10, const QStringList &availableLocalInputDirectories=QStringList())
void updateProgressBarDuringRefresh()
void bringFromConstructedToReady(IVP1ChannelWidget *)
bool executeNewEvent(const int &runnumber, const unsigned long long &eventnumber, const unsigned &triggerType=0, const unsigned &time=0)
void setCruiseMode(const CruiseMode &)
QString saveSnaphsotToFile(IVP1System *s, bool batch=false)
void refreshSystem(IVP1System *)
void actualUncreateAndDelete(IVP1ChannelWidget *)
void refreshingStatusChanged(bool)
void processSystemForRefresh()
void channelUncreated(IVP1ChannelWidget *)
bool hasAllActiveSystemsRefreshed(IVP1ChannelWidget *) const
void eraseSystem(IVP1System *)
void channelCreated(IVP1ChannelWidget *)
virtual ~VP1ExecutionScheduler()
void startRefreshQueueIfAppropriate()
VP1ExecutionScheduler(QObject *parent, StoreGateSvc *eventStore, StoreGateSvc *detStore, ISvcLocator *svcLocator, IToolSvc *toolSvc, VP1AvailEvents *availEvents)
static void cleanup(VP1ExecutionScheduler *)
void setNextRequestedEventFile(const QString &)
QStringList userRequestedFiles()
void uncreateAndDelete(IVP1ChannelWidget *)
bool isRefreshing() const
static void warnUndeletedInstances()
void request_cruisemodechange()
void loadConfigurationFromFile(const QString &file)
static void messageVerbose(const QString &)
static void messageDebug(const QString &)
static void message(const QString &, IVP1System *sys=0)
static void messageWarningRed(const QString &str, IVP1System *sys=0)
static void messageWarningAllRed(const QString &str, IVP1System *sys=0)
static bool environmentVariableIsOn(const QString &name)
static bool environmentVariableIsSet(const QString &name)
static QString environmentVariableValue(const QString &name)
static bool expertSettingIsOn(const QString &type, const QString &name)
static void setEnvironmentVariable(const QString &name, const QString &content)
static QString defaultFileSelectDirectory()
uint16_t level1TriggerType() const
The Level-1 trigger type.
uint32_t timeStamp() const
POSIX time in seconds from 1970. January 1st.
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
@ kAthenaAccess
Access containers/objects like Athena does.
std::vector< std::string > split(const std::string &s, const std::string &t=":")
static std::vector< uint32_t > runnumber
std::string label(const std::string &format, int i)
path
python interpreter configuration --------------------------------------—
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
EventInfo_v1 EventInfo
Definition of the latest event info version.