ATLAS Offline Software
Loading...
Searching...
No Matches
VP1CaloLegoSystem.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "ui_calolegocontrollerform.h"
7
8#include <QMap>
9
10#include <Inventor/nodes/SoSwitch.h>
11#include <Inventor/nodes/SoSeparator.h>
12#include <Inventor/nodes/SoCube.h>
13#include <Inventor/nodes/SoMaterial.h>
14#include <Inventor/nodes/SoTranslation.h>
15#include <Inventor/nodes/SoLineSet.h>
16#include <Inventor/nodes/SoLightModel.h>
17#include <Inventor/nodes/SoDrawStyle.h>
18
21
24
27
30
34#include "VP1Utils/VP1DetInfo.h"
36
37#define MAX_OBJECTS_PER_TECHNOLOGY 3000
38
40{
41public:
42 // Switches:
43 // 1. EMB0-3
44 // 2. EMEC0-3
45 // 3. HEC0-3
46 QMap<QString,SoSwitch*> switchMap;
47
48 // Two maps for controller check boxes
49 QMap<QCheckBox*,QString> checkBoxNamesMap;
50 QMap<QString,QCheckBox*> checkBoxMap;
51
52 SoSwitch *fcalSwitch[3]{}; // FCAL
53 SoSwitch *hecSwitch[4]{}; // HEC
54 SoSwitch *emecSwitch[4]{}; // EMEC
55 SoSwitch *embSwitch[4]{}; // EMB
56
57
58 std::map < SoNode *, const FCALTile *> TileMap;
59 std::map < SoNode *, HECCellConstLink> HECMap;
60 std::map < SoNode *, EMECCellConstLink> EMECMap;
61 std::map < SoNode *, EMBCellConstLink> EMBMap;
62
63 SoSeparator * dummyCubeSep = nullptr;
64 SoSeparator * root = nullptr;
65
66};
67
69 :IVP13DSystemSimple("CaloLego","Display the readout in an eta-phi view","boudreau@pitt.edu"),
71{
72 m_clockwork->dummyCubeSep = 0;
73 m_clockwork->root = 0;
74}
75
81
83{
84 QWidget* controller = new QWidget(0);
85 Ui::frmCaloLegoController ui;
86 ui.setupUi(controller);
87
90 controller->setEnabled(false);
91 }
92
93 // Populate Check Box Names Map
94 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMB0, "EMB0");
95 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMB1, "EMB1");
96 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMB2, "EMB2");
97 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMB3, "EMB3");
98 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMEC0,"EMEC0");
99 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMEC1,"EMEC1");
100 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMEC2,"EMEC2");
101 m_clockwork->checkBoxNamesMap.insert(ui.chbxEMEC3,"EMEC3");
102 m_clockwork->checkBoxNamesMap.insert(ui.chbxHEC0, "HEC0");
103 m_clockwork->checkBoxNamesMap.insert(ui.chbxHEC1, "HEC1");
104 m_clockwork->checkBoxNamesMap.insert(ui.chbxHEC2, "HEC2");
105 m_clockwork->checkBoxNamesMap.insert(ui.chbxHEC3, "HEC3");
106
107 // Populate Check Box Map and connect slots
108 for(QCheckBox* cb : m_clockwork->checkBoxNamesMap.keys())
109 {
110 connect(cb,SIGNAL(toggled(bool)),this,SLOT(checkboxChanged()));
111 m_clockwork->checkBoxMap.insert(m_clockwork->checkBoxNamesMap[cb],cb);
112 }
113
114 return controller;
115}
116
120
122
125 return;
126
127 m_clockwork->root = root;
128
129 for (int i=0;i<3;i++) {
130 m_clockwork->fcalSwitch[i] = new SoSwitch();
131 root->addChild(m_clockwork->fcalSwitch[i]);
132 }
133
134 //We add a fully transparent dummy cube in order to get proper
135 //initial view (after first event we remove it again):
136 SoSeparator * dummyCubeSep = new SoSeparator;
137 dummyCubeSep->ref();
138 SoMaterial * dummyMat = new SoMaterial;
139 dummyMat->transparency = 1.0f;
140 SoTranslation * dummyTransl = new SoTranslation;
141 dummyTransl->translation.setValue(SbVec3f(0,3.15,0));
142 SoCube * dummyCube = new SoCube;
143 dummyCube->width = 6.7;
144 dummyCube->height = 6.3;
145 dummyCube->depth = 0.1;
146 dummyCubeSep->addChild(dummyMat);
147 dummyCubeSep->addChild(dummyTransl);
148 dummyCubeSep->addChild(dummyCube);
149 root->addChild(dummyCubeSep);
150
151 for (int i=0;i<4;i++) {
152 m_clockwork->embSwitch[i] = new SoSwitch();
153 root->addChild(m_clockwork->embSwitch[i]);
154
155 m_clockwork->emecSwitch[i] = new SoSwitch();
156 root->addChild(m_clockwork->emecSwitch[i]);
157
158 m_clockwork->hecSwitch[i] = new SoSwitch();
159 root->addChild(m_clockwork->hecSwitch[i]);
160 }
161 m_clockwork->switchMap["EMB0"] = m_clockwork->embSwitch[0];
162 m_clockwork->switchMap["EMB1"] = m_clockwork->embSwitch[1];
163 m_clockwork->switchMap["EMB2"] = m_clockwork->embSwitch[2];
164 m_clockwork->switchMap["EMB3"] = m_clockwork->embSwitch[3];
165
166 m_clockwork->switchMap["EMEC0"] = m_clockwork->emecSwitch[0];
167 m_clockwork->switchMap["EMEC1"] = m_clockwork->emecSwitch[1];
168 m_clockwork->switchMap["EMEC2"] = m_clockwork->emecSwitch[2];
169 m_clockwork->switchMap["EMEC3"] = m_clockwork->emecSwitch[3];
170
171 m_clockwork->switchMap["HEC0"] = m_clockwork->hecSwitch[0];
172 m_clockwork->switchMap["HEC1"] = m_clockwork->hecSwitch[1];
173 m_clockwork->switchMap["HEC2"] = m_clockwork->hecSwitch[2];
174 m_clockwork->switchMap["HEC3"] = m_clockwork->hecSwitch[3];
175
176 createEtaPhi();
177
178}
179
181{
182 if (m_clockwork->dummyCubeSep) {
183 if (m_clockwork->root->findChild(m_clockwork->dummyCubeSep)>=0)
184 m_clockwork->root->removeChild(m_clockwork->dummyCubeSep);
185 m_clockwork->dummyCubeSep->unref();
186 m_clockwork->dummyCubeSep = 0;
187 }
188
189}
190
192{
194 return;
195
196 m_clockwork->root->enableNotify(false);
197 for (int i=0;i<4;i++) {
198 if (i<3) {
199 m_clockwork->fcalSwitch[i]->enableNotify(false);
200 m_clockwork->fcalSwitch[i]->removeAllChildren();
201 }
202 m_clockwork->embSwitch[i]->enableNotify(false);
203 m_clockwork->emecSwitch[i]->enableNotify(false);
204 m_clockwork->hecSwitch[i]->enableNotify(false);
205 m_clockwork->embSwitch[i]->removeAllChildren();
206 m_clockwork->emecSwitch[i]->removeAllChildren();
207 m_clockwork->hecSwitch[i]->removeAllChildren();
208 }
209
210 m_clockwork->TileMap.clear();
211 m_clockwork->HECMap.clear();
212 m_clockwork->EMECMap.clear();
213 m_clockwork->EMBMap.clear();
214 m_clockwork->root->removeAllChildren();
215}
216
218
219 // Styles & cet:
220 SoDrawStyle *drawStyle = new SoDrawStyle();
221 drawStyle->lineWidth=1;
222 SoLightModel *lm = new SoLightModel();
223 lm->model=SoLightModel::BASE_COLOR;
224
225 SoMaterial *blue= new SoMaterial();
226 blue->diffuseColor.setValue(0,0,1);
227
228 SoMaterial *green= new SoMaterial();
229 green->diffuseColor.setValue(0 , 1, 0);
230
231 SoMaterial *yellow= new SoMaterial();
232 yellow->diffuseColor.setValue(0, 1.00, 1.00);
233
234 SoMaterial *magenta = new SoMaterial();
235 magenta->diffuseColor.setValue(1.00,0.00, 1.00);
236
237 for (int i=0;i<4;i++) {
238 if (i<3) {
239 m_clockwork->fcalSwitch[i]->addChild(drawStyle);
240 m_clockwork->fcalSwitch[i]->addChild(lm);
241 m_clockwork->fcalSwitch[i]->addChild(green);
242 }
243 m_clockwork->embSwitch[i]->addChild(drawStyle);
244 m_clockwork->emecSwitch[i]->addChild(drawStyle);
245 m_clockwork->hecSwitch[i]->addChild(drawStyle);
246 m_clockwork->embSwitch[i]->addChild(lm);
247 m_clockwork->emecSwitch[i]->addChild(lm);
248 m_clockwork->hecSwitch[i]->addChild(lm);
249 m_clockwork->embSwitch[i]->addChild(blue);
250 m_clockwork->emecSwitch[i]->addChild(magenta);
251 m_clockwork->hecSwitch[i]->addChild(yellow);
252 }
253
255
256 {
258
259 if (manager) {
261 for (e=manager->beginFCAL();e!=manager->endFCAL(); ++e) {
262
263 const FCALModule *fcalMod = *e;
264 SoSeparator *sep1 = new SoSeparator();
266
268 for (t=fcalMod->beginTiles();t!=fcalMod->endTiles();++t) {
269 double x = t->getX();
270 double y = t->getY();
271 double dx = fcalMod->getFullWidthX(*t)/2.0;
272 double dy = fcalMod->getFullWidthY(*t)/2.0;
273// double zf = fcalMod->getEndcapIndex()== 0 ? +fcalMod->getFullDepthZ(*t)/2.0 : -fcalMod->getFullDepthZ(*t)/2.0;
274// double zc = 0;
275// double zb = fcalMod->getEndcapIndex()== 0 ? -fcalMod->getFullDepthZ(*t)/2.0 : +fcalMod->getFullDepthZ(*t)/2.0;
276
277 int cc=0;
278 SoVertexProperty *vtxProperty = new SoVertexProperty();
279 vtxProperty->vertex.set1Value(cc++, SbVec3f(x-dx+3,y-dy+3 ,0));
280 vtxProperty->vertex.set1Value(cc++, SbVec3f(x+dx-3,y-dy+3, 0));
281 vtxProperty->vertex.set1Value(cc++, SbVec3f(x+dx-3,y+dy-3 ,0));
282 vtxProperty->vertex.set1Value(cc++, SbVec3f(x-dx+3,y+dy-3 ,0));
283 vtxProperty->vertex.set1Value(cc++, SbVec3f(x-dx+3,y-dy+3 ,0));
284
285 SoLineSet *ls = new SoLineSet();
286 ls->numVertices=5;
287 ls->vertexProperty=vtxProperty;
288 sep->addNode(ls);
289
290 m_clockwork->TileMap[ls]=&(*t);
291 }
292 int sp = fcalMod->getModuleIndex()-1;
293 m_clockwork->fcalSwitch[sp]->addChild(sep1);
294
295 }
296 }
297 }
298
299 {
301
302 if (manager) {
303
305 for (e=manager->beginDetectorRegion();e!=manager->endDetectorRegion(); ++e) {
306
307 const HECDetectorRegion *region=*e;
308 SoSeparator *sep1 = new SoSeparator();
310
311 for (unsigned int iPhi=region->beginPhiIndex();iPhi<region->endPhiIndex();iPhi++) {
312 for (unsigned int iEta=region->beginEtaIndex();iEta<region->endEtaIndex();iEta++) {
313 HECCellConstLink cellPtr = region->getHECCell(iEta,iPhi);
314 if (cellPtr) {
315
316 double phiMin = cellPtr->getPhiLocalLower();
317 double phiMax = cellPtr->getPhiLocalUpper();
318 double etaMin = cellPtr->getEtaMinNominal();
319 double etaMax = cellPtr->getEtaMaxNominal();
320
321 if (region->getEndcapIndex()==0) {
322 phiMin = M_PI-phiMin;
323 phiMax = M_PI-phiMax;
324 etaMin = -etaMin;
325 etaMax = -etaMax;
326 }
327
328 int cc=0;
329 SoVertexProperty *vtxProperty = new SoVertexProperty();
330 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMin,phiMin ,0));
331 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMin,phiMax ,0));
332 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMax,phiMax ,0));
333 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMax,phiMin ,0));
334 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMin,phiMin ,0));
335
336 SoLineSet *ls = new SoLineSet();
337 ls->numVertices=5;
338 ls->vertexProperty=vtxProperty;
339 sep->addNode(ls);
340
341 m_clockwork->HECMap[ls]=cellPtr;
342 }
343 }
344 }
345 m_clockwork->hecSwitch[region->getSamplingIndex()]->addChild(sep1);
346 }
347 }
348 }
349
350
351 {
353
354 if (manager) {
355
357 for (e=manager->beginDetectorRegion();e!=manager->endDetectorRegion(); ++e) {
358 const EMECDetectorRegion *region = *e;
359
360 // Then grid:
361
362
363 SoSeparator *sep1 = new SoSeparator();
365
366
367 for (unsigned int iPhi=region->beginPhiIndex();iPhi<region->endPhiIndex();iPhi++) {
368 for (unsigned int iEta=region->beginEtaIndex();iEta<region->endEtaIndex();iEta++) {
369
370
371
372 EMECCellConstLink cellPtr = (static_cast<const EMECDetectorRegion *> (region))->getEMECCell(iEta,iPhi);
373 double phiMin = cellPtr->getPhiLocalLower();
374 double phiMax = cellPtr->getPhiLocalUpper();
375 double etaMin = cellPtr->getEtaMin();
376 double etaMax = cellPtr->getEtaMax();
377
378 if (region->getEndcapIndex()==0) {
379 phiMin = M_PI-phiMin;
380 phiMax = M_PI-phiMax;
381 etaMin = -etaMin;
382 etaMax = -etaMax;
383 }
384
385 int cc=0;
386 SoVertexProperty *vtxProperty = new SoVertexProperty();
387 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMin,phiMin ,0));
388 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMin,phiMax ,0));
389 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMax,phiMax ,0));
390 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMax,phiMin ,0));
391 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMin,phiMin ,0));
392
393 SoLineSet *ls = new SoLineSet();
394 ls->numVertices=5;
395 ls->vertexProperty=vtxProperty;
396 sep->addNode(ls);
397 m_clockwork->EMECMap[ls]=cellPtr;
398 }
399 }
400 m_clockwork->emecSwitch[region->getSamplingIndex()]->addChild(sep1);
401 }
402 }
403 }
404 {
406
407 if (manager) {
408
410 for (e=manager->beginDetectorRegion();e!=manager->endDetectorRegion(); ++e) {
411 const EMBDetectorRegion *region = *e;
412 SoSeparator *sep1 = new SoSeparator();
414
415 for (unsigned int iPhi=region->beginPhiIndex();iPhi<region->endPhiIndex();iPhi++) {
416 for (unsigned int iEta=region->beginEtaIndex();iEta<region->endEtaIndex();iEta++) {
417
418
419 EMBCellConstLink cellPtr = (static_cast<const EMBDetectorRegion *> (region))->getEMBCell(iEta,iPhi);
420 double phiMin = cellPtr->getPhiLocalLower();
421 double phiMax = cellPtr->getPhiLocalUpper();
422 double etaMin = cellPtr->getEtaMin();
423 double etaMax = cellPtr->getEtaMax();
424
425 if (region->getEndcapIndex()==0) {
426 phiMin = M_PI-phiMin;
427 phiMax = M_PI-phiMax;
428 etaMin = -etaMin;
429 etaMax = -etaMax;
430 }
431
432 int cc=0;
433 SoVertexProperty *vtxProperty = new SoVertexProperty();
434 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMin,phiMin ,0));
435 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMin,phiMax ,0));
436 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMax,phiMax ,0));
437 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMax,phiMin ,0));
438 vtxProperty->vertex.set1Value(cc++, SbVec3f(etaMin,phiMin ,0));
439
440 SoLineSet *ls = new SoLineSet();
441 ls->numVertices=5;
442 ls->vertexProperty=vtxProperty;
443 sep->addNode(ls);
444 m_clockwork->EMBMap[ls]=cellPtr;
445 }
446 }
447 m_clockwork->embSwitch[region->getSamplingIndex()]->addChild(sep1);
448 }
449 }
450 }
451}
452
456
458{
460 return;
461
462 // Get ChB pointer
463 QCheckBox* cb = dynamic_cast<QCheckBox*>(sender());
464 if(cb && m_clockwork->checkBoxNamesMap.contains(cb))
465 {
466 // Get technology name
467 QString swName = m_clockwork->checkBoxNamesMap[cb];
468
469 if(m_clockwork->switchMap.contains(swName))
470 {
471 // Get switch
472 SoSwitch* sw = m_clockwork->switchMap[swName];
473 if(cb->isChecked())
474 {
475 sw->whichChild = SO_SWITCH_ALL;
476 }
477 else
478 sw->whichChild = SO_SWITCH_NONE;
479 }
480 }
481}
482
483
484void VP1CaloLegoSystem::userPickedNode(SoNode* /*pickedNode*/, SoPath */*pickedPath*/)
485{
486}
487
489{
491 VP1Serialise serialise(1/*version*/,this);
492 serialise.save(IVP13DSystemSimple::saveState());
493
494 //Checkboxes (by name for greater stability in case we change content of map):
495 QMapIterator<QString,QCheckBox*> it(m_clockwork->checkBoxMap);
496 QMap<QString,bool> checkboxstate;
497 while (it.hasNext()) {
498 it.next();
499 checkboxstate.insert(it.key(),it.value()->isChecked());
500 serialise.widgetHandled(it.value());
501 }
502 serialise.save(checkboxstate);
503
504 serialise.warnUnsaved(controllerWidget());
505 return serialise.result();
506}
507
509{
510 VP1Deserialise state(ba,this);
511 if (state.version()==0) {
512 message("Warning: State data in .vp1 file has obsolete format - ignoring!");
513 return;
514 }
515 if (state.version()!=1) {
516 message("Warning: State data in .vp1 file is in wrong format - ignoring!");
517 return;
518 }
521
522 //Checkboxes (by name for greater stability in case we change content of map):
523 QMap<QString,bool> checkboxstate(state.restore<QMap<QString,bool> >());
524 QMapIterator<QString,QCheckBox*> it(m_clockwork->checkBoxMap);
525 while (it.hasNext()) {
526 it.next();
527 state.widgetHandled(it.value());
528 if (checkboxstate.contains(it.key())) {
529 bool checked = checkboxstate.value(it.key());
530 if (it.value()->isChecked()!=checked)
531 it.value()->setChecked(checked);
532 }
533 }
534
535 state.warnUnrestored(controllerWidget());
536}
#define M_PI
static Double_t sp
#define y
#define x
A manager class providing access to readout geometry information for the electromagnetic barrel calor...
std::vector< constEMBDetectorRegion * >::const_iterator DetectorRegionConstIterator
unsigned int beginPhiIndex() const
Returns the first phi index in the region.
unsigned int getSamplingIndex() const
Returns the Sampling Layer Index.
EMBDetectorRegion::DetectorSide getEndcapIndex() const
The endcap index.
unsigned int beginEtaIndex() const
Returns the first eta index in the region.
A manager class providing access to readout geometry information for the electromagnetic endcap calor...
std::vector< constEMECDetectorRegion * >::const_iterator DetectorRegionConstIterator
unsigned int beginPhiIndex() const
returns the first phi index in the region.
EMECDetectorRegion::DetectorSide getEndcapIndex() const
The endcap index.
unsigned int getSamplingIndex() const
Returns the Sampling Layer Index.
unsigned int beginEtaIndex() const
returns the first eta index in the region.
A manager class providing access to readout geometry information for the forward calorimeter.
std::vector< constFCALModule * >::const_iterator ConstIterator
double getFullWidthY(const FCALTile &tile) const
Gets Tile Full Width in Y.
double getFullWidthX(const FCALTile &tile) const
Gets Tile Full Width in X.
std::vector< FCALTile >::const_iterator ConstIterator
Definition FCALModule.h:36
FCALModule::ConstIterator beginTiles() const
Iteration over FCAL Tiles.
FCALModule::Module getModuleIndex() const
Returns the Module (1,2, or 3)
FCALModule::ConstIterator endTiles() const
Iteration over FCAL Tiles.
A manager class providing access to readout geometry information for the hadronic endcap calorimeter.
std::vector< constHECDetectorRegion * >::const_iterator DetectorRegionConstIterator
Description of a region of homogenous granularity in the hadronic endcap calorimeter.
HECCellConstLink getHECCell(unsigned int ieta, unsigned int iphi) const
Retrieve a cell with eta index and phi index.
unsigned int beginPhiIndex() const
returns the first phi index in the region.
unsigned int getSamplingIndex() const
Returns the Sampling Layer Index (0-3)
unsigned int beginEtaIndex() const
returns the first eta index in the region.
HECDetectorRegion::DetectorSide getEndcapIndex() const
The endcap index.
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
std::map< SoNode *, EMBCellConstLink > EMBMap
std::map< SoNode *, EMECCellConstLink > EMECMap
std::map< SoNode *, const FCALTile * > TileMap
std::map< SoNode *, HECCellConstLink > HECMap
QMap< QString, SoSwitch * > switchMap
void systemcreate(StoreGateSvc *detstore)
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
void restoreFromState(QByteArray ba)
void buildPermanentSceneGraph(StoreGateSvc *detstore, SoSeparator *root)
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
static const FCALDetectorManager * fcalDetMgr()
static const EMECDetectorManager * emecDetMgr()
static void ensureInit(IVP1System *)
Definition VP1DetInfo.h:49
static const EMBDetectorManager * embDetMgr()
static const HECDetectorManager * hecDetMgr()
static bool hasTileGeometry()
static bool hasLArGeometry()
static void ensureInit(IVP1System *)