ATLAS Offline Software
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 //____________________________________________________________________
29 class VP1Gui::Imp {
30 public:
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)
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 
167  VP1Msg::message("WARNING: Too low value of localFileCacheLimit. Setting to 3. (Set to 0 to disable removal of locally cached files.");
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("");
192  m_d->detstore,
193  m_d->svclocator,
194  m_d->toolSvc,
200 
201  VP1Msg::messageDebug("end of VP1Gui::init().");
202 }
203 
204 //____________________________________________________________________
206 {
207  assert(m_d->the_scheduler&&"Cant cleanup before init");
209 }
210 
211 //____________________________________________________________________
212 bool 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 
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 //____________________________________________________________________
237 std::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 }
VP1Gui::Imp::singleEventLocalTmpDir
QString singleEventLocalTmpDir
Definition: VP1Gui.cxx:49
VP1ExecutionScheduler::nextRequestedEventFile
const QString & nextRequestedEventFile() const
Definition: VP1ExecutionScheduler.cxx:578
VP1Gui::Imp::sg
StoreGateSvc * sg
Definition: VP1Gui.cxx:41
VP1Gui::Imp::the_scheduler
VP1ExecutionScheduler * the_scheduler
Definition: VP1Gui.cxx:38
VP1Gui::VP1Gui
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::Imp::toolSvc
IToolSvc * toolSvc
Definition: VP1Gui.cxx:44
VP1Gui::Imp::initialCruiseSeconds
unsigned initialCruiseSeconds
Definition: VP1Gui.cxx:47
VP1ExecutionScheduler.h
VP1Gui::m_d
Imp * m_d
Definition: VP1Gui.h:71
VP1Msg.h
VP1Gui.h
VP1Gui::cleanup
void cleanup()
Definition: VP1Gui.cxx:205
VP1Gui::init
void init()
Definition: VP1Gui.cxx:181
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
skel.it
it
Definition: skel.GENtoEVGEN.py:396
VP1Gui::executeNewEvent
bool executeNewEvent(const int &run, const uint64_t &event, const unsigned &triggerType=0, const unsigned &time=0)
Definition: VP1Gui.cxx:212
VP1Gui::Imp::singleEventSource
QString singleEventSource
Definition: VP1Gui.cxx:48
empty
bool empty(TH1 *h)
Definition: computils.cxx:295
physics_parameters.url
string url
Definition: physics_parameters.py:27
VP1Gui::Imp::detstore
StoreGateSvc * detstore
Definition: VP1Gui.cxx:42
TruthTest.itE
itE
Definition: TruthTest.py:25
VP1ExecutionScheduler::init
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())
Definition: VP1ExecutionScheduler.cxx:350
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
VP1ExecutionScheduler::userRequestedFiles
QStringList userRequestedFiles()
Definition: VP1ExecutionScheduler.cxx:1373
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:85
VP1Gui::Imp
Definition: VP1Gui.cxx:29
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
VP1Gui::Imp::availableLocalInputDirectories
QStringList availableLocalInputDirectories
Definition: VP1Gui.cxx:51
run
Definition: run.py:1
VP1Gui::hasBeenInitialised
bool hasBeenInitialised()
Definition: VP1Gui.cxx:175
VP1ExecutionScheduler
Definition: VP1ExecutionScheduler.h:42
python.selection.number
number
Definition: selection.py:20
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1Gui::Imp::initialvp1files
QStringList initialvp1files
Definition: VP1Gui.cxx:45
VP1Gui::userRequestedFiles
std::vector< std::string > userRequestedFiles()
Definition: VP1Gui.cxx:237
VP1Gui::Imp::localFileCacheLimit
unsigned localFileCacheLimit
Definition: VP1Gui.cxx:50
VP1Gui::Imp::Imp
Imp()
Definition: VP1Gui.cxx:31
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
RunTileMonitoring.triggerType
triggerType
Definition: RunTileMonitoring.py:162
VP1Gui::argumentsAreValid
bool argumentsAreValid() const
Definition: VP1Gui.cxx:92
VP1Gui::nextRequestedEventFile
std::string nextRequestedEventFile() const
Definition: VP1Gui.cxx:231
VP1Gui::Imp::svclocator
ISvcLocator * svclocator
Definition: VP1Gui.cxx:43
VP1Gui::Imp::initialCruiseMode
QString initialCruiseMode
Definition: VP1Gui.cxx:46
VP1ExecutionScheduler::cleanup
static void cleanup(VP1ExecutionScheduler *)
Definition: VP1ExecutionScheduler.cxx:506
VP1Gui::~VP1Gui
~VP1Gui()
Definition: VP1Gui.cxx:86
VP1ExecutionScheduler::executeNewEvent
bool executeNewEvent(const int &runnumber, const unsigned long long &eventnumber, const unsigned &triggerType=0, const unsigned &time=0)
Definition: VP1ExecutionScheduler.cxx:590