ATLAS Offline Software
CaloClusterSysController.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Implementation of class CaloClusterSysController //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: July 2008 //
12 // //
14 
15 #define VP1IMPVARNAME m_d
16 
19 #include "ui_vp1caloclustercontrollerform.h"
20 #include "ui_calocluster_settings_display_form.h"
21 #include "ui_calocluster_settings_interactions_form.h"
22 #include "ui_calocluster_settings_cuts_form.h"
23 #include "VP1Base/VP1Serialise.h"
24 #include "VP1Base/VP1Deserialise.h"
26 #include <cmath>
27 #include "CLHEP/Units/SystemOfUnits.h"
28 
29 //____________________________________________________________________
31 public:
32  Ui::VP1CaloClusterControllerForm ui{};
33  Ui::CaloClusterSysSettingsCutsForm ui_cuts{};
34  Ui::CaloClusterSysSettingsInteractionsForm ui_int{};
35  Ui::CaloClusterSysSettingsDisplayForm ui_display{};
37 
38  double gui_mostEnergetic = 0.0;
39 
40  QPair<bool,double> last_scale;
43  QList<VP1Interval> last_cutAllowedPhi;//All off: empty list. All on: list with one entry: ]-inf,inf[
46 };
47 
48 //____________________________________________________________________
49 QString CaloClusterSysController::toString( const QPair<bool,double>& par )
50 {
51  return "<"+QString(par.first?"log":"linear")+", "+QString::number(par.second/(CLHEP::cm/CLHEP::GeV))+" cm/GeV>";
52 }
53 
54 //____________________________________________________________________
56  : VP1Controller(sys,"CaloClusterSysController"), m_d(new Imp)
57 {
58  m_d->ui.setupUi(this);
60 
62  setupCollWidgetInScrollArea(m_d->ui.collWidgetScrollArea,m_d->collWidget);
63 
64  initDialog(m_d->ui_display, m_d->ui.pushButton_settings_display);
65  initDialog(m_d->ui_int, m_d->ui.pushButton_settings_interactions);
66  initDialog(m_d->ui_cuts, m_d->ui.pushButton_settings_cuts);
67 
68  m_d->ui_display.widget_drawOptions->setLineWidths(2.0);
69  m_d->ui_display.widget_drawOptions->setPointSizesDisabled();
70  m_d->ui_display.widget_drawOptions->setBaseLightingDisabled();
71  m_d->ui_display.widget_drawOptions->setComplexityDisabled();
72 
73  m_d->ui_cuts.etaPhiCutWidget->setEtaCutEnabled(false);
74 
76  // Setup connections which monitor changes in the controller so that we may emit signals as appropriate: //
78 
79  // -> Eta cut presets:
80  connect(m_d->ui_cuts.toolButton_quicketa_barrel,SIGNAL(clicked()),this,SLOT(etaCutPresetButtonTriggered()));
81  connect(m_d->ui_cuts.toolButton_quicketa_endcapA,SIGNAL(clicked()),this,SLOT(etaCutPresetButtonTriggered()));
82  connect(m_d->ui_cuts.toolButton_quicketa_endcapC,SIGNAL(clicked()),this,SLOT(etaCutPresetButtonTriggered()));
83 
84  // -> scale:
86  connectToLastUpdateSlot(m_d->ui_display.checkBox_logscale);
87  connectToLastUpdateSlot(m_d->ui_display.radioButton_relativeScale);
88  connectToLastUpdateSlot(m_d->ui_display.doubleSpinBox_lengthOfMostEnergetic);
89  connectToLastUpdateSlot(m_d->ui_display.doubleSpinBox_lengthOf10GeV);
90 
91  // -> cutAllowedEnergies:
93  connectToLastUpdateSlot(m_d->ui_cuts.checkBox_Emin);
94  connectToLastUpdateSlot(m_d->ui_cuts.checkBox_Emax);
95  connectToLastUpdateSlot(m_d->ui_cuts.doubleSpinBox_Emin);
96  connectToLastUpdateSlot(m_d->ui_cuts.doubleSpinBox_Emax);
97 
98  // -> cutAllowedEta:
100  connectToLastUpdateSlot(m_d->ui_cuts.etaPhiCutWidget,SIGNAL(allowedEtaChanged(const VP1Interval&)));
101 
102  // -> cutAllowedPhi:
104  connectToLastUpdateSlot(m_d->ui_cuts.etaPhiCutWidget,SIGNAL(allowedPhiChanged(const QList<VP1Interval>&)));
105 
106  // -> showVolumeOutLines
108  connectToLastUpdateSlot(m_d->ui_display.checkBox_showVolumeOutLines);
109 
110  // -> useTransverseEnergies
112  connectToLastUpdateSlot(m_d->ui.radioButton_energyMode_Et);
113  connectToLastUpdateSlot(m_d->ui.radioButton_energyMode_E);
114 
115  initLastVars();
116 }
117 
118 //____________________________________________________________________
120 {
121  delete m_d;
122 }
123 
124 
125 //____________________________________________________________________
127 {
128  return 3;
129 }
130 
131 //____________________________________________________________________
133 {
134  //version 0 had an integer here
135  s.save(m_d->ui_display.checkBox_logscale);
136  s.save(m_d->ui_display.radioButton_relativeScale,m_d->ui_display.radioButton_absoluteScale);
137  s.save(m_d->ui_display.doubleSpinBox_lengthOfMostEnergetic);
138  s.save(m_d->ui_display.doubleSpinBox_lengthOf10GeV);
139  s.save(m_d->ui_cuts.checkBox_Emin);
140  s.save(m_d->ui_cuts.doubleSpinBox_Emin);
141  s.save(m_d->ui_cuts.checkBox_Emax);
142  s.save(m_d->ui_cuts.doubleSpinBox_Emax);
143  s.save(m_d->ui_cuts.etaPhiCutWidget);
144  s.save(m_d->ui_int.checkBox_printinfo);//Version 1+
145  s.save(m_d->ui_int.checkBox_printinfo_verbose);//Version 1+
146  s.save(m_d->ui_int.checkBox_zoom);//Version 1+
147  s.save(m_d->ui_display.checkBox_showVolumeOutLines);//Version 2+
148  s.save(m_d->ui_display.widget_drawOptions);//Version 2+
149  s.save(m_d->ui.radioButton_energyMode_Et,m_d->ui.radioButton_energyMode_E);//Version 3+
150 }
151 
152 //____________________________________________________________________
154 {
155  if (s.version()<0||s.version()>3) {
156  message("Warning: State data in .vp1 file has unsupported version ("+str(s.version())+")");
157  return;
158  }
159  if (s.version()==0)
160  s.ignoreInt();
161  s.restore(m_d->ui_display.checkBox_logscale);
162  s.restore(m_d->ui_display.radioButton_relativeScale,m_d->ui_display.radioButton_absoluteScale);
163  s.restore(m_d->ui_display.doubleSpinBox_lengthOfMostEnergetic);
164  s.restore(m_d->ui_display.doubleSpinBox_lengthOf10GeV);
165  s.restore(m_d->ui_cuts.checkBox_Emin);
166  s.restore(m_d->ui_cuts.doubleSpinBox_Emin);
167  s.restore(m_d->ui_cuts.checkBox_Emax);
168  s.restore(m_d->ui_cuts.doubleSpinBox_Emax);
169  s.restore(m_d->ui_cuts.etaPhiCutWidget);
170  if (s.version()>=1) {
171  s.restore(m_d->ui_int.checkBox_printinfo);
172  s.restore(m_d->ui_int.checkBox_printinfo_verbose);
173  s.restore(m_d->ui_int.checkBox_zoom);
174  }
175  if (s.version()>=2) {
176  s.restore(m_d->ui_display.checkBox_showVolumeOutLines);
177  s.restore(m_d->ui_display.widget_drawOptions);
178  }
179  if (s.version()>=3)
180  s.restore(m_d->ui.radioButton_energyMode_Et,m_d->ui.radioButton_energyMode_E);
181 }
182 
183 //____________________________________________________________________
185 {
186  return m_d->collWidget;
187 }
188 
189 
190 //____________________________________________________________________
192 {
193  const double cracketa = VP1CaloClusterCollection::crackEta();
194  bool save = m_d->ui_cuts.etaPhiCutWidget->blockSignals(true);
195 
196  if (sender()==m_d->ui_cuts.toolButton_quicketa_barrel)
197  m_d->ui_cuts.etaPhiCutWidget->setEtaCut(cracketa);
198  else if (sender()==m_d->ui_cuts.toolButton_quicketa_endcapA)
199  m_d->ui_cuts.etaPhiCutWidget->setEtaCut(cracketa,9.0);
200  else if (sender()==m_d->ui_cuts.toolButton_quicketa_endcapC)
201  m_d->ui_cuts.etaPhiCutWidget->setEtaCut(-9.0,-cracketa);
202  else
203  message("ERROR: Unknown sender() in etaCutPresetButtonTriggered() slot.");
204 
205  m_d->ui_cuts.etaPhiCutWidget->blockSignals(save);
207 }
208 
209 //____________________________________________________________________
211 {
212  return m_d->ui_display.widget_drawOptions->drawOptionsGroup();
213 }
214 
215 //____________________________________________________________________
216 bool CaloClusterSysController::printInfoOnClick() const { return m_d->ui_int.checkBox_printinfo->isChecked(); }
217 bool CaloClusterSysController::printVerboseInfoOnClick() const { return m_d->ui_int.checkBox_printinfo_verbose->isChecked(); }
218 bool CaloClusterSysController::zoomOnClick() const { return m_d->ui_int.checkBox_zoom->isChecked(); }
219 
220 //____________________________________________________________________
221 QPair<bool,double> CaloClusterSysController::scale() const
222 {
223  const bool relative = m_d->ui_display.radioButton_relativeScale->isChecked();
224  const bool logscale = m_d->ui_display.checkBox_logscale->isChecked();
225 
226  double highestvisibleenergy=0*CLHEP::eV;
228  VP1CaloClusterCollection* col = dynamic_cast<VP1CaloClusterCollection*>(stdcol);
229  if ( col && highestvisibleenergy < col->highestVisibleClusterEnergy() )
230  highestvisibleenergy = col->highestVisibleClusterEnergy();
231  }
232  if (m_d->gui_mostEnergetic!=highestvisibleenergy) {
233  m_d->gui_mostEnergetic=highestvisibleenergy;
234  m_d->ui_display.label_current_most_energetic->setText("Current value: "+QString::number(m_d->gui_mostEnergetic/CLHEP::GeV,'f',2)+" GeV");
235  }
236 
237  const double length = (relative ? m_d->ui_display.doubleSpinBox_lengthOfMostEnergetic->value()*CLHEP::m
238  : m_d->ui_display.doubleSpinBox_lengthOf10GeV->value()*CLHEP::m );
239  const double energy = relative ? highestvisibleenergy : 10*CLHEP::GeV;
240  const double minscale = 1*CLHEP::mm/(1*CLHEP::GeV);
241  const double maxscale = 1*CLHEP::m/(1*CLHEP::MeV);
242  double scl;
243  if (energy<=0)
244  scl = maxscale;
245  else
246  scl = logscale ? length/log(1+fabs(energy)) :length/energy;
247  if (scl!=scl||scl>maxscale)
248  scl = maxscale;
249  if (scl<minscale)
250  scl = minscale;
251  return QPair<bool,double>(logscale,scl);
252 }
253 
254 //____________________________________________________________________
256 {
257  const double min = (m_d->ui_cuts.checkBox_Emin->isChecked() ? m_d->ui_cuts.doubleSpinBox_Emin->value()*CLHEP::GeV : -std::numeric_limits<double>::infinity());
258  const double max = (m_d->ui_cuts.checkBox_Emax->isChecked() ? m_d->ui_cuts.doubleSpinBox_Emax->value()*CLHEP::GeV : std::numeric_limits<double>::infinity());
259  if (max<min)
260  return VP1Interval();
261  return VP1Interval( min, max );
262 }
263 
264 //____________________________________________________________________
266 {
267  return m_d->ui_cuts.etaPhiCutWidget->allowedEta();
268 }
269 
270 //____________________________________________________________________
271 QList<VP1Interval> CaloClusterSysController::cutAllowedPhi() const
272 {
273  return m_d->ui_cuts.etaPhiCutWidget->allowedPhi();
274 }
275 
276 //____________________________________________________________________
278 {
279  return m_d->ui_display.checkBox_showVolumeOutLines->isChecked();
280 }
281 
283 {
284  return m_d->ui.radioButton_energyMode_Et->isChecked();
285 }
286 
288 // Test for possible changes in values and emit signals as appropriate:
289 // (possibleChange_XXX() slots code provided by macros)
290 #define VP1CONTROLLERCLASSNAME CaloClusterSysController
292 POSSIBLECHANGE_IMP(cutAllowedEnergies)
293 POSSIBLECHANGE_IMP(cutAllowedEta)
294 POSSIBLECHANGE_IMP(cutAllowedPhi)
296 POSSIBLECHANGE_IMP(showVolumeOutLines)
297 POSSIBLECHANGE_IMP(useTransverseEnergies)
VP1Serialise.h
VP1Controller::addUpdateSlot
const char * addUpdateSlot(const char *slot)
Definition: VP1Controller.cxx:318
CaloClusterSysController::useTransverseEnergies
bool useTransverseEnergies() const
Definition: CaloClusterSysController.cxx:282
VP1Controller::setupCollWidgetInScrollArea
void setupCollWidgetInScrollArea(QScrollArea *scrollarea, VP1CollectionWidget *collWidget)
Definition: VP1Controller.cxx:255
CaloClusterSysController::possibleChange_cutAllowedEta
void possibleChange_cutAllowedEta()
POSSIBLECHANGE_IMP
#define POSSIBLECHANGE_IMP(x)
Definition: VP1ControllerMacros.h:18
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VP1Deserialise.h
CaloClusterSysController::CaloClusterSysController
CaloClusterSysController(IVP1System *sys)
Definition: CaloClusterSysController.cxx:55
VP1Serialise
Definition: VP1Serialise.h:45
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
CaloClusterSysController::Imp::collWidget
VP1CollectionWidget * collWidget
Definition: CaloClusterSysController.cxx:36
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
CaloClusterSysController::actualRestoreSettings
void actualRestoreSettings(VP1Deserialise &)
Definition: CaloClusterSysController.cxx:153
CaloClusterSysController::possibleChange_cutAllowedEnergies
void possibleChange_cutAllowedEnergies()
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
python.SystemOfUnits.MeV
int MeV
Definition: SystemOfUnits.py:154
VP1Controller::initDialog
void initDialog(T &theUI, QPushButton *launchbutton, QAbstractButton *enabledButton=0)
Definition: VP1Controller.h:144
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
CaloClusterSysController::cutAllowedEta
VP1Interval cutAllowedEta() const
Definition: CaloClusterSysController.cxx:265
CaloClusterSysController::scale
QPair< bool, double > scale() const
Definition: CaloClusterSysController.cxx:221
CaloClusterSysController::Imp::last_cutAllowedEta
VP1Interval last_cutAllowedEta
Definition: CaloClusterSysController.cxx:42
CaloClusterSysController::Imp::ui
Ui::VP1CaloClusterControllerForm ui
Definition: CaloClusterSysController.cxx:32
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
CaloClusterSysController::~CaloClusterSysController
virtual ~CaloClusterSysController()
Definition: CaloClusterSysController.cxx:119
VP1Controller::connectToLastUpdateSlot
void connectToLastUpdateSlot(QObject *sender, const char *signal)
Definition: VP1Controller.cxx:327
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
VP1CollectionWidget.h
CaloClusterSysController::printInfoOnClick
bool printInfoOnClick() const
Definition: CaloClusterSysController.cxx:216
CaloClusterSysController::Imp::ui_cuts
Ui::CaloClusterSysSettingsCutsForm ui_cuts
Definition: CaloClusterSysController.cxx:33
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
CaloClusterSysController::drawOptions
SoGroup * drawOptions() const
Definition: CaloClusterSysController.cxx:210
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:178
CaloClusterSysController::Imp::last_showVolumeOutLines
bool last_showVolumeOutLines
Definition: CaloClusterSysController.cxx:44
IVP1System
Definition: IVP1System.h:36
VP1CaloClusterCollection.h
CaloClusterSysController::toString
static QString toString(const T &t)
Definition: CaloClusterSysController.h:84
CaloClusterSysController::possibleChange_scale
void possibleChange_scale()
CaloClusterSysController::Imp::gui_mostEnergetic
double gui_mostEnergetic
Definition: CaloClusterSysController.cxx:38
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
VP1CaloClusterCollection
Definition: VP1CaloClusterCollection.h:28
CaloClusterSysController::collWidget
VP1CollectionWidget * collWidget() const
Definition: CaloClusterSysController.cxx:184
CaloClusterSysController::Imp::last_cutAllowedPhi
QList< VP1Interval > last_cutAllowedPhi
Definition: CaloClusterSysController.cxx:43
CaloClusterSysController::cutAllowedPhi
QList< VP1Interval > cutAllowedPhi() const
Definition: CaloClusterSysController.cxx:271
VP1Deserialise
Definition: VP1Deserialise.h:44
CaloClusterSysController::etaCutPresetButtonTriggered
void etaCutPresetButtonTriggered()
Definition: CaloClusterSysController.cxx:191
CaloClusterSysController::m_d
Imp * m_d
Definition: CaloClusterSysController.h:80
VP1Controller
Definition: VP1Controller.h:45
CaloClusterSysController::Imp::ui_display
Ui::CaloClusterSysSettingsDisplayForm ui_display
Definition: CaloClusterSysController.cxx:35
CaloClusterSysController::actualSaveSettings
void actualSaveSettings(VP1Serialise &) const
Definition: CaloClusterSysController.cxx:132
python.selection.number
number
Definition: selection.py:20
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
python.SystemOfUnits.eV
int eV
Definition: SystemOfUnits.py:155
CaloClusterSysController::Imp
Definition: CaloClusterSysController.cxx:30
CaloClusterSysController.h
VP1CollectionWidget::visibleStdCollections
QList< VP1StdCollection * > visibleStdCollections() const
Definition: VP1CollectionWidget.cxx:330
VP1CaloClusterCollection::crackEta
static double crackEta()
Definition: VP1CaloClusterCollection.cxx:158
query_example.col
col
Definition: query_example.py:7
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
CaloClusterSysController::possibleChange_useTransverseEnergies
void possibleChange_useTransverseEnergies()
CaloClusterSysController::Imp::last_cutAllowedEnergies
VP1Interval last_cutAllowedEnergies
Definition: CaloClusterSysController.cxx:41
VP1Interval
Definition: VP1Interval.h:23
CaloClusterSysController::printVerboseInfoOnClick
bool printVerboseInfoOnClick() const
Definition: CaloClusterSysController.cxx:217
VP1CollectionWidget
Definition: VP1CollectionWidget.h:32
CaloClusterSysController::Imp::ui_int
Ui::CaloClusterSysSettingsInteractionsForm ui_int
Definition: CaloClusterSysController.cxx:34
CaloClusterSysController::currentSettingsVersion
int currentSettingsVersion() const
Definition: CaloClusterSysController.cxx:126
CaloClusterSysController::cutAllowedEnergies
VP1Interval cutAllowedEnergies() const
Definition: CaloClusterSysController.cxx:255
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CaloClusterSysController::possibleChange_showVolumeOutLines
void possibleChange_showVolumeOutLines()
CaloClusterSysController::Imp::last_useTransverseEnergies
bool last_useTransverseEnergies
Definition: CaloClusterSysController.cxx:45
CaloClusterSysController::Imp::last_scale
QPair< bool, double > last_scale
Definition: CaloClusterSysController.cxx:40
VP1HelperClassBase::message
void message(const QString &) const
Definition: VP1HelperClassBase.cxx:49
CaloClusterSysController::zoomOnClick
bool zoomOnClick() const
Definition: CaloClusterSysController.cxx:218
VP1StdCollection
Definition: VP1StdCollection.h:31
CaloClusterSysController::showVolumeOutLines
bool showVolumeOutLines() const
Definition: CaloClusterSysController.cxx:277
CaloClusterSysController::possibleChange_cutAllowedPhi
void possibleChange_cutAllowedPhi()
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
VP1Controller::initLastVars
void initLastVars()
Definition: VP1Controller.cxx:68
VP1ControllerMacros.h