ATLAS Offline Software
Loading...
Searching...
No Matches
VP1HVLegoSystem.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "ui_hvlegocontrollerform.h"
7
8#include <QMap>
9
10#include <Inventor/nodes/SoSwitch.h>
11#include <Inventor/nodes/SoSeparator.h>
12#include <Inventor/nodes/SoTranslation.h>
13
16#include "VP1Base/VP1Msg.h"
19
21
22
23#define MAX_OBJECTS_PER_TECHNOLOGY 3000
24
26{
27public:
28 // Switches:
29 // 1. EMB0-3
30 // 2. EMEC0-3
31 // 3. HEC0-3
32 QMap<QString,SoSwitch*> switchMap;
33
34 // Two maps for controller check boxes
35 QMap<QCheckBox*,QString> checkBoxNamesMap;
36 QMap<QString,QCheckBox*> checkBoxMap;
37
38 SoSwitch *fcalSwitch[3]{}; // FCAL
39 SoSwitch *hecSwitch[4]{}; // HEC
40 SoSwitch *emecSwitch[4]{}; // EMEC
41 SoSwitch *embSwitch[4]{}; // EMB
42
43
44 // std::map < SoNode *, const FCALTile *> TileMap;
45 // std::map < SoNode *, HECCellConstLink> HECMap;
46 // std::map < SoNode *, EMECCellConstLink> EMECMap;
47 // std::map < SoNode *, EMBCellConstLink> EMBMap;
48
49
50};
51
53 :IVP13DSystemSimple("HVLego","Display the readout in an eta-phi view","boudreau@pitt.edu"),
55{
56}
57
63
65{
66 QWidget* controller = new QWidget(0);
67 Ui::frmHVLegoController ui;
68 ui.setupUi(controller);
69
72 controller->setEnabled(false);
73 }
74
75 // Populate Check Box Names Map
76 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMB, "EMB");
77 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMEC, "EMEC");
78
79 // Populate Check Box Map and connect slots
80 for(QCheckBox* cb : m_clockwork->checkBoxNamesMap.keys())
81 {
82 connect(cb,SIGNAL(toggled(bool)),this,SLOT(checkboxChanged()));
83 m_clockwork->checkBoxMap.insert(m_clockwork->checkBoxNamesMap[cb],cb);
84 }
85
86 return controller;
87}
88
92
93void VP1HVLegoSystem::buildPermanentSceneGraph(StoreGateSvc */*detStore*/, SoSeparator *root) {
94
97 return;
98
99 for (int i=0;i<3;i++) {
100 m_clockwork->fcalSwitch[i] = new SoSwitch();
101 root->addChild(m_clockwork->fcalSwitch[i]);
102 }
103
104 for (int i=0;i<4;i++) {
105 m_clockwork->embSwitch[i] = new SoSwitch();
106 root->addChild(m_clockwork->embSwitch[i]);
107
108 m_clockwork->emecSwitch[i] = new SoSwitch();
109 root->addChild(m_clockwork->emecSwitch[i]);
110
111 m_clockwork->hecSwitch[i] = new SoSwitch();
112 root->addChild(m_clockwork->hecSwitch[i]);
113 }
114 m_clockwork->switchMap["EMB0"] = m_clockwork->embSwitch[0];
115 m_clockwork->switchMap["EMB1"] = m_clockwork->embSwitch[1];
116 m_clockwork->switchMap["EMB2"] = m_clockwork->embSwitch[2];
117 m_clockwork->switchMap["EMB3"] = m_clockwork->embSwitch[3];
118
119 m_clockwork->switchMap["EMEC0"] = m_clockwork->emecSwitch[0];
120 m_clockwork->switchMap["EMEC1"] = m_clockwork->emecSwitch[1];
121 m_clockwork->switchMap["EMEC2"] = m_clockwork->emecSwitch[2];
122 m_clockwork->switchMap["EMEC3"] = m_clockwork->emecSwitch[3];
123
124 m_clockwork->switchMap["HEC0"] = m_clockwork->hecSwitch[0];
125 m_clockwork->switchMap["HEC1"] = m_clockwork->hecSwitch[1];
126 m_clockwork->switchMap["HEC2"] = m_clockwork->hecSwitch[2];
127 m_clockwork->switchMap["HEC3"] = m_clockwork->hecSwitch[3];
128
129
130 const LArElectrodeID* elecId(0);
131 if (!VP1SGAccessHelper(this,true/*detectorstore*/).retrieve(elecId, "LArElectrodeID")) {
132 message("ERROR: Cannot access LArElectrodeID");
133 }
134 else {
135 if (VP1Msg::verbose()) {
136 std::vector<HWIdentifier>::const_iterator begin=elecId->electrode_begin(), end=elecId->electrode_end(), e;
137 for (e=begin;e!=end;++e) {
138 if (elecId->detector(*e) ==0) {
139 std::cout << elecId->detector(*e) << ' '
140 << elecId->zside(*e) << ' '
141 << elecId->module(*e) << ' '
142 << elecId->hv_phi(*e) << ' '
143 << elecId->hv_eta(*e) << ' '
144 << elecId->gap(*e) << ' '
145 << elecId->electrode(*e) << std::endl;
146 }
147 }
148 }
149 }
150
151}
152
153
157
159{
160
162 return;
163 // Get ChB pointer
164 QCheckBox* cb = dynamic_cast<QCheckBox*>(sender());
165 if(cb && m_clockwork->checkBoxNamesMap.contains(cb))
166 {
167 // Get technology name
168 QString swName = m_clockwork->checkBoxNamesMap[cb];
169
170 if(m_clockwork->switchMap.contains(swName))
171 {
172 // Get switch
173 SoSwitch* sw = m_clockwork->switchMap[swName];
174 if(cb->isChecked())
175 {
176 sw->whichChild = SO_SWITCH_ALL;
177 }
178 else
179 sw->whichChild = SO_SWITCH_NONE;
180 }
181 }
182}
183
184
185void VP1HVLegoSystem::userPickedNode(SoNode* /*pickedNode*/, SoPath */*pickedPath*/)
186{
187}
188
190{
192 VP1Serialise serialise(1/*version*/,this);
193 serialise.save(IVP13DSystemSimple::saveState());
194
195 //Checkboxes (by name for greater stability in case we change content of map):
196 QMapIterator<QString,QCheckBox*> it(m_clockwork->checkBoxMap);
197 QMap<QString,bool> checkboxstate;
198 while (it.hasNext()) {
199 it.next();
200 checkboxstate.insert(it.key(),it.value()->isChecked());
201 serialise.widgetHandled(it.value());
202 }
203 serialise.save(checkboxstate);
204
205 serialise.warnUnsaved(controllerWidget());
206 return serialise.result();
207}
208
210{
211 VP1Deserialise state(ba,this);
212 if (state.version()==0) {
213 message("Warning: State data in .vp1 file has obsolete format - ignoring!");
214 return;
215 }
216 if (state.version()!=1) {
217 message("Warning: State data in .vp1 file is in wrong format - ignoring!");
218 return;
219 }
222
223 //Checkboxes (by name for greater stability in case we change content of map):
224 QMap<QString,bool> checkboxstate(state.restore<QMap<QString,bool> >());
225 QMapIterator<QString,QCheckBox*> it(m_clockwork->checkBoxMap);
226 while (it.hasNext()) {
227 it.next();
228 state.widgetHandled(it.value());
229 if (checkboxstate.contains(it.key())) {
230 bool checked = checkboxstate.value(it.key());
231 if (it.value()->isChecked()!=checked)
232 it.value()->setChecked(checked);
233 }
234 }
235
236 state.warnUnrestored(controllerWidget());
237}
IVP13DSystemSimple(const QString &name, const QString &information, const QString &contact_info)
virtual void restoreFromState(QByteArray)
State state() const
QWidget * controllerWidget()
void message(const QString &) const
virtual QByteArray saveState()
Helper for the Liquid Argon Calorimeter cell at the electrode level.
std::vector< HWIdentifier >::const_iterator electrode_begin() const
Return an iterator pointing to a collection of electrode identifiers.
int hv_eta(const HWIdentifier id) const
Return an integer corresponding to the high volatge eta sector of an hardware electrode identifier.
int zside(const HWIdentifier id) const
Return an integer corresponding to the side of an hardware electrode identifier.
int gap(const HWIdentifier id) const
Return an integer corresponding to the cell gap of an hardware electrode identifier.
std::vector< HWIdentifier >::const_iterator electrode_end() const
int electrode(const HWIdentifier id) const
Return an integer corresponding to the electrode number of an hardware electrode identifier.
int detector(const HWIdentifier id) const
Return an integer corresponding to the detector of an hardware electrode identifier.
int hv_phi(const HWIdentifier id) const
Return an integer corresponding to the high voltage phi sector of an hardware electrode identifier.
The Athena Transient Store API.
QMap< QString, QCheckBox * > checkBoxMap
QMap< QString, SoSwitch * > switchMap
QMap< QCheckBox *, QString > checkBoxNamesMap
void systemcreate(StoreGateSvc *detstore)
QWidget * buildController()
void buildPermanentSceneGraph(StoreGateSvc *detstore, SoSeparator *root)
Clockwork * m_clockwork
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
void restoreFromState(QByteArray ba)
QByteArray saveState()
static bool hasTileGeometry()
static bool hasLArGeometry()
static void ensureInit(IVP1System *)
static bool verbose()
Definition VP1Msg.h:31