ATLAS Offline Software
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 
14 #include "VP1Base/VP1Serialise.h"
15 #include "VP1Base/VP1Deserialise.h"
16 #include "VP1Base/VP1Msg.h"
19 
21 
22 
23 #define MAX_OBJECTS_PER_TECHNOLOGY 3000
24 
26 {
27 public:
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"),
54  m_clockwork(new Clockwork())
55 {
56 }
57 
59 {
60  delete m_clockwork;
61  m_clockwork = 0;
62 }
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()));
84  }
85 
86  return controller;
87 }
88 
90 {
91 }
92 
93 void 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  }
118 
123 
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 
155 {
156 }
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 
185 void VP1HVLegoSystem::userPickedNode(SoNode* /*pickedNode*/, SoPath */*pickedPath*/)
186 {
187 }
188 
190 {
192  VP1Serialise serialise(1/*version*/,this);
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  }
221  IVP13DSystemSimple::restoreFromState(state.restoreByteArray());
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
VP1Serialise.h
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
VP1HVLegoSystem::restoreFromState
void restoreFromState(QByteArray ba)
Definition: VP1HVLegoSystem.cxx:209
VP1Deserialise.h
VP1Serialise
Definition: VP1Serialise.h:45
IVP13DSystemSimple
Definition: IVP13DSystemSimple.h:24
RoiUtil::serialise
void serialise(const std::vector< const IRoiDescriptor * > &rois, roiserial_type &s)
serialise an entire vector of IRoiDescriptors
Definition: RoiSerialise.cxx:45
VP1HVLegoSystem::saveState
QByteArray saveState()
Definition: VP1HVLegoSystem.cxx:189
VP1JobConfigInfo::ensureInit
static void ensureInit(IVP1System *)
Definition: VP1JobConfigInfo.h:30
LArElectrodeID
Helper for the Liquid Argon Calorimeter cell at the electrode level.
Definition: LArElectrodeID.h:101
VP1Msg.h
VP1JobConfigInfo::hasTileGeometry
static bool hasTileGeometry()
Definition: VP1JobConfigInfo.cxx:133
VP1JobConfigInfo::hasLArGeometry
static bool hasLArGeometry()
Definition: VP1JobConfigInfo.cxx:132
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
VP1HVLegoSystem::Clockwork::emecSwitch
SoSwitch * emecSwitch[4]
Definition: VP1HVLegoSystem.cxx:40
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:396
VP1HVLegoSystem::userPickedNode
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
Definition: VP1HVLegoSystem.cxx:185
VP1HVLegoSystem::buildController
QWidget * buildController()
Definition: VP1HVLegoSystem.cxx:64
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
VP1HVLegoSystem::~VP1HVLegoSystem
~VP1HVLegoSystem()
Definition: VP1HVLegoSystem.cxx:58
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
IVP1System::state
State state() const
Definition: IVP1System.cxx:129
VP1HVLegoSystem::Clockwork
Definition: VP1HVLegoSystem.cxx:26
IVP1System::saveState
virtual QByteArray saveState()
Definition: IVP1System.cxx:294
LArElectrodeID::electrode
int electrode(const HWIdentifier id) const
Return an integer corresponding to the electrode number of an hardware electrode identifier.
Definition: LArElectrodeID.h:398
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
lumiFormat.i
int i
Definition: lumiFormat.py:85
VP1HVLegoSystem::systemcreate
void systemcreate(StoreGateSvc *detstore)
Definition: VP1HVLegoSystem.cxx:89
VP1HVLegoSystem::Clockwork::fcalSwitch
SoSwitch * fcalSwitch[3]
Definition: VP1HVLegoSystem.cxx:38
LArElectrodeID::zside
int zside(const HWIdentifier id) const
Return an integer corresponding to the side of an hardware electrode identifier.
Definition: LArElectrodeID.h:367
VP1HVLegoSystem.h
LArElectrodeID::module
int module(const HWIdentifier id) const
Return an integer corresponding to the module of an hardware electrode identifier.
Definition: LArElectrodeID.h:374
VP1HVLegoSystem::buildEventSceneGraph
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
Definition: VP1HVLegoSystem.cxx:154
IVP13DSystemSimple::ensureBuildController
void ensureBuildController()
Definition: IVP13DSystemSimple.cxx:90
VP1Deserialise
Definition: VP1Deserialise.h:44
VP1HVLegoSystem::Clockwork::switchMap
QMap< QString, SoSwitch * > switchMap
Definition: VP1HVLegoSystem.cxx:32
VP1HVLegoSystem::Clockwork::checkBoxMap
QMap< QString, QCheckBox * > checkBoxMap
Definition: VP1HVLegoSystem.cxx:36
LArElectrodeID::detector
int detector(const HWIdentifier id) const
Return an integer corresponding to the detector of an hardware electrode identifier.
Definition: LArElectrodeID.h:361
VP1HVLegoSystem::buildPermanentSceneGraph
void buildPermanentSceneGraph(StoreGateSvc *detstore, SoSeparator *root)
Definition: VP1HVLegoSystem.cxx:93
LArElectrodeID::gap
int gap(const HWIdentifier id) const
Return an integer corresponding to the cell gap of an hardware electrode identifier.
Definition: LArElectrodeID.h:392
VP1HVLegoSystem::VP1HVLegoSystem
VP1HVLegoSystem()
Definition: VP1HVLegoSystem.cxx:52
LArElectrodeID::hv_eta
int hv_eta(const HWIdentifier id) const
Return an integer corresponding to the high volatge eta sector of an hardware electrode identifier.
Definition: LArElectrodeID.h:386
VP1HVLegoSystem::Clockwork::checkBoxNamesMap
QMap< QCheckBox *, QString > checkBoxNamesMap
Definition: VP1HVLegoSystem.cxx:35
VP1HVLegoSystem::checkboxChanged
void checkboxChanged()
Definition: VP1HVLegoSystem.cxx:158
VP1HVLegoSystem::m_clockwork
Clockwork * m_clockwork
Definition: VP1HVLegoSystem.h:37
VP1HVLegoSystem::Clockwork::hecSwitch
SoSwitch * hecSwitch[4]
Definition: VP1HVLegoSystem.cxx:39
LArElectrodeID::electrode_end
std::vector< HWIdentifier >::const_iterator electrode_end(void) const
Definition: LArElectrodeID.h:354
LArElectrodeID::electrode_begin
std::vector< HWIdentifier >::const_iterator electrode_begin(void) const
Return an iterator pointing to a collection of electrode identifiers.
Definition: LArElectrodeID.h:348
LArElectrodeID::hv_phi
int hv_phi(const HWIdentifier id) const
Return an integer corresponding to the high voltage phi sector of an hardware electrode identifier.
Definition: LArElectrodeID.h:380
VP1HVLegoSystem::Clockwork::embSwitch
SoSwitch * embSwitch[4]
Definition: VP1HVLegoSystem.cxx:41
VP1JobConfigInfo.h
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
LArElectrodeID.h
VP1SGAccessHelper
Definition: VP1SGAccessHelper.h:25
VP1SGAccessHelper.h
IVP1System::message
void message(const QString &) const
Definition: IVP1System.cxx:336
IVP1System::controllerWidget
QWidget * controllerWidget()
Definition: IVP1System.cxx:202
IVP1System::restoreFromState
virtual void restoreFromState(QByteArray)
Definition: IVP1System.cxx:302