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) {
32  return;
34  lastEmitted_types=types;
36  theclass->messageVerbose("emitting entriesChanged(..) with "+str(keys.count())+" entries");
38  }
39 
40 };
41 
42 
43 //____________________________________________________________________
45  : IVP1System("Banks",
46  "System for browsing the contents of StoreGate",
47  "Joe Boudreau <boudreau@pitt.edu> (original), Thomas.Kittelmann@cern.ch (VP1 implementation)"),
48  m_d(new Imp(this))
49 {
50  m_d->ui.radioButton_store_event = 0;
51  m_d->ui.radioButton_store_detector = 0;
52  m_d->ui.pushButton_refresh = 0;
53 }
54 
55 
56 //____________________________________________________________________
58 {
59  delete m_d; m_d=0;
60 }
61 
62 //____________________________________________________________________
63 QString VP1BanksSystem::Imp::idToName( const CLID& id ) const
64 {
65  if (!clidSvc)
66  return "";
67  std::string n;
68  if (clidSvc->getTypeNameOfID(id, n).isFailure())
69  return "<unknown>";
70  return n.c_str();
71 }
72 
73 //____________________________________________________________________
75 {
76  return ui.radioButton_store_event && !ui.radioButton_store_event->isChecked();
77 }
78 
79 
80 //____________________________________________________________________
81 void VP1BanksSystem::create( StoreGateSvc* /*detstore*/ )
82 {
83  QWidget * controller = new QWidget;
84  m_d->ui.setupUi(controller);
85  connect(m_d->ui.radioButton_store_event,SIGNAL(toggled(bool)),this,SLOT(refreshList()));
86  connect(m_d->ui.pushButton_refresh,SIGNAL(clicked()),this,SLOT(refreshList()));
87  registerController(controller);
88 
89  ISvcLocator* svcLoc = serviceLocator();
90  if (!svcLoc) {
91  message("Error: Got NULL pointer to the service locator!");
92  return;
93  }
94 
95  m_d->clidSvc = svcLoc->service( "ClassIDSvc" );
96  if(!m_d->clidSvc) {
97  message("Error: Could not retrieve ClassIDSvc!!");
98  return;
99  }
100 
101 
102 }
103 
104 //____________________________________________________________________
106 {
107  m_d->allowRefresh = true;
108  refreshList();
109 }
110 
111 //____________________________________________________________________
113 {
114  if (!m_d->allowRefresh)
115  return;
116  messageVerbose("Refreshing list for "+QString(m_d->useDetStore()?"detector":"event")+" store");
117 
118  QStringList entry_key;
119  QStringList entry_type;
120  QStringList entry_id;
121 
122  VP1SGContentsHelper sgcont(this,m_d->useDetStore());
123 
124  int i(0);
125  for (CLID id : sgcont.getPossibleCLIDs()) {
126  QStringList keys = sgcont.getKeys(id);
127  if (!keys.isEmpty()) {
128  QString typeName = m_d->idToName(id);
129  QString idstr = QString::number(id);
130  for (const QString& key : keys) {
131  entry_key << key;
132  entry_type << typeName;
133  entry_id << idstr;
134  }
135  }
136  if (!i++%20)
137  updateGUI();
138  }
139  m_d->emitIfChanged(entry_key,entry_type,entry_id);
140 }
141 
142 //____________________________________________________________________
144 {
145  m_d->allowRefresh = false;
146  m_d->emitIfChanged(QStringList(),QStringList(),QStringList());
147 }
148 
149 
150 //____________________________________________________________________
152 {
153  VP1Serialise serialise(0/*version*/,this);
154  serialise.save(IVP1System::saveState());//Info from base class
155 
156  serialise.save(m_d->ui.radioButton_store_event,m_d->ui.radioButton_store_detector);
157 
158  serialise.warnUnsaved(controllerWidget());
159  return serialise.result();
160 
161 }
162 
163 //____________________________________________________________________
165 {
166  VP1Deserialise state(ba,this);
167  if (state.version()!=0) {
168  message("Warning: State data in .vp1 file is in wrong format - ignoring!");
169  return;
170  }
171  IVP1System::restoreFromState(state.restoreByteArray());
172 
173  state.restore(m_d->ui.radioButton_store_event,m_d->ui.radioButton_store_detector);
174 
175  state.warnUnrestored(controllerWidget());
176 }
VP1Serialise.h
VP1BanksSystem::refreshList
void refreshList()
Definition: VP1BanksSystem.cxx:112
VP1BanksSystem::Imp::allowRefresh
bool allowRefresh
Definition: VP1BanksSystem.cxx:20
VP1BanksSystem::Imp
Definition: VP1BanksSystem.cxx:15
VP1BanksSystem::Imp::emitIfChanged
void emitIfChanged(const QStringList &keys, const QStringList &types, const QStringList &ids)
Definition: VP1BanksSystem.cxx:30
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:81
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP1BanksSystem::Imp::useDetStore
bool useDetStore()
Definition: VP1BanksSystem.cxx:74
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:63
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::VP1BanksSystem
VP1BanksSystem()
Definition: VP1BanksSystem.cxx:44
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:57
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:164
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:105
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:151
VP1SGContentsHelper.h
VP1BanksSystem::erase
void erase()
Definition: VP1BanksSystem.cxx:143
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