ATLAS Offline Software
Loading...
Searching...
No Matches
VP1Gui.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// Implementation of class VP1Gui //
8// //
9// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
10// //
11// Initial version: April 2007 //
12// //
14
15#include "VP1Gui/VP1Gui.h"
17#include "VP1Base/VP1Msg.h"
18
19#include <QStringList>
20#include <QFile>
21#include <QFileInfo>
22#include <QUrl>
23#include <QSslSocket>
24
25#include <cassert>
26#include <iostream>
27
28//____________________________________________________________________
30public:
31 Imp() : the_scheduler(nullptr), sg(nullptr), detstore(nullptr),
32 svclocator(nullptr), toolSvc(nullptr),
36 //nop
37 }
39
40 //We hold the arguments here until init is called:
43 ISvcLocator * svclocator;
44 IToolSvc * toolSvc;
45 QStringList initialvp1files;
52};
53
54
55//____________________________________________________________________
57 ISvcLocator* svclocator,IToolSvc*toolSvc,
58 const std::vector<std::string>& initialvp1files,
59 const std::string& initialCruiseMode, unsigned initialCruiseSeconds,
60 const std::string& singleEventSource, const std::string& singleEventLocalTmpDir,
61 unsigned localFileCacheLimit,
62 const std::vector<std::string>& availableLocalInputDirectories )
63 : m_d(new Imp)
64{
65 m_d->sg = sg;
66 m_d->detstore = detstore;
67 m_d->svclocator = svclocator;
68 m_d->toolSvc = toolSvc;
69 m_d->initialCruiseMode = QString(initialCruiseMode.c_str()).simplified();
70 m_d->initialCruiseSeconds = initialCruiseSeconds;
71 m_d->singleEventSource = singleEventSource.c_str();
72 m_d->singleEventLocalTmpDir = singleEventLocalTmpDir.c_str();
73 m_d->localFileCacheLimit = localFileCacheLimit;
74
75 std::vector<std::string>::const_iterator it, itE = initialvp1files.end();
76 for (it = initialvp1files.begin();it!=itE;++it)
77 m_d->initialvp1files << it->c_str();
78
79 itE = availableLocalInputDirectories.end();
80 for (it = availableLocalInputDirectories.begin();it!=itE;++it)
81 m_d->availableLocalInputDirectories << it->c_str();
82
83}
84
85//____________________________________________________________________
87{
88 delete m_d; m_d=0;
89}
90
91//____________________________________________________________________
93{
94 //Athena pointers:
95
96 if (!m_d->sg) {
97 VP1Msg::message("ERROR: Null pointer to event store.");
98 return false;
99 }
100 if (!m_d->detstore) {
101 VP1Msg::message("ERROR: Null pointer to detector store.");
102 return false;
103 }
104 if (!m_d->svclocator) {
105 VP1Msg::message("ERROR: Null pointer to service locator.");
106 return false;
107 }
108 if (!m_d->toolSvc) {
109 VP1Msg::message("ERROR: Null pointer to tool service.");
110 return false;
111 }
112
113 //Initial files:
114
115 // ...no checks...
116
117 //Cruise mode:
118 if (m_d->initialCruiseMode!="NONE"&&m_d->initialCruiseMode!="EVENT"&&m_d->initialCruiseMode!="TAB"&&m_d->initialCruiseMode!="BOTH") {
119 VP1Msg::message("WARNING: unknown initial cruise mode "+m_d->initialCruiseMode+" (valid are NONE/EVENT/TAB/BOTH). Assuming NONE.");
120 m_d->initialCruiseMode = "NONE";
121 }
122
123 //Single-Event-Per-File modes:
124 if (!m_d->singleEventSource.isEmpty()&&!m_d->singleEventLocalTmpDir.isEmpty()) {
125 const bool httpmode = m_d->singleEventSource.startsWith("http://") || m_d->singleEventSource.startsWith("https://") ;
126 if (httpmode) {
127 QUrl url(m_d->singleEventSource);
128 if (!url.isValid()||url.path().isEmpty()) {
129 //Fixme: check that path ends with a filename!
130 VP1Msg::message("VP1ExecutionScheduler::init ERROR: Source URL ("+m_d->singleEventSource+") incorrect format!");
131 return false;
132 }
133
134 // For the https mode check if the platform supports SSL
135 if(m_d->singleEventSource.startsWith("https://")
136#ifndef QT_NO_SSL
137 && ! (QSslSocket::supportsSsl()) ) {
138#else
139 ) {
140#endif
141 VP1Msg::message("VP1ExecutionScheduler::init ERROR: Unable to retrieve events over Https. The platform does not support SSL");
142 return false;
143 }
144 } else {
145 QFileInfo fi_s(m_d->singleEventSource), fi_l(m_d->singleEventLocalTmpDir);
146 if (!fi_s.exists()||!fi_s.isDir()||!fi_s.isReadable()) {
147 VP1Msg::message("ERROR: Source directory ("+m_d->singleEventSource+") does not exist, is not readable, or is not a directory!");
148 return false;
149 }
150 if (!fi_l.exists()||!fi_l.isDir()||!fi_l.isReadable()||!fi_l.isWritable()) {
151 VP1Msg::message("ERROR: Local tmp directory ("+m_d->singleEventLocalTmpDir+") does not exist, had incorrect permissions, or is not a directory!");
152 return false;
153 }
154 if (fi_l.canonicalFilePath()==fi_s.canonicalFilePath()) {
155 VP1Msg::message("ERROR: Local tmp directory ("+m_d->singleEventLocalTmpDir+") is the same the source directory ("+m_d->singleEventSource+")");
156 return false;
157 }
158 }
159 } else {
160 if (!m_d->singleEventSource.isEmpty()||!m_d->singleEventLocalTmpDir.isEmpty()) {
161 VP1Msg::message("ERROR: Only one of SourceDir and LocalCopyDir set. Set either both or none.");
162 return false;
163 }
164 }
165
166 if (m_d->localFileCacheLimit==1||m_d->localFileCacheLimit==2) {
167 VP1Msg::message("WARNING: Too low value of localFileCacheLimit. Setting to 3. (Set to 0 to disable removal of locally cached files.");
168 m_d->localFileCacheLimit=3;
169 }
170
171 return true;
172}
173
174//____________________________________________________________________
176{
177 return m_d->the_scheduler != 0;
178}
179
180//____________________________________________________________________
182{
183 VP1Msg::messageDebug("Start of VP1Gui::init()...");
184
185 assert(!m_d->the_scheduler&&"Dont init twice!!");
186 VP1Msg::message("");
187 VP1Msg::message("===================================================");
188 VP1Msg::message(" Launching the VP1 GUI");
189 VP1Msg::message("===================================================");
190 VP1Msg::message("");
191 m_d->the_scheduler = VP1ExecutionScheduler::init(m_d->sg,
192 m_d->detstore,
193 m_d->svclocator,
194 m_d->toolSvc,
195 m_d->initialvp1files,
196 m_d->initialCruiseMode,m_d->initialCruiseSeconds,
197 m_d->singleEventSource,m_d->singleEventLocalTmpDir,
198 m_d->localFileCacheLimit,
199 m_d->availableLocalInputDirectories);
200
201 VP1Msg::messageDebug("end of VP1Gui::init().");
202}
203
204//____________________________________________________________________
206{
207 assert(m_d->the_scheduler&&"Cant cleanup before init");
208 VP1ExecutionScheduler::cleanup(m_d->the_scheduler);
209}
210
211//____________________________________________________________________
212bool VP1Gui::executeNewEvent( const int& run, const uint64_t& event, const unsigned& triggerType, const unsigned& time )
213{
214 VP1Msg::messageDebug("Examining new event ( run# "+QString::number(run)+", event# "+QString::number(event)+" )");
215
216 bool b = m_d->the_scheduler->executeNewEvent(run,event,triggerType,time);
217
218 // NOTE:
219 // we will go on to the lines here below
220 // only when the user clicks on the "Next event" button.
221
222 VP1Msg::messageDebug("Leaving event ( run# "+QString::number(run)+", event# "+QString::number(event)+" )"
223 +(nextRequestedEventFile().empty()?QString(""):". Next requested event file: "+QString(nextRequestedEventFile().c_str())));
224
225 VP1Msg::messageDebug("end of VP1Gui::executeNewEvent().");
226
227 return b;
228}
229
230//____________________________________________________________________
232{
233 return m_d->the_scheduler->nextRequestedEventFile().toStdString();
234}
235
236//____________________________________________________________________
237std::vector<std::string> VP1Gui::userRequestedFiles()
238{
239 std::vector<std::string> retvector;
240 if(m_d->the_scheduler) {
241 const QStringList& inplist = m_d->the_scheduler->userRequestedFiles();
242 for(int i=0; i<inplist.size(); ++i)
243 retvector.push_back(inplist.at(i).toStdString());
244 }
245 return retvector;
246}
static const Attributes_t empty
The Athena Transient Store API.
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())
static void cleanup(VP1ExecutionScheduler *)
QStringList availableLocalInputDirectories
Definition VP1Gui.cxx:51
QString singleEventLocalTmpDir
Definition VP1Gui.cxx:49
StoreGateSvc * sg
Definition VP1Gui.cxx:41
unsigned localFileCacheLimit
Definition VP1Gui.cxx:50
unsigned initialCruiseSeconds
Definition VP1Gui.cxx:47
QString initialCruiseMode
Definition VP1Gui.cxx:46
ISvcLocator * svclocator
Definition VP1Gui.cxx:43
QStringList initialvp1files
Definition VP1Gui.cxx:45
StoreGateSvc * detstore
Definition VP1Gui.cxx:42
QString singleEventSource
Definition VP1Gui.cxx:48
IToolSvc * toolSvc
Definition VP1Gui.cxx:44
VP1ExecutionScheduler * the_scheduler
Definition VP1Gui.cxx:38
bool argumentsAreValid() const
Definition VP1Gui.cxx:92
std::string nextRequestedEventFile() const
Definition VP1Gui.cxx:231
std::vector< std::string > userRequestedFiles()
Definition VP1Gui.cxx:237
void init()
Definition VP1Gui.cxx:181
VP1Gui(StoreGateSvc *sg, StoreGateSvc *detstore, ISvcLocator *svclocator, IToolSvc *toolSvc, const std::vector< std::string > &initialvp1files=std::vector< std::string >(), const std::string &initialCruiseMode="NONE", unsigned initialCruiseSeconds=10, const std::string &singleEventSource="", const std::string &singleEventLocalTmpDir="", unsigned localFileCacheLimit=10, const std::vector< std::string > &availableLocalInputDirectories=std::vector< std::string >())
Definition VP1Gui.cxx:56
~VP1Gui()
Definition VP1Gui.cxx:86
bool hasBeenInitialised()
Definition VP1Gui.cxx:175
void cleanup()
Definition VP1Gui.cxx:205
bool executeNewEvent(const int &run, const uint64_t &event, const unsigned &triggerType=0, const unsigned &time=0)
Definition VP1Gui.cxx:212
Imp * m_d
Definition VP1Gui.h:72
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
Definition run.py:1