ATLAS Offline Software
VP1MissingEtHandle.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 VP1MissingEtHandle //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: July 2008 //
12 // Updated: Giorgi Gvaberidze (ggvaberi@cern.ch) //
13 // Updated: July 2010 //
14 // //
16 
19 #include "VP1Base/VP1Serialise.h"
22 
26 #include "CLHEP/Units/SystemOfUnits.h"
27 
28 #include <Inventor/nodes/SoSeparator.h>
29 #include <Inventor/nodes/SoRotationXYZ.h>
30 #include <Inventor/nodes/SoTranslation.h>
31 #include <Inventor/nodes/SoCone.h>
32 #include <Inventor/SoPath.h>
33 
34 #include <QColor>
35 
36 
38 double VP1MissingEtHandle::scale = 1.0;
39 bool VP1MissingEtHandle::shape = true;
40 
41 
42 //____________________________________________________________________
44 {
45  //updated: for prevent loading zero length system
46  static const MissingET* met = 0;
47 
48  //Get list of keys (only those that are not MissingEtTruth/MissingEtCalo as well):
50  QStringList keys = sg.getKeys<MissingET>();
51  for (QString key : sg.getKeys<MissingEtTruth>())
52  keys.removeAll(key);
53  for (QString key : sg.getKeys<MissingEtCalo>())
54  keys.removeAll(key);
55 
56  QList<VP1StdCollection*> l;
57  for (QString key : keys) {
58  //updated: for prevent loading zero length system
59  met = 0;
61  continue;
62  double length = met->et() * (200.0*CLHEP::cm/(100.0*CLHEP::GeV));
64  continue;
65  //-----------------------------------------------
66 
68  col->init();
69  l << col;
70  }
71  return l;
72 }
73 
74 //____________________________________________________________________
76 public:
77  QString key;
78  const MissingET* met = nullptr;
79  //Classification (purely for where/how the handle is displayed in
80  //the collection widget and for the default colour):
83 };
84 
85 
86 //____________________________________________________________________
88  :VP1StdCollection(sys,"VP1MissingEtHandle_"+key), m_d(new Imp)
89 {
90  m_d->key = key;
91  m_d->met = 0;
92 
93  if (m_d->key.startsWith("MET_"))
94  m_d->type = Imp::NORMAL;
95  else if (m_d->key.startsWith("ObjMET_"))
97  else
98  m_d->type = Imp::OTHER;
99 
100  //ggvaberi
101  m_base = 0;
102  m_arrow = 0;
103  m_dash = 0;
104 
105  m_length = 0.0;
106  m_phi = 0.0;
107  //-------------------
108 }
109 
110 //____________________________________________________________________
112 {
113  delete m_d;
114 
115  if(m_arrow){
116  m_arrow->removeAllChildren();
117  m_arrow->unref();
118  }
119 
120  if(m_dash){
121  m_dash->removeAllChildren();
122  m_dash->unref();
123  }
124 }
125 
126 //____________________________________________________________________
127 QString VP1MissingEtHandle::key() const
128 {
129  return m_d->key;
130 }
131 
132 //____________________________________________________________________
134 {
136  serialise.disableUnsavedChecks();
137  serialise.save(collTypeID());
138  serialise.save(key());//Since we truncate stuff in provideText(), we want to m_base the id on the full key.
139  return serialise.result();
140 }
141 
142 //____________________________________________________________________
144 {
145  if (m_d->key.startsWith("MET_"))
146  return m_d->key.right(m_d->key.count()-4);
147  else if (m_d->key.startsWith("ObjMET_"))
148  return m_d->key.right(m_d->key.count()-7);
149  return m_d->key;
150 }
151 
152 //____________________________________________________________________
154 {
155  if (m_d->type==Imp::NORMAL)
156  return "Standard";
157  else if (m_d->type==Imp::OBJECTBASED)
158  return "Object-Based";
159  else if (m_d->type==Imp::OTHER)
160  return "Other";
161  else
162  return "Unknown";
163 }
164 
165 //____________________________________________________________________
167 {
168  if (m_d->type==Imp::NORMAL)
169  return "Missing Et objects found by standard algorithms";
170  else if (m_d->type==Imp::OBJECTBASED)
171  return "Missing Et found by Object-Based algorithms";
172  else if (m_d->type==Imp::OTHER)
173  return "Missing ET objects not recognised as belonging to any other section";
174  else
175  return "Unknown";
176 }
177 
178 //____________________________________________________________________
180 {
181  if (m_d->type==Imp::OBJECTBASED)
182  return QColor::fromRgbF(0, 2./3., 0.5);
183  else
184  return QColor::fromRgbF(1, 2./3., 0.5);
185 }
186 
187 //____________________________________________________________________
189 {
190  VP1MaterialButton::setMaterialParameters( m, baseCol(), 0.2/*brightness*/ );
191 }
192 
193 //____________________________________________________________________
195 {
196  //Truncate to collSep to get correct highlighting:
197  int icollsep = p->findNode(collSep());
198  if (icollsep<0)
199  message("ERROR: Could not truncate picked path correctly");
200  else
201  p->truncate(icollsep+1);
202 }
203 
204 //____________________________________________________________________
205 QStringList VP1MissingEtHandle::baseInfo(const MissingET* met) const
206 {
207  if (!met)
208  return QStringList() << "ERROR: Nul MissingET pointer!";
209  QStringList l;
210  l << "Missing ET ["+key()+"]:";
211  l << " Et: "+str(met->et()/CLHEP::GeV)+" GeV";
212  l << " SumEt: "+str(met->sumet()/CLHEP::GeV)+" GeV";
213  l << " EtX: "+str(met->etx()/CLHEP::GeV)+" GeV";
214  l << " EtY: "+str(met->ety()/CLHEP::GeV)+" GeV";
215  l << " Phi: "+str(met->phi());
216  //Fixme: Add author (met->getSource() enum)
217  return l;
218 }
219 
220 //____________________________________________________________________
221 QStringList VP1MissingEtHandle::clicked(SoPath*pickedPath) const
222 {
223  truncateToCollSep(pickedPath);
224  return baseInfo(m_d->met);
225 }
226 
227 //____________________________________________________________________
229 {
230  //3D code for the m_arrow here is due to Moustapha Thioye:
231  //Updated by GGvaberi
232 
233  double length = met->et() * (200.0*CLHEP::cm/(100.0*CLHEP::GeV));//Fixme: Make scale factor (and thickness) adjustable.
234 
235  this->m_length = length;
236  this->m_phi = met->phi();
237 
238  SoRotationXYZ *finalRotation = new SoRotationXYZ();
239  finalRotation->axis=SoRotationXYZ::Z;
240  finalRotation->angle=-M_PI/2+ met->phi();
241 
242  //Translation
243  SoTranslation *translation1= new SoTranslation();
244  translation1->translation.setValue(0,0.5*0.75*m_length*scale,0);
245 
246  //Cylinder
247  SoCylinder *cyl = new SoCylinder();
248  cyl->height=0.75*m_length*scale;
249  cyl->radius=2.0*thickness;
250 
251  //Translation
252  SoTranslation *translation2= new SoTranslation();
253  translation2->translation.setValue(0,0.5*m_length*scale,0);
254 
255  //Cone
256  SoCone *cone = new SoCone();
257  cone->height=0.25*m_length*scale;
258  cone->bottomRadius= 4.0*thickness;
259 
260  //Arrow
261  m_arrow = new SoGroup;
262  m_arrow->addChild(finalRotation);
263  m_arrow->addChild(translation1);
264  m_arrow->addChild(cyl);
265  m_arrow->addChild(translation2);
266  m_arrow->addChild(cone);
267  m_arrow->ref();
268 
269  //Dash line
270  m_dash = new SoGroup;
271  SoRotationXYZ *r = new SoRotationXYZ();
272  r->axis=SoRotationXYZ::Z;
273  r->angle=-M_PI/2+ met->phi();
274  m_dash->addChild(r);
275 
276  SoTranslation *t= new SoTranslation();
277  t->translation.setValue(0, 0, 0);
278  m_dash->addChild(t);
279 
280  //Define line width
281  SoDrawStyle *drawStyle = new SoDrawStyle;
282  drawStyle->style.setValue(SoDrawStyle::LINES);
283  drawStyle->lineWidth.setValue(2.0 * thickness);
284  drawStyle->linePattern.setValue(0xFF00);
285  m_dash->addChild(drawStyle);
286 
287  //Define line connection
288  SoCoordinate3 *coords = new SoCoordinate3;
289  SbVec3f* vert = new SbVec3f[2];
290  vert[0] = SbVec3f(0.0, 0.0, 0.0);
291  vert[1] = SbVec3f(0.0, m_length * scale, 0.0);
292  coords->point.setValues(0, 2, vert);
293  delete [] vert;
294  m_dash->addChild(coords);
295 
296  SoLineSet *lineSet = new SoLineSet ;
297  lineSet->numVertices.set1Value(0, 2) ;
298  m_dash->addChild(lineSet);
299  m_dash->ref();
300 
301  m_base = new SoGroup;
302  if(shape)
303  m_base->addChild(m_arrow);
304  else
305  m_base->addChild(m_dash);
306 
307  collSep()->addChild(m_base);
308  //--------
309 }
310 
311 //____________________________________________________________________
313 {
315  return false;
316 
318  return true;
319 }
320 
321 //ggvaberi
323  if(!m_base)
324  return;
325 
326  //Arrow
327  SoTranslation *translation1= (SoTranslation*)m_arrow->getChild(1);
328  translation1->translation.setValue(0,0.5*0.75*m_length*scale,0);
329 
330  SoCylinder *cyl = (SoCylinder*)m_arrow->getChild(2);
331  cyl->height=0.75*m_length*scale;
332  cyl->radius=2.0*thickness;
333 
334  SoTranslation *translation2= (SoTranslation*)m_arrow->getChild(3);
335  translation2->translation.setValue(0,0.5*m_length*scale,0);
336 
337  SoCone *cone = (SoCone*)m_arrow->getChild(4);
338  cone->height=0.25*m_length*scale;
339  cone->bottomRadius= 4.0*thickness;
340 
341  //Dash
342  SoDrawStyle *drawStyle = (SoDrawStyle*)m_dash->getChild(2);
343  drawStyle->lineWidth.setValue(2.0 * thickness);
344 
345  SoCoordinate3 *coords = (SoCoordinate3*)m_dash->getChild(3);
346  SbVec3f* vert = new SbVec3f[2];
347  vert[0] = SbVec3f(0.0, 0.0, 0.0);
348  vert[1] = SbVec3f(0.0, m_length * scale, 0.0);
349  coords->point.setValues(0, 2, vert);
350  delete [] vert;
351 
352  m_base->removeAllChildren();
353  if(shape)
354  m_base->addChild(m_arrow);
355  else
356  m_base->addChild(m_dash);
357 }
358 
359 void VP1MissingEtHandle::useThickness(double thickness){
361 }
362 
365 }
366 
369 }
370 //--------
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
VP1Serialise.h
MissingEtTruth
Definition: MissingEtTruth.h:28
beamspotman.r
def r
Definition: beamspotman.py:676
MissingET.h
VP1Serialise
Definition: VP1Serialise.h:45
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
VP1MissingEtHandle::provideSection
virtual QString provideSection() const
Definition: VP1MissingEtHandle.cxx:153
VP1MissingEtHandle::Imp
Definition: VP1MissingEtHandle.cxx:75
RoiUtil::serialise
void serialise(const std::vector< const IRoiDescriptor * > &rois, roiserial_type &s)
serialise an entire vector of IRoiDescriptors
Definition: RoiSerialise.cxx:45
VP1MaterialButton.h
VP1StdCollection::collTypeID
qint32 collTypeID() const
Definition: VP1StdCollection.cxx:315
Monitored::Z
@ Z
Definition: HistogramFillerUtils.h:24
VP1MissingEtHandle::Imp::key
QString key
Definition: VP1MissingEtHandle.cxx:77
VP1MissingEtHandle::key
QString key() const
Definition: VP1MissingEtHandle.cxx:127
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP1MissingEtHandle
Definition: VP1MissingEtHandle.h:36
M_PI
#define M_PI
Definition: ActiveFraction.h:11
MissingEtCalo
Definition: MissingEtCalo.h:27
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
VP1MissingEtHandle::load
virtual bool load()
Definition: VP1MissingEtHandle.cxx:312
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
VP1MissingEtHandle::useThickness
static void useThickness(double)
Definition: VP1MissingEtHandle.cxx:359
LINES
bool LINES
Definition: computils.cxx:39
VP1MissingEtHandle::VP1MissingEtHandle
VP1MissingEtHandle(IVP1System *sys, const QString &key)
Definition: VP1MissingEtHandle.cxx:87
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
VP1MissingEtHandle::thickness
static double thickness
Definition: VP1MissingEtHandle.h:69
VP1MissingEtHandle::m_dash
SoGroup * m_dash
Definition: VP1MissingEtHandle.h:65
VP1SGContentsHelper::getKeys
QStringList getKeys() const
Definition: VP1SGContentsHelper.h:55
VP1MissingEtHandle::baseInfo
QStringList baseInfo(const MissingET *) const
Definition: VP1MissingEtHandle.cxx:205
VP1MissingEtHandle::assignDefaultMaterial
void assignDefaultMaterial(SoMaterial *) const
Definition: VP1MissingEtHandle.cxx:188
VP1MissingEtHandle::m_arrow
SoGroup * m_arrow
Definition: VP1MissingEtHandle.h:65
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
VP1MissingEtHandle::createCollections
static QList< VP1StdCollection * > createCollections(IVP1System *sys)
Definition: VP1MissingEtHandle.cxx:43
IVP1System
Definition: IVP1System.h:36
met
Definition: IMETSignificance.h:24
VP1MissingEtHandle::refresh
void refresh()
Definition: VP1MissingEtHandle.cxx:322
VP1MissingEtHandle::provideSectionToolTip
virtual QString provideSectionToolTip() const
Definition: VP1MissingEtHandle.cxx:166
VP1MaterialButton::setMaterialParameters
static void setMaterialParameters(SoMaterial *m, const QColor &, const double &brightness=0.0, const double &transp=0.0)
Definition: VP1MaterialButton.cxx:802
VP1MissingEtHandle::useShape
static void useShape(bool)
Definition: VP1MissingEtHandle.cxx:367
VP1MissingEtHandle::scale
static double scale
Definition: VP1MissingEtHandle.h:70
VP1MissingEtHandle::baseCol
virtual QColor baseCol() const
Definition: VP1MissingEtHandle.cxx:179
VP1MissingEtHandle::clicked
virtual QStringList clicked(SoPath *) const
Definition: VP1MissingEtHandle.cxx:221
MissingEtCalo.h
VP1MissingEtHandle::m_phi
double m_phi
Definition: VP1MissingEtHandle.h:66
VP1MissingEtHandle::m_d
Imp * m_d
Definition: VP1MissingEtHandle.h:61
VP1MissingEtHandle::Imp::met
const MissingET * met
Definition: VP1MissingEtHandle.cxx:78
VP1MissingEtHandle::Imp::NORMAL
@ NORMAL
Definition: VP1MissingEtHandle.cxx:81
VP1SGAccessHelper::retrieve
bool retrieve(const T *&, const QString &key) const
VP1MissingEtHandle::Imp::type
TYPE type
Definition: VP1MissingEtHandle.cxx:82
VP1HelperClassBase::systemBase
IVP1System * systemBase() const
Definition: VP1HelperClassBase.h:50
VP1MissingEtHandle::truncateToCollSep
void truncateToCollSep(SoPath *) const
Definition: VP1MissingEtHandle.cxx:194
VP1MissingEtHandle::Imp::OTHER
@ OTHER
Definition: VP1MissingEtHandle.cxx:81
VP1MissingEtHandle::addArrowToCollSep
void addArrowToCollSep(const MissingET *)
Definition: VP1MissingEtHandle.cxx:228
VP1MissingEtHandle::Imp::TYPE
TYPE
Definition: VP1MissingEtHandle.cxx:81
MissingEtTruth.h
VP1SGContentsHelper
Definition: VP1SGContentsHelper.h:26
query_example.col
col
Definition: query_example.py:7
VP1MissingEtHandle::m_base
SoGroup * m_base
Definition: VP1MissingEtHandle.h:65
MISSINGET_ZEROLENGTH
#define MISSINGET_ZEROLENGTH(x)
Definition: VP1MissingEtHandle.h:34
VP1MissingEtHandle::~VP1MissingEtHandle
virtual ~VP1MissingEtHandle()
Definition: VP1MissingEtHandle.cxx:111
VP1MissingEtHandle::m_length
double m_length
Definition: VP1MissingEtHandle.h:66
VP1MissingEtHandle::shape
static bool shape
Definition: VP1MissingEtHandle.h:71
MissingET
Definition: Reconstruction/MissingETEvent/MissingETEvent/MissingET.h:23
VP1StdCollection::collSep
SoSeparator * collSep() const
All 3D objects from this coll.
Definition: VP1StdCollection.cxx:212
VP1MissingEtHandle::useScale
static void useScale(double)
Definition: VP1MissingEtHandle.cxx:363
VP1MissingEtHandle.h
VP1HelperClassBase::message
void message(const QString &) const
Definition: VP1HelperClassBase.cxx:49
VP1MissingEtHandle::Imp::OBJECTBASED
@ OBJECTBASED
Definition: VP1MissingEtHandle.cxx:81
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
MissingET::phi
virtual double phi() const
Definition: MissingET.cxx:157
VP1StdCollection
Definition: VP1StdCollection.h:31
VP1SGAccessHelper
Definition: VP1SGAccessHelper.h:25
VP1MissingEtHandle::provideText
virtual QString provideText() const
Definition: VP1MissingEtHandle.cxx:143
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
VP1SGAccessHelper.h
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
VP1SGContentsHelper.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
VP1MissingEtHandle::providePersistifiableID
virtual QByteArray providePersistifiableID() const
Definition: VP1MissingEtHandle.cxx:133