ATLAS Offline Software
Loading...
Searching...
No Matches
VP1MissingEtHandle.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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
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
38double VP1MissingEtHandle::scale = 1.0;
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):
49 VP1SGContentsHelper sg(sys);
50 QStringList keys = sg.getKeys<MissingET>();
51 for (const QString& key : sg.getKeys<MissingEtTruth>())
52 keys.removeAll(key);
53 for (const QString& key : sg.getKeys<MissingEtCalo>())
54 keys.removeAll(key);
55
56 QList<VP1StdCollection*> l;
57 for (const QString& key : keys) {
58 //updated: for prevent loading zero length system
59 met = 0;
60 if(!VP1SGAccessHelper(sys).retrieve(met, key))
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//____________________________________________________________________
76public:
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_"))
96 m_d->type = Imp::OBJECTBASED;
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//____________________________________________________________________
127const QString& VP1MissingEtHandle::key() const
128{
129 return m_d->key;
130}
131
132//____________________________________________________________________
134{
135 VP1Serialise serialise(0);
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//____________________________________________________________________
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//____________________________________________________________________
221QStringList 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{
314 if (!VP1SGAccessHelper(systemBase()).retrieve(m_d->met,m_d->key))
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
362
366
370//--------
#define M_PI
double length(const pvec &v)
if(febId1==febId2)
#define MISSINGET_ZEROLENGTH(x)
void message(const QString &) const
IVP1System * systemBase() const
static void setMaterialParameters(SoMaterial *m, const QColor &, const double &brightness=0.0, const double &transp=0.0)
const QString & key() const
virtual QColor baseCol() const
static void useThickness(double)
QStringList baseInfo(const MissingET *) const
virtual QString provideText() const
virtual QStringList clicked(SoPath *) const
static void useShape(bool)
VP1MissingEtHandle(IVP1System *sys, const QString &key)
virtual QByteArray providePersistifiableID() const
virtual QString provideSection() const
void truncateToCollSep(SoPath *) const
virtual QString provideSectionToolTip() const
void assignDefaultMaterial(SoMaterial *) const
void addArrowToCollSep(const MissingET *)
static void useScale(double)
static QList< VP1StdCollection * > createCollections(IVP1System *sys)
QStringList getKeys() const
virtual void init(VP1MaterialButtonBase *button=0)
SoSeparator * collSep() const
All 3D objects from this coll.
qint32 collTypeID() const
VP1StdCollection(IVP1System *, const QString &helperClassName)
int r
Definition globals.cxx:22