ATLAS Offline Software
Loading...
Searching...
No Matches
VP1CaloHitLegoSystem.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_calohitlegocontrollerform.h"
7
13
16
17#include <Inventor/nodes/SoSwitch.h>
18#include <Inventor/nodes/SoSeparator.h>
19#include <Inventor/nodes/SoTranslation.h>
20#include <Inventor/nodes/SoCube.h>
21
22#include <QMap>
23
25{
26public:
27
28 QMap<QString,SoSwitch*> switchMap;
29 QMap<QString,QCheckBox*> checkBoxMap;
30 QMap<QCheckBox*,QString> checkBoxNamesMap;
31
32 SoSwitch *fcalSwitch[3]{}; // FCAL
33 SoSwitch *hecSwitch[4]{}; // HEC
34 SoSwitch *emecSwitch[4]{}; // EMEC
35 SoSwitch *embSwitch[4]{}; // EMB
36
37 double lowThresholdEnergy = 0.0;
38 double highThresholdEnergy = 0.0;
39 double larEnergyScale = 0.0;
40};
41
43 :IVP13DSystemSimple("CaloHitLego","Display the calorimeter hits in an eta-phi view","boudreau@pitt.edu"),
45{
46 m_clockwork->lowThresholdEnergy=500;
47 m_clockwork->highThresholdEnergy=1000000;
48 m_clockwork->larEnergyScale=0.0002;
49}
50
56
58{
59 QWidget* controller = new QWidget(0);
60 Ui::frmCaloHitLegoController ui;
61 ui.setupUi(controller);
62
65 controller->setEnabled(false);
66 }
67
68 // Populate Check Box Names Map
69 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMB0, "EMB0");
70 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMB1, "EMB1");
71 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMB2, "EMB2");
72 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMB3, "EMB3");
73 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMEC0,"EMEC0");
74 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMEC1,"EMEC1");
75 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMEC2,"EMEC2");
76 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMEC3,"EMEC3");
77 m_clockwork->checkBoxNamesMap.insert(ui.chbxHEC0, "HEC0");
78 m_clockwork->checkBoxNamesMap.insert(ui.chbxHEC1, "HEC1");
79 m_clockwork->checkBoxNamesMap.insert(ui.chbxHEC2, "HEC2");
80 m_clockwork->checkBoxNamesMap.insert(ui.chbxHEC3, "HEC3");
81
82 // Populate Check Box Map and connect slots
83 for(QCheckBox* cb : m_clockwork->checkBoxNamesMap.keys())
84 {
85 connect(cb,SIGNAL(toggled(bool)),this,SLOT(checkboxChanged()));
86 m_clockwork->checkBoxMap.insert(m_clockwork->checkBoxNamesMap[cb],cb);
87 }
88
89 return controller;
90}
91
93{
95 return;
96
97 for (int i=0;i<3;i++) {
98 m_clockwork->fcalSwitch[i]->removeAllChildren();
99 m_clockwork->fcalSwitch[i]->unref();
100 m_clockwork->fcalSwitch[i]=0;
101 }
102
103 for (int i=0;i<4;i++) {
104 m_clockwork->embSwitch[i]->removeAllChildren();
105 m_clockwork->embSwitch[i]->unref();
106 m_clockwork->embSwitch[i]=0;
107 m_clockwork->emecSwitch[i]->removeAllChildren();
108 m_clockwork->emecSwitch[i]->unref();
109 m_clockwork->emecSwitch[i]=0;
110 m_clockwork->hecSwitch[i]->removeAllChildren();
111 m_clockwork->hecSwitch[i]->unref();
112 m_clockwork->hecSwitch[i]=0;
113 }
114
115}
116
118{
120 return;
121
122 for (int i=0;i<3;i++) {
123 m_clockwork->fcalSwitch[i] = new SoSwitch();
124 m_clockwork->fcalSwitch[i]->ref();
125 }
126
127 for (int i=0;i<4;i++) {
128 m_clockwork->embSwitch[i] = new SoSwitch();
129 m_clockwork->embSwitch[i]->ref();
130 m_clockwork->emecSwitch[i] = new SoSwitch();
131 m_clockwork->emecSwitch[i]->ref();
132 m_clockwork->hecSwitch[i] = new SoSwitch();
133 m_clockwork->hecSwitch[i]->ref();
134 }
135 m_clockwork->switchMap["EMB0"] = m_clockwork->embSwitch[0];
136 m_clockwork->switchMap["EMB1"] = m_clockwork->embSwitch[1];
137 m_clockwork->switchMap["EMB2"] = m_clockwork->embSwitch[2];
138 m_clockwork->switchMap["EMB3"] = m_clockwork->embSwitch[3];
139
140 m_clockwork->switchMap["EMEC0"] = m_clockwork->emecSwitch[0];
141 m_clockwork->switchMap["EMEC1"] = m_clockwork->emecSwitch[1];
142 m_clockwork->switchMap["EMEC2"] = m_clockwork->emecSwitch[2];
143 m_clockwork->switchMap["EMEC3"] = m_clockwork->emecSwitch[3];
144
145 m_clockwork->switchMap["HEC0"] = m_clockwork->hecSwitch[0];
146 m_clockwork->switchMap["HEC1"] = m_clockwork->hecSwitch[1];
147 m_clockwork->switchMap["HEC2"] = m_clockwork->hecSwitch[2];
148 m_clockwork->switchMap["HEC3"] = m_clockwork->hecSwitch[3];
149}
150
151void VP1CaloHitLegoSystem::buildPermanentSceneGraph(StoreGateSvc* /*detStore*/, SoSeparator */*root*/)
152{
153}
154
155
157{
160 return;
161
162 for (int i=0; i<3; i++)
163 m_clockwork->fcalSwitch[i]->removeAllChildren();
164 for (int i=0; i<4; i++) {
165 m_clockwork->embSwitch[i]->removeAllChildren();
166 m_clockwork->emecSwitch[i]->removeAllChildren();
167 m_clockwork->hecSwitch[i]->removeAllChildren();
168 }
169}
170
172{
175 return;
176 const CaloCellContainer * p_calocells;
177 QString key = "AllCalo";
179 if(VP1SGAccessHelper(this).retrieve(p_calocells,key)) {
180 for(CaloCellContainer::const_iterator i_cell=p_calocells->begin(); i_cell!=p_calocells->end(); ++i_cell) {
181 double energy = (*i_cell)->energy();
182 // Cannot draw object if it has no Calo DDE
183 const EMBDetectorElement *embElement = dynamic_cast<const EMBDetectorElement *> ((*i_cell)->caloDDE());
184 if (embElement) {
185 bool overThresh=(energy>=m_clockwork->lowThresholdEnergy) && (energy<=m_clockwork->highThresholdEnergy);
186 if (overThresh) {
187
188 EMBCellConstLink cellPtr = (const_cast<EMBDetectorElement *> (embElement))->getEMBCell();
189 double phiMin = cellPtr->getPhiLocalLower();
190 double phiMax = cellPtr->getPhiLocalUpper();
191 double etaMin = cellPtr->getEtaMin();
192 double etaMax = cellPtr->getEtaMax();
193
194 if (cellPtr->getEndcapIndex()==0) {
195 phiMin = M_PI-phiMin;
196 phiMax = M_PI-phiMax;
197 etaMin = -etaMin;
198 etaMax = -etaMax;
199 }
200 double height = energy*fabs(1.0/cosh((etaMin+etaMax)/2.0))*m_clockwork->larEnergyScale;
201 SoCube *cube = new SoCube();
202 SoTranslation *translation = new SoTranslation();
203 translation->translation.setValue((etaMax+etaMin)/2.0, (phiMax+phiMin)/2.0, height/2.0);
204 cube->width=(fabs(etaMax-etaMin));
205 cube->height=(fabs(phiMax-phiMin));
206 cube->depth=height;
207 SoSeparator *sep = new SoSeparator();
208 sep->addChild(translation);
209 sep->addChild(cube);
210 m_clockwork->embSwitch[cellPtr->getSamplingIndex()]->addChild(sep);
211
212 }
213 }
214 const EMECDetectorElement *emecElement = dynamic_cast<const EMECDetectorElement *> ((*i_cell)->caloDDE());
215 if (emecElement) {
216 bool overThresh=(energy>=m_clockwork->lowThresholdEnergy) && (energy<=m_clockwork->highThresholdEnergy);
217 if (overThresh) {
218
219 EMECCellConstLink cellPtr = (const_cast<EMECDetectorElement *> (emecElement))->getEMECCell();
220 double phiMin = cellPtr->getPhiLocalLower();
221 double phiMax = cellPtr->getPhiLocalUpper();
222 double etaMin = cellPtr->getEtaMin();
223 double etaMax = cellPtr->getEtaMax();
224
225 if (cellPtr->getEndcapIndex()==0) {
226 phiMin = M_PI-phiMin;
227 phiMax = M_PI-phiMax;
228 etaMin = -etaMin;
229 etaMax = -etaMax;
230 }
231 double height = energy*fabs(1.0/cosh((etaMin+etaMax)/2.0))*m_clockwork->larEnergyScale;
232 SoCube *cube = new SoCube();
233 SoTranslation *translation = new SoTranslation();
234 translation->translation.setValue((etaMax+etaMin)/2.0, (phiMax+phiMin)/2.0, height/2);
235 cube->width=(fabs(etaMax-etaMin));
236 cube->height=(fabs(phiMax-phiMin));
237 cube->depth=height;
238 SoSeparator *sep = new SoSeparator();
239 sep->addChild(translation);
240 sep->addChild(cube);
241 m_clockwork->emecSwitch[cellPtr->getSamplingIndex()]->addChild(sep);
242
243 }
244 }
245 const HECDetectorElement *hecElement = dynamic_cast<const HECDetectorElement *> ((*i_cell)->caloDDE());
246 if (hecElement) {
247 bool overThresh=(energy>=m_clockwork->lowThresholdEnergy) && (energy<=m_clockwork->highThresholdEnergy);
248 if (overThresh) {
249
250 HECCellConstLink cellPtr = (const_cast<HECDetectorElement *> (hecElement))->getHECCell();
251 double phiMin = cellPtr->getPhiLocalLower();
252 double phiMax = cellPtr->getPhiLocalUpper();
253 double etaMin = cellPtr->getEtaMinNominal();
254 double etaMax = cellPtr->getEtaMaxNominal();
255
256 if (cellPtr->getEndcapIndex()==0) {
257 phiMin = M_PI-phiMin;
258 phiMax = M_PI-phiMax;
259 etaMin = -etaMin;
260 etaMax = -etaMax;
261 }
262 double height = energy*fabs(1.0/cosh((etaMin+etaMax)/2.0))*m_clockwork->larEnergyScale;
263 SoCube *cube = new SoCube();
264 SoTranslation *translation = new SoTranslation();
265 translation->translation.setValue((etaMax+etaMin)/2.0, (phiMax+phiMin)/2.0, height/2);
266 cube->width=(fabs(etaMax-etaMin));
267 cube->height=(fabs(phiMax-phiMin));
268 cube->depth=height;
269 SoSeparator *sep = new SoSeparator();
270 sep->addChild(translation);
271 sep->addChild(cube);
272 m_clockwork->hecSwitch[cellPtr->getSamplingIndex()]->addChild(sep);
273
274 }
275 }
276 }
277 }
278 }
279
280 for (int i=0;i<3;i++)
281 root->addChild(m_clockwork->fcalSwitch[i]);
282 for (int i=0;i<4;i++) {
283 root->addChild(m_clockwork->embSwitch[i]);
284 root->addChild(m_clockwork->emecSwitch[i]);
285 root->addChild(m_clockwork->hecSwitch[i]);
286 }
287}
288
290{
292 return;
293 // Get ChB pointer
294 QCheckBox* cb = dynamic_cast<QCheckBox*>(sender());
295 if(cb && m_clockwork->checkBoxNamesMap.contains(cb))
296 {
297 // Get technology name
298 QString swName = m_clockwork->checkBoxNamesMap[cb];
299
300 if(m_clockwork->switchMap.contains(swName))
301 {
302 // Get swtich
303 SoSwitch* sw = m_clockwork->switchMap[swName];
304 if(cb->isChecked())
305 {
306 sw->whichChild = SO_SWITCH_ALL;
307 }
308 else
309 sw->whichChild = SO_SWITCH_NONE;
310 }
311 }
312}
313
314
315void VP1CaloHitLegoSystem::userPickedNode(SoNode* /*pickedNode*/, SoPath * /*pickedPath*/)
316{
317}
318
320{
322 VP1Serialise serialise(0/*version*/,this);
323 serialise.save(IVP13DSystemSimple::saveState());
324
325 //Checkboxes (by name for greater stability in case we change content of map):
326 QMapIterator<QString,QCheckBox*> it(m_clockwork->checkBoxMap);
327 QMap<QString,bool> checkboxstate;
328 while (it.hasNext()) {
329 it.next();
330 checkboxstate.insert(it.key(),it.value()->isChecked());
331 serialise.widgetHandled(it.value());
332 }
333 serialise.save(checkboxstate);
334
335 serialise.warnUnsaved(controllerWidget());
336 return serialise.result();
337}
338
340{
341 VP1Deserialise state(ba,this);
342 if (state.version()!=0) {
343 message("Warning: State data in .vp1 file is in wrong format - ignoring!");
344 return;
345 }
348
349 //Checkboxes (by name for greater stability in case we change content of map):
350 QMap<QString,bool> checkboxstate(state.restore<QMap<QString,bool> >());
351 QMapIterator<QString,QCheckBox*> it(m_clockwork->checkBoxMap);
352 while (it.hasNext()) {
353 it.next();
354 state.widgetHandled(it.value());
355 if (checkboxstate.contains(it.key())) {
356 bool checked = checkboxstate.value(it.key());
357 if (it.value()->isChecked()!=checked)
358 it.value()->setChecked(checked);
359 }
360 }
361
362 state.warnUnrestored(controllerWidget());
363}
364
365
366
367
#define M_PI
Calo Subsystem specific Detector Elements + Dummy element for testing.
Container class for CaloCell.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
LAr EMB Detector Element.
LAr EMEC Detector Element.
LAr HEC Detector Element.
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()
The Athena Transient Store API.
QMap< QCheckBox *, QString > checkBoxNamesMap
QMap< QString, QCheckBox * > checkBoxMap
QMap< QString, SoSwitch * > switchMap
void restoreFromState(QByteArray ba)
void buildPermanentSceneGraph(StoreGateSvc *detstore, SoSeparator *root)
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
void systemcreate(StoreGateSvc *detstore)
static bool hasTileGeometry()
static bool hasLArGeometry()
static void ensureInit(IVP1System *)
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114