ATLAS Offline Software
VP1BanksSystem.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "ui_vp1bankscontroller.h"
8 #include "VP1Base/VP1Serialise.h"
10 
11 #include "GaudiKernel/IClassIDSvc.h"
12 #include "GaudiKernel/ISvcLocator.h"
13 
14 //____________________________________________________________________
16 public:
17  Imp(VP1BanksSystem*tc) : theclass(tc), allowRefresh(false), clidSvc(0) {}
19  bool useDetStore();
21  Ui::VP1BanksSystemControllerForm ui{};
22 
23  QString idToName(const CLID&) const;
24  SmartIF<IClassIDSvc> clidSvc;
25 
26  QStringList lastEmitted_keys;
27  QStringList lastEmitted_types;
28  QStringList lastEmitted_ids;
29 
30  // void emitIfChanged(const QStringList& keys, const QStringList& types, const QStringList& ids) {
31  void emitIfChanged(QStringList keys, QStringList types, QStringList ids) {
33  return;
35  lastEmitted_types=types;
37  theclass->messageVerbose("emitting entriesChanged(..) with "+str(keys.count())+" entries");
39  }
40 
41 };
42 
43 
44 //____________________________________________________________________
46  : IVP1System("Banks",
47  "System for browsing the contents of StoreGate",
48  "Joe Boudreau <boudreau@pitt.edu> (original), Thomas.Kittelmann@cern.ch (VP1 implementation)"),
49  m_d(new Imp(this))
50 {
51  m_d->ui.radioButton_store_event = 0;
52  m_d->ui.radioButton_store_detector = 0;
53  m_d->ui.pushButton_refresh = 0;
54 }
55 
56 
57 //____________________________________________________________________
59 {
60  delete m_d; m_d=0;
61 }
62 
63 //____________________________________________________________________
64 QString VP1BanksSystem::Imp::idToName( const CLID& id ) const
65 {
66  if (!clidSvc)
67  return "";
68  std::string n;
69  if (clidSvc->getTypeNameOfID(id, n).isFailure())
70  return "<unknown>";
71  return n.c_str();
72 }
73 
74 //____________________________________________________________________
76 {
77  return ui.radioButton_store_event && !ui.radioButton_store_event->isChecked();
78 }
79 
80 
81 //____________________________________________________________________
82 void VP1BanksSystem::create( StoreGateSvc* /*detstore*/ )
83 {
84  QWidget * controller = new QWidget;
85  m_d->ui.setupUi(controller);
86  connect(m_d->ui.radioButton_store_event,SIGNAL(toggled(bool)),this,SLOT(refreshList()));
87  connect(m_d->ui.pushButton_refresh,SIGNAL(clicked()),this,SLOT(refreshList()));
88  registerController(controller);
89 
90  ISvcLocator* svcLoc = serviceLocator();
91  if (!svcLoc) {
92  message("Error: Got NULL pointer to the service locator!");
93  return;
94  }
95 
96  m_d->clidSvc = svcLoc->service( "ClassIDSvc" );
97  if(!m_d->clidSvc) {
98  message("Error: Could not retrieve ClassIDSvc!!");
99  return;
100  }
101 
102 
103 }
104 
105 //____________________________________________________________________
107 {
108  m_d->allowRefresh = true;
109  refreshList();
110 }
111 
112 //____________________________________________________________________
114 {
115  if (!m_d->allowRefresh)
116  return;
117  messageVerbose("Refreshing list for "+QString(m_d->useDetStore()?"detector":"event")+" store");
118 
119  QStringList entry_key;
120  QStringList entry_type;
121  QStringList entry_id;
122 
123  VP1SGContentsHelper sgcont(this,m_d->useDetStore());
124 
125  int i(0);
126  for (CLID id : sgcont.getPossibleCLIDs()) {
127  QStringList keys = sgcont.getKeys(id);
128  if (!keys.isEmpty()) {
129  QString typeName = m_d->idToName(id);
130  QString idstr = QString::number(id);
131  for (QString key : keys) {
132  entry_key << key;
133  entry_type << typeName;
134  entry_id << idstr;
135  }
136  }
137  if (!i++%20)
138  updateGUI();
139  }
140  m_d->emitIfChanged(entry_key,entry_type,entry_id);
141 }
142 
143 //____________________________________________________________________
145 {
146  m_d->allowRefresh = false;
147  m_d->emitIfChanged(QStringList(),QStringList(),QStringList());
148 }
149 
150 
151 //____________________________________________________________________
153 {
154  VP1Serialise serialise(0/*version*/,this);
155  serialise.save(IVP1System::saveState());//Info from base class
156 
157  serialise.save(m_d->ui.radioButton_store_event,m_d->ui.radioButton_store_detector);
158 
159  serialise.warnUnsaved(controllerWidget());
160  return serialise.result();
161 
162 }
163 
164 //____________________________________________________________________
166 {
167  VP1Deserialise state(ba,this);
168  if (state.version()!=0) {
169  message("Warning: State data in .vp1 file is in wrong format - ignoring!");
170  return;
171  }
172  IVP1System::restoreFromState(state.restoreByteArray());
173 
174  state.restore(m_d->ui.radioButton_store_event,m_d->ui.radioButton_store_detector);
175 
176  state.warnUnrestored(controllerWidget());
177 }
VP1Serialise.h
VP1BanksSystem::refreshList
void refreshList()
Definition: VP1BanksSystem.cxx:113
VP1BanksSystem::Imp::allowRefresh
bool allowRefresh
Definition: VP1BanksSystem.cxx:20
VP1BanksSystem::Imp
Definition: VP1BanksSystem.cxx:15
VP1Deserialise.h
VP1Serialise
Definition: VP1Serialise.h:45
RoiUtil::serialise
void serialise(const std::vector< const IRoiDescriptor * > &rois, roiserial_type &s)
serialise an entire vector of IRoiDescriptors
Definition: RoiSerialise.cxx:45
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
VP1BanksSystem::create
void create(StoreGateSvc *detstore)
Definition: VP1BanksSystem.cxx:82
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP1BanksSystem::Imp::useDetStore
bool useDetStore()
Definition: VP1BanksSystem.cxx:75
VP1BanksSystem::Imp::clidSvc
SmartIF< IClassIDSvc > clidSvc
Definition: VP1BanksSystem.cxx:24
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
VP1BanksSystem::m_d
Imp * m_d
Definition: VP1BanksSystem.h:43
VP1BanksSystem::Imp::lastEmitted_keys
QStringList lastEmitted_keys
Definition: VP1BanksSystem.cxx:26
IVP1System::state
State state() const
Definition: IVP1System.cxx:129
IVP1System::saveState
virtual QByteArray saveState()
Definition: IVP1System.cxx:294
VP1SGContentsHelper::getKeys
QStringList getKeys() const
Definition: VP1SGContentsHelper.h:55
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
IVP1System
Definition: IVP1System.h:36
VP1BanksSystem::Imp::idToName
QString idToName(const CLID &) const
Definition: VP1BanksSystem.cxx:64
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
IVP1System::serviceLocator
ISvcLocator * serviceLocator() const
Definition: IVP1System.cxx:324
VP1BanksSystem::Imp::Imp
Imp(VP1BanksSystem *tc)
Definition: VP1BanksSystem.cxx:17
VP1BanksSystem::Imp::lastEmitted_types
QStringList lastEmitted_types
Definition: VP1BanksSystem.cxx:27
VP1BanksSystem::Imp::emitIfChanged
void emitIfChanged(QStringList keys, QStringList types, QStringList ids)
Definition: VP1BanksSystem.cxx:31
VP1BanksSystem::VP1BanksSystem
VP1BanksSystem()
Definition: VP1BanksSystem.cxx:45
VP1Deserialise
Definition: VP1Deserialise.h:44
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
VP1BanksSystem::~VP1BanksSystem
virtual ~VP1BanksSystem()
Definition: VP1BanksSystem.cxx:58
VP1BanksSystem.h
python.selection.number
number
Definition: selection.py:20
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
VP1BanksSystem::Imp::theclass
VP1BanksSystem * theclass
Definition: VP1BanksSystem.cxx:18
VP1BanksSystem::Imp::lastEmitted_ids
QStringList lastEmitted_ids
Definition: VP1BanksSystem.cxx:28
VP1SGContentsHelper
Definition: VP1SGContentsHelper.h:26
IVP1System::registerController
void registerController(QWidget *)
Definition: IVP1System.cxx:224
VP1BanksSystem::restoreFromState
void restoreFromState(QByteArray)
Definition: VP1BanksSystem.cxx:165
IVP1System::updateGUI
void updateGUI()
Definition: IVP1System.cxx:262
VP1BanksSystem::entriesChanged
void entriesChanged(const QStringList &entry_key, const QStringList &entry_type, const QStringList &entry_id)
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
VP1SGContentsHelper::getPossibleCLIDs
QList< CLID > getPossibleCLIDs() const
Definition: VP1SGContentsHelper.cxx:113
IVP1System::message
void message(const QString &) const
Definition: IVP1System.cxx:336
VP1BanksSystem::refresh
void refresh(StoreGateSvc *storegate)
Definition: VP1BanksSystem.cxx:106
IVP1System::messageVerbose
void messageVerbose(const QString &) const
Definition: IVP1System.cxx:354
VP1BanksSystem::Imp::ui
Ui::VP1BanksSystemControllerForm ui
Definition: VP1BanksSystem.cxx:21
VP1BanksSystem::saveState
QByteArray saveState()
Definition: VP1BanksSystem.cxx:152
VP1SGContentsHelper.h
VP1BanksSystem::erase
void erase()
Definition: VP1BanksSystem.cxx:144
IVP1System::controllerWidget
QWidget * controllerWidget()
Definition: IVP1System.cxx:202
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
IVP1System::restoreFromState
virtual void restoreFromState(QByteArray)
Definition: IVP1System.cxx:302
VP1BanksSystem
Definition: VP1BanksSystem.h:21