ATLAS Offline Software
IVP1System.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class IVP1System //
9 // //
10 // Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
11 // //
12 // Initial version: April 2007 //
13 // //
15 
16 #include "VP1Base/IVP1System.h"
18 #include "VP1Base/VP1QtUtils.h"
19 #include "VP1Base/VP1Msg.h"
20 #include "VP1Base/VP1AthenaPtrs.h"
21 
22 #include <QApplication>
23 #include <QWidget>
24 
25 #include <cassert>
26 #include <iostream>
27 
28 const bool IVP1System::s_vp1verbose = VP1QtUtils::environmentVariableIsOn("VP1_VERBOSE_OUTPUT"); // TODO: is this used at all?
29 
31 public:
32  Imp(const QString & n, const QString & i, const QString & c)
35  controller(0),refreshing(false),
36  canregistercontroller(true) {}
37  const QString name;
38  const QString information;
39  const QString contact_info;
44  QWidget * controller;
45  bool refreshing;
47 };
48 
49 //________________________________________________________
50 const QString& IVP1System::name() const
51 {
52  return m_d->name;
53 }
54 
55 //________________________________________________________
56 const QString& IVP1System::information() const
57 {
58  return m_d->information;
59 }
60 
61 //________________________________________________________
62 const QString& IVP1System::contact_info() const
63 {
64  return m_d->contact_info;
65 }
66 
67 //________________________________________________________
68 IVP1System::IVP1System(const QString & n, const QString & i, const QString & c)
69  : m_d(new Imp(n,i,c))
70 {
71  if (VP1Msg::verbose()){
72  messageVerbose("IVP1System()");
73  }
74  setObjectName("IVP1System:"+n);
75 
76 }
77 
78 //________________________________________________________
80 {
81  if (VP1Msg::verbose()){
82  messageVerbose("IVP1System() Destructor. Start...");
83  }
84 
85  assert(m_d->state==UNCREATED||m_d->state==CONSTRUCTED);
86  assert(!m_d->controller);
87 
88  delete m_d;
89  m_d=nullptr;
90  VP1Msg::messageDebug("IVP1System() Destructor. END.");
91 }
92 
93 //_______________________________________________________
95 {
96  if (VP1Msg::verbose()) {
97  messageVerbose("setChannel ");
98  messageVerbose("setChannel m_d->state==CONSTRUCTED = "+QString(m_d->state==CONSTRUCTED?"true":"false"));
99  messageVerbose("setChannel cw!=0 = "+QString(cw!=0?"true":"false"));
100  }
101  assert(!m_d->channel);
102  assert(cw);
103  assert(m_d->state==CONSTRUCTED);
104  m_d->channel = cw;
105 }
106 
107 //________________________________________________________
109 {
110  return m_d->refreshing;
111 }
112 
113 //________________________________________________________
114 void IVP1System::setRefreshing(const bool& b)
115 {
116  if (VP1Msg::verbose()){
117  messageVerbose("setRefreshing() called with b="+QString(b?"true":"false"));
118  }
119  if (b) {
120  assert(m_d->state==ERASED);
121  } else {
122  assert(m_d->state==REFRESHED);
123  }
124  m_d->refreshing = b;
125 }
126 
127 
128 //________________________________________________________
130 {
131  return m_d->state;
132 }
133 
134 //________________________________________________________
136 {
137  return m_d->activeState;
138 }
139 
140 //________________________________________________________
142 {
143 #ifndef NDEBUG
144  assert (m_d->state != s);
145  assert(s!=CONSTRUCTED);
146  if (s==REFRESHED) {
147  assert(m_d->state==ERASED);
148  }
149  if (s==ERASED) {
150  assert(m_d->state==REFRESHED||m_d->state==CONSTRUCTED);
151  }
152  if (s==UNCREATED) {
153  assert(m_d->state==ERASED);
154  }
155 #endif
156  m_d->state = s;
157  if (s==REFRESHED||s==ERASED)
159 }
160 
161 //________________________________________________________
162 void IVP1System::setActiveState(const ActiveState&s,const bool& donttriggererase)
163 {
164  //First handle case where we dont actually change state. Only
165  //special consideration is OFF->OFF where we have to do something if
166  //we need to erase:
167  if (m_d->activeState==OFF&&s==OFF&&(m_d->state==REFRESHED||m_d->refreshing)&&!donttriggererase) {
168  needErase();
170  return;
171  } else if (m_d->activeState==s) {
173  return;
174  }
175 
176  //Ok, we know that we are either ON->OFF or OFF->ON.
177  m_d->activeState = s;
178 
179  if (s==ON) {
180  //OFF->ON: We might need a refresh, so send out a signal for the scheduler:
182  } else {
183  //ON->OFF: We might need an erase signal:
184  if ((m_d->state==REFRESHED||m_d->refreshing)&&!donttriggererase) {
185  needErase();
186  }
187  }
189 }
190 
191 //________________________________________________________
193 {
194  if (VP1Msg::verbose()) {
195  messageVerbose("uncreate() base implementation");
196  messageVerbose("registerController m_d->state==ERASED = "+QString(m_d->state==ERASED?"true":"false"));
197  }
198  assert(m_d->state==ERASED);
199 }
200 
201 //________________________________________________________
203  if (VP1Msg::verbose()) {
204  messageVerbose("controllerWidget()");
205  messageVerbose("registerController m_d->state==ERASED = "+QString(m_d->state==ERASED?"true":"false"));
206  messageVerbose("registerController m_d->state==REFRESHED = "+QString(m_d->state==REFRESHED?"true":"false"));
207  }
208  assert(m_d->state==REFRESHED||m_d->state==ERASED);
209  return m_d->controller;
210  }
211 
212 //_______________________________________________________
214 {
215  if (VP1Msg::verbose()){
216  messageVerbose("deleteController()");
217  }
218  if (m_d->controller)
219  m_d->controller->deleteLater();
220  m_d->controller = 0;
221 }
222 
223 //________________________________________________________
225 {
226  if (VP1Msg::verbose()) {
227  messageVerbose("registerController ");
228  messageVerbose("registerController m_d->canregistercontroller = "+QString(m_d->canregistercontroller?"true":"false"));
229  messageVerbose("registerController m_d->state==CONSTRUCTED = "+QString(m_d->state==CONSTRUCTED?"true":"false"));
230  messageVerbose("registerController m_d->controller==0 = "+QString(m_d->controller==0?"true":"false"));
231  messageVerbose("registerController w!=0 = "+QString(w!=0?"true":"false"));
232  }
234  message("ERROR: Please don't register controllers after create().");
235  if (m_d->state!=CONSTRUCTED)
236  message("ERROR: Please only register controllers in CONSTRUCTED state.");
237  if (!w) {
238  message("ERROR: Attempt to register null controller.");
239  return;
240  }
241  if (m_d->controller) {
242  message("ERROR: Attempt to register controller twice.");
243  return;
244  }
245  m_d->controller = w;
246  w->setParent(0);
247 }
248 
249 //________________________________________________________
251 {
252  m_d->allowupdategui=false;
253 }
254 
255 //________________________________________________________
257 {
258  m_d->allowupdategui=true;
259 }
260 
261 //________________________________________________________
263 // messageDebug("IVP1System::updateGUI() - START");
264  //assert(m_d->allowupdategui);
265  //assert(m_d->state==ERASED);
266 
267  if ( m_d->allowupdategui ) {
268  qApp->processEvents();
269  }
270 
271 // messageDebug("IVP1System::updateGUI() - END");
272 }
273 
274 //________________________________________________________
276 {
277  if (VP1Msg::verbose()&&!m_d->channel){
278  messageVerbose("WARNING channel() returning NULL");
279  }
280  assert(m_d->channel);
281  return m_d->channel;
282 }
283 
284 //_______________________________________________________
286 {
287  if (VP1Msg::verbose()){
288  messageVerbose("setCanRegisterController called with"+QString(c?"true":"false"));
289  }
291 }
292 
293 //_______________________________________________________
294 QByteArray IVP1System::saveState() {
295  if (VP1Msg::verbose()){
296  messageVerbose("base saveState called [IVP1System]");
297  }
298  return QByteArray();
299 }
300 
301 //_______________________________________________________
302 void IVP1System::restoreFromState(QByteArray ba)
303 {
304  if (VP1Msg::verbose()){
305  messageVerbose("base restoreFromState called");
306  }
307  if (!ba.isEmpty())
308  message("Error in IVP1System::restoreFromState: Received non-empty saved state.");
309 }
310 
311 //_______________________________________________________
313 {
314  return VP1AthenaPtrs::eventStore();
315 }
316 
317 //_______________________________________________________
319 {
321 }
322 
323 //_______________________________________________________
324 ISvcLocator * IVP1System::serviceLocator() const
325 {
327 }
328 
329 //_______________________________________________________
330 IToolSvc * IVP1System::toolSvc() const
331 {
332  return VP1AthenaPtrs::toolSvc();
333 }
334 
335 //_______________________________________________________
336 void IVP1System::message(const QString& str) const
337 {
338  if (receivers(SIGNAL(sysmessage(QString))) > 0){
339  sysmessage(str);
340  }
341  else{
342  std::cout<<VP1Msg::prefix_msg()<<" ["<<m_d->name.toStdString()<<"]: "<<str.toStdString()<<std::endl;
343  }
344 }
345 
346 //_______________________________________________________
347 void IVP1System::messageDebug(const QString& str) const
348 {
349  if (VP1Msg::debug())
350  std::cout<<VP1Msg::prefix_debug()<<" ["<<m_d->name.toStdString()<<"]: "<<str.toStdString()<<std::endl;
351 }
352 
353 //_______________________________________________________
354 void IVP1System::messageVerbose(const QString& str) const
355 {
356  if (VP1Msg::verbose())
357  std::cout<<VP1Msg::prefix_verbose()<<" ["<<m_d->name.toStdString()<<"]: "<<str.toStdString()<<std::endl;
358 }
359 
360 
361 //____________________________________________________________________
362 void IVP1System::message(const QStringList& l, const QString& addtoend ) const
363 {
364  if (addtoend.isEmpty()) {
365  for (QString s : l)
366  message(s);
367  } else {
368  for (QString s : l)
369  message(s+addtoend);
370  }
371 }
372 
373 //____________________________________________________________________
374 void IVP1System::messageDebug(const QStringList& l, const QString& addtoend ) const
375 {
376  if (addtoend.isEmpty()) {
377  for (QString s : l)
378  messageDebug(s);
379  } else {
380  for (QString s : l)
381  messageDebug(s+addtoend);
382  }
383 }
384 
385 //____________________________________________________________________
386 void IVP1System::messageVerbose(const QStringList& l, const QString& addtoend ) const
387 {
388  if (!VP1Msg::verbose())
389  return;
390  if (addtoend.isEmpty()) {
391  for (QString s : l)
392  messageVerbose(s);
393  } else {
394  for (QString s : l)
395  messageVerbose(s+addtoend);
396  }
397 }
398 
399 //____________________________________________________________________
400 void IVP1System::message(const QString& addtostart, const QStringList& l, const QString& addtoend ) const
401 {
402  if (addtostart.isEmpty()) {
403  message(l,addtoend);
404  return;
405  }
406  if (addtoend.isEmpty()) {
407  for (QString s : l)
408  message(addtostart+s);
409  } else {
410  for (QString s : l)
411  message(addtostart+s+addtoend);
412  }
413 }
414 
415 //____________________________________________________________________
416 void IVP1System::messageDebug(const QString& addtostart, const QStringList& l, const QString& addtoend ) const
417 {
418  if (addtostart.isEmpty()) {
419  messageDebug(l,addtoend);
420  return;
421  }
422  if (addtoend.isEmpty()) {
423  for (QString s : l)
424  messageDebug(addtostart+s);
425  } else {
426  for (QString s : l)
427  messageDebug(addtostart+s+addtoend);
428  }
429 }
430 
431 //____________________________________________________________________
432 void IVP1System::messageVerbose(const QString& addtostart, const QStringList& l, const QString& addtoend ) const
433 {
434  if (!VP1Msg::verbose())
435  return;
436  if (addtostart.isEmpty()) {
437  messageVerbose(l,addtoend);
438  return;
439  }
440  if (addtoend.isEmpty()) {
441  for (QString s : l)
442  messageVerbose(addtostart+s);
443  } else {
444  for (QString s : l)
445  messageVerbose(addtostart+s+addtoend);
446  }
447 }
448 
449 #ifdef BUILDVP1LIGHT
450 //____________________________________________________________________
451 xAOD::TEvent* IVP1System::getEvent(){
452  return m_event;
453 }
454 
455 void IVP1System::setEvent( xAOD::TEvent* event ){
456  m_event = event;
457 }
458 
459 //____________________________________________________________________
460 QStringList IVP1System::getObjectList(xAOD::Type::ObjectType type){
461  if( type == xAOD::Type::Vertex ) {
462 
463  message("(((((((((())))))))))))))))");
464  message(m_list[0]);
465  return m_list[0];
466  }
467  else if ( type == xAOD::Type::Other ) {
468  return m_list[1];
469  }
470  else if ( type == xAOD::Type::Jet ){
471  return m_list[2];
472  }
473  else if ( type == xAOD::Type::CaloCluster ) {
474  return m_list[3];
475  }
476  else if ( type == xAOD::Type::TrackParticle ) {
477  return m_list[4];
478  }
479  else if ( type == xAOD::Type::Muon ) {
480  return m_list[5];
481  }
482  else if ( type == xAOD::Type::Electron ) {
483  return m_list[6];
484  }
485  else {
486  message("Unknown xAOD type requested");
487  return QStringList {};
488  }
489 }
490 
491 void IVP1System::setObjectList(QList<QStringList> list){
492  m_list = list;
493 }
494 
495 
496 #endif // BUILDVP1LIGHT
IVP1System::Imp::contact_info
const QString contact_info
Definition: IVP1System.cxx:39
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition: Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
IVP1System::isRefreshing
bool isRefreshing()
Definition: IVP1System.cxx:108
ObjectType
ObjectType
Definition: BaseObject.h:11
IVP1System::setChannel
void setChannel(IVP1ChannelWidget *)
Definition: IVP1System.cxx:94
IVP1System::CONSTRUCTED
@ CONSTRUCTED
Definition: IVP1System.h:143
VP1Msg.h
IVP1System::information
const QString & information() const
Definition: IVP1System.cxx:56
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
IVP1System::uncreate
virtual void uncreate()
Definition: IVP1System.cxx:192
VP1QtUtils.h
IVP1System::m_d
Imp * m_d
Definition: IVP1System.h:130
IVP1System::setCanRegisterController
void setCanRegisterController(const bool &)
Definition: IVP1System.cxx:285
IVP1System::inactiveSystemTurnedActive
void inactiveSystemTurnedActive()
VP1Msg::debug
static bool debug()
Definition: VP1Msg.h:32
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
IVP1System::Imp::refreshing
bool refreshing
Definition: IVP1System.cxx:45
IVP1ChannelWidget::emitRefreshInfoChanged
void emitRefreshInfoChanged()
Definition: IVP1ChannelWidget.cxx:268
IVP1System::disallowUpdateGUI
void disallowUpdateGUI()
Definition: IVP1System.cxx:250
IVP1System::deleteController
void deleteController()
Definition: IVP1System.cxx:213
IVP1System::s_vp1verbose
static const bool s_vp1verbose
Definition: IVP1System.h:158
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
VP1AthenaPtrs.h
IVP1System::state
State state() const
Definition: IVP1System.cxx:129
IVP1System::saveState
virtual QByteArray saveState()
Definition: IVP1System.cxx:294
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
IVP1System::setRefreshing
void setRefreshing(const bool &)
Definition: IVP1System.cxx:114
IVP1System::needErase
void needErase()
IVP1System::activeState
ActiveState activeState() const
Definition: IVP1System.cxx:135
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
IVP1System::Imp
Definition: IVP1System.cxx:30
VP1Msg::prefix_msg
static const char * prefix_msg()
Definition: VP1Msg.h:56
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
IVP1System::Imp::information
const QString information
Definition: IVP1System.cxx:38
VP1QtUtils::environmentVariableIsOn
static bool environmentVariableIsOn(const QString &name)
Definition: VP1QtUtils.cxx:127
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
IVP1System::setState
void setState(const State &)
Definition: IVP1System.cxx:141
IVP1System::serviceLocator
ISvcLocator * serviceLocator() const
Definition: IVP1System.cxx:324
IVP1System::name
const QString & name() const
Definition: IVP1System.cxx:50
IVP1System::REFRESHED
@ REFRESHED
Definition: IVP1System.h:143
IVP1System::Imp::activeState
ActiveState activeState
Definition: IVP1System.cxx:43
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
IVP1System::allowUpdateGUI
void allowUpdateGUI()
Definition: IVP1System.cxx:256
IVP1System::Imp::allowupdategui
bool allowupdategui
Definition: IVP1System.cxx:41
IVP1System::contact_info
const QString & contact_info() const
Definition: IVP1System.cxx:62
IVP1System::UNCREATED
@ UNCREATED
Definition: IVP1System.h:143
IVP1System::eventStore
StoreGateSvc * eventStore() const
Definition: IVP1System.cxx:312
IVP1System::sysmessage
void sysmessage(QString) const
VP1AthenaPtrs::serviceLocator
static ISvcLocator * serviceLocator()
Definition: VP1AthenaPtrs.h:29
IVP1ChannelWidget
Definition: IVP1ChannelWidget.h:34
IVP1System::ON
@ ON
Definition: IVP1System.h:144
VP1AthenaPtrs::eventStore
static StoreGateSvc * eventStore()
Definition: VP1AthenaPtrs.h:27
IVP1System::State
State
Definition: IVP1System.h:143
IVP1System::channel
IVP1ChannelWidget * channel() const
Definition: IVP1System.cxx:275
IVP1System::messageDebug
void messageDebug(const QString &) const
Definition: IVP1System.cxx:347
IVP1System::detectorStore
StoreGateSvc * detectorStore() const
Definition: IVP1System.cxx:318
VP1AthenaPtrs::toolSvc
static IToolSvc * toolSvc()
Definition: VP1AthenaPtrs.h:30
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
IVP1System::Imp::controller
QWidget * controller
Definition: IVP1System.cxx:44
VP1Msg::prefix_debug
static const char * prefix_debug()
Definition: VP1Msg.h:57
IVP1System::registerController
void registerController(QWidget *)
Definition: IVP1System.cxx:224
IVP1System::toolSvc
IToolSvc * toolSvc() const
Definition: IVP1System.cxx:330
Muon
struct TBPatternUnitContext Muon
VP1Msg::prefix_verbose
static const char * prefix_verbose()
Definition: VP1Msg.h:59
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
IVP1System::updateGUI
void updateGUI()
Definition: IVP1System.cxx:262
IVP1System::Imp::channel
IVP1ChannelWidget * channel
Definition: IVP1System.cxx:40
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
IVP1System::ActiveState
ActiveState
Definition: IVP1System.h:144
str
Definition: BTagTrackIpAccessor.cxx:11
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
IVP1System::Imp::canregistercontroller
bool canregistercontroller
Definition: IVP1System.cxx:46
VP1AthenaPtrs::detectorStore
static StoreGateSvc * detectorStore()
Definition: VP1AthenaPtrs.h:28
IVP1System::~IVP1System
virtual ~IVP1System()
Definition: IVP1System.cxx:79
python.compressB64.c
def c
Definition: compressB64.py:93
IVP1System::Imp::Imp
Imp(const QString &n, const QString &i, const QString &c)
Definition: IVP1System.cxx:32
IVP1System::IVP1System
IVP1System(const QString &name, const QString &information, const QString &contact_info)
Definition: IVP1System.cxx:68
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
IVP1System.h
IVP1System::message
void message(const QString &) const
Definition: IVP1System.cxx:336
IVP1System::OFF
@ OFF
Definition: IVP1System.h:144
IVP1System::Imp::state
State state
Definition: IVP1System.cxx:42
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:81
IVP1System::messageVerbose
void messageVerbose(const QString &) const
Definition: IVP1System.cxx:354
IVP1System::ERASED
@ ERASED
Definition: IVP1System.h:143
IVP1System::Imp::name
const QString name
Definition: IVP1System.cxx:37
IVP1System::controllerWidget
QWidget * controllerWidget()
Definition: IVP1System.cxx:202
IVP1System::setActiveState
void setActiveState(const ActiveState &, const bool &donttriggererase=true)
Definition: IVP1System.cxx:162
IVP1ChannelWidget.h
IVP1System::restoreFromState
virtual void restoreFromState(QByteArray)
Definition: IVP1System.cxx:302