ATLAS Offline Software
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 
8 #include "VP1Base/VP1Serialise.h"
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 {
26 public:
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"),
44  m_clockwork(new Clockwork())
45 {
49 }
50 
52 {
53  delete m_clockwork;
54  m_clockwork = 0;
55 }
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()));
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();
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();
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  }
139 
144 
149 }
150 
151 void 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";
178  if(VP1SGContentsHelper(this).contains<CaloCellContainer>(key)) {
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 
315 void VP1CaloHitLegoSystem::userPickedNode(SoNode* /*pickedNode*/, SoPath * /*pickedPath*/)
316 {
317 }
318 
320 {
322  VP1Serialise serialise(0/*version*/,this);
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  }
347  IVP13DSystemSimple::restoreFromState(state.restoreByteArray());
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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
VP1Serialise.h
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
VP1CaloHitLegoSystem::systemuncreate
void systemuncreate()
Definition: VP1CaloHitLegoSystem.cxx:92
VP1Deserialise.h
VP1Serialise
Definition: VP1Serialise.h:45
EMECDetectorElement
LAr EMEC Detector Element.
Definition: CaloDetectorElements.h:116
IVP13DSystemSimple
Definition: IVP13DSystemSimple.h:24
VP1CaloHitLegoSystem::Clockwork::emecSwitch
SoSwitch * emecSwitch[4]
Definition: VP1CaloHitLegoSystem.cxx:34
RoiUtil::serialise
void serialise(const std::vector< const IRoiDescriptor * > &rois, roiserial_type &s)
serialise an entire vector of IRoiDescriptors
Definition: RoiSerialise.cxx:45
VP1CaloHitLegoSystem::checkboxChanged
void checkboxChanged()
Definition: VP1CaloHitLegoSystem.cxx:289
VP1JobConfigInfo::ensureInit
static void ensureInit(IVP1System *)
Definition: VP1JobConfigInfo.h:30
VP1CaloHitLegoSystem::Clockwork::fcalSwitch
SoSwitch * fcalSwitch[3]
Definition: VP1CaloHitLegoSystem.cxx:32
VP1CaloHitLegoSystem::m_clockwork
Clockwork * m_clockwork
Definition: VP1CaloHitLegoSystem.h:43
VP1JobConfigInfo::hasTileGeometry
static bool hasTileGeometry()
Definition: VP1JobConfigInfo.cxx:133
VP1CaloHitLegoSystem::Clockwork::larEnergyScale
double larEnergyScale
Definition: VP1CaloHitLegoSystem.cxx:39
VP1JobConfigInfo::hasLArGeometry
static bool hasLArGeometry()
Definition: VP1JobConfigInfo.cxx:132
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP1CaloHitLegoSystem::userPickedNode
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
Definition: VP1CaloHitLegoSystem.cxx:315
skel.it
it
Definition: skel.GENtoEVGEN.py:396
M_PI
#define M_PI
Definition: ActiveFraction.h:11
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
VP1CaloHitLegoSystem::Clockwork::hecSwitch
SoSwitch * hecSwitch[4]
Definition: VP1CaloHitLegoSystem.cxx:33
VP1CaloHitLegoSystem::systemcreate
void systemcreate(StoreGateSvc *detstore)
Definition: VP1CaloHitLegoSystem.cxx:117
VP1CaloHitLegoSystem::~VP1CaloHitLegoSystem
~VP1CaloHitLegoSystem()
Definition: VP1CaloHitLegoSystem.cxx:51
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
VP1CaloHitLegoSystem::Clockwork::checkBoxNamesMap
QMap< QCheckBox *, QString > checkBoxNamesMap
Definition: VP1CaloHitLegoSystem.cxx:30
VP1CaloHitLegoSystem::Clockwork::checkBoxMap
QMap< QString, QCheckBox * > checkBoxMap
Definition: VP1CaloHitLegoSystem.cxx:29
EMBDetectorElement
LAr EMB Detector Element.
Definition: CaloDetectorElements.h:52
VP1CaloHitLegoSystem::saveState
QByteArray saveState()
Definition: VP1CaloHitLegoSystem.cxx:319
HECDetectorElement
LAr HEC Detector Element.
Definition: CaloDetectorElements.h:189
IVP1System::state
State state() const
Definition: IVP1System.cxx:129
IVP1System::saveState
virtual QByteArray saveState()
Definition: IVP1System.cxx:294
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
VP1CaloHitLegoSystem::Clockwork::highThresholdEnergy
double highThresholdEnergy
Definition: VP1CaloHitLegoSystem.cxx:38
lumiFormat.i
int i
Definition: lumiFormat.py:85
VP1CaloHitLegoSystem::buildController
QWidget * buildController()
Definition: VP1CaloHitLegoSystem.cxx:57
IVP13DSystemSimple::ensureBuildController
void ensureBuildController()
Definition: IVP13DSystemSimple.cxx:90
VP1Deserialise
Definition: VP1Deserialise.h:44
VP1CaloHitLegoSystem::restoreFromState
void restoreFromState(QByteArray ba)
Definition: VP1CaloHitLegoSystem.cxx:339
VP1CaloHitLegoSystem::buildEventSceneGraph
void buildEventSceneGraph(StoreGateSvc *sg, SoSeparator *root)
Definition: VP1CaloHitLegoSystem.cxx:171
grepfile.sep
sep
Definition: grepfile.py:38
VP1CaloHitLegoSystem::Clockwork::lowThresholdEnergy
double lowThresholdEnergy
Definition: VP1CaloHitLegoSystem.cxx:37
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
EMBDetectorElement::getEMBCell
EMBCellConstLink getEMBCell() const
EMB Cell description from LArReadoutGeometry.
Definition: CaloDetectorElements.h:77
VP1SGContentsHelper
Definition: VP1SGContentsHelper.h:26
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
VP1CaloHitLegoSystem::Clockwork::embSwitch
SoSwitch * embSwitch[4]
Definition: VP1CaloHitLegoSystem.cxx:35
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
VP1CaloHitLegoSystem::Clockwork
Definition: VP1CaloHitLegoSystem.cxx:25
VP1CaloHitLegoSystem::systemerase
void systemerase()
Definition: VP1CaloHitLegoSystem.cxx:156
VP1CaloHitLegoSystem::buildPermanentSceneGraph
void buildPermanentSceneGraph(StoreGateSvc *detstore, SoSeparator *root)
Definition: VP1CaloHitLegoSystem.cxx:151
VP1CaloHitLegoSystem.h
VP1JobConfigInfo.h
VP1SGAccessHelper
Definition: VP1SGAccessHelper.h:25
HECDetectorElement::getHECCell
HECCellConstLink getHECCell() const
HEC Cell description from LArReadoutGeometry.
Definition: CaloDetectorElements.h:214
VP1CaloHitLegoSystem::Clockwork::switchMap
QMap< QString, SoSwitch * > switchMap
Definition: VP1CaloHitLegoSystem.cxx:28
VP1CaloHitLegoSystem::VP1CaloHitLegoSystem
VP1CaloHitLegoSystem()
Definition: VP1CaloHitLegoSystem.cxx:42
VP1SGAccessHelper.h
IVP1System::message
void message(const QString &) const
Definition: IVP1System.cxx:336
CaloDetectorElements.h
Calo Subsystem specific Detector Elements + Dummy element for testing.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
VP1SGContentsHelper.h
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